aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/log-pow.ll
blob: c5ca1688d34ac5a87890b5fdd64d733aeb16a090 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
; RUN: opt < %s -instcombine -S | FileCheck %s

define double @mylog(double %x, double %y) #0 {
entry:
  %pow = call double @llvm.pow.f64(double %x, double %y)
  %call = call double @log(double %pow) #0
  ret double %call
}

; CHECK-LABEL: define double @mylog(
; CHECK:   %log = call fast double @log(double %x) #0
; CHECK:   %mul = fmul fast double %log, %y
; CHECK:   ret double %mul
; CHECK: }

define double @test2(double ()* %fptr, double %p1) #0 {
  %call1 = call double %fptr()
  %pow = call double @log(double %call1)
  ret double %pow
}

; CHECK-LABEL: @test2
; CHECK: log

define double @test3(double %x) #0 {
  %call2 = call double @exp2(double %x) #0
  %call3 = call double @log(double %call2) #0
  ret double %call3
}

; CHECK-LABEL: @test3
; CHECK:  %call2 = call double @exp2(double %x) #0
; CHECK:  %logmul = fmul fast double %x, 0x3FE62E42FEFA39EF
; CHECK:  ret double %logmul
; CHECK: }

declare double @log(double) #0
declare double @exp2(double) #0
declare double @llvm.pow.f64(double, double)

attributes #0 = { "unsafe-fp-math"="true" }