[PATCH] D55935: [X86][SSE] Canonicalize OR(AND(X,C),AND(Y,~C)) -> OR(AND(X,C),ANDNP(C,Y))

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 24 03:09:24 PST 2018


lebedev.ri added a comment.

In D55935#1340459 <https://reviews.llvm.org/D55935#1340459>, @spatel wrote:

> Would we better off doing a generic DAGCombine into the optimal xor-and-xor (aka, masked merge) pattern?
>  (x & C) | (y & ~C) --> ((x ^ y) & C) ^ y
>
> We weren't allowed to do that transform with a variable mask in D46814 <https://reviews.llvm.org/D46814> because:
>  http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20180528/556578.html
>
> But I think that's ok with a constant mask. We can't accidentally dynamically access an undef value when the mask is a constant.


To add to that, i *think* we intentionally avoided transforming the pattern with constants there, IIRC because that was better for ValueTracking?

> That should allow load folding of the constant, so it never burns a register to hold the constant.

I think that would work.
But there will likely be //some// cost to that: https://godbolt.org/z/-MZNgY


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55935





More information about the llvm-commits mailing list