[llvm] [AMDGPU][SILoadStoreOptimizer] Try to find common base for L/Ss with 0 offset (PR #71126)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 19 04:12:36 PDT 2024
================
@@ -2034,17 +2036,20 @@ void SILoadStoreOptimizer::processBaseWithConstOffset(const MachineOperand &Base
if (Src0->isImm())
std::swap(Src0, Src1);
- if (!Src1->isImm())
- return;
-
- uint64_t Offset1 = Src1->getImm();
- BaseHi = *Src0;
+ // If w,e are unable to find an offset by looking through BaseHi, then default
+ // to 0 offset with BaseHi as the base.
+ int64_t Offset1 = 0;
+ BaseHi = Def->getOperand(3);
+ if (Src1->isImm()) {
+ Offset1 = Src1->getImm();
+ BaseHi = *Src0;
+ }
Addr.Base.LoReg = BaseLo.getReg();
Addr.Base.HiReg = BaseHi.getReg();
Addr.Base.LoSubReg = BaseLo.getSubReg();
Addr.Base.HiSubReg = BaseHi.getSubReg();
- Addr.Offset = (*Offset0P & 0x00000000ffffffff) | (Offset1 << 32);
+ Addr.Offset = (Offset0P & 0x00000000ffffffff) | (Offset1 << 32);
----------------
arsenm wrote:
Offset1 may hit signed overflow, needs to cast to unsigned. Use Make_64
https://github.com/llvm/llvm-project/pull/71126
More information about the llvm-commits
mailing list