diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h index 41df158f5de7c..0327dc1b9fb07 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -74,25 +74,23 @@ class Type; /// This is the base class for unary cast operator classes. class SCEVCastExpr : public SCEV { protected: - const SCEV *const Op; + std::array Operands; Type *Ty; SCEVCastExpr(const FoldingSetNodeIDRef ID, unsigned SCEVTy, const SCEV *op, Type *ty); public: - const SCEV *getOperand() const { return Op; } + const SCEV *getOperand() const { return Operands[0]; } const SCEV *getOperand(unsigned i) const { assert(i == 0 && "Operand index out of range!"); - return Op; + return Operands[0]; } using op_iterator = const SCEV *const *; using op_range = iterator_range; - op_iterator op_begin() const { return &Op; } - op_iterator op_end() const { return &Op + 1; } op_range operands() const { - return make_range(op_begin(), op_end()); + return make_range(Operands.begin(), Operands.end()); } size_t getNumOperands() const { return 1; } Type *getType() const { return Ty; } diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 75d2d39e7114b..9c9b9c53c939f 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -447,26 +447,28 @@ ScalarEvolution::getConstant(Type *Ty, uint64_t V, bool isSigned) { SCEVCastExpr::SCEVCastExpr(const FoldingSetNodeIDRef ID, unsigned SCEVTy, const SCEV *op, Type *ty) - : SCEV(ID, SCEVTy, computeExpressionSize(op)), Op(op), Ty(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) { - assert(Op->getType()->isIntOrPtrTy() && Ty->isIntOrPtrTy() && + 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) { - assert(Op->getType()->isIntOrPtrTy() && Ty->isIntOrPtrTy() && + 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) { - assert(Op->getType()->isIntOrPtrTy() && Ty->isIntOrPtrTy() && + assert(getOperand()->getType()->isIntOrPtrTy() && Ty->isIntOrPtrTy() && "Cannot sign extend non-integer value!"); }