[llvm-branch-commits] [llvm] [AMDGPU] Price constant address space memory operations (PR #238840)

Dmitry Sidorov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Nov 5 02:14:33 PST 2026


================
@@ -2172,13 +2172,47 @@ static unsigned getNumMemoryInsts(unsigned Bytes, unsigned MaxBytes,
                                   bool HasDwordx3) {
   unsigned NumInsts = Bytes / MaxBytes;
   unsigned Rem = Bytes % MaxBytes;
-  if (HasDwordx3 && Rem >= 12) {
+  if (HasDwordx3 && Rem % 16 >= 12) {
     ++NumInsts;
     Rem -= 12;
   }
   return NumInsts + llvm::popcount(Rem);
 }
 
+static unsigned getNumWidenedSMEMLoads(unsigned Bytes, uint64_t Alignment,
+                                       unsigned EltBytes, unsigned MaxBytes,
+                                       bool HasDwordx3) {
+  unsigned MaxPiece = EltBytes == 1 ? 8 : MaxBytes;
----------------
MrSidims wrote:

I'd love to avoid it as well, but the helper doesn't exactly follow the legalization as DAG splits these loads and type legalization cost counts registers and not loads. I can still reuse it and drop the helper, but the result would be less precise than the current model.

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


More information about the llvm-branch-commits mailing list