[llvm] [InstCombine] When canoncicalizing clamp like, also consider certain sgt/slt cases (PR #153240)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 14 19:56:55 PDT 2025
dtcxzyw wrote:
> > I am fine with the IR change. But we may need to handle the new usat pattern on AArch64: https://godbolt.org/z/nq8P6Yssx
>
> I don't see how `usat` applies here, this change is specifically looking at the following case: https://godbolt.org/z/MY1ErP1oK
>
> ```
> if (x < 0) return 0
> if (x > 256) return -1;
> else return x;
> ```
This pattern comes from IR changes to ffmpeg: https://github.com/dtcxzyw/llvm-opt-benchmark/pull/2670
Imagine you have a `trunc i32 to i8` for the return value, we get a usat pattern since `return -1` can be interpreted as `return 255`.
https://github.com/llvm/llvm-project/pull/153240
More information about the llvm-commits
mailing list