This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [fortran PATCH] Implement a(:,:) = 0.0 using memset
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: roger at eyesopen dot com
- Cc: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Mon, 18 Dec 2006 18:44:56 +0100
- Subject: Re: [fortran PATCH] Implement a(:,:) = 0.0 using memset
- References: <4568.208.41.78.162.1166463384.squirrel@mail.eyesopen.com>
roger@eyesopen.com wrote on Mon, 18 Dec 2006:
The following patch makes use of the recently added gfc_full_array_ref_p
function to provide the optimization of using memset when assigning an
entire array to zero. Currently, the source code below:
integer :: a(20)
a(:) = 0;
we currently generate the following with -fdump-tree-original
int8 S.0;
S.0 = 1;
while (1)
{
if (S.0 > 20) goto L.1; else (void) 0;
(*a)[NON_LVALUE_EXPR <S.0> + -1] = 0;
S.0 = S.0 + 1;
}
L.1:;
with the patch below, we now generate this instead.
(void) __builtin_memset ((void *) a, 0, 80);
Does this work for strided arrays? Say
program t
real :: arr(4)
call a(arr(1:4:2))
print *, arr
contains
subroutine a(b)
real :: b(:)
b(:) = 0
end subroutine
end program
- Tobi
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.