forked from OSchip/llvm-project
[InstCombine] Add more test cases (NFC)
Add more test cases simplifying `log()`. llvm-svn: 370966
This commit is contained in:
parent
09768c5d7a
commit
bf78e39cbb
|
@ -1,62 +1,121 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; 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: @log_pow(
|
||||
; CHECK-NEXT: [[LOG1:%.*]] = call fast double @log(double [[X:%.*]]) #0
|
||||
; CHECK-NEXT: [[MUL:%.*]] = fmul fast double [[LOG1]], [[Y:%.*]]
|
||||
; CHECK-NEXT: ret double [[MUL]]
|
||||
;
|
||||
%pow = call fast double @pow(double %x, double %y)
|
||||
%log = call fast double @log(double %pow)
|
||||
ret double %log
|
||||
}
|
||||
|
||||
; 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
|
||||
; FIXME: log10f() should also be simplified.
|
||||
define float @log10f_powf(float %x, float %y) {
|
||||
; CHECK-LABEL: @log10f_powf(
|
||||
; CHECK-NEXT: [[POW:%.*]] = call fast float @powf(float [[X:%.*]], float [[Y:%.*]])
|
||||
; CHECK-NEXT: [[LOG:%.*]] = call fast float @log10f(float [[POW]])
|
||||
; CHECK-NEXT: ret float [[LOG]]
|
||||
;
|
||||
%pow = call fast float @powf(float %x, float %y)
|
||||
%log = call fast float @log10f(float %pow)
|
||||
ret float %log
|
||||
}
|
||||
|
||||
; FIXME: Intrinsic log2() should also be simplified.
|
||||
define <2 x double> @log2v_powv(<2 x double> %x, <2 x double> %y) {
|
||||
; CHECK-LABEL: @log2v_powv(
|
||||
; CHECK-NEXT: [[POW:%.*]] = call fast <2 x double> @llvm.pow.v2f64(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]])
|
||||
; CHECK-NEXT: [[LOG:%.*]] = call fast <2 x double> @llvm.log2.v2f64(<2 x double> [[POW]])
|
||||
; CHECK-NEXT: ret <2 x double> [[LOG]]
|
||||
;
|
||||
%pow = call fast <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> %y)
|
||||
%log = call fast <2 x double> @llvm.log2.v2f64(<2 x double> %pow)
|
||||
ret <2 x double> %log
|
||||
}
|
||||
|
||||
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: @log_pow_not_fast(
|
||||
; CHECK-NEXT: [[POW:%.*]] = call double @pow(double [[X:%.*]], double [[Y:%.*]])
|
||||
; CHECK-NEXT: [[LOG:%.*]] = call fast double @log(double [[POW]])
|
||||
; CHECK-NEXT: ret double [[LOG]]
|
||||
;
|
||||
%pow = call double @pow(double %x, double %y)
|
||||
%log = call fast double @log(double %pow)
|
||||
ret double %log
|
||||
}
|
||||
|
||||
; 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
|
||||
define float @function_pointer(float ()* %fptr, float %p1) {
|
||||
; CHECK-LABEL: @function_pointer(
|
||||
; CHECK-NEXT: [[PTR:%.*]] = call float [[FPTR:%.*]]()
|
||||
; CHECK-NEXT: [[LOG:%.*]] = call float @logf(float [[PTR]])
|
||||
; CHECK-NEXT: ret float [[LOG]]
|
||||
;
|
||||
%ptr = call float %fptr()
|
||||
%log = call float @logf(float %ptr)
|
||||
ret float %log
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @function_pointer
|
||||
; CHECK-NEXT: %call1 = call double %fptr()
|
||||
; CHECK-NEXT: %pow = call double @log(double %call1)
|
||||
; CHECK-NEXT: ret double %pow
|
||||
|
||||
; FIXME: The call to exp2() should be removed.
|
||||
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: [[EXP:%.*]] = call fast double @exp2(double [[X:%.*]])
|
||||
; CHECK-NEXT: [[LOGMUL:%.*]] = fmul fast double [[X]], 0x3FE62E42FEFA39EF
|
||||
; CHECK-NEXT: ret double [[LOGMUL]]
|
||||
;
|
||||
%exp = call fast double @exp2(double %x)
|
||||
%log = call fast double @log(double %exp)
|
||||
ret double %log
|
||||
}
|
||||
|
||||
; 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
|
||||
; FIXME: Intrinsic logf() should also be simplified.
|
||||
define <2 x float> @logv_exp2v(<2 x float> %x) {
|
||||
; CHECK-LABEL: @logv_exp2v(
|
||||
; CHECK-NEXT: [[EXP:%.*]] = call fast <2 x float> @llvm.exp2.v2f32(<2 x float> [[X:%.*]])
|
||||
; CHECK-NEXT: [[LOG:%.*]] = call fast <2 x float> @llvm.log.v2f32(<2 x float> [[EXP]])
|
||||
; CHECK-NEXT: ret <2 x float> [[LOG]]
|
||||
;
|
||||
%exp = call fast <2 x float> @llvm.exp2.v2f32(<2 x float> %x)
|
||||
%log = call fast <2 x float> @llvm.log.v2f32(<2 x float> %exp)
|
||||
ret <2 x float> %log
|
||||
}
|
||||
|
||||
; FIXME: log10f() should also be simplified.
|
||||
define float @log10f_exp2f(float %x) {
|
||||
; CHECK-LABEL: @log10f_exp2f(
|
||||
; CHECK-NEXT: [[EXP:%.*]] = call fast float @exp2f(float [[X:%.*]])
|
||||
; CHECK-NEXT: [[LOG:%.*]] = call fast float @log10f(float [[EXP]])
|
||||
; CHECK-NEXT: ret float [[LOG]]
|
||||
;
|
||||
%exp = call fast float @exp2f(float %x)
|
||||
%log = call fast float @log10f(float %exp)
|
||||
ret float %log
|
||||
}
|
||||
|
||||
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: [[EXP:%.*]] = call double @exp2(double [[X:%.*]])
|
||||
; CHECK-NEXT: [[LOG:%.*]] = call fast double @log(double [[EXP]])
|
||||
; CHECK-NEXT: ret double [[LOG]]
|
||||
;
|
||||
%exp = call double @exp2(double %x)
|
||||
%log = call fast double @log(double %exp)
|
||||
ret double %log
|
||||
}
|
||||
|
||||
; 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 float @logf(float) #0
|
||||
declare <2 x float> @llvm.log.v2f32(<2 x float>)
|
||||
declare double @log2(double) #0
|
||||
declare <2 x double> @llvm.log2.v2f64(<2 x double>)
|
||||
declare float @log10f(float) #0
|
||||
declare double @exp2(double)
|
||||
declare double @llvm.pow.f64(double, double)
|
||||
declare float @exp2f(float)
|
||||
declare <2 x float> @llvm.exp2.v2f32(<2 x float>)
|
||||
declare double @pow(double, double) #0
|
||||
declare float @powf(float, float) #0
|
||||
declare <2 x double> @llvm.pow.v2f64(<2 x double>, <2 x double>)
|
||||
|
||||
attributes #0 = { nounwind readnone }
|
||||
|
|
Loading…
Reference in New Issue