[SCEV] Remove ptrtoint expression (NFC). (#212038)
Follow-up to https://github.com/llvm/llvm-project/pull/180244 to remove the now unused SCEVPtrToIntExpr. PR: https://github.com/llvm/llvm-project/pull/212038
This commit is contained in:
parent
39eb2a11a2
commit
814a883c3c
13 changed files with 6 additions and 113 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {}
|
||||
|
|
|
|||
|
|
@ -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 <typename SC, typename RetVal = void> 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 <typename SC, typename RetVal = void> struct SCEVUseVisitor {
|
|||
case scPtrToAddr:
|
||||
return ((SC *)this)
|
||||
->visitPtrToAddrExpr(cast<SCEVUseT<const SCEVPtrToAddrExpr *>>(S));
|
||||
case scPtrToInt:
|
||||
return ((SC *)this)
|
||||
->visitPtrToIntExpr(cast<SCEVUseT<const SCEVPtrToIntExpr *>>(S));
|
||||
case scTruncate:
|
||||
return ((SC *)this)
|
||||
->visitTruncateExpr(cast<SCEVUseT<const SCEVTruncateExpr *>>(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()
|
||||
|
|
|
|||
|
|
@ -186,12 +186,6 @@ m_scev_ZExt(const Op0_t &Op0) {
|
|||
return m_scev_Unary<SCEVZeroExtendExpr>(Op0);
|
||||
}
|
||||
|
||||
template <typename Op0_t>
|
||||
inline SCEVUnaryExpr_match<SCEVPtrToIntExpr, Op0_t>
|
||||
m_scev_PtrToInt(const Op0_t &Op0) {
|
||||
return SCEVUnaryExpr_match<SCEVPtrToIntExpr, Op0_t>(Op0);
|
||||
}
|
||||
|
||||
template <typename Op0_t>
|
||||
inline SCEVUnaryExpr_match<SCEVPtrToAddrExpr, Op0_t>
|
||||
m_scev_PtrToAddr(const Op0_t &Op0) {
|
||||
|
|
|
|||
|
|
@ -515,8 +515,6 @@ private:
|
|||
|
||||
Value *visitPtrToAddrExpr(SCEVUseT<const SCEVPtrToAddrExpr *> S);
|
||||
|
||||
Value *visitPtrToIntExpr(SCEVUseT<const SCEVPtrToIntExpr *> S);
|
||||
|
||||
Value *visitTruncateExpr(SCEVUseT<const SCEVTruncateExpr *> S);
|
||||
|
||||
Value *visitZeroExtendExpr(SCEVUseT<const SCEVZeroExtendExpr *> S);
|
||||
|
|
|
|||
|
|
@ -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<SCEVCastExpr>(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<SCEVUse> 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<SCEVConstant>(S)->getAPInt();
|
||||
case scPtrToAddr:
|
||||
case scPtrToInt:
|
||||
return getConstantMultiple(cast<SCEVCastExpr>(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<SCEVCastExpr>(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<SCEVPtrToIntExpr>(V);
|
||||
if (Constant *CastOp = BuildConstantFromSCEV(P2I->getOperand()))
|
||||
return ConstantExpr::getPtrToInt(CastOp, P2I->getType());
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
case scTruncate: {
|
||||
const SCEVTruncateExpr *ST = cast<SCEVTruncateExpr>(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<SCEVAddRecExpr>(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:
|
||||
|
|
|
|||
|
|
@ -6641,8 +6641,7 @@ struct SCEVDbgValueBuilder {
|
|||
} else if (const SCEVCastExpr *Cast = dyn_cast<SCEVCastExpr>(S)) {
|
||||
// Assert if a new and unknown SCEVCastEXpr type is encountered.
|
||||
assert((isa<SCEVZeroExtendExpr>(Cast) || isa<SCEVTruncateExpr>(Cast) ||
|
||||
isa<SCEVPtrToIntExpr>(Cast) || isa<SCEVPtrToAddrExpr>(Cast) ||
|
||||
isa<SCEVSignExtendExpr>(Cast)) &&
|
||||
isa<SCEVPtrToAddrExpr>(Cast) || isa<SCEVSignExtendExpr>(Cast)) &&
|
||||
"Unexpected cast type in SCEV.");
|
||||
Success &= pushCast(Cast, (isa<SCEVSignExtendExpr>(Cast)));
|
||||
|
||||
|
|
|
|||
|
|
@ -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<const SCEVPtrToAddrExpr *> S) {
|
|||
GetOptimalInsertionPointForCastOf(V));
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitPtrToIntExpr(SCEVUseT<const SCEVPtrToIntExpr *> S) {
|
||||
Value *V = expand(S->getOperand());
|
||||
return ReuseOrCreateCast(V, S->getType(), CastInst::PtrToInt,
|
||||
GetOptimalInsertionPointForCastOf(V));
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitTruncateExpr(SCEVUseT<const SCEVTruncateExpr *> S) {
|
||||
Type *Ty = S->getType();
|
||||
|
||||
|
|
@ -2050,9 +2043,6 @@ template<typename T> 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 +=
|
||||
|
|
|
|||
|
|
@ -908,7 +908,6 @@ VPValue *VPSCEVExpander::tryToExpand(const SCEV *S) {
|
|||
case scTruncate:
|
||||
case scZeroExtend:
|
||||
case scSignExtend:
|
||||
case scPtrToInt:
|
||||
case scPtrToAddr: {
|
||||
auto *Cast = cast<SCEVCastExpr>(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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue