[PATCH] D86801: [InstCombine] add extra-use tests for fmul+sqrt; NFC
Venkataramanan Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 29 11:21:58 PDT 2020
venkataramanan.kumar.llvm updated this revision to Diff 288794.
venkataramanan.kumar.llvm added a comment.
Added comment in the test case.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86801/new/
https://reviews.llvm.org/D86801
Files:
llvm/test/Transforms/InstCombine/fmul-sqrt.ll
Index: llvm/test/Transforms/InstCombine/fmul-sqrt.ll
===================================================================
--- llvm/test/Transforms/InstCombine/fmul-sqrt.ll
+++ llvm/test/Transforms/InstCombine/fmul-sqrt.ll
@@ -99,6 +99,38 @@
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]]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86801.288794.patch
Type: text/x-patch
Size: 1878 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200829/4cb6529b/attachment.bin>
More information about the llvm-commits
mailing list