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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 17 04:08:26 PDT 2019


nikic marked 2 inline comments as done.
nikic added inline comments.


================
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)) &&
----------------
lebedev.ri wrote:
> There are 4 variations of this pattern, both `or` and `and` are commutative.
Right you are. I've added these now, which resulted in a few more changes to the variablemask tests. I was under the mistaken impression that `(and X, (xor Y, -1))` is a canonicalized and-not pattern.


================
Comment at: llvm/test/CodeGen/X86/unfold-masked-merge-vector-variablemask-const.ll:344
 ; CHECK-SSE1-NEXT:    movaps %xmm1, (%rdi)
 ; CHECK-SSE1-NEXT:    retq
 ;
----------------
Looks like this doesn't fold for the SSE1 case, because FXOR and friends are created via custom DAG combine very early on.


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

https://reviews.llvm.org/D59174





More information about the llvm-commits mailing list