public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/6984: wrong code generated with -O2, -O3, -Os for do-while loop on PowerPC
@ 2002-06-17 1:45 Alan Modra
0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2002-06-17 1:45 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/6984; it has been noted by GNATS.
From: Alan Modra <amodra@bigpond.net.au>
To: fshvaige@cisco.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: optimization/6984: wrong code generated with -O2, -O3, -Os for do-while loop on PowerPC
Date: Mon, 17 Jun 2002 17:00:07 +0930
Hmm, we get the same sort of bogus code on x86 with -march=k6.
The code that this patch disables looks bogus to me. Perhaps it's
relevant when doloop_start is defined?? Anyway this cures your
testcase on ppc.
Index: gcc/doloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doloop.c,v
retrieving revision 1.18
diff -u -p -r1.18 doloop.c
--- gcc/doloop.c 11 Jun 2002 12:21:52 -0000 1.18
+++ gcc/doloop.c 17 Jun 2002 07:23:22 -0000
@@ -720,7 +720,7 @@ doloop_modify_runtime (loop, iterations_
not executed before the start of the loop. We need to determine
if the loop will terminate after the first pass and to limit the
iteration count to one if necessary. */
- if (! loop->vtop)
+ if (0 && ! loop->vtop)
{
rtx label;
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: optimization/6984: wrong code generated with -O2, -O3, -Os for do-while loop on PowerPC
@ 2002-06-24 3:06 Alan Modra
0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2002-06-24 3:06 UTC (permalink / raw)
To: amodra; +Cc: gcc-prs
The following reply was made to PR optimization/6984; it has been noted by GNATS.
From: Alan Modra <amodra@bigpond.net.au>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, fshvaige@cisco.com,
gcc-bugs@gcc.gnu.org, amodra@gcc.gnu.org
Cc:
Subject: Re: optimization/6984: wrong code generated with -O2, -O3, -Os for do-while loop on PowerPC
Date: Mon, 24 Jun 2002 12:02:42 +0930
Fixed with http://gcc.gnu.org/ml/gcc-patches/2002-06/msg01487.html
PR closed.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: optimization/6984: wrong code generated with -O2, -O3, -Os for do-while loop on PowerPC
@ 2002-06-17 8:26 Alan Modra
0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2002-06-17 8:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/6984; it has been noted by GNATS.
From: Alan Modra <amodra@bigpond.net.au>
To: fshvaige@cisco.com, gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: optimization/6984: wrong code generated with -O2, -O3, -Os for do-while loop on PowerPC
Date: Tue, 18 Jun 2002 00:17:42 +0930
Except that disabling that causes failures on powerpc-linux for
loop-3c and loop-4b.
The following patch passes bootstrap and regression testing on
powerpc-linux, and I believe is correct. However, I'm not completely
happy with it, as this whole chunk of code dealing with do-while loops
looks like it's just covering up errors in previous calculation of
"iterations".
* doloop.c (doloop_modify_runtime <do-while>): Compare against
incremented initial value.
Index: gcc/doloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doloop.c,v
retrieving revision 1.18
diff -u -p -r1.18 doloop.c
--- gcc/doloop.c 11 Jun 2002 12:21:52 -0000 1.18
+++ gcc/doloop.c 17 Jun 2002 14:30:01 -0000
@@ -722,8 +722,6 @@ doloop_modify_runtime (loop, iterations_
iteration count to one if necessary. */
if (! loop->vtop)
{
- rtx label;
-
if (loop_dump_stream)
fprintf (loop_dump_stream, "Doloop: Do-while loop.\n");
@@ -733,10 +731,16 @@ doloop_modify_runtime (loop, iterations_
is guaranteed to execute at least once. */
if (loop_info->unroll_number == 1)
{
+ rtx label;
+ rtx after_one;
+
/* Emit insns to test if the loop will immediately
terminate and to set the iteration count to 1 if true. */
label = gen_label_rtx();
- emit_cmp_and_jump_insns (copy_rtx (initial_value),
+ after_one = expand_simple_binop (mode, PLUS,
+ initial_value, increment, NULL_RTX,
+ unsigned_p, OPTAB_LIB_WIDEN);
+ emit_cmp_and_jump_insns (after_one,
copy_rtx (loop_info->comparison_value),
comparison_code, NULL_RTX, mode, 0,
label);
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 4+ messages in thread
* optimization/6984: wrong code generated with -O2, -O3, -Os for do-while loop on PowerPC
@ 2002-06-10 8:26 fshvaige
0 siblings, 0 replies; 4+ messages in thread
From: fshvaige @ 2002-06-10 8:26 UTC (permalink / raw)
To: gcc-gnats
>Number: 6984
>Category: optimization
>Synopsis: wrong code generated with -O2, -O3, -Os for do-while loop on PowerPC
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Jun 10 08:26:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: fshvaige@cisco.com
>Release: 3.1
>Organization:
>Environment:
../gcc-3.1/configure --with-gcc-version-trigger=/home/install/gcc-3.1/gcc/version.c --host=i686-pc-linux-gnu --with-newlib --enable-target-optspace --target=ppc-eabi --prefix=/home/crossGCC/ppc-eabi --with-local-prefix=/home/crossGCC/ppc-eabi --program-prefix=ppc-eabi- --enable-languages=c,c++ -v --norecursion
>Description:
File test1.c:
void f1 (unsigned n) {
do {
} while (--n);
}
void f2 (unsigned n) {
l1:
if (--n) goto l1;
}
When compiled with:
ppc-eabi-gcc -v -save-temps -c -O2 -Wall test1.c
Produces wrong-large-ugly code for function f1().
The same for -O3 and -Os.
For -O1 all Ok.
Note: code for function f2() always Ok.
>How-To-Repeat:
compile test1.c:
void f1 (unsigned n) {
do {
} while (--n);
}
void f2 (unsigned n) {
l1:
if (--n) goto l1;
}
with command line like:
ppc-eabi-gcc -v -save-temps -c -O2 -Wall test1.c
and see file test1.s:
.file "test1.c"
.section ".text"
.align 2
.globl f1
.type f1,@function
f1:
cmpwi 0,3,0
bne- 0,.L7
li 3,1
.L7:
mtctr 3
.L6:
bdnz .L6
blr
.Lfe1:
.size f1,.Lfe1-f1
.align 2
.globl f2
.type f2,@function
f2:
mtctr 3
.L9:
bdnz .L9
blr
.Lfe2:
.size f2,.Lfe2-f2
.ident "GCC: (GNU) 3.1"
Code for f1() must be the same as for f2().
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-06-24 2:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-17 1:45 optimization/6984: wrong code generated with -O2, -O3, -Os for do-while loop on PowerPC Alan Modra
-- strict thread matches above, loose matches on Subject: below --
2002-06-24 3:06 Alan Modra
2002-06-17 8:26 Alan Modra
2002-06-10 8:26 fshvaige
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).