[Mlir-commits] [mlir] [mlir][Vector] Add vector.extract(vector.shuffle) folder (PR #115105)
Han-Chung Wang
llvmlistbot at llvm.org
Wed Nov 6 09:21:50 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:
Yes, that's what I'm thinking, and I'm wondering if there are other approaches. This approach looks bad to me because it introduces branching in the IR. If we don't have a good plan, perhaps we should drop the `TODO` and make an explicit comment.
https://github.com/llvm/llvm-project/pull/115105
More information about the Mlir-commits
mailing list