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 @llvm.log.f64(double [[X:%.*]])
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 define 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]]
21 %pow = call fast float @powf(float %x, float %y)
22 %log = call fast float @llvm.log10.f32(float %pow)
26 define <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]]
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)
37 define 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]]
43 %pow = call double @pow(double %x, double %y)
44 %log = call fast double @log(double %pow)
48 define 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]]
54 %ptr = call float %fptr()
55 %log = call float @logf(float %ptr)
59 define 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]]
64 %exp = call fast double @exp(double %x)
65 %log = call fast double @log10(double %exp)
69 define <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]]
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)
79 define 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]]
84 %exp = call fast float @exp10f(float %x)
85 %log = call fast float @log2f(float %exp)
89 define 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]]
95 %exp = call double @exp2(double %x)
96 %log = call fast double @log(double %exp)
100 define double @pr43617(double %d, i32 %i, double (i32)* %f) {
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
109 declare double @log(double) #0
110 declare float @logf(float) #0
111 declare double @llvm.log.f64(double) #0
112 declare <2 x float> @llvm.log.v2f32(<2 x float>)
113 declare float @log2f(float) #0
114 declare <2 x double> @llvm.log2.v2f64(<2 x double>)
115 declare double @log10(double) #0
116 declare float @llvm.log10.f32(float)
117 declare double @exp(double %x) #0
118 declare double @exp2(double) #0
119 declare float @exp10f(float) #0
120 declare <2 x float> @llvm.exp2.v2f32(<2 x float>)
121 declare double @pow(double, double) #0
122 declare float @powf(float, float) #0
123 declare <2 x double> @llvm.pow.v2f64(<2 x double>, <2 x double>)
125 attributes #0 = { nounwind readnone }