public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later)
@ 2008-09-16 1:31 pinskia at gcc dot gnu dot org
2008-09-16 1:34 ` [Bug fortran/37536] " pinskia at gcc dot gnu dot org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-16 1:31 UTC (permalink / raw)
To: gcc-bugs
When looking into PR 37534, I noticed that in some cases a compare and then a
mfcr and then again a compare happens. This is the most reduced testcase I
could come up with:
Function f(MaxDev, a, b, Step)
Integer :: Step, NewX, NewY
Integer :: MaxDev, a, b
Do NewX = a-MaxDev, b+MaxDev, Step
enddo
MaxDev = NewX
end
--- CUT --
Currently we produce:
.L2:
cmpw 7,10,9
neg 8,0
subf 10,10,9
mfcr 11
rlwinm 11,11,30,1
divwu 10,10,8
b .L3
--- CUT ---
This is caused by the following tree level code:
if (D.692 > 0 ? D.691 < D.690 : D.691 > D.690) goto L.2;
I think the front-end might be better at optimizing this.
--
Summary: a mfcr is produced instead of branches (when it is used
in branches later)
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] a mfcr is produced instead of branches (when it is used in branches later)
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
@ 2008-09-16 1:34 ` pinskia at gcc dot gnu dot org
2008-09-16 1:40 ` pinskia at gcc dot gnu dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-16 1:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2008-09-16 01:32 -------
> if (D.692 > 0 ? D.691 < D.690 : D.691 > D.690) goto L.2;
> I think the front-end might be better at optimizing this.
That is produce:
if (D.692 > 0)
{
if (D.691 < D.690) goto L.2;
}
else if (D.691 > D.690) goto L.2;
Or maybe the gimplifier should do that.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] a mfcr is produced instead of branches (when it is used in branches later)
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
2008-09-16 1:34 ` [Bug fortran/37536] " pinskia at gcc dot gnu dot org
@ 2008-09-16 1:40 ` pinskia at gcc dot gnu dot org
2008-09-16 1:45 ` [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops pinskia at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-16 1:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2008-09-16 01:39 -------
This was caused by PR 31399.
(In reply to comment #1)
> Or maybe the gimplifier should do that.
As a stop gap, I think the front-end should do it for 4.4, I might want to look
into that soon. I will file a C bug version. The Fortran version is caused by
the front-end and the user did not do it.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |31399
nThis| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
2008-09-16 1:34 ` [Bug fortran/37536] " pinskia at gcc dot gnu dot org
2008-09-16 1:40 ` pinskia at gcc dot gnu dot org
@ 2008-09-16 1:45 ` pinskia at gcc dot gnu dot org
2008-09-16 13:04 ` jakub at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-16 1:45 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|a mfcr is produced instead |[4.3/4.4 Regression] a mfcr
|of branches (when it is used|is produced instead of
|in branches later) |branches for DO loops
Target Milestone|--- |4.3.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
` (2 preceding siblings ...)
2008-09-16 1:45 ` [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops pinskia at gcc dot gnu dot org
@ 2008-09-16 13:04 ` jakub at gcc dot gnu dot org
2008-09-16 13:11 ` rguenth at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-09-16 13:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jakub at gcc dot gnu dot org 2008-09-16 13:02 -------
Created an attachment (id=16338)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16338&action=view)
gcc44-pr37536.patch
So far untested patch to optimize slightly integer type non-simple do loops.
At least on x86_64 it results in smaller and hopefully faster code.
Still testing it with make check-gfortran, but will probably need a SPEC
testing too.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
` (3 preceding siblings ...)
2008-09-16 13:04 ` jakub at gcc dot gnu dot org
@ 2008-09-16 13:11 ` rguenth at gcc dot gnu dot org
2008-09-16 15:30 ` pault at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-09-16 13:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2008-09-16 13:10 -------
ifcombine would be a place to do this CFG re-writing.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu dot
| |org
Severity|enhancement |normal
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Known to work| |4.2.4
Last reconfirmed|0000-00-00 00:00:00 |2008-09-16 13:10:01
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
` (4 preceding siblings ...)
2008-09-16 13:11 ` rguenth at gcc dot gnu dot org
@ 2008-09-16 15:30 ` pault at gcc dot gnu dot org
2008-09-16 15:56 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-09-16 15:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pault at gcc dot gnu dot org 2008-09-16 15:29 -------
(In reply to comment #2)
Hi Andrew,
Does this do it for you or is this all to rarified for this
Bear-of-little-brain to follow?
D.1359 = *start - *offset;
D.1360 = *end + *offset;
D.1361 = *step;
D.1364 = D.1361 > 0 ? D.1360 < D.1359 : D.1360 > D.1359; /* Fix the
result*/
if (D.1364) goto L.2; /* Then branch */
countm1.0 = (D.1361 > 0 ? (character(kind=4)) (D.1360 - D.1359) :
(character(kind=4)) (D.1359 - D.1360)) / (character(kind=4)) ABS_EXPR <D.1361>;
i = D.1359;
while (1)
Cheers
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
` (5 preceding siblings ...)
2008-09-16 15:30 ` pault at gcc dot gnu dot org
@ 2008-09-16 15:56 ` pinskia at gcc dot gnu dot org
2008-09-16 17:53 ` pault at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-16 15:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2008-09-16 15:55 -------
(In reply to comment #5)
> (In reply to comment #2)
> Hi Andrew,
>
> Does this do it for you or is this all to rarified for this
> Bear-of-little-brain to follow?
>
> D.1359 = *start - *offset;
> D.1360 = *end + *offset;
> D.1361 = *step;
> D.1364 = D.1361 > 0 ? D.1360 < D.1359 : D.1360 > D.1359; /* Fix the
> result*/
> if (D.1364) goto L.2; /* Then branch */
The issue is that D.1364 is used to the store of the result of a comparison.
Since GCC does not currently optimize that case, the front-end could rewrite
the if statement to begin with; this is what Jabuk's patch does (Thanks
Jabuk!).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
` (6 preceding siblings ...)
2008-09-16 15:56 ` pinskia at gcc dot gnu dot org
@ 2008-09-16 17:53 ` pault at gcc dot gnu dot org
2008-09-16 22:18 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-09-16 17:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pault at gcc dot gnu dot org 2008-09-16 17:51 -------
(In reply to comment #2)
Hi Andrew,
Does this do it for you or is this all to rarified for this
Bear-of-little-brain to follow?
D.1359 = *start - *offset;
D.1360 = *end + *offset;
D.1361 = *step;
D.1364 = D.1361 > 0 ? D.1360 < D.1359 : D.1360 > D.1359; /* Fix the
result*/
if (D.1364) goto L.2; /* Then branch */
countm1.0 = (D.1361 > 0 ? (character(kind=4)) (D.1360 - D.1359) :
(character(kind=4)) (D.1359 - D.1360)) / (character(kind=4)) ABS_EXPR <D.1361>;
i = D.1359;
while (1)
Cheers
Paul
(In reply to comment #6)
> (In reply to comment #5)
> > (In reply to comment #2)
> > Hi Andrew,
> >
> > Does this do it for you or is this all to rarified for this
> > Bear-of-little-brain to follow?
> >
> > D.1359 = *start - *offset;
> > D.1360 = *end + *offset;
> > D.1361 = *step;
> > D.1364 = D.1361 > 0 ? D.1360 < D.1359 : D.1360 > D.1359; /* Fix the
> > result*/
> > if (D.1364) goto L.2; /* Then branch */
>
> The issue is that D.1364 is used to the store of the result of a comparison.
> Since GCC does not currently optimize that case, the front-end could rewrite
> the if statement to begin with; this is what Jabuk's patch does (Thanks
> Jabuk!).
>
Ahhhhh....!
Thanks
P.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
` (7 preceding siblings ...)
2008-09-16 17:53 ` pault at gcc dot gnu dot org
@ 2008-09-16 22:18 ` jakub at gcc dot gnu dot org
2008-09-17 15:23 ` luisgpm at linux dot vnet dot ibm dot com
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-09-16 22:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jakub at gcc dot gnu dot org 2008-09-16 22:17 -------
An ifcombine optimization is certainly desirable, still IMHO it makes sense to
do something about it in the FE too. The vanilla f951 generated code contains
essentially 3 different conditional expressions on step > 0, and one of those
is assigned to a var to be used by another COND_EXPR. One is the empty
COND_EXPR,
another is step > 0 ? to - from : from - to and another is ABS_EXPR <step>.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
` (8 preceding siblings ...)
2008-09-16 22:18 ` jakub at gcc dot gnu dot org
@ 2008-09-17 15:23 ` luisgpm at linux dot vnet dot ibm dot com
2008-09-17 21:54 ` jakub at gcc dot gnu dot org
2008-09-17 21:54 ` jakub at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: luisgpm at linux dot vnet dot ibm dot com @ 2008-09-17 15:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from luisgpm at linux dot vnet dot ibm dot com 2008-09-17 15:22 -------
Gathered some PPC 32/64 performance numbers with the patch (based on 140409).
No noticeable performance regressions were found. 32-bit swin and 64-bit art
had a little boost on speed (7.8% and 3.4% respectivelly).
--
luisgpm at linux dot vnet dot ibm dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |luisgpm at linux dot vnet
| |dot ibm dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
` (9 preceding siblings ...)
2008-09-17 15:23 ` luisgpm at linux dot vnet dot ibm dot com
@ 2008-09-17 21:54 ` jakub at gcc dot gnu dot org
2008-09-17 21:54 ` jakub at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-09-17 21:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from jakub at gcc dot gnu dot org 2008-09-17 21:53 -------
Fixed on the trunk.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|4.3.3 |4.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
` (10 preceding siblings ...)
2008-09-17 21:54 ` jakub at gcc dot gnu dot org
@ 2008-09-17 21:54 ` jakub at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-09-17 21:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jakub at gcc dot gnu dot org 2008-09-17 21:53 -------
Subject: Bug 37536
Author: jakub
Date: Wed Sep 17 21:51:50 2008
New Revision: 140433
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140433
Log:
PR fortran/37536
* trans-stmt.c (gfc_trans_do): Optimize integer type non-simple
do loop initialization.
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-stmt.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37536
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2008-09-17 21:54 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-16 1:31 [Bug fortran/37536] New: a mfcr is produced instead of branches (when it is used in branches later) pinskia at gcc dot gnu dot org
2008-09-16 1:34 ` [Bug fortran/37536] " pinskia at gcc dot gnu dot org
2008-09-16 1:40 ` pinskia at gcc dot gnu dot org
2008-09-16 1:45 ` [Bug fortran/37536] [4.3/4.4 Regression] a mfcr is produced instead of branches for DO loops pinskia at gcc dot gnu dot org
2008-09-16 13:04 ` jakub at gcc dot gnu dot org
2008-09-16 13:11 ` rguenth at gcc dot gnu dot org
2008-09-16 15:30 ` pault at gcc dot gnu dot org
2008-09-16 15:56 ` pinskia at gcc dot gnu dot org
2008-09-16 17:53 ` pault at gcc dot gnu dot org
2008-09-16 22:18 ` jakub at gcc dot gnu dot org
2008-09-17 15:23 ` luisgpm at linux dot vnet dot ibm dot com
2008-09-17 21:54 ` jakub at gcc dot gnu dot org
2008-09-17 21:54 ` jakub at gcc dot gnu dot 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).