[Mlir-commits] [mlir] [mlir][Vector] Add support for poison indices to `Extract/IndexOp` (PR #123488)

Diego Caballero llvmlistbot at llvm.org
Tue Jan 28 11:16:58 PST 2025


================
@@ -26,6 +26,15 @@ def Vector_Dialect : Dialect {
 
 // Base class for Vector dialect ops.
 class Vector_Op<string mnemonic, list<Trait> traits = []> :
-    Op<Vector_Dialect, mnemonic, traits>;
+    Op<Vector_Dialect, mnemonic, traits> {
+
+  // Includes definitions for operations that support the use of poison values
+  // within positive index ranges.
+  code extraPoisonClassDeclaration = [{
+    // Integer to represent a poison index within a static and positive integer
+    // range.
+    static constexpr int64_t kPoisonIndex = -1;
+  }];
----------------
dcaballe wrote:

`-1` is the value used by LLVM so I'm just sticking to that to prevent unnecessary conversion bugs. We use numeric_limits::min for dynamic shapes so no conflict there. I can't think of an alternative that would make a difference. Any negative number would lead to a verification error or UB so... 

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


More information about the Mlir-commits mailing list