[Mlir-commits] [mlir] [mlir][vector] Add opt-in `inbounds`/`nneg` flags to `vector.load`/`vector.store` (PR #202118)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Wed Jun 17 00:14:10 PDT 2026
================
@@ -1805,6 +1805,23 @@ func.func @store_with_alignment(%memref : memref<200x100xf32>, %i : index, %j :
// -----
+//===----------------------------------------------------------------------===//
+// vector.load / vector.store with --enable-gep-inbounds-nuw pass option
+//===----------------------------------------------------------------------===//
+
+// RUN: mlir-opt %s -convert-vector-to-llvm='enable-gep-inbounds-nuw=1' -split-input-file | FileCheck %s --check-prefix=CHECK-INBOUNDS
----------------
banach-space wrote:
We always put `RUN` lines at the top :)
Also, instead of writing a dedicated test, you can re-use one of the existing tests for `vector.load` + `vector.store` and have duplicate `CHECK` lines, see e.g. [mlir/test/Conversion/VectorToLLVM/vector-reduction-to-llvm.mlir](https://github.com/llvm/llvm-project/blob/f6e4e71fcdbff98cb060f87695c75f00b43bf918/mlir/test/Conversion/VectorToLLVM/vector-reduction-to-llvm.mlir).
To further improve `CHECK` lines re-use, you can do something like this (very simplified, pseudo-example):
```
// RUN: mlir-opt %s -convert-vector-to-llvm -split-input-file | FileCheck %s --check-prefixes=ALL,DEFAULT
// RUN: mlir-opt %s -convert-vector-to-llvm='enable-gep-inbounds-nuw=1' -split-input-file | FileCheck %s --check-prefixes=ALL,INBOUNDS
func.func @store_index(%memref : memref<200x100xindex>, %i : index, %j : index) {
%val = arith.constant dense<11> : vector<4xindex>
vector.store %val, %memref[%i, %j] : memref<200x100xindex>, vector<4xindex>
return
}
// ALL-LABEL: func @store_index
// DEFAULT: llvm.getelementptr (...)
// INBOUNDS: llvm.getelementptr inbounds|nuw (...)
```
Finally, to reduce noise in this file, I'd move all tests for `vector.load` + `vector.store` from this file to e.g. `mlir/test/Conversion/VectorToLLVM/vector-load-store-to-llvm.mlir` :)
That's a bit of a refactor and extra work, but we'll end up with a bit cleaner and clearer set-up. Would you be willing to move the tests? If you are busy, I can suggest a less labour intensive update :)
Thank you!
https://github.com/llvm/llvm-project/pull/202118
More information about the Mlir-commits
mailing list