Skip to content

Commit 9284955

Browse files
committed
Assert number of ops is power of 2, rename recursive variables
1 parent a12be52 commit 9284955

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15305,18 +15305,19 @@ performCONCAT_VECTORSSplitCombine(SDNode *N, SelectionDAG &DAG,
1530515305
MVT VT = N->getSimpleValueType(0);
1530615306

1530715307
MVT HalfVT = VT.getHalfNumVectorElementsVT();
15308-
size_t HalfNumOps = (N->getNumOperands() + 1) / 2;
15309-
SDValue BotSubConcat = DAG.getNode(ISD::CONCAT_VECTORS, DL, HalfVT,
15310-
N->ops().take_front(HalfNumOps));
15311-
SDValue TopSubConcat = DAG.getNode(ISD::CONCAT_VECTORS, DL, HalfVT,
15312-
N->ops().drop_front(HalfNumOps));
15308+
assert(isPowerOf2_32(N->getNumOperands()));
15309+
size_t HalfNumOps = N->getNumOperands() / 2;
15310+
SDValue Lo = DAG.getNode(ISD::CONCAT_VECTORS, DL, HalfVT,
15311+
N->ops().take_front(HalfNumOps));
15312+
SDValue Hi = DAG.getNode(ISD::CONCAT_VECTORS, DL, HalfVT,
15313+
N->ops().drop_front(HalfNumOps));
1531315314

1531415315
// Lower to an insert_subvector directly so the concat_vectors don't get
1531515316
// recombined.
15316-
SDValue Vec = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getUNDEF(VT),
15317-
BotSubConcat, DAG.getVectorIdxConstant(0, DL));
15317+
SDValue Vec = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getUNDEF(VT), Lo,
15318+
DAG.getVectorIdxConstant(0, DL));
1531815319
Vec = DAG.getNode(
15319-
ISD::INSERT_SUBVECTOR, DL, VT, Vec, TopSubConcat,
15320+
ISD::INSERT_SUBVECTOR, DL, VT, Vec, Hi,
1532015321
DAG.getVectorIdxConstant(HalfVT.getVectorMinNumElements(), DL));
1532115322
return Vec;
1532215323
}

0 commit comments

Comments
 (0)