Skip to content

Commit

Permalink
[flang] Fold IS_CONTIGUOUS of component refs with non-contiguous base (
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanPerier authored Oct 18, 2023
1 parent 112e49b commit 51a2ac6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 7 additions & 2 deletions flang/lib/Evaluate/check-expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
9 changes: 9 additions & 0 deletions flang/test/Evaluate/folding09.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 51a2ac6

Please sign in to comment.