diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2016-02-20 12:57:32 +0000 |
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2016-02-20 12:57:32 +0000 |
| commit | ccf2cce67cf545f4bed029b8feb027ca783a2e00 (patch) | |
| tree | b10ee8c3b4aadd4e95df20d222e0110b6529125a /llvm/lib | |
| parent | bc0122bca941d9b41be9e2206951cf2c117d53e1 (diff) | |
| download | bcm5719-llvm-ccf2cce67cf545f4bed029b8feb027ca783a2e00.tar.gz bcm5719-llvm-ccf2cce67cf545f4bed029b8feb027ca783a2e00.zip | |
[X86][SSE] Move all undef/zero cases before target shuffle combining.
First small step towards fixing PR26667 - we need to ensure that combineX86ShuffleChain only gets called with a valid shuffle input node (a similar issue was found in D17041).
llvm-svn: 261433
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index ffbee65afba..49ded80e299 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -23525,21 +23525,9 @@ static bool combineX86ShuffleChain(SDValue Op, SDValue Root, ArrayRef<int> Mask, SDValue Res; if (Mask.size() == 1) { - int Index = Mask[0]; - assert((Index >= 0 || Index == SM_SentinelUndef || - Index == SM_SentinelZero) && - "Invalid shuffle index found!"); - - // We may end up with an accumulated mask of size 1 as a result of - // widening of shuffle operands (see function canWidenShuffleElements). - // If the only shuffle index is equal to SM_SentinelZero then propagate - // a zero vector. Otherwise, the combine shuffle mask is a no-op shuffle - // mask, and therefore the entire chain of shuffles can be folded away. - if (Index == SM_SentinelZero) - DCI.CombineTo(Root.getNode(), getZeroVector(RootVT, Subtarget, DAG, DL)); - else - DCI.CombineTo(Root.getNode(), DAG.getBitcast(RootVT, Input), - /*AddTo*/ true); + assert(Mask[0] == 0 && "Invalid shuffle index found!"); + DCI.CombineTo(Root.getNode(), DAG.getBitcast(RootVT, Input), + /*AddTo*/ true); return true; } @@ -23802,20 +23790,26 @@ static bool combineX86ShufflesRecursively(SDValue Op, SDValue Root, RootMaskedIdx % OpRatio); } - // Handle the all undef case early. - // TODO - should we handle zero/undef case as well? Widening the mask - // will lose information on undef elements possibly reducing future - // combine possibilities. + // Handle the all undef/zero cases early. if (std::all_of(Mask.begin(), Mask.end(), [](int Idx) { return Idx == SM_SentinelUndef; })) { DCI.CombineTo(Root.getNode(), DAG.getUNDEF(Root.getValueType())); return true; } + if (std::all_of(Mask.begin(), Mask.end(), [](int Idx) { return Idx < 0; })) { + // TODO - should we handle the mixed zero/undef case as well? Just returning + // a zero mask will lose information on undef elements possibly reducing + // future combine possibilities. + DCI.CombineTo(Root.getNode(), getZeroVector(Root.getSimpleValueType(), + Subtarget, DAG, SDLoc(Root))); + return true; + } + assert(Input0 && "Shuffle with no inputs detected"); HasPSHUFB |= (Op.getOpcode() == X86ISD::PSHUFB); // See if we can recurse into Input0 (if it's a target shuffle). - if (Input0 && Op->isOnlyUserOf(Input0.getNode()) && + if (Op->isOnlyUserOf(Input0.getNode()) && combineX86ShufflesRecursively(Input0, Root, Mask, Depth + 1, HasPSHUFB, DAG, DCI, Subtarget)) return true; |

