mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
Simplify this code; LoopInfo::getCanonicalInductionVariable will only
find integer induction variables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108853 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1059,9 +1059,7 @@ Value *SCEVExpander::visitAddRecExpr(const SCEVAddRecExpr *S) {
|
|||||||
// First check for an existing canonical IV in a suitable type.
|
// First check for an existing canonical IV in a suitable type.
|
||||||
PHINode *CanonicalIV = 0;
|
PHINode *CanonicalIV = 0;
|
||||||
if (PHINode *PN = L->getCanonicalInductionVariable())
|
if (PHINode *PN = L->getCanonicalInductionVariable())
|
||||||
if (SE.isSCEVable(PN->getType()) &&
|
if (SE.getTypeSizeInBits(PN->getType()) >= SE.getTypeSizeInBits(Ty))
|
||||||
SE.getEffectiveSCEVType(PN->getType())->isIntegerTy() &&
|
|
||||||
SE.getTypeSizeInBits(PN->getType()) >= SE.getTypeSizeInBits(Ty))
|
|
||||||
CanonicalIV = PN;
|
CanonicalIV = PN;
|
||||||
|
|
||||||
// Rewrite an AddRec in terms of the canonical induction variable, if
|
// Rewrite an AddRec in terms of the canonical induction variable, if
|
||||||
@ -1353,12 +1351,17 @@ PHINode *
|
|||||||
SCEVExpander::getOrInsertCanonicalInductionVariable(const Loop *L,
|
SCEVExpander::getOrInsertCanonicalInductionVariable(const Loop *L,
|
||||||
const Type *Ty) {
|
const Type *Ty) {
|
||||||
assert(Ty->isIntegerTy() && "Can only insert integer induction variables!");
|
assert(Ty->isIntegerTy() && "Can only insert integer induction variables!");
|
||||||
|
|
||||||
|
// Build a SCEV for {0,+,1}<L>.
|
||||||
const SCEV *H = SE.getAddRecExpr(SE.getConstant(Ty, 0),
|
const SCEV *H = SE.getAddRecExpr(SE.getConstant(Ty, 0),
|
||||||
SE.getConstant(Ty, 1), L);
|
SE.getConstant(Ty, 1), L);
|
||||||
|
|
||||||
|
// Emit code for it.
|
||||||
BasicBlock *SaveInsertBB = Builder.GetInsertBlock();
|
BasicBlock *SaveInsertBB = Builder.GetInsertBlock();
|
||||||
BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint();
|
BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint();
|
||||||
PHINode *V = cast<PHINode>(expandCodeFor(H, 0, L->getHeader()->begin()));
|
PHINode *V = cast<PHINode>(expandCodeFor(H, 0, L->getHeader()->begin()));
|
||||||
if (SaveInsertBB)
|
if (SaveInsertBB)
|
||||||
restoreInsertPoint(SaveInsertBB, SaveInsertPt);
|
restoreInsertPoint(SaveInsertBB, SaveInsertPt);
|
||||||
|
|
||||||
return V;
|
return V;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user