| Summary: | Unnecessary array temporary: Passing contiguous array as actual argument | ||
|---|---|---|---|
| Product: | gcc | Reporter: | Tobias Burnus <burnus> |
| Component: | fortran | Assignee: | Not yet assigned to anyone <unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | gcc-bugs, pault, tkoenig |
| Priority: | P3 | Keywords: | missed-optimization |
| Version: | 4.5.0 | ||
| Target Milestone: | --- | ||
| Host: | Target: | ||
| Build: | Known to work: | ||
| Known to fail: | 4.4.3 | Last reconfirmed: | 2010-02-26 05:28:34 |
|
Description
Tobias Burnus
2010-02-25 11:26:35 UTC
This does not occur on i386. I will try on a x86_64 tonight. Paul (In reply to comment #1) > This does not occur on i386. I will try on a x86_64 tonight. The warning for -Warray-temporaries is shown here for both -m32 and -m64 -- and I also see "_gfortran_internal_pack" in the -fdump-tree-original. Do you have by chance local changes which fix this issue?
> The warning for -Warray-temporaries is shown here for both -m32 and -m64 -- and
> I also see "_gfortran_internal_pack" in the -fdump-tree-original. Do you have
> by chance local changes which fix this issue?
CALL foo ((MAIN__:ot(FULL)))
CALL foo ((MAIN__:ot(0_8:5_8:1_8)))
CALL foo ((MAIN__:ot(0_8:__convert_i4_i8[[((MAIN__:time_steps))]])))
I was distracted by the convert_i4_i8. Not only does it not appear for the second line but it does not appear at all with -fdefault-integer-8.
I will go back and confirm that the tree on my machine at work is clean.
Confirmed
Cheers
Paul
(In reply to comment #3) > > by chance local changes which fix this issue? > I will go back and confirm that the tree on my machine at work is clean. No, it wasn't, so my comment was incorrect. Cheers Paul I do not see the temporaries with gcc-Version 4.5.0 20100214 (experimental) (GCC) but I see this with gcc-Version 4.5.0 20100227 (experimental) (GCC) on x86_64-unknown-linux-gnu This makes this a regression. Not a regression (we track regressions only against releases). I see both temporaries also on the 4.4 branch. > I do not see the temporaries with [...] 4.5.0 20100214 > but I see this with [...] 4.5.0 20100227 I think the "regression" is due to: http://gcc.gnu.org/viewcvs?view=revision&revision=156926 Namely due to the added "no_pack" logic in trans-arrays.c's gfc_conv_array_parameter (as suggested in comment 0). http://gcc.gnu.org/viewcvs/trunk/gcc/fortran/trans-array.c?r1=156926&r2=156925 That committal fixed PR 36932, PR 36933, PR 43072, and PR 43111. Completely untested patch:
--- trans-array.c (revision 157160)
+++ trans-array.c (working copy)
@@ -5555,5 +5555,5 @@ gfc_conv_array_parameter (gfc_se * se, g
no_pack = ((sym && sym->as
&& !sym->attr.pointer
- && sym->as->type != AS_DEFERRED
+ && (sym->as->type != AS_DEFERRED || sym->attr.allocatable)
&& sym->as->type != AS_ASSUMED_SHAPE)
||
(In reply to comment #8) > Completely untested patch: Still untested, but I think it might lead to wrong code with either allocatable(1)%pointer(1:2) ! Potentially non-contiguous or pointer%allocatable(1:2) ! Cannot alias & is contiguous Though I have not really studied the source code. Actually, also for other parts in this function I am unsure whether it really takes derived-type components into account. Subject: Bug 43173 Author: pault Date: Tue Mar 2 11:58:02 2010 New Revision: 157163 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157163 Log: 2010-03-02 Paul Thomas <pault@gcc.gnu.org> PR fortran/43180 * trans-array.c (gfc_conv_array_parameter): A full array of derived type need not be restricted to a symbol without an array spec to use the call to gfc_conv_expr_descriptor. PR fortran/43173 * trans-array.c (gfc_conv_array_parameter): Contiguous refs to allocatable arrays do not need temporaries. 2010-03-02 Paul Thomas <pault@gcc.gnu.org> PR fortran/43180 * gfortran.dg/internal_pack_10.f90: New test. PR fortran/43173 * gfortran.dg/internal_pack_11.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/internal_pack_10.f90 trunk/gcc/testsuite/gfortran.dg/internal_pack_11.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-array.c trunk/gcc/testsuite/ChangeLog Fixed on trunk, thanks for the report! Paul |