Skip to content

Commit 1139664

Browse files
committed
[DAG] Cleanup DAGCombiner::CombineConsecutiveLoads early-outs. NFCI.
We had some similar hasOneUse/isNON_EXTLoad early-outs spread out over different parts of the method - we should pull them all together. Noticed while triaging PR45116
1 parent 8e29b4b commit 1139664

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12536,22 +12536,23 @@ static SDNode *getBuildPairElt(SDNode *N, unsigned i) {
1253612536
SDValue DAGCombiner::CombineConsecutiveLoads(SDNode *N, EVT VT) {
1253712537
assert(N->getOpcode() == ISD::BUILD_PAIR);
1253812538

12539-
LoadSDNode *LD1 = dyn_cast<LoadSDNode>(getBuildPairElt(N, 0));
12540-
LoadSDNode *LD2 = dyn_cast<LoadSDNode>(getBuildPairElt(N, 1));
12539+
auto *LD1 = dyn_cast<LoadSDNode>(getBuildPairElt(N, 0));
12540+
auto *LD2 = dyn_cast<LoadSDNode>(getBuildPairElt(N, 1));
1254112541

1254212542
// A BUILD_PAIR is always having the least significant part in elt 0 and the
1254312543
// most significant part in elt 1. So when combining into one large load, we
1254412544
// need to consider the endianness.
1254512545
if (DAG.getDataLayout().isBigEndian())
1254612546
std::swap(LD1, LD2);
1254712547

12548-
if (!LD1 || !LD2 || !ISD::isNON_EXTLoad(LD1) || !LD1->hasOneUse() ||
12548+
if (!LD1 || !LD2 || !ISD::isNON_EXTLoad(LD1) || !ISD::isNON_EXTLoad(LD2) ||
12549+
!LD1->hasOneUse() || !LD2->hasOneUse() ||
1254912550
LD1->getAddressSpace() != LD2->getAddressSpace())
1255012551
return SDValue();
12552+
1255112553
EVT LD1VT = LD1->getValueType(0);
1255212554
unsigned LD1Bytes = LD1VT.getStoreSize();
12553-
if (ISD::isNON_EXTLoad(LD2) && LD2->hasOneUse() &&
12554-
DAG.areNonVolatileConsecutiveLoads(LD2, LD1, LD1Bytes, 1)) {
12555+
if (DAG.areNonVolatileConsecutiveLoads(LD2, LD1, LD1Bytes, 1)) {
1255512556
Align Alignment = LD1->getAlign();
1255612557
Align NewAlign = DAG.getDataLayout().getABITypeAlign(
1255712558
VT.getTypeForEVT(*DAG.getContext()));

0 commit comments

Comments
 (0)