[llvm] [IR] Add nowrap flags for trunc instruction (PR #85592)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 22 11:15:01 PDT 2024
================
@@ -368,11 +368,19 @@ bool Instruction::isOnlyUserOfAnyOperand() {
}
void Instruction::setHasNoUnsignedWrap(bool b) {
- cast<OverflowingBinaryOperator>(this)->setHasNoUnsignedWrap(b);
+ if (auto Inst = cast<OverflowingBinaryOperator>(this)) {
+ Inst->setHasNoUnsignedWrap(b);
+ } else {
+ cast<PossiblyNoWrapInst>(this)->setHasNoUnsignedWrap(b);
+ }
}
void Instruction::setHasNoSignedWrap(bool b) {
- cast<OverflowingBinaryOperator>(this)->setHasNoSignedWrap(b);
+ if (auto Inst = cast<OverflowingBinaryOperator>(this)) {
----------------
dtcxzyw wrote:
```suggestion
if (auto *Inst = dyn_cast<OverflowingBinaryOperator>(this)) {
```
https://github.com/llvm/llvm-project/pull/85592
More information about the llvm-commits
mailing list