[PATCH] D120332: [RISCV] Avoid infinite loop between DAGCombiner::visitMUL and RISCVISelLowering::transformAddImmMulImm
Alex Bradbury via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 23 03:06:38 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc5bcfb983e47: [RISCV] Avoid infinite loop between DAGCombiner::visitMUL and RISCVISelLowering… (authored by asb).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120332/new/
https://reviews.llvm.org/D120332
Files:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/addimm-mulimm.ll
Index: llvm/test/CodeGen/RISCV/addimm-mulimm.ll
===================================================================
--- llvm/test/CodeGen/RISCV/addimm-mulimm.ll
+++ llvm/test/CodeGen/RISCV/addimm-mulimm.ll
@@ -872,3 +872,16 @@
%tmp1 = add i64 %tmp0, -8990
ret i64 %tmp1
}
+
+; This test case previously caused an infinite loop between transformations
+; performed in RISCVISelLowering;:transformAddImmMulImm and
+; DAGCombiner::visitMUL.
+define i1 @pr53831(i32 %x) {
+ %tmp0 = add i32 %x, 1
+ %tmp1 = mul i32 %tmp0, 24
+ %tmp2 = add i32 %tmp1, 1
+ %tmp3 = mul i32 %x, 24
+ %tmp4 = add i32 %tmp3, 2048
+ %tmp5 = icmp eq i32 %tmp4, %tmp2
+ ret i1 %tmp5
+}
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -7477,6 +7477,11 @@
auto *N1C = dyn_cast<ConstantSDNode>(N->getOperand(1));
if (!N0C || !N1C)
return SDValue();
+ // If N0C has multiple uses it's possible one of the cases in
+ // DAGCombiner::isMulAddWithConstProfitable will be true, which would result
+ // in an infinite loop.
+ if (!N0C->hasOneUse())
+ return SDValue();
int64_t C0 = N0C->getSExtValue();
int64_t C1 = N1C->getSExtValue();
int64_t CA, CB;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120332.410760.patch
Type: text/x-patch
Size: 1323 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220223/1296a50d/attachment.bin>
More information about the llvm-commits
mailing list