@@ -41336,29 +41336,27 @@ static SDValue combineTargetShuffle(SDValue N, const SDLoc &DL,
4133641336 case X86ISD::VPERMV3: {
4133741337 // Combine VPERMV3 to widened VPERMV if the two source operands are split
4133841338 // from the same vector.
41339- // TODO: Handle extraction from a wider source vector (e.g. v16i32 -> v4i32).
4134041339 SDValue V1 = peekThroughBitcasts(N.getOperand(0));
4134141340 SDValue V2 = peekThroughBitcasts(N.getOperand(2));
4134241341 MVT SVT = V1.getSimpleValueType();
41343- MVT NVT = VT.getDoubleNumVectorElementsVT();
41344- if ((NVT.is256BitVector() ||
41345- (NVT.is512BitVector() && Subtarget.hasEVEX512())) &&
41346- V1.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
41342+ if (V1.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
4134741343 V1.getConstantOperandVal(1) == 0 &&
4134841344 V2.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
4134941345 V2.getConstantOperandVal(1) == SVT.getVectorNumElements() &&
41350- V1.getOperand(0) == V2.getOperand(0) &&
41351- V1.getOperand(0).getValueSizeInBits() == NVT.getSizeInBits()) {
41352- SDValue Mask =
41353- DAG.getNode(ISD::INSERT_SUBVECTOR, DL, NVT, DAG.getUNDEF(NVT),
41354- N.getOperand(1), DAG.getIntPtrConstant(0, DL));
41355- return DAG.getNode(
41356- ISD::EXTRACT_SUBVECTOR, DL, VT,
41357- DAG.getNode(X86ISD::VPERMV, DL, NVT, Mask,
41358- DAG.getBitcast(NVT, V1.getOperand(0))),
41359- DAG.getIntPtrConstant(0, DL));
41346+ V1.getOperand(0) == V2.getOperand(0)) {
41347+ EVT NVT = V1.getOperand(0).getValueType();
41348+ if (NVT.is256BitVector() ||
41349+ (NVT.is512BitVector() && Subtarget.hasEVEX512())) {
41350+ MVT WideVT = MVT::getVectorVT(
41351+ VT.getScalarType(), NVT.getSizeInBits() / VT.getScalarSizeInBits());
41352+ SDValue Mask = widenSubVector(N.getOperand(1), false, Subtarget, DAG,
41353+ DL, WideVT.getSizeInBits());
41354+ SDValue Perm = DAG.getNode(X86ISD::VPERMV, DL, WideVT, Mask,
41355+ DAG.getBitcast(WideVT, V1.getOperand(0)));
41356+ return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Perm,
41357+ DAG.getIntPtrConstant(0, DL));
41358+ }
4136041359 }
41361-
4136241360 return SDValue();
4136341361 }
4136441362 default:
0 commit comments