[flang-commits] [flang] 51a2ac6 - [flang] Fold IS_CONTIGUOUS of component refs with non-contiguous base (#69327)
via flang-commits
flang-commits at lists.llvm.org
Tue Oct 17 23:47:20 PDT 2023
Author: jeanPerier
Date: 2023-10-18T08:47:15+02:00
New Revision: 51a2ac645f4efde053175e7cc8f7882d1ea0e14d
URL: https://github.com/llvm/llvm-project/commit/51a2ac645f4efde053175e7cc8f7882d1ea0e14d
DIFF: https://github.com/llvm/llvm-project/commit/51a2ac645f4efde053175e7cc8f7882d1ea0e14d.diff
LOG: [flang] Fold IS_CONTIGUOUS of component refs with non-contiguous base (#69327)
Added:
Modified:
flang/lib/Evaluate/check-expression.cpp
flang/test/Evaluate/folding09.f90
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/check-expression.cpp b/flang/lib/Evaluate/check-expression.cpp
index 29bd6eaa466bbc2..531fc5ccc56c858 100644
--- a/flang/lib/Evaluate/check-expression.cpp
+++ b/flang/lib/Evaluate/check-expression.cpp
@@ -821,8 +821,13 @@ class IsContiguousHelper
if (x.base().Rank() == 0) {
return (*this)(x.GetLastSymbol());
} else {
- // TODO could be true if base contiguous and this is only component, or
- // if base has only one element?
+ if (Result baseIsContiguous{(*this)(x.base())}) {
+ if (!*baseIsContiguous) {
+ return false;
+ }
+ // TODO could be true if base contiguous and this is only component, or
+ // if base has only one element?
+ }
return std::nullopt;
}
}
diff --git a/flang/test/Evaluate/folding09.f90 b/flang/test/Evaluate/folding09.f90
index e796ed3d5169bab..863b5e873a1e5b0 100644
--- a/flang/test/Evaluate/folding09.f90
+++ b/flang/test/Evaluate/folding09.f90
@@ -56,4 +56,13 @@ subroutine test(arr1, arr2, arr3, mat, alloc)
end block
end associate
end subroutine
+ subroutine test2(x, vec)
+ type t
+ integer :: i
+ end type
+ type(t) :: x(100)
+ integer(8) :: vec(10)
+ integer(kind=merge(1,-1, .not. is_contiguous(x(1:50:2)%i))) t01
+ integer(kind=merge(1,-1, .not. is_contiguous(x(vec)%i))) t02
+ end subroutine
end module
More information about the flang-commits
mailing list