[Mlir-commits] [mlir] [MLIR][AMDGPU] Add a wrapper for global LDS load intrinsics in AMDGPU (PR #133498)

Jakub Kuderski llvmlistbot at llvm.org
Tue Apr 8 07:22:41 PDT 2025


================
@@ -1031,11 +1031,14 @@ struct GatherToLDSOpLowering : public ConvertOpToLLVMPattern<GatherToLDSOp> {
     // augment it to transfer multiple elements per thread by issuing multiple
     // `global_load_lds` instructions.
     Type transferType = op.getTransferType();
-    size_t loadWidth = transferType.getIntOrFloatBitWidth() / 8;
-    if (auto transferVectorType = dyn_cast<VectorType>(transferType)) {
-      loadWidth = transferVectorType.getNumElements() *
-                  (transferVectorType.getElementTypeBitWidth() / 8);
-    }
+    size_t loadWidth = [&]() -> size_t {
+      if (auto transferVectorType = dyn_cast<VectorType>(transferType)) {
+        return transferVectorType.getNumElements() *
+               (transferVectorType.getElementTypeBitWidth() / 8);
+      } else {
+        return transferType.getIntOrFloatBitWidth() / 8;
+      }
----------------
kuhar wrote:

no else after return: https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return

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


More information about the Mlir-commits mailing list