[llvm] [DAG] Generalize fold (not (neg x)) -> (add X, -1) (PR #154348)

guan jian via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 09:28:30 PDT 2025


rez5427 wrote:

> Infinite loop in AArch64/aarch64-bitwisenot-fold.ll ?

It seems like is mutual recursion with the code below.
```
// Fold (and X, (add (not Y), Z)) -> (and X, (not (sub Y, Z)))
// Fold (and X, (sub (not Y), Z)) -> (and X, (not (add Y, Z)))
if (TLI.hasAndNot(SDValue(N, 0)))
  if (SDValue Folded = foldBitwiseOpWithNeg(N, DL, VT))
    return Folded;
```

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


More information about the llvm-commits mailing list