Skip to content

Commit c7634c1

Browse files
authored
[flang] Disabled hlfir.sum inlining by default. (#119287)
To temporarily address exchange2 perf regression reported in #118556 I disabled the inlining by default, and put it under engineering option `-flang-simplify-hlfir-sum`.
1 parent 9735873 commit c7634c1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ namespace hlfir {
2929
#include "flang/Optimizer/HLFIR/Passes.h.inc"
3030
} // namespace hlfir
3131

32+
static llvm::cl::opt<bool>
33+
simplifySum("flang-simplify-hlfir-sum",
34+
llvm::cl::desc("Expand hlfir.sum into an inline sequence"),
35+
llvm::cl::init(false));
3236
namespace {
3337

3438
class TransposeAsElementalConversion
@@ -349,6 +353,8 @@ class SimplifyHLFIRIntrinsics
349353
// expanding the SUM into a total reduction loop nest
350354
// would avoid creating a temporary for the elemental array expression.
351355
target.addDynamicallyLegalOp<hlfir::SumOp>([](hlfir::SumOp sum) {
356+
if (!simplifySum)
357+
return true;
352358
if (mlir::Value dim = sum.getDim()) {
353359
if (auto dimVal = fir::getIntIfConstant(dim)) {
354360
if (!fir::isa_trivial(sum.getType())) {

flang/test/HLFIR/simplify-hlfir-intrinsics-sum.fir

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: fir-opt --simplify-hlfir-intrinsics %s | FileCheck %s
1+
// RUN: fir-opt --simplify-hlfir-intrinsics -flang-simplify-hlfir-sum %s | FileCheck %s
22

33
// box with known extents
44
func.func @sum_box_known_extents(%arg0: !fir.box<!fir.array<2x3xi32>>) {

0 commit comments

Comments
 (0)