aboutsummaryrefslogtreecommitdiff
path: root/mlir/test/Examples
diff options
context:
space:
mode:
authorValentin Clement <clementval@gmail.com>2022-04-07 10:06:50 +0200
committerValentin Clement <clementval@gmail.com>2022-04-07 10:08:55 +0200
commit02da9643506dee4a82353e0f911513279634d846 (patch)
tree51889f0a2150283dee322514730d868e1a538dd6 /mlir/test/Examples
parent842d0bf93176b9cb1e0d6894a2bbfb32ad33ebb8 (diff)
downloadllvm-02da9643506dee4a82353e0f911513279634d846.zip
llvm-02da9643506dee4a82353e0f911513279634d846.tar.gz
llvm-02da9643506dee4a82353e0f911513279634d846.tar.bz2
[mlir][CSE] Remove duplicated operations with MemRead side-effect
This patch enhances the CSE pass to deal with simple cases of duplicated operations with MemoryEffects. It allows the CSE pass to remove safely duplicate operations with the MemoryEffects::Read that have no other side-effecting operations in between. Other MemoryEffects::Read operation are allowed. The use case is pretty simple so far so we can build on top of it to add more features. This patch is also meant to avoid a dedicated CSE pass in FIR and was brought together afetr discussion on https://reviews.llvm.org/D112711. It does not currently cover the full range of use cases described in https://reviews.llvm.org/D112711 but the idea is to gradually enhance the MLIR CSE pass to handle common use cases that can be used by other dialects. This patch takes advantage of the new CSE capabilities in Fir. Reviewed By: mehdi_amini, rriddle, schweitz Differential Revision: https://reviews.llvm.org/D122801
Diffstat (limited to 'mlir/test/Examples')
-rw-r--r--mlir/test/Examples/Toy/Ch5/affine-lowering.mlir3
-rw-r--r--mlir/test/Examples/Toy/Ch6/affine-lowering.mlir3
-rw-r--r--mlir/test/Examples/Toy/Ch7/affine-lowering.mlir3
3 files changed, 3 insertions, 6 deletions
diff --git a/mlir/test/Examples/Toy/Ch5/affine-lowering.mlir b/mlir/test/Examples/Toy/Ch5/affine-lowering.mlir
index ad99faa..034474d 100644
--- a/mlir/test/Examples/Toy/Ch5/affine-lowering.mlir
+++ b/mlir/test/Examples/Toy/Ch5/affine-lowering.mlir
@@ -32,8 +32,7 @@ toy.func @main() {
// CHECK: affine.for [[VAL_12:%.*]] = 0 to 3 {
// CHECK: affine.for [[VAL_13:%.*]] = 0 to 2 {
// CHECK: [[VAL_14:%.*]] = affine.load [[VAL_7]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64>
-// CHECK: [[VAL_15:%.*]] = affine.load [[VAL_7]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64>
-// CHECK: [[VAL_16:%.*]] = arith.mulf [[VAL_14]], [[VAL_15]] : f64
+// CHECK: [[VAL_16:%.*]] = arith.mulf [[VAL_14]], [[VAL_14]] : f64
// CHECK: affine.store [[VAL_16]], [[VAL_6]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64>
// CHECK: toy.print [[VAL_6]] : memref<3x2xf64>
// CHECK: memref.dealloc [[VAL_8]] : memref<2x3xf64>
diff --git a/mlir/test/Examples/Toy/Ch6/affine-lowering.mlir b/mlir/test/Examples/Toy/Ch6/affine-lowering.mlir
index ca056b4..51dedaf 100644
--- a/mlir/test/Examples/Toy/Ch6/affine-lowering.mlir
+++ b/mlir/test/Examples/Toy/Ch6/affine-lowering.mlir
@@ -32,8 +32,7 @@ toy.func @main() {
// CHECK: affine.for [[VAL_12:%.*]] = 0 to 3 {
// CHECK: affine.for [[VAL_13:%.*]] = 0 to 2 {
// CHECK: [[VAL_14:%.*]] = affine.load [[VAL_7]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64>
-// CHECK: [[VAL_15:%.*]] = affine.load [[VAL_7]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64>
-// CHECK: [[VAL_16:%.*]] = arith.mulf [[VAL_14]], [[VAL_15]] : f64
+// CHECK: [[VAL_16:%.*]] = arith.mulf [[VAL_14]], [[VAL_14]] : f64
// CHECK: affine.store [[VAL_16]], [[VAL_6]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64>
// CHECK: toy.print [[VAL_6]] : memref<3x2xf64>
// CHECK: memref.dealloc [[VAL_8]] : memref<2x3xf64>
diff --git a/mlir/test/Examples/Toy/Ch7/affine-lowering.mlir b/mlir/test/Examples/Toy/Ch7/affine-lowering.mlir
index 60d466e..3cefd0e 100644
--- a/mlir/test/Examples/Toy/Ch7/affine-lowering.mlir
+++ b/mlir/test/Examples/Toy/Ch7/affine-lowering.mlir
@@ -32,8 +32,7 @@ toy.func @main() {
// CHECK: affine.for [[VAL_12:%.*]] = 0 to 3 {
// CHECK: affine.for [[VAL_13:%.*]] = 0 to 2 {
// CHECK: [[VAL_14:%.*]] = affine.load [[VAL_7]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64>
-// CHECK: [[VAL_15:%.*]] = affine.load [[VAL_7]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64>
-// CHECK: [[VAL_16:%.*]] = arith.mulf [[VAL_14]], [[VAL_15]] : f64
+// CHECK: [[VAL_16:%.*]] = arith.mulf [[VAL_14]], [[VAL_14]] : f64
// CHECK: affine.store [[VAL_16]], [[VAL_6]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64>
// CHECK: toy.print [[VAL_6]] : memref<3x2xf64>
// CHECK: memref.dealloc [[VAL_8]] : memref<2x3xf64>