-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Local] Move OverflowTracking to Local.h, move logic to helpers (NFC) #140403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -556,6 +556,30 @@ 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; | ||
|
||
// Note: At the moment, users are responsible to manage AllKnownNonNegative | ||
// and AllKnownNonZero manually. 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 | ||
bool AllKnownNonNegative = true; | ||
bool AllKnownNonZero = true; | ||
|
||
OverflowTracking() = default; | ||
|
||
/// Merge in the no-wrap flags from \p I. | ||
void mergeFlags(Instruction &I); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will share a separate patch for that, thanks |
||
|
||
/// Apply the no-wrap flags to \p I if applicable. | ||
void applyFlags(Instruction &I); | ||
}; | ||
|
||
} // end namespace llvm | ||
|
||
#endif // LLVM_TRANSFORMS_UTILS_LOCAL_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment indicating that the user is responsible for updating
AllKnownNonNegative
andAllKnownNonZero
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done thanks