diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index 74efe4db7f41..0d7f9ae298e2 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -739,7 +739,6 @@ public: LLVM_ABI const SCEV *getConstant(Type *Ty, uint64_t V, bool isSigned = false); LLVM_ABI const SCEV *getPtrToAddrExpr(const SCEV *Op); - LLVM_ABI const SCEV *getPtrToIntExpr(const SCEV *Op, Type *Ty); LLVM_ABI const SCEV *getTruncateExpr(const SCEV *Op, Type *Ty, unsigned Depth = 0); LLVM_ABI const SCEV *getVScale(Type *Ty); diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionDivision.h b/llvm/include/llvm/Analysis/ScalarEvolutionDivision.h index 6e8baae6237f..da873bda9db5 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolutionDivision.h +++ b/llvm/include/llvm/Analysis/ScalarEvolutionDivision.h @@ -47,7 +47,6 @@ public: // Except in the trivial case described above, we do not know how to divide // Expr by Denominator for the following functions with empty implementation. void visitPtrToAddrExpr(const SCEVPtrToAddrExpr *Numerator) {} - void visitPtrToIntExpr(const SCEVPtrToIntExpr *Numerator) {} void visitTruncateExpr(const SCEVTruncateExpr *Numerator) {} void visitZeroExtendExpr(const SCEVZeroExtendExpr *Numerator) {} void visitSignExtendExpr(const SCEVSignExtendExpr *Numerator) {} diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h index fbf50ee7a0bb..ebee63963c70 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -53,7 +53,6 @@ enum SCEVTypes : unsigned short { scSMinExpr, scSequentialUMinExpr, scPtrToAddr, - scPtrToInt, scUnknown, scCouldNotCompute }; @@ -114,25 +113,11 @@ public: /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const SCEV *S) { - return S->getSCEVType() == scPtrToAddr || S->getSCEVType() == scPtrToInt || - S->getSCEVType() == scTruncate || S->getSCEVType() == scZeroExtend || - S->getSCEVType() == scSignExtend; + return S->getSCEVType() == scPtrToAddr || S->getSCEVType() == scTruncate || + S->getSCEVType() == scZeroExtend || S->getSCEVType() == scSignExtend; } }; -/// This class represents a cast from a pointer to a pointer-sized integer -/// value. -class SCEVPtrToIntExpr : public SCEVCastExpr { - friend class ScalarEvolution; - - SCEVPtrToIntExpr(const FoldingSetNodeIDRef ID, SCEVUse Op, Type *ITy); - -public: - /// Methods for support type inquiry through isa, cast, and dyn_cast: - static bool classof(const SCEV *S) { return S->getSCEVType() == scPtrToInt; } - static bool classof(const SCEVUse *U) { return classof(U->getPointer()); } -}; - /// This class represents a cast from a pointer to a pointer-sized integer /// value, without capturing the provenance of the pointer. class SCEVPtrToAddrExpr : public SCEVCastExpr { @@ -612,8 +597,6 @@ template struct SCEVVisitor { return ((SC *)this)->visitVScale((const SCEVVScale *)S); case scPtrToAddr: return ((SC *)this)->visitPtrToAddrExpr((const SCEVPtrToAddrExpr *)S); - case scPtrToInt: - return ((SC *)this)->visitPtrToIntExpr((const SCEVPtrToIntExpr *)S); case scTruncate: return ((SC *)this)->visitTruncateExpr((const SCEVTruncateExpr *)S); case scZeroExtend: @@ -664,9 +647,6 @@ template struct SCEVUseVisitor { case scPtrToAddr: return ((SC *)this) ->visitPtrToAddrExpr(cast>(S)); - case scPtrToInt: - return ((SC *)this) - ->visitPtrToIntExpr(cast>(S)); case scTruncate: return ((SC *)this) ->visitTruncateExpr(cast>(S)); @@ -748,7 +728,6 @@ public: case scUnknown: continue; case scPtrToAddr: - case scPtrToInt: case scTruncate: case scZeroExtend: case scSignExtend: @@ -842,13 +821,6 @@ public: return Operand == Expr->getOperand() ? Expr : SE.getPtrToAddrExpr(Operand); } - const SCEV *visitPtrToIntExpr(const SCEVPtrToIntExpr *Expr) { - const SCEV *Operand = ((SC *)this)->visit(Expr->getOperand()); - return Operand == Expr->getOperand() - ? Expr - : SE.getPtrToIntExpr(Operand, Expr->getType()); - } - const SCEV *visitTruncateExpr(const SCEVTruncateExpr *Expr) { const SCEV *Operand = ((SC *)this)->visit(Expr->getOperand()); return Operand == Expr->getOperand() diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h b/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h index 5aa54e1d7fb3..d7f1b7af932f 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h +++ b/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h @@ -186,12 +186,6 @@ m_scev_ZExt(const Op0_t &Op0) { return m_scev_Unary(Op0); } -template -inline SCEVUnaryExpr_match -m_scev_PtrToInt(const Op0_t &Op0) { - return SCEVUnaryExpr_match(Op0); -} - template inline SCEVUnaryExpr_match m_scev_PtrToAddr(const Op0_t &Op0) { diff --git a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h index 5d514568b013..570200212309 100644 --- a/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h +++ b/llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h @@ -515,8 +515,6 @@ private: Value *visitPtrToAddrExpr(SCEVUseT S); - Value *visitPtrToIntExpr(SCEVUseT S); - Value *visitTruncateExpr(SCEVUseT S); Value *visitZeroExtendExpr(SCEVUseT S); diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index f31c8c3375c7..b858f18c5174 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -291,9 +291,6 @@ void SCEV::computeAndSetCanonical(ScalarEvolution &SE) { case scPtrToAddr: CanonicalSCEV = SE.getPtrToAddrExpr(CanonOps[0]); return; - case scPtrToInt: - CanonicalSCEV = SE.getPtrToIntExpr(CanonOps[0], getType()); - return; case scTruncate: CanonicalSCEV = SE.getTruncateExpr(CanonOps[0], getType()); return; @@ -355,12 +352,10 @@ void SCEV::print(raw_ostream &OS) const { case scVScale: OS << "vscale"; return; - case scPtrToAddr: - case scPtrToInt: { + case scPtrToAddr: { const SCEVCastExpr *PtrCast = cast(this); const SCEV *Op = PtrCast->getOperand(); - StringRef OpS = getSCEVType() == scPtrToAddr ? "addr" : "int"; - OS << "(ptrto" << OpS << " " << *Op->getType() << " " << *Op << " to " + OS << "(ptrtoaddr " << *Op->getType() << " " << *Op << " to " << *PtrCast->getType() << ")"; return; } @@ -467,7 +462,6 @@ ArrayRef SCEV::operands() const { case scUnknown: return {}; case scPtrToAddr: - case scPtrToInt: case scTruncate: case scZeroExtend: case scSignExtend: @@ -578,13 +572,6 @@ SCEVPtrToAddrExpr::SCEVPtrToAddrExpr(const FoldingSetNodeIDRef ID, "Must be a non-bit-width-changing pointer-to-integer cast!"); } -SCEVPtrToIntExpr::SCEVPtrToIntExpr(const FoldingSetNodeIDRef ID, SCEVUse Op, - Type *ITy) - : SCEVCastExpr(ID, scPtrToInt, Op, ITy) { - assert(getOperand()->getType()->isPointerTy() && getType()->isIntegerTy() && - "Must be a non-bit-width-changing pointer-to-integer cast!"); -} - SCEVIntegralCastExpr::SCEVIntegralCastExpr(const FoldingSetNodeIDRef ID, SCEVTypes SCEVTy, SCEVUse op, Type *ty) @@ -791,7 +778,6 @@ CompareSCEVComplexity(const LoopInfo *const LI, const SCEV *LHS, case scZeroExtend: case scSignExtend: case scPtrToAddr: - case scPtrToInt: case scAddExpr: case scMulExpr: case scUDivExpr: @@ -1173,14 +1159,6 @@ const SCEV *ScalarEvolution::getPtrToAddrExpr(const SCEV *Op) { return IntOp; } -const SCEV *ScalarEvolution::getPtrToIntExpr(const SCEV *Op, Type *Ty) { - assert(Ty->isIntegerTy() && "Target type must be an integer type!"); - - // We don't model ptrtoint in SCEV. Return CouldNotCompute, which will cause - // callers to fall back to SCEVUnknown. - return getCouldNotCompute(); -} - const SCEV *ScalarEvolution::getTruncateExpr(const SCEV *Op, Type *Ty, unsigned Depth) { assert(getTypeSizeInBits(Op->getType()) > getTypeSizeInBits(Ty) && @@ -2224,8 +2202,6 @@ const SCEV *ScalarEvolution::getCastExpr(SCEVTypes Kind, const SCEV *Op, assert(Expr->getType() == Ty && "requested type must match"); return Expr; } - case scPtrToInt: - return getPtrToIntExpr(Op, Ty); default: llvm_unreachable("Not a SCEV cast expression!"); } @@ -4172,8 +4148,6 @@ public: RetVal visitPtrToAddrExpr(const SCEVPtrToAddrExpr *Expr) { return Expr; } - RetVal visitPtrToIntExpr(const SCEVPtrToIntExpr *Expr) { return Expr; } - RetVal visitTruncateExpr(const SCEVTruncateExpr *Expr) { return Expr; } RetVal visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) { return Expr; } @@ -4223,7 +4197,6 @@ static bool scevUnconditionallyPropagatesPoisonFromOperands(SCEVTypes Kind) { case scZeroExtend: case scSignExtend: case scPtrToAddr: - case scPtrToInt: case scAddExpr: case scMulExpr: case scUDivExpr: @@ -6441,7 +6414,6 @@ APInt ScalarEvolution::getConstantMultipleImpl(const SCEV *S, case scConstant: return cast(S)->getAPInt(); case scPtrToAddr: - case scPtrToInt: return getConstantMultiple(cast(S)->getOperand()); case scUDivExpr: case scVScale: @@ -6746,7 +6718,6 @@ ScalarEvolution::getRangeRefIter(const SCEV *S, case scZeroExtend: case scSignExtend: case scPtrToAddr: - case scPtrToInt: case scAddExpr: case scMulExpr: case scUDivExpr: @@ -6869,8 +6840,7 @@ const ConstantRange &ScalarEvolution::getRangeRef( SExt, SignHint, ConservativeResult.intersectWith(X.signExtend(BitWidth), RangeType)); } - case scPtrToAddr: - case scPtrToInt: { + case scPtrToAddr: { const SCEVCastExpr *Cast = cast(S); ConstantRange X = getRangeRef(Cast->getOperand(), SignHint, Depth + 1); return setRange(Cast, SignHint, X); @@ -10190,13 +10160,6 @@ static Constant *BuildConstantFromSCEV(const SCEV *V) { return nullptr; } - case scPtrToInt: { - const SCEVPtrToIntExpr *P2I = cast(V); - if (Constant *CastOp = BuildConstantFromSCEV(P2I->getOperand())) - return ConstantExpr::getPtrToInt(CastOp, P2I->getType()); - - return nullptr; - } case scTruncate: { const SCEVTruncateExpr *ST = cast(V); if (Constant *CastOp = BuildConstantFromSCEV(ST->getOperand())) @@ -10247,7 +10210,6 @@ const SCEV *ScalarEvolution::getWithOperands(const SCEV *S, case scZeroExtend: case scSignExtend: case scPtrToAddr: - case scPtrToInt: return getCastExpr(S->getSCEVType(), NewOps[0], S->getType()); case scAddRecExpr: { auto *AddRec = cast(S); @@ -10332,7 +10294,6 @@ const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) { case scZeroExtend: case scSignExtend: case scPtrToAddr: - case scPtrToInt: case scAddExpr: case scMulExpr: case scUDivExpr: @@ -14545,7 +14506,6 @@ ScalarEvolution::computeLoopDisposition(const SCEV *S, const Loop *L) { case scZeroExtend: case scSignExtend: case scPtrToAddr: - case scPtrToInt: case scAddExpr: case scMulExpr: case scUDivExpr: @@ -14636,7 +14596,6 @@ ScalarEvolution::computeBlockDisposition(const SCEV *S, const BasicBlock *BB) { case scZeroExtend: case scSignExtend: case scPtrToAddr: - case scPtrToInt: case scAddExpr: case scMulExpr: case scUDivExpr: diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 658858ba4fc4..4ba8d55a918b 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -6641,8 +6641,7 @@ struct SCEVDbgValueBuilder { } else if (const SCEVCastExpr *Cast = dyn_cast(S)) { // Assert if a new and unknown SCEVCastEXpr type is encountered. assert((isa(Cast) || isa(Cast) || - isa(Cast) || isa(Cast) || - isa(Cast)) && + isa(Cast) || isa(Cast)) && "Unexpected cast type in SCEV."); Success &= pushCast(Cast, (isa(Cast))); diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 18350f29aa43..22dc1bc8e674 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -460,7 +460,6 @@ const Loop *SCEVExpander::getRelevantLoop(const SCEV *S) { case scZeroExtend: case scSignExtend: case scPtrToAddr: - case scPtrToInt: case scAddExpr: case scMulExpr: case scUDivExpr: @@ -1495,12 +1494,6 @@ Value *SCEVExpander::visitPtrToAddrExpr(SCEVUseT S) { GetOptimalInsertionPointForCastOf(V)); } -Value *SCEVExpander::visitPtrToIntExpr(SCEVUseT S) { - Value *V = expand(S->getOperand()); - return ReuseOrCreateCast(V, S->getType(), CastInst::PtrToInt, - GetOptimalInsertionPointForCastOf(V)); -} - Value *SCEVExpander::visitTruncateExpr(SCEVUseT S) { Type *Ty = S->getType(); @@ -2050,9 +2043,6 @@ template static InstructionCost costAndCollectOperands( case scPtrToAddr: Cost = CastCost(Instruction::PtrToAddr); break; - case scPtrToInt: - Cost = CastCost(Instruction::PtrToInt); - break; case scTruncate: Cost = CastCost(Instruction::Trunc); break; @@ -2188,7 +2178,6 @@ bool SCEVExpander::isHighCostExpansionHelper( } case scTruncate: case scPtrToAddr: - case scPtrToInt: case scZeroExtend: case scSignExtend: { Cost += diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp index 95a4350d5c09..0bcd4dd8aba5 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp @@ -908,7 +908,6 @@ VPValue *VPSCEVExpander::tryToExpand(const SCEV *S) { case scTruncate: case scZeroExtend: case scSignExtend: - case scPtrToInt: case scPtrToAddr: { auto *Cast = cast(S); VPValue *Op = tryToExpand(Cast->getOperand()); @@ -925,9 +924,6 @@ VPValue *VPSCEVExpander::tryToExpand(const SCEV *S) { case scSignExtend: Opcode = Instruction::SExt; break; - case scPtrToInt: - Opcode = Instruction::PtrToInt; - break; case scPtrToAddr: Opcode = Instruction::PtrToAddr; break; diff --git a/polly/include/polly/Support/SCEVAffinator.h b/polly/include/polly/Support/SCEVAffinator.h index 8fe1ed44e16d..5e149b50b189 100644 --- a/polly/include/polly/Support/SCEVAffinator.h +++ b/polly/include/polly/Support/SCEVAffinator.h @@ -116,7 +116,6 @@ private: PWACtx visitConstant(const llvm::SCEVConstant *E); PWACtx visitVScale(const llvm::SCEVVScale *E); PWACtx visitPtrToAddrExpr(const llvm::SCEVPtrToAddrExpr *E); - PWACtx visitPtrToIntExpr(const llvm::SCEVPtrToIntExpr *E); PWACtx visitTruncateExpr(const llvm::SCEVTruncateExpr *E); PWACtx visitZeroExtendExpr(const llvm::SCEVZeroExtendExpr *E); PWACtx visitSignExtendExpr(const llvm::SCEVSignExtendExpr *E); diff --git a/polly/lib/Support/SCEVAffinator.cpp b/polly/lib/Support/SCEVAffinator.cpp index 03859d4df064..07155486bd1e 100644 --- a/polly/lib/Support/SCEVAffinator.cpp +++ b/polly/lib/Support/SCEVAffinator.cpp @@ -277,10 +277,6 @@ PWACtx SCEVAffinator::visitPtrToAddrExpr(const SCEVPtrToAddrExpr *Expr) { return visit(Expr->getOperand(0)); } -PWACtx SCEVAffinator::visitPtrToIntExpr(const SCEVPtrToIntExpr *Expr) { - return visit(Expr->getOperand(0)); -} - PWACtx SCEVAffinator::visitTruncateExpr(const SCEVTruncateExpr *Expr) { // Truncate operations are basically modulo operations, thus we can // model them that way. However, for large types we assume the operand diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp index 291853cde830..ad62406d85e7 100644 --- a/polly/lib/Support/SCEVValidator.cpp +++ b/polly/lib/Support/SCEVValidator.cpp @@ -160,10 +160,6 @@ public: return visit(Expr->getOperand()); } - ValidatorResult visitPtrToIntExpr(const SCEVPtrToIntExpr *Expr) { - return visit(Expr->getOperand()); - } - ValidatorResult visitTruncateExpr(const SCEVTruncateExpr *Expr) { return visitZeroExtendOrTruncateExpr(Expr, Expr->getOperand()); } diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp index e1e7befdfad9..20473c231341 100644 --- a/polly/lib/Support/ScopHelper.cpp +++ b/polly/lib/Support/ScopHelper.cpp @@ -368,9 +368,6 @@ private: const SCEV *visitPtrToAddrExpr(const SCEVPtrToAddrExpr *E) { return GenSE.getPtrToAddrExpr(visit(E->getOperand())); } - const SCEV *visitPtrToIntExpr(const SCEVPtrToIntExpr *E) { - return GenSE.getPtrToIntExpr(visit(E->getOperand()), E->getType()); - } const SCEV *visitTruncateExpr(const SCEVTruncateExpr *E) { return GenSE.getTruncateExpr(visit(E->getOperand()), E->getType()); }