[llvm] [InstCombine] Canonicalize more saturated-add variants (PR #100008)

Rose Silicon via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 14:18:03 PDT 2024


RSilicon wrote:

> Your proof has this
> 
> 
> 
> ```
> 
> define dso_local i8 @src2(i8 %x, i8  %c) {
> 
> entry:
> 
>   %add = add i8 %x, %c
> 
>   %c.not = xor i8 %c, -1
> 
>   %d = sub nuw i8 %c.not, 1
> 
>   %cmp.not = icmp ugt i8 %x, %d
> 
>   %cond = select i1 %cmp.not, i8 -1, i8 %add
> 
>   ret i8 %cond
> 
> }
> 
> ```
> 
> 
> 
> Which has an `nuw` on the `sub`. It fails without it. Your transform does not check this condition.

Because we are checking constants, and not variables, if this wraps, then m_SpecificInt will always fail.

https://github.com/llvm/llvm-project/pull/100008


More information about the llvm-commits mailing list