Skip to content

Commit 7e7ce07

Browse files
committed
improved needsConstrainedOpcode function to check for a valid MMO.
1 parent e8e3ce0 commit 7e7ce07

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,9 +1712,11 @@ MachineBasicBlock::iterator SILoadStoreOptimizer::mergeFlatStorePair(
17121712
}
17131713

17141714
static bool needsConstrainedOpcode(const GCNSubtarget &STM,
1715-
const MachineMemOperand *MMO,
1715+
ArrayRef<MachineMemOperand *> MMOs,
17161716
unsigned Width) {
1717-
return STM.isXNACKEnabled() && MMO->getAlign().value() < Width * 4;
1717+
// Conservatively returns true if not found the MMO.
1718+
return STM.isXNACKEnabled() &&
1719+
(MMOs.size() != 1 || MMOs[0]->getAlign().value() < Width * 4);
17181720
}
17191721

17201722
unsigned SILoadStoreOptimizer::getNewOpcode(const CombineInfo &CI,
@@ -1737,8 +1739,8 @@ unsigned SILoadStoreOptimizer::getNewOpcode(const CombineInfo &CI,
17371739
case S_BUFFER_LOAD_IMM: {
17381740
// If XNACK is enabled, use the constrained opcodes when the first load is
17391741
// under-aligned.
1740-
const MachineMemOperand *MMO = *CI.I->memoperands_begin();
1741-
bool NeedsConstrainedOpc = MMO && needsConstrainedOpcode(*STM, MMO, Width);
1742+
bool NeedsConstrainedOpc =
1743+
needsConstrainedOpcode(*STM, CI.I->memoperands(), Width);
17421744
switch (Width) {
17431745
default:
17441746
return 0;
@@ -1759,8 +1761,8 @@ unsigned SILoadStoreOptimizer::getNewOpcode(const CombineInfo &CI,
17591761
case S_BUFFER_LOAD_SGPR_IMM: {
17601762
// If XNACK is enabled, use the constrained opcodes when the first load is
17611763
// under-aligned.
1762-
const MachineMemOperand *MMO = *CI.I->memoperands_begin();
1763-
bool NeedsConstrainedOpc = MMO && needsConstrainedOpcode(*STM, MMO, Width);
1764+
bool NeedsConstrainedOpc =
1765+
needsConstrainedOpcode(*STM, CI.I->memoperands(), Width);
17641766
switch (Width) {
17651767
default:
17661768
return 0;
@@ -1781,8 +1783,8 @@ unsigned SILoadStoreOptimizer::getNewOpcode(const CombineInfo &CI,
17811783
case S_LOAD_IMM: {
17821784
// If XNACK is enabled, use the constrained opcodes when the first load is
17831785
// under-aligned.
1784-
const MachineMemOperand *MMO = *CI.I->memoperands_begin();
1785-
bool NeedsConstrainedOpc = MMO && needsConstrainedOpcode(*STM, MMO, Width);
1786+
bool NeedsConstrainedOpc =
1787+
needsConstrainedOpcode(*STM, CI.I->memoperands(), Width);
17861788
switch (Width) {
17871789
default:
17881790
return 0;

0 commit comments

Comments
 (0)