[llvm] r338070 - [RegisterCoalescer] Fixed inconsistent followCopyChain with subreg
Tim Renouf via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 26 14:27:34 PDT 2018
Author: tpr
Date: Thu Jul 26 14:27:34 2018
New Revision: 338070
URL: http://llvm.org/viewvc/llvm-project?rev=338070&view=rev
Log:
[RegisterCoalescer] Fixed inconsistent followCopyChain with subreg
Summary:
The behavior of followCopyChain with a subreg depends on the order in
which subranges appear in a live interval, which is bad.
This commit fixes that, and allows the copy chain to continue only if
all matching subranges that are not undefined take us to the same def.
I don't have a test for this; the reproducer I had on my branch with
various other local changes does not reproduce the problem on upstream
llvm. Also that reproducer was an ll test; attempting to convert it to a
mir test made the subranges appear in a different order and hid the
problem.
However I would argue that the old behavior was obviously wrong
and needs fixing.
Subscribers: MatzeB, qcolombet, llvm-commits
Differential Revision: https://reviews.llvm.org/D49535
Change-Id: Iee7936ef305918f3b498ac432e2cf651ae5cc2df
Modified:
llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp
Modified: llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp?rev=338070&r1=338069&r2=338070&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp Thu Jul 26 14:27:34 2018
@@ -2280,7 +2280,8 @@ std::pair<const VNInfo*, unsigned> JoinV
LiveQueryResult LRQ = LI.Query(Def);
ValueIn = LRQ.valueIn();
} else {
- // Query subranges. Pick the first matching one.
+ // Query subranges. Ensure that all matching ones take us to the same def
+ // (allowing some of them to be undef).
ValueIn = nullptr;
for (const LiveInterval::SubRange &S : LI.subranges()) {
// Transform lanemask to a mask in the joined live interval.
@@ -2288,8 +2289,12 @@ std::pair<const VNInfo*, unsigned> JoinV
if ((SMask & LaneMask).none())
continue;
LiveQueryResult LRQ = S.Query(Def);
- ValueIn = LRQ.valueIn();
- break;
+ if (!ValueIn) {
+ ValueIn = LRQ.valueIn();
+ continue;
+ }
+ if (LRQ.valueIn() && ValueIn != LRQ.valueIn())
+ return std::make_pair(VNI, TrackReg);
}
}
if (ValueIn == nullptr) {
More information about the llvm-commits
mailing list