[flang-commits] [flang] c995038 - [Flang] Call the CSE pass in the pass pipeline

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Thu Jun 23 04:06:04 PDT 2022


Author: Kiran Chandramohan
Date: 2022-06-23T11:04:39Z
New Revision: c995038c27891fd776375bd7f20e16181d86d573

URL: https://github.com/llvm/llvm-project/commit/c995038c27891fd776375bd7f20e16181d86d573
DIFF: https://github.com/llvm/llvm-project/commit/c995038c27891fd776375bd7f20e16181d86d573.diff

LOG: [Flang] Call the CSE pass in the pass pipeline

During the upstreaming process, it was decided to move contents
of the FIR CSE pass to the MLIR pass. Most of the FIR CSE changes
that are used are already moved to the MLIR pass. This patch calls
the MLIR CSE pass in places where the FIR CSE pass is called in the
pass pipeline.

Note: This is part of upstreaming from the fir-dev branch of
https://github.com/flang-compiler/f18-llvm-project.

Reviewed By: awarzynski, clementval

Differential Revision: https://reviews.llvm.org/D128365

Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>
Co-authored-by: Valentin Clement <clementval at gmail.com>
Co-authored-by: Andrzej Warzynski <andrzej.warzynski at arm.com>

Added: 
    

Modified: 
    flang/include/flang/Tools/CLOptions.inc
    flang/test/Driver/mlir-pass-pipeline.f90
    flang/test/Fir/basic-program.fir

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Tools/CLOptions.inc b/flang/include/flang/Tools/CLOptions.inc
index 66e0818ef24df..c432d7d9cb839 100644
--- a/flang/include/flang/Tools/CLOptions.inc
+++ b/flang/include/flang/Tools/CLOptions.inc
@@ -154,10 +154,12 @@ inline void createDefaultFIROptimizerPassPipeline(mlir::PassManager &pm) {
   // simplify the IR
   mlir::GreedyRewriteConfig config;
   config.enableRegionSimplification = false;
+  pm.addPass(mlir::createCSEPass());
   fir::addAVC(pm);
   pm.addNestedPass<mlir::func::FuncOp>(fir::createCharacterConversionPass());
   pm.addPass(mlir::createCanonicalizerPass(config));
   pm.addPass(fir::createSimplifyRegionLitePass());
+  pm.addPass(mlir::createCSEPass());
   fir::addMemoryAllocationOpt(pm);
 
   // The default inliner pass adds the canonicalizer pass with the default
@@ -173,6 +175,7 @@ inline void createDefaultFIROptimizerPassPipeline(mlir::PassManager &pm) {
 
   pm.addPass(mlir::createCanonicalizerPass(config));
   pm.addPass(fir::createSimplifyRegionLitePass());
+  pm.addPass(mlir::createCSEPass());
 }
 
 #if !defined(FLANG_EXCLUDE_CODEGEN)

diff  --git a/flang/test/Driver/mlir-pass-pipeline.f90 b/flang/test/Driver/mlir-pass-pipeline.f90
index ba006f7d7ef02..344520a1511c8 100644
--- a/flang/test/Driver/mlir-pass-pipeline.f90
+++ b/flang/test/Driver/mlir-pass-pipeline.f90
@@ -5,11 +5,13 @@
 
 ! CHECK: Pass statistics report
 
+! CHECK: CSE
 ! CHECK-LABEL: 'func.func' Pipeline
 ! CHECK: ArrayValueCopy
 ! CHECK: CharacterConversion
 ! CHECK: Canonicalizer
 ! CHECK: SimplifyRegionLite
+! CHECK: CSE
 
 ! CHECK-LABEL: 'func.func' Pipeline
 ! CHECK: MemoryAllocationOpt
@@ -21,6 +23,7 @@
 ! CHECK: SCFToControlFlow
 ! CHECK: Canonicalizer
 ! CHECK: SimplifyRegionLite
+! CHECK: CSE
 ! CHECK: BoxedProcedurePass
 
 ! CHECK-LABEL: 'func.func' Pipeline

diff  --git a/flang/test/Fir/basic-program.fir b/flang/test/Fir/basic-program.fir
index b74ebb2a6f6fa..b47ff59007614 100644
--- a/flang/test/Fir/basic-program.fir
+++ b/flang/test/Fir/basic-program.fir
@@ -14,11 +14,13 @@ func.func @_QQmain() {
 
 // PASSES: Pass statistics report
 
+// PASSES: CSE
 // PASSES-LABEL: 'func.func' Pipeline
 // PASSES: ArrayValueCopy
 // PASSES: CharacterConversion
 // PASSES: Canonicalizer
 // PASSES: SimplifyRegionLite
+// PASSES: CSE
 
 // PASSES-LABEL: 'func.func' Pipeline
 // PASSES: MemoryAllocationOpt
@@ -30,6 +32,7 @@ func.func @_QQmain() {
 // PASSES: SCFToControlFlow
 // PASSES: Canonicalizer
 // PASSES: SimplifyRegionLite
+// PASSES: CSE
 // PASSES: BoxedProcedurePass
 
 // PASSES-LABEL: 'func.func' Pipeline


        


More information about the flang-commits mailing list