[Mlir-commits] [mlir] [mlir][Vector] Add vector.extract(vector.shuffle) folder (PR #115105)

Diego Caballero llvmlistbot at llvm.org
Wed Nov 6 15:29:23 PST 2024


================
@@ -1705,6 +1705,46 @@ static Value foldExtractFromBroadcast(ExtractOp extractOp) {
   return extractOp.getResult();
 }
 
+/// Fold extractOp coming from ShuffleOp.
+///
+/// Example:
+///
+///   %shuffle = vector.shuffle %a, %b [0, 8, 7, 15]
+///     : vector<8xf32>, vector<8xf32>
+///   %extract = vector.extract %shuffle[3] : f32 from vector<4xf32>
+/// ->
+///   %extract = vector.extract %b[7] : f32 from vector<4xf32>
+///
+static Value foldExtractFromShuffle(ExtractOp extractOp) {
+  // TODO: Canonicalization for dynamic position not implemented yet.
+  if (extractOp.hasDynamicPosition())
+    return Value();
----------------
dcaballe wrote:

The TODO is inherited from similar canonicalizations. Not sure if branches but at least quite some instructions, including more vector extracts and select ops. Definitely not a good canonical form for dynamic cases.

https://github.com/llvm/llvm-project/pull/115105


More information about the Mlir-commits mailing list