xref: /llvm-project/llvm/test/Transforms/InstSimplify/ConstProp/calls.ll (revision 04b944e23050e4e0c6ee983cc9bc17740315ea4f)
1b280ee1dSBjorn Pettersson; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
2b280ee1dSBjorn Pettersson; RUN: opt < %s -passes=instsimplify -disable-simplify-libcalls -S | FileCheck %s --check-prefix=FNOBUILTIN
3486ed885SArthur Eubanks
49d279621SNikita Popovdeclare double @acos(double) readnone nounwind willreturn
59d279621SNikita Popovdeclare double @asin(double) readnone nounwind willreturn
69d279621SNikita Popovdeclare double @atan(double) readnone nounwind willreturn
79d279621SNikita Popovdeclare double @atan2(double, double) readnone nounwind willreturn
89d279621SNikita Popovdeclare double @ceil(double) readnone nounwind willreturn
99d279621SNikita Popovdeclare double @cos(double) readnone nounwind willreturn
109d279621SNikita Popovdeclare double @cosh(double) readnone nounwind willreturn
119d279621SNikita Popovdeclare double @exp(double) readnone nounwind willreturn
129d279621SNikita Popovdeclare double @exp2(double) readnone nounwind willreturn
139d279621SNikita Popovdeclare double @fabs(double) readnone nounwind willreturn
149d279621SNikita Popovdeclare double @floor(double) readnone nounwind willreturn
159d279621SNikita Popovdeclare double @fmod(double, double) readnone nounwind willreturn
169d279621SNikita Popovdeclare double @log(double) readnone nounwind willreturn
179d279621SNikita Popovdeclare double @log10(double) readnone nounwind willreturn
189d279621SNikita Popovdeclare double @pow(double, double) readnone nounwind willreturn
199d279621SNikita Popovdeclare double @round(double) readnone nounwind willreturn
209d279621SNikita Popovdeclare double @sin(double) readnone nounwind willreturn
219d279621SNikita Popovdeclare double @sinh(double) readnone nounwind willreturn
229d279621SNikita Popovdeclare double @sqrt(double) readnone nounwind willreturn
239d279621SNikita Popovdeclare double @tan(double) readnone nounwind willreturn
249d279621SNikita Popovdeclare double @tanh(double) readnone nounwind willreturn
25486ed885SArthur Eubanks
269d279621SNikita Popovdeclare float @acosf(float) readnone nounwind willreturn
279d279621SNikita Popovdeclare float @asinf(float) readnone nounwind willreturn
289d279621SNikita Popovdeclare float @atanf(float) readnone nounwind willreturn
299d279621SNikita Popovdeclare float @atan2f(float, float) readnone nounwind willreturn
309d279621SNikita Popovdeclare float @ceilf(float) readnone nounwind willreturn
319d279621SNikita Popovdeclare float @cosf(float) readnone nounwind willreturn
329d279621SNikita Popovdeclare float @coshf(float) readnone nounwind willreturn
339d279621SNikita Popovdeclare float @expf(float) readnone nounwind willreturn
349d279621SNikita Popovdeclare float @exp2f(float) readnone nounwind willreturn
359d279621SNikita Popovdeclare float @fabsf(float) readnone nounwind willreturn
369d279621SNikita Popovdeclare float @floorf(float) readnone nounwind willreturn
379d279621SNikita Popovdeclare float @fmodf(float, float) readnone nounwind willreturn
389d279621SNikita Popovdeclare float @logf(float) readnone nounwind willreturn
399d279621SNikita Popovdeclare float @log10f(float) readnone nounwind willreturn
409d279621SNikita Popovdeclare float @powf(float, float) readnone nounwind willreturn
419d279621SNikita Popovdeclare float @roundf(float) readnone nounwind willreturn
429d279621SNikita Popovdeclare float @sinf(float) readnone nounwind willreturn
439d279621SNikita Popovdeclare float @sinhf(float) readnone nounwind willreturn
449d279621SNikita Popovdeclare float @sqrtf(float) readnone nounwind willreturn
459d279621SNikita Popovdeclare float @tanf(float) readnone nounwind willreturn
469d279621SNikita Popovdeclare float @tanhf(float) readnone nounwind willreturn
47486ed885SArthur Eubanks
48486ed885SArthur Eubanksdefine double @T() {
49486ed885SArthur Eubanks; CHECK-LABEL: @T(
50486ed885SArthur Eubanks; FNOBUILTIN-LABEL: @T(
51486ed885SArthur Eubanks
52486ed885SArthur Eubanks; CHECK-NOT: call
53486ed885SArthur Eubanks; CHECK: ret
54486ed885SArthur Eubanks  %A = call double @cos(double 0.000000e+00)
55486ed885SArthur Eubanks  %B = call double @sin(double 0.000000e+00)
56486ed885SArthur Eubanks  %a = fadd double %A, %B
57486ed885SArthur Eubanks  %C = call double @tan(double 0.000000e+00)
58486ed885SArthur Eubanks  %b = fadd double %a, %C
59486ed885SArthur Eubanks  %D = call double @sqrt(double 4.000000e+00)
60486ed885SArthur Eubanks  %c = fadd double %b, %D
61486ed885SArthur Eubanks
62486ed885SArthur Eubanks  %slot = alloca double
63486ed885SArthur Eubanks  %slotf = alloca float
64486ed885SArthur Eubanks; FNOBUILTIN: call
65486ed885SArthur Eubanks  %1 = call double @acos(double 1.000000e+00)
66*04b944e2SNikita Popov  store double %1, ptr %slot
67486ed885SArthur Eubanks; FNOBUILTIN: call
68486ed885SArthur Eubanks  %2 = call double @asin(double 1.000000e+00)
69*04b944e2SNikita Popov  store double %2, ptr %slot
70486ed885SArthur Eubanks; FNOBUILTIN: call
71486ed885SArthur Eubanks  %3 = call double @atan(double 3.000000e+00)
72*04b944e2SNikita Popov  store double %3, ptr %slot
73486ed885SArthur Eubanks; FNOBUILTIN: call
74486ed885SArthur Eubanks  %4 = call double @atan2(double 3.000000e+00, double 4.000000e+00)
75*04b944e2SNikita Popov  store double %4, ptr %slot
76486ed885SArthur Eubanks; FNOBUILTIN: call
77486ed885SArthur Eubanks  %5 = call double @ceil(double 3.000000e+00)
78*04b944e2SNikita Popov  store double %5, ptr %slot
79486ed885SArthur Eubanks; FNOBUILTIN: call
80486ed885SArthur Eubanks  %6 = call double @cosh(double 3.000000e+00)
81*04b944e2SNikita Popov  store double %6, ptr %slot
82486ed885SArthur Eubanks; FNOBUILTIN: call
83486ed885SArthur Eubanks  %7 = call double @exp(double 3.000000e+00)
84*04b944e2SNikita Popov  store double %7, ptr %slot
85486ed885SArthur Eubanks; FNOBUILTIN: call
86486ed885SArthur Eubanks  %8 = call double @exp2(double 3.000000e+00)
87*04b944e2SNikita Popov  store double %8, ptr %slot
88486ed885SArthur Eubanks; FNOBUILTIN: call
89486ed885SArthur Eubanks  %9 = call double @fabs(double 3.000000e+00)
90*04b944e2SNikita Popov  store double %9, ptr %slot
91486ed885SArthur Eubanks; FNOBUILTIN: call
92486ed885SArthur Eubanks  %10 = call double @floor(double 3.000000e+00)
93*04b944e2SNikita Popov  store double %10, ptr %slot
94486ed885SArthur Eubanks; FNOBUILTIN: call
95486ed885SArthur Eubanks  %11 = call double @fmod(double 3.000000e+00, double 4.000000e+00)
96*04b944e2SNikita Popov  store double %11, ptr %slot
97486ed885SArthur Eubanks; FNOBUILTIN: call
98486ed885SArthur Eubanks  %12 = call double @log(double 3.000000e+00)
99*04b944e2SNikita Popov  store double %12, ptr %slot
100486ed885SArthur Eubanks; FNOBUILTIN: call
101486ed885SArthur Eubanks  %13 = call double @log10(double 3.000000e+00)
102*04b944e2SNikita Popov  store double %13, ptr %slot
103486ed885SArthur Eubanks; FNOBUILTIN: call
104486ed885SArthur Eubanks  %14 = call double @pow(double 3.000000e+00, double 4.000000e+00)
105*04b944e2SNikita Popov  store double %14, ptr %slot
106486ed885SArthur Eubanks; FNOBUILTIN: call
107486ed885SArthur Eubanks  %round_val = call double @round(double 3.000000e+00)
108*04b944e2SNikita Popov  store double %round_val, ptr %slot
109486ed885SArthur Eubanks; FNOBUILTIN: call
110486ed885SArthur Eubanks  %15 = call double @sinh(double 3.000000e+00)
111*04b944e2SNikita Popov  store double %15, ptr %slot
112486ed885SArthur Eubanks; FNOBUILTIN: call
113486ed885SArthur Eubanks  %16 = call double @tanh(double 3.000000e+00)
114*04b944e2SNikita Popov  store double %16, ptr %slot
115486ed885SArthur Eubanks; FNOBUILTIN: call
116486ed885SArthur Eubanks  %17 = call float @acosf(float 1.000000e+00)
117*04b944e2SNikita Popov  store float %17, ptr %slotf
118486ed885SArthur Eubanks; FNOBUILTIN: call
119486ed885SArthur Eubanks  %18 = call float @asinf(float 1.000000e+00)
120*04b944e2SNikita Popov  store float %18, ptr %slotf
121486ed885SArthur Eubanks; FNOBUILTIN: call
122486ed885SArthur Eubanks  %19 = call float @atanf(float 3.000000e+00)
123*04b944e2SNikita Popov  store float %19, ptr %slotf
124486ed885SArthur Eubanks; FNOBUILTIN: call
125486ed885SArthur Eubanks  %20 = call float @atan2f(float 3.000000e+00, float 4.000000e+00)
126*04b944e2SNikita Popov  store float %20, ptr %slotf
127486ed885SArthur Eubanks; FNOBUILTIN: call
128486ed885SArthur Eubanks  %21 = call float @ceilf(float 3.000000e+00)
129*04b944e2SNikita Popov  store float %21, ptr %slotf
130486ed885SArthur Eubanks; FNOBUILTIN: call
131486ed885SArthur Eubanks  %22 = call float @cosf(float 3.000000e+00)
132*04b944e2SNikita Popov  store float %22, ptr %slotf
133486ed885SArthur Eubanks; FNOBUILTIN: call
134486ed885SArthur Eubanks  %23 = call float @coshf(float 3.000000e+00)
135*04b944e2SNikita Popov  store float %23, ptr %slotf
136486ed885SArthur Eubanks; FNOBUILTIN: call
137486ed885SArthur Eubanks  %24 = call float @expf(float 3.000000e+00)
138*04b944e2SNikita Popov  store float %24, ptr %slotf
139486ed885SArthur Eubanks; FNOBUILTIN: call
140486ed885SArthur Eubanks  %25 = call float @exp2f(float 3.000000e+00)
141*04b944e2SNikita Popov  store float %25, ptr %slotf
142486ed885SArthur Eubanks; FNOBUILTIN: call
143486ed885SArthur Eubanks  %26 = call float @fabsf(float 3.000000e+00)
144*04b944e2SNikita Popov  store float %26, ptr %slotf
145486ed885SArthur Eubanks; FNOBUILTIN: call
146486ed885SArthur Eubanks  %27 = call float @floorf(float 3.000000e+00)
147*04b944e2SNikita Popov  store float %27, ptr %slotf
148486ed885SArthur Eubanks; FNOBUILTIN: call
149486ed885SArthur Eubanks  %28 = call float @fmodf(float 3.000000e+00, float 4.000000e+00)
150*04b944e2SNikita Popov  store float %28, ptr %slotf
151486ed885SArthur Eubanks; FNOBUILTIN: call
152486ed885SArthur Eubanks  %29 = call float @logf(float 3.000000e+00)
153*04b944e2SNikita Popov  store float %29, ptr %slotf
154486ed885SArthur Eubanks; FNOBUILTIN: call
155486ed885SArthur Eubanks  %30 = call float @log10f(float 3.000000e+00)
156*04b944e2SNikita Popov  store float %30, ptr %slotf
157486ed885SArthur Eubanks; FNOBUILTIN: call
158486ed885SArthur Eubanks  %31 = call float @powf(float 3.000000e+00, float 4.000000e+00)
159*04b944e2SNikita Popov  store float %31, ptr %slotf
160486ed885SArthur Eubanks; FNOBUILTIN: call
161486ed885SArthur Eubanks  %roundf_val = call float @roundf(float 3.000000e+00)
162*04b944e2SNikita Popov  store float %roundf_val, ptr %slotf
163486ed885SArthur Eubanks; FNOBUILTIN: call
164486ed885SArthur Eubanks  %32 = call float @sinf(float 3.000000e+00)
165*04b944e2SNikita Popov  store float %32, ptr %slotf
166486ed885SArthur Eubanks; FNOBUILTIN: call
167486ed885SArthur Eubanks  %33 = call float @sinhf(float 3.000000e+00)
168*04b944e2SNikita Popov  store float %33, ptr %slotf
169486ed885SArthur Eubanks; FNOBUILTIN: call
170486ed885SArthur Eubanks  %34 = call float @sqrtf(float 3.000000e+00)
171*04b944e2SNikita Popov  store float %34, ptr %slotf
172486ed885SArthur Eubanks; FNOBUILTIN: call
173486ed885SArthur Eubanks  %35 = call float @tanf(float 3.000000e+00)
174*04b944e2SNikita Popov  store float %35, ptr %slotf
175486ed885SArthur Eubanks; FNOBUILTIN: call
176486ed885SArthur Eubanks  %36 = call float @tanhf(float 3.000000e+00)
177*04b944e2SNikita Popov  store float %36, ptr %slotf
178486ed885SArthur Eubanks
179486ed885SArthur Eubanks; FNOBUILTIN: ret
180486ed885SArthur Eubanks
181486ed885SArthur Eubanks  ; PR9315
182486ed885SArthur Eubanks  %E = call double @exp2(double 4.0)
183486ed885SArthur Eubanks  %d = fadd double %c, %E
184486ed885SArthur Eubanks  ret double %d
185486ed885SArthur Eubanks}
186486ed885SArthur Eubanks
187486ed885SArthur Eubanksdefine double @test_intrinsic_pow() nounwind uwtable ssp {
188486ed885SArthur Eubanksentry:
189486ed885SArthur Eubanks; CHECK-LABEL: @test_intrinsic_pow(
190486ed885SArthur Eubanks; CHECK-NOT: call
191486ed885SArthur Eubanks; CHECK: ret
192486ed885SArthur Eubanks  %0 = call double @llvm.pow.f64(double 1.500000e+00, double 3.000000e+00)
193486ed885SArthur Eubanks  ret double %0
194486ed885SArthur Eubanks}
195486ed885SArthur Eubanks
196486ed885SArthur Eubanksdefine float @test_intrinsic_pow_f32_overflow() nounwind uwtable ssp {
197486ed885SArthur Eubanksentry:
198486ed885SArthur Eubanks; CHECK-LABEL: @test_intrinsic_pow_f32_overflow(
199486ed885SArthur Eubanks; CHECK-NOT: call
200486ed885SArthur Eubanks; CHECK: ret float 0x7FF0000000000000
201486ed885SArthur Eubanks  %0 = call float @llvm.pow.f32(float 40.0, float 50.0)
202486ed885SArthur Eubanks  ret float %0
203486ed885SArthur Eubanks}
204486ed885SArthur Eubanks
205486ed885SArthur Eubanksdeclare double @llvm.pow.f64(double, double) nounwind readonly
206486ed885SArthur Eubanksdeclare float @llvm.pow.f32(float, float) nounwind readonly
207