1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
3 ; RUN: opt < %s -passes=instsimplify -S -mtriple=x86_64-unknown-linux-musl | FileCheck -check-prefix=MUSL %s
5 ; Test to verify constant folding can occur when math routines are mapped
6 ; to the __<func>_finite versions of functions due to __FINITE_MATH_ONLY__
7 ; being enabled on headers on Linux. All calls should constant fold away
10 target triple = "x86_64-unknown-linux-gnu"
12 declare double @__acos_finite(double) #0
13 declare float @__acosf_finite(float) #0
14 declare double @__asin_finite(double) #0
15 declare float @__asinf_finite(float) #0
16 declare double @__atan2_finite(double, double) #0
17 declare float @__atan2f_finite(float, float) #0
18 declare double @__cosh_finite(double) #0
19 declare float @__coshf_finite(float) #0
20 declare double @__exp2_finite(double) #0
21 declare float @__exp2f_finite(float) #0
22 declare double @__exp_finite(double) #0
23 declare float @__expf_finite(float) #0
24 declare double @__log10_finite(double) #0
25 declare float @__log10f_finite(float) #0
26 declare double @__log_finite(double) #0
27 declare float @__logf_finite(float) #0
28 declare double @__pow_finite(double, double) #0
29 declare float @__powf_finite(float, float) #0
30 declare double @__sinh_finite(double) #0
31 declare float @__sinhf_finite(float) #0
33 attributes #0 = { nounwind readnone willreturn }
37 ; CHECK-NEXT: [[SLOT:%.*]] = alloca double, align 8
38 ; CHECK-NEXT: [[SLOTF:%.*]] = alloca float, align 4
39 ; CHECK-NEXT: store double 0.000000e+00, ptr [[SLOT]], align 8
40 ; CHECK-NEXT: store double 0x3FF921FB54442D18, ptr [[SLOT]], align 8
41 ; CHECK-NEXT: store double 0x3FE4978FA3269EE1, ptr [[SLOT]], align 8
42 ; CHECK-NEXT: store double 0x402422A497D6185E, ptr [[SLOT]], align 8
43 ; CHECK-NEXT: store double 0x403415E5BF6FB106, ptr [[SLOT]], align 8
44 ; CHECK-NEXT: store double 8.000000e+00, ptr [[SLOT]], align 8
45 ; CHECK-NEXT: store double 0x3FF193EA7AAD030{{[AB]}}, ptr [[SLOT]], align 8
46 ; CHECK-NEXT: store double 0x3FDE8927964FD5FD, ptr [[SLOT]], align 8
47 ; CHECK-NEXT: store double 1.000000e+00, ptr [[SLOT]], align 8
48 ; CHECK-NEXT: store double 0x40240926E70949AE, ptr [[SLOT]], align 8
49 ; CHECK-NEXT: store float 0.000000e+00, ptr [[SLOTF]], align 4
50 ; CHECK-NEXT: store float 0x3FF921FB60000000, ptr [[SLOTF]], align 4
51 ; CHECK-NEXT: store float 0x3FE4978FA0000000, ptr [[SLOTF]], align 4
52 ; CHECK-NEXT: store float 0x402422A4A0000000, ptr [[SLOTF]], align 4
53 ; CHECK-NEXT: store float 0x403415E5C0000000, ptr [[SLOTF]], align 4
54 ; CHECK-NEXT: store float 8.000000e+00, ptr [[SLOTF]], align 4
55 ; CHECK-NEXT: store float 0x3FF193EA80000000, ptr [[SLOTF]], align 4
56 ; CHECK-NEXT: store float 0x3FDE8927A0000000, ptr [[SLOTF]], align 4
57 ; CHECK-NEXT: store float 8.100000e+01, ptr [[SLOTF]], align 4
58 ; CHECK-NEXT: store float 0x40240926E0000000, ptr [[SLOTF]], align 4
59 ; CHECK-NEXT: ret void
62 ; MUSL-NEXT: [[SLOT:%.*]] = alloca double, align 8
63 ; MUSL-NEXT: [[SLOTF:%.*]] = alloca float, align 4
64 ; MUSL-NEXT: [[ACOS:%.*]] = call fast double @__acos_finite(double 1.000000e+00)
65 ; MUSL-NEXT: store double [[ACOS]], ptr [[SLOT]], align 8
66 ; MUSL-NEXT: [[ASIN:%.*]] = call fast double @__asin_finite(double 1.000000e+00)
67 ; MUSL-NEXT: store double [[ASIN]], ptr [[SLOT]], align 8
68 ; MUSL-NEXT: [[ATAN2:%.*]] = call fast double @__atan2_finite(double 3.000000e+00, double 4.000000e+00)
69 ; MUSL-NEXT: store double [[ATAN2]], ptr [[SLOT]], align 8
70 ; MUSL-NEXT: [[COSH:%.*]] = call fast double @__cosh_finite(double 3.000000e+00)
71 ; MUSL-NEXT: store double [[COSH]], ptr [[SLOT]], align 8
72 ; MUSL-NEXT: [[EXP:%.*]] = call fast double @__exp_finite(double 3.000000e+00)
73 ; MUSL-NEXT: store double [[EXP]], ptr [[SLOT]], align 8
74 ; MUSL-NEXT: [[EXP2:%.*]] = call fast double @__exp2_finite(double 3.000000e+00)
75 ; MUSL-NEXT: store double [[EXP2]], ptr [[SLOT]], align 8
76 ; MUSL-NEXT: [[LOG:%.*]] = call fast double @__log_finite(double 3.000000e+00)
77 ; MUSL-NEXT: store double [[LOG]], ptr [[SLOT]], align 8
78 ; MUSL-NEXT: [[LOG10:%.*]] = call fast double @__log10_finite(double 3.000000e+00)
79 ; MUSL-NEXT: store double [[LOG10]], ptr [[SLOT]], align 8
80 ; MUSL-NEXT: [[POW:%.*]] = call fast double @__pow_finite(double 1.000000e+00, double 4.000000e+00)
81 ; MUSL-NEXT: store double [[POW]], ptr [[SLOT]], align 8
82 ; MUSL-NEXT: [[SINH:%.*]] = call fast double @__sinh_finite(double 3.000000e+00)
83 ; MUSL-NEXT: store double [[SINH]], ptr [[SLOT]], align 8
84 ; MUSL-NEXT: [[ACOSF:%.*]] = call fast float @__acosf_finite(float 1.000000e+00)
85 ; MUSL-NEXT: store float [[ACOSF]], ptr [[SLOTF]], align 4
86 ; MUSL-NEXT: [[ASINF:%.*]] = call fast float @__asinf_finite(float 1.000000e+00)
87 ; MUSL-NEXT: store float [[ASINF]], ptr [[SLOTF]], align 4
88 ; MUSL-NEXT: [[ATAN2F:%.*]] = call fast float @__atan2f_finite(float 3.000000e+00, float 4.000000e+00)
89 ; MUSL-NEXT: store float [[ATAN2F]], ptr [[SLOTF]], align 4
90 ; MUSL-NEXT: [[COSHF:%.*]] = call fast float @__coshf_finite(float 3.000000e+00)
91 ; MUSL-NEXT: store float [[COSHF]], ptr [[SLOTF]], align 4
92 ; MUSL-NEXT: [[EXPF:%.*]] = call fast float @__expf_finite(float 3.000000e+00)
93 ; MUSL-NEXT: store float [[EXPF]], ptr [[SLOTF]], align 4
94 ; MUSL-NEXT: [[EXP2F:%.*]] = call fast float @__exp2f_finite(float 3.000000e+00)
95 ; MUSL-NEXT: store float [[EXP2F]], ptr [[SLOTF]], align 4
96 ; MUSL-NEXT: [[LOGF:%.*]] = call fast float @__logf_finite(float 3.000000e+00)
97 ; MUSL-NEXT: store float [[LOGF]], ptr [[SLOTF]], align 4
98 ; MUSL-NEXT: [[LOG10F:%.*]] = call fast float @__log10f_finite(float 3.000000e+00)
99 ; MUSL-NEXT: store float [[LOG10F]], ptr [[SLOTF]], align 4
100 ; MUSL-NEXT: [[POWF:%.*]] = call fast float @__powf_finite(float 3.000000e+00, float 4.000000e+00)
101 ; MUSL-NEXT: store float [[POWF]], ptr [[SLOTF]], align 4
102 ; MUSL-NEXT: [[SINHF:%.*]] = call fast float @__sinhf_finite(float 3.000000e+00)
103 ; MUSL-NEXT: store float [[SINHF]], ptr [[SLOTF]], align 4
104 ; MUSL-NEXT: ret void
107 %slot = alloca double
108 %slotf = alloca float
110 %ACOS = call fast double @__acos_finite(double 1.000000e+00)
111 store double %ACOS, ptr %slot
112 %ASIN = call fast double @__asin_finite(double 1.000000e+00)
113 store double %ASIN, ptr %slot
114 %ATAN2 = call fast double @__atan2_finite(double 3.000000e+00, double 4.000000e+00)
115 store double %ATAN2, ptr %slot
116 %COSH = call fast double @__cosh_finite(double 3.000000e+00)
117 store double %COSH, ptr %slot
118 %EXP = call fast double @__exp_finite(double 3.000000e+00)
119 store double %EXP, ptr %slot
120 %EXP2 = call fast double @__exp2_finite(double 3.000000e+00)
121 store double %EXP2, ptr %slot
122 %LOG = call fast double @__log_finite(double 3.000000e+00)
123 store double %LOG, ptr %slot
124 %LOG10 = call fast double @__log10_finite(double 3.000000e+00)
125 store double %LOG10, ptr %slot
126 %POW = call fast double @__pow_finite(double 1.000000e+00, double 4.000000e+00)
127 store double %POW, ptr %slot
128 %SINH = call fast double @__sinh_finite(double 3.000000e+00)
129 store double %SINH, ptr %slot
131 %ACOSF = call fast float @__acosf_finite(float 1.000000e+00)
132 store float %ACOSF, ptr %slotf
133 %ASINF = call fast float @__asinf_finite(float 1.000000e+00)
134 store float %ASINF, ptr %slotf
135 %ATAN2F = call fast float @__atan2f_finite(float 3.000000e+00, float 4.000000e+00)
136 store float %ATAN2F, ptr %slotf
137 %COSHF = call fast float @__coshf_finite(float 3.000000e+00)
138 store float %COSHF, ptr %slotf
139 %EXPF = call fast float @__expf_finite(float 3.000000e+00)
140 store float %EXPF, ptr %slotf
141 %EXP2F = call fast float @__exp2f_finite(float 3.000000e+00)
142 store float %EXP2F, ptr %slotf
143 %LOGF = call fast float @__logf_finite(float 3.000000e+00)
144 store float %LOGF, ptr %slotf
145 %LOG10F = call fast float @__log10f_finite(float 3.000000e+00)
146 store float %LOG10F, ptr %slotf
147 %POWF = call fast float @__powf_finite(float 3.000000e+00, float 4.000000e+00)
148 store float %POWF, ptr %slotf
149 %SINHF = call fast float @__sinhf_finite(float 3.000000e+00)
150 store float %SINHF, ptr %slotf