| Issue |
164495
|
| Summary |
[InstCombine] sub(X, umin(X, Y)) => usub_sat(X, Y) (where supported?)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
krzysz00
|
[Alive2 verification](https://alive2.llvm.org/ce/z/GHChPo)
This here pattern
```llvm
define i8 @src(i8 noundef %x, i8 noundef %y) {
%z = call i8 @llvm.umin.i8(i8 %x, i8 %y)
%z2 = sub i8 %x, %z
ret i8 %z2
}
define i8 @tgt(i8 noundef %x, i8 noundef %y) {
%z = call i8 @llvm.usub.sat(i8 %x, i8 %y)
ret i8 %z
}
```
shows up a bunch in code generate at least from IREE if not general MLIR projects (once reasoning was done, often MLIR side, to convert what used to be `smin`s into `umin`s).
I think this is a good candidate for an InstCombine, since it shrinks the IR and removes duplicate uses of `%x`. It also looks to me like most targets support usubsat so this is a safe transform in general.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs