[flang-commits] [flang] [flang] Disabled hlfir.sum inlining by default. (PR #119287)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Mon Dec 9 15:28:45 PST 2024
https://github.com/vzakhari created https://github.com/llvm/llvm-project/pull/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`.
>From 3c22dacb8b0fddc78666477cb519fbccba434515 Mon Sep 17 00:00:00 2001
From: Slava Zakharin <szakharin at nvidia.com>
Date: Mon, 9 Dec 2024 15:25:47 -0800
Subject: [PATCH] [flang] Disabled hlfir.sum inlining by default.
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`.
---
.../Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp | 6 ++++++
flang/test/HLFIR/simplify-hlfir-intrinsics-sum.fir | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp b/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp
index ace63a970db932..b61f9767ccc2b8 100644
--- a/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp
+++ b/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp
@@ -29,6 +29,10 @@ namespace hlfir {
#include "flang/Optimizer/HLFIR/Passes.h.inc"
} // namespace hlfir
+static llvm::cl::opt<bool>
+ simplifySum("flang-simplify-hlfir-sum",
+ llvm::cl::desc("Expand hlfir.sum into an inline sequence"),
+ llvm::cl::init(false));
namespace {
class TransposeAsElementalConversion
@@ -349,6 +353,8 @@ class SimplifyHLFIRIntrinsics
// expanding the SUM into a total reduction loop nest
// would avoid creating a temporary for the elemental array expression.
target.addDynamicallyLegalOp<hlfir::SumOp>([](hlfir::SumOp sum) {
+ if (!simplifySum)
+ return true;
if (mlir::Value dim = sum.getDim()) {
if (auto dimVal = fir::getIntIfConstant(dim)) {
if (!fir::isa_trivial(sum.getType())) {
diff --git a/flang/test/HLFIR/simplify-hlfir-intrinsics-sum.fir b/flang/test/HLFIR/simplify-hlfir-intrinsics-sum.fir
index 313e54d5d0c4af..54a592a66670f1 100644
--- a/flang/test/HLFIR/simplify-hlfir-intrinsics-sum.fir
+++ b/flang/test/HLFIR/simplify-hlfir-intrinsics-sum.fir
@@ -1,4 +1,4 @@
-// RUN: fir-opt --simplify-hlfir-intrinsics %s | FileCheck %s
+// RUN: fir-opt --simplify-hlfir-intrinsics -flang-simplify-hlfir-sum %s | FileCheck %s
// box with known extents
func.func @sum_box_known_extents(%arg0: !fir.box<!fir.array<2x3xi32>>) {
More information about the flang-commits
mailing list