1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instcombine -S | FileCheck %s
3
4define double @log_pow(double %x, double %y) {
5; CHECK-LABEL: @log_pow(
6; CHECK-NEXT:    [[LOG1:%.*]] = call fast double @llvm.log.f64(double [[X:%.*]])
7; CHECK-NEXT:    [[MUL:%.*]] = fmul fast double [[LOG1]], [[Y:%.*]]
8; CHECK-NEXT:    ret double [[MUL]]
9;
10  %pow = call fast double @pow(double %x, double %y)
11  %log = call fast double @log(double %pow)
12  ret double %log
13}
14
15define float @log10f_powf(float %x, float %y) {
16; CHECK-LABEL: @log10f_powf(
17; CHECK-NEXT:    [[LOG1:%.*]] = call fast float @llvm.log10.f32(float [[X:%.*]])
18; CHECK-NEXT:    [[MUL:%.*]] = fmul fast float [[LOG1]], [[Y:%.*]]
19; CHECK-NEXT:    ret float [[MUL]]
20;
21  %pow = call fast float @powf(float %x, float %y)
22  %log = call fast float @llvm.log10.f32(float %pow)
23  ret float %log
24}
25
26define <2 x double> @log2v_powv(<2 x double> %x, <2 x double> %y) {
27; CHECK-LABEL: @log2v_powv(
28; CHECK-NEXT:    [[LOG1:%.*]] = call fast <2 x double> @llvm.log2.v2f64(<2 x double> [[X:%.*]])
29; CHECK-NEXT:    [[MUL:%.*]] = fmul fast <2 x double> [[LOG1]], [[Y:%.*]]
30; CHECK-NEXT:    ret <2 x double> [[MUL]]
31;
32  %pow = call fast <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> %y)
33  %log = call fast <2 x double> @llvm.log2.v2f64(<2 x double> %pow)
34  ret <2 x double> %log
35}
36
37define double @log_pow_not_fast(double %x, double %y) {
38; CHECK-LABEL: @log_pow_not_fast(
39; CHECK-NEXT:    [[POW:%.*]] = call double @pow(double [[X:%.*]], double [[Y:%.*]])
40; CHECK-NEXT:    [[LOG:%.*]] = call fast double @log(double [[POW]])
41; CHECK-NEXT:    ret double [[LOG]]
42;
43  %pow = call double @pow(double %x, double %y)
44  %log = call fast double @log(double %pow)
45  ret double %log
46}
47
48define float @function_pointer(float ()* %fptr, float %p1) {
49; CHECK-LABEL: @function_pointer(
50; CHECK-NEXT:    [[PTR:%.*]] = call float [[FPTR:%.*]]()
51; CHECK-NEXT:    [[LOG:%.*]] = call float @logf(float [[PTR]])
52; CHECK-NEXT:    ret float [[LOG]]
53;
54  %ptr = call float %fptr()
55  %log = call float @logf(float %ptr)
56  ret float %log
57}
58
59define double @log10_exp(double %x) {
60; CHECK-LABEL: @log10_exp(
61; CHECK-NEXT:    [[MUL:%.*]] = fmul fast double [[X:%.*]], 0x3FDBCB7B1526E50E
62; CHECK-NEXT:    ret double [[MUL]]
63;
64  %exp = call fast double @exp(double %x)
65  %log = call fast double @log10(double %exp)
66  ret double %log
67}
68
69define <2 x float> @logv_exp2v(<2 x float> %x) {
70; CHECK-LABEL: @logv_exp2v(
71; CHECK-NEXT:    [[MUL:%.*]] = fmul fast <2 x float> [[X:%.*]], <float 0x3FE62E4300000000, float 0x3FE62E4300000000>
72; CHECK-NEXT:    ret <2 x float> [[MUL]]
73;
74  %exp = call fast <2 x float> @llvm.exp2.v2f32(<2 x float> %x)
75  %log = call fast <2 x float> @llvm.log.v2f32(<2 x float> %exp)
76  ret <2 x float> %log
77}
78
79define float @log2f_exp10f(float %x) {
80; CHECK-LABEL: @log2f_exp10f(
81; CHECK-NEXT:    [[MUL:%.*]] = fmul fast float [[X:%.*]], 0x400A934F00000000
82; CHECK-NEXT:    ret float [[MUL]]
83;
84  %exp = call fast float @exp10f(float %x)
85  %log = call fast float @log2f(float %exp)
86  ret float %log
87}
88
89define double @log_exp2_not_fast(double %x) {
90; CHECK-LABEL: @log_exp2_not_fast(
91; CHECK-NEXT:    [[EXP:%.*]] = call double @exp2(double [[X:%.*]])
92; CHECK-NEXT:    [[LOG:%.*]] = call fast double @log(double [[EXP]])
93; CHECK-NEXT:    ret double [[LOG]]
94;
95  %exp = call double @exp2(double %x)
96  %log = call fast double @log(double %exp)
97  ret double %log
98}
99
100define double @pr43617(double %d, i32 %i, double (i32)* %f) {
101entry:
102  %sub = fsub double -0.000000e+00, %d
103  %icall = tail call fast double %f(i32 %i)
104  %log = tail call fast double @llvm.log.f64(double %icall)
105  %mul = fmul double %log, %sub
106  ret double %mul
107}
108
109declare double @log(double) #0
110declare float @logf(float) #0
111declare double @llvm.log.f64(double) #0
112declare <2 x float> @llvm.log.v2f32(<2 x float>)
113declare float @log2f(float) #0
114declare <2 x double> @llvm.log2.v2f64(<2 x double>)
115declare double @log10(double) #0
116declare float @llvm.log10.f32(float)
117declare double @exp(double %x) #0
118declare double @exp2(double) #0
119declare float @exp10f(float) #0
120declare <2 x float> @llvm.exp2.v2f32(<2 x float>)
121declare double @pow(double, double) #0
122declare float @powf(float, float) #0
123declare <2 x double> @llvm.pow.v2f64(<2 x double>, <2 x double>)
124
125attributes #0 = { nounwind readnone }
126