[Mlir-commits] [mlir] [mlir][Vector] Add `vector.shuffle` fold for poison inputs (PR #125608)
Jakub Kuderski
llvmlistbot at llvm.org
Wed Feb 5 07:43:07 PST 2025
================
@@ -2684,25 +2682,45 @@ OpFoldResult vector::ShuffleOp::fold(FoldAdaptor adaptor) {
if (!v1Attr || !v2Attr)
return {};
+ // Fold shuffle poison, poison -> poison.
+ bool isV1Poison = isa<ub::PoisonAttr>(v1Attr);
+ bool isV2Poison = isa<ub::PoisonAttr>(v2Attr);
+ if (isV1Poison && isV2Poison)
+ return ub::PoisonAttr::get(getContext());
+
// Only support 1-D for now to avoid complicated n-D DenseElementsAttr
// manipulation.
if (v1Type.getRank() != 1)
return {};
- int64_t v1Size = v1Type.getDimSize(0);
+ // Poison input attributes need special handling as they are not
+ // DenseElementsAttr. If an index is poison, we select the first element of
+ // the first non-poison input.
----------------
kuhar wrote:
> Sure, but we are selecting a specific "arbitrary value" :)
??? In this context, arbitrary is synonymous to non-deterministics, as in: absolutely any value will do and the choice doesn't have to be fair by any definition of fair.
https://github.com/llvm/llvm-project/pull/125608
More information about the Mlir-commits
mailing list