[patch, Fortran] PR 55806 - Inefficient ANY with array constructors
Thomas Koenig
tkoenig@netcologne.de
Sun Jan 13 22:14:00 GMT 2013
Hi Mikael,
thanks a lot for your comments!
>> + actual_arglist->expr = gfc_copy_expr (e);
>> + actual_arglist->next = gfc_get_actual_arglist ();
> Another one is needed. I get a segmentation fault with SUM.
Fixed by using gfc_build_intrisic_call. I have also put SUM
into the test case.
>> + if (dim != NULL)
>> + {
> Minor, but I think you can assume dim != NULL. Same for mask.
Fixed.
>> + /* We changed things from under the expression walker. Walking the
>> + old tree would mess up things, so let's not do that. */
>> + return 1;
> I think this prevents any further reduction optimization. The following
> variant of your test case doesn't avoid the temporary:
You're right; I also could not come up with a test case where this
didn't work.
I have put this
> do i=1,3
> if (any([abs(a(i,1) - b(i,1)) > acc, &
> (j==i+1,j=3,8)])) cycle
> if (any([abs(a(i,2) - b(i,2)) > acc, &
> abs(a(i,3) - b(i,3)) > acc, lo(i,:)])) cycle
> c = c + i
> end do
into the test case.
Updated test case and patch attached.
OK for trunk?
Thomas
2013-01-13 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/55806
* frontend-passes.c (optimize_reduction): New function,
including prototype.
(callback_reduction): Likewise.
(gfc_run_passes): Also run optimize_reduction.
(copy_walk_reduction_arg): New function.
(dummy_code_callback): New function.
2013-01-13 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/55806
* gfortran.dg/array_constructor_40.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p5.diff
Type: text/x-patch
Size: 5242 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20130113/e9556d54/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: array_constructor_40.f90
Type: text/x-fortran
Size: 1300 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20130113/e9556d54/attachment-0001.bin>
More information about the Fortran
mailing list