public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/31691] New: optimized code taking the wrong branch
@ 2007-04-24 21:14 stephaniechc-gccbug at yahoo dot com
2007-04-25 8:53 ` [Bug middle-end/31691] " rguenth at gcc dot gnu dot org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: stephaniechc-gccbug at yahoo dot com @ 2007-04-24 21:14 UTC (permalink / raw)
To: gcc-bugs
The following example takes the "wrong_branch" when compiled with
gcc -O3 -fno-inline
gcc --version
gcc (GCC) 4.1.2
Copyright (C) 2006 Free Software Foundation, Inc.
===== example =====
#include <stdio.h>
static int get_kind(int v) {
volatile int k = v;
return k;
}
static int some_call(void)
{
return 0;
}
static void wrong_branch(void) {
printf("wrong_branch\n");
}
static int example(int arg)
{
int kind;
kind = get_kind(arg);
if (kind == 9 || kind == 10 || kind == 5) {
if (some_call() == 0) {
int tmp;
// kind = get_kind(arg); // ok if this call is inserted
if (kind == 9 || kind == 10) {
tmp = arg;
} else {
wrong_branch();
} /* if */
return 0;
}
}
return 0;
}
int main(void) {
int v = 10;
example(v);
return 0;
}
===================
The example prints "wrong_branch" when executed. If the second call to get_kind
is uncommented, nothing is printed (which is correct).
The generated assembly code is
===== example.s ======
example:
save %sp, -112, %sp
call get_kind, 0
mov %i0, %o0
add %o0, -9, %g1
subcc %g0, %g1, %g0
subx %g0, -1, %i0
cmp %g1, 1
bleu .LL11
cmp %o0, 5
be .LL11
nop
.LL9:
jmp %i7+8
restore %g0, 0, %o0
.LL11:
call some_call, 0
nop
cmp %o0, 0
bne .LL9
cmp %i0, 0
bne .LL9
nop
call wrong_branch, 0
mov 0, %i0
jmp %i7+8
restore
=======================
--
Summary: optimized code taking the wrong branch
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: stephaniechc-gccbug at yahoo dot com
GCC build triplet: sparc-sun-solaris2.8
GCC host triplet: sparc-sun-solaris2.8+
GCC target triplet: sparc-sun-solaris2.8+
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/31691] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
@ 2007-04-25 8:53 ` rguenth at gcc dot gnu dot org
2007-04-25 10:14 ` [Bug middle-end/31691] [4.1 regression] " ebotcazou at gcc dot gnu dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-04-25 8:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2007-04-25 09:53 -------
Works for me. Can you attach the FILE.c.t93.optimized file you get if you
build with gcc -O3 -fno-inline -fdump-tree-optimized?
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/31691] [4.1 regression] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
2007-04-25 8:53 ` [Bug middle-end/31691] " rguenth at gcc dot gnu dot org
@ 2007-04-25 10:14 ` ebotcazou at gcc dot gnu dot org
2007-04-25 10:15 ` ebotcazou at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-04-25 10:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from ebotcazou at gcc dot gnu dot org 2007-04-25 11:14 -------
Confirmed with -O2 -fno-inline too, thanks for the reduced testcase.
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
Ever Confirmed|0 |1
GCC host triplet|sparc-sun-solaris2.8+ |sparc-sun-solaris2.8
GCC target triplet|sparc-sun-solaris2.8+ |sparc-sun-solaris2.8
Known to fail| |4.1.2
Known to work| |3.4.3 4.2.0 4.3.0
Last reconfirmed|0000-00-00 00:00:00 |2007-04-25 11:14:17
date| |
Summary|optimized code taking the |[4.1 regression] optimized
|wrong branch |code taking the wrong branch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/31691] [4.1 regression] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
2007-04-25 8:53 ` [Bug middle-end/31691] " rguenth at gcc dot gnu dot org
2007-04-25 10:14 ` [Bug middle-end/31691] [4.1 regression] " ebotcazou at gcc dot gnu dot org
@ 2007-04-25 10:15 ` ebotcazou at gcc dot gnu dot org
2007-04-25 13:26 ` stephaniechc-gccbug at yahoo dot com
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-04-25 10:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from ebotcazou at gcc dot gnu dot org 2007-04-25 11:14 -------
Investigating.
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |ebotcazou at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2007-04-25 11:14:17 |2007-04-25 11:14:55
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/31691] [4.1 regression] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
` (2 preceding siblings ...)
2007-04-25 10:15 ` ebotcazou at gcc dot gnu dot org
@ 2007-04-25 13:26 ` stephaniechc-gccbug at yahoo dot com
2007-04-26 10:28 ` [Bug rtl-optimization/31691] " ebotcazou at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: stephaniechc-gccbug at yahoo dot com @ 2007-04-25 13:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from stephaniechc-gccbug at yahoo dot com 2007-04-25 14:26 -------
Created an attachment (id=13438)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13438&action=view)
output of -fdump-tree-optimized
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/31691] [4.1 regression] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
` (3 preceding siblings ...)
2007-04-25 13:26 ` stephaniechc-gccbug at yahoo dot com
@ 2007-04-26 10:28 ` ebotcazou at gcc dot gnu dot org
2007-04-30 10:26 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-04-26 10:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from ebotcazou at gcc dot gnu dot org 2007-04-26 11:28 -------
It's again the RTL combiner.
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |rtl-optimization
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/31691] [4.1 regression] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
` (4 preceding siblings ...)
2007-04-26 10:28 ` [Bug rtl-optimization/31691] " ebotcazou at gcc dot gnu dot org
@ 2007-04-30 10:26 ` pinskia at gcc dot gnu dot org
2007-05-10 11:16 ` ebotcazou at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-30 10:26 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Target Milestone|--- |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/31691] [4.1 regression] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
` (5 preceding siblings ...)
2007-04-30 10:26 ` pinskia at gcc dot gnu dot org
@ 2007-05-10 11:16 ` ebotcazou at gcc dot gnu dot org
2007-05-10 19:30 ` ebotcazou at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-05-10 11:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from ebotcazou at gcc dot gnu dot org 2007-05-10 12:16 -------
*** Bug 31523 has been marked as a duplicate of this bug. ***
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anirkko at insel dot ch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/31691] [4.1 regression] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
` (6 preceding siblings ...)
2007-05-10 11:16 ` ebotcazou at gcc dot gnu dot org
@ 2007-05-10 19:30 ` ebotcazou at gcc dot gnu dot org
2007-05-17 13:30 ` ebotcazou at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-05-10 19:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from ebotcazou at gcc dot gnu dot org 2007-05-10 20:30 -------
Created an attachment (id=13540)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13540&action=view)
Fix for the 4.1 branch.
I'm waiting for the 4.2 branch to reopen in order to install it on all
branches.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/31691] [4.1 regression] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
` (7 preceding siblings ...)
2007-05-10 19:30 ` ebotcazou at gcc dot gnu dot org
@ 2007-05-17 13:30 ` ebotcazou at gcc dot gnu dot org
2007-05-17 13:30 ` ebotcazou at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-05-17 13:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from ebotcazou at gcc dot gnu dot org 2007-05-17 14:30 -------
Subject: Bug 31691
Author: ebotcazou
Date: Thu May 17 13:29:38 2007
New Revision: 124798
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124798
Log:
PR rtl-optimization/31691
* combine.c (simplify_set): Build a new src pattern instead of
substituting its operands in the COMPARE case.
Added:
branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/execute/20070517-1.c
Modified:
branches/gcc-4_2-branch/gcc/ChangeLog
branches/gcc-4_2-branch/gcc/combine.c
branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/31691] [4.1 regression] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
` (8 preceding siblings ...)
2007-05-17 13:30 ` ebotcazou at gcc dot gnu dot org
@ 2007-05-17 13:30 ` ebotcazou at gcc dot gnu dot org
2007-05-17 13:31 ` ebotcazou at gcc dot gnu dot org
2007-05-17 13:34 ` ebotcazou at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-05-17 13:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from ebotcazou at gcc dot gnu dot org 2007-05-17 14:29 -------
Subject: Bug 31691
Author: ebotcazou
Date: Thu May 17 13:29:10 2007
New Revision: 124797
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124797
Log:
PR rtl-optimization/31691
* combine.c (simplify_set): Build a new src pattern instead of
substituting its operands in the COMPARE case.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/20070517-1.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/combine.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/31691] [4.1 regression] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
` (9 preceding siblings ...)
2007-05-17 13:30 ` ebotcazou at gcc dot gnu dot org
@ 2007-05-17 13:31 ` ebotcazou at gcc dot gnu dot org
2007-05-17 13:34 ` ebotcazou at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-05-17 13:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from ebotcazou at gcc dot gnu dot org 2007-05-17 14:30 -------
Subject: Bug 31691
Author: ebotcazou
Date: Thu May 17 13:30:15 2007
New Revision: 124799
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124799
Log:
PR rtl-optimization/31691
* combine.c (simplify_set): Build a new src pattern instead of
substituting its operands in the COMPARE case.
Added:
branches/gcc-4_1-branch/gcc/testsuite/gcc.c-torture/execute/20070517-1.c
Modified:
branches/gcc-4_1-branch/gcc/ChangeLog
branches/gcc-4_1-branch/gcc/combine.c
branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/31691] [4.1 regression] optimized code taking the wrong branch
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
` (10 preceding siblings ...)
2007-05-17 13:31 ` ebotcazou at gcc dot gnu dot org
@ 2007-05-17 13:34 ` ebotcazou at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2007-05-17 13:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from ebotcazou at gcc dot gnu dot org 2007-05-17 14:34 -------
Fixed on all branches.
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2007-
| |05/msg01131.html
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31691
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-05-17 13:34 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-24 21:14 [Bug c/31691] New: optimized code taking the wrong branch stephaniechc-gccbug at yahoo dot com
2007-04-25 8:53 ` [Bug middle-end/31691] " rguenth at gcc dot gnu dot org
2007-04-25 10:14 ` [Bug middle-end/31691] [4.1 regression] " ebotcazou at gcc dot gnu dot org
2007-04-25 10:15 ` ebotcazou at gcc dot gnu dot org
2007-04-25 13:26 ` stephaniechc-gccbug at yahoo dot com
2007-04-26 10:28 ` [Bug rtl-optimization/31691] " ebotcazou at gcc dot gnu dot org
2007-04-30 10:26 ` pinskia at gcc dot gnu dot org
2007-05-10 11:16 ` ebotcazou at gcc dot gnu dot org
2007-05-10 19:30 ` ebotcazou at gcc dot gnu dot org
2007-05-17 13:30 ` ebotcazou at gcc dot gnu dot org
2007-05-17 13:30 ` ebotcazou at gcc dot gnu dot org
2007-05-17 13:31 ` ebotcazou at gcc dot gnu dot org
2007-05-17 13:34 ` ebotcazou 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).