[PATCH] D149181: [RISCV] Remove one use restriction on the scalar from combineBinOpToReduce.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 25 21:11:22 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG12cd7e11aad0: [RISCV] Remove one use restriction on the scalar from combineBinOpToReduce. (authored by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D149181?vs=516868&id=517039#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149181/new/

https://reviews.llvm.org/D149181

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/rvv/fold-binary-reduce.ll


Index: llvm/test/CodeGen/RISCV/rvv/fold-binary-reduce.ll
===================================================================
--- llvm/test/CodeGen/RISCV/rvv/fold-binary-reduce.ll
+++ llvm/test/CodeGen/RISCV/rvv/fold-binary-reduce.ll
@@ -282,13 +282,12 @@
 ; CHECK-LABEL: reduce_fadd4:
 ; CHECK:       # %bb.0: # %entry
 ; CHECK-NEXT:    vsetivli zero, 4, e32, m1, ta, ma
-; CHECK-NEXT:    vmv.s.x v10, zero
+; CHECK-NEXT:    vfmv.s.f v10, fa0
 ; CHECK-NEXT:    vfredusum.vs v8, v8, v10
 ; CHECK-NEXT:    vfmv.f.s fa5, v8
-; CHECK-NEXT:    vfredusum.vs v8, v9, v10
+; CHECK-NEXT:    vfmv.s.f v8, fa1
+; CHECK-NEXT:    vfredusum.vs v8, v9, v8
 ; CHECK-NEXT:    vfmv.f.s fa4, v8
-; CHECK-NEXT:    fadd.s fa5, fa5, fa0
-; CHECK-NEXT:    fadd.s fa4, fa4, fa1
 ; CHECK-NEXT:    fdiv.s fa0, fa5, fa4
 ; CHECK-NEXT:    ret
 entry:
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -9208,9 +9208,6 @@
                          0))
     return SDValue();
 
-  if (!ScalarV.hasOneUse())
-    return SDValue();
-
   // If the AVL is zero, operand 0 will be returned. So it's not safe to fold.
   // FIXME: We might be able to improve this if operand 0 is undef.
   if (!isNonZeroAVL(Reduce.getOperand(5)))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149181.517039.patch
Type: text/x-patch
Size: 1362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230426/5c7531d2/attachment.bin>


More information about the llvm-commits mailing list