Skip to content

Commit 234b9fb

Browse files
RKSimongithub-actions[bot]
authored andcommitted
Automerge: [X86] EltsFromConsecutiveLoads - add recursion depth limiter (#168694)
EltsFromConsecutiveLoads can be recursively called - ensure we limit the recursion depth.
2 parents b749459 + b42851b commit 234b9fb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7281,7 +7281,10 @@ static bool findEltLoadSrc(SDValue Elt, LoadSDNode *&Ld, int64_t &ByteOffset) {
72817281
static SDValue EltsFromConsecutiveLoads(EVT VT, ArrayRef<SDValue> Elts,
72827282
const SDLoc &DL, SelectionDAG &DAG,
72837283
const X86Subtarget &Subtarget,
7284-
bool IsAfterLegalize) {
7284+
bool IsAfterLegalize,
7285+
unsigned Depth = 0) {
7286+
if (Depth >= SelectionDAG::MaxRecursionDepth)
7287+
return SDValue(); // Limit search depth.
72857288
if ((VT.getScalarSizeInBits() % 8) != 0)
72867289
return SDValue();
72877290

@@ -7455,7 +7458,7 @@ static SDValue EltsFromConsecutiveLoads(EVT VT, ArrayRef<SDValue> Elts,
74557458
EVT::getVectorVT(*DAG.getContext(), VT.getScalarType(), HalfNumElems);
74567459
SDValue HalfLD =
74577460
EltsFromConsecutiveLoads(HalfVT, Elts.drop_back(HalfNumElems), DL,
7458-
DAG, Subtarget, IsAfterLegalize);
7461+
DAG, Subtarget, IsAfterLegalize, Depth + 1);
74597462
if (HalfLD)
74607463
return DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getUNDEF(VT),
74617464
HalfLD, DAG.getVectorIdxConstant(0, DL));
@@ -7532,7 +7535,8 @@ static SDValue EltsFromConsecutiveLoads(EVT VT, ArrayRef<SDValue> Elts,
75327535
VT.getSizeInBits() / ScalarSize);
75337536
if (TLI.isTypeLegal(BroadcastVT)) {
75347537
if (SDValue RepeatLoad = EltsFromConsecutiveLoads(
7535-
RepeatVT, RepeatedLoads, DL, DAG, Subtarget, IsAfterLegalize)) {
7538+
RepeatVT, RepeatedLoads, DL, DAG, Subtarget, IsAfterLegalize,
7539+
Depth + 1)) {
75367540
SDValue Broadcast = RepeatLoad;
75377541
if (RepeatSize > ScalarSize) {
75387542
while (Broadcast.getValueSizeInBits() < VT.getSizeInBits())

0 commit comments

Comments
 (0)