[PATCH] D112276: [InstCombine] Fold `(c & ~(a | b)) | (b & ~(a | c))` to `~a & (b ^ c)`

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 25 06:58:31 PDT 2021


spatel added a reviewer: lebedev.ri.
spatel added a subscriber: anton-afanasyev.
spatel added a comment.

For reference, we did discuss more general boolean logic solving in D112108 <https://reviews.llvm.org/D112108>, and I'm not sure how many more patterns like this or D112338 <https://reviews.llvm.org/D112338> are needed, but at some point, it will become unreasonable to continue adding these to instcombine (some have said that we went over the cliff long ago!).

We do have -aggressive-instcombine for housing rare/large pattern-matching, so that is another option for minimizing compile-time impact. That pass is currently only enabled at -O3, but there is some work/motivation to enable that at -O2 as well ( cc @anton-afanasyev ).

That said, the logic seems right, but we need many more tests - at least 8 combinations for commutes/swaps? There are also several patterns where intermediate ops can have extra uses, and we allow the fold, so we should have positive tests for all of those cases.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112276/new/

https://reviews.llvm.org/D112276



More information about the llvm-commits mailing list