mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 20:29:53 +00:00
14834723b0
Just because we can constant fold the result of an instruction does not imply that we can delete the instruction. It may have side effects. This fixes PR28655. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276389 91177308-0d34-0410-b5e6-96231b3b80d8
63 lines
1.9 KiB
LLVM
63 lines
1.9 KiB
LLVM
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
|
|
define double @log_pow(double %x, double %y) {
|
|
%pow = call fast double @llvm.pow.f64(double %x, double %y)
|
|
%call = call fast double @log(double %pow)
|
|
ret double %call
|
|
}
|
|
|
|
; CHECK-LABEL: define double @log_pow(
|
|
; CHECK-NEXT: %log = call fast double @log(double %x)
|
|
; CHECK-NEXT: %mul = fmul fast double %log, %y
|
|
; CHECK-NEXT: ret double %mul
|
|
|
|
define double @log_pow_not_fast(double %x, double %y) {
|
|
%pow = call double @llvm.pow.f64(double %x, double %y)
|
|
%call = call fast double @log(double %pow)
|
|
ret double %call
|
|
}
|
|
|
|
; CHECK-LABEL: define double @log_pow_not_fast(
|
|
; CHECK-NEXT: %pow = call double @llvm.pow.f64(double %x, double %y)
|
|
; CHECK-NEXT: %call = call fast double @log(double %pow)
|
|
; CHECK-NEXT: ret double %call
|
|
|
|
define double @function_pointer(double ()* %fptr, double %p1) {
|
|
%call1 = call double %fptr()
|
|
%pow = call double @log(double %call1)
|
|
ret double %pow
|
|
}
|
|
|
|
; CHECK-LABEL: @function_pointer
|
|
; CHECK-NEXT: %call1 = call double %fptr()
|
|
; CHECK-NEXT: %pow = call double @log(double %call1)
|
|
; CHECK-NEXT: ret double %pow
|
|
|
|
define double @log_exp2(double %x) {
|
|
%call2 = call fast double @exp2(double %x)
|
|
%call3 = call fast double @log(double %call2)
|
|
ret double %call3
|
|
}
|
|
|
|
; CHECK-LABEL: @log_exp2
|
|
; CHECK-NEXT: %call2 = call fast double @exp2(double %x)
|
|
; CHECK-NEXT: %logmul = fmul fast double %x, 0x3FE62E42FEFA39EF
|
|
; CHECK-NEXT: ret double %logmul
|
|
|
|
define double @log_exp2_not_fast(double %x) {
|
|
%call2 = call double @exp2(double %x)
|
|
%call3 = call fast double @log(double %call2)
|
|
ret double %call3
|
|
}
|
|
|
|
; CHECK-LABEL: @log_exp2_not_fast
|
|
; CHECK-NEXT: %call2 = call double @exp2(double %x)
|
|
; CHECK-NEXT: %call3 = call fast double @log(double %call2)
|
|
; CHECK-NEXT: ret double %call3
|
|
|
|
declare double @log(double) #0
|
|
declare double @exp2(double)
|
|
declare double @llvm.pow.f64(double, double)
|
|
|
|
attributes #0 = { nounwind readnone }
|