[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:35:46 PST 2025
================
@@ -154,14 +174,26 @@ struct VectorExtractOpConvert final
}
if (std::optional<int64_t> id =
- getConstantIntValue(extractOp.getMixedPosition()[0]))
- rewriter.replaceOpWithNewOp<spirv::CompositeExtractOp>(
- extractOp, dstType, adaptor.getVector(),
- rewriter.getI32ArrayAttr(id.value()));
- else
+ getConstantIntValue(extractOp.getMixedPosition()[0])) {
+ // TODO: It would be better to apply the ub.poison folding for this case
+ // unconditionally, and have a specific SPIR-V lowering for it,
+ // rather than having to handle it here.
----------------
andfau-amd wrote:
Ahh, no: `legalizeWithFold` calls `tryFold`, `tryFold` calls `ExtractOp::fold`, `ExtractOp::fold` calls `foldPoisonIndexInsertExtractOp`, and a poison attribute is generated, but then `tryFold` calls `VectorDialect::materializeConstant` and somewhere in there, the poison is rejected. Apparently, `VectorDialect::materializeConstant` calls `arith::ConstantOp::materialize`; maybe I just need to add a path to it that calls the UB dialect equivalent?
https://github.com/llvm/llvm-project/pull/125560
More information about the Mlir-commits
mailing list