diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h --- a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -72,13 +72,13 @@ } /// This is the base class for unary cast operator classes. - class SCEVCastExpr : public SCEV { + class SCEVIntegralCastExpr : public SCEV { protected: std::array Operands; Type *Ty; - SCEVCastExpr(const FoldingSetNodeIDRef ID, - unsigned SCEVTy, const SCEV *op, Type *ty); + SCEVIntegralCastExpr(const FoldingSetNodeIDRef ID, unsigned SCEVTy, + const SCEV *op, Type *ty); public: const SCEV *getOperand() const { return Operands[0]; } @@ -105,7 +105,7 @@ /// This class represents a truncation of an integer value to a /// smaller integer value. - class SCEVTruncateExpr : public SCEVCastExpr { + class SCEVTruncateExpr : public SCEVIntegralCastExpr { friend class ScalarEvolution; SCEVTruncateExpr(const FoldingSetNodeIDRef ID, @@ -120,7 +120,7 @@ /// This class represents a zero extension of a small integer value /// to a larger integer value. - class SCEVZeroExtendExpr : public SCEVCastExpr { + class SCEVZeroExtendExpr : public SCEVIntegralCastExpr { friend class ScalarEvolution; SCEVZeroExtendExpr(const FoldingSetNodeIDRef ID, @@ -135,7 +135,7 @@ /// This class represents a sign extension of a small integer value /// to a larger integer value. - class SCEVSignExtendExpr : public SCEVCastExpr { + class SCEVSignExtendExpr : public SCEVIntegralCastExpr { friend class ScalarEvolution; SCEVSignExtendExpr(const FoldingSetNodeIDRef ID, @@ -610,7 +610,7 @@ case scTruncate: case scZeroExtend: case scSignExtend: - push(cast(S)->getOperand()); + push(cast(S)->getOperand()); break; case scAddExpr: case scMulExpr: diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp --- a/llvm/lib/Analysis/DependenceAnalysis.cpp +++ b/llvm/lib/Analysis/DependenceAnalysis.cpp @@ -871,8 +871,8 @@ const SCEV *Dst = Pair->Dst; if ((isa(Src) && isa(Dst)) || (isa(Src) && isa(Dst))) { - const SCEVCastExpr *SrcCast = cast(Src); - const SCEVCastExpr *DstCast = cast(Dst); + const SCEVIntegralCastExpr *SrcCast = cast(Src); + const SCEVIntegralCastExpr *DstCast = cast(Dst); const SCEV *SrcCastOp = SrcCast->getOperand(); const SCEV *DstCastOp = DstCast->getOperand(); if (SrcCastOp->getType() == DstCastOp->getType()) { @@ -969,8 +969,8 @@ isa(Y)) || (isa(X) && isa(Y))) { - const SCEVCastExpr *CX = cast(X); - const SCEVCastExpr *CY = cast(Y); + const SCEVIntegralCastExpr *CX = cast(X); + const SCEVIntegralCastExpr *CY = cast(Y); const SCEV *Xop = CX->getOperand(); const SCEV *Yop = CY->getOperand(); if (Xop->getType() == Yop->getType()) { diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -367,7 +367,7 @@ case scTruncate: case scZeroExtend: case scSignExtend: - return cast(this)->getType(); + return cast(this)->getType(); case scAddRecExpr: case scMulExpr: case scUMaxExpr: @@ -445,29 +445,30 @@ return getConstant(ConstantInt::get(ITy, V, isSigned)); } -SCEVCastExpr::SCEVCastExpr(const FoldingSetNodeIDRef ID, - unsigned SCEVTy, const SCEV *op, Type *ty) - : SCEV(ID, SCEVTy, computeExpressionSize(op)), Ty(ty) { - Operands[0] = op; +SCEVIntegralCastExpr::SCEVIntegralCastExpr(const FoldingSetNodeIDRef ID, + unsigned SCEVTy, const SCEV *op, + Type *ty) + : SCEV(ID, SCEVTy, computeExpressionSize(op)), Ty(ty) { + Operands[0] = op; } -SCEVTruncateExpr::SCEVTruncateExpr(const FoldingSetNodeIDRef ID, - const SCEV *op, Type *ty) - : SCEVCastExpr(ID, scTruncate, op, ty) { +SCEVTruncateExpr::SCEVTruncateExpr(const FoldingSetNodeIDRef ID, const SCEV *op, + Type *ty) + : SCEVIntegralCastExpr(ID, scTruncate, op, ty) { assert(getOperand()->getType()->isIntOrPtrTy() && Ty->isIntOrPtrTy() && "Cannot truncate non-integer value!"); } SCEVZeroExtendExpr::SCEVZeroExtendExpr(const FoldingSetNodeIDRef ID, const SCEV *op, Type *ty) - : SCEVCastExpr(ID, scZeroExtend, op, ty) { + : SCEVIntegralCastExpr(ID, scZeroExtend, op, ty) { assert(getOperand()->getType()->isIntOrPtrTy() && Ty->isIntOrPtrTy() && "Cannot zero extend non-integer value!"); } SCEVSignExtendExpr::SCEVSignExtendExpr(const FoldingSetNodeIDRef ID, const SCEV *op, Type *ty) - : SCEVCastExpr(ID, scSignExtend, op, ty) { + : SCEVIntegralCastExpr(ID, scSignExtend, op, ty) { assert(getOperand()->getType()->isIntOrPtrTy() && Ty->isIntOrPtrTy() && "Cannot sign extend non-integer value!"); } @@ -781,8 +782,8 @@ case scTruncate: case scZeroExtend: case scSignExtend: { - const SCEVCastExpr *LC = cast(LHS); - const SCEVCastExpr *RC = cast(RHS); + const SCEVIntegralCastExpr *LC = cast(LHS); + const SCEVIntegralCastExpr *RC = cast(RHS); // Compare cast expressions by operand. int X = CompareSCEVComplexity(EqCacheSCEV, EqCacheValue, LI, @@ -1052,7 +1053,8 @@ for (unsigned i = 0, e = CommOp->getNumOperands(); i != e && numTruncs < 2; ++i) { const SCEV *S = getTruncateExpr(CommOp->getOperand(i), Ty, Depth + 1); - if (!isa(CommOp->getOperand(i)) && isa(S)) + if (!isa(CommOp->getOperand(i)) && + isa(S)) numTruncs++; Operands.push_back(S); } @@ -3964,7 +3966,7 @@ return V; while (true) { - if (const SCEVCastExpr *Cast = dyn_cast(V)) { + if (const SCEVIntegralCastExpr *Cast = dyn_cast(V)) { V = Cast->getOperand(); } else if (const SCEVNAryExpr *NAry = dyn_cast(V)) { const SCEV *PtrOp = nullptr; @@ -5721,7 +5723,7 @@ } // Peel off a cast operation - if (auto *SCast = dyn_cast(S)) { + if (auto *SCast = dyn_cast(S)) { CastOp = SCast->getSCEVType(); S = SCast->getOperand(); } @@ -11795,7 +11797,7 @@ case scTruncate: case scZeroExtend: case scSignExtend: - return getLoopDisposition(cast(S)->getOperand(), L); + return getLoopDisposition(cast(S)->getOperand(), L); case scAddRecExpr: { const SCEVAddRecExpr *AR = cast(S); @@ -11902,7 +11904,7 @@ case scTruncate: case scZeroExtend: case scSignExtend: - return getBlockDisposition(cast(S)->getOperand(), BB); + return getBlockDisposition(cast(S)->getOperand(), BB); case scAddRecExpr: { // This uses a "dominates" query instead of "properly dominates" query // to test for proper dominance too, because the instruction which diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp --- a/llvm/lib/Analysis/VectorUtils.cpp +++ b/llvm/lib/Analysis/VectorUtils.cpp @@ -208,7 +208,7 @@ if (Ptr != OrigPtr) // Strip off casts. - while (const SCEVCastExpr *C = dyn_cast(V)) + while (const SCEVIntegralCastExpr *C = dyn_cast(V)) V = C->getOperand(); const SCEVAddRecExpr *S = dyn_cast(V); @@ -241,7 +241,7 @@ // Strip off casts. Type *StripedOffRecurrenceCast = nullptr; - if (const SCEVCastExpr *C = dyn_cast(V)) { + if (const SCEVIntegralCastExpr *C = dyn_cast(V)) { StripedOffRecurrenceCast = C->getType(); V = C->getOperand(); } diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1212,7 +1212,7 @@ return 0; if (const auto *S = dyn_cast(Reg)) return getSetupCost(S->getStart(), Depth - 1); - if (auto S = dyn_cast(Reg)) + if (auto S = dyn_cast(Reg)) return getSetupCost(S->getOperand(), Depth - 1); if (auto S = dyn_cast(Reg)) return std::accumulate(S->op_begin(), S->op_end(), 0, @@ -3403,7 +3403,7 @@ if (const SCEVNAryExpr *N = dyn_cast(S)) Worklist.append(N->op_begin(), N->op_end()); - else if (const SCEVCastExpr *C = dyn_cast(S)) + else if (const SCEVIntegralCastExpr *C = dyn_cast(S)) Worklist.push_back(C->getOperand()); else if (const SCEVUDivExpr *D = dyn_cast(S)) { Worklist.push_back(D->getLHS()); diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -663,7 +663,7 @@ L = PickMostRelevantLoop(L, getRelevantLoop(Op), SE.DT); return RelevantLoops[N] = L; } - if (const SCEVCastExpr *C = dyn_cast(S)) { + if (const SCEVIntegralCastExpr *C = dyn_cast(S)) { const Loop *Result = getRelevantLoop(C->getOperand()); return RelevantLoops[C] = Result; } @@ -2364,9 +2364,9 @@ TTI.getIntImmCostInst(WorkItem.ParentOpcode, WorkItem.OperandIdx, Imm, Ty, CostKind); return BudgetRemaining < 0; - } else if (isa(S)) { - int Cost = - costAndCollectOperands(WorkItem, TTI, CostKind, Worklist); + } else if (isa(S)) { + int Cost = costAndCollectOperands(WorkItem, TTI, + CostKind, Worklist); BudgetRemaining -= Cost; return false; // Will answer upon next entry into this function. } else if (isa(S)) {