[llvm] [InstCombine] Canonicalize more saturated-add variants (PR #100008)
Rose Silicon via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 14:01:28 PDT 2024
RSilicon wrote:
> Your alive proof has
>
> ```
> define dso_local i8 @src3(i8 %x, i8 %c) {
> entry:
> %noZero = icmp ne i8 %c, 0
> call void @llvm.assume(i1 %noZero)
> %add = add nuw i8 %x, %c
> %c.not = xor i8 %c, -1
> %d = add i8 %c.not, 1
> %cmp.not = icmp ugt i8 %x, %d
> %cond = select i1 %cmp.not, i8 -1, i8 %add
> ret i8 %cond
> }
> ```
>
> The `nuw` flag there says that the add never overflows and thus never saturates. The transform fails without the nuw. There's no check for the nuw in your transform.
I meant to remove this. This exact situation is impossible to run into in real code. It is not covered by my code at all.
https://github.com/llvm/llvm-project/pull/100008
More information about the llvm-commits
mailing list