diff --git a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h index 22a6791aaa891..0d3c37ba2a538 100644 --- a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h +++ b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h @@ -424,7 +424,7 @@ class SCEVExpander : public SCEVVisitor { /// Expand a SCEVAddExpr with a pointer type into a GEP instead of using /// ptrtoint+arithmetic+inttoptr. - Value *expandAddToGEP(const SCEV *Op, Type *Ty, Value *V); + Value *expandAddToGEP(const SCEV *Op, Value *V); /// Find a previous Value in ExprValueMap for expand. /// DropPoisonGeneratingInsts is populated with instructions for which @@ -484,7 +484,7 @@ class SCEVExpander : public SCEVVisitor { const Loop *L, Type *ExpandTy, Type *IntTy, Type *&TruncTy, bool &InvertStep); Value *expandIVInc(PHINode *PN, Value *StepV, const Loop *L, Type *ExpandTy, - Type *IntTy, bool useSubtract); + bool useSubtract); void fixupInsertPoints(Instruction *I); diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 93b4f6a0d9f88..d5e98e42b4e34 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -312,11 +312,11 @@ Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode, /// loop-invariant portions of expressions, after considering what /// can be folded using target addressing modes. /// -Value *SCEVExpander::expandAddToGEP(const SCEV *Offset, Type *Ty, Value *V) { +Value *SCEVExpander::expandAddToGEP(const SCEV *Offset, Value *V) { assert(!isa(V) || SE.DT.dominates(cast(V), &*Builder.GetInsertPoint())); - Value *Idx = expandCodeFor(Offset, Ty); + Value *Idx = expand(Offset); // Fold a GEP with constant operands. if (Constant *CLHS = dyn_cast(V)) @@ -338,7 +338,7 @@ Value *SCEVExpander::expandAddToGEP(const SCEV *Offset, Type *Ty, Value *V) { if (IP->getOpcode() == Instruction::GetElementPtr && IP->getOperand(0) == V && IP->getOperand(1) == Idx && cast(&*IP)->getSourceElementType() == - Type::getInt8Ty(Ty->getContext())) + Builder.getInt8Ty()) return &*IP; if (IP == BlockBegin) break; } @@ -495,8 +495,7 @@ Value *SCEVExpander::visitAddExpr(const SCEVAddExpr *S) { X = SE.getSCEV(U->getValue()); NewOps.push_back(X); } - Type *Ty = SE.getEffectiveSCEVType(S->getType()); - Sum = expandAddToGEP(SE.getAddExpr(NewOps), Ty, Sum); + Sum = expandAddToGEP(SE.getAddExpr(NewOps), Sum); } else if (Op->isNonConstantNegative()) { // Instead of doing a negate and add, just do a subtract. Value *W = expand(SE.getNegativeSCEV(Op)); @@ -796,12 +795,11 @@ bool SCEVExpander::isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV, /// Typically this is the LatchBlock terminator or IVIncInsertPos, but we may /// need to materialize IV increments elsewhere to handle difficult situations. Value *SCEVExpander::expandIVInc(PHINode *PN, Value *StepV, const Loop *L, - Type *ExpandTy, Type *IntTy, - bool useSubtract) { + Type *ExpandTy, bool useSubtract) { Value *IncV; // If the PHI is a pointer, use a GEP, otherwise use an add or sub. if (ExpandTy->isPointerTy()) { - IncV = expandAddToGEP(SE.getSCEV(StepV), IntTy, PN); + IncV = expandAddToGEP(SE.getSCEV(StepV), PN); } else { IncV = useSubtract ? Builder.CreateSub(PN, StepV, Twine(IVName) + ".iv.next") : @@ -1039,7 +1037,7 @@ SCEVExpander::getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized, Instruction *InsertPos = L == IVIncInsertLoop ? IVIncInsertPos : Pred->getTerminator(); Builder.SetInsertPoint(InsertPos); - Value *IncV = expandIVInc(PN, StepV, L, ExpandTy, IntTy, useSubtract); + Value *IncV = expandIVInc(PN, StepV, L, ExpandTy, useSubtract); if (isa(IncV)) { if (IncrementIsNUW) @@ -1169,7 +1167,7 @@ Value *SCEVExpander::expandAddRecExprLiterally(const SCEVAddRecExpr *S) { StepV = expandCodeFor(Step, IntTy, L->getHeader()->getFirstInsertionPt()); } - Result = expandIVInc(PN, StepV, L, ExpandTy, IntTy, useSubtract); + Result = expandIVInc(PN, StepV, L, ExpandTy, useSubtract); } } @@ -1202,9 +1200,9 @@ Value *SCEVExpander::expandAddRecExprLiterally(const SCEVAddRecExpr *S) { if (isa(ExpandTy)) { if (Result->getType()->isIntegerTy()) { Value *Base = expandCodeFor(PostLoopOffset, ExpandTy); - Result = expandAddToGEP(SE.getUnknown(Result), IntTy, Base); + Result = expandAddToGEP(SE.getUnknown(Result), Base); } else { - Result = expandAddToGEP(PostLoopOffset, IntTy, Result); + Result = expandAddToGEP(PostLoopOffset, Result); } } else { Result = InsertNoopCastOfTo(Result, IntTy); @@ -1259,7 +1257,7 @@ Value *SCEVExpander::visitAddRecExpr(const SCEVAddRecExpr *S) { if (!S->getStart()->isZero()) { if (isa(S->getType())) { Value *StartV = expand(SE.getPointerBase(S)); - return expandAddToGEP(SE.removePointerBase(S), Ty, StartV); + return expandAddToGEP(SE.removePointerBase(S), StartV); } SmallVector NewOps(S->operands());