1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=amdgpu-simplifylib %s | FileCheck %s
4 target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
6 declare float @_Z5floorf(float)
7 declare <2 x float> @_Z5floorDv2_f(<2 x float>)
8 declare <3 x float> @_Z5floorDv3_f(<3 x float>)
9 declare <4 x float> @_Z5floorDv4_f(<4 x float>)
10 declare <8 x float> @_Z5floorDv8_f(<8 x float>)
11 declare <16 x float> @_Z5floorDv16_f(<16 x float>)
13 declare double @_Z5floord(double)
14 declare <2 x double> @_Z5floorDv2_d(<2 x double>)
15 declare <3 x double> @_Z5floorDv3_d(<3 x double>)
16 declare <4 x double> @_Z5floorDv4_d(<4 x double>)
17 declare <8 x double> @_Z5floorDv8_d(<8 x double>)
18 declare <16 x double> @_Z5floorDv16_d(<16 x double>)
20 declare half @_Z5floorDh(half)
21 declare <2 x half> @_Z5floorDv2_Dh(<2 x half>)
22 declare <3 x half> @_Z5floorDv3_Dh(<3 x half>)
23 declare <4 x half> @_Z5floorDv4_Dh(<4 x half>)
24 declare <8 x half> @_Z5floorDv8_Dh(<8 x half>)
25 declare <16 x half> @_Z5floorDv16_Dh(<16 x half>)
27 define float @test_rint_f32(float %arg) {
28 ; CHECK-LABEL: define float @test_rint_f32
29 ; CHECK-SAME: (float [[ARG:%.*]]) {
30 ; CHECK-NEXT: [[RINT:%.*]] = tail call float @llvm.floor.f32(float [[ARG]])
31 ; CHECK-NEXT: ret float [[RINT]]
33 %rint = tail call float @_Z5floorf(float %arg)
37 define <2 x float> @test_rint_v2f32(<2 x float> %arg) {
38 ; CHECK-LABEL: define <2 x float> @test_rint_v2f32
39 ; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {
40 ; CHECK-NEXT: [[RINT:%.*]] = tail call <2 x float> @llvm.floor.v2f32(<2 x float> [[ARG]])
41 ; CHECK-NEXT: ret <2 x float> [[RINT]]
43 %rint = tail call <2 x float> @_Z5floorDv2_f(<2 x float> %arg)
47 define <3 x float> @test_rint_v3f32(<3 x float> %arg) {
48 ; CHECK-LABEL: define <3 x float> @test_rint_v3f32
49 ; CHECK-SAME: (<3 x float> [[ARG:%.*]]) {
50 ; CHECK-NEXT: [[RINT:%.*]] = tail call <3 x float> @llvm.floor.v3f32(<3 x float> [[ARG]])
51 ; CHECK-NEXT: ret <3 x float> [[RINT]]
53 %rint = tail call <3 x float> @_Z5floorDv3_f(<3 x float> %arg)
57 define <4 x float> @test_rint_v4f32(<4 x float> %arg) {
58 ; CHECK-LABEL: define <4 x float> @test_rint_v4f32
59 ; CHECK-SAME: (<4 x float> [[ARG:%.*]]) {
60 ; CHECK-NEXT: [[RINT:%.*]] = tail call <4 x float> @llvm.floor.v4f32(<4 x float> [[ARG]])
61 ; CHECK-NEXT: ret <4 x float> [[RINT]]
63 %rint = tail call <4 x float> @_Z5floorDv4_f(<4 x float> %arg)
67 define <8 x float> @test_rint_v8f32(<8 x float> %arg) {
68 ; CHECK-LABEL: define <8 x float> @test_rint_v8f32
69 ; CHECK-SAME: (<8 x float> [[ARG:%.*]]) {
70 ; CHECK-NEXT: [[RINT:%.*]] = tail call <8 x float> @llvm.floor.v8f32(<8 x float> [[ARG]])
71 ; CHECK-NEXT: ret <8 x float> [[RINT]]
73 %rint = tail call <8 x float> @_Z5floorDv8_f(<8 x float> %arg)
77 define <16 x float> @test_rint_v16f32(<16 x float> %arg) {
78 ; CHECK-LABEL: define <16 x float> @test_rint_v16f32
79 ; CHECK-SAME: (<16 x float> [[ARG:%.*]]) {
80 ; CHECK-NEXT: [[RINT:%.*]] = tail call <16 x float> @llvm.floor.v16f32(<16 x float> [[ARG]])
81 ; CHECK-NEXT: ret <16 x float> [[RINT]]
83 %rint = tail call <16 x float> @_Z5floorDv16_f(<16 x float> %arg)
84 ret <16 x float> %rint
87 define double @test_rint_f64(double %arg) {
88 ; CHECK-LABEL: define double @test_rint_f64
89 ; CHECK-SAME: (double [[ARG:%.*]]) {
90 ; CHECK-NEXT: [[RINT:%.*]] = tail call double @llvm.floor.f64(double [[ARG]])
91 ; CHECK-NEXT: ret double [[RINT]]
93 %rint = tail call double @_Z5floord(double %arg)
97 define <2 x double> @test_rint_v2f64(<2 x double> %arg) {
98 ; CHECK-LABEL: define <2 x double> @test_rint_v2f64
99 ; CHECK-SAME: (<2 x double> [[ARG:%.*]]) {
100 ; CHECK-NEXT: [[RINT:%.*]] = tail call <2 x double> @llvm.floor.v2f64(<2 x double> [[ARG]])
101 ; CHECK-NEXT: ret <2 x double> [[RINT]]
103 %rint = tail call <2 x double> @_Z5floorDv2_d(<2 x double> %arg)
104 ret <2 x double> %rint
107 define <3 x double> @test_rint_v3f64(<3 x double> %arg) {
108 ; CHECK-LABEL: define <3 x double> @test_rint_v3f64
109 ; CHECK-SAME: (<3 x double> [[ARG:%.*]]) {
110 ; CHECK-NEXT: [[RINT:%.*]] = tail call <3 x double> @llvm.floor.v3f64(<3 x double> [[ARG]])
111 ; CHECK-NEXT: ret <3 x double> [[RINT]]
113 %rint = tail call <3 x double> @_Z5floorDv3_d(<3 x double> %arg)
114 ret <3 x double> %rint
117 define <4 x double> @test_rint_v4f64(<4 x double> %arg) {
118 ; CHECK-LABEL: define <4 x double> @test_rint_v4f64
119 ; CHECK-SAME: (<4 x double> [[ARG:%.*]]) {
120 ; CHECK-NEXT: [[RINT:%.*]] = tail call <4 x double> @llvm.floor.v4f64(<4 x double> [[ARG]])
121 ; CHECK-NEXT: ret <4 x double> [[RINT]]
123 %rint = tail call <4 x double> @_Z5floorDv4_d(<4 x double> %arg)
124 ret <4 x double> %rint
127 define <8 x double> @test_rint_v8f64(<8 x double> %arg) {
128 ; CHECK-LABEL: define <8 x double> @test_rint_v8f64
129 ; CHECK-SAME: (<8 x double> [[ARG:%.*]]) {
130 ; CHECK-NEXT: [[RINT:%.*]] = tail call <8 x double> @llvm.floor.v8f64(<8 x double> [[ARG]])
131 ; CHECK-NEXT: ret <8 x double> [[RINT]]
133 %rint = tail call <8 x double> @_Z5floorDv8_d(<8 x double> %arg)
134 ret <8 x double> %rint
137 define <16 x double> @test_rint_v16f64(<16 x double> %arg) {
138 ; CHECK-LABEL: define <16 x double> @test_rint_v16f64
139 ; CHECK-SAME: (<16 x double> [[ARG:%.*]]) {
140 ; CHECK-NEXT: [[RINT:%.*]] = tail call <16 x double> @llvm.floor.v16f64(<16 x double> [[ARG]])
141 ; CHECK-NEXT: ret <16 x double> [[RINT]]
143 %rint = tail call <16 x double> @_Z5floorDv16_d(<16 x double> %arg)
144 ret <16 x double> %rint
147 define half @test_rint_f16(half %arg) {
148 ; CHECK-LABEL: define half @test_rint_f16
149 ; CHECK-SAME: (half [[ARG:%.*]]) {
150 ; CHECK-NEXT: [[RINT:%.*]] = tail call half @llvm.floor.f16(half [[ARG]])
151 ; CHECK-NEXT: ret half [[RINT]]
153 %rint = tail call half @_Z5floorDh(half %arg)
157 define <2 x half> @test_rint_v2f16(<2 x half> %arg) {
158 ; CHECK-LABEL: define <2 x half> @test_rint_v2f16
159 ; CHECK-SAME: (<2 x half> [[ARG:%.*]]) {
160 ; CHECK-NEXT: [[RINT:%.*]] = tail call <2 x half> @llvm.floor.v2f16(<2 x half> [[ARG]])
161 ; CHECK-NEXT: ret <2 x half> [[RINT]]
163 %rint = tail call <2 x half> @_Z5floorDv2_Dh(<2 x half> %arg)
167 define <3 x half> @test_rint_v3f16(<3 x half> %arg) {
168 ; CHECK-LABEL: define <3 x half> @test_rint_v3f16
169 ; CHECK-SAME: (<3 x half> [[ARG:%.*]]) {
170 ; CHECK-NEXT: [[RINT:%.*]] = tail call <3 x half> @llvm.floor.v3f16(<3 x half> [[ARG]])
171 ; CHECK-NEXT: ret <3 x half> [[RINT]]
173 %rint = tail call <3 x half> @_Z5floorDv3_Dh(<3 x half> %arg)
177 define <4 x half> @test_rint_v4f16(<4 x half> %arg) {
178 ; CHECK-LABEL: define <4 x half> @test_rint_v4f16
179 ; CHECK-SAME: (<4 x half> [[ARG:%.*]]) {
180 ; CHECK-NEXT: [[RINT:%.*]] = tail call <4 x half> @llvm.floor.v4f16(<4 x half> [[ARG]])
181 ; CHECK-NEXT: ret <4 x half> [[RINT]]
183 %rint = tail call <4 x half> @_Z5floorDv4_Dh(<4 x half> %arg)
187 define <8 x half> @test_rint_v8f16(<8 x half> %arg) {
188 ; CHECK-LABEL: define <8 x half> @test_rint_v8f16
189 ; CHECK-SAME: (<8 x half> [[ARG:%.*]]) {
190 ; CHECK-NEXT: [[RINT:%.*]] = tail call <8 x half> @llvm.floor.v8f16(<8 x half> [[ARG]])
191 ; CHECK-NEXT: ret <8 x half> [[RINT]]
193 %rint = tail call <8 x half> @_Z5floorDv8_Dh(<8 x half> %arg)
197 define <16 x half> @test_rint_v16f16(<16 x half> %arg) {
198 ; CHECK-LABEL: define <16 x half> @test_rint_v16f16
199 ; CHECK-SAME: (<16 x half> [[ARG:%.*]]) {
200 ; CHECK-NEXT: [[RINT:%.*]] = tail call <16 x half> @llvm.floor.v16f16(<16 x half> [[ARG]])
201 ; CHECK-NEXT: ret <16 x half> [[RINT]]
203 %rint = tail call <16 x half> @_Z5floorDv16_Dh(<16 x half> %arg)
204 ret <16 x half> %rint
207 define float @test_rint_f32_nobuiltin_callsite(float %arg) {
208 ; CHECK-LABEL: define float @test_rint_f32_nobuiltin_callsite
209 ; CHECK-SAME: (float [[ARG:%.*]]) {
210 ; CHECK-NEXT: [[RINT:%.*]] = tail call float @_Z5floorf(float [[ARG]]) #[[ATTR4:[0-9]+]]
211 ; CHECK-NEXT: ret float [[RINT]]
213 %rint = tail call float @_Z5floorf(float %arg) #0
217 define <2 x float> @test_rint_v2f32_nobuiltin_callsite(<2 x float> %arg) {
218 ; CHECK-LABEL: define <2 x float> @test_rint_v2f32_nobuiltin_callsite
219 ; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {
220 ; CHECK-NEXT: [[RINT:%.*]] = tail call <2 x float> @_Z5floorDv2_f(<2 x float> [[ARG]]) #[[ATTR4]]
221 ; CHECK-NEXT: ret <2 x float> [[RINT]]
223 %rint = tail call <2 x float> @_Z5floorDv2_f(<2 x float> %arg) #0
224 ret <2 x float> %rint
227 ; "no-builtins" should be ignored
228 define float @test_rint_f32_nobuiltins(float %arg) #1 {
229 ; CHECK-LABEL: define float @test_rint_f32_nobuiltins
230 ; CHECK-SAME: (float [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {
231 ; CHECK-NEXT: [[RINT:%.*]] = tail call float @_Z5floorf(float [[ARG]]) #[[ATTR4]]
232 ; CHECK-NEXT: ret float [[RINT]]
234 %rint = tail call float @_Z5floorf(float %arg) #0
238 define <2 x float> @test_rint_v2f32_nobuiltins(<2 x float> %arg) #1 {
239 ; CHECK-LABEL: define <2 x float> @test_rint_v2f32_nobuiltins
240 ; CHECK-SAME: (<2 x float> [[ARG:%.*]]) #[[ATTR0]] {
241 ; CHECK-NEXT: [[RINT:%.*]] = tail call <2 x float> @_Z5floorDv2_f(<2 x float> [[ARG]]) #[[ATTR4]]
242 ; CHECK-NEXT: ret <2 x float> [[RINT]]
244 %rint = tail call <2 x float> @_Z5floorDv2_f(<2 x float> %arg) #0
245 ret <2 x float> %rint
248 define float @test_rint_f32_preserve_flags(float %arg) {
249 ; CHECK-LABEL: define float @test_rint_f32_preserve_flags
250 ; CHECK-SAME: (float [[ARG:%.*]]) {
251 ; CHECK-NEXT: [[RINT:%.*]] = tail call nnan ninf float @llvm.floor.f32(float [[ARG]])
252 ; CHECK-NEXT: ret float [[RINT]]
254 %rint = tail call nnan ninf float @_Z5floorf(float %arg)
258 define <2 x float> @test_rint_v2f32_preserve_flags(<2 x float> %arg) {
259 ; CHECK-LABEL: define <2 x float> @test_rint_v2f32_preserve_flags
260 ; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {
261 ; CHECK-NEXT: [[RINT:%.*]] = tail call nnan nsz contract <2 x float> @llvm.floor.v2f32(<2 x float> [[ARG]])
262 ; CHECK-NEXT: ret <2 x float> [[RINT]]
264 %rint = tail call contract nsz nnan <2 x float> @_Z5floorDv2_f(<2 x float> %arg)
265 ret <2 x float> %rint
268 define float @test_rint_f32_preserve_flags_md(float %arg) {
269 ; CHECK-LABEL: define float @test_rint_f32_preserve_flags_md
270 ; CHECK-SAME: (float [[ARG:%.*]]) {
271 ; CHECK-NEXT: [[RINT:%.*]] = tail call nnan ninf float @llvm.floor.f32(float [[ARG]]), !foo !0
272 ; CHECK-NEXT: ret float [[RINT]]
274 %rint = tail call nnan ninf float @_Z5floorf(float %arg), !foo !0
278 define <2 x float> @test_rint_v2f32_preserve_flags_md(<2 x float> %arg) {
279 ; CHECK-LABEL: define <2 x float> @test_rint_v2f32_preserve_flags_md
280 ; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {
281 ; CHECK-NEXT: [[RINT:%.*]] = tail call nnan nsz contract <2 x float> @llvm.floor.v2f32(<2 x float> [[ARG]]), !foo !0
282 ; CHECK-NEXT: ret <2 x float> [[RINT]]
284 %rint = tail call contract nsz nnan <2 x float> @_Z5floorDv2_f(<2 x float> %arg), !foo !0
285 ret <2 x float> %rint
288 ; Test the libm name, not a recognized opencl builtin.
289 declare float @rintf(float) #2
290 declare double @rint(double) #2
292 define float @test_libm_rint_f32(float %arg) {
293 ; CHECK-LABEL: define float @test_libm_rint_f32
294 ; CHECK-SAME: (float [[ARG:%.*]]) {
295 ; CHECK-NEXT: [[RINT:%.*]] = tail call float @rintf(float [[ARG]])
296 ; CHECK-NEXT: ret float [[RINT]]
298 %rint = tail call float @rintf(float %arg)
302 define double @test_libm_rint_f64(double %arg) {
303 ; CHECK-LABEL: define double @test_libm_rint_f64
304 ; CHECK-SAME: (double [[ARG:%.*]]) {
305 ; CHECK-NEXT: [[RINT:%.*]] = tail call double @rint(double [[ARG]])
306 ; CHECK-NEXT: ret double [[RINT]]
308 %rint = tail call double @rint(double %arg)
312 define float @test_rint_f32_strictfp(float %arg) #3 {
313 ; CHECK-LABEL: define float @test_rint_f32_strictfp
314 ; CHECK-SAME: (float [[ARG:%.*]]) #[[ATTR2:[0-9]+]] {
315 ; CHECK-NEXT: [[RINT:%.*]] = tail call nnan float @_Z5floorf(float [[ARG]]) #[[ATTR2]]
316 ; CHECK-NEXT: ret float [[RINT]]
318 %rint = tail call nnan float @_Z5floorf(float %arg) #3
322 attributes #0 = { nobuiltin }
323 attributes #1 = { "no-builtins" }
324 attributes #2 = { nounwind memory(none) }
325 attributes #3 = { strictfp }