[flang-commits] [flang] [Flang][HLFIR] Lower PACK(array, .TRUE.) to hlfir.reshape (PR #213603)

via flang-commits flang-commits at lists.llvm.org
Sun Aug 2 23:55:05 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- flang/include/flang/Lower/HlfirIntrinsics.h flang/lib/Lower/ConvertCall.cpp flang/lib/Lower/HlfirIntrinsics.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/flang/include/flang/Lower/HlfirIntrinsics.h b/flang/include/flang/Lower/HlfirIntrinsics.h
index 4ec4cd5a4..98e088afc 100644
--- a/flang/include/flang/Lower/HlfirIntrinsics.h
+++ b/flang/include/flang/Lower/HlfirIntrinsics.h
@@ -160,11 +160,11 @@ std::optional<hlfir::EntityWithAttributes> lowerHlfirIntrinsic(
     const fir::IntrinsicArgumentLoweringRules *argLowering,
     mlir::Type stmtResultType);
 
-std::optional<hlfir::EntityWithAttributes> lowerPackAsReshape(
-    fir::FirOpBuilder &builder, mlir::Location loc,
-    const PreparedActualArguments &loweredActuals,
-    const fir::IntrinsicArgumentLoweringRules *argLowering,
-    mlir::Type stmtResultType);
+std::optional<hlfir::EntityWithAttributes>
+lowerPackAsReshape(fir::FirOpBuilder &builder, mlir::Location loc,
+                   const PreparedActualArguments &loweredActuals,
+                   const fir::IntrinsicArgumentLoweringRules *argLowering,
+                   mlir::Type stmtResultType);
 
 } // namespace Fortran::lower
 #endif // FORTRAN_LOWER_HLFIRINTRINSICS_H
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index 59452b2b2..2466844e8 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -2372,9 +2372,9 @@ genIntrinsicRefCore(Fortran::lower::PreparedActualArguments &loweredActuals,
 
 /// Lower calls to intrinsic procedures with actual arguments that have been
 /// pre-lowered but have not yet been prepared according to the interface.
-static bool isPackWithScalarTrueMask(
-    const Fortran::evaluate::ProcedureRef &procRef,
-    Fortran::lower::AbstractConverter &converter) {
+static bool
+isPackWithScalarTrueMask(const Fortran::evaluate::ProcedureRef &procRef,
+                         Fortran::lower::AbstractConverter &converter) {
   if (procRef.arguments().size() < 2 || !procRef.arguments()[1])
     return false;
   if (procRef.arguments().size() >= 3 && procRef.arguments()[2])
@@ -2382,9 +2382,8 @@ static bool isPackWithScalarTrueMask(
   const auto *maskExpr = procRef.UnwrapArgExpr(1);
   if (!maskExpr)
     return false;
-  const auto *logExpr =
-      Fortran::evaluate::UnwrapExpr<Fortran::evaluate::Expr<
-          Fortran::evaluate::SomeLogical>>(*maskExpr);
+  const auto *logExpr = Fortran::evaluate::UnwrapExpr<
+      Fortran::evaluate::Expr<Fortran::evaluate::SomeLogical>>(*maskExpr);
   if (!logExpr || logExpr->Rank() != 0)
     return false;
   auto &ctx = converter.getFoldingContext();
diff --git a/flang/lib/Lower/HlfirIntrinsics.cpp b/flang/lib/Lower/HlfirIntrinsics.cpp
index fbb517d25..5e53123bd 100644
--- a/flang/lib/Lower/HlfirIntrinsics.cpp
+++ b/flang/lib/Lower/HlfirIntrinsics.cpp
@@ -719,10 +719,8 @@ std::optional<hlfir::EntityWithAttributes> Fortran::lower::lowerPackAsReshape(
   if (!loweredActuals[0])
     return std::nullopt;
   hlfir::Entity array = loweredActuals[0]->getActual(loc, builder);
-  if (!fir::isa_trivial(array.getFortranElementType()) ||
-      array.isPolymorphic())
+  if (!fir::isa_trivial(array.getFortranElementType()) || array.isPolymorphic())
     return std::nullopt;
-  return HlfirPackAsReshapeLowering{builder, loc}.lower(loweredActuals,
-                                                        argLowering,
-                                                        stmtResultType);
+  return HlfirPackAsReshapeLowering{builder, loc}.lower(
+      loweredActuals, argLowering, stmtResultType);
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/213603


More information about the flang-commits mailing list