mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Change FoldPHIArgBinOpIntoPHI to decline folding if it would introduce two
phis, similar to the FoldPHIArgGEPIntoPHI change. Also, delete some comments that don't reflect the code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82053 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -10313,8 +10313,8 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
|
|||||||
return CS.getInstruction();
|
return CS.getInstruction();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FoldPHIArgBinOpIntoPHI - If we have something like phi [add (a,b), add(c,d)]
|
/// FoldPHIArgBinOpIntoPHI - If we have something like phi [add (a,b), add(a,c)]
|
||||||
/// and if a/b/c/d and the add's all have a single use, turn this into two phi's
|
/// and if a/b/c and the add's all have a single use, turn this into a phi
|
||||||
/// and a single binop.
|
/// and a single binop.
|
||||||
Instruction *InstCombiner::FoldPHIArgBinOpIntoPHI(PHINode &PN) {
|
Instruction *InstCombiner::FoldPHIArgBinOpIntoPHI(PHINode &PN) {
|
||||||
Instruction *FirstInst = cast<Instruction>(PN.getIncomingValue(0));
|
Instruction *FirstInst = cast<Instruction>(PN.getIncomingValue(0));
|
||||||
@@ -10326,8 +10326,7 @@ Instruction *InstCombiner::FoldPHIArgBinOpIntoPHI(PHINode &PN) {
|
|||||||
const Type *LHSType = LHSVal->getType();
|
const Type *LHSType = LHSVal->getType();
|
||||||
const Type *RHSType = RHSVal->getType();
|
const Type *RHSType = RHSVal->getType();
|
||||||
|
|
||||||
// Scan to see if all operands are the same opcode, all have one use, and all
|
// Scan to see if all operands are the same opcode, and all have one use.
|
||||||
// kill their operands (i.e. the operands have one use).
|
|
||||||
for (unsigned i = 1; i != PN.getNumIncomingValues(); ++i) {
|
for (unsigned i = 1; i != PN.getNumIncomingValues(); ++i) {
|
||||||
Instruction *I = dyn_cast<Instruction>(PN.getIncomingValue(i));
|
Instruction *I = dyn_cast<Instruction>(PN.getIncomingValue(i));
|
||||||
if (!I || I->getOpcode() != Opc || !I->hasOneUse() ||
|
if (!I || I->getOpcode() != Opc || !I->hasOneUse() ||
|
||||||
@@ -10348,6 +10347,13 @@ Instruction *InstCombiner::FoldPHIArgBinOpIntoPHI(PHINode &PN) {
|
|||||||
if (I->getOperand(1) != RHSVal) RHSVal = 0;
|
if (I->getOperand(1) != RHSVal) RHSVal = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If both LHS and RHS would need a PHI, don't do this transformation,
|
||||||
|
// because it would increase the number of PHIs entering the block,
|
||||||
|
// which leads to higher register pressure. This is especially
|
||||||
|
// bad when the PHIs are in the header of a loop.
|
||||||
|
if (!LHSVal && !RHSVal)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// Otherwise, this is safe to transform!
|
// Otherwise, this is safe to transform!
|
||||||
|
|
||||||
Value *InLHS = FirstInst->getOperand(0);
|
Value *InLHS = FirstInst->getOperand(0);
|
||||||
@@ -10403,11 +10409,11 @@ Instruction *InstCombiner::FoldPHIArgGEPIntoPHI(PHINode &PN) {
|
|||||||
bool AllBasePointersAreAllocas = true;
|
bool AllBasePointersAreAllocas = true;
|
||||||
|
|
||||||
// We don't want to replace this phi if the replacement would require
|
// We don't want to replace this phi if the replacement would require
|
||||||
// more than one phi.
|
// more than one phi, which leads to higher register pressure. This is
|
||||||
|
// especially bad when the PHIs are in the header of a loop.
|
||||||
bool NeededPhi = false;
|
bool NeededPhi = false;
|
||||||
|
|
||||||
// Scan to see if all operands are the same opcode, all have one use, and all
|
// Scan to see if all operands are the same opcode, and all have one use.
|
||||||
// kill their operands (i.e. the operands have one use).
|
|
||||||
for (unsigned i = 1; i != PN.getNumIncomingValues(); ++i) {
|
for (unsigned i = 1; i != PN.getNumIncomingValues(); ++i) {
|
||||||
GetElementPtrInst *GEP= dyn_cast<GetElementPtrInst>(PN.getIncomingValue(i));
|
GetElementPtrInst *GEP= dyn_cast<GetElementPtrInst>(PN.getIncomingValue(i));
|
||||||
if (!GEP || !GEP->hasOneUse() || GEP->getType() != FirstInst->getType() ||
|
if (!GEP || !GEP->hasOneUse() || GEP->getType() != FirstInst->getType() ||
|
||||||
|
Reference in New Issue
Block a user