Make the hasPHIKills flag a computed property.
The VNInfo::HAS_PHI_KILL is only half supported. We precompute it in LiveIntervalAnalysis, but it isn't properly updated by live range splitting and functions like shrinkToUses(). It is only used in one place: RegisterCoalescer::removeCopyByCommutingDef(). This patch changes that function to use a new LiveIntervals::hasPHIKill() function that computes the flag for a given value number. llvm-svn: 161254
This commit is contained in:
parent
84864018c2
commit
06d6a5363b
|
@ -246,6 +246,10 @@ namespace llvm {
|
||||||
/// return NULL.
|
/// return NULL.
|
||||||
MachineBasicBlock *intervalIsInOneMBB(const LiveInterval &LI) const;
|
MachineBasicBlock *intervalIsInOneMBB(const LiveInterval &LI) const;
|
||||||
|
|
||||||
|
/// Returns true if VNI is killed by any PHI-def values in LI.
|
||||||
|
/// This may conservatively return true to avoid expensive computations.
|
||||||
|
bool hasPHIKill(const LiveInterval &LI, const VNInfo *VNI) const;
|
||||||
|
|
||||||
/// addKillFlags - Add kill flags to any instruction that kills a virtual
|
/// addKillFlags - Add kill flags to any instruction that kills a virtual
|
||||||
/// register.
|
/// register.
|
||||||
void addKillFlags();
|
void addKillFlags();
|
||||||
|
|
|
@ -780,6 +780,25 @@ LiveIntervals::intervalIsInOneMBB(const LiveInterval &LI) const {
|
||||||
return MBB1 == MBB2 ? MBB1 : NULL;
|
return MBB1 == MBB2 ? MBB1 : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
LiveIntervals::hasPHIKill(const LiveInterval &LI, const VNInfo *VNI) const {
|
||||||
|
for (LiveInterval::const_vni_iterator I = LI.vni_begin(), E = LI.vni_end();
|
||||||
|
I != E; ++I) {
|
||||||
|
const VNInfo *PHI = *I;
|
||||||
|
if (PHI->isUnused() || !PHI->isPHIDef())
|
||||||
|
continue;
|
||||||
|
const MachineBasicBlock *PHIMBB = getMBBFromIndex(PHI->def);
|
||||||
|
// Conservatively return true instead of scanning huge predecessor lists.
|
||||||
|
if (PHIMBB->pred_size() > 100)
|
||||||
|
return true;
|
||||||
|
for (MachineBasicBlock::const_pred_iterator
|
||||||
|
PI = PHIMBB->pred_begin(), PE = PHIMBB->pred_end(); PI != PE; ++PI)
|
||||||
|
if (VNI == LI.getVNInfoBefore(Indexes->getMBBEndIdx(*PI)))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
LiveIntervals::getSpillWeight(bool isDef, bool isUse, unsigned loopDepth) {
|
LiveIntervals::getSpillWeight(bool isDef, bool isUse, unsigned loopDepth) {
|
||||||
// Limit the loop depth ridiculousness.
|
// Limit the loop depth ridiculousness.
|
||||||
|
|
|
@ -494,6 +494,11 @@ bool RegisterCoalescer::hasOtherReachingDefs(LiveInterval &IntA,
|
||||||
LiveInterval &IntB,
|
LiveInterval &IntB,
|
||||||
VNInfo *AValNo,
|
VNInfo *AValNo,
|
||||||
VNInfo *BValNo) {
|
VNInfo *BValNo) {
|
||||||
|
// If AValNo has PHI kills, conservatively assume that IntB defs can reach
|
||||||
|
// the PHI values.
|
||||||
|
if (LIS->hasPHIKill(IntA, AValNo))
|
||||||
|
return true;
|
||||||
|
|
||||||
for (LiveInterval::iterator AI = IntA.begin(), AE = IntA.end();
|
for (LiveInterval::iterator AI = IntA.begin(), AE = IntA.end();
|
||||||
AI != AE; ++AI) {
|
AI != AE; ++AI) {
|
||||||
if (AI->valno != AValNo) continue;
|
if (AI->valno != AValNo) continue;
|
||||||
|
@ -558,10 +563,7 @@ bool RegisterCoalescer::removeCopyByCommutingDef(const CoalescerPair &CP,
|
||||||
// AValNo is the value number in A that defines the copy, A3 in the example.
|
// AValNo is the value number in A that defines the copy, A3 in the example.
|
||||||
VNInfo *AValNo = IntA.getVNInfoAt(CopyIdx.getRegSlot(true));
|
VNInfo *AValNo = IntA.getVNInfoAt(CopyIdx.getRegSlot(true));
|
||||||
assert(AValNo && "COPY source not live");
|
assert(AValNo && "COPY source not live");
|
||||||
|
if (AValNo->isPHIDef() || AValNo->isUnused())
|
||||||
// If other defs can reach uses of this def, then it's not safe to perform
|
|
||||||
// the optimization.
|
|
||||||
if (AValNo->isPHIDef() || AValNo->isUnused() || AValNo->hasPHIKill())
|
|
||||||
return false;
|
return false;
|
||||||
MachineInstr *DefMI = LIS->getInstructionFromIndex(AValNo->def);
|
MachineInstr *DefMI = LIS->getInstructionFromIndex(AValNo->def);
|
||||||
if (!DefMI)
|
if (!DefMI)
|
||||||
|
|
Loading…
Reference in New Issue