* [Bug c++/22167] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
@ 2005-06-23 23:48 ` dahowell at directv dot com
2005-06-23 23:49 ` dahowell at directv dot com
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dahowell at directv dot com @ 2005-06-23 23:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dahowell at directv dot com 2005-06-23 23:48 -------
Created an attachment (id=9138)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9138&action=view)
Short test file which demonstrates optimization failuer
This is pretty much what was left of basic_string.h after I removed all the
code which was not needed to cause the bug to happen. For the curious, S was
derived from the basic_string template, A was derived from the allocator
object, and p used to be the _M_rep pointer to the basic_string::_Rep
structure. S::init was once basic_string::append.
The function do_nothing was once the allocator's dispose method, but as you can
see it now truly should do nothing. But it doesn't quite do nothing, it causes
the optimizer to fail when optimizing for size. The seemingly pointless
static_cast<A> also is needed to cause the bug. Inlining either S::init or
do_nothing will also make the bug magically disappear.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/22167] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
2005-06-23 23:48 ` [Bug c++/22167] " dahowell at directv dot com
@ 2005-06-23 23:49 ` dahowell at directv dot com
2005-06-24 14:14 ` [Bug rtl-optimization/22167] " pinskia at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dahowell at directv dot com @ 2005-06-23 23:49 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Attachment #9138|Short test file which |Short test file which
description|demonstrates optimization |demonstrates optimization
|failuer |failure
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/22167] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
2005-06-23 23:48 ` [Bug c++/22167] " dahowell at directv dot com
2005-06-23 23:49 ` dahowell at directv dot com
@ 2005-06-24 14:14 ` pinskia at gcc dot gnu dot org
2005-06-29 14:41 ` [Bug rtl-optimization/22167] [3.4/4.0?/4.1? regression] " reichelt 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 @ 2005-06-24 14:14 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Component|c++ |rtl-optimization
Keywords| |wrong-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/22167] [3.4/4.0?/4.1? regression] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
` (2 preceding siblings ...)
2005-06-24 14:14 ` [Bug rtl-optimization/22167] " pinskia at gcc dot gnu dot org
@ 2005-06-29 14:41 ` reichelt at gcc dot gnu dot org
2005-06-29 15:14 ` [Bug rtl-optimization/22167] [3.4 " pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2005-06-29 14:41 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From reichelt at gcc dot gnu dot org 2005-06-29 14:40 -------
I can confirm the bug on mips-sgi-irix6.5 (GCC 3.3.x, 3.4.x).
I can't test whether the bug is also present on gcc 4.0.0 and later.
The same bug also appears on i686-pc-linux-gnu, but only with GCC 3.3.x.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Known to fail| |3.3 3.4.4
Known to work| |3.2.3
Last reconfirmed|0000-00-00 00:00:00 |2005-06-29 14:40:54
date| |
Summary|Strange optimization bug |[3.4/4.0?/4.1? regression]
|when using -Os |Strange optimization bug
| |when using -Os
Target Milestone|--- |3.4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/22167] [3.4 regression] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
` (3 preceding siblings ...)
2005-06-29 14:41 ` [Bug rtl-optimization/22167] [3.4/4.0?/4.1? regression] " reichelt at gcc dot gnu dot org
@ 2005-06-29 15:14 ` pinskia at gcc dot gnu dot org
2005-07-14 13:49 ` rsandifo at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-29 15:14 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-29 15:14 -------
It works for me on powerpc-darwin with 4.0.0, 4.1.0 but does not work with 3.3.3 and 3.4.0, so
removing the 4.0, 4.1 regression markers.
--
What |Removed |Added
----------------------------------------------------------------------------
Known to work|3.2.3 |3.2.3 4.0.0 4.1.0
Summary|[3.4/4.0?/4.1? regression] |[3.4 regression] Strange
|Strange optimization bug |optimization bug when using
|when using -Os |-Os
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/22167] [3.4 regression] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
` (4 preceding siblings ...)
2005-06-29 15:14 ` [Bug rtl-optimization/22167] [3.4 " pinskia at gcc dot gnu dot org
@ 2005-07-14 13:49 ` rsandifo at gcc dot gnu dot org
2005-07-14 18:05 ` [Bug rtl-optimization/22167] [3.4, 4.1 " rsandifo at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2005-07-14 13:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rsandifo at gcc dot gnu dot org 2005-07-14 13:49 -------
I think this is a bug in gcse.c:hoist_code. It appears to date back
to when the code was first added.
The function is supposed to be doing the following:
for each block BB
for each expr E
HOISTABLE := 0
A: if (E is very busy at the end of BB
&& E is transparent at the end of BB)
for each block BB' that is dominated by BB
if (BB' uses E
&& a computation of E at the end of BB would reach that use)
HOISTABLE := HOISTABLE + 1
HOIST_EXPRS[E] := HOISTABLE > 1
if there exists an E such that HOIST_EXPRS[E] > 0
for each expr E
B: if HOIST_EXPRS[E]
for each block BB' that is dominated by BB
if (BB' uses E
&& a computation of E at the end of BB would reach that use)
replace the use with the reaching reg
Unfortunately, the implementation of condition B is checking the wrong
bitmap (hoist_vbeout instead of hoist_exprs). In other words, the code
is effectively doing:
B: if E is very busy at the end of BB
Thus hoist_code() would do nothing for a function that has no candidate
expressions with two or more suitable uses. However, if a function
_does_ have such an expression, hoist_code() would hoist all candidate
expressions, even if they have only one use. And it would effectively
drop the all-important "E is transparent at the end of BB" condition
when doing this.
So what happens on MIPS (and presumably powerpc) is this: we have two
candidate expressions that are of interest:
1. (mem s.p)
2. (high "p is 0x%x and p2 ...")
Both expressions are very busy on the output from block 0, which ends
with the call to S::init(). And both expressions have more than one
suitable use. However, expression 1 is not entered in HOIST_EXPRS
because it is not transparent at the end of block 0. We'd have to
insert the load _before_ the call to S::init(), and that would change
its value. Expression 2 _is_ transparent at the end of block 0 and
so HOIST_EXPRS[2] is correctly set to true.
So we have one expression that we want to hoist -- expression 2 -- and
we therefore enter the second loop. This then ignores the fact that
expression 1 is not transparent at the end of block 0 and hoists it
anyway.
Although I haven't checked, I think the reason this doesn't show up
on i686 is because there's no equivalent of (high ...) that would
cause the second loop to be executed.
Richard
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rsandifo at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2005-06-29 14:40:54 |2005-07-14 13:49:01
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/22167] [3.4, 4.1 regression] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
` (5 preceding siblings ...)
2005-07-14 13:49 ` rsandifo at gcc dot gnu dot org
@ 2005-07-14 18:05 ` rsandifo at gcc dot gnu dot org
2005-07-14 19:27 ` [Bug rtl-optimization/22167] [3.4/4.0/4.1 " pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2005-07-14 18:05 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rsandifo at gcc dot gnu dot org 2005-07-14 17:55 -------
The reduced testcase that I've just attached fails for 4.1 as
well as 3.4 on mips64-elf. I haven't yet tried 4.0.
--
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|3.3 3.4.4 |3.3 3.4.4 4.1.0
Known to work|3.2.3 4.0.0 4.1.0 |3.2.3 4.0.0
Summary|[3.4 regression] Strange |[3.4, 4.1 regression]
|optimization bug when using |Strange optimization bug
|-Os |when using -Os
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/22167] [3.4/4.0/4.1 regression] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
` (6 preceding siblings ...)
2005-07-14 18:05 ` [Bug rtl-optimization/22167] [3.4, 4.1 " rsandifo at gcc dot gnu dot org
@ 2005-07-14 19:27 ` pinskia at gcc dot gnu dot org
2005-07-21 6:53 ` cvs-commit at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-14 19:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-14 18:57 -------
The reduced testcase also fails on ppc-darwin with 4.0.0.
--
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|3.3 3.4.4 4.1.0 |3.3 3.4.4 4.1.0 4.0.0
Known to work|3.2.3 4.0.0 |3.2.3
Summary|[3.4/4.1 regression] Strange|[3.4/4.0/4.1 regression]
|optimization bug when using |Strange optimization bug
|-Os |when using -Os
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/22167] [3.4/4.0/4.1 regression] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
` (7 preceding siblings ...)
2005-07-14 19:27 ` [Bug rtl-optimization/22167] [3.4/4.0/4.1 " pinskia at gcc dot gnu dot org
@ 2005-07-21 6:53 ` cvs-commit at gcc dot gnu dot org
2005-07-21 6:56 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-07-21 6:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-07-21 06:51 -------
Subject: Bug 22167
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: rsandifo@gcc.gnu.org 2005-07-21 06:51:26
Modified files:
gcc : ChangeLog gcse.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/opt: pr22167.C
Log message:
PR rtl-optimization/22167
* gcse.c (hoist_code): Fix hoist_exprs[] check.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9495&r2=2.9496
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gcse.c.diff?cvsroot=gcc&r1=1.346&r2=1.347
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5790&r2=1.5791
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/pr22167.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/22167] [3.4/4.0/4.1 regression] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
` (8 preceding siblings ...)
2005-07-21 6:53 ` cvs-commit at gcc dot gnu dot org
@ 2005-07-21 6:56 ` cvs-commit at gcc dot gnu dot org
2005-07-21 6:58 ` cvs-commit at gcc dot gnu dot org
2005-07-21 7:10 ` rsandifo at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-07-21 6:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-07-21 06:53 -------
Subject: Bug 22167
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-4_0-branch
Changes by: rsandifo@gcc.gnu.org 2005-07-21 06:53:29
Modified files:
gcc : ChangeLog gcse.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/opt: pr22167.C
Log message:
PR rtl-optimization/22167
* gcse.c (hoist_code): Fix hoist_exprs[] check.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.324&r2=2.7592.2.325
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gcse.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.335&r2=1.335.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.290&r2=1.5084.2.291
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/pr22167.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/22167] [3.4/4.0/4.1 regression] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
` (9 preceding siblings ...)
2005-07-21 6:56 ` cvs-commit at gcc dot gnu dot org
@ 2005-07-21 6:58 ` cvs-commit at gcc dot gnu dot org
2005-07-21 7:10 ` rsandifo at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-07-21 6:58 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-07-21 06:56 -------
Subject: Bug 22167
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_4-branch
Changes by: rsandifo@gcc.gnu.org 2005-07-21 06:56:24
Modified files:
gcc : ChangeLog gcse.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/opt: pr22167.C
Log message:
PR rtl-optimization/22167
* gcse.c (hoist_code): Fix hoist_exprs[] check.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.882&r2=2.2326.2.883
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gcse.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.288.2.9&r2=1.288.2.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.406&r2=1.3389.2.407
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/pr22167.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/22167] [3.4/4.0/4.1 regression] Strange optimization bug when using -Os
2005-06-23 23:37 [Bug c++/22167] New: Strange optimization bug when using -Os dahowell at directv dot com
` (10 preceding siblings ...)
2005-07-21 6:58 ` cvs-commit at gcc dot gnu dot org
@ 2005-07-21 7:10 ` rsandifo at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2005-07-21 7:10 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rsandifo at gcc dot gnu dot org 2005-07-21 06:58 -------
Patch committed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22167
^ permalink raw reply [flat|nested] 13+ messages in thread