[Mlir-commits] [mlir] [mlir][spirv] Support poison index when converting vector.insert/extract (PR #125560)
Andrea Faulds
llvmlistbot at llvm.org
Tue Feb 4 07:11:38 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) {
----------------
andfau-amd wrote:
There's a separate `kPoisonIndex` constants for `ExtractOp` and `InsertOp`, and it feels unclean to assume they have the same value, even if that happens to be the case in practice.
https://github.com/llvm/llvm-project/pull/125560
More information about the Mlir-commits
mailing list