1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 define double @log_pow(double %x, double %y) {
5 ; CHECK-LABEL: @log_pow(
6 ; CHECK-NEXT: [[LOG1:%.*]] = call fast double @log(double [[X:%.*]]) #0
7 ; CHECK-NEXT: [[MUL:%.*]] = fmul fast double [[LOG1]], [[Y:%.*]]
8 ; CHECK-NEXT: ret double [[MUL]]
10 %pow = call fast double @pow(double %x, double %y)
11 %log = call fast double @log(double %pow)
15 ; FIXME: log10f() should also be simplified.
16 define float @log10f_powf(float %x, float %y) {
17 ; CHECK-LABEL: @log10f_powf(
18 ; CHECK-NEXT: [[POW:%.*]] = call fast float @powf(float [[X:%.*]], float [[Y:%.*]])
19 ; CHECK-NEXT: [[LOG:%.*]] = call fast float @log10f(float [[POW]])
20 ; CHECK-NEXT: ret float [[LOG]]
22 %pow = call fast float @powf(float %x, float %y)
23 %log = call fast float @log10f(float %pow)
27 ; FIXME: Intrinsic log2() should also be simplified.
28 define <2 x double> @log2v_powv(<2 x double> %x, <2 x double> %y) {
29 ; CHECK-LABEL: @log2v_powv(
30 ; CHECK-NEXT: [[POW:%.*]] = call fast <2 x double> @llvm.pow.v2f64(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]])
31 ; CHECK-NEXT: [[LOG:%.*]] = call fast <2 x double> @llvm.log2.v2f64(<2 x double> [[POW]])
32 ; CHECK-NEXT: ret <2 x double> [[LOG]]
34 %pow = call fast <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> %y)
35 %log = call fast <2 x double> @llvm.log2.v2f64(<2 x double> %pow)
39 define double @log_pow_not_fast(double %x, double %y) {
40 ; CHECK-LABEL: @log_pow_not_fast(
41 ; CHECK-NEXT: [[POW:%.*]] = call double @pow(double [[X:%.*]], double [[Y:%.*]])
42 ; CHECK-NEXT: [[LOG:%.*]] = call fast double @log(double [[POW]])
43 ; CHECK-NEXT: ret double [[LOG]]
45 %pow = call double @pow(double %x, double %y)
46 %log = call fast double @log(double %pow)
50 define float @function_pointer(float ()* %fptr, float %p1) {
51 ; CHECK-LABEL: @function_pointer(
52 ; CHECK-NEXT: [[PTR:%.*]] = call float [[FPTR:%.*]]()
53 ; CHECK-NEXT: [[LOG:%.*]] = call float @logf(float [[PTR]])
54 ; CHECK-NEXT: ret float [[LOG]]
56 %ptr = call float %fptr()
57 %log = call float @logf(float %ptr)
61 ; FIXME: The call to exp2() should be removed.
62 define double @log_exp2(double %x) {
63 ; CHECK-LABEL: @log_exp2(
64 ; CHECK-NEXT: [[EXP:%.*]] = call fast double @exp2(double [[X:%.*]])
65 ; CHECK-NEXT: [[LOGMUL:%.*]] = fmul fast double [[X]], 0x3FE62E42FEFA39EF
66 ; CHECK-NEXT: ret double [[LOGMUL]]
68 %exp = call fast double @exp2(double %x)
69 %log = call fast double @log(double %exp)
73 ; FIXME: Intrinsic logf() should also be simplified.
74 define <2 x float> @logv_exp2v(<2 x float> %x) {
75 ; CHECK-LABEL: @logv_exp2v(
76 ; CHECK-NEXT: [[EXP:%.*]] = call fast <2 x float> @llvm.exp2.v2f32(<2 x float> [[X:%.*]])
77 ; CHECK-NEXT: [[LOG:%.*]] = call fast <2 x float> @llvm.log.v2f32(<2 x float> [[EXP]])
78 ; CHECK-NEXT: ret <2 x float> [[LOG]]
80 %exp = call fast <2 x float> @llvm.exp2.v2f32(<2 x float> %x)
81 %log = call fast <2 x float> @llvm.log.v2f32(<2 x float> %exp)
85 ; FIXME: log10f() should also be simplified.
86 define float @log10f_exp2f(float %x) {
87 ; CHECK-LABEL: @log10f_exp2f(
88 ; CHECK-NEXT: [[EXP:%.*]] = call fast float @exp2f(float [[X:%.*]])
89 ; CHECK-NEXT: [[LOG:%.*]] = call fast float @log10f(float [[EXP]])
90 ; CHECK-NEXT: ret float [[LOG]]
92 %exp = call fast float @exp2f(float %x)
93 %log = call fast float @log10f(float %exp)
97 define double @log_exp2_not_fast(double %x) {
98 ; CHECK-LABEL: @log_exp2_not_fast(
99 ; CHECK-NEXT: [[EXP:%.*]] = call double @exp2(double [[X:%.*]])
100 ; CHECK-NEXT: [[LOG:%.*]] = call fast double @log(double [[EXP]])
101 ; CHECK-NEXT: ret double [[LOG]]
103 %exp = call double @exp2(double %x)
104 %log = call fast double @log(double %exp)
108 declare double @log(double) #0
109 declare float @logf(float) #0
110 declare <2 x float> @llvm.log.v2f32(<2 x float>)
111 declare double @log2(double) #0
112 declare <2 x double> @llvm.log2.v2f64(<2 x double>)
113 declare float @log10f(float) #0
114 declare double @exp2(double)
115 declare float @exp2f(float)
116 declare <2 x float> @llvm.exp2.v2f32(<2 x float>)
117 declare double @pow(double, double) #0
118 declare float @powf(float, float) #0
119 declare <2 x double> @llvm.pow.v2f64(<2 x double>, <2 x double>)
121 attributes #0 = { nounwind readnone }