public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686
@ 2004-09-29 22:37 m dot calderbank at iname dot com
2004-09-29 22:46 ` [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 " pinskia at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: m dot calderbank at iname dot com @ 2004-09-29 22:37 UTC (permalink / raw)
To: gcc-bugs
The following program compiles incorrectly on i686 using the latest CVS code and
optimization level -O1 or -O2. But -O3 is OK, as is -fno-ivopts.
I am aware that bug #17474 concerns -fno-ivopts but lack the knowledge to
determine if this is a related problem.
Compiled with gcc -O1 -save-temps test.c:
--- Begin test.c ---
#define advance(f) do { ++pos; if ((f) && pos >= argc) return(2); } while (0)
int pos;
int argc; char **argv;
int term();
int
main(int margc, char **margv)
{
argc = margc; argv = margv;
pos = 1;
return term();
}
int
term()
{
int value;
if (pos >= argc) return (2);
if (argv[pos][0] == '!' && argv[pos][1] == '\0')
{
value = 0;
while (pos < argc && argv[pos][0] == '!' && argv[pos][1] == '\0')
{
advance (1);
value = 1 - value;
}
return (value ? !term() : term());
}
return (0);
}
--- End test.c ---
Output of gcc -v:
Reading specs from
/home/mark/tarballs/gcc-cvs/gcc-build/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/specs
Configured with: ../gcc/configure
--prefix=/home/mark/tarballs/gcc-cvs/gcc-build/usr
--libexecdir=/home/mark/tarballs/gcc-cvs/gcc-build/usr/lib --enable-shared
--enable-languages=c
Thread model: posix
gcc version 4.0.0 20040929 (experimental)
The file test.c is cut down from the coreutils program of the same name, which
also suffers from this bug. When supplied with three or more arguments of which
at least the first two are exclamation marks, the program enters an infinite
loop. e.g.
./a.out ! ! foo
I've included a portion of my assembly output below to point out what I think is
going wrong. Line (1) earmarks register %ecx for the 'value' variable. Line (2)
is supposed to be performing ++pos, but in fact performs "pos = original-pos +
value + 1". Lines (3) flip "value" between 0 and 1. Of course this breaks after
two iterations, and the loop never exits.
movl $0, %ecx ; (1)
leal 0(,%eax,4), %ebx
.L13:
leal 1(%edi,%ecx), %eax ; (2)
movl %eax, pos
cmpl %eax, -16(%ebp)
jg .L14
movl $2, %eax
jmp .L8
.L14:
movl $1, %eax ; (3)
subl %ecx, %eax ; (3)
movl %eax, %edx ; (3)
movl %eax, %ecx ; (3)
leal (%ebx,%eax,4), %eax
movl (%eax,%esi), %eax
cmpb $33, (%eax)
jne .L16
cmpb $0, 1(%eax)
je .L13
--
Summary: C Optimization error with -O1 and -O2 on i686
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: m dot calderbank at iname dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 on i686
2004-09-29 22:37 [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686 m dot calderbank at iname dot com
@ 2004-09-29 22:46 ` pinskia at gcc dot gnu dot org
2004-09-30 21:46 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-29 22:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-09-29 22:46 -------
It does look like -fno-ivopts fixes the problem and it does not look related to PR 17474 at all.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |rakdver at gcc dot gnu dot
| |org
Keywords| |wrong-code
Summary|C Optimization error with - |[4.0 Regression] C
|O1 and -O2 on i686 |Optimization error with -O1
| |on i686
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 on i686
2004-09-29 22:37 [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686 m dot calderbank at iname dot com
2004-09-29 22:46 ` [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 " pinskia at gcc dot gnu dot org
@ 2004-09-30 21:46 ` pinskia at gcc dot gnu dot org
2004-10-01 0:21 ` m dot calderbank at iname dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-30 21:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-09-30 21:46 -------
Hmm, this fails for me with -O0 on powerpc-apple-darwin.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 on i686
2004-09-29 22:37 [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686 m dot calderbank at iname dot com
2004-09-29 22:46 ` [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 " pinskia at gcc dot gnu dot org
2004-09-30 21:46 ` pinskia at gcc dot gnu dot org
@ 2004-10-01 0:21 ` m dot calderbank at iname dot com
2004-11-08 23:20 ` reichelt at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: m dot calderbank at iname dot com @ 2004-10-01 0:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From m dot calderbank at iname dot com 2004-10-01 00:21 -------
Actually -O3 is not OK as I thought at first: it produces wrong return codes
rather than going infinite.
Inspection of assembly and test.c.00.expand shows that the problem is the same:
it's treating pos and value as equivalent.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 on i686
2004-09-29 22:37 [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686 m dot calderbank at iname dot com
` (2 preceding siblings ...)
2004-10-01 0:21 ` m dot calderbank at iname dot com
@ 2004-11-08 23:20 ` reichelt at gcc dot gnu dot org
2004-11-08 23:25 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-11-08 23:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From reichelt at gcc dot gnu dot org 2004-11-08 23:20 -------
Here's a reduced testcase. It goes into an infinite loop when compiled
with optimization (-O, -O2, -O3, -Os).
=====================
int i=0;
int main()
{
int j=0;
while (++i<3)
j = 1-j;
return j;
}
=====================
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |reichelt at gcc dot gnu dot
| |org
Severity|normal |critical
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |monitored
Last reconfirmed|0000-00-00 00:00:00 |2004-11-08 23:20:37
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 on i686
2004-09-29 22:37 [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686 m dot calderbank at iname dot com
` (3 preceding siblings ...)
2004-11-08 23:20 ` reichelt at gcc dot gnu dot org
@ 2004-11-08 23:25 ` pinskia at gcc dot gnu dot org
2004-11-08 23:38 ` reichelt at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-08 23:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-11-08 23:25 -------
This is most likely the same as PR 17926.
--
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |17926
nThis| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 on i686
2004-09-29 22:37 [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686 m dot calderbank at iname dot com
` (4 preceding siblings ...)
2004-11-08 23:25 ` pinskia at gcc dot gnu dot org
@ 2004-11-08 23:38 ` reichelt at gcc dot gnu dot org
2004-11-09 0:15 ` rakdver at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-11-08 23:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From reichelt at gcc dot gnu dot org 2004-11-08 23:38 -------
Zdenek, the bug really appears with your ivopts patch
http://gcc.gnu.org/ml/gcc-cvs/2004-09/msg00234.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 on i686
2004-09-29 22:37 [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686 m dot calderbank at iname dot com
` (5 preceding siblings ...)
2004-11-08 23:38 ` reichelt at gcc dot gnu dot org
@ 2004-11-09 0:15 ` rakdver at gcc dot gnu dot org
2004-11-09 11:47 ` rakdver at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rakdver at gcc dot gnu dot org @ 2004-11-09 0:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rakdver at gcc dot gnu dot org 2004-11-09 00:15 -------
This is a problem due to scev. It claims that j is an induction variable with
step 1. Ummm....
Patch in testing.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 on i686
2004-09-29 22:37 [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686 m dot calderbank at iname dot com
` (6 preceding siblings ...)
2004-11-09 0:15 ` rakdver at gcc dot gnu dot org
@ 2004-11-09 11:47 ` rakdver at gcc dot gnu dot org
2004-11-11 20:13 ` cvs-commit at gcc dot gnu dot org
2004-11-11 20:14 ` rakdver at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: rakdver at gcc dot gnu dot org @ 2004-11-09 11:47 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rakdver at gcc dot gnu dot org 2004-11-09 11:46 -------
Patch:
http://gcc.gnu.org/ml/gcc-patches/2004-11/msg00716.html
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 on i686
2004-09-29 22:37 [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686 m dot calderbank at iname dot com
` (7 preceding siblings ...)
2004-11-09 11:47 ` rakdver at gcc dot gnu dot org
@ 2004-11-11 20:13 ` cvs-commit at gcc dot gnu dot org
2004-11-11 20:14 ` rakdver at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-11-11 20:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-11-11 20:12 -------
Subject: Bug 17742
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: rakdver@gcc.gnu.org 2004-11-11 20:12:36
Modified files:
gcc : ChangeLog tree-scalar-evolution.c
Log message:
PR tree-optimization/17742
* tree-scalar-evolution.c (follow_ssa_edge_in_rhs): Handle
MINUS_EXPR correctly.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6279&r2=2.6280
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-scalar-evolution.c.diff?cvsroot=gcc&r1=2.11&r2=2.12
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 on i686
2004-09-29 22:37 [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686 m dot calderbank at iname dot com
` (8 preceding siblings ...)
2004-11-11 20:13 ` cvs-commit at gcc dot gnu dot org
@ 2004-11-11 20:14 ` rakdver at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: rakdver at gcc dot gnu dot org @ 2004-11-11 20:14 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rakdver at gcc dot gnu dot org 2004-11-11 20:14 -------
Fixed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17742
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-11-11 20:14 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-29 22:37 [Bug tree-optimization/17742] New: C Optimization error with -O1 and -O2 on i686 m dot calderbank at iname dot com
2004-09-29 22:46 ` [Bug tree-optimization/17742] [4.0 Regression] C Optimization error with -O1 " pinskia at gcc dot gnu dot org
2004-09-30 21:46 ` pinskia at gcc dot gnu dot org
2004-10-01 0:21 ` m dot calderbank at iname dot com
2004-11-08 23:20 ` reichelt at gcc dot gnu dot org
2004-11-08 23:25 ` pinskia at gcc dot gnu dot org
2004-11-08 23:38 ` reichelt at gcc dot gnu dot org
2004-11-09 0:15 ` rakdver at gcc dot gnu dot org
2004-11-09 11:47 ` rakdver at gcc dot gnu dot org
2004-11-11 20:13 ` cvs-commit at gcc dot gnu dot org
2004-11-11 20:14 ` rakdver 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).