[Mlir-commits] [mlir] [mlir] Add use-vector-alignment flag to ConvertVectorToLLVMPass (PR #137389)

Lily Orth-Smith llvmlistbot at llvm.org
Thu May 1 11:31:25 PDT 2025


================
@@ -0,0 +1,144 @@
+// RUN: mlir-opt %s --convert-vector-to-llvm='use-vector-alignment=0' --split-input-file | FileCheck %s --check-prefix=MEMREF-ALIGN
+// RUN: mlir-opt %s --convert-vector-to-llvm='use-vector-alignment=1' --split-input-file | FileCheck %s --check-prefix=VEC-ALIGN
+
+
+//===----------------------------------------------------------------------===//
+// vector.load
+//===----------------------------------------------------------------------===//
+
+func.func @load(%base : memref<200x100xf32>, %i : index, %j : index) -> vector<8xf32> {
+  %0 = vector.load %base[%i, %j] : memref<200x100xf32>, vector<8xf32>
+  return %0 : vector<8xf32>
+}
+
+// VEC-ALIGN-LABEL: func @load
+// VEC-ALIGN: %[[C100:.*]] = llvm.mlir.constant(100 : index) : i64
+// VEC-ALIGN: %[[MUL:.*]] = llvm.mul %{{.*}}, %[[C100]]  : i64
+// VEC-ALIGN: %[[ADD:.*]] = llvm.add %[[MUL]], %{{.*}}  : i64
+// VEC-ALIGN: %[[GEP:.*]] = llvm.getelementptr %{{.*}}[%[[ADD]]] : (!llvm.ptr, i64) -> !llvm.ptr, f32
+// VEC-ALIGN: llvm.load %[[GEP]] {alignment = 32 : i64} : !llvm.ptr -> vector<8xf32>
+
+// MEMREF-ALIGN-LABEL: func @load
+// MEMREF-ALIGN: %[[C100:.*]] = llvm.mlir.constant(100 : index) : i64
+// MEMREF-ALIGN: %[[MUL:.*]] = llvm.mul %{{.*}}, %[[C100]]  : i64
+// MEMREF-ALIGN: %[[ADD:.*]] = llvm.add %[[MUL]], %{{.*}}  : i64
+// MEMREF-ALIGN: %[[GEP:.*]] = llvm.getelementptr %{{.*}}[%[[ADD]]] : (!llvm.ptr, i64) -> !llvm.ptr, f32
+// MEMREF-ALIGN: llvm.load %[[GEP]] {alignment = 4 : i64} : !llvm.ptr -> vector<8xf32>
----------------
electriclilies wrote:

Thanks for the tips! The file is much smaller now :) 

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


More information about the Mlir-commits mailing list