Issue 98017
Summary [InstCombine] Missed optimization for `zext(trunc nuw(x))`
Labels new issue
Assignees
Reporter Il-Capitano
    Godbolt link: https://godbolt.org/z/Ws1jPz4rE

Instcombine transforms this function:
```llvm
define i64 @test(i64 %n) {
    %trunc = trunc nuw i64 %n to i32
    %zext = zext i32 %trunc to i64
    ret i64 %zext
}
```
into this:
```llvm
define i64 @test(i64 %n) {
 %zext = and i64 %n, 4294967295
  ret i64 %zext
}
```

However, because of the `nuw` flag on `trunc`, this could be simplified into this instead:
```llvm
define i64 @test(i64 %n) {
    ret i64 %n
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to