[llvm] [AMDGPU] Fold image load/store with known-zero slice index to non-arrayed form (PR #214744)

Barbara Mitic via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 04:03:08 PDT 2026


================
@@ -251,12 +254,31 @@ simplifyAMDGCNImageIntrinsic(const GCNSubtarget *ST,
     }
   }
 
+  // Optimize the arrayed dim away when the array slice is zero, since slice 0
+  // is the base layer. Restricted to plain image loads and stores for now.
+  const AMDGPU::MIMGDimInfo *DimInfo =
+      AMDGPU::getMIMGDimInfo(ImageDimIntr->Dim);
+  if (!BaseOpcode->Atomic && !BaseOpcode->Sampler && BaseOpcode->Coordinates &&
+      DimInfo->NonArrayDim != ImageDimIntr->Dim) {
+    // Address is [coords..., slice, (fragid)] plus an optional lod/clamp/mip,
----------------
barbara-amd wrote:

Correct - that phrasing was an (incorrect) leftover. Updated to "non-atomic, non-sampled image loads and stores," which matches the guard.

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


More information about the llvm-commits mailing list