mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Use more const qualifiers with SCEV interfaces.
llvm-svn: 69450
This commit is contained in:
parent
66b00a33fe
commit
e2e949ee98
@ -69,7 +69,7 @@ namespace llvm {
|
||||
|
||||
/// addInsertedValue - Remember the specified instruction as being the
|
||||
/// canonical form for the specified SCEV.
|
||||
void addInsertedValue(Instruction *I, SCEV *S) {
|
||||
void addInsertedValue(Instruction *I, const SCEV *S) {
|
||||
InsertedExpressions[S] = (Value*)I;
|
||||
InsertedInstructions.insert(I);
|
||||
}
|
||||
@ -90,31 +90,31 @@ namespace llvm {
|
||||
static Value *InsertBinop(Instruction::BinaryOps Opcode, Value *LHS,
|
||||
Value *RHS, Instruction *InsertPt);
|
||||
protected:
|
||||
Value *expand(SCEV *S);
|
||||
Value *expand(const SCEV *S);
|
||||
|
||||
Value *visitConstant(SCEVConstant *S) {
|
||||
Value *visitConstant(const SCEVConstant *S) {
|
||||
return S->getValue();
|
||||
}
|
||||
|
||||
Value *visitTruncateExpr(SCEVTruncateExpr *S);
|
||||
Value *visitTruncateExpr(const SCEVTruncateExpr *S);
|
||||
|
||||
Value *visitZeroExtendExpr(SCEVZeroExtendExpr *S);
|
||||
Value *visitZeroExtendExpr(const SCEVZeroExtendExpr *S);
|
||||
|
||||
Value *visitSignExtendExpr(SCEVSignExtendExpr *S);
|
||||
Value *visitSignExtendExpr(const SCEVSignExtendExpr *S);
|
||||
|
||||
Value *visitAddExpr(SCEVAddExpr *S);
|
||||
Value *visitAddExpr(const SCEVAddExpr *S);
|
||||
|
||||
Value *visitMulExpr(SCEVMulExpr *S);
|
||||
Value *visitMulExpr(const SCEVMulExpr *S);
|
||||
|
||||
Value *visitUDivExpr(SCEVUDivExpr *S);
|
||||
Value *visitUDivExpr(const SCEVUDivExpr *S);
|
||||
|
||||
Value *visitAddRecExpr(SCEVAddRecExpr *S);
|
||||
Value *visitAddRecExpr(const SCEVAddRecExpr *S);
|
||||
|
||||
Value *visitSMaxExpr(SCEVSMaxExpr *S);
|
||||
Value *visitSMaxExpr(const SCEVSMaxExpr *S);
|
||||
|
||||
Value *visitUMaxExpr(SCEVUMaxExpr *S);
|
||||
Value *visitUMaxExpr(const SCEVUMaxExpr *S);
|
||||
|
||||
Value *visitUnknown(SCEVUnknown *S) {
|
||||
Value *visitUnknown(const SCEVUnknown *S) {
|
||||
return S->getValue();
|
||||
}
|
||||
};
|
||||
|
@ -552,39 +552,39 @@ namespace llvm {
|
||||
/// for various SCEV analysis purposes.
|
||||
template<typename SC, typename RetVal=void>
|
||||
struct SCEVVisitor {
|
||||
RetVal visit(SCEV *S) {
|
||||
RetVal visit(const SCEV *S) {
|
||||
switch (S->getSCEVType()) {
|
||||
case scConstant:
|
||||
return ((SC*)this)->visitConstant((SCEVConstant*)S);
|
||||
return ((SC*)this)->visitConstant((const SCEVConstant*)S);
|
||||
case scTruncate:
|
||||
return ((SC*)this)->visitTruncateExpr((SCEVTruncateExpr*)S);
|
||||
return ((SC*)this)->visitTruncateExpr((const SCEVTruncateExpr*)S);
|
||||
case scZeroExtend:
|
||||
return ((SC*)this)->visitZeroExtendExpr((SCEVZeroExtendExpr*)S);
|
||||
return ((SC*)this)->visitZeroExtendExpr((const SCEVZeroExtendExpr*)S);
|
||||
case scSignExtend:
|
||||
return ((SC*)this)->visitSignExtendExpr((SCEVSignExtendExpr*)S);
|
||||
return ((SC*)this)->visitSignExtendExpr((const SCEVSignExtendExpr*)S);
|
||||
case scAddExpr:
|
||||
return ((SC*)this)->visitAddExpr((SCEVAddExpr*)S);
|
||||
return ((SC*)this)->visitAddExpr((const SCEVAddExpr*)S);
|
||||
case scMulExpr:
|
||||
return ((SC*)this)->visitMulExpr((SCEVMulExpr*)S);
|
||||
return ((SC*)this)->visitMulExpr((const SCEVMulExpr*)S);
|
||||
case scUDivExpr:
|
||||
return ((SC*)this)->visitUDivExpr((SCEVUDivExpr*)S);
|
||||
return ((SC*)this)->visitUDivExpr((const SCEVUDivExpr*)S);
|
||||
case scAddRecExpr:
|
||||
return ((SC*)this)->visitAddRecExpr((SCEVAddRecExpr*)S);
|
||||
return ((SC*)this)->visitAddRecExpr((const SCEVAddRecExpr*)S);
|
||||
case scSMaxExpr:
|
||||
return ((SC*)this)->visitSMaxExpr((SCEVSMaxExpr*)S);
|
||||
return ((SC*)this)->visitSMaxExpr((const SCEVSMaxExpr*)S);
|
||||
case scUMaxExpr:
|
||||
return ((SC*)this)->visitUMaxExpr((SCEVUMaxExpr*)S);
|
||||
return ((SC*)this)->visitUMaxExpr((const SCEVUMaxExpr*)S);
|
||||
case scUnknown:
|
||||
return ((SC*)this)->visitUnknown((SCEVUnknown*)S);
|
||||
return ((SC*)this)->visitUnknown((const SCEVUnknown*)S);
|
||||
case scCouldNotCompute:
|
||||
return ((SC*)this)->visitCouldNotCompute((SCEVCouldNotCompute*)S);
|
||||
return ((SC*)this)->visitCouldNotCompute((const SCEVCouldNotCompute*)S);
|
||||
default:
|
||||
assert(0 && "Unknown SCEV type!");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
RetVal visitCouldNotCompute(SCEVCouldNotCompute *S) {
|
||||
RetVal visitCouldNotCompute(const SCEVCouldNotCompute *S) {
|
||||
assert(0 && "Invalid use of SCEVCouldNotCompute!");
|
||||
abort();
|
||||
return RetVal();
|
||||
|
@ -112,7 +112,7 @@ Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode, Value *LHS,
|
||||
return BinaryOperator::Create(Opcode, LHS, RHS, "tmp", InsertPt);
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitAddExpr(SCEVAddExpr *S) {
|
||||
Value *SCEVExpander::visitAddExpr(const SCEVAddExpr *S) {
|
||||
const Type *Ty = S->getType();
|
||||
if (isa<PointerType>(Ty)) Ty = TD.getIntPtrType();
|
||||
Value *V = expand(S->getOperand(S->getNumOperands()-1));
|
||||
@ -127,11 +127,11 @@ Value *SCEVExpander::visitAddExpr(SCEVAddExpr *S) {
|
||||
return V;
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitMulExpr(SCEVMulExpr *S) {
|
||||
Value *SCEVExpander::visitMulExpr(const SCEVMulExpr *S) {
|
||||
const Type *Ty = S->getType();
|
||||
if (isa<PointerType>(Ty)) Ty = TD.getIntPtrType();
|
||||
int FirstOp = 0; // Set if we should emit a subtract.
|
||||
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(S->getOperand(0)))
|
||||
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(S->getOperand(0)))
|
||||
if (SC->getValue()->isAllOnesValue())
|
||||
FirstOp = 1;
|
||||
|
||||
@ -152,13 +152,13 @@ Value *SCEVExpander::visitMulExpr(SCEVMulExpr *S) {
|
||||
return V;
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitUDivExpr(SCEVUDivExpr *S) {
|
||||
Value *SCEVExpander::visitUDivExpr(const SCEVUDivExpr *S) {
|
||||
const Type *Ty = S->getType();
|
||||
if (isa<PointerType>(Ty)) Ty = TD.getIntPtrType();
|
||||
|
||||
Value *LHS = expand(S->getLHS());
|
||||
LHS = InsertCastOfTo(CastInst::getCastOpcode(LHS, false, Ty, false), LHS, Ty);
|
||||
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(S->getRHS())) {
|
||||
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(S->getRHS())) {
|
||||
const APInt &RHS = SC->getValue()->getValue();
|
||||
if (RHS.isPowerOf2())
|
||||
return InsertBinop(Instruction::LShr, LHS,
|
||||
@ -171,7 +171,7 @@ Value *SCEVExpander::visitUDivExpr(SCEVUDivExpr *S) {
|
||||
return InsertBinop(Instruction::UDiv, LHS, RHS, InsertPt);
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
|
||||
Value *SCEVExpander::visitAddRecExpr(const SCEVAddRecExpr *S) {
|
||||
const Type *Ty = S->getType();
|
||||
const Loop *L = S->getLoop();
|
||||
// We cannot yet do fp recurrences, e.g. the xform of {X,+,F} --> X+{0,+,F}
|
||||
@ -275,14 +275,14 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
|
||||
return expand(V);
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitTruncateExpr(SCEVTruncateExpr *S) {
|
||||
Value *SCEVExpander::visitTruncateExpr(const SCEVTruncateExpr *S) {
|
||||
Value *V = expand(S->getOperand());
|
||||
if (isa<PointerType>(V->getType()))
|
||||
V = InsertCastOfTo(Instruction::PtrToInt, V, TD.getIntPtrType());
|
||||
return CastInst::CreateTruncOrBitCast(V, S->getType(), "tmp.", InsertPt);
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitZeroExtendExpr(SCEVZeroExtendExpr *S) {
|
||||
Value *SCEVExpander::visitZeroExtendExpr(const SCEVZeroExtendExpr *S) {
|
||||
const Type *Ty = S->getType();
|
||||
if (isa<PointerType>(Ty)) Ty = TD.getIntPtrType();
|
||||
Value *V = expand(S->getOperand());
|
||||
@ -291,7 +291,7 @@ Value *SCEVExpander::visitZeroExtendExpr(SCEVZeroExtendExpr *S) {
|
||||
return CastInst::CreateZExtOrBitCast(V, Ty, "tmp.", InsertPt);
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitSignExtendExpr(SCEVSignExtendExpr *S) {
|
||||
Value *SCEVExpander::visitSignExtendExpr(const SCEVSignExtendExpr *S) {
|
||||
const Type *Ty = S->getType();
|
||||
if (isa<PointerType>(Ty)) Ty = TD.getIntPtrType();
|
||||
Value *V = expand(S->getOperand());
|
||||
@ -300,7 +300,7 @@ Value *SCEVExpander::visitSignExtendExpr(SCEVSignExtendExpr *S) {
|
||||
return CastInst::CreateSExtOrBitCast(V, Ty, "tmp.", InsertPt);
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitSMaxExpr(SCEVSMaxExpr *S) {
|
||||
Value *SCEVExpander::visitSMaxExpr(const SCEVSMaxExpr *S) {
|
||||
const Type *Ty = S->getType();
|
||||
Value *LHS = expand(S->getOperand(0));
|
||||
LHS = InsertCastOfTo(CastInst::getCastOpcode(LHS, false, Ty, false), LHS, Ty);
|
||||
@ -314,7 +314,7 @@ Value *SCEVExpander::visitSMaxExpr(SCEVSMaxExpr *S) {
|
||||
return LHS;
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitUMaxExpr(SCEVUMaxExpr *S) {
|
||||
Value *SCEVExpander::visitUMaxExpr(const SCEVUMaxExpr *S) {
|
||||
const Type *Ty = S->getType();
|
||||
Value *LHS = expand(S->getOperand(0));
|
||||
LHS = InsertCastOfTo(CastInst::getCastOpcode(LHS, false, Ty, false), LHS, Ty);
|
||||
@ -338,7 +338,7 @@ Value *SCEVExpander::expandCodeFor(SCEVHandle SH, const Type *Ty,
|
||||
return InsertCastOfTo(CastInst::getCastOpcode(V, false, Ty, false), V, Ty);
|
||||
}
|
||||
|
||||
Value *SCEVExpander::expand(SCEV *S) {
|
||||
Value *SCEVExpander::expand(const SCEV *S) {
|
||||
// Check to see if we already expanded this.
|
||||
std::map<SCEVHandle, Value*>::iterator I = InsertedExpressions.find(S);
|
||||
if (I != InsertedExpressions.end())
|
||||
|
@ -98,7 +98,7 @@ namespace {
|
||||
BasicBlock *ExitingBlock,
|
||||
BranchInst *BI,
|
||||
SCEVExpander &Rewriter);
|
||||
void RewriteLoopExitValues(Loop *L, SCEV *BackedgeTakenCount);
|
||||
void RewriteLoopExitValues(Loop *L, const SCEV *BackedgeTakenCount);
|
||||
|
||||
void DeleteTriviallyDeadInstructions(SmallPtrSet<Instruction*, 16> &Insts);
|
||||
|
||||
@ -211,7 +211,8 @@ void IndVarSimplify::LinearFunctionTestReplace(Loop *L,
|
||||
/// final value of any expressions that are recurrent in the loop, and
|
||||
/// substitute the exit values from the loop into any instructions outside of
|
||||
/// the loop that use the final values of the current expressions.
|
||||
void IndVarSimplify::RewriteLoopExitValues(Loop *L, SCEV *BackedgeTakenCount) {
|
||||
void IndVarSimplify::RewriteLoopExitValues(Loop *L,
|
||||
const SCEV *BackedgeTakenCount) {
|
||||
BasicBlock *Preheader = L->getLoopPreheader();
|
||||
|
||||
// Scan all of the instructions in the loop, looking at those that have
|
||||
@ -627,7 +628,7 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
|
||||
// polynomial evaluations inside of the loop, and the str reduction pass
|
||||
// currently can only reduce affine polynomials. For now just disable
|
||||
// indvar subst on anything more complex than an affine addrec.
|
||||
if (SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SCEV))
|
||||
if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SCEV))
|
||||
if (AR->getLoop() == L && AR->isAffine())
|
||||
IndVars.push_back(std::make_pair(PN, SCEV));
|
||||
}
|
||||
@ -716,7 +717,7 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
|
||||
// variable.
|
||||
while (!IndVars.empty()) {
|
||||
PHINode *PN = IndVars.back().first;
|
||||
SCEVAddRecExpr *AR = cast<SCEVAddRecExpr>(IndVars.back().second);
|
||||
const SCEVAddRecExpr *AR = cast<SCEVAddRecExpr>(IndVars.back().second);
|
||||
Value *NewVal = Rewriter.expandCodeFor(AR, PN->getType(), InsertPt);
|
||||
DOUT << "INDVARS: Rewrote IV '" << *AR << "' " << *PN
|
||||
<< " into = " << *NewVal << "\n";
|
||||
|
@ -278,13 +278,13 @@ static bool containsAddRecFromDifferentLoop(SCEVHandle S, Loop *L) {
|
||||
// This is very common, put it first.
|
||||
if (isa<SCEVConstant>(S))
|
||||
return false;
|
||||
if (SCEVCommutativeExpr *AE = dyn_cast<SCEVCommutativeExpr>(S)) {
|
||||
if (const SCEVCommutativeExpr *AE = dyn_cast<SCEVCommutativeExpr>(S)) {
|
||||
for (unsigned int i=0; i< AE->getNumOperands(); i++)
|
||||
if (containsAddRecFromDifferentLoop(AE->getOperand(i), L))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (SCEVAddRecExpr *AE = dyn_cast<SCEVAddRecExpr>(S)) {
|
||||
if (const SCEVAddRecExpr *AE = dyn_cast<SCEVAddRecExpr>(S)) {
|
||||
if (const Loop *newLoop = AE->getLoop()) {
|
||||
if (newLoop == L)
|
||||
return false;
|
||||
@ -294,21 +294,21 @@ static bool containsAddRecFromDifferentLoop(SCEVHandle S, Loop *L) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (SCEVUDivExpr *DE = dyn_cast<SCEVUDivExpr>(S))
|
||||
if (const SCEVUDivExpr *DE = dyn_cast<SCEVUDivExpr>(S))
|
||||
return containsAddRecFromDifferentLoop(DE->getLHS(), L) ||
|
||||
containsAddRecFromDifferentLoop(DE->getRHS(), L);
|
||||
#if 0
|
||||
// SCEVSDivExpr has been backed out temporarily, but will be back; we'll
|
||||
// need this when it is.
|
||||
if (SCEVSDivExpr *DE = dyn_cast<SCEVSDivExpr>(S))
|
||||
if (const SCEVSDivExpr *DE = dyn_cast<SCEVSDivExpr>(S))
|
||||
return containsAddRecFromDifferentLoop(DE->getLHS(), L) ||
|
||||
containsAddRecFromDifferentLoop(DE->getRHS(), L);
|
||||
#endif
|
||||
if (SCEVTruncateExpr *TE = dyn_cast<SCEVTruncateExpr>(S))
|
||||
if (const SCEVTruncateExpr *TE = dyn_cast<SCEVTruncateExpr>(S))
|
||||
return containsAddRecFromDifferentLoop(TE->getOperand(), L);
|
||||
if (SCEVZeroExtendExpr *ZE = dyn_cast<SCEVZeroExtendExpr>(S))
|
||||
if (const SCEVZeroExtendExpr *ZE = dyn_cast<SCEVZeroExtendExpr>(S))
|
||||
return containsAddRecFromDifferentLoop(ZE->getOperand(), L);
|
||||
if (SCEVSignExtendExpr *SE = dyn_cast<SCEVSignExtendExpr>(S))
|
||||
if (const SCEVSignExtendExpr *SE = dyn_cast<SCEVSignExtendExpr>(S))
|
||||
return containsAddRecFromDifferentLoop(SE->getOperand(), L);
|
||||
return false;
|
||||
}
|
||||
@ -326,7 +326,7 @@ static bool getSCEVStartAndStride(const SCEVHandle &SH, Loop *L,
|
||||
|
||||
// If the outer level is an AddExpr, the operands are all start values except
|
||||
// for a nested AddRecExpr.
|
||||
if (SCEVAddExpr *AE = dyn_cast<SCEVAddExpr>(SH)) {
|
||||
if (const SCEVAddExpr *AE = dyn_cast<SCEVAddExpr>(SH)) {
|
||||
for (unsigned i = 0, e = AE->getNumOperands(); i != e; ++i)
|
||||
if (SCEVAddRecExpr *AddRec =
|
||||
dyn_cast<SCEVAddRecExpr>(AE->getOperand(i))) {
|
||||
@ -344,7 +344,7 @@ static bool getSCEVStartAndStride(const SCEVHandle &SH, Loop *L,
|
||||
return false; // not analyzable.
|
||||
}
|
||||
|
||||
SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(TheAddRec);
|
||||
const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(TheAddRec);
|
||||
if (!AddRec || AddRec->getLoop() != L) return false;
|
||||
|
||||
// FIXME: Generalize to non-affine IV's.
|
||||
@ -787,7 +787,7 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase,
|
||||
/// mode, and does not need to be put in a register first.
|
||||
static bool fitsInAddressMode(const SCEVHandle &V, const Type *UseTy,
|
||||
const TargetLowering *TLI, bool HasBaseReg) {
|
||||
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V)) {
|
||||
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(V)) {
|
||||
int64_t VC = SC->getValue()->getSExtValue();
|
||||
if (TLI) {
|
||||
TargetLowering::AddrMode AM;
|
||||
@ -800,7 +800,7 @@ static bool fitsInAddressMode(const SCEVHandle &V, const Type *UseTy,
|
||||
}
|
||||
}
|
||||
|
||||
if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(V))
|
||||
if (const SCEVUnknown *SU = dyn_cast<SCEVUnknown>(V))
|
||||
if (GlobalValue *GV = dyn_cast<GlobalValue>(SU->getValue())) {
|
||||
TargetLowering::AddrMode AM;
|
||||
AM.BaseGV = GV;
|
||||
@ -817,7 +817,7 @@ static void MoveLoopVariantsToImmediateField(SCEVHandle &Val, SCEVHandle &Imm,
|
||||
Loop *L, ScalarEvolution *SE) {
|
||||
if (Val->isLoopInvariant(L)) return; // Nothing to do.
|
||||
|
||||
if (SCEVAddExpr *SAE = dyn_cast<SCEVAddExpr>(Val)) {
|
||||
if (const SCEVAddExpr *SAE = dyn_cast<SCEVAddExpr>(Val)) {
|
||||
std::vector<SCEVHandle> NewOps;
|
||||
NewOps.reserve(SAE->getNumOperands());
|
||||
|
||||
@ -834,7 +834,7 @@ static void MoveLoopVariantsToImmediateField(SCEVHandle &Val, SCEVHandle &Imm,
|
||||
Val = SE->getIntegerSCEV(0, Val->getType());
|
||||
else
|
||||
Val = SE->getAddExpr(NewOps);
|
||||
} else if (SCEVAddRecExpr *SARE = dyn_cast<SCEVAddRecExpr>(Val)) {
|
||||
} else if (const SCEVAddRecExpr *SARE = dyn_cast<SCEVAddRecExpr>(Val)) {
|
||||
// Try to pull immediates out of the start value of nested addrec's.
|
||||
SCEVHandle Start = SARE->getStart();
|
||||
MoveLoopVariantsToImmediateField(Start, Imm, L, SE);
|
||||
@ -858,7 +858,7 @@ static void MoveImmediateValues(const TargetLowering *TLI,
|
||||
SCEVHandle &Val, SCEVHandle &Imm,
|
||||
bool isAddress, Loop *L,
|
||||
ScalarEvolution *SE) {
|
||||
if (SCEVAddExpr *SAE = dyn_cast<SCEVAddExpr>(Val)) {
|
||||
if (const SCEVAddExpr *SAE = dyn_cast<SCEVAddExpr>(Val)) {
|
||||
std::vector<SCEVHandle> NewOps;
|
||||
NewOps.reserve(SAE->getNumOperands());
|
||||
|
||||
@ -880,7 +880,7 @@ static void MoveImmediateValues(const TargetLowering *TLI,
|
||||
else
|
||||
Val = SE->getAddExpr(NewOps);
|
||||
return;
|
||||
} else if (SCEVAddRecExpr *SARE = dyn_cast<SCEVAddRecExpr>(Val)) {
|
||||
} else if (const SCEVAddRecExpr *SARE = dyn_cast<SCEVAddRecExpr>(Val)) {
|
||||
// Try to pull immediates out of the start value of nested addrec's.
|
||||
SCEVHandle Start = SARE->getStart();
|
||||
MoveImmediateValues(TLI, UseTy, Start, Imm, isAddress, L, SE);
|
||||
@ -891,7 +891,7 @@ static void MoveImmediateValues(const TargetLowering *TLI,
|
||||
Val = SE->getAddRecExpr(Ops, SARE->getLoop());
|
||||
}
|
||||
return;
|
||||
} else if (SCEVMulExpr *SME = dyn_cast<SCEVMulExpr>(Val)) {
|
||||
} else if (const SCEVMulExpr *SME = dyn_cast<SCEVMulExpr>(Val)) {
|
||||
// Transform "8 * (4 + v)" -> "32 + 8*V" if "32" fits in the immed field.
|
||||
if (isAddress && fitsInAddressMode(SME->getOperand(0), UseTy, TLI, false) &&
|
||||
SME->getNumOperands() == 2 && SME->isLoopInvariant(L)) {
|
||||
@ -945,10 +945,10 @@ static void MoveImmediateValues(const TargetLowering *TLI,
|
||||
static void SeparateSubExprs(std::vector<SCEVHandle> &SubExprs,
|
||||
SCEVHandle Expr,
|
||||
ScalarEvolution *SE) {
|
||||
if (SCEVAddExpr *AE = dyn_cast<SCEVAddExpr>(Expr)) {
|
||||
if (const SCEVAddExpr *AE = dyn_cast<SCEVAddExpr>(Expr)) {
|
||||
for (unsigned j = 0, e = AE->getNumOperands(); j != e; ++j)
|
||||
SeparateSubExprs(SubExprs, AE->getOperand(j), SE);
|
||||
} else if (SCEVAddRecExpr *SARE = dyn_cast<SCEVAddRecExpr>(Expr)) {
|
||||
} else if (const SCEVAddRecExpr *SARE = dyn_cast<SCEVAddRecExpr>(Expr)) {
|
||||
SCEVHandle Zero = SE->getIntegerSCEV(0, Expr->getType());
|
||||
if (SARE->getOperand(0) == Zero) {
|
||||
SubExprs.push_back(Expr);
|
||||
@ -1156,7 +1156,7 @@ bool LoopStrengthReduce::ValidStride(bool HasBaseReg,
|
||||
continue;
|
||||
|
||||
TargetLowering::AddrMode AM;
|
||||
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(UsersToProcess[i].Imm))
|
||||
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(UsersToProcess[i].Imm))
|
||||
AM.BaseOffs = SC->getValue()->getSExtValue();
|
||||
AM.HasBaseReg = HasBaseReg || !UsersToProcess[i].Base->isZero();
|
||||
AM.Scale = Scale;
|
||||
@ -1201,7 +1201,7 @@ SCEVHandle LoopStrengthReduce::CheckForIVReuse(bool HasBaseReg,
|
||||
const SCEVHandle &Stride,
|
||||
IVExpr &IV, const Type *Ty,
|
||||
const std::vector<BasedUser>& UsersToProcess) {
|
||||
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(Stride)) {
|
||||
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(Stride)) {
|
||||
int64_t SInt = SC->getValue()->getSExtValue();
|
||||
for (unsigned NewStride = 0, e = StrideOrder.size(); NewStride != e;
|
||||
++NewStride) {
|
||||
@ -1261,8 +1261,8 @@ SCEVHandle LoopStrengthReduce::CheckForIVReuse(bool HasBaseReg,
|
||||
IVsByStride.find(StrideOrder[NewStride]);
|
||||
if (SI == IVsByStride.end())
|
||||
continue;
|
||||
if (SCEVMulExpr *ME = dyn_cast<SCEVMulExpr>(SI->first))
|
||||
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(ME->getOperand(0)))
|
||||
if (const SCEVMulExpr *ME = dyn_cast<SCEVMulExpr>(SI->first))
|
||||
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(ME->getOperand(0)))
|
||||
if (Stride == ME->getOperand(1) &&
|
||||
SC->getValue()->getSExtValue() == -1LL)
|
||||
for (std::vector<IVExpr>::iterator II = SI->second.IVs.begin(),
|
||||
@ -1287,11 +1287,11 @@ static bool PartitionByIsUseOfPostIncrementedValue(const BasedUser &Val) {
|
||||
/// isNonConstantNegative - Return true if the specified scev is negated, but
|
||||
/// not a constant.
|
||||
static bool isNonConstantNegative(const SCEVHandle &Expr) {
|
||||
SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(Expr);
|
||||
const SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(Expr);
|
||||
if (!Mul) return false;
|
||||
|
||||
// If there is a constant factor, it will be first.
|
||||
SCEVConstant *SC = dyn_cast<SCEVConstant>(Mul->getOperand(0));
|
||||
const SCEVConstant *SC = dyn_cast<SCEVConstant>(Mul->getOperand(0));
|
||||
if (!SC) return false;
|
||||
|
||||
// Return true if the value is negative, this matches things like (-42 * V).
|
||||
@ -1711,10 +1711,10 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride,
|
||||
// If the immediate part of the common expression is a GV, check if it's
|
||||
// possible to fold it into the target addressing mode.
|
||||
GlobalValue *GV = 0;
|
||||
if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(Imm))
|
||||
if (const SCEVUnknown *SU = dyn_cast<SCEVUnknown>(Imm))
|
||||
GV = dyn_cast<GlobalValue>(SU->getValue());
|
||||
int64_t Offset = 0;
|
||||
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(Imm))
|
||||
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(Imm))
|
||||
Offset = SC->getValue()->getSExtValue();
|
||||
if (GV || Offset)
|
||||
// Pass VoidTy as the AccessTy to be conservative, because
|
||||
@ -1963,8 +1963,8 @@ namespace {
|
||||
explicit StrideCompare(const TargetData *td) : TD(td) {}
|
||||
|
||||
bool operator()(const SCEVHandle &LHS, const SCEVHandle &RHS) {
|
||||
SCEVConstant *LHSC = dyn_cast<SCEVConstant>(LHS);
|
||||
SCEVConstant *RHSC = dyn_cast<SCEVConstant>(RHS);
|
||||
const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(LHS);
|
||||
const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(RHS);
|
||||
if (LHSC && RHSC) {
|
||||
int64_t LV = LHSC->getValue()->getSExtValue();
|
||||
int64_t RV = RHSC->getValue()->getSExtValue();
|
||||
@ -2239,7 +2239,7 @@ ICmpInst *LoopStrengthReduce::OptimizeSMax(Loop *L, ICmpInst *Cond,
|
||||
// Check the relevant induction variable for conformance to
|
||||
// the pattern.
|
||||
SCEVHandle IV = SE->getSCEV(Cond->getOperand(0));
|
||||
SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(IV);
|
||||
const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(IV);
|
||||
if (!AR || !AR->isAffine() ||
|
||||
AR->getStart() != One ||
|
||||
AR->getStepRecurrence(*SE) != One)
|
||||
|
Loading…
Reference in New Issue
Block a user