OSDN Git Service

[InstCombine] enhance shuffle-of-binops to allow different variable ops (PR37806)
authorSanjay Patel <spatel@rotateright.com>
Fri, 29 Jun 2018 13:44:06 +0000 (13:44 +0000)
committerSanjay Patel <spatel@rotateright.com>
Fri, 29 Jun 2018 13:44:06 +0000 (13:44 +0000)
commitce6e09c740511f2679a91d75f8a343a4d7753e72
tree0193e47c9370adfe19cb62862f7fe19825b67fb9
parentecdc1aafd0c8da8765c4beadeb55a2b64cd7e645
[InstCombine] enhance shuffle-of-binops to allow different variable ops (PR37806)

This was discussed in D48401 as another improvement for:
https://bugs.llvm.org/show_bug.cgi?id=37806

If we have 2 different variable values, then we shuffle (select) those lanes,
shuffle (select) the constants, and then perform the binop. This eliminates a binop.

The new shuffle uses the same shuffle mask as the existing shuffle, so there's no
danger of creating a difficult shuffle.

All of the earlier constraints still apply, but we also check for extra uses to
avoid creating more instructions than we'll remove.

Additionally, we're disallowing the fold for div/rem because that could expose a
UB hole.

Differential Revision: https://reviews.llvm.org/D48678

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335974 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineVectorOps.cpp
test/Transforms/InstCombine/shuffle_select.ll