[PATCH] D114599: [flang] Return true in IsSymplyContiguous for allocatables

Jean Perier via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 28 23:29:32 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d1938fd1441: [flang] Return true in IsSymplyContiguous for allocatables (authored by jeanPerier).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114599/new/

https://reviews.llvm.org/D114599

Files:
  flang/lib/Evaluate/check-expression.cpp
  flang/test/Evaluate/folding09.f90


Index: flang/test/Evaluate/folding09.f90
===================================================================
--- flang/test/Evaluate/folding09.f90
+++ flang/test/Evaluate/folding09.f90
@@ -9,9 +9,10 @@
     real, pointer, contiguous :: f(:)
     f => hosted
   end function
-  subroutine test(arr1, arr2, arr3, mat)
+  subroutine test(arr1, arr2, arr3, mat, alloc)
     real, intent(in) :: arr1(:), arr2(10), mat(10, 10)
     real, intent(in), contiguous :: arr3(:)
+    real, allocatable :: alloc(:)
     real :: scalar
     logical, parameter :: test_isc01 = is_contiguous(0)
     logical, parameter :: test_isc02 = is_contiguous(scalar)
@@ -24,5 +25,6 @@
     logical, parameter :: test_isc09 = is_contiguous(arr2(1:10:1))
     logical, parameter :: test_isc10 = is_contiguous(arr3)
     logical, parameter :: test_isc11 = is_contiguous(f())
+    logical, parameter :: test_isc12 = is_contiguous(alloc)
   end subroutine
 end module
Index: flang/lib/Evaluate/check-expression.cpp
===================================================================
--- flang/lib/Evaluate/check-expression.cpp
+++ flang/lib/Evaluate/check-expression.cpp
@@ -661,10 +661,15 @@
       return true;
     } else if (semantics::IsPointer(ultimate)) {
       return false;
+    } else if (semantics::IsAllocatable(ultimate)) {
+      // TODO: this could be merged with the case below if
+      // details->IsAssumedShape() did not return true for allocatables. Current
+      // ArraySpec building in semantics does not allow making a difference
+      // between some_assumed_shape(:) and some_allocatable(:). Both
+      // isDeferredShape() and isAssumedShape() are true in each case.
+      return true;
     } else if (const auto *details{
                    ultimate.detailsIf<semantics::ObjectEntityDetails>()}) {
-      // N.B. ALLOCATABLEs are deferred shape, not assumed, and
-      // are obviously contiguous.
       return !details->IsAssumedShape() && !details->IsAssumedRank();
     } else if (auto assoc{Base::operator()(ultimate)}) {
       return assoc;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114599.390258.patch
Type: text/x-patch
Size: 2052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211129/9b3f3e89/attachment.bin>


More information about the llvm-commits mailing list