[Mlir-commits] [mlir] [mlir][Vector] Fix vector.insert folder for scalar to 0-d inserts (PR #113828)
Jakub Kuderski
llvmlistbot at llvm.org
Sun Oct 27 16:17:00 PDT 2024
================
@@ -2951,11 +2951,11 @@ void InsertOp::getCanonicalizationPatterns(RewritePatternSet &results,
InsertOpConstantFolder>(context);
}
-// Eliminates insert operations that produce values identical to their source
-// value. This happens when the source and destination vectors have identical
-// sizes.
OpFoldResult vector::InsertOp::fold(FoldAdaptor adaptor) {
- if (getNumIndices() == 0)
+ // Fold "vector.insert %v, %dest [] : vector<2x2xf32> from vector<2x2xf32>" to
+ // %v. Note: Do not fold "vector.insert %v, %dest [] : f32 into vector<f32>"
+ // (type mismatch).
+ if (getNumIndices() == 0 && getSourceType() == getResult().getType())
----------------
kuhar wrote:
```suggestion
if (getNumIndices() == 0 && getSourceType() == getType())
```
https://github.com/llvm/llvm-project/pull/113828
More information about the Mlir-commits
mailing list