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