Taints the non-acquire RMW's store address with the load part
[oota-llvm.git] / test / CodeGen / AMDGPU / udiv.ll
1 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
2 ; RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
4
5 ; FUNC-LABEL: {{^}}udiv_i32:
6 ; EG-NOT: SETGE_INT
7 ; EG: CF_END
8 define void @udiv_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
9   %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
10   %a = load i32, i32 addrspace(1) * %in
11   %b = load i32, i32 addrspace(1) * %b_ptr
12   %result = udiv i32 %a, %b
13   store i32 %result, i32 addrspace(1)* %out
14   ret void
15 }
16
17 ; FUNC-LABEL: {{^}}s_udiv_i32:
18
19 define void @s_udiv_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) {
20   %result = udiv i32 %a, %b
21   store i32 %result, i32 addrspace(1)* %out
22   ret void
23 }
24
25
26 ; The code generated by udiv is long and complex and may frequently
27 ; change. The goal of this test is to make sure the ISel doesn't fail
28 ; when it gets a v4i32 udiv
29
30 ; FUNC-LABEL: {{^}}udiv_v2i32:
31 ; EG: CF_END
32
33 ; SI: s_endpgm
34 define void @udiv_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %in) {
35   %b_ptr = getelementptr <2 x i32>, <2 x i32> addrspace(1)* %in, i32 1
36   %a = load <2 x i32>, <2 x i32> addrspace(1) * %in
37   %b = load <2 x i32>, <2 x i32> addrspace(1) * %b_ptr
38   %result = udiv <2 x i32> %a, %b
39   store <2 x i32> %result, <2 x i32> addrspace(1)* %out
40   ret void
41 }
42
43 ; FUNC-LABEL: {{^}}udiv_v4i32:
44 ; EG: CF_END
45 ; SI: s_endpgm
46 define void @udiv_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) {
47   %b_ptr = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %in, i32 1
48   %a = load <4 x i32>, <4 x i32> addrspace(1) * %in
49   %b = load <4 x i32>, <4 x i32> addrspace(1) * %b_ptr
50   %result = udiv <4 x i32> %a, %b
51   store <4 x i32> %result, <4 x i32> addrspace(1)* %out
52   ret void
53 }
54
55 ; FUNC-LABEL: {{^}}udiv_i32_div_pow2:
56 ; SI: buffer_load_dword [[VAL:v[0-9]+]]
57 ; SI: v_lshrrev_b32_e32 [[RESULT:v[0-9]+]], 4, [[VAL]]
58 ; SI: buffer_store_dword [[RESULT]]
59 define void @udiv_i32_div_pow2(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
60   %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
61   %a = load i32, i32 addrspace(1)* %in
62   %result = udiv i32 %a, 16
63   store i32 %result, i32 addrspace(1)* %out
64   ret void
65 }
66
67 ; FUNC-LABEL: {{^}}udiv_i32_div_k_even:
68 ; SI-DAG: buffer_load_dword [[VAL:v[0-9]+]]
69 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0xfabbd9c1
70 ; SI: v_mul_hi_u32 [[MULHI:v[0-9]+]], [[K]], [[VAL]]
71 ; SI: v_lshrrev_b32_e32 [[RESULT:v[0-9]+]], 25, [[MULHI]]
72 ; SI: buffer_store_dword [[RESULT]]
73 define void @udiv_i32_div_k_even(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
74   %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
75   %a = load i32, i32 addrspace(1)* %in
76   %result = udiv i32 %a, 34259182
77   store i32 %result, i32 addrspace(1)* %out
78   ret void
79 }
80
81 ; FUNC-LABEL: {{^}}udiv_i32_div_k_odd:
82 ; SI-DAG: buffer_load_dword [[VAL:v[0-9]+]]
83 ; SI-DAG: v_mov_b32_e32 [[K:v[0-9]+]], 0x7d5deca3
84 ; SI: v_mul_hi_u32 [[MULHI:v[0-9]+]], [[K]], [[VAL]]
85 ; SI: v_lshrrev_b32_e32 [[RESULT:v[0-9]+]], 24, [[MULHI]]
86 ; SI: buffer_store_dword [[RESULT]]
87 define void @udiv_i32_div_k_odd(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
88   %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
89   %a = load i32, i32 addrspace(1)* %in
90   %result = udiv i32 %a, 34259183
91   store i32 %result, i32 addrspace(1)* %out
92   ret void
93 }