[llvm] [ValueTracking] Improve `and` and `or` recurrence handling (PR #225775)

Ömer Sinan Ağacan via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 07:29:51 PDT 2026


osa1 wrote:

Huh.. yeah it seems to include the changes here, but it also does a few other things:

- Adds `xor` recurrence handling
- Updates recursion handling in `isKnownZero...`
- Adds `or` handling in `isNonZeroRecurrence`

These (including the `and` and `or` handling) could be 4 PRs if we wanted to improve one thing at a time.

I also don't like that `or` and `and` are handled together with `add`, `sub`, etc. when they don't really have much in common. And then we special case them in the switch-case block that handles all of those. Also the block
```
        auto *OverflowOp = dyn_cast<OverflowingBinaryOperator>(BO);
        if (!OverflowOp || !Q.IIQ.hasNoSignedWrap(OverflowOp))
          break;
```
does not apply to `or`, `and`, and `xor`.

I think we should just have them separately in the switch-case, as in this PR.

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


More information about the llvm-commits mailing list