[llvm] [InstCombine] Extend `foldICmpAddConstant` to disjoint `or`. (PR #75899)

Mikhail Gudim via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 01:35:25 PST 2024


mgudim wrote:

@nikic 

>I don't really get what your change does in that example. Why is it changing the comparison operand from 0 to -15? Where is the or + icmp pattern in this sample?

In the "simplified testcase" we have this:

```
  %add_ = add i64 %select_, 15
  %cmp_ = icmp slt i64 %add_, 0
```

The `add` instruction first changes to `or`. Then during `visitICmp`, due to my change it gets deleted, at expance of replacing `0` with `-15` in the comparison. BUT, now, since it's `-15` we can't deduce that the highest bit is nonzero if we come to `f` block

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


More information about the llvm-commits mailing list