diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2015-01-21 22:56:15 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2015-01-21 22:56:15 +0000 |
commit | b45c78bc2ce7a569f499b827d193797ab62d03f7 (patch) | |
tree | 28ce44a3bcec49a648d4e28b63014fb27f46bfcf /llvm | |
parent | c1988f384c9d792da7289fc3ef450b5156d47ff3 (diff) | |
download | bcm5719-llvm-b45c78bc2ce7a569f499b827d193797ab62d03f7.tar.gz bcm5719-llvm-b45c78bc2ce7a569f499b827d193797ab62d03f7.zip |
R600: Add checks for urem/srem by a constant
Make sure this uses the faster expansion using magic constants
to avoid the full division path.
llvm-svn: 226734
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/test/CodeGen/R600/srem.ll | 15 | ||||
-rw-r--r-- | llvm/test/CodeGen/R600/urem.ll | 15 |
2 files changed, 29 insertions, 1 deletions
diff --git a/llvm/test/CodeGen/R600/srem.ll b/llvm/test/CodeGen/R600/srem.ll index e9156b16481..ea96c39fb44 100644 --- a/llvm/test/CodeGen/R600/srem.ll +++ b/llvm/test/CodeGen/R600/srem.ll @@ -1,4 +1,4 @@ -; RUN: llc -march=amdgcn -mcpu=SI < %s +; RUN: llc -march=amdgcn -mcpu=SI < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s ; RUN: llc -march=r600 -mcpu=redwood < %s define void @srem_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) { @@ -17,6 +17,19 @@ define void @srem_i32_4(i32 addrspace(1)* %out, i32 addrspace(1)* %in) { ret void } +; FUNC-LABEL: {{^}}srem_i32_7: +; SI: v_mov_b32_e32 [[MAGIC:v[0-9]+]], 0x92492493 +; SI: v_mul_hi_i32 {{v[0-9]+}}, [[MAGIC]], +; SI: v_mul_lo_i32 +; SI: v_sub_i32 +; SI: s_endpgm +define void @srem_i32_7(i32 addrspace(1)* %out, i32 addrspace(1)* %in) { + %num = load i32 addrspace(1) * %in + %result = srem i32 %num, 7 + store i32 %result, i32 addrspace(1)* %out + ret void +} + define void @srem_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %in) { %den_ptr = getelementptr <2 x i32> addrspace(1)* %in, i32 1 %num = load <2 x i32> addrspace(1) * %in diff --git a/llvm/test/CodeGen/R600/urem.ll b/llvm/test/CodeGen/R600/urem.ll index daa32446146..a58a550f823 100644 --- a/llvm/test/CodeGen/R600/urem.ll +++ b/llvm/test/CodeGen/R600/urem.ll @@ -17,6 +17,21 @@ define void @test_urem_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) { ret void } +; FUNC-LABEL: {{^}}test_urem_i32_7: +; SI: v_mov_b32_e32 [[MAGIC:v[0-9]+]], 0x24924925 +; SI: v_mul_hi_u32 {{v[0-9]+}}, [[MAGIC]] +; SI: v_subrev_i32 +; SI: v_mul_lo_i32 +; SI: v_sub_i32 +; SI: buffer_store_dword +; SI: s_endpgm +define void @test_urem_i32_7(i32 addrspace(1)* %out, i32 addrspace(1)* %in) { + %num = load i32 addrspace(1) * %in + %result = urem i32 %num, 7 + store i32 %result, i32 addrspace(1)* %out + ret void +} + ; FUNC-LABEL: {{^}}test_urem_v2i32: ; SI: s_endpgm ; EG: CF_END |