[PATCH] D52306: [DAGCombine] Don't fold dependent loads across SELECT_CC.
Bevin Hansson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 20 07:53:55 PDT 2018
ebevhan created this revision.
ebevhan added a reviewer: bogner.
Herald added a subscriber: llvm-commits.
ebevhan added a reviewer: niravd.
DAGCombine will try to fold two loads that feed a SELECT
or SELECT_CC after the select, resulting in a select of
an address and a single load after.
If either of the loads depend on the other, this is not
legal as it could introduce cycles. However, it only
checked this if the opcode was a SELECT, and not for a
SELECT_CC.
Unfortunately, the only reproducer I have for this is
for our downstream target. I've tried getting it to trigger
on an upstream one but haven't been successful.
Repository:
rL LLVM
https://reviews.llvm.org/D52306
Files:
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -17866,6 +17866,11 @@
LLD->getBasePtr().getValueType()))
return false;
+ // The loads must not depend on one another.
+ if (LLD->isPredecessorOf(RLD) ||
+ RLD->isPredecessorOf(LLD))
+ return false;
+
// Check that the select condition doesn't reach either load. If so,
// folding this will induce a cycle into the DAG. If not, this is safe to
// xform, so create a select of the addresses.
@@ -17875,10 +17880,7 @@
if ((LLD->hasAnyUseOfValue(1) && LLD->isPredecessorOf(CondNode)) ||
(RLD->hasAnyUseOfValue(1) && RLD->isPredecessorOf(CondNode)))
return false;
- // The loads must not depend on one another.
- if (LLD->isPredecessorOf(RLD) ||
- RLD->isPredecessorOf(LLD))
- return false;
+
Addr = DAG.getSelect(SDLoc(TheSelect),
LLD->getBasePtr().getValueType(),
TheSelect->getOperand(0), LLD->getBasePtr(),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52306.166289.patch
Type: text/x-patch
Size: 1214 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180920/0e5d5d3b/attachment.bin>
More information about the llvm-commits
mailing list