[llvm] [InstCombine] Improve handling of `not` and free inversion. (PR #66787)

via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 17 22:59:51 PST 2023


goldsteinn wrote:

> > Only looked at the first three commits, which imho could be a separate PR (maybe drop the rest from this one for now).
> > I think after adding getFreeInverted() it would be good to also go through existing users of isFreeToInvert() and replace them with getFreeInverted() where this is easy, e.g. in foldICmpOrXX(). Directly creating the inverted op instead of letting it get inverted separately does seem a lot more robust to me.
> 
> Thank you for the review.
> 
> Regarding replacing `getFreeInverted` with `isFreeToInvert` + (creating a `not`). So I do add a fold for using `getFreeInverted` in `not` fold. My feeling was we have places where we create a `not` in a canonicalizing effort and more places recognize `m_Not` than `isFreeToInvert`, so it made sense to let the new pattern be checked by other folds before stripping the `not`. But not married to that idea.

Okay, its split to 4 four commits related to the free inversion (re-titled).
The fourth commit is essentially NFC (although not quite due to change in inst order/names) and puts `getFreelyInverted` in a few places.

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


More information about the llvm-commits mailing list