Skip to content

Commit fab9256

Browse files
[LLVM][AArch64] Fix invalid use of AArch64ISD::UZP2 in performConcatVectorsCombine. (llvm#104774)
UZP2 requires both operands to match the result type but the combine tries to replace a truncate by passing the pre-truncated operands directly to an UZP2 with the truncated result type. This patch nop-casts the operands to keep the DAG consistent. There should be no changes to the generated code, which is fine as it. This patch also enables more target specific getNode() validation for fixed length vector types.
1 parent f0e34f3 commit fab9256

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19852,15 +19852,15 @@ static SDValue performConcatVectorsCombine(SDNode *N,
1985219852
// This optimization reduces instruction count.
1985319853
if (N00Opc == AArch64ISD::VLSHR && N10Opc == AArch64ISD::VLSHR &&
1985419854
N00->getOperand(1) == N10->getOperand(1)) {
19855-
1985619855
SDValue N000 = N00->getOperand(0);
1985719856
SDValue N100 = N10->getOperand(0);
1985819857
uint64_t N001ConstVal = N00->getConstantOperandVal(1),
1985919858
N101ConstVal = N10->getConstantOperandVal(1),
1986019859
NScalarSize = N->getValueType(0).getScalarSizeInBits();
1986119860

1986219861
if (N001ConstVal == N101ConstVal && N001ConstVal > NScalarSize) {
19863-
19862+
N000 = DAG.getNode(AArch64ISD::NVCAST, dl, VT, N000);
19863+
N100 = DAG.getNode(AArch64ISD::NVCAST, dl, VT, N100);
1986419864
SDValue Uzp = DAG.getNode(AArch64ISD::UZP2, dl, VT, N000, N100);
1986519865
SDValue NewShiftConstant =
1986619866
DAG.getConstant(N001ConstVal - NScalarSize, dl, MVT::i32);
@@ -29344,8 +29344,10 @@ void AArch64TargetLowering::verifyTargetSDNode(const SDNode *N) const {
2934429344
assert(OpVT.getSizeInBits() == VT.getSizeInBits() &&
2934529345
"Expected vectors of equal size!");
2934629346
// TODO: Enable assert once bogus creations have been fixed.
29347-
// assert(OpVT.getVectorElementCount() == VT.getVectorElementCount()*2 &&
29348-
// "Expected result vector with half the lanes of its input!");
29347+
if (VT.isScalableVector())
29348+
break;
29349+
assert(OpVT.getVectorElementCount() == VT.getVectorElementCount() * 2 &&
29350+
"Expected result vector with half the lanes of its input!");
2934929351
break;
2935029352
}
2935129353
case AArch64ISD::TRN1:
@@ -29362,7 +29364,9 @@ void AArch64TargetLowering::verifyTargetSDNode(const SDNode *N) const {
2936229364
assert(VT.isVector() && Op0VT.isVector() && Op1VT.isVector() &&
2936329365
"Expected vectors!");
2936429366
// TODO: Enable assert once bogus creations have been fixed.
29365-
// assert(VT == Op0VT && VT == Op1VT && "Expected matching vectors!");
29367+
if (VT.isScalableVector())
29368+
break;
29369+
assert(VT == Op0VT && VT == Op1VT && "Expected matching vectors!");
2936629370
break;
2936729371
}
2936829372
}

0 commit comments

Comments
 (0)