@@ -41336,29 +41336,27 @@ static SDValue combineTargetShuffle(SDValue N, const SDLoc &DL,
41336
41336
case X86ISD::VPERMV3: {
41337
41337
// Combine VPERMV3 to widened VPERMV if the two source operands are split
41338
41338
// from the same vector.
41339
- // TODO: Handle extraction from a wider source vector (e.g. v16i32 -> v4i32).
41340
41339
SDValue V1 = peekThroughBitcasts(N.getOperand(0));
41341
41340
SDValue V2 = peekThroughBitcasts(N.getOperand(2));
41342
41341
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 &&
41347
41343
V1.getConstantOperandVal(1) == 0 &&
41348
41344
V2.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
41349
41345
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
+ }
41360
41359
}
41361
-
41362
41360
return SDValue();
41363
41361
}
41364
41362
default:
0 commit comments