[Mlir-commits] [mlir] [mlir][vector][memref] Add `alignment` attribute to memory access ops (PR #144344)

Andrzej WarzyƄski llvmlistbot at llvm.org
Thu Jul 17 08:53:27 PDT 2025


================
@@ -962,6 +962,24 @@ func.func @test_store_zero_results2(%x: i32, %p: memref<i32>) {
 
 // -----
 
+func.func @negative_load_alignment(%memref: memref<4xi32>) {
+  %c0 = arith.constant 0 : index
+  // expected-error @below {{'memref.load' op attribute 'alignment' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive and whose value is a power of two > 0}}
+  %val = memref.load %memref[%c0] { alignment = -1 } : memref<4xi32>
+  return
+}
+
+// -----
+
+func.func @non_power_of_2_store_alignment(%memref: memref<4xi32>, %val: i32) {
+  %c0 = arith.constant 0 : index
+  // expected-error @below {{'memref.store' op attribute 'alignment' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive and whose value is a power of two > 0}}
+  memref.store %val, %memref[%c0] { alignment = 3 } : memref<4xi32>
+  return
+}
----------------
banach-space wrote:

OK, thanks for clarifying. 

This is a bit confusing, we recommend the leading `negative` prefix to label "negative" (i.e. failing) tests:
* https://mlir.llvm.org/getting_started/TestingGuide/#test-naming-convention

How about:
* `@negative_load_alignmen` -> `@invalid_load_alignment`
* `@non_power_of_2_store_alignment` -> `@invalid_store_alignment`

?

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


More information about the Mlir-commits mailing list