Thomas Koenig
2018-10-21 10:42:01 UTC
Hello world,
I have been busy in the last weeks implementing FINDLOC. It is almost
feature-complete; still missing is the library version for a character
version (that is easy, if a bit of work), handling scalar masks in
the inlined version (also easy, just look at other intrinsics for that),
but I have hit one snag.
The problem can be seen with the following test case.
program main
integer, dimension(0:5) :: a = [1,2,3,1,2,3]
logical, dimension(6) :: mask =
[.false.,.false.,.false.,.true.,.true.,.true.]
logical :: back
back = .false.
if (findloc(a,2,dim=1,mask=mask,back=back) /= 5) stop 1
if (findloc(a,2,dim=1,mask=mask,back=back) /= 5) stop 1
end program main
If I run this through the compiler, I hit a gimplification error.
This can be understood from the beginning of the tree dump:
MAIN__ ()
{
integer(kind=8) pos.4;
integer(kind=8) offset.5;
static integer(kind=4) a[6] = {1, 2, 3, 1, 2, 3};
logical(kind=4) back;
static logical(kind=4) mask[6] = {0, 0, 0, 1, 1, 1};
{
integer(kind=8) S.6;
back = 0;
{
integer(kind=8) S.3;
pos.0 = 0;
The declaration for pos.0 is missing, and I have no idea why.
Can anybody shed any light on this? I think this has
something to do with me generating two loops for the
single findloc statement (one for BACK=.false., one
for BACK=.true.). Also, this only occurs if BACK
is a variable.
Any ideas?
Regards
Thomas
I have been busy in the last weeks implementing FINDLOC. It is almost
feature-complete; still missing is the library version for a character
version (that is easy, if a bit of work), handling scalar masks in
the inlined version (also easy, just look at other intrinsics for that),
but I have hit one snag.
The problem can be seen with the following test case.
program main
integer, dimension(0:5) :: a = [1,2,3,1,2,3]
logical, dimension(6) :: mask =
[.false.,.false.,.false.,.true.,.true.,.true.]
logical :: back
back = .false.
if (findloc(a,2,dim=1,mask=mask,back=back) /= 5) stop 1
if (findloc(a,2,dim=1,mask=mask,back=back) /= 5) stop 1
end program main
If I run this through the compiler, I hit a gimplification error.
This can be understood from the beginning of the tree dump:
MAIN__ ()
{
integer(kind=8) pos.4;
integer(kind=8) offset.5;
static integer(kind=4) a[6] = {1, 2, 3, 1, 2, 3};
logical(kind=4) back;
static logical(kind=4) mask[6] = {0, 0, 0, 1, 1, 1};
{
integer(kind=8) S.6;
back = 0;
{
integer(kind=8) S.3;
pos.0 = 0;
The declaration for pos.0 is missing, and I have no idea why.
Can anybody shed any light on this? I think this has
something to do with me generating two loops for the
single findloc statement (one for BACK=.false., one
for BACK=.true.). Also, this only occurs if BACK
is a variable.
Any ideas?
Regards
Thomas