[llvm] r370966 - [InstCombine] Add more test cases (NFC)
Evandro Menezes via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 13:01:09 PDT 2019
Author: evandro
Date: Wed Sep 4 13:01:09 2019
New Revision: 370966
URL: http://llvm.org/viewvc/llvm-project?rev=370966&view=rev
Log:
[InstCombine] Add more test cases (NFC)
Add more test cases simplifying `log()`.
Modified:
llvm/trunk/test/Transforms/InstCombine/log-pow.ll
Modified: llvm/trunk/test/Transforms/InstCombine/log-pow.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/log-pow.ll?rev=370966&r1=370965&r2=370966&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/log-pow.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/log-pow.ll Wed Sep 4 13:01:09 2019
@@ -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: 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
+; 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
+}
+
+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
+}
+; 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
+}
-define double @log_exp2_not_fast(double %x) {
- %call2 = call double @exp2(double %x)
- %call3 = call fast double @log(double %call2)
- ret double %call3
+; 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
}
-; 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
+define double @log_exp2_not_fast(double %x) {
+; 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
+}
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 }
More information about the llvm-commits
mailing list