1 ; RUN: opt -O3 -S < %s | FileCheck %s
3 ; Test to verify that constants aren't folded when the rounding mode is unknown.
5 ; CHECK: call double @llvm.experimental.constrained.fdiv.f64
8 %div = call double @llvm.experimental.constrained.fdiv.f64(
11 metadata !"round.dynamic",
12 metadata !"fpexcept.strict")
16 ; Verify that 'a - 0' isn't simplified to 'a' when the rounding mode is unknown.
18 ; double f2(double a) {
19 ; // Because the result of '0 - 0' is negative zero if rounding mode is
20 ; // downward, this shouldn't be simplified.
25 ; CHECK: call double @llvm.experimental.constrained.fsub.f64
26 define double @f2(double %a) {
28 %div = call double @llvm.experimental.constrained.fsub.f64(
29 double %a, double 0.000000e+00,
30 metadata !"round.dynamic",
31 metadata !"fpexcept.strict")
35 ; Verify that '-((-a)*b)' isn't simplified to 'a*b' when the rounding mode is
38 ; double f3(double a, double b) {
39 ; // Because the intermediate value involved in this calculation may require
40 ; // rounding, this shouldn't be simplified.
45 ; CHECK: call double @llvm.experimental.constrained.fsub.f64
46 ; CHECK: call double @llvm.experimental.constrained.fmul.f64
47 ; CHECK: call double @llvm.experimental.constrained.fsub.f64
48 define double @f3(double %a, double %b) {
50 %sub = call double @llvm.experimental.constrained.fsub.f64(
51 double -0.000000e+00, double %a,
52 metadata !"round.dynamic",
53 metadata !"fpexcept.strict")
54 %mul = call double @llvm.experimental.constrained.fmul.f64(
55 double %sub, double %b,
56 metadata !"round.dynamic",
57 metadata !"fpexcept.strict")
58 %ret = call double @llvm.experimental.constrained.fsub.f64(
61 metadata !"round.dynamic",
62 metadata !"fpexcept.strict")
66 ; Verify that FP operations are not performed speculatively when FP exceptions
67 ; are not being ignored.
69 ; double f4(int n, double a) {
70 ; // Because a + 1 may overflow, this should not be simplified.
80 define double @f4(i32 %n, double %a) {
82 %cmp = icmp sgt i32 %n, 0
83 br i1 %cmp, label %if.then, label %if.end
86 %add = call double @llvm.experimental.constrained.fadd.f64(
87 double 1.000000e+00, double %a,
88 metadata !"round.dynamic",
89 metadata !"fpexcept.strict")
93 %a.0 = phi double [%add, %if.then], [ %a, %entry ]
97 ; Verify that sqrt(42.0) isn't simplified when the rounding mode is unknown.
99 ; CHECK: call double @llvm.experimental.constrained.sqrt
100 define double @f5() {
102 %result = call double @llvm.experimental.constrained.sqrt.f64(double 42.0,
103 metadata !"round.dynamic",
104 metadata !"fpexcept.strict")
108 ; Verify that pow(42.1, 3.0) isn't simplified when the rounding mode is unknown.
110 ; CHECK: call double @llvm.experimental.constrained.pow
111 define double @f6() {
113 %result = call double @llvm.experimental.constrained.pow.f64(double 42.1,
115 metadata !"round.dynamic",
116 metadata !"fpexcept.strict")
120 ; Verify that powi(42.1, 3) isn't simplified when the rounding mode is unknown.
122 ; CHECK: call double @llvm.experimental.constrained.powi
123 define double @f7() {
125 %result = call double @llvm.experimental.constrained.powi.f64(double 42.1,
127 metadata !"round.dynamic",
128 metadata !"fpexcept.strict")
132 ; Verify that sin(42.0) isn't simplified when the rounding mode is unknown.
134 ; CHECK: call double @llvm.experimental.constrained.sin
135 define double @f8() {
137 %result = call double @llvm.experimental.constrained.sin.f64(double 42.0,
138 metadata !"round.dynamic",
139 metadata !"fpexcept.strict")
143 ; Verify that cos(42.0) isn't simplified when the rounding mode is unknown.
145 ; CHECK: call double @llvm.experimental.constrained.cos
146 define double @f9() {
148 %result = call double @llvm.experimental.constrained.cos.f64(double 42.0,
149 metadata !"round.dynamic",
150 metadata !"fpexcept.strict")
154 ; Verify that exp(42.0) isn't simplified when the rounding mode is unknown.
156 ; CHECK: call double @llvm.experimental.constrained.exp
157 define double @f10() {
159 %result = call double @llvm.experimental.constrained.exp.f64(double 42.0,
160 metadata !"round.dynamic",
161 metadata !"fpexcept.strict")
165 ; Verify that exp2(42.1) isn't simplified when the rounding mode is unknown.
167 ; CHECK: call double @llvm.experimental.constrained.exp2
168 define double @f11() {
170 %result = call double @llvm.experimental.constrained.exp2.f64(double 42.1,
171 metadata !"round.dynamic",
172 metadata !"fpexcept.strict")
176 ; Verify that log(42.0) isn't simplified when the rounding mode is unknown.
178 ; CHECK: call double @llvm.experimental.constrained.log
179 define double @f12() {
181 %result = call double @llvm.experimental.constrained.log.f64(double 42.0,
182 metadata !"round.dynamic",
183 metadata !"fpexcept.strict")
187 ; Verify that log10(42.0) isn't simplified when the rounding mode is unknown.
189 ; CHECK: call double @llvm.experimental.constrained.log10
190 define double @f13() {
192 %result = call double @llvm.experimental.constrained.log10.f64(double 42.0,
193 metadata !"round.dynamic",
194 metadata !"fpexcept.strict")
198 ; Verify that log2(42.0) isn't simplified when the rounding mode is unknown.
200 ; CHECK: call double @llvm.experimental.constrained.log2
201 define double @f14() {
203 %result = call double @llvm.experimental.constrained.log2.f64(double 42.0,
204 metadata !"round.dynamic",
205 metadata !"fpexcept.strict")
209 ; Verify that rint(42.1) isn't simplified when the rounding mode is unknown.
211 ; CHECK: call double @llvm.experimental.constrained.rint
212 define double @f15() {
214 %result = call double @llvm.experimental.constrained.rint.f64(double 42.1,
215 metadata !"round.dynamic",
216 metadata !"fpexcept.strict")
220 ; Verify that nearbyint(42.1) isn't simplified when the rounding mode is
223 ; CHECK: call double @llvm.experimental.constrained.nearbyint
224 define double @f16() {
226 %result = call double @llvm.experimental.constrained.nearbyint.f64(
228 metadata !"round.dynamic",
229 metadata !"fpexcept.strict")
233 ; Verify that fma(42.1) isn't simplified when the rounding mode is
236 ; CHECK: call double @llvm.experimental.constrained.fma
237 define double @f17() {
239 %result = call double @llvm.experimental.constrained.fma.f64(double 42.1, double 42.1, double 42.1,
240 metadata !"round.dynamic",
241 metadata !"fpexcept.strict")
245 ; Verify that fptoui(42.1) isn't simplified when the rounding mode is
248 ; CHECK: call zeroext i32 @llvm.experimental.constrained.fptoui
249 define zeroext i32 @f18() {
251 %result = call zeroext i32 @llvm.experimental.constrained.fptoui.i32.f64(
253 metadata !"fpexcept.strict")
257 ; Verify that fptosi(42.1) isn't simplified when the rounding mode is
260 ; CHECK: call i32 @llvm.experimental.constrained.fptosi
263 %result = call i32 @llvm.experimental.constrained.fptosi.i32.f64(double 42.1,
264 metadata !"fpexcept.strict")
268 ; Verify that fptrunc(42.1) isn't simplified when the rounding mode is
271 ; CHECK: call float @llvm.experimental.constrained.fptrunc
272 define float @f20() {
274 %result = call float @llvm.experimental.constrained.fptrunc.f32.f64(
276 metadata !"round.dynamic",
277 metadata !"fpexcept.strict")
281 ; Verify that fpext(42.1) isn't simplified when the rounding mode is
284 ; CHECK: call double @llvm.experimental.constrained.fpext
285 define double @f21() {
287 %result = call double @llvm.experimental.constrained.fpext.f64.f32(float 42.0,
288 metadata !"fpexcept.strict")
292 @llvm.fp.env = thread_local global i8 zeroinitializer, section "llvm.metadata"
293 declare double @llvm.experimental.constrained.fdiv.f64(double, double, metadata, metadata)
294 declare double @llvm.experimental.constrained.fmul.f64(double, double, metadata, metadata)
295 declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)
296 declare double @llvm.experimental.constrained.fsub.f64(double, double, metadata, metadata)
297 declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata)
298 declare double @llvm.experimental.constrained.pow.f64(double, double, metadata, metadata)
299 declare double @llvm.experimental.constrained.powi.f64(double, i32, metadata, metadata)
300 declare double @llvm.experimental.constrained.sin.f64(double, metadata, metadata)
301 declare double @llvm.experimental.constrained.cos.f64(double, metadata, metadata)
302 declare double @llvm.experimental.constrained.exp.f64(double, metadata, metadata)
303 declare double @llvm.experimental.constrained.exp2.f64(double, metadata, metadata)
304 declare double @llvm.experimental.constrained.log.f64(double, metadata, metadata)
305 declare double @llvm.experimental.constrained.log10.f64(double, metadata, metadata)
306 declare double @llvm.experimental.constrained.log2.f64(double, metadata, metadata)
307 declare double @llvm.experimental.constrained.rint.f64(double, metadata, metadata)
308 declare double @llvm.experimental.constrained.nearbyint.f64(double, metadata, metadata)
309 declare double @llvm.experimental.constrained.fma.f64(double, double, double, metadata, metadata)
310 declare i32 @llvm.experimental.constrained.fptosi.i32.f64(double, metadata)
311 declare i32 @llvm.experimental.constrained.fptoui.i32.f64(double, metadata)
312 declare float @llvm.experimental.constrained.fptrunc.f32.f64(double, metadata, metadata)
313 declare double @llvm.experimental.constrained.fpext.f64.f32(float, metadata)