[llvm] [Local] Move OverflowTracking to Local.h, move logic to helpers (NFC) (PR #140403)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Sun May 18 08:43:30 PDT 2025
================
@@ -556,6 +556,27 @@ Value *invertCondition(Value *Condition);
/// function, explicitly materialize the maximal set in the IR.
bool inferAttributesFromOthers(Function &F);
+//===----------------------------------------------------------------------===//
+// Helpers to track and update flags on instructions.
+//
+
+struct OverflowTracking {
+ bool HasNUW = true;
+ bool HasNSW = true;
+ bool AllKnownNonNegative = true;
+ bool AllKnownNonZero = true;
+ // Note: AllKnownNonNegative can be true in a case where one of the operands
+ // is negative, but one the operators is not NSW. AllKnownNonNegative should
+ // not be used independently of HasNSW
+ OverflowTracking() = default;
+
+ /// Merge in the no-wrap flags from \p I.
+ void mergeFlags(Instruction &I);
----------------
preames wrote:
Random thought - maybe we should have two merge routines, one for the interior nodes being reassociated, and one for the leaves? This would let us move all the KnownNonNegative and KnownNonZero logic out, and reuse it from LICM.
https://github.com/llvm/llvm-project/pull/140403
More information about the llvm-commits
mailing list