[flang-commits] [flang] ce8dbe3 - [flang] Do not include dangling ac-implied-do-index in folded shape inquiry
Jean Perier via flang-commits
flang-commits at lists.llvm.org
Fri Feb 24 00:09:24 PST 2023
Author: Jean Perier
Date: 2023-02-24T09:08:34+01:00
New Revision: ce8dbe3c253147b6229a34899d2adc5bc705157c
URL: https://github.com/llvm/llvm-project/commit/ce8dbe3c253147b6229a34899d2adc5bc705157c
DIFF: https://github.com/llvm/llvm-project/commit/ce8dbe3c253147b6229a34899d2adc5bc705157c.diff
LOG: [flang] Do not include dangling ac-implied-do-index in folded shape inquiry
The current code was replacing inquiry to array constructor whose
ac-value shape depends on ac-implied-do-index with an expression
using the ac-implied-do-index without the implied-do (folding the
first case added in the test as in the second case with a regular
symbol).
Differential Revision: https://reviews.llvm.org/D144655
Added:
Modified:
flang/include/flang/Evaluate/shape.h
flang/test/Evaluate/rewrite01.f90
Removed:
################################################################################
diff --git a/flang/include/flang/Evaluate/shape.h b/flang/include/flang/Evaluate/shape.h
index 0539d8f19b55a..dce24b7cb052b 100644
--- a/flang/include/flang/Evaluate/shape.h
+++ b/flang/include/flang/Evaluate/shape.h
@@ -184,8 +184,10 @@ class GetShapeHelper
!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;
diff --git a/flang/test/Evaluate/rewrite01.f90 b/flang/test/Evaluate/rewrite01.f90
index e971ff29d2b88..3f7f954cc69f5 100644
--- a/flang/test/Evaluate/rewrite01.f90
+++ b/flang/test/Evaluate/rewrite01.f90
@@ -206,4 +206,14 @@ function return_allocatable()
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
More information about the flang-commits
mailing list