[flang-commits] [PATCH] D99346: [flang] fold LOGICAL intrinsic calls

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Mar 25 08:40:32 PDT 2021


jeanPerier created this revision.
jeanPerier added reviewers: klausler, PeteSteinfeld.
jeanPerier added a project: Flang.
Herald added a subscriber: jdoerfert.
jeanPerier requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Folding of LOGICAL intrinsic procedure was missing in the front-end causing
crash when using it in parameter expressions.
Simply fold LOGICAL calls to evaluate::Convert<T>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99346

Files:
  flang/lib/Evaluate/fold-logical.cpp
  flang/test/Evaluate/folding01.f90


Index: flang/test/Evaluate/folding01.f90
===================================================================
--- flang/test/Evaluate/folding01.f90
+++ flang/test/Evaluate/folding01.f90
@@ -30,6 +30,9 @@
   logical, parameter :: test_neqv3 = .NOT.(.false..NEQV..false.)
   logical, parameter :: test_neqv4 = .NOT.(.true..NEQV..true.)
 
+  logical, parameter :: test_logical1 = logical(logical(.true., 2))
+  logical, parameter :: test_logical2 = .NOT.logical(logical(.false., 2))
+
 ! Check integer intrinsic operator folding
 
 ! Check integer relational intrinsic operation folding
Index: flang/lib/Evaluate/fold-logical.cpp
===================================================================
--- flang/lib/Evaluate/fold-logical.cpp
+++ flang/lib/Evaluate/fold-logical.cpp
@@ -106,6 +106,10 @@
         }
       }
     }
+  } else if (name == "logical") {
+    if (auto *expr{UnwrapExpr<Expr<SomeLogical>>(args[0])}) {
+      return Fold(context, ConvertToType<T>(std::move(*expr)));
+    }
   } else if (name == "merge") {
     return FoldMerge<T>(context, std::move(funcRef));
   } else if (name == "__builtin_ieee_support_datatype" ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99346.333316.patch
Type: text/x-patch
Size: 1139 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20210325/acd7f5fe/attachment.bin>


More information about the flang-commits mailing list