[llvm] [polly] [SCEV] Refactor SCEV flags, in preparation to extend (NFC) (PR #225179)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 12:54:37 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-vectorizers
@llvm/pr-subscribers-llvm-analysis
Author: Ramkumar Ramachandra (artagnon)
<details>
<summary>Changes</summary>
In preparation to extend the flags that ScalarEvolution can represent, rename SCEV::NoWrapFlags to the more general SCEVFlags. This is a large refactoring non-functional change.
See also: #<!-- -->225065
---
Patch is 146.95 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/225179.diff
23 Files Affected:
- (modified) llvm/include/llvm/Analysis/IVDescriptors.h (+4-5)
- (modified) llvm/include/llvm/Analysis/ScalarEvolution.h (+57-71)
- (modified) llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h (+22-29)
- (modified) llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h (+12-14)
- (modified) llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h (+2-2)
- (modified) llvm/lib/Analysis/IVDescriptors.cpp (+1-1)
- (modified) llvm/lib/Analysis/LoopAccessAnalysis.cpp (+1-1)
- (modified) llvm/lib/Analysis/LoopCacheAnalysis.cpp (+3-3)
- (modified) llvm/lib/Analysis/ScalarEvolution.cpp (+236-247)
- (modified) llvm/lib/Analysis/ScalarEvolutionDivision.cpp (+4-4)
- (modified) llvm/lib/Analysis/ScalarEvolutionNormalization.cpp (+2-2)
- (modified) llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp (+5-5)
- (modified) llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp (+22-23)
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp (+1-1)
- (modified) llvm/lib/Transforms/Vectorize/VPlanUtils.cpp (+7-7)
- (modified) llvm/unittests/Analysis/IVDescriptorsTest.cpp (+1-1)
- (modified) llvm/unittests/Analysis/ScalarEvolutionTest.cpp (+62-65)
- (modified) llvm/unittests/Transforms/Utils/ScalarEvolutionExpanderTest.cpp (+4-4)
- (modified) polly/lib/Analysis/ScopInfo.cpp (+1-1)
- (modified) polly/lib/CodeGen/IslNodeBuilder.cpp (+3-3)
- (modified) polly/lib/Support/SCEVAffinator.cpp (+4-4)
- (modified) polly/lib/Support/SCEVValidator.cpp (+4-5)
- (modified) polly/lib/Support/ScopHelper.cpp (+1-1)
``````````diff
diff --git a/llvm/include/llvm/Analysis/IVDescriptors.h b/llvm/include/llvm/Analysis/IVDescriptors.h
index 7548ea1c871fe..08bde23b8f328 100644
--- a/llvm/include/llvm/Analysis/IVDescriptors.h
+++ b/llvm/include/llvm/Analysis/IVDescriptors.h
@@ -30,7 +30,7 @@ class ScalarEvolution;
class SCEV;
class SCEVPredicate;
class StoreInst;
-enum class SCEVNoWrapFlags;
+enum class SCEVFlags;
/// These are the kinds of recurrences that we support.
enum class RecurKind {
@@ -515,13 +515,12 @@ class ConditionalInductionDescriptor {
const SCEV *getStepSCEV() const { return StepSCEV; }
/// Returns the SCEV no-wrap flags that apply to StepInst.
- SCEVNoWrapFlags getSCEVNoWrapFlags() const { return NoWrapFlags; }
+ SCEVFlags getSCEVNoWrapFlags() const { return NoWrapFlags; }
private:
ConditionalInductionDescriptor(PHINode *HeaderPHI, PHINode *BackedgePHI,
Instruction *StepInst, const SCEV *StartSCEV,
- const SCEV *StepSCEV,
- SCEVNoWrapFlags NoWrapFlags)
+ const SCEV *StepSCEV, SCEVFlags NoWrapFlags)
: HeaderPHI(HeaderPHI), BackedgePHI(BackedgePHI), StepInst(StepInst),
StartSCEV(StartSCEV), StepSCEV(StepSCEV), NoWrapFlags(NoWrapFlags) {}
@@ -543,7 +542,7 @@ class ConditionalInductionDescriptor {
const SCEV *StepSCEV = nullptr;
/// The SCEV no-wrap flags that apply to StepInst.
- SCEVNoWrapFlags NoWrapFlags{};
+ SCEVFlags NoWrapFlags{};
};
} // end namespace llvm
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index 8d423c57824e7..2ba0ae30f5ce4 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -107,20 +107,20 @@ LLVM_ABI extern bool VerifySCEV;
/// can trap) can be defined per these rules in regions where it would trap
/// at runtime. A SCEV being defined does not require the existence of any
/// instruction within the defined scope.
-enum class SCEVNoWrapFlags {
- FlagAnyWrap = 0, // No guarantee.
+enum class SCEVFlags {
+ FlagAny = 0, // No guarantee.
FlagNW = (1 << 0), // No self-wrap.
FlagNUW = (1 << 1), // No unsigned wrap.
FlagNSW = (1 << 2), // No signed wrap.
- NoWrapMask = (1 << 3) - 1,
- LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/NoWrapMask)
+ NoFlagMask = (1 << 3) - 1,
+ LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/NoFlagMask)
};
class SCEV;
template <typename SCEVPtrT = const SCEV *>
-struct SCEVUseT : private PointerIntPair<SCEVPtrT, 2> {
- using Base = PointerIntPair<SCEVPtrT, 2>;
+struct SCEVUseT : private PointerIntPair<SCEVPtrT, 3> {
+ using Base = PointerIntPair<SCEVPtrT, 3>;
using Base::getOpaqueValue;
using Base::getPointer;
@@ -130,11 +130,11 @@ struct SCEVUseT : private PointerIntPair<SCEVPtrT, 2> {
/// must be an expression supporting flags. Only flags not already present on
/// \p S are added. Note that the expression may gain flags also part of the
/// SCEVUse later, via settNoWrapFlags.
- SCEVUseT(SCEVPtrT S, SCEVNoWrapFlags Flags);
+ SCEVUseT(SCEVPtrT S, SCEVFlags Flags);
template <typename OtherPtrT, typename = std::enable_if_t<
std::is_convertible_v<OtherPtrT, SCEVPtrT>>>
SCEVUseT(const SCEVUseT<OtherPtrT> &Other)
- : SCEVUseT(Other.getPointer(), Other.getUseNoWrapFlags()) {}
+ : SCEVUseT(Other.getPointer(), Other.getUseFlags()) {}
operator SCEVPtrT() const { return getPointer(); }
SCEVPtrT operator->() const { return getPointer(); }
@@ -151,16 +151,14 @@ struct SCEVUseT : private PointerIntPair<SCEVPtrT, 2> {
/// Return the no-wrap flags for this SCEVUse, which is the union of the
/// use-specific flags and the underlying SCEV's flags, masked by \p Mask.
- SCEVNoWrapFlags
- getNoWrapFlags(SCEVNoWrapFlags Mask = SCEVNoWrapFlags::NoWrapMask) const;
+ SCEVFlags getFlags(SCEVFlags Mask = SCEVFlags::NoFlagMask) const;
/// Return only the use-specific no-wrap flags (NUW/NSW) without the
/// underlying SCEV's flags.
- SCEVNoWrapFlags getUseNoWrapFlags() const {
- SCEVNoWrapFlags UseFlags =
- static_cast<SCEVNoWrapFlags>(Base::getInt() << 1);
- if (any(UseFlags & (SCEVNoWrapFlags::FlagNUW | SCEVNoWrapFlags::FlagNSW)))
- UseFlags |= SCEVNoWrapFlags::FlagNW;
+ SCEVFlags getUseFlags() const {
+ SCEVFlags UseFlags = static_cast<SCEVFlags>(Base::getInt() << 1);
+ if (any(UseFlags & (SCEVFlags::FlagNUW | SCEVFlags::FlagNSW)))
+ UseFlags |= SCEVFlags::FlagNW;
return UseFlags;
}
@@ -193,18 +191,14 @@ template <typename SCEVPtrT> SCEVUseT(SCEVPtrT) -> SCEVUseT<SCEVPtrT>;
using SCEVUse = SCEVUseT<const SCEV *>;
/// The no-wrap flags to apply when creating a SCEV expression, to the
-/// expression and use respectively.
-struct SCEVFlags {
- /// Flags applied directly to a SCEV expression, must be valid wherever the
- /// expression is valid.
- SCEVNoWrapFlags ExprFlags;
-
- /// Flags only applied to a SCEVUse.
- SCEVNoWrapFlags UseFlags;
-
- constexpr SCEVFlags(SCEVNoWrapFlags ExprFlags = SCEVNoWrapFlags::FlagAnyWrap,
- SCEVNoWrapFlags UseFlags = SCEVNoWrapFlags::FlagAnyWrap)
- : ExprFlags(ExprFlags), UseFlags(UseFlags) {}
+/// expression and use: the first component of the pair is applied directly to a
+/// SCEV expression, and the second component is only applied to a SCEVUse.
+struct SCEVFlagInfo : public std::pair<SCEVFlags, SCEVFlags> {
+ using BaseT = std::pair<SCEVFlags, SCEVFlags>;
+
+ constexpr SCEVFlagInfo(SCEVFlags ExprFlags = SCEVFlags::FlagAny,
+ SCEVFlags UseFlags = SCEVFlags::FlagAny)
+ : BaseT(ExprFlags, UseFlags) {}
};
/// Provide PointerLikeTypeTraits for SCEVUse, so it can be used with
@@ -249,7 +243,7 @@ struct CastInfo<SCEVUseT<ToSCEVPtrT>, SCEVUse,
static bool isPossible(const SCEVUse &U) { return isa<To>(U.getPointer()); }
static CastReturnType doCast(const SCEVUse &U) {
- return CastReturnType(cast<To>(U.getPointer()), U.getUseNoWrapFlags());
+ return CastReturnType(cast<To>(U.getPointer()), U.getUseFlags());
}
static CastReturnType castFailed() { return CastReturnType(nullptr); }
static CastReturnType doCastIfPossible(const SCEVUse &U) {
@@ -293,12 +287,11 @@ class SCEV : public FoldingSetNode {
Type *const Ty;
public:
- using NoWrapFlags = SCEVNoWrapFlags;
- static constexpr auto FlagAnyWrap = SCEVNoWrapFlags::FlagAnyWrap;
- static constexpr auto FlagNW = SCEVNoWrapFlags::FlagNW;
- static constexpr auto FlagNUW = SCEVNoWrapFlags::FlagNUW;
- static constexpr auto FlagNSW = SCEVNoWrapFlags::FlagNSW;
- static constexpr auto NoWrapMask = SCEVNoWrapFlags::NoWrapMask;
+ static constexpr auto FlagAny = SCEVFlags::FlagAny;
+ static constexpr auto FlagNW = SCEVFlags::FlagNW;
+ static constexpr auto FlagNUW = SCEVFlags::FlagNUW;
+ static constexpr auto FlagNSW = SCEVFlags::FlagNSW;
+ static constexpr auto NoFlagMask = SCEVFlags::NoFlagMask;
explicit SCEV(const FoldingSetNodeIDRef ID, SCEVTypes SCEVTy,
unsigned short ExpressionSize, Type *Ty)
@@ -647,20 +640,17 @@ class ScalarEvolution {
/// Convenient NoWrapFlags manipulation. TODO: Replace with & operator of
/// enum class.
- [[nodiscard]] static SCEV::NoWrapFlags maskFlags(SCEV::NoWrapFlags Flags,
- SCEV::NoWrapFlags Mask) {
+ [[nodiscard]] static SCEVFlags maskFlags(SCEVFlags Flags, SCEVFlags Mask) {
return Flags & Mask;
}
- [[nodiscard]] static SCEV::NoWrapFlags setFlags(SCEV::NoWrapFlags Flags,
- SCEV::NoWrapFlags OnFlags) {
+ [[nodiscard]] static SCEVFlags setFlags(SCEVFlags Flags, SCEVFlags OnFlags) {
return Flags | OnFlags;
}
- [[nodiscard]] static SCEV::NoWrapFlags
- clearFlags(SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OffFlags) {
+ [[nodiscard]] static SCEVFlags clearFlags(SCEVFlags Flags,
+ SCEVFlags OffFlags) {
return Flags & ~OffFlags;
}
- [[nodiscard]] static bool hasFlags(SCEV::NoWrapFlags Flags,
- SCEV::NoWrapFlags TestFlags) {
+ [[nodiscard]] static bool hasFlags(SCEVFlags Flags, SCEVFlags TestFlags) {
return TestFlags == maskFlags(Flags, TestFlags);
};
@@ -722,7 +712,7 @@ class ScalarEvolution {
/// Does not mutate the original instruction. Returns std::nullopt if it could
/// not deduce more precise flags than the instruction already has, otherwise
/// returns proven flags.
- LLVM_ABI std::optional<SCEV::NoWrapFlags>
+ LLVM_ABI std::optional<SCEVFlags>
getStrengthenedNoWrapFlagsFromBinOp(const OverflowingBinaryOperator *OBO);
/// Notify this ScalarEvolution that \p User directly uses SCEVs in \p Ops.
@@ -750,9 +740,8 @@ class ScalarEvolution {
LLVM_ABI const SCEV *getTruncateExpr(SCEVUse Op, Type *Ty,
unsigned Depth = 0);
LLVM_ABI const SCEV *getVScale(Type *Ty);
- LLVM_ABI const SCEV *
- getElementCount(Type *Ty, ElementCount EC,
- SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap);
+ LLVM_ABI const SCEV *getElementCount(Type *Ty, ElementCount EC,
+ SCEVFlags Flags = SCEV::FlagAny);
LLVM_ABI const SCEV *getZeroExtendExpr(SCEVUse Op, Type *Ty,
unsigned Depth = 0);
LLVM_ABI const SCEV *getZeroExtendExprImpl(SCEVUse Op, Type *Ty,
@@ -765,26 +754,26 @@ class ScalarEvolution {
LLVM_ABI const SCEV *getAnyExtendExpr(SCEVUse Op, Type *Ty);
LLVM_ABI SCEVUse getAddExpr(SmallVectorImpl<SCEVUse> &Ops,
- SCEVFlags Flags = {}, unsigned Depth = 0);
- SCEVUse getAddExpr(SCEVUse LHS, SCEVUse RHS, SCEVFlags Flags = {},
+ SCEVFlagInfo Flags = {}, unsigned Depth = 0);
+ SCEVUse getAddExpr(SCEVUse LHS, SCEVUse RHS, SCEVFlagInfo Flags = {},
unsigned Depth = 0) {
SmallVector<SCEVUse, 2> Ops = {LHS, RHS};
return getAddExpr(Ops, Flags, Depth);
}
SCEVUse getAddExpr(SCEVUse Op0, SCEVUse Op1, SCEVUse Op2,
- SCEVFlags Flags = {}, unsigned Depth = 0) {
+ SCEVFlagInfo Flags = {}, unsigned Depth = 0) {
SmallVector<SCEVUse, 3> Ops = {Op0, Op1, Op2};
return getAddExpr(Ops, Flags, Depth);
}
LLVM_ABI SCEVUse getMulExpr(SmallVectorImpl<SCEVUse> &Ops,
- SCEVFlags Flags = {}, unsigned Depth = 0);
- SCEVUse getMulExpr(SCEVUse LHS, SCEVUse RHS, SCEVFlags Flags = {},
+ SCEVFlagInfo Flags = {}, unsigned Depth = 0);
+ SCEVUse getMulExpr(SCEVUse LHS, SCEVUse RHS, SCEVFlagInfo Flags = {},
unsigned Depth = 0) {
SmallVector<SCEVUse, 2> Ops = {LHS, RHS};
return getMulExpr(Ops, Flags, Depth);
}
SCEVUse getMulExpr(SCEVUse Op0, SCEVUse Op1, SCEVUse Op2,
- SCEVFlags Flags = {}, unsigned Depth = 0) {
+ SCEVFlagInfo Flags = {}, unsigned Depth = 0) {
SmallVector<SCEVUse, 3> Ops = {Op0, Op1, Op2};
return getMulExpr(Ops, Flags, Depth);
}
@@ -792,11 +781,11 @@ class ScalarEvolution {
LLVM_ABI const SCEV *getUDivExactExpr(SCEVUse LHS, SCEVUse RHS);
LLVM_ABI const SCEV *getURemExpr(SCEVUse LHS, SCEVUse RHS);
LLVM_ABI SCEVUse getAddRecExpr(SCEVUse Start, SCEVUse Step, const Loop *L,
- SCEVFlags Flags);
+ SCEVFlagInfo Flags);
LLVM_ABI SCEVUse getAddRecExpr(SmallVectorImpl<SCEVUse> &Operands,
- const Loop *L, SCEVFlags Flags);
+ const Loop *L, SCEVFlagInfo Flags);
SCEVUse getAddRecExpr(const SmallVectorImpl<SCEVUse> &Operands, const Loop *L,
- SCEVFlags Flags) {
+ SCEVFlagInfo Flags) {
SmallVector<SCEVUse, 4> NewOp(Operands.begin(), Operands.end());
return getAddRecExpr(NewOp, L, Flags);
}
@@ -869,8 +858,8 @@ class ScalarEvolution {
unsigned FieldNo);
/// Return the SCEV object corresponding to -V.
- LLVM_ABI const SCEV *
- getNegativeSCEV(const SCEV *V, SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap);
+ LLVM_ABI const SCEV *getNegativeSCEV(const SCEV *V,
+ SCEVFlags Flags = SCEV::FlagAny);
/// Return the SCEV object corresponding to ~V.
LLVM_ABI const SCEV *getNotSCEV(const SCEV *V);
@@ -883,7 +872,7 @@ class ScalarEvolution {
/// explicitly convert the arguments using getPtrToAddrExpr(), for pointer
/// types that support it.
LLVM_ABI const SCEV *getMinusSCEV(SCEVUse LHS, SCEVUse RHS,
- SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
+ SCEVFlags Flags = SCEV::FlagAny,
unsigned Depth = 0);
/// Compute ceil(N / D). N and D are treated as unsigned values.
@@ -1579,7 +1568,7 @@ class ScalarEvolution {
/// Update no-wrap flags of an AddRec. This may drop the cached info about
/// this AddRec (such as range info) in case if new flags may potentially
/// sharpen it.
- LLVM_ABI void setNoWrapFlags(SCEVAddRecExpr *AddRec, SCEV::NoWrapFlags Flags);
+ LLVM_ABI void setFlags(SCEVAddRecExpr *AddRec, SCEVFlags Flags);
class LoopGuards {
DenseMap<const SCEV *, const SCEV *> RewriteMap;
@@ -2023,7 +2012,7 @@ class ScalarEvolution {
/// Determines the range for the affine SCEVAddRecExpr {\p Start,+,\p Step},
/// and whether it may wrap. Helper for \c getRange.
- std::pair<ConstantRange, SCEV::NoWrapFlags>
+ std::pair<ConstantRange, SCEVFlags>
getRangeForAffineAR(const SCEV *Start, const SCEV *Step,
const APInt &MaxBECount);
/// If \p S is a SCEVConstant, return the wrapped constant or nullptr
@@ -2406,8 +2395,7 @@ class ScalarEvolution {
SCEVUse RHS);
/// Try to match the Expr as "(L + R)<Flags>".
- bool splitBinaryAdd(SCEVUse Expr, SCEVUse &L, SCEVUse &R,
- SCEV::NoWrapFlags &Flags);
+ bool splitBinaryAdd(SCEVUse Expr, SCEVUse &L, SCEVUse &R, SCEVFlags &Flags);
/// Forget predicated/non-predicated backedge taken counts for the given loop.
void forgetBackedgeTakenCounts(const Loop *L, bool Predicated);
@@ -2448,11 +2436,11 @@ class ScalarEvolution {
/// Try to prove NSW on \p AR by proving facts about conditions known on
/// entry and backedge.
- SCEV::NoWrapFlags proveNoSignedWrapViaInduction(const SCEVAddRecExpr *AR);
+ SCEVFlags proveNoSignedWrapViaInduction(const SCEVAddRecExpr *AR);
/// Try to prove NUW on \p AR by proving facts about conditions known on
/// entry and backedge.
- SCEV::NoWrapFlags proveNoUnsignedWrapViaInduction(const SCEVAddRecExpr *AR);
+ SCEVFlags proveNoUnsignedWrapViaInduction(const SCEVAddRecExpr *AR);
std::optional<MonotonicPredicateType>
getMonotonicPredicateTypeImpl(const SCEVAddRecExpr *LHS,
@@ -2461,7 +2449,7 @@ class ScalarEvolution {
/// Return SCEV no-wrap flags that can be proven based on reasoning about
/// how poison produced from no-wrap flags on this value (e.g. a nuw add)
/// would trigger undefined behavior on overflow.
- SCEV::NoWrapFlags getNoWrapFlagsFromUB(const Value *V);
+ SCEVFlags getNoWrapFlagsFromUB(const Value *V);
/// Return a scope which provides an upper bound on the defining scope of
/// 'S'. Specifically, return the first instruction in said bounding scope.
@@ -2560,16 +2548,14 @@ class ScalarEvolution {
bool Invert = false);
/// Get add expr already created or create a new one.
- const SCEV *getOrCreateAddExpr(ArrayRef<SCEVUse> Ops,
- SCEV::NoWrapFlags Flags);
+ const SCEV *getOrCreateAddExpr(ArrayRef<SCEVUse> Ops, SCEVFlags Flags);
/// Get mul expr already created or create a new one.
- const SCEV *getOrCreateMulExpr(ArrayRef<SCEVUse> Ops,
- SCEV::NoWrapFlags Flags);
+ const SCEV *getOrCreateMulExpr(ArrayRef<SCEVUse> Ops, SCEVFlags Flags);
// Get addrec expr already created or create a new one.
const SCEV *getOrCreateAddRecExpr(ArrayRef<SCEVUse> Ops, const Loop *L,
- SCEV::NoWrapFlags Flags);
+ SCEVFlags Flags);
// Get UDiv expression already created or create a new one.
const SCEV *getOrCreateUDivExpr(SCEVUse LHS, SCEVUse RHS);
@@ -2812,7 +2798,7 @@ template <> inline const SCEV *SCEVUseT<const SCEV *>::getCanonical() const {
template <typename SCEVPtrT>
void SCEVUseT<SCEVPtrT>::print(raw_ostream &OS) const {
getPointer()->print(OS);
- SCEV::NoWrapFlags Flags = getUseNoWrapFlags();
+ SCEVFlags Flags = getUseFlags();
if (any(Flags & SCEV::FlagNUW))
OS << "<u nuw>";
if (any(Flags & SCEV::FlagNSW))
diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
index ace050bd2c2c1..ac1e194968f42 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
@@ -210,19 +210,15 @@ class SCEVNAryExpr : public SCEV {
ArrayRef<SCEVUse> operands() const { return ArrayRef(Operands, NumOperands); }
- NoWrapFlags getNoWrapFlags(NoWrapFlags Mask = NoWrapMask) const {
- return static_cast<NoWrapFlags>(SubclassData) & Mask;
+ SCEVFlags getFlags(SCEVFlags Mask = NoFlagMask) const {
+ return static_cast<SCEVFlags>(SubclassData) & Mask;
}
- bool hasNoUnsignedWrap() const {
- return getNoWrapFlags(FlagNUW) != FlagAnyWrap;
- }
+ bool hasNoUnsignedWrap() const { return getFlags(FlagNUW) != FlagAny; }
- bool hasNoSignedWrap() const {
- return getNoWrapFlags(FlagNSW) != FlagAnyWrap;
- }
+ bool hasNoSignedWrap() const { return getFlags(FlagNSW) != FlagAny; }
- bool hasNoSelfWrap() const { return getNoWrapFlags(FlagNW) != FlagAnyWrap; }
+ bool hasNoSelfWrap() const { return getFlags(FlagNW) != FlagAny; }
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const SCEV *S) {
@@ -251,7 +247,7 @@ class SCEVCommutativeExpr : public SCEVNAryExpr {
}
/// Set flags for a non-recurrence without clearing previously set flags.
- void setNoWrapFlags(NoWrapFlags Flags) {
+ void setFlags(SCEVFlags Flags) {
SubclassData |= static_cast<unsigned short>(Flags);
}
};
@@ -350,7 +346,7 @@ class SCEVAddRecExpr : public SCEVNAryExpr {
if (isAffine())
return getOperand(1);
return SE.getAddRecExpr(SmallVector<SCEVUse, 3>(operands().drop_front()),
- getLoop(), FlagAnyWrap);
+ getLoop(), FlagAny);
}
/// Return true if this represents an expression A + B*x where A
@@ -369,7 +365,7 @@ class SCEVAddRecExpr : public SCEVNAryExpr {
/// Set flags for a recurrence without clearing any previously set flags.
/// For AddRec, either NUW or NSW implies NW. Keep track of this fact here
/// to make it easier to propagate flags.
- void setNoWrapFlags(NoWrapFlags Flags) {
+ void setFlags(SCEVFlags Flags) {
if (any(Flags & (FlagNUW | FlagNSW)))
Flags = ScalarEvolution::setFlags(Flags, FlagNW);
SubclassData |= static_cast<unsigned short>(Flags);
@@ -384,8 +380,7 @@ class SCEVAddRecExpr : public SCEVNAryExpr {
/// number. Takes an explicit list of operands to represent an AddRec.
LLVM_ABI static SCEVUse
evaluateAtIteration(ArrayRef<SCEVUse> Operands, const SCEV *It,
- ScalarEvolution &SE,
- SCEV::NoWrapFlags UseFlags = SCEV::FlagAnyWrap);
+ ScalarEvolution &SE, SCEVFlags UseFlags = SCEV::FlagAny);
/// Return the value of this recurrences when its loop exits, i.e. its value
/// at the loop's exact backedge-taken count, or SCEVCouldNotCompute if that
@@ -427,7 +422,7 @@ class SCEVMinMaxExpr : public SCEVCommutativeExpr {
: SCEVCommutativeExpr(ID, T, O, N, O[0]->getType()) {
assert(isMinMaxType(T));
// Min and max never overflow
- setNoWrapFlags(FlagNUW | FlagNSW);
+ setFlags(FlagNUW | FlagNSW);
}
public:
@@ -511,7 +506,7 @@ class SCEVSequentialMinMaxExpr : public SCEVNAryEx...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/225179
More information about the llvm-commits
mailing list