[PATCH] D158208: [DAGCombiner][RISCV] Return SDValue(N, 0) instead of SDValue() after 2 calls to CombineTo in visitSTORE.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 17 12:42:09 PDT 2023
craig.topper created this revision.
craig.topper added reviewers: efriedma, RKSimon, arsenm.
Herald added subscribers: jobnoorman, luke, sunshaoce, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, steven.zhang, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: wangpc, eopXD, MaskRay, wdng.
Herald added a project: LLVM.
RISC-V found a case where the CombineTo caused N to be CSEd with
an existing node and then deleted. The top level DAGCombiner loop
was surprised to find a node was deleted, but SDValue() was returned
from the visit function.
We need to return SDValue(N, 0) to tell the top level loop that
a change was made, but the worklist updates were already handled.
Fixes #64772.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D158208
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/RISCV/pr64772.ll
Index: llvm/test/CodeGen/RISCV/pr64772.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/pr64772.ll
@@ -0,0 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
+
+define void @f() {
+; CHECK-LABEL: f:
+; CHECK: # %bb.0:
+; CHECK-NEXT: sb zero, 0(zero)
+; CHECK-NEXT: ret
+ %B1 = shl i64 -9223372036854775808, 0
+ %LGV6 = load i8, ptr null, align 1
+ %G3 = getelementptr i32, ptr null, i64 %B1
+ %B5 = ashr i64 -9223372036854775808, 0
+ store i1 false, ptr %G3, align 1
+ store i8 1, ptr null, align 1
+ store i1 false, ptr null, align 1
+ ret void
+}
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -20716,7 +20716,7 @@
TypeSize::isKnownLE(ST1->getMemoryVT().getStoreSize(),
ST->getMemoryVT().getStoreSize())) {
CombineTo(ST1, ST1->getChain());
- return SDValue();
+ return SDValue(N, 0);
}
} else {
const BaseIndexOffset STBase = BaseIndexOffset::match(ST, DAG);
@@ -20729,7 +20729,7 @@
ChainBase,
ST1->getMemoryVT().getFixedSizeInBits())) {
CombineTo(ST1, ST1->getChain());
- return SDValue();
+ return SDValue(N, 0);
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158208.551230.patch
Type: text/x-patch
Size: 1632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230817/e3aeae4f/attachment.bin>
More information about the llvm-commits
mailing list