blob: 7e36eadb4026328cfe5a110e1052a50dbb1ad192 [file] [log] [blame]
Davide Italianoc8a79132015-11-03 20:32:23 +00001; RUN: opt < %s -instcombine -S | FileCheck %s
2
Sanjay Patel71e550f2016-01-12 16:50:17 +00003define double @pow_exp(double %x, double %y) #0 {
4 %call = call fast double @exp(double %x) #0
5 %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
14; FIXME: This should not be transformed because the 'exp' call is not fast.
15define double @pow_exp_not_fast(double %x, double %y) #0 {
Davide Italianoc8a79132015-11-03 20:32:23 +000016 %call = call double @exp(double %x)
Sanjay Patel71e550f2016-01-12 16:50:17 +000017 %pow = call fast double @llvm.pow.f64(double %call, double %y)
Davide Italianoc8a79132015-11-03 20:32:23 +000018 ret double %pow
19}
20
Sanjay Patel71e550f2016-01-12 16:50:17 +000021; CHECK-LABEL: define double @pow_exp_not_fast(
22; CHECK-NEXT: %call = call double @exp(double %x)
23; CHECK-NEXT: %mul = fmul fast double %x, %y
24; CHECK-NEXT: %exp = call fast double @exp(double %mul)
25; CHECK-NEXT: ret double %exp
Davide Italianoc8a79132015-11-03 20:32:23 +000026
Sanjay Patel71e550f2016-01-12 16:50:17 +000027define double @function_pointer(double ()* %fptr, double %p1) #0 {
28 %call1 = call fast double %fptr()
29 %pow = call fast double @llvm.pow.f64(double %call1, double %p1)
Benjamin Kramerfb419e72015-11-26 09:51:17 +000030 ret double %pow
31}
32
Sanjay Patel71e550f2016-01-12 16:50:17 +000033; CHECK-LABEL: @function_pointer
34; CHECK-NEXT: %call1 = call fast double %fptr()
35; CHECK-NEXT: %pow = call fast double @llvm.pow.f64(double %call1, double %p1)
Benjamin Kramerfb419e72015-11-26 09:51:17 +000036
Sanjay Patel71e550f2016-01-12 16:50:17 +000037declare double @exp(double)
Davide Italianoc8a79132015-11-03 20:32:23 +000038declare double @llvm.pow.f64(double, double)
Sanjay Patel71e550f2016-01-12 16:50:17 +000039attributes #0 = { "unsafe-fp-math"="true" nounwind readnone }
40