[llvm] [IR] Add nowrap flags for trunc instruction (PR #85592)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 18 02:53:10 PDT 2024
================
@@ -386,11 +394,17 @@ void Instruction::setNonNeg(bool b) {
}
bool Instruction::hasNoUnsignedWrap() const {
- return cast<OverflowingBinaryOperator>(this)->hasNoUnsignedWrap();
+ if (auto Inst = cast<OverflowingBinaryOperator>(this))
+ return Inst->hasNoUnsignedWrap();
+
+ return cast<PossiblyNoWrapInst>(this)->hasNoUnsignedWrap();
}
bool Instruction::hasNoSignedWrap() const {
- return cast<OverflowingBinaryOperator>(this)->hasNoSignedWrap();
+ if (auto Inst = cast<OverflowingBinaryOperator>(this))
+ return Inst->hasNoSignedWrap();
+
+ return cast<PossiblyNoWrapInst>(this)->hasNoSignedWrap();
----------------
arsenm wrote:
Can there be a common base class for has nuw/nsw instead of requiring this split?
https://github.com/llvm/llvm-project/pull/85592
More information about the llvm-commits
mailing list