diff options
author | Nikita Popov <npopov@redhat.com> | 2023-09-21 16:13:32 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-09-21 16:15:49 +0200 |
commit | eb31208be15326e6e6523611e6d3d8fdabbbc127 (patch) | |
tree | 024d21f0c62822c47fa61fcf6d7f702e083572f6 /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | b5ff57615165a4e4f7a719c44bfbf1194822a3fb (diff) | |
download | llvm-eb31208be15326e6e6523611e6d3d8fdabbbc127.zip llvm-eb31208be15326e6e6523611e6d3d8fdabbbc127.tar.gz llvm-eb31208be15326e6e6523611e6d3d8fdabbbc127.tar.bz2 |
[SCEVExpander] Drop Ty argument from expandAddToGEP() (NFC)
We can directly use the type of Offset here.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 93b4f6a..d5e98e4 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<Instruction>(V) || SE.DT.dominates(cast<Instruction>(V), &*Builder.GetInsertPoint())); - Value *Idx = expandCodeFor(Offset, Ty); + Value *Idx = expand(Offset); // Fold a GEP with constant operands. if (Constant *CLHS = dyn_cast<Constant>(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<GEPOperator>(&*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<OverflowingBinaryOperator>(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<PointerType>(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<PointerType>(S->getType())) { Value *StartV = expand(SE.getPointerBase(S)); - return expandAddToGEP(SE.removePointerBase(S), Ty, StartV); + return expandAddToGEP(SE.removePointerBase(S), StartV); } SmallVector<const SCEV *, 4> NewOps(S->operands()); |