public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/56688] New: Fortran save statement prevents loop vectorization.
@ 2013-03-22 10:49 ysrumyan at gmail dot com
2013-03-22 13:30 ` [Bug tree-optimization/56688] " rguenth at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: ysrumyan at gmail dot com @ 2013-03-22 10:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56688
Bug #: 56688
Summary: Fortran save statement prevents loop vectorization.
Classification: Unclassified
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ysrumyan@gmail.com
Analyzing gcc vectorization on 200.sixtrack from spec2000 suite we found out
that only 6 loops are vectorized in the hottest routine (97% run time). The
reason is that save statement is used. This issue can be illustrated by the
following simple example:
subroutine bar
implicit real*8 (a-h,o-z)
parameter (n=700)
common/my_data/ x1(n), y1(n), z1(n), t1(n)
save
do i=1,n
x = x1(i) - y1(i)
z1(i) = t1(i) * x
enddo
end
and vectorizer issues the following message:
t1.f:6: note: ==> examining statement: _6 = my_data.x1[_5];
t1.f:6: note: num. args = 4 (not unary/binary/ternary op).
t1.f:6: note: vect_is_simple_use: operand my_data.x1[_5]
t1.f:6: note: not ssa-name.
t1.f:6: note: use not simple.
t1.f:6: note: vect_model_load_cost: aligned.
t1.f:6: note: vect_model_load_cost: inside_cost = 1, prologue_cost = 0 .
t1.f:6: note: vect_is_simple_use: operand my_data.x1
t1.f:6: note: not ssa-name.
t1.f:6: note: use not simple.
t1.f:6: note: not vectorized: live stmt not supported: _6 = my_data.x1[_5];
Note also if we comment down svae stmt loop will be vectorized.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/56688] Fortran save statement prevents loop vectorization.
2013-03-22 10:49 [Bug tree-optimization/56688] New: Fortran save statement prevents loop vectorization ysrumyan at gmail dot com
@ 2013-03-22 13:30 ` rguenth at gcc dot gnu.org
2013-03-22 13:31 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-22 13:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56688
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-03-22
Blocks| |53947
Ever Confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-22 13:29:57 UTC ---
The issue is that x is kept live by applying store-motion:
<bb 3>:
# prephitmp_26 = PHI <1(2), i.3_14(4)>
# ivtmp_30 = PHI <700(2), ivtmp_15(4)>
_5 = (integer(kind=8)) prephitmp_26;
_6 = _5 + -1;
_7 = my_data.x1[_6];
_8 = my_data.y1[_6];
x.1_9 = _7 - _8;
_11 = my_data.t1[_6];
_12 = x.1_9 * _11;
my_data.z1[_6] = _12;
i.3_14 = prephitmp_26 + 1;
ivtmp_15 = ivtmp_30 - 1;
if (ivtmp_15 == 0)
goto <bb 5>;
else
goto <bb 4>;
<bb 4>:
goto <bb 3>;
<bb 5>:
# x_lsm.7_25 = PHI <x.1_9(3)>
x = x_lsm.7_25;
i = 701;
return;
because it appears that 'save' makes all variables global ones. This kind
of "reduction" is not handled by the vectorizer. If would be handled
by a pass that re-materializes x_lsm.7_25 from memory and operations
after the loop. Or by handling the "final" value properly by means
of vector extraction or in the epilogue loop, simply using it, or
forcing at least one iteration of the epilogue loop by adjusting the
number of iterations of the vectorized loop.
I like the last option most ;)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/56688] Fortran save statement prevents loop vectorization.
2013-03-22 10:49 [Bug tree-optimization/56688] New: Fortran save statement prevents loop vectorization ysrumyan at gmail dot com
2013-03-22 13:30 ` [Bug tree-optimization/56688] " rguenth at gcc dot gnu.org
@ 2013-03-22 13:31 ` rguenth at gcc dot gnu.org
2013-03-22 14:16 ` Joost.VandeVondele at mat dot ethz.ch
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-22 13:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56688
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-22 13:31:23 UTC ---
C testcase:
int x[1024], y[1024];
int z;
void foo (void)
{
unsigned i;
for (i = 0; i < 1024; ++i)
{
z = x[i] - y[i];
x[i] = z;
}
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/56688] Fortran save statement prevents loop vectorization.
2013-03-22 10:49 [Bug tree-optimization/56688] New: Fortran save statement prevents loop vectorization ysrumyan at gmail dot com
2013-03-22 13:30 ` [Bug tree-optimization/56688] " rguenth at gcc dot gnu.org
2013-03-22 13:31 ` rguenth at gcc dot gnu.org
@ 2013-03-22 14:16 ` Joost.VandeVondele at mat dot ethz.ch
2013-03-22 14:24 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2013-03-22 14:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56688
Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Joost.VandeVondele at mat
| |dot ethz.ch
--- Comment #3 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 2013-03-22 14:16:47 UTC ---
(In reply to comment #1)
> because it appears that 'save' makes all variables global ones.
But this is maybe a frontend issue ? The visibility of x is local to the this
subroutine, but its lifetime extends over the entire run (so different to your
variable z in the C testcase).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/56688] Fortran save statement prevents loop vectorization.
2013-03-22 10:49 [Bug tree-optimization/56688] New: Fortran save statement prevents loop vectorization ysrumyan at gmail dot com
` (2 preceding siblings ...)
2013-03-22 14:16 ` Joost.VandeVondele at mat dot ethz.ch
@ 2013-03-22 14:24 ` rguenth at gcc dot gnu.org
2013-03-22 14:25 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-22 14:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56688
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-22 14:24:14 UTC ---
(In reply to comment #3)
> (In reply to comment #1)
> > because it appears that 'save' makes all variables global ones.
>
> But this is maybe a frontend issue ? The visibility of x is local to the this
> subroutine, but its lifetime extends over the entire run (so different to your
> variable z in the C testcase).
No, same for
int x[1024], y[1024];
void foo (void)
{
static int z;
unsigned i;
for (i = 0; i < 1024; ++i)
{
z = x[i] - y[i];
x[i] = z;
}
}
(missed optimization is that the variable and the store to it is not
removed completely).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/56688] Fortran save statement prevents loop vectorization.
2013-03-22 10:49 [Bug tree-optimization/56688] New: Fortran save statement prevents loop vectorization ysrumyan at gmail dot com
` (3 preceding siblings ...)
2013-03-22 14:24 ` rguenth at gcc dot gnu.org
@ 2013-03-22 14:25 ` rguenth at gcc dot gnu.org
2015-06-12 14:14 ` alalaw01 at gcc dot gnu.org
2021-10-01 18:23 ` [Bug tree-optimization/56688] static/saved variables prevent " anlauf at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-22 14:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56688
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-22 14:25:15 UTC ---
Testcase for that:
void foo(int i)
{
static int x;
x = i;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/56688] Fortran save statement prevents loop vectorization.
2013-03-22 10:49 [Bug tree-optimization/56688] New: Fortran save statement prevents loop vectorization ysrumyan at gmail dot com
` (4 preceding siblings ...)
2013-03-22 14:25 ` rguenth at gcc dot gnu.org
@ 2015-06-12 14:14 ` alalaw01 at gcc dot gnu.org
2021-10-01 18:23 ` [Bug tree-optimization/56688] static/saved variables prevent " anlauf at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: alalaw01 at gcc dot gnu.org @ 2015-06-12 14:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56688
alalaw01 at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |alalaw01 at gcc dot gnu.org
--- Comment #6 from alalaw01 at gcc dot gnu.org ---
(In reply to Richard Biener from comment #4)
The C testcase vectorizes on gcc 6 development (at -O3 on aarch64 or
x86_64)....
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/56688] static/saved variables prevent loop vectorization.
2013-03-22 10:49 [Bug tree-optimization/56688] New: Fortran save statement prevents loop vectorization ysrumyan at gmail dot com
` (5 preceding siblings ...)
2015-06-12 14:14 ` alalaw01 at gcc dot gnu.org
@ 2021-10-01 18:23 ` anlauf at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-10-01 18:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56688
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|anlauf at gmx dot de |anlauf at gcc dot gnu.org
--- Comment #9 from anlauf at gcc dot gnu.org ---
The loop can be vectorized if the final value of the 'saved' scalar can be
determined.
Some vectorizing compilers (Cray, NEC) offer directives (e.g. lstval/nolstval)
to control the evaluation of that scalar, and sometimes suggest to add that
directive in front of the loop.
I think the requirements for handling this are very similar to those for the
OpenMP lastprivate declaration.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-10-01 18:23 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-22 10:49 [Bug tree-optimization/56688] New: Fortran save statement prevents loop vectorization ysrumyan at gmail dot com
2013-03-22 13:30 ` [Bug tree-optimization/56688] " rguenth at gcc dot gnu.org
2013-03-22 13:31 ` rguenth at gcc dot gnu.org
2013-03-22 14:16 ` Joost.VandeVondele at mat dot ethz.ch
2013-03-22 14:24 ` rguenth at gcc dot gnu.org
2013-03-22 14:25 ` rguenth at gcc dot gnu.org
2015-06-12 14:14 ` alalaw01 at gcc dot gnu.org
2021-10-01 18:23 ` [Bug tree-optimization/56688] static/saved variables prevent " anlauf 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).