[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
Thu Nov 2 17:13:02 PDT 2023


================
@@ -2034,17 +2040,24 @@ void SILoadStoreOptimizer::processBaseWithConstOffset(const MachineOperand &Base
   if (Src0->isImm())
     std::swap(Src0, Src1);
 
-  if (!Src1->isImm())
-    return;
+  std::optional<uint64_t> Offset1;
+  if (Src1->isImm()) {
+    Offset1 = Src1->getImm();
+    BaseHi = *Src0;
+  }
 
-  uint64_t Offset1 = Src1->getImm();
-  BaseHi = *Src0;
+  // We are unable to find an offset by looking through BaseHi. Try using 0
+  // offset with BaseHi as the base.
+  if (!Offset1) {
+    Offset1 = 0;
----------------
arsenm wrote:

Don't see the point of Offset1 being optional if you just immediately make it 0 anyway

https://github.com/llvm/llvm-project/pull/71126


More information about the llvm-commits mailing list