[flang-commits] [PATCH] D144655: [flang] Do not include dangling ac-implied-do-index in folded shape inquiry

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Feb 24 00:09:26 PST 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGce8dbe3c2531: [flang] Do not include dangling ac-implied-do-index in folded shape inquiry (authored by jeanPerier).
Herald added a subscriber: sunshaoce.

Changed prior to commit:
  https://reviews.llvm.org/D144655?vs=499905&id=500090#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144655

Files:
  flang/include/flang/Evaluate/shape.h
  flang/test/Evaluate/rewrite01.f90


Index: flang/test/Evaluate/rewrite01.f90
===================================================================
--- flang/test/Evaluate/rewrite01.f90
+++ flang/test/Evaluate/rewrite01.f90
@@ -206,4 +206,14 @@
   print *, size([return_allocatable(), return_allocatable()])
 end subroutine
 
+!CHECK-LABEL: array_ctor_implied_do_index
+subroutine array_ctor_implied_do_index(x, j)
+  integer :: x(:)
+  integer(8) :: j
+  !CHECK: PRINT *, size([INTEGER(4)::(x(1_8:i:1_8),INTEGER(8)::i=1_8,2_8,1_8)])
+  print *, size([(x(1:i), integer(8)::i=1,2)])
+  !CHECK: PRINT *, int(0_8+2_8*(0_8+max((j-1_8+1_8)/1_8,0_8)),kind=4)
+  print *, size([(x(1:j), integer(8)::i=1,2)])
+end subroutine
+
 end module
Index: flang/include/flang/Evaluate/shape.h
===================================================================
--- flang/include/flang/Evaluate/shape.h
+++ flang/include/flang/Evaluate/shape.h
@@ -184,8 +184,10 @@
                   !ContainsAnyImpliedDoIndex(ido.upper()) &&
                   !ContainsAnyImpliedDoIndex(ido.stride())) {
                 if (auto nValues{GetArrayConstructorExtent(ido.values())}) {
-                  return std::move(*nValues) *
-                      CountTrips(ido.lower(), ido.upper(), ido.stride());
+                  if (!ContainsAnyImpliedDoIndex(*nValues)) {
+                    return std::move(*nValues) *
+                        CountTrips(ido.lower(), ido.upper(), ido.stride());
+                  }
                 }
               }
               return std::nullopt;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144655.500090.patch
Type: text/x-patch
Size: 1516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230224/81134f47/attachment-0001.bin>


More information about the flang-commits mailing list