[llvm] 86163f8 - [InstCombine] add extra-use tests for fmul+sqrt; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 30 15:41:27 PDT 2020
Author: Venkataramanan Kumar
Date: 2020-08-30T18:41:01-04:00
New Revision: 86163f885b56436be0b52183d13f21a18f157dcd
URL: https://github.com/llvm/llvm-project/commit/86163f885b56436be0b52183d13f21a18f157dcd
DIFF: https://github.com/llvm/llvm-project/commit/86163f885b56436be0b52183d13f21a18f157dcd.diff
LOG: [InstCombine] add extra-use tests for fmul+sqrt; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/fmul-sqrt.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/fmul-sqrt.ll b/llvm/test/Transforms/InstCombine/fmul-sqrt.ll
index 6ab70e4d3cd8..f2497d0a84be 100644
--- a/llvm/test/Transforms/InstCombine/fmul-sqrt.ll
+++ b/llvm/test/Transforms/InstCombine/fmul-sqrt.ll
@@ -99,6 +99,38 @@ define double @rsqrt_squared(double %x) {
ret double %squared
}
+define double @rsqrt_x_reassociate_extra_use(double %x, double * %p) {
+; CHECK-LABEL: @rsqrt_x_reassociate_extra_use(
+; CHECK-NEXT: [[SQRT:%.*]] = call fast double @llvm.sqrt.f64(double [[X:%.*]])
+; CHECK-NEXT: [[RSQRT:%.*]] = fdiv fast double 1.000000e+00, [[SQRT]]
+; CHECK-NEXT: [[RES:%.*]] = fmul reassoc double [[RSQRT]], [[X:%.*]]
+; CHECK-NEXT: store double [[RSQRT]], double* %p
+; CHECK-NEXT: ret double [[RES]]
+;
+ %sqrt = call fast double @llvm.sqrt.f64(double %x)
+ %rsqrt = fdiv fast double 1.0, %sqrt
+ %res = fmul reassoc double %rsqrt, %x
+ store double %rsqrt, double* %p
+ ret double %res
+}
+
+define double @x_add_y_rsqrt_reassociate_extra_use(double %x, double %y, double * %p) {
+; CHECK-LABEL: @x_add_y_rsqrt_reassociate_extra_use(
+; CHECK-NEXT: [[ADD:%.*]] = fadd fast double %x, %y
+; CHECK-NEXT: [[SQRT:%.*]] = call fast double @llvm.sqrt.f64(double [[ADD]])
+; CHECK-NEXT: [[RSQRT:%.*]] = fdiv fast double 1.000000e+00, [[SQRT]]
+; CHECK-NEXT: [[RES:%.*]] = fmul reassoc double [[ADD]], [[RSQRT]]
+; CHECK-NEXT: store double [[RSQRT]], double* %p
+; CHECK-NEXT: ret double [[RES]]
+;
+ %add = fadd fast double %x, %y ; thwart complexity-based canonicalization
+ %sqrt = call fast double @llvm.sqrt.f64(double %add)
+ %rsqrt = fdiv fast double 1.0, %sqrt
+ %res = fmul reassoc double %add, %rsqrt
+ store double %rsqrt, double* %p
+ ret double %res
+}
+
define double @sqrt_divisor_squared(double %x, double %y) {
; CHECK-LABEL: @sqrt_divisor_squared(
; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc nnan nsz double [[Y:%.*]], [[Y]]
More information about the llvm-commits
mailing list