[Mlir-commits] [mlir] [mli][vector] canonicalize vector.from_elements from ascending extracts (PR #139819)
Andrzej Warzyński
llvmlistbot at llvm.org
Fri May 16 09:41:31 PDT 2025
================
@@ -2385,9 +2386,105 @@ static LogicalResult rewriteFromElementsAsSplat(FromElementsOp fromElementsOp,
return success();
}
+/// Rewrite vector.from_elements as vector.shape_cast, if possible.
+///
+/// Example:
+/// %0 = vector.extract %source[0, 0] : i8 from vector<1x2xi8>
+/// %1 = vector.extract %source[0, 1] : i8 from vector<1x2xi8>
+/// %2 = vector.from_elements %0, %1 : vector<2xi8>
+///
+/// becomes
+/// %2 = vector.shape_cast %source : vector<1x2xi8> to vector<2xi8>
+///
+/// The requirements for this to be valid are
+/// i) source and from_elements result have the same number of elements,
----------------
banach-space wrote:
[nit] Otherwise it's not clear what `source` and `from_elements` are. Perhaps there's better way to clarify 🤔
```suggestion
/// i) vector.extract and vector.from_elements result have the same number of elements,
```
https://github.com/llvm/llvm-project/pull/139819
More information about the Mlir-commits
mailing list