diff --git a/flang/include/flang/Tools/CLOptions.inc b/flang/include/flang/Tools/CLOptions.inc --- a/flang/include/flang/Tools/CLOptions.inc +++ b/flang/include/flang/Tools/CLOptions.inc @@ -165,9 +165,11 @@ pm.addNestedPass(fir::createCharacterConversionPass()); pm.addPass(mlir::createCanonicalizerPass(config)); pm.addPass(fir::createSimplifyRegionLitePass()); - // Algebraic simplifications may increase code size. - if (optLevel.isOptimizingForSpeed()) + if (optLevel.isOptimizingForSpeed()) { + // These passes may increase code size. + pm.addPass(fir::createSimplifyIntrinsicsPass()); pm.addPass(fir::createAlgebraicSimplificationPass(config)); + } pm.addPass(mlir::createCSEPass()); fir::addMemoryAllocationOpt(pm); diff --git a/flang/test/Driver/bbc-mlir-pass-pipeline.f90 b/flang/test/Driver/bbc-mlir-pass-pipeline.f90 --- a/flang/test/Driver/bbc-mlir-pass-pipeline.f90 +++ b/flang/test/Driver/bbc-mlir-pass-pipeline.f90 @@ -23,6 +23,7 @@ ! CHECK-NEXT: Canonicalizer ! CHECK-NEXT: SimplifyRegionLite +! CHECK-NEXT: SimplifyIntrinsics ! CHECK-NEXT: AlgebraicSimplification ! CHECK-NEXT: CSE ! CHECK-NEXT: (S) 0 num-cse'd - Number of operations CSE'd diff --git a/flang/test/Driver/mlir-pass-pipeline.f90 b/flang/test/Driver/mlir-pass-pipeline.f90 --- a/flang/test/Driver/mlir-pass-pipeline.f90 +++ b/flang/test/Driver/mlir-pass-pipeline.f90 @@ -26,6 +26,7 @@ ! ALL-NEXT: Canonicalizer ! ALL-NEXT: SimplifyRegionLite +! O2-NEXT: SimplifyIntrinsics ! O2-NEXT: AlgebraicSimplification ! ALL-NEXT: CSE ! ALL-NEXT: (S) 0 num-cse'd - Number of operations CSE'd diff --git a/flang/test/Fir/basic-program.fir b/flang/test/Fir/basic-program.fir --- a/flang/test/Fir/basic-program.fir +++ b/flang/test/Fir/basic-program.fir @@ -26,6 +26,7 @@ // PASSES-NEXT: Canonicalizer // PASSES-NEXT: SimplifyRegionLite +// PASSES-NEXT: SimplifyIntrinsics // PASSES-NEXT: AlgebraicSimplification // PASSES-NEXT: CSE // PASSES-NEXT: (S) 0 num-cse'd - Number of operations CSE'd