[PATCH] D59174: [DAGCombine] Fold (x & ~y) | y patterns

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 17 02:12:59 PDT 2019


lebedev.ri added a comment.

In D59174#1423934 <https://reviews.llvm.org/D59174#1423934>, @RKSimon wrote:

> These seem to be managing special cases of the bit select pattern OR(AND(X,Y),AND(Z,~Y)) - would we benefit from adding a helper function to detect these, similar to what we have for isBitwiseNot ? Although in this case we'd have to generate the -1 constant.


I'm not sure why/how/for what it would be useful?

This looks good, but is partial, nit added.



================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:5429
 
+  // fold (or (and X, (xor Y, -1)), Y) -> (or X, Y)
+  if (N0.getOpcode() == ISD::AND && isBitwiseNot(N0.getOperand(1)) &&
----------------
There are 4 variations of this pattern, both `or` and `and` are commutative.


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

https://reviews.llvm.org/D59174





More information about the llvm-commits mailing list