@@ -6586,12 +6586,13 @@ SDValue SystemZTargetLowering::combineExtract(const SDLoc &DL, EVT ResVT,
6586
6586
// The number of bytes being extracted.
6587
6587
unsigned BytesPerElement = VecVT.getVectorElementType ().getStoreSize ();
6588
6588
6589
- while ( canTreatAsByteVector (Op. getValueType ()) ) {
6589
+ for (;; ) {
6590
6590
unsigned Opcode = Op.getOpcode ();
6591
6591
if (Opcode == ISD::BITCAST)
6592
6592
// Look through bitcasts.
6593
6593
Op = Op.getOperand (0 );
6594
- else if (Opcode == ISD::VECTOR_SHUFFLE || Opcode == SystemZISD::SPLAT) {
6594
+ else if ((Opcode == ISD::VECTOR_SHUFFLE || Opcode == SystemZISD::SPLAT) &&
6595
+ canTreatAsByteVector (Op.getValueType ())) {
6595
6596
// Get a VPERM-like permute mask and see whether the bytes covered
6596
6597
// by the extracted element are a contiguous sequence from one
6597
6598
// source operand.
@@ -6613,7 +6614,8 @@ SDValue SystemZTargetLowering::combineExtract(const SDLoc &DL, EVT ResVT,
6613
6614
Index = Byte / BytesPerElement;
6614
6615
Op = Op.getOperand (unsigned (First) / Bytes.size ());
6615
6616
Force = true ;
6616
- } else if (Opcode == ISD::BUILD_VECTOR) {
6617
+ } else if (Opcode == ISD::BUILD_VECTOR &&
6618
+ canTreatAsByteVector (Op.getValueType ())) {
6617
6619
// We can only optimize this case if the BUILD_VECTOR elements are
6618
6620
// at least as wide as the extracted value.
6619
6621
EVT OpVT = Op.getValueType ();
@@ -6642,6 +6644,7 @@ SDValue SystemZTargetLowering::combineExtract(const SDLoc &DL, EVT ResVT,
6642
6644
} else if ((Opcode == ISD::SIGN_EXTEND_VECTOR_INREG ||
6643
6645
Opcode == ISD::ZERO_EXTEND_VECTOR_INREG ||
6644
6646
Opcode == ISD::ANY_EXTEND_VECTOR_INREG) &&
6647
+ canTreatAsByteVector (Op.getValueType ()) &&
6645
6648
canTreatAsByteVector (Op.getOperand (0 ).getValueType ())) {
6646
6649
// Make sure that only the unextended bits are significant.
6647
6650
EVT ExtVT = Op.getValueType ();
@@ -7358,8 +7361,9 @@ SDValue SystemZTargetLowering::combineEXTRACT_VECTOR_ELT(
7358
7361
if (auto *IndexN = dyn_cast<ConstantSDNode>(N->getOperand (1 ))) {
7359
7362
SDValue Op0 = N->getOperand (0 );
7360
7363
EVT VecVT = Op0.getValueType ();
7361
- return combineExtract (SDLoc (N), N->getValueType (0 ), VecVT, Op0,
7362
- IndexN->getZExtValue (), DCI, false );
7364
+ if (canTreatAsByteVector (VecVT))
7365
+ return combineExtract (SDLoc (N), N->getValueType (0 ), VecVT, Op0,
7366
+ IndexN->getZExtValue (), DCI, false );
7363
7367
}
7364
7368
return SDValue ();
7365
7369
}
0 commit comments