diff --git a/llvm/lib/Analysis/Delinearization.cpp b/llvm/lib/Analysis/Delinearization.cpp index 3cc83db02128ff..19845aa63c1a79 100644 --- a/llvm/lib/Analysis/Delinearization.cpp +++ b/llvm/lib/Analysis/Delinearization.cpp @@ -131,7 +131,7 @@ struct SCEVCollectAddRecMultiplies { if (auto *Mul = dyn_cast(S)) { bool HasAddRec = false; SmallVector Operands; - for (const auto *Op : Mul->operands()) { + for (const SCEV *Op : Mul->operands()) { const SCEVUnknown *Unknown = dyn_cast(Op); if (Unknown && !isa(Unknown->getValue())) { Operands.push_back(Op); diff --git a/llvm/lib/Analysis/IVUsers.cpp b/llvm/lib/Analysis/IVUsers.cpp index fc9f4343178b8b..0880701d830821 100644 --- a/llvm/lib/Analysis/IVUsers.cpp +++ b/llvm/lib/Analysis/IVUsers.cpp @@ -73,7 +73,7 @@ static bool isInteresting(const SCEV *S, const Instruction *I, const Loop *L, // An add is interesting if exactly one of its operands is interesting. if (const SCEVAddExpr *Add = dyn_cast(S)) { bool AnyInterestingYet = false; - for (const auto *Op : Add->operands()) + for (const SCEV *Op : Add->operands()) if (isInteresting(Op, I, L, SE, LI)) { if (AnyInterestingYet) return false; @@ -346,7 +346,7 @@ static const SCEVAddRecExpr *findAddRecForLoop(const SCEV *S, const Loop *L) { } if (const SCEVAddExpr *Add = dyn_cast(S)) { - for (const auto *Op : Add->operands()) + for (const SCEV *Op : Add->operands()) if (const SCEVAddRecExpr *AR = findAddRecForLoop(Op, L)) return AR; return nullptr; diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index a2b124d3b10bfa..d67fd7985f6a50 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -171,9 +171,9 @@ const SCEV *llvm::replaceSymbolicStrideSCEV(PredicatedScalarEvolution &PSE, assert(isa(StrideSCEV) && "shouldn't be in map"); ScalarEvolution *SE = PSE.getSE(); - const auto *CT = SE->getOne(StrideSCEV->getType()); + const SCEV *CT = SE->getOne(StrideSCEV->getType()); PSE.addPredicate(*SE->getEqualPredicate(StrideSCEV, CT)); - auto *Expr = PSE.getSCEV(Ptr); + const SCEV *Expr = PSE.getSCEV(Ptr); LLVM_DEBUG(dbgs() << "LAA: Replacing SCEV: " << *OrigSCEV << " by: " << *Expr << "\n"); @@ -1084,7 +1084,7 @@ bool AccessAnalysis::createCheckForAccess(RuntimePointerChecking &RtCheck, return false; if (!isNoWrap(PSE, StridesMap, Ptr, AccessTy, TheLoop)) { - auto *Expr = PSE.getSCEV(Ptr); + const SCEV *Expr = PSE.getSCEV(Ptr); if (!Assume || !isa(Expr)) return false; PSE.setNoOverflow(Ptr, SCEVWrapPredicate::IncrementNUSW); @@ -1440,7 +1440,7 @@ static bool isNoWrapAddRec(Value *Ptr, const SCEVAddRecExpr *AR, // Assume constant for other the operand so that the AddRec can be // easily found. isa(OBO->getOperand(1))) { - auto *OpScev = PSE.getSCEV(OBO->getOperand(0)); + const SCEV *OpScev = PSE.getSCEV(OBO->getOperand(0)); if (auto *OpAR = dyn_cast(OpScev)) return OpAR->getLoop() == L && OpAR->getNoWrapFlags(SCEV::FlagNSW); diff --git a/llvm/lib/Target/ARM/MVETailPredication.cpp b/llvm/lib/Target/ARM/MVETailPredication.cpp index c0fffe05fe1d7e..e554e4d428d46f 100644 --- a/llvm/lib/Target/ARM/MVETailPredication.cpp +++ b/llvm/lib/Target/ARM/MVETailPredication.cpp @@ -205,8 +205,8 @@ const SCEV *MVETailPredication::IsSafeActiveMask(IntrinsicInst *ActiveLaneMask, if (!L->makeLoopInvariant(ElemCount, Changed)) return nullptr; - auto *EC= SE->getSCEV(ElemCount); - auto *TC = SE->getSCEV(TripCount); + const SCEV *EC = SE->getSCEV(ElemCount); + const SCEV *TC = SE->getSCEV(TripCount); int VectorWidth = cast(ActiveLaneMask->getType())->getNumElements(); if (VectorWidth != 2 && VectorWidth != 4 && VectorWidth != 8 && @@ -228,7 +228,7 @@ const SCEV *MVETailPredication::IsSafeActiveMask(IntrinsicInst *ActiveLaneMask, // different counter. Using SCEV, we check that the induction is of the // form i = i + 4, where the increment must be equal to the VectorWidth. auto *IV = ActiveLaneMask->getOperand(0); - auto *IVExpr = SE->getSCEV(IV); + const SCEV *IVExpr = SE->getSCEV(IV); auto *AddExpr = dyn_cast(IVExpr); if (!AddExpr) { @@ -291,14 +291,16 @@ const SCEV *MVETailPredication::IsSafeActiveMask(IntrinsicInst *ActiveLaneMask, // // which what we will be using here. // - auto *VW = SE->getSCEV(ConstantInt::get(TripCount->getType(), VectorWidth)); + const SCEV *VW = + SE->getSCEV(ConstantInt::get(TripCount->getType(), VectorWidth)); // ElementCount + (VW-1): - auto *Start = AddExpr->getStart(); - auto *ECPlusVWMinus1 = SE->getAddExpr(EC, + const SCEV *Start = AddExpr->getStart(); + const SCEV *ECPlusVWMinus1 = SE->getAddExpr( + EC, SE->getSCEV(ConstantInt::get(TripCount->getType(), VectorWidth - 1))); // Ceil = ElementCount + (VW-1) / VW - auto *Ceil = SE->getUDivExpr(ECPlusVWMinus1, VW); + const SCEV *Ceil = SE->getUDivExpr(ECPlusVWMinus1, VW); // Prevent unused variable warnings with TC (void)TC; diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index 5e2131b0b18075..3abf3aa5542c27 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -1287,7 +1287,7 @@ createReplacement(ICmpInst *ICmp, const Loop *L, BasicBlock *ExitingBB, MaxIter = SE->getZeroExtendExpr(MaxIter, ARTy); else if (SE->getTypeSizeInBits(ARTy) < SE->getTypeSizeInBits(MaxIterTy)) { const SCEV *MinusOne = SE->getMinusOne(ARTy); - auto *MaxAllowedIter = SE->getZeroExtendExpr(MinusOne, MaxIterTy); + const SCEV *MaxAllowedIter = SE->getZeroExtendExpr(MinusOne, MaxIterTy); if (SE->isKnownPredicateAt(ICmpInst::ICMP_ULE, MaxIter, MaxAllowedIter, BI)) MaxIter = SE->getTruncateExpr(MaxIter, ARTy); } @@ -1299,7 +1299,7 @@ createReplacement(ICmpInst *ICmp, const Loop *L, BasicBlock *ExitingBB, // So we manually construct umin(a - 1, b - 1). SmallVector Elements; if (auto *UMin = dyn_cast(MaxIter)) { - for (auto *Op : UMin->operands()) + for (const SCEV *Op : UMin->operands()) Elements.push_back(SE->getMinusSCEV(Op, SE->getOne(Op->getType()))); MaxIter = SE->getUMinFromMismatchedTypes(Elements); } else @@ -1376,15 +1376,15 @@ static bool optimizeLoopExitWithUnknownExitCount( for (auto *ICmp : LeafConditions) { auto EL = SE->computeExitLimitFromCond(L, ICmp, Inverted, /*ControlsExit*/ false); - auto *ExitMax = EL.SymbolicMaxNotTaken; + const SCEV *ExitMax = EL.SymbolicMaxNotTaken; if (isa(ExitMax)) continue; // They could be of different types (specifically this happens after // IV widening). auto *WiderType = SE->getWiderType(ExitMax->getType(), MaxIter->getType()); - auto *WideExitMax = SE->getNoopOrZeroExtend(ExitMax, WiderType); - auto *WideMaxIter = SE->getNoopOrZeroExtend(MaxIter, WiderType); + const SCEV *WideExitMax = SE->getNoopOrZeroExtend(ExitMax, WiderType); + const SCEV *WideMaxIter = SE->getNoopOrZeroExtend(MaxIter, WiderType); if (WideExitMax == WideMaxIter) ICmpsFailingOnLastIter.insert(ICmp); } diff --git a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp index b0b7ae60da9884..e5355d23b5d61b 100644 --- a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp @@ -404,9 +404,9 @@ breakBackedgeIfNotTaken(Loop *L, DominatorTree &DT, ScalarEvolution &SE, if (!L->getLoopLatch()) return LoopDeletionResult::Unmodified; - auto *BTCMax = SE.getConstantMaxBackedgeTakenCount(L); + const SCEV *BTCMax = SE.getConstantMaxBackedgeTakenCount(L); if (!BTCMax->isZero()) { - auto *BTC = SE.getBackedgeTakenCount(L); + const SCEV *BTC = SE.getBackedgeTakenCount(L); if (!BTC->isZero()) { if (!isa(BTC) && SE.isKnownNonZero(BTC)) return LoopDeletionResult::Unmodified; diff --git a/llvm/lib/Transforms/Scalar/LoopPredication.cpp b/llvm/lib/Transforms/Scalar/LoopPredication.cpp index 027dbb9c0f71ac..209b083a4e91a3 100644 --- a/llvm/lib/Transforms/Scalar/LoopPredication.cpp +++ b/llvm/lib/Transforms/Scalar/LoopPredication.cpp @@ -677,7 +677,7 @@ LoopPredication::widenICmpRangeCheck(ICmpInst *ICI, SCEVExpander &Expander, LLVM_DEBUG(dbgs() << "Range check IV is not affine!\n"); return std::nullopt; } - auto *Step = RangeCheckIV->getStepRecurrence(*SE); + const SCEV *Step = RangeCheckIV->getStepRecurrence(*SE); // We cannot just compare with latch IV step because the latch and range IVs // may have different types. if (!isSupportedStep(Step)) { @@ -845,7 +845,7 @@ std::optional LoopPredication::parseLoopLatchICmp() { return std::nullopt; } - auto *Step = Result->IV->getStepRecurrence(*SE); + const SCEV *Step = Result->IV->getStepRecurrence(*SE); if (!isSupportedStep(Step)) { LLVM_DEBUG(dbgs() << "Unsupported loop stride(" << *Step << ")!\n"); return std::nullopt; diff --git a/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp b/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp index f0c7e31b9c223a..ba62d75250c85e 100644 --- a/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp +++ b/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp @@ -865,8 +865,8 @@ static void createMemSetLoop(Instruction *InsertBefore, Value *DstAddr, template static bool canOverlap(MemTransferBase *Memcpy, ScalarEvolution *SE) { if (SE) { - auto *SrcSCEV = SE->getSCEV(Memcpy->getRawSource()); - auto *DestSCEV = SE->getSCEV(Memcpy->getRawDest()); + const SCEV *SrcSCEV = SE->getSCEV(Memcpy->getRawSource()); + const SCEV *DestSCEV = SE->getSCEV(Memcpy->getRawDest()); if (SE->isKnownPredicateAt(CmpInst::ICMP_NE, SrcSCEV, DestSCEV, Memcpy)) return false; } diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index 5bda7c50c62c66..8e3a14bb4f6d79 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -167,8 +167,8 @@ Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand) D = ConstantInt::get(UseInst->getContext(), APInt::getOneBitSet(BitWidth, D->getZExtValue())); } - const auto *LHS = SE->getSCEV(IVSrc); - const auto *RHS = SE->getSCEV(D); + const SCEV *LHS = SE->getSCEV(IVSrc); + const SCEV *RHS = SE->getSCEV(D); FoldedExpr = SE->getUDivExpr(LHS, RHS); // We might have 'exact' flag set at this point which will no longer be // correct after we make the replacement. @@ -297,8 +297,8 @@ void SimplifyIndvar::eliminateIVComparison(ICmpInst *ICmp, bool SimplifyIndvar::eliminateSDiv(BinaryOperator *SDiv) { // Get the SCEVs for the ICmp operands. - auto *N = SE->getSCEV(SDiv->getOperand(0)); - auto *D = SE->getSCEV(SDiv->getOperand(1)); + const SCEV *N = SE->getSCEV(SDiv->getOperand(0)); + const SCEV *D = SE->getSCEV(SDiv->getOperand(1)); // Simplify unnecessary loops away. const Loop *L = LI->getLoopFor(SDiv->getParent()); @@ -397,7 +397,7 @@ void SimplifyIndvar::simplifyIVRemainder(BinaryOperator *Rem, } auto *T = Rem->getType(); - const auto *NLessOne = SE->getMinusSCEV(N, SE->getOne(T)); + const SCEV *NLessOne = SE->getMinusSCEV(N, SE->getOne(T)); if (SE->isKnownPredicate(LT, NLessOne, D)) { replaceRemWithNumeratorOrZero(Rem); return; diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp index 5babb1d4c1f967..465d0df30e3f75 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp @@ -507,14 +507,15 @@ class SCEVAddRecForUniformityRewriter // Build a new AddRec by multiplying the step by StepMultiplier and // incrementing the start by Offset * step. Type *Ty = Expr->getType(); - auto *Step = Expr->getStepRecurrence(SE); + const SCEV *Step = Expr->getStepRecurrence(SE); if (!SE.isLoopInvariant(Step, TheLoop)) { CannotAnalyze = true; return Expr; } - auto *NewStep = SE.getMulExpr(Step, SE.getConstant(Ty, StepMultiplier)); - auto *ScaledOffset = SE.getMulExpr(Step, SE.getConstant(Ty, Offset)); - auto *NewStart = SE.getAddExpr(Expr->getStart(), ScaledOffset); + const SCEV *NewStep = + SE.getMulExpr(Step, SE.getConstant(Ty, StepMultiplier)); + const SCEV *ScaledOffset = SE.getMulExpr(Step, SE.getConstant(Ty, Offset)); + const SCEV *NewStart = SE.getAddExpr(Expr->getStart(), ScaledOffset); return SE.getAddRecExpr(NewStart, NewStep, TheLoop, SCEV::FlagAnyWrap); } diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 8d2ce6bad6af70..cd273429e6e67e 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -19062,10 +19062,10 @@ bool SLPVectorizerPass::vectorizeGEPIndices(BasicBlock *BB, BoUpSLP &R) { auto *GEPI = GEPList[I]; if (!Candidates.count(GEPI)) continue; - auto *SCEVI = SE->getSCEV(GEPList[I]); + const SCEV *SCEVI = SE->getSCEV(GEPList[I]); for (int J = I + 1; J < E && Candidates.size() > 1; ++J) { auto *GEPJ = GEPList[J]; - auto *SCEVJ = SE->getSCEV(GEPList[J]); + const SCEV *SCEVJ = SE->getSCEV(GEPList[J]); if (isa(SE->getMinusSCEV(SCEVI, SCEVJ))) { Candidates.remove(GEPI); Candidates.remove(GEPJ); diff --git a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp index 3802ae4051f423..5e20e434780117 100644 --- a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp +++ b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp @@ -141,9 +141,9 @@ TEST_F(ScalarEvolutionsTest, SimplifiedPHI) { PN->addIncoming(Constant::getNullValue(Ty), EntryBB); PN->addIncoming(UndefValue::get(Ty), LoopBB); ScalarEvolution SE = buildSE(*F); - auto *S1 = SE.getSCEV(PN); - auto *S2 = SE.getSCEV(PN); - auto *ZeroConst = SE.getConstant(Ty, 0); + const SCEV *S1 = SE.getSCEV(PN); + const SCEV *S2 = SE.getSCEV(PN); + const SCEV *ZeroConst = SE.getConstant(Ty, 0); // At some point, only the first call to getSCEV returned the simplified // SCEVConstant and later calls just returned a SCEVUnknown referencing the @@ -238,9 +238,9 @@ TEST_F(ScalarEvolutionsTest, CommutativeExprOperandOrder) { auto *IV0 = getInstructionByName(F, "iv0"); auto *IV0Inc = getInstructionByName(F, "iv0.inc"); - auto *FirstExprForIV0 = SE.getSCEV(IV0); - auto *FirstExprForIV0Inc = SE.getSCEV(IV0Inc); - auto *SecondExprForIV0 = SE.getSCEV(IV0); + const SCEV *FirstExprForIV0 = SE.getSCEV(IV0); + const SCEV *FirstExprForIV0Inc = SE.getSCEV(IV0Inc); + const SCEV *SecondExprForIV0 = SE.getSCEV(IV0); EXPECT_TRUE(isa(FirstExprForIV0)); EXPECT_TRUE(isa(FirstExprForIV0Inc)); @@ -260,12 +260,12 @@ TEST_F(ScalarEvolutionsTest, CommutativeExprOperandOrder) { SmallVector Ops4 = {C, B, A}; SmallVector Ops5 = {C, A, B}; - auto *Mul0 = SE.getMulExpr(Ops0); - auto *Mul1 = SE.getMulExpr(Ops1); - auto *Mul2 = SE.getMulExpr(Ops2); - auto *Mul3 = SE.getMulExpr(Ops3); - auto *Mul4 = SE.getMulExpr(Ops4); - auto *Mul5 = SE.getMulExpr(Ops5); + const SCEV *Mul0 = SE.getMulExpr(Ops0); + const SCEV *Mul1 = SE.getMulExpr(Ops1); + const SCEV *Mul2 = SE.getMulExpr(Ops2); + const SCEV *Mul3 = SE.getMulExpr(Ops3); + const SCEV *Mul4 = SE.getMulExpr(Ops4); + const SCEV *Mul5 = SE.getMulExpr(Ops5); EXPECT_EQ(Mul0, Mul1) << "Expected " << *Mul0 << " == " << *Mul1; EXPECT_EQ(Mul1, Mul2) << "Expected " << *Mul1 << " == " << *Mul2; @@ -383,8 +383,8 @@ TEST_F(ScalarEvolutionsTest, CompareValueComplexity) { // CompareValueComplexity that is both fast and more accurate. ScalarEvolution SE = buildSE(*F); - auto *A = SE.getSCEV(MulA); - auto *B = SE.getSCEV(MulB); + const SCEV *A = SE.getSCEV(MulA); + const SCEV *B = SE.getSCEV(MulB); EXPECT_NE(A, B); } @@ -430,21 +430,21 @@ TEST_F(ScalarEvolutionsTest, SCEVAddExpr) { EXPECT_EQ(AddWithNUW->getNumOperands(), 3u); EXPECT_EQ(AddWithNUW->getNoWrapFlags(), SCEV::FlagNUW); - auto *AddWithAnyWrap = + const SCEV *AddWithAnyWrap = SE.getAddExpr(SE.getSCEV(A3), SE.getSCEV(A4), SCEV::FlagAnyWrap); auto *AddWithAnyWrapNUW = cast( SE.getAddExpr(AddWithAnyWrap, SE.getSCEV(A5), SCEV::FlagNUW)); EXPECT_EQ(AddWithAnyWrapNUW->getNumOperands(), 3u); EXPECT_EQ(AddWithAnyWrapNUW->getNoWrapFlags(), SCEV::FlagAnyWrap); - auto *AddWithNSW = SE.getAddExpr( + const SCEV *AddWithNSW = SE.getAddExpr( SE.getSCEV(A2), SE.getConstant(APInt(32, 99)), SCEV::FlagNSW); auto *AddWithNSW_NUW = cast( SE.getAddExpr(AddWithNSW, SE.getSCEV(A5), SCEV::FlagNUW)); EXPECT_EQ(AddWithNSW_NUW->getNumOperands(), 3u); EXPECT_EQ(AddWithNSW_NUW->getNoWrapFlags(), SCEV::FlagAnyWrap); - auto *AddWithNSWNUW = + const SCEV *AddWithNSWNUW = SE.getAddExpr(SE.getSCEV(A2), SE.getSCEV(A4), ScalarEvolution::setFlags(SCEV::FlagNUW, SCEV::FlagNSW)); auto *AddWithNSWNUW_NUW = cast( @@ -780,8 +780,8 @@ TEST_F(ScalarEvolutionsTest, SCEVExitLimitForgetLoop) { // The add recurrence {5,+,1} does not correspond to any PHI in the IR, and // that is relevant to this test. - auto *Five = SE.getConstant(APInt(/*numBits=*/64, 5)); - auto *AR = + const SCEV *Five = SE.getConstant(APInt(/*numBits=*/64, 5)); + const SCEV *AR = SE.getAddRecExpr(Five, SE.getOne(T_int64), Loop, SCEV::FlagAnyWrap); const SCEV *ARAtLoopExit = SE.getSCEVAtScope(AR, nullptr); EXPECT_FALSE(isa(ARAtLoopExit)); @@ -1019,19 +1019,19 @@ TEST_F(ScalarEvolutionsTest, SCEVFoldSumOfTruncs) { ScalarEvolution SE = buildSE(*F); auto *Arg = &*(F->arg_begin()); - const auto *ArgSCEV = SE.getSCEV(Arg); + const SCEV *ArgSCEV = SE.getSCEV(Arg); // Build the SCEV - const auto *A0 = SE.getNegativeSCEV(ArgSCEV); - const auto *A1 = SE.getTruncateExpr(A0, Int32Ty); - const auto *A = SE.getNegativeSCEV(A1); + const SCEV *A0 = SE.getNegativeSCEV(ArgSCEV); + const SCEV *A1 = SE.getTruncateExpr(A0, Int32Ty); + const SCEV *A = SE.getNegativeSCEV(A1); - const auto *B0 = SE.getTruncateExpr(ArgSCEV, Int32Ty); - const auto *B = SE.getNegativeSCEV(B0); + const SCEV *B0 = SE.getTruncateExpr(ArgSCEV, Int32Ty); + const SCEV *B = SE.getNegativeSCEV(B0); - const auto *Expr = SE.getAddExpr(A, B); + const SCEV *Expr = SE.getAddExpr(A, B); // Verify that the SCEV was folded to 0 - const auto *ZeroConst = SE.getConstant(Int32Ty, 0); + const SCEV *ZeroConst = SE.getConstant(Int32Ty, 0); EXPECT_EQ(Expr, ZeroConst); } @@ -1108,7 +1108,7 @@ TEST_F(ScalarEvolutionsTest, SCEVLoopDecIntrinsic) { ASSERT_TRUE(!verifyModule(*M) && "Must have been well formed!"); runWithSE(*M, "foo", [&](Function &F, LoopInfo &LI, ScalarEvolution &SE) { - auto *ScevInc = SE.getSCEV(getInstructionByName(F, "inc")); + const SCEV *ScevInc = SE.getSCEV(getInstructionByName(F, "inc")); EXPECT_TRUE(isa(ScevInc)); }); } @@ -1141,16 +1141,19 @@ TEST_F(ScalarEvolutionsTest, SCEVComputeConstantDifference) { ASSERT_TRUE(!verifyModule(*M) && "Must have been well formed!"); runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) { - auto *ScevV0 = SE.getSCEV(getInstructionByName(F, "v0")); // %pp - auto *ScevV3 = SE.getSCEV(getInstructionByName(F, "v3")); // (3 + %pp) - auto *ScevVX = SE.getSCEV(getInstructionByName(F, "vx")); // (%pp + %x) + const SCEV *ScevV0 = SE.getSCEV(getInstructionByName(F, "v0")); // %pp + const SCEV *ScevV3 = SE.getSCEV(getInstructionByName(F, "v3")); // (3 + %pp) + const SCEV *ScevVX = + SE.getSCEV(getInstructionByName(F, "vx")); // (%pp + %x) // (%pp + %x + 3) - auto *ScevVX3 = SE.getSCEV(getInstructionByName(F, "vx3")); - auto *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1} - auto *ScevXA = SE.getSCEV(getInstructionByName(F, "xa")); // {%pp,+,1} - auto *ScevYY = SE.getSCEV(getInstructionByName(F, "yy")); // {(3 + %pp),+,1} - auto *ScevXB = SE.getSCEV(getInstructionByName(F, "xb")); // {%pp,+,1} - auto *ScevIVNext = SE.getSCEV(getInstructionByName(F, "iv.next")); // {1,+,1} + const SCEV *ScevVX3 = SE.getSCEV(getInstructionByName(F, "vx3")); + const SCEV *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1} + const SCEV *ScevXA = SE.getSCEV(getInstructionByName(F, "xa")); // {%pp,+,1} + const SCEV *ScevYY = + SE.getSCEV(getInstructionByName(F, "yy")); // {(3 + %pp),+,1} + const SCEV *ScevXB = SE.getSCEV(getInstructionByName(F, "xb")); // {%pp,+,1} + const SCEV *ScevIVNext = + SE.getSCEV(getInstructionByName(F, "iv.next")); // {1,+,1} auto diff = [&SE](const SCEV *LHS, const SCEV *RHS) -> std::optional { auto ConstantDiffOrNone = computeConstantDifference(SE, LHS, RHS); @@ -1203,16 +1206,17 @@ TEST_F(ScalarEvolutionsTest, SCEVrewriteUnknowns) { ASSERT_TRUE(!verifyModule(*M) && "Must have been well formed!"); runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) { - auto *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1} - auto *ScevI = SE.getSCEV(getArgByName(F, "i")); // {0,+,1} + const SCEV *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1} + const SCEV *ScevI = SE.getSCEV(getArgByName(F, "i")); // {0,+,1} ValueToSCEVMapTy RewriteMap; RewriteMap[cast(ScevI)->getValue()] = SE.getUMinExpr(ScevI, SE.getConstant(ScevI->getType(), 17)); - auto *WithUMin = SCEVParameterRewriter::rewrite(ScevIV, SE, RewriteMap); + const SCEV *WithUMin = + SCEVParameterRewriter::rewrite(ScevIV, SE, RewriteMap); EXPECT_NE(WithUMin, ScevIV); - auto *AR = dyn_cast(WithUMin); + const auto *AR = dyn_cast(WithUMin); EXPECT_TRUE(AR); EXPECT_EQ(AR->getStart(), SE.getUMinExpr(ScevI, SE.getConstant(ScevI->getType(), 17))); @@ -1233,9 +1237,9 @@ TEST_F(ScalarEvolutionsTest, SCEVAddNUW) { ASSERT_TRUE(!verifyModule(*M) && "Must have been well formed!"); runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) { - auto *X = SE.getSCEV(getArgByName(F, "x")); - auto *One = SE.getOne(X->getType()); - auto *Sum = SE.getAddExpr(X, One, SCEV::FlagNUW); + const SCEV *X = SE.getSCEV(getArgByName(F, "x")); + const SCEV *One = SE.getOne(X->getType()); + const SCEV *Sum = SE.getAddExpr(X, One, SCEV::FlagNUW); EXPECT_TRUE(SE.isKnownPredicate(ICmpInst::ICMP_UGE, Sum, X)); EXPECT_TRUE(SE.isKnownPredicate(ICmpInst::ICMP_UGT, Sum, X)); }); @@ -1259,16 +1263,17 @@ TEST_F(ScalarEvolutionsTest, SCEVgetRanges) { Err, C); runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) { - auto *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1} - auto *ScevI = SE.getSCEV(getArgByName(F, "i")); + const SCEV *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1} + const SCEV *ScevI = SE.getSCEV(getArgByName(F, "i")); EXPECT_EQ(SE.getUnsignedRange(ScevIV).getLower(), 0); EXPECT_EQ(SE.getUnsignedRange(ScevIV).getUpper(), 16); - auto *Add = SE.getAddExpr(ScevI, ScevIV); + const SCEV *Add = SE.getAddExpr(ScevI, ScevIV); ValueToSCEVMapTy RewriteMap; RewriteMap[cast(ScevI)->getValue()] = SE.getUMinExpr(ScevI, SE.getConstant(ScevI->getType(), 17)); - auto *AddWithUMin = SCEVParameterRewriter::rewrite(Add, SE, RewriteMap); + const SCEV *AddWithUMin = + SCEVParameterRewriter::rewrite(Add, SE, RewriteMap); EXPECT_EQ(SE.getUnsignedRange(AddWithUMin).getLower(), 0); EXPECT_EQ(SE.getUnsignedRange(AddWithUMin).getUpper(), 33); }); @@ -1296,7 +1301,7 @@ TEST_F(ScalarEvolutionsTest, SCEVgetExitLimitForGuardedLoop) { ASSERT_TRUE(!verifyModule(*M) && "Must have been well formed!"); runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) { - auto *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1} + const SCEV *ScevIV = SE.getSCEV(getInstructionByName(F, "iv")); // {0,+,1} const Loop *L = cast(ScevIV)->getLoop(); const SCEV *BTC = SE.getBackedgeTakenCount(L); @@ -1331,7 +1336,7 @@ TEST_F(ScalarEvolutionsTest, ImpliedViaAddRecStart) { ASSERT_TRUE(!verifyModule(*M) && "Must have been well formed!"); runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) { - auto *X = SE.getSCEV(getInstructionByName(F, "x")); + const SCEV *X = SE.getSCEV(getInstructionByName(F, "x")); auto *Context = getInstructionByName(F, "iv.next"); EXPECT_TRUE(SE.isKnownPredicateAt(ICmpInst::ICMP_NE, X, SE.getZero(X->getType()), Context)); @@ -1360,8 +1365,8 @@ TEST_F(ScalarEvolutionsTest, UnsignedIsImpliedViaOperations) { ASSERT_TRUE(!verifyModule(*M) && "Must have been well formed!"); runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) { - auto *X = SE.getSCEV(getInstructionByName(F, "x")); - auto *Y = SE.getSCEV(getInstructionByName(F, "y")); + const SCEV *X = SE.getSCEV(getInstructionByName(F, "x")); + const SCEV *Y = SE.getSCEV(getInstructionByName(F, "y")); auto *Guarded = getInstructionByName(F, "y")->getParent(); ASSERT_TRUE(Guarded); EXPECT_TRUE( @@ -1403,8 +1408,8 @@ TEST_F(ScalarEvolutionsTest, ProveImplicationViaNarrowing) { ASSERT_TRUE(!verifyModule(*M) && "Must have been well formed!"); runWithSE(*M, "foo", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) { - auto *IV = SE.getSCEV(getInstructionByName(F, "iv")); - auto *Zero = SE.getZero(IV->getType()); + const SCEV *IV = SE.getSCEV(getInstructionByName(F, "iv")); + const SCEV *Zero = SE.getZero(IV->getType()); auto *Backedge = getInstructionByName(F, "iv.next")->getParent(); ASSERT_TRUE(Backedge); (void)IV; @@ -1531,8 +1536,8 @@ TEST_F(ScalarEvolutionsTest, SCEVUDivFloorCeiling) { using namespace llvm::APIntOps; APInt FloorInt = RoundingUDiv(NInt, DInt, APInt::Rounding::DOWN); APInt CeilingInt = RoundingUDiv(NInt, DInt, APInt::Rounding::UP); - auto *NS = SE.getConstant(NInt); - auto *DS = SE.getConstant(DInt); + const SCEV *NS = SE.getConstant(NInt); + const SCEV *DS = SE.getConstant(DInt); auto *FloorS = cast(SE.getUDivExpr(NS, DS)); auto *CeilingS = cast(SE.getUDivCeilSCEV(NS, DS)); ASSERT_TRUE(FloorS->getAPInt() == FloorInt); @@ -1584,13 +1589,13 @@ TEST_F(ScalarEvolutionsTest, ApplyLoopGuards) { ASSERT_TRUE(!verifyModule(*M) && "Must have been well formed!"); runWithSE(*M, "test", [](Function &F, LoopInfo &LI, ScalarEvolution &SE) { - auto *TCScev = SE.getSCEV(getArgByName(F, "num")); - auto *ApplyLoopGuardsTC = SE.applyLoopGuards(TCScev, *LI.begin()); + const SCEV *TCScev = SE.getSCEV(getArgByName(F, "num")); + const SCEV *ApplyLoopGuardsTC = SE.applyLoopGuards(TCScev, *LI.begin()); // Assert that the new TC is (4 * ((4 umax %num) /u 4)) APInt Four(32, 4); - auto *Constant4 = SE.getConstant(Four); - auto *Max = SE.getUMaxExpr(TCScev, Constant4); - auto *Mul = SE.getMulExpr(SE.getUDivExpr(Max, Constant4), Constant4); + const SCEV *Constant4 = SE.getConstant(Four); + const SCEV *Max = SE.getUMaxExpr(TCScev, Constant4); + const SCEV *Mul = SE.getMulExpr(SE.getUDivExpr(Max, Constant4), Constant4); ASSERT_TRUE(Mul == ApplyLoopGuardsTC); }); } diff --git a/llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp b/llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp index 2b11aadb7f6e4d..cd4717181d2ca3 100644 --- a/llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp +++ b/llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp @@ -114,7 +114,7 @@ TEST(LoopUtils, IsKnownPositiveInLoopTest) { Loop *L = *LI.begin(); assert(L && L->getName() == "loop" && "Expecting loop 'loop'"); auto *Arg = F.getArg(0); - auto *ArgSCEV = SE.getSCEV(Arg); + const SCEV *ArgSCEV = SE.getSCEV(Arg); EXPECT_EQ(isKnownPositiveInLoop(ArgSCEV, L, SE), true); }); } @@ -138,7 +138,7 @@ TEST(LoopUtils, IsKnownNonPositiveInLoopTest) { Loop *L = *LI.begin(); assert(L && L->getName() == "loop" && "Expecting loop 'loop'"); auto *Arg = F.getArg(0); - auto *ArgSCEV = SE.getSCEV(Arg); + const SCEV *ArgSCEV = SE.getSCEV(Arg); EXPECT_EQ(isKnownNonPositiveInLoop(ArgSCEV, L, SE), true); }); } diff --git a/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp b/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp index 9e80c6d39c3c13..c4560cb9ce9b22 100644 --- a/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp +++ b/llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp @@ -117,7 +117,7 @@ TEST_F(ScalarEvolutionExpanderTest, ExpandPtrTypeSCEV) { CastInst::CreateBitOrPointerCast(Sel, I32PtrTy, "bitcast2", Br); ScalarEvolution SE = buildSE(*F); - auto *S = SE.getSCEV(CastB); + const SCEV *S = SE.getSCEV(CastB); EXPECT_TRUE(isa(S)); } @@ -185,7 +185,7 @@ TEST_F(ScalarEvolutionExpanderTest, SCEVZeroExtendExprNonIntegral) { Instruction *Ret = Builder.CreateRetVoid(); ScalarEvolution SE = buildSE(*F); - auto *AddRec = + const SCEV *AddRec = SE.getAddRecExpr(SE.getUnknown(GepBase), SE.getConstant(T_int64, 1), LI->getLoopFor(L), SCEV::FlagNUW); @@ -762,7 +762,7 @@ TEST_F(ScalarEvolutionExpanderTest, SCEVExpandNonAffineAddRec) { SCEVExpander Exp(SE, M->getDataLayout(), "expander"); auto *InsertAt = I.getNextNode(); Value *V = Exp.expandCodeFor(AR, nullptr, InsertAt); - auto *ExpandedAR = SE.getSCEV(V); + const SCEV *ExpandedAR = SE.getSCEV(V); // Check that the expansion happened literally. EXPECT_EQ(AR, ExpandedAR); }); @@ -811,7 +811,7 @@ TEST_F(ScalarEvolutionExpanderTest, SCEVExpandNonAffineAddRec) { SCEVExpander Exp(SE, M->getDataLayout(), "expander"); auto *InsertAt = I.getNextNode(); Value *V = Exp.expandCodeFor(AR, nullptr, InsertAt); - auto *ExpandedAR = SE.getSCEV(V); + const SCEV *ExpandedAR = SE.getSCEV(V); // Check that the expansion happened literally. EXPECT_EQ(AR, ExpandedAR); }); @@ -866,7 +866,7 @@ TEST_F(ScalarEvolutionExpanderTest, SCEVExpandNonAffineAddRec) { SCEVExpander Exp(SE, M->getDataLayout(), "expander"); auto *InsertAt = I.getNextNode(); Value *V = Exp.expandCodeFor(AR, nullptr, InsertAt); - auto *ExpandedAR = SE.getSCEV(V); + const SCEV *ExpandedAR = SE.getSCEV(V); // Check that the expansion happened literally. EXPECT_EQ(AR, ExpandedAR); });