[Mlir-commits] [mlir] [mlir][vector] Add alignment attribute to vector operations. (PR #152507)

Andrzej WarzyƄski llvmlistbot at llvm.org
Mon Aug 11 02:12:33 PDT 2025


================
@@ -1470,6 +1470,24 @@ func.func @gather_pass_thru_type_mismatch(%base: memref<?xf32>, %indices: vector
 
 // -----
 
+func.func @gather_invalid_alignment(%base: memref<16xf32>, %indices: vector<16xi32>,
+                                %mask: vector<16xi1>, %pass_thru: vector<16xf32>, %c0 : index) {
+  // expected-error at +2 {{'vector.gather' 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}}
+  %0 = vector.gather %base[%c0][%indices], %mask, %pass_thru
+    { alignment = -1 } : memref<16xf32>, vector<16xi32>, vector<16xi1>, vector<16xf32> into vector<16xf32>
+}
+
+// -----
+
+func.func @gather_invalid_alignment(%base: memref<16xf32>, %indices: vector<16xi32>,
+                                %mask: vector<16xi1>, %pass_thru: vector<16xf32>, %c0 : index) {
+  // expected-error at +2 {{'vector.gather' 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}}
+  %0 = vector.gather %base[%c0][%indices], %mask, %pass_thru
+    { alignment = 3 } : memref<16xf32>, vector<16xi32>, vector<16xi1>, vector<16xf32> into vector<16xf32>
+}
----------------
banach-space wrote:

[nit] This or something similar to more visible highlight the difference between these cases. Similar suggestion for other tests. Thanks!

```suggestion
func.func @gather_negative_alignment(%base: memref<16xf32>, %indices: vector<16xi32>,
                                %mask: vector<16xi1>, %pass_thru: vector<16xf32>, %c0 : index) {
  // expected-error at +2 {{'vector.gather' 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}}
  %0 = vector.gather %base[%c0][%indices], %mask, %pass_thru
    { alignment = -1 } : memref<16xf32>, vector<16xi32>, vector<16xi1>, vector<16xf32> into vector<16xf32>
}

// -----

func.func @gather_non_pow_of_2_alignment(%base: memref<16xf32>, %indices: vector<16xi32>,
                                %mask: vector<16xi1>, %pass_thru: vector<16xf32>, %c0 : index) {
  // expected-error at +2 {{'vector.gather' 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}}
  %0 = vector.gather %base[%c0][%indices], %mask, %pass_thru
    { alignment = 3 } : memref<16xf32>, vector<16xi32>, vector<16xi1>, vector<16xf32> into vector<16xf32>
}
```

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


More information about the Mlir-commits mailing list