• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -instcombine -S | FileCheck %s
2
3define double @log_pow(double %x, double %y) {
4  %pow = call fast double @llvm.pow.f64(double %x, double %y)
5  %call = call fast double @log(double %pow)
6  ret double %call
7}
8
9; CHECK-LABEL: define double @log_pow(
10; CHECK-NEXT:  %log = call fast double @log(double %x)
11; CHECK-NEXT:  %mul = fmul fast double %log, %y
12; CHECK-NEXT:  ret double %mul
13
14define double @log_pow_not_fast(double %x, double %y) {
15  %pow = call double @llvm.pow.f64(double %x, double %y)
16  %call = call fast double @log(double %pow)
17  ret double %call
18}
19
20; CHECK-LABEL: define double @log_pow_not_fast(
21; CHECK-NEXT:  %pow = call double @llvm.pow.f64(double %x, double %y)
22; CHECK-NEXT:  %call = call fast double @log(double %pow)
23; CHECK-NEXT:  ret double %call
24
25define double @function_pointer(double ()* %fptr, double %p1) {
26  %call1 = call double %fptr()
27  %pow = call double @log(double %call1)
28  ret double %pow
29}
30
31; CHECK-LABEL: @function_pointer
32; CHECK-NEXT:  %call1 = call double %fptr()
33; CHECK-NEXT:  %pow = call double @log(double %call1)
34; CHECK-NEXT:  ret double %pow
35
36define double @log_exp2(double %x) {
37  %call2 = call fast double @exp2(double %x)
38  %call3 = call fast double @log(double %call2)
39  ret double %call3
40}
41
42; CHECK-LABEL: @log_exp2
43; CHECK-NEXT:  %call2 = call fast double @exp2(double %x)
44; CHECK-NEXT:  %logmul = fmul fast double %x, 0x3FE62E42FEFA39EF
45; CHECK-NEXT:  ret double %logmul
46
47define double @log_exp2_not_fast(double %x) {
48  %call2 = call double @exp2(double %x)
49  %call3 = call fast double @log(double %call2)
50  ret double %call3
51}
52
53; CHECK-LABEL: @log_exp2_not_fast
54; CHECK-NEXT:  %call2 = call double @exp2(double %x)
55; CHECK-NEXT:  %call3 = call fast double @log(double %call2)
56; CHECK-NEXT:  ret double %call3
57
58declare double @log(double)
59declare double @exp2(double)
60declare double @llvm.pow.f64(double, double)
61
62