[llvm] GlobalISel: Match loads by pointer operand in CombinerHelper (PR #216672)
Tim Gymnich via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 17 04:12:35 PDT 2026
================
@@ -1153,24 +1154,21 @@ bool CombinerHelper::matchSextInRegOfLoad(
if (!isPowerOf2_32(NewSizeBits))
return false;
- const MachineMemOperand &MMO = LoadDef->getMMO();
- LegalityQuery::MemDesc MMDesc(MMO);
+ LegalityQuery::MemDesc MMDesc(*MMO);
// Don't modify the memory access size if this is atomic/volatile, but we can
// still adjust the opcode to indicate the high bit behavior.
- if (LoadDef->isSimple())
+ if (!MMO->isAtomic() && !MMO->isVolatile())
MMDesc.MemoryTy = LLT::scalar(NewSizeBits);
else if (MemBits > NewSizeBits || MemBits == RegTy.getSizeInBits())
return false;
// TODO: Could check if it's legal with the reduced or original memory size.
- if (!isLegalOrBeforeLegalizer({TargetOpcode::G_SEXTLOAD,
- {MRI.getType(LoadDef->getDstReg()),
- MRI.getType(LoadDef->getPointerReg())},
- {MMDesc}}))
+ if (!isLegalOrBeforeLegalizer(
+ {TargetOpcode::G_SEXTLOAD, {RegTy, MRI.getType(PtrReg)}, {MMDesc}}))
return false;
- MatchInfo = std::make_tuple(LoadDef->getDstReg(), NewSizeBits);
+ MatchInfo = std::make_tuple(SrcReg, NewSizeBits);
----------------
tgymnich wrote:
shouldn't this be `PtrReg`?
```suggestion
MatchInfo = std::make_tuple(PtrReg, NewSizeBits);
```
https://github.com/llvm/llvm-project/pull/216672
More information about the llvm-commits
mailing list