Skip to content

Commit f2f1051

Browse files
committed
Do a check before call instead.
1 parent e116cec commit f2f1051

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6586,12 +6586,13 @@ SDValue SystemZTargetLowering::combineExtract(const SDLoc &DL, EVT ResVT,
65866586
// The number of bytes being extracted.
65876587
unsigned BytesPerElement = VecVT.getVectorElementType().getStoreSize();
65886588

6589-
while (canTreatAsByteVector(Op.getValueType())) {
6589+
for (;;) {
65906590
unsigned Opcode = Op.getOpcode();
65916591
if (Opcode == ISD::BITCAST)
65926592
// Look through bitcasts.
65936593
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())) {
65956596
// Get a VPERM-like permute mask and see whether the bytes covered
65966597
// by the extracted element are a contiguous sequence from one
65976598
// source operand.
@@ -6613,7 +6614,8 @@ SDValue SystemZTargetLowering::combineExtract(const SDLoc &DL, EVT ResVT,
66136614
Index = Byte / BytesPerElement;
66146615
Op = Op.getOperand(unsigned(First) / Bytes.size());
66156616
Force = true;
6616-
} else if (Opcode == ISD::BUILD_VECTOR) {
6617+
} else if (Opcode == ISD::BUILD_VECTOR &&
6618+
canTreatAsByteVector(Op.getValueType())) {
66176619
// We can only optimize this case if the BUILD_VECTOR elements are
66186620
// at least as wide as the extracted value.
66196621
EVT OpVT = Op.getValueType();
@@ -6642,6 +6644,7 @@ SDValue SystemZTargetLowering::combineExtract(const SDLoc &DL, EVT ResVT,
66426644
} else if ((Opcode == ISD::SIGN_EXTEND_VECTOR_INREG ||
66436645
Opcode == ISD::ZERO_EXTEND_VECTOR_INREG ||
66446646
Opcode == ISD::ANY_EXTEND_VECTOR_INREG) &&
6647+
canTreatAsByteVector(Op.getValueType()) &&
66456648
canTreatAsByteVector(Op.getOperand(0).getValueType())) {
66466649
// Make sure that only the unextended bits are significant.
66476650
EVT ExtVT = Op.getValueType();
@@ -7358,8 +7361,9 @@ SDValue SystemZTargetLowering::combineEXTRACT_VECTOR_ELT(
73587361
if (auto *IndexN = dyn_cast<ConstantSDNode>(N->getOperand(1))) {
73597362
SDValue Op0 = N->getOperand(0);
73607363
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);
73637367
}
73647368
return SDValue();
73657369
}

0 commit comments

Comments
 (0)