public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33341] New: unnecessary stores for array constructor
@ 2007-09-07 20:17 tkoenig at gcc dot gnu dot org
2007-09-07 21:05 ` [Bug fortran/33341] " tkoenig at gcc dot gnu dot org
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-09-07 20:17 UTC (permalink / raw)
To: gcc-bugs
The following idiom causes unnecessary runtime
overhead:
$ cat compare.f90
function foo(a,b,c,d)
logical :: foo
integer, intent(in):: a,b,c,d
foo = all((/ a, b, c /) /= d)
end function foo
$ gfortran -fdump-tree-optimized -O3 -S compare.f90
The *.optimized file shows
<bb 2>:
D.521 = (int4[0:] *) &A.2;
D.522 = *a;
(*D.521)[0] = D.522;
D.523 = *b;
(*D.521)[1] = D.523;
D.524 = *c;
(*D.521)[2] = D.524;
D.516 = *d;
The stores are unneeded, as the array itself could
be eliminated.
--
Summary: unnecessary stores for array constructor
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tkoenig at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33341
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/33341] unnecessary stores for array constructor
2007-09-07 20:17 [Bug fortran/33341] New: unnecessary stores for array constructor tkoenig at gcc dot gnu dot org
@ 2007-09-07 21:05 ` tkoenig at gcc dot gnu dot org
2007-09-08 11:32 ` tkoenig at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-09-07 21:05 UTC (permalink / raw)
To: gcc-bugs
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33341
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/33341] unnecessary stores for array constructor
2007-09-07 20:17 [Bug fortran/33341] New: unnecessary stores for array constructor tkoenig at gcc dot gnu dot org
2007-09-07 21:05 ` [Bug fortran/33341] " tkoenig at gcc dot gnu dot org
@ 2007-09-08 11:32 ` tkoenig at gcc dot gnu dot org
2007-10-01 13:15 ` fxcoudert at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-09-08 11:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from tkoenig at gcc dot gnu dot org 2007-09-08 11:32 -------
An equivalent C testcase eliminates the array stores:
int foo(int *a,int *b,int *c,int *d)
{
int val[3];
val[0] = *a;
val[1] = *b;
val[2] = *c;
return (val[0] != *d) && (val[1] != *d) && (val[2] != *d);
}
$ gcc -O3 -fdump-tree-optimized -S compare.c
$ cat compare.c.116t.optimized
;; Function foo (foo)
Analyzing Edge Insertions.
Opportunities in BB 5 for stmt/block reduction:
Splitting BB 5 for Common stmt list. Original block is now BB6.
D.1138 = 0;
Edge (2->5) lands here.
Edge (3->5) lands here.
foo (a, b, c, d)
{
int D.1143;
int D.1138;
int D.1137;
int D.1136;
<bb 2>:
D.1136 = *b;
D.1137 = *c;
D.1143 = *d;
if (*a == D.1143)
goto <bb 5>;
else
goto <bb 3>;
<bb 3>:
if (D.1136 == D.1143)
goto <bb 5>;
else
goto <bb 4>;
<bb 4>:
(void) 0;
D.1138 = (int) !(D.1137 == D.1143);
goto <bb 6>;
<bb 5>:
D.1138 = 0;
<bb 6>:
return D.1138;
}
$ gcc -O3 -fdump-tree-optimized -S compare.c
$ cat compare.c.116t.optimized
;; Function foo (foo)
Analyzing Edge Insertions.
Opportunities in BB 5 for stmt/block reduction:
Splitting BB 5 for Common stmt list. Original block is now BB6.
D.1138 = 0;
Edge (2->5) lands here.
Edge (3->5) lands here.
foo (a, b, c, d)
{
int D.1143;
int D.1138;
int D.1137;
int D.1136;
<bb 2>:
D.1136 = *b;
D.1137 = *c;
D.1143 = *d;
if (*a == D.1143)
goto <bb 5>;
else
goto <bb 3>;
<bb 3>:
if (D.1136 == D.1143)
goto <bb 5>;
else
goto <bb 4>;
<bb 4>:
(void) 0;
D.1138 = (int) !(D.1137 == D.1143);
goto <bb 6>;
<bb 5>:
D.1138 = 0;
<bb 6>:
return D.1138;
}
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33341
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/33341] unnecessary stores for array constructor
2007-09-07 20:17 [Bug fortran/33341] New: unnecessary stores for array constructor tkoenig at gcc dot gnu dot org
2007-09-07 21:05 ` [Bug fortran/33341] " tkoenig at gcc dot gnu dot org
2007-09-08 11:32 ` tkoenig at gcc dot gnu dot org
@ 2007-10-01 13:15 ` fxcoudert at gcc dot gnu dot org
2008-07-27 19:29 ` [Bug fortran/33341] array temporaries for "all intrinsic" (unnecessary stores for array constructor) tkoenig at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-10-01 13:15 UTC (permalink / raw)
To: gcc-bugs
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-10-01 13:15:26
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33341
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/33341] array temporaries for "all intrinsic" (unnecessary stores for array constructor)
2007-09-07 20:17 [Bug fortran/33341] New: unnecessary stores for array constructor tkoenig at gcc dot gnu dot org
` (2 preceding siblings ...)
2007-10-01 13:15 ` fxcoudert at gcc dot gnu dot org
@ 2008-07-27 19:29 ` tkoenig at gcc dot gnu dot org
2009-01-03 21:42 ` [Bug fortran/33341] array temporaries for array constructors (unnecessary stores) dfranke at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-07-27 19:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from tkoenig at gcc dot gnu dot org 2008-07-27 19:28 -------
The test case now correctly complains about
an unneeded temporary:
$ gfortran -Warray-temporaries foo.f90
foo.f90:5.8:
foo = all((/ a, b, c /) /= d)
1
Warning: Creating array temporary at (1)
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|unnecessary stores for array|array temporaries for "all
|constructor |intrinsic" (unnecessary
| |stores for array
| |constructor)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33341
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/33341] array temporaries for array constructors (unnecessary stores)
2007-09-07 20:17 [Bug fortran/33341] New: unnecessary stores for array constructor tkoenig at gcc dot gnu dot org
` (3 preceding siblings ...)
2008-07-27 19:29 ` [Bug fortran/33341] array temporaries for "all intrinsic" (unnecessary stores for array constructor) tkoenig at gcc dot gnu dot org
@ 2009-01-03 21:42 ` dfranke at gcc dot gnu dot org
2009-01-04 0:21 ` dfranke at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2009-01-03 21:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from dfranke at gcc dot gnu dot org 2009-01-03 21:39 -------
Not specific to the ALL intrinsic.
$> cat ctor.f90
INTEGER :: i, n, a(5)
n = 5
a = (/ (i, i = 1, n) /)
END
$> gfortran-svn -Warray-temporaries ctor.f90
ctor.f90:3.9:
a = (/ (i, i = 1, n) /)
1
Warning: Creating array temporary at (1)
If N is not a variable, the simplifier takes over and no runtime construction
of arrays is necessary. Not applicable example in #0, of course.
--
dfranke at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dfranke at gcc dot gnu dot
| |org
Summary|array temporaries for "all |array temporaries for array
|intrinsic" (unnecessary |constructors (unnecessary
|stores for array |stores)
|constructor) |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33341
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/33341] array temporaries for array constructors (unnecessary stores)
2007-09-07 20:17 [Bug fortran/33341] New: unnecessary stores for array constructor tkoenig at gcc dot gnu dot org
` (4 preceding siblings ...)
2009-01-03 21:42 ` [Bug fortran/33341] array temporaries for array constructors (unnecessary stores) dfranke at gcc dot gnu dot org
@ 2009-01-04 0:21 ` dfranke at gcc dot gnu dot org
2010-05-09 18:31 ` dfranke at gcc dot gnu dot org
2010-06-09 20:58 ` dominiq at lps dot ens dot fr
7 siblings, 0 replies; 10+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2009-01-04 0:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from dfranke at gcc dot gnu dot org 2009-01-04 00:20 -------
*** Bug 36935 has been marked as a duplicate of this bug. ***
--
dfranke at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jv244 at cam dot ac dot uk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33341
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/33341] array temporaries for array constructors (unnecessary stores)
2007-09-07 20:17 [Bug fortran/33341] New: unnecessary stores for array constructor tkoenig at gcc dot gnu dot org
` (5 preceding siblings ...)
2009-01-04 0:21 ` dfranke at gcc dot gnu dot org
@ 2010-05-09 18:31 ` dfranke at gcc dot gnu dot org
2010-06-09 20:58 ` dominiq at lps dot ens dot fr
7 siblings, 0 replies; 10+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2010-05-09 18:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from dfranke at gcc dot gnu dot org 2010-05-09 18:31 -------
This improved at some point. We still create the temporary array, but the
optimizer got smarter:
$> gfortran-svn -O3 -fdump-tree-optimized -Warray-temporaries -c pr33341.f90
pr33341.f90:5.8:
foo = all((/ a, b, c /) /= d)
1
Warning: Creating array temporary at (1)
$> cat pr33341.f90.142t.optimized
;; Function foo (foo_)
foo (integer(kind=4) & restrict a, integer(kind=4) & restrict b,
integer(kind=4) & restrict c, integer(kind=4) & restrict d)
{
logical(kind=4) test.0;
integer(kind=4) D.1525;
integer(kind=4) D.1533;
integer(kind=4) D.1532;
integer(kind=4) D.1531;
<bb 2>:
D.1531_7 = *a_6(D);
D.1532_11 = *b_10(D);
D.1533_15 = *c_14(D);
D.1525_17 = *d_16(D);
if (D.1531_7 == D.1525_17)
goto <bb 5>;
else
goto <bb 3>;
<bb 3>:
if (D.1532_11 == D.1525_17)
goto <bb 5>;
else
goto <bb 4>;
<bb 4>:
test.0_32 = D.1533_15 != D.1525_17;
<bb 5>:
# test.0_1 = PHI <0(2), 0(3), test.0_32(4)>
return test.0_1;
}
Should we keep the PR open to (eventually) eliminate the temporary or does this
count as fixed?
--
dfranke at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33341
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/33341] array temporaries for array constructors (unnecessary stores)
2007-09-07 20:17 [Bug fortran/33341] New: unnecessary stores for array constructor tkoenig at gcc dot gnu dot org
` (6 preceding siblings ...)
2010-05-09 18:31 ` dfranke at gcc dot gnu dot org
@ 2010-06-09 20:58 ` dominiq at lps dot ens dot fr
7 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens dot fr @ 2010-06-09 20:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from dominiq at lps dot ens dot fr 2010-06-09 20:57 -------
*** Bug 44442 has been marked as a duplicate of this bug. ***
--
dominiq at lps dot ens dot fr changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dominiq at lps dot ens dot
| |fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33341
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/33341] array temporaries for array constructors (unnecessary stores)
[not found] <bug-33341-4@http.gcc.gnu.org/bugzilla/>
@ 2013-01-31 21:02 ` tkoenig at gcc dot gnu.org
0 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-01-31 21:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33341
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution| |DUPLICATE
--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2013-01-31 21:01:58 UTC ---
I sometimes should read my own old PRs.
Closing this one as a duplicate of PR 55806 (which has a patch :-)
*** This bug has been marked as a duplicate of bug 55806 ***
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-01-31 21:02 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-07 20:17 [Bug fortran/33341] New: unnecessary stores for array constructor tkoenig at gcc dot gnu dot org
2007-09-07 21:05 ` [Bug fortran/33341] " tkoenig at gcc dot gnu dot org
2007-09-08 11:32 ` tkoenig at gcc dot gnu dot org
2007-10-01 13:15 ` fxcoudert at gcc dot gnu dot org
2008-07-27 19:29 ` [Bug fortran/33341] array temporaries for "all intrinsic" (unnecessary stores for array constructor) tkoenig at gcc dot gnu dot org
2009-01-03 21:42 ` [Bug fortran/33341] array temporaries for array constructors (unnecessary stores) dfranke at gcc dot gnu dot org
2009-01-04 0:21 ` dfranke at gcc dot gnu dot org
2010-05-09 18:31 ` dfranke at gcc dot gnu dot org
2010-06-09 20:58 ` dominiq at lps dot ens dot fr
[not found] <bug-33341-4@http.gcc.gnu.org/bugzilla/>
2013-01-31 21:02 ` tkoenig 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).