1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt -S -passes=instsimplify %s | FileCheck %s
4 declare { float, i32 } @llvm.frexp.f32.i32(float)
5 declare { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float>)
6 declare { <4 x float>, <4 x i32> } @llvm.frexp.v4f32.v4i32(<4 x float>)
7 declare { ppc_fp128, i32 } @llvm.frexp.ppcf128.i32(ppc_fp128)
8 declare { <vscale x 2 x float>, <vscale x 2 x i32> } @llvm.frexp.nxv2f32.nxv2i32(<vscale x 2 x float>)
11 define { float, i32 } @frexp_frexp(float %x) {
12 ; CHECK-LABEL: define { float, i32 } @frexp_frexp
13 ; CHECK-SAME: (float [[X:%.*]]) {
14 ; CHECK-NEXT: [[FREXP0:%.*]] = call { float, i32 } @llvm.frexp.f32.i32(float [[X]])
15 ; CHECK-NEXT: ret { float, i32 } [[FREXP0]]
17 %frexp0 = call { float, i32 } @llvm.frexp.f32.i32(float %x)
18 %frexp0.0 = extractvalue { float, i32 } %frexp0, 0
19 %frexp1 = call { float, i32 } @llvm.frexp.f32.i32(float %frexp0.0)
20 ret { float, i32 } %frexp1
23 define { <2 x float>, <2 x i32> } @frexp_frexp_vector(<2 x float> %x) {
24 ; CHECK-LABEL: define { <2 x float>, <2 x i32> } @frexp_frexp_vector
25 ; CHECK-SAME: (<2 x float> [[X:%.*]]) {
26 ; CHECK-NEXT: [[FREXP0:%.*]] = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> [[X]])
27 ; CHECK-NEXT: ret { <2 x float>, <2 x i32> } [[FREXP0]]
29 %frexp0 = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> %x)
30 %frexp0.0 = extractvalue { <2 x float>, <2 x i32> } %frexp0, 0
31 %frexp1 = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> %frexp0.0)
32 ret { <2 x float>, <2 x i32> } %frexp1
35 define { float, i32 } @frexp_frexp_const(float %x) {
36 ; CHECK-LABEL: define { float, i32 } @frexp_frexp_const
37 ; CHECK-SAME: (float [[X:%.*]]) {
38 ; CHECK-NEXT: ret { float, i32 } { float 6.562500e-01, i32 0 }
40 %frexp0 = call { float, i32 } @llvm.frexp.f32.i32(float 42.0)
41 %frexp0.0 = extractvalue { float, i32 } %frexp0, 0
42 %frexp1 = call { float, i32 } @llvm.frexp.f32.i32(float %frexp0.0)
43 ret { float, i32 } %frexp1
46 define { <vscale x 2 x float>, <vscale x 2 x i32> } @frexp_frexp_scalable_vector(<vscale x 2 x float> %x) {
47 ; CHECK-LABEL: define { <vscale x 2 x float>, <vscale x 2 x i32> } @frexp_frexp_scalable_vector
48 ; CHECK-SAME: (<vscale x 2 x float> [[X:%.*]]) {
49 ; CHECK-NEXT: [[FREXP0:%.*]] = call { <vscale x 2 x float>, <vscale x 2 x i32> } @llvm.frexp.nxv2f32.nxv2i32(<vscale x 2 x float> [[X]])
50 ; CHECK-NEXT: ret { <vscale x 2 x float>, <vscale x 2 x i32> } [[FREXP0]]
52 %frexp0 = call { <vscale x 2 x float>, <vscale x 2 x i32> } @llvm.frexp.nxv2f32.nxv2i32(<vscale x 2 x float> %x)
53 %frexp0.0 = extractvalue { <vscale x 2 x float>, <vscale x 2 x i32> } %frexp0, 0
54 %frexp1 = call { <vscale x 2 x float>, <vscale x 2 x i32> } @llvm.frexp.nxv2f32.nxv2i32(<vscale x 2 x float> %frexp0.0)
55 ret { <vscale x 2 x float>, <vscale x 2 x i32> } %frexp1
58 define { float, i32 } @frexp_poison() {
59 ; CHECK-LABEL: define { float, i32 } @frexp_poison() {
60 ; CHECK-NEXT: ret { float, i32 } poison
62 %ret = call { float, i32 } @llvm.frexp.f32.i32(float poison)
63 ret { float, i32 } %ret
66 define { <2 x float>, <2 x i32> } @frexp_poison_vector() {
67 ; CHECK-LABEL: define { <2 x float>, <2 x i32> } @frexp_poison_vector() {
68 ; CHECK-NEXT: ret { <2 x float>, <2 x i32> } poison
70 %ret = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> poison)
71 ret { <2 x float>, <2 x i32> } %ret
74 define { <vscale x 2 x float>, <vscale x 2 x i32> } @frexp_poison_scaleable_vector() {
75 ; CHECK-LABEL: define { <vscale x 2 x float>, <vscale x 2 x i32> } @frexp_poison_scaleable_vector() {
76 ; CHECK-NEXT: ret { <vscale x 2 x float>, <vscale x 2 x i32> } poison
78 %ret = call { <vscale x 2 x float>, <vscale x 2 x i32> } @llvm.frexp.nxv2f32.nxv2i32(<vscale x 2 x float> poison)
79 ret { <vscale x 2 x float>, <vscale x 2 x i32> } %ret
82 define { float, i32 } @frexp_undef() {
83 ; CHECK-LABEL: define { float, i32 } @frexp_undef() {
84 ; CHECK-NEXT: [[RET:%.*]] = call { float, i32 } @llvm.frexp.f32.i32(float undef)
85 ; CHECK-NEXT: ret { float, i32 } [[RET]]
87 %ret = call { float, i32 } @llvm.frexp.f32.i32(float undef)
88 ret { float, i32 } %ret
90 define { <2 x float>, <2 x i32> } @frexp_undef_vector() {
91 ; CHECK-LABEL: define { <2 x float>, <2 x i32> } @frexp_undef_vector() {
92 ; CHECK-NEXT: [[RET:%.*]] = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> undef)
93 ; CHECK-NEXT: ret { <2 x float>, <2 x i32> } [[RET]]
95 %ret = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> undef)
96 ret { <2 x float>, <2 x i32> } %ret
99 define { <2 x float>, <2 x i32> } @frexp_zero_vector() {
100 ; CHECK-LABEL: define { <2 x float>, <2 x i32> } @frexp_zero_vector() {
101 ; CHECK-NEXT: ret { <2 x float>, <2 x i32> } zeroinitializer
103 %ret = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> zeroinitializer)
104 ret { <2 x float>, <2 x i32> } %ret
107 define { <vscale x 2 x float>, <vscale x 2 x i32> } @frexp_zero_scalable_vector() {
108 ; CHECK-LABEL: define { <vscale x 2 x float>, <vscale x 2 x i32> } @frexp_zero_scalable_vector() {
109 ; CHECK-NEXT: [[RET:%.*]] = call { <vscale x 2 x float>, <vscale x 2 x i32> } @llvm.frexp.nxv2f32.nxv2i32(<vscale x 2 x float> zeroinitializer)
110 ; CHECK-NEXT: ret { <vscale x 2 x float>, <vscale x 2 x i32> } [[RET]]
112 %ret = call { <vscale x 2 x float>, <vscale x 2 x i32> } @llvm.frexp.nxv2f32.nxv2i32(<vscale x 2 x float> zeroinitializer)
113 ret { <vscale x 2 x float>, <vscale x 2 x i32> } %ret
116 define { <2 x float>, <2 x i32> } @frexp_zero_negzero_vector() {
117 ; CHECK-LABEL: define { <2 x float>, <2 x i32> } @frexp_zero_negzero_vector() {
118 ; CHECK-NEXT: ret { <2 x float>, <2 x i32> } { <2 x float> <float 0.000000e+00, float -0.000000e+00>, <2 x i32> zeroinitializer }
120 %ret = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> <float 0.0, float -0.0>)
121 ret { <2 x float>, <2 x i32> } %ret
124 define { <4 x float>, <4 x i32> } @frexp_nonsplat_vector() {
125 ; CHECK-LABEL: define { <4 x float>, <4 x i32> } @frexp_nonsplat_vector() {
126 ; CHECK-NEXT: [[RET:%.*]] = call { <4 x float>, <4 x i32> } @llvm.frexp.v4f32.v4i32(<4 x float> <float 1.600000e+01, float -3.200000e+01, float undef, float 9.999000e+03>)
127 ; CHECK-NEXT: ret { <4 x float>, <4 x i32> } [[RET]]
129 %ret = call { <4 x float>, <4 x i32> } @llvm.frexp.v4f32.v4i32(<4 x float> <float 16.0, float -32.0, float undef, float 9999.0>)
130 ret { <4 x float>, <4 x i32> } %ret
133 define { float, i32 } @frexp_zero() {
134 ; CHECK-LABEL: define { float, i32 } @frexp_zero() {
135 ; CHECK-NEXT: ret { float, i32 } zeroinitializer
137 %ret = call { float, i32 } @llvm.frexp.f32.i32(float 0.0)
138 ret { float, i32 } %ret
141 define { float, i32 } @frexp_negzero() {
142 ; CHECK-LABEL: define { float, i32 } @frexp_negzero() {
143 ; CHECK-NEXT: ret { float, i32 } { float -0.000000e+00, i32 0 }
145 %ret = call { float, i32 } @llvm.frexp.f32.i32(float -0.0)
146 ret { float, i32 } %ret
149 define { float, i32 } @frexp_one() {
150 ; CHECK-LABEL: define { float, i32 } @frexp_one() {
151 ; CHECK-NEXT: ret { float, i32 } { float 5.000000e-01, i32 1 }
153 %ret = call { float, i32 } @llvm.frexp.f32.i32(float 1.0)
154 ret { float, i32 } %ret
157 define { float, i32 } @frexp_negone() {
158 ; CHECK-LABEL: define { float, i32 } @frexp_negone() {
159 ; CHECK-NEXT: ret { float, i32 } { float -5.000000e-01, i32 1 }
161 %ret = call { float, i32 } @llvm.frexp.f32.i32(float -1.0)
162 ret { float, i32 } %ret
165 define { float, i32 } @frexp_two() {
166 ; CHECK-LABEL: define { float, i32 } @frexp_two() {
167 ; CHECK-NEXT: ret { float, i32 } { float 5.000000e-01, i32 2 }
169 %ret = call { float, i32 } @llvm.frexp.f32.i32(float 2.0)
170 ret { float, i32 } %ret
173 define { float, i32 } @frexp_negtwo() {
174 ; CHECK-LABEL: define { float, i32 } @frexp_negtwo() {
175 ; CHECK-NEXT: ret { float, i32 } { float -5.000000e-01, i32 2 }
177 %ret = call { float, i32 } @llvm.frexp.f32.i32(float -2.0)
178 ret { float, i32 } %ret
181 define { float, i32 } @frexp_inf() {
182 ; CHECK-LABEL: define { float, i32 } @frexp_inf() {
183 ; CHECK-NEXT: ret { float, i32 } { float 0x7FF0000000000000, i32 0 }
185 %ret = call { float, i32 } @llvm.frexp.f32.i32(float 0x7FF0000000000000)
186 ret { float, i32 } %ret
189 define { float, i32 } @frexp_neginf() {
190 ; CHECK-LABEL: define { float, i32 } @frexp_neginf() {
191 ; CHECK-NEXT: ret { float, i32 } { float 0xFFF0000000000000, i32 0 }
193 %ret = call { float, i32 } @llvm.frexp.f32.i32(float 0xFFF0000000000000)
194 ret { float, i32 } %ret
197 define { float, i32 } @frexp_qnan() {
198 ; CHECK-LABEL: define { float, i32 } @frexp_qnan() {
199 ; CHECK-NEXT: ret { float, i32 } { float 0x7FF8000000000000, i32 0 }
201 %ret = call { float, i32 } @llvm.frexp.f32.i32(float 0x7FF8000000000000)
202 ret { float, i32 } %ret
205 define { float, i32 } @frexp_snan() {
206 ; CHECK-LABEL: define { float, i32 } @frexp_snan() {
207 ; CHECK-NEXT: ret { float, i32 } { float 0x7FF8000020000000, i32 0 }
209 %ret = call { float, i32 } @llvm.frexp.f32.i32(float bitcast (i32 2139095041 to float))
210 ret { float, i32 } %ret
213 define { float, i32 } @frexp_pos_denorm() {
214 ; CHECK-LABEL: define { float, i32 } @frexp_pos_denorm() {
215 ; CHECK-NEXT: ret { float, i32 } { float 0x3FEFFFFFC0000000, i32 -126 }
217 %ret = call { float, i32 } @llvm.frexp.f32.i32(float bitcast (i32 8388607 to float))
218 ret { float, i32 } %ret
221 define { float, i32 } @frexp_neg_denorm() {
222 ; CHECK-LABEL: define { float, i32 } @frexp_neg_denorm() {
223 ; CHECK-NEXT: ret { float, i32 } { float 0xBFEFFFFFC0000000, i32 -126 }
225 %ret = call { float, i32 } @llvm.frexp.f32.i32(float bitcast (i32 -2139095041 to float))
226 ret { float, i32 } %ret
229 define { ppc_fp128, i32 } @frexp_one_ppcf128() {
230 ; CHECK-LABEL: define { ppc_fp128, i32 } @frexp_one_ppcf128() {
231 ; CHECK-NEXT: ret { ppc_fp128, i32 } { ppc_fp128 0xM3FE00000000000000000000000000000, i32 1 }
233 %ret = call { ppc_fp128, i32 } @llvm.frexp.ppcf128.i32(ppc_fp128 0xM3FF00000000000000000000000000000)
234 ret { ppc_fp128, i32 } %ret
237 define { ppc_fp128, i32 } @frexp_negone_ppcf128() {
238 ; CHECK-LABEL: define { ppc_fp128, i32 } @frexp_negone_ppcf128() {
239 ; CHECK-NEXT: ret { ppc_fp128, i32 } { ppc_fp128 0xMBFE00000000000000000000000000000, i32 1 }
241 %ret = call { ppc_fp128, i32 } @llvm.frexp.ppcf128.i32(ppc_fp128 0xMBFF00000000000000000000000000000)
242 ret { ppc_fp128, i32 } %ret
245 define { ppc_fp128, i32} @canonicalize_noncanonical_zero_1_ppcf128() {
246 ; CHECK-LABEL: define { ppc_fp128, i32 } @canonicalize_noncanonical_zero_1_ppcf128() {
247 ; CHECK-NEXT: ret { ppc_fp128, i32 } { ppc_fp128 0xM00000000000000000000000000000001, i32 0 }
249 %ret = call { ppc_fp128, i32 } @llvm.frexp.ppcf128.i32(ppc_fp128 0xM00000000000000000000000000000001)
250 ret { ppc_fp128, i32 } %ret
253 define { <2 x float>, <2 x i32> } @frexp_splat_4() {
254 ; CHECK-LABEL: define { <2 x float>, <2 x i32> } @frexp_splat_4() {
255 ; CHECK-NEXT: ret { <2 x float>, <2 x i32> } { <2 x float> <float 5.000000e-01, float 5.000000e-01>, <2 x i32> <i32 3, i32 3> }
257 %ret = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> <float 4.0, float 4.0>)
258 ret { <2 x float>, <2 x i32> } %ret
261 define { <2 x float>, <2 x i32> } @frexp_splat_qnan() {
262 ; CHECK-LABEL: define { <2 x float>, <2 x i32> } @frexp_splat_qnan() {
263 ; CHECK-NEXT: ret { <2 x float>, <2 x i32> } { <2 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000>, <2 x i32> zeroinitializer }
265 %ret = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000>)
266 ret { <2 x float>, <2 x i32> } %ret
269 define { <2 x float>, <2 x i32> } @frexp_splat_inf() {
270 ; CHECK-LABEL: define { <2 x float>, <2 x i32> } @frexp_splat_inf() {
271 ; CHECK-NEXT: ret { <2 x float>, <2 x i32> } { <2 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000>, <2 x i32> zeroinitializer }
273 %ret = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> <float 0x7FF0000000000000, float 0x7FF0000000000000>)
274 ret { <2 x float>, <2 x i32> } %ret
277 define { <2 x float>, <2 x i32> } @frexp_splat_neginf() {
278 ; CHECK-LABEL: define { <2 x float>, <2 x i32> } @frexp_splat_neginf() {
279 ; CHECK-NEXT: ret { <2 x float>, <2 x i32> } { <2 x float> <float 0xFFF0000000000000, float 0xFFF0000000000000>, <2 x i32> zeroinitializer }
281 %ret = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> <float 0xFFF0000000000000, float 0xFFF0000000000000>)
282 ret { <2 x float>, <2 x i32> } %ret
285 define { <2 x float>, <2 x i32> } @frexp_splat_undef_inf() {
286 ; CHECK-LABEL: define { <2 x float>, <2 x i32> } @frexp_splat_undef_inf() {
287 ; CHECK-NEXT: [[RET:%.*]] = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> <float undef, float 0x7FF0000000000000>)
288 ; CHECK-NEXT: ret { <2 x float>, <2 x i32> } [[RET]]
290 %ret = call { <2 x float>, <2 x i32> } @llvm.frexp.v2f32.v2i32(<2 x float> <float undef, float 0x7FF0000000000000>)
291 ret { <2 x float>, <2 x i32> } %ret