[Mlir-commits] [mlir] [mlir][spirv] Support poison index when converting vector.insert/extract (PR #125560)
Jakub Kuderski
llvmlistbot at llvm.org
Tue Feb 4 08:50:08 PST 2025
================
@@ -137,6 +137,26 @@ struct VectorBroadcastConvert final
}
};
+// SPIR-V does not have a concept of a poison index for certain instructions,
+// which creates a UB hazard when lowering from otherwise equivalent Vector
+// dialect instructions, because this index will be considered out-of-bounds.
+// To avoid this, this function implements a dynamic sanitization, arbitrarily
+// choosing to replace the poison index with index 0 (always in-bounds).
+static Value sanitizeDynamicIndex(ConversionPatternRewriter &rewriter,
+ Location loc, Value dynamicIndex,
+ int64_t kPoisonIndex) {
----------------
kuhar wrote:
I think that both are defined here: https://github.com/llvm/llvm-project/blob/84fbed86ffcb97c24f9294a204c60da5444b8646/mlir/include/mlir/Dialect/Vector/IR/Vector.td#L36 but, like you noted, this is not something we can universally query. Let's leave it as-is. Thanks!
https://github.com/llvm/llvm-project/pull/125560
More information about the Mlir-commits
mailing list