public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/110241] New: Redundant temporaries passing empty array constructors
@ 2023-06-13 19:27 anlauf at gcc dot gnu.org
2023-06-14 7:44 ` [Bug fortran/110241] " mikael at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-06-13 19:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110241
Bug ID: 110241
Summary: Redundant temporaries passing empty array constructors
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: anlauf at gcc dot gnu.org
Target Milestone: ---
Found while working on pr86277:
program p
call sub ([real :: 42.]) ! Single temporary
call sub ([real :: ]) ! Double temporary
contains
subroutine sub (arg)
real, intent(in), optional :: arg(:)
if (.not. present (arg)) stop 1
end
end
The dump-tree (at r14-1795-gc1691509e5a887) shows the following for the
first call:
{
static real(kind=4) A.4[1] = {4.2e+1};
struct array01_real(kind=4) parm.5;
parm.5.span = 4;
parm.5.dtype = {.elem_len=4, .rank=1, .type=3};
parm.5.dim[0].lbound = 1;
parm.5.dim[0].ubound = 1;
parm.5.dim[0].stride = 1;
parm.5.data = (void *) &A.4[0];
parm.5.offset = -1;
sub (&parm.5);
}
which is as expected, but for the second call:
{
struct array01_real(kind=4) atmp.6;
real(kind=4) A.7[0];
struct array01_real(kind=4) atmp.9;
real(kind=4) A.10[0];
typedef real(kind=4) [0];
atmp.6.dtype = {.elem_len=4, .rank=1, .type=3};
atmp.6.dim[0].stride = 1;
atmp.6.dim[0].lbound = 0;
atmp.6.dim[0].ubound = -1;
atmp.6.span = 4;
atmp.6.data = (void * restrict) &A.7;
atmp.6.offset = 0;
typedef real(kind=4) [0];
atmp.9.dtype = {.elem_len=4, .rank=1, .type=3};
atmp.9.dim[0].stride = 1;
atmp.9.dim[0].lbound = 0;
atmp.9.dim[0].ubound = -1;
atmp.9.span = 4;
atmp.9.data = (void * restrict) &A.10;
atmp.9.offset = 0;
{
integer(kind=8) S.11;
S.11 = 0;
while (1)
{
if (S.11 >= 0) goto L.2;
(*(real(kind=4)[0] * restrict) atmp.9.data)[S.11] =
(*(real(kind=4)[0] * restrict) atmp.6.data)[S.11];
S.11 = S.11 + 1;
}
L.2:;
}
sub (&atmp.9);
}
While this is at least correct code (as opposed to before the fix for pr86277),
it could be as simple as for the non-empty constructor.
(There's a patch attached to the other pr demonstrating that this can be
achieved for this code snippet).
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug fortran/110241] Redundant temporaries passing empty array constructors
2023-06-13 19:27 [Bug fortran/110241] New: Redundant temporaries passing empty array constructors anlauf at gcc dot gnu.org
@ 2023-06-14 7:44 ` mikael at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: mikael at gcc dot gnu.org @ 2023-06-14 7:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110241
Mikael Morin <mikael at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikael at gcc dot gnu.org
--- Comment #1 from Mikael Morin <mikael at gcc dot gnu.org> ---
Somehow related, but with non-empty arguments: PR38111, PR55839
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-14 7:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 19:27 [Bug fortran/110241] New: Redundant temporaries passing empty array constructors anlauf at gcc dot gnu.org
2023-06-14 7:44 ` [Bug fortran/110241] " mikael at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).