[PATCH] D72388: [InstCombine] Adding testcase for Z / (1.0 / Y) => (Y * Z)

Raghesh Aloor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 01:38:43 PST 2020


raghesh created this revision.
raghesh added reviewers: spatel, craig.topper, llvm-commits.
Herald added a project: LLVM.

The added testcase shows the current transformation for the operation
Z / (1.0 / Y), which remains unchanged. This will be updated to align
 with the transformed code (Y * Z) in a later patch.

The existing transformation Z / (X / Y) => (Y * Z) / X is not handling
 this case as there are multiple uses for (1.0 / Y) in this testcase.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72388

Files:
  llvm/test/Transforms/InstCombine/fdiv.ll


Index: llvm/test/Transforms/InstCombine/fdiv.ll
===================================================================
--- llvm/test/Transforms/InstCombine/fdiv.ll
+++ llvm/test/Transforms/InstCombine/fdiv.ll
@@ -187,6 +187,21 @@
   ret float %div2
 }
 
+; Z / (1.0 / Y)
+
+define float @div_with_div_denominator_with_one_as_numerator_extra_use(float %x, float %y, float %z) {
+; CHECK-LABEL: @div_with_div_denominator_with_one_as_numerator_extra_use(
+; CHECK-NEXT:    [[DIV1:%.*]] = fdiv float 1.000000e+00, [[Y:%.*]]
+; CHECK-NEXT:    [[DIV2:%.*]] = fdiv fast float [[Z:%.*]], [[DIV1]]
+; CHECK-NEXT:    call void @use_f32(float [[DIV1]])
+; CHECK-NEXT:    ret float [[DIV2]]
+;
+  %div1 = fdiv float 1.0, %y
+  %div2 = fdiv fast float %z, %div1
+  call void @use_f32(float %div1)
+  ret float %div2
+}
+
 define float @fneg_fneg(float %x, float %y) {
 ; CHECK-LABEL: @fneg_fneg(
 ; CHECK-NEXT:    [[DIV:%.*]] = fdiv float [[X:%.*]], [[Y:%.*]]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72388.236776.patch
Type: text/x-patch
Size: 944 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200108/37767f97/attachment.bin>


More information about the llvm-commits mailing list