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

Han-Chung Wang llvmlistbot at llvm.org
Wed Nov 6 16:41:41 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();
----------------
hanhanW wrote:

I see, thanks! Yes, I also think that it is not a good canonical form. It's good that we're on the same page..

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


More information about the Mlir-commits mailing list