blob: 594594abd7d14b30425b0b644d900c8f9383d38a [file] [log] [blame]
Davide Italianoc8a79132015-11-03 20:32:23 +00001; RUN: opt < %s -instcombine -S | FileCheck %s
2
Sanjay Patel6002e782016-01-12 17:30:37 +00003define double @pow_exp(double %x, double %y) {
4 %call = call fast double @exp(double %x) nounwind readnone
Sanjay Patel71e550f2016-01-12 16:50:17 +00005 %pow = call fast double @llvm.pow.f64(double %call, double %y)
6 ret double %pow
7}
8
9; CHECK-LABEL: define double @pow_exp(
10; CHECK-NEXT: %mul = fmul fast double %x, %y
11; CHECK-NEXT: %exp = call fast double @exp(double %mul)
12; CHECK-NEXT: ret double %exp
13
Sanjay Patel6002e782016-01-12 17:30:37 +000014define double @pow_exp2(double %x, double %y) {
15 %call = call fast double @exp2(double %x) nounwind readnone
Sanjay Pateldc19b8d2016-01-12 17:00:38 +000016 %pow = call fast double @llvm.pow.f64(double %call, double %y)
17 ret double %pow
18}
19
20; CHECK-LABEL: define double @pow_exp2(
21; CHECK-NEXT: %mul = fmul fast double %x, %y
22; CHECK-NEXT: %exp2 = call fast double @exp2(double %mul)
23; CHECK-NEXT: ret double %exp2
24
Sanjay Patel6002e782016-01-12 17:30:37 +000025define double @pow_exp_not_fast(double %x, double %y) {
Davide Italianoc8a79132015-11-03 20:32:23 +000026 %call = call double @exp(double %x)
Sanjay Patel71e550f2016-01-12 16:50:17 +000027 %pow = call fast double @llvm.pow.f64(double %call, double %y)
Davide Italianoc8a79132015-11-03 20:32:23 +000028 ret double %pow
29}
30
Sanjay Patel71e550f2016-01-12 16:50:17 +000031; CHECK-LABEL: define double @pow_exp_not_fast(
32; CHECK-NEXT: %call = call double @exp(double %x)
Sanjay Patel6002e782016-01-12 17:30:37 +000033; CHECK-NEXT: %pow = call fast double @llvm.pow.f64(double %call, double %y)
34; CHECK-NEXT: ret double %pow
Davide Italianoc8a79132015-11-03 20:32:23 +000035
Sanjay Patel6002e782016-01-12 17:30:37 +000036define double @function_pointer(double ()* %fptr, double %p1) {
Sanjay Patel71e550f2016-01-12 16:50:17 +000037 %call1 = call fast double %fptr()
38 %pow = call fast double @llvm.pow.f64(double %call1, double %p1)
Benjamin Kramerfb419e72015-11-26 09:51:17 +000039 ret double %pow
40}
41
Sanjay Patel71e550f2016-01-12 16:50:17 +000042; CHECK-LABEL: @function_pointer
43; CHECK-NEXT: %call1 = call fast double %fptr()
44; CHECK-NEXT: %pow = call fast double @llvm.pow.f64(double %call1, double %p1)
Benjamin Kramerfb419e72015-11-26 09:51:17 +000045
Sanjay Patel71e550f2016-01-12 16:50:17 +000046declare double @exp(double)
Sanjay Pateldc19b8d2016-01-12 17:00:38 +000047declare double @exp2(double)
Davide Italianoc8a79132015-11-03 20:32:23 +000048declare double @llvm.pow.f64(double, double)
Sanjay Patel71e550f2016-01-12 16:50:17 +000049