[llvm] [IR] Add nowrap flags for trunc instruction (PR #85592)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 30 11:05:46 PDT 2024
================
@@ -27,6 +27,10 @@ bool Operator::hasPoisonGeneratingFlags() const {
auto *OBO = cast<OverflowingBinaryOperator>(this);
return OBO->hasNoUnsignedWrap() || OBO->hasNoSignedWrap();
}
+ case Instruction::Trunc: {
+ auto *TI = dyn_cast<TruncInst>(this);
+ return TI->hasNoUnsignedWrap() || TI->hasNoSignedWrap();
----------------
antoniofrighetto wrote:
```llvm
@g_var = external global [0 x i8]
define i64 @test_ret_noundef_add_constantexpr() {
entry:
%add = add i32 trunc (i64 sub (i64 0, i64 ptrtoint (ptr @g_var to i64)) to i32), 1
%conv = sext i32 %add to i64
ret i64 %conv
}
```
Think you can put it in `test/Transforms/FunctionAttrs/noundef.ll`.
https://github.com/llvm/llvm-project/pull/85592
More information about the llvm-commits
mailing list