diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-05-16 15:15:22 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-05-16 15:15:22 +0000 |
commit | 2eb3512090b8a3be45d88b53b2416e6e16455efb (patch) | |
tree | e88d8ee83b126de60638e93282ec62fb141d9094 /llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | |
parent | 561228b2fa1fa7e638a10a7767df5f6f99ddaa43 (diff) | |
download | bcm5719-llvm-2eb3512090b8a3be45d88b53b2416e6e16455efb.tar.gz bcm5719-llvm-2eb3512090b8a3be45d88b53b2416e6e16455efb.zip |
[InstCombine] allow more binop (shuffle X), C transforms
The canonicalization was restricted to shuffle masks with
a 1-to-1 mapping to the constant vector, but that disqualifies
the common splat pattern. This is part of solving PR37463:
https://bugs.llvm.org/show_bug.cgi?id=37463
llvm-svn: 332479
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 5dc63632691..6c48db5d225 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1401,7 +1401,8 @@ Value *InstCombiner::SimplifyVectorOp(BinaryOperator &Inst) { // Find constant NewC that has property: // shuffle(NewC, ShMask) = C // If such constant does not exist (example: ShMask=<0,0> and C=<1,2>) - // reorder is not possible. + // reorder is not possible. A 1-to-1 mapping is not required. Example: + // ShMask = <1,1,2,2> and C = <5,5,6,6> --> NewC = <undef,5,6,undef> SmallVector<int, 16> ShMask; ShuffleVectorInst::getShuffleMask(Mask, ShMask); SmallVector<Constant *, 16> @@ -1411,7 +1412,8 @@ Value *InstCombiner::SimplifyVectorOp(BinaryOperator &Inst) { if (ShMask[I] >= 0) { assert(ShMask[I] < (int)VWidth); Constant *CElt = C->getAggregateElement(I); - if (!CElt || !isa<UndefValue>(NewVecC[ShMask[I]])) { + Constant *NewCElt = NewVecC[ShMask[I]]; + if (!CElt || (!isa<UndefValue>(NewCElt) && NewCElt != CElt)) { MayChange = false; break; } |