diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index bf89782ea017..9cbfae445a54 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -43196,15 +43196,21 @@ static SDValue combineHorizOpWithShuffle(SDNode *N, SelectionDAG &DAG, // If the op is an unary shuffle that can scale to v2x64, // then we can perform this as a v4x32 post shuffle. auto AdjustOp = [&](SDValue V, int Offset) { - auto *SVN = dyn_cast(V); - SmallVector ScaledMask; - if (!SVN || !SVN->getOperand(1).isUndef() || - !scaleShuffleElements(SVN->getMask(), 2, ScaledMask) || - !N->isOnlyUserOf(V.getNode())) + SmallVector ShuffleOps; + SmallVector ShuffleMask, ScaledMask; + if (!getTargetShuffleInputs(V, ShuffleOps, ShuffleMask, DAG)) return SDValue(); + + resolveTargetShuffleInputsAndMask(ShuffleOps, ShuffleMask); + if (isAnyZero(ShuffleMask) || ShuffleOps.size() != 1 || + !ShuffleOps[0].getValueType().is128BitVector() || + !N->isOnlyUserOf(V.getNode()) || + !scaleShuffleElements(ShuffleMask, 2, ScaledMask)) + return SDValue(); + PostShuffle[Offset + 0] = ScaledMask[0] < 0 ? -1 : Offset + ScaledMask[0]; PostShuffle[Offset + 1] = ScaledMask[1] < 0 ? -1 : Offset + ScaledMask[1]; - return SVN->getOperand(0); + return DAG.getBitcast(V.getValueType(), ShuffleOps[0]); }; SDValue Src0 = AdjustOp(N0, 0);