[PATCH] D45631: [InstCombine] Simplify 'xor' to 'or' if no common bits are set.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 13 10:42:57 PDT 2018


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

In order to get the whole fold as specified in PR6773 <https://bugs.llvm.org/show_bug.cgi?id=6773>,
let's first handle the simple straight-forward things.
Let's start with the `xor` -> `or` simplification.

The one obvious thing missing here: the constant mask is not handled.
I have an idea how to handle it, but it will require some thinking,
and is not strictly required here, so i've left that for later.

This `haveNoCommonBitsSet()` change looks kinda monstrous, i could refactor
it e.g. into "out of these 2 pairs of two values, one of these 4 values is inverted value from another pair" matcher,
but i'm not sure if i should?


Repository:
  rL LLVM

https://reviews.llvm.org/D45631

Files:
  lib/Analysis/ValueTracking.cpp
  lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  test/Transforms/InstCombine/logical-select.ll
  test/Transforms/InstCombine/masked-merge.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45631.142436.patch
Type: text/x-patch
Size: 6991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180413/6594fb72/attachment.bin>


More information about the llvm-commits mailing list