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;
}
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;