[PATCH] D46814: [InstCombine] Canonicalize (not fold!) unfolded masked merge pattern.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 13 14:36:11 PDT 2018


lebedev.ri created this revision.
lebedev.ri added reviewers: spatel, craig.topper.

The canonical unfolded masked merge pattern is

  (x &  m) | (y & ~m)

But there is a second, equivalend variant:

  (x | ~m) & (y |  m)

We should prefer one of them, and **for now** just canonicalize to the first one.

https://rise4fun.com/Alive/TEM

I have left out the constant handling out here, since i'm not quite sure how to properly handle that.
I can either do `Builder.CreateNot()`, rely on automatic deduplication, and do pointer comparison.
That will be enough for everything without undef.
But with `undef` i will need a `undef`-ignoring comparator (in `Constant` class?)
Or i could write a more specialized comparator, which specifically checks that one constant is ~another constant.
Suggestions welcomed. Maybe there is already such a thing, and i'm simply not aware of it?


Repository:
  rL LLVM

https://reviews.llvm.org/D46814

Files:
  lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  test/Transforms/InstCombine/and-or-not.ll
  test/Transforms/InstCombine/masked-merge-and-of-ors.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46814.146530.patch
Type: text/x-patch
Size: 9543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180513/3b52cdf8/attachment.bin>


More information about the llvm-commits mailing list