[llvm] [AMDGPU] Reject image-load merges when either op has TFE/LWE (PR #210583)

Piotr Sobczak via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 20 09:00:06 PDT 2026


================
@@ -2676,6 +2676,17 @@ SILoadStoreOptimizer::collectMergeableInsts(
       }
     }
 
+    // Do not merge MIMG instructions with tfe or lwe enabled.
+    // TFE/LWE add a status result that the image merge path does not model.
+    if (InstClass == MIMG) {
+      const auto *TFEOp =
+          TII->getNamedOperand(MI, AMDGPU::OpName::tfe);
+      const auto *LWEOp =
+          TII->getNamedOperand(MI, AMDGPU::OpName::lwe);
+      if ((TFEOp && TFEOp->getImm()) || (LWEOp && LWEOp->getImm()))
----------------
piotrAMD wrote:

Nit: Better to split the if, so TFE is checked right after TFEOp - no need to check LWEOp if TFE is already set.

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


More information about the llvm-commits mailing list