• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
4
5; FUNC-LABEL: {{^}}udiv_i32:
6; EG-NOT: SETGE_INT
7; EG: CF_END
8define 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
19define 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
34define 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
46define 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]]
59define 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]]
73define 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]]
87define 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}
94
95; FUNC-LABEL: {{^}}v_udiv_i8:
96; SI: v_rcp_f32
97; SI: v_and_b32_e32 [[TRUNC:v[0-9]+]], 0xff, v{{[0-9]+}}
98; SI: buffer_store_dword [[TRUNC]]
99define void @v_udiv_i8(i32 addrspace(1)* %out, i8 addrspace(1)* %in) {
100  %den_ptr = getelementptr i8, i8 addrspace(1)* %in, i8 1
101  %num = load i8, i8 addrspace(1) * %in
102  %den = load i8, i8 addrspace(1) * %den_ptr
103  %result = udiv i8 %num, %den
104  %result.ext = zext i8 %result to i32
105  store i32 %result.ext, i32 addrspace(1)* %out
106  ret void
107}
108
109; FUNC-LABEL: {{^}}v_udiv_i16:
110; SI: v_rcp_f32
111; SI: v_and_b32_e32 [[TRUNC:v[0-9]+]], 0xffff, v{{[0-9]+}}
112; SI: buffer_store_dword [[TRUNC]]
113define void @v_udiv_i16(i32 addrspace(1)* %out, i16 addrspace(1)* %in) {
114  %den_ptr = getelementptr i16, i16 addrspace(1)* %in, i16 1
115  %num = load i16, i16 addrspace(1) * %in
116  %den = load i16, i16 addrspace(1) * %den_ptr
117  %result = udiv i16 %num, %den
118  %result.ext = zext i16 %result to i32
119  store i32 %result.ext, i32 addrspace(1)* %out
120  ret void
121}
122
123; FUNC-LABEL: {{^}}v_udiv_i23:
124; SI: v_rcp_f32
125; SI: v_and_b32_e32 [[TRUNC:v[0-9]+]], 0x7fffff, v{{[0-9]+}}
126; SI: buffer_store_dword [[TRUNC]]
127define void @v_udiv_i23(i32 addrspace(1)* %out, i23 addrspace(1)* %in) {
128  %den_ptr = getelementptr i23, i23 addrspace(1)* %in, i23 1
129  %num = load i23, i23 addrspace(1) * %in
130  %den = load i23, i23 addrspace(1) * %den_ptr
131  %result = udiv i23 %num, %den
132  %result.ext = zext i23 %result to i32
133  store i32 %result.ext, i32 addrspace(1)* %out
134  ret void
135}
136
137; FUNC-LABEL: {{^}}v_udiv_i24:
138; SI-NOT: v_rcp_f32
139define void @v_udiv_i24(i32 addrspace(1)* %out, i24 addrspace(1)* %in) {
140  %den_ptr = getelementptr i24, i24 addrspace(1)* %in, i24 1
141  %num = load i24, i24 addrspace(1) * %in
142  %den = load i24, i24 addrspace(1) * %den_ptr
143  %result = udiv i24 %num, %den
144  %result.ext = zext i24 %result to i32
145  store i32 %result.ext, i32 addrspace(1)* %out
146  ret void
147}
148