Skip to content

Commit 06eb79b

Browse files
jgu222igcbot
authored andcommitted
Early exit if no load/store to merge
If the number of unmerged loads/stores are less than 2, exit testing loops to save compiling time, as there are no merging candidates.
1 parent bdbd756 commit 06eb79b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

IGC/Compiler/CISACodeGen/MemOpt.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,10 +3308,12 @@ void LdStCombine::createBundles(BasicBlock* BB, InstAndOffsetPairs& Stores)
33083308
}
33093309
const AddressModel AddrModel = lsi0->getAddressModel(m_CGC);
33103310

3311-
// Starting from the largest alignment.
3311+
// Starting from the largest alignment (favor larger alignment)
33123312
const uint32_t bundleAlign[] = { 8, 4, 1 };
33133313
const uint32_t aligns = (int)(sizeof(bundleAlign)/sizeof(bundleAlign[0]));
3314-
for (int ix = 0; ix < aligns; ++ix)
3314+
// keep track of the number of unmerged loads
3315+
uint32_t numRemainingLdSt = SZ;
3316+
for (int ix = 0; ix < aligns && numRemainingLdSt > 1; ++ix)
33153317
{
33163318
const uint32_t theAlign = bundleAlign[ix];
33173319

@@ -3447,6 +3449,11 @@ void LdStCombine::createBundles(BasicBlock* BB, InstAndOffsetPairs& Stores)
34473449
setVisited(tlsi.Inst);
34483450
}
34493451
i = e + 1;
3452+
numRemainingLdSt -= bundle_nelts;
3453+
if (numRemainingLdSt < 2) {
3454+
// No enough loads/stores to merge
3455+
break;
3456+
}
34503457
}
34513458
else {
34523459
++i;

0 commit comments

Comments
 (0)