* [Bug optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
@ 2004-05-01 14:30 ` anton at mips dot complang dot tuwien dot ac dot at
2004-05-01 14:38 ` pinskia at gcc dot gnu dot org
` (40 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: anton at mips dot complang dot tuwien dot ac dot at @ 2004-05-01 14:30 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From anton at mips dot complang dot tuwien dot ac dot at 2004-05-01 14:30 -------
Created an attachment (id=6206)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6206&action=view)
test input (file ef.i mentioned in the bug report)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
2004-05-01 14:30 ` [Bug optimization/15242] " anton at mips dot complang dot tuwien dot ac dot at
@ 2004-05-01 14:38 ` pinskia at gcc dot gnu dot org
2004-05-01 14:41 ` pinskia at gcc dot gnu dot org
` (39 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-01 14:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-01 14:38 -------
Note jumping out of a statement expression is really illegal and should not be done.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |pessimizes-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
2004-05-01 14:30 ` [Bug optimization/15242] " anton at mips dot complang dot tuwien dot ac dot at
2004-05-01 14:38 ` pinskia at gcc dot gnu dot org
@ 2004-05-01 14:41 ` pinskia at gcc dot gnu dot org
2004-05-01 14:42 ` pinskia at gcc dot gnu dot org
` (38 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-01 14:41 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
BugsThisDependsOn| |15243
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (2 preceding siblings ...)
2004-05-01 14:41 ` pinskia at gcc dot gnu dot org
@ 2004-05-01 14:42 ` pinskia at gcc dot gnu dot org
2004-05-01 15:03 ` anton at a0 dot complang dot tuwien dot ac dot at
` (37 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-01 14:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-01 14:42 -------
One more thing statement expressions should end with a non-void expression.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (3 preceding siblings ...)
2004-05-01 14:42 ` pinskia at gcc dot gnu dot org
@ 2004-05-01 15:03 ` anton at a0 dot complang dot tuwien dot ac dot at
2004-05-01 15:13 ` pinskia at gcc dot gnu dot org
` (36 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: anton at a0 dot complang dot tuwien dot ac dot at @ 2004-05-01 15:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From anton at a0 dot complang dot tuwien dot ac dot at 2004-05-01 15:03 -------
Subject: Re: pessimization of "goto *"
pinskia at gcc dot gnu dot org wrote:
> Note jumping out of a statement expression is really illegal and should not be done.
Statement expressions are used here just to produce a way to include a
statement sequence in a macro. Do you recommend that we should switch
from
({ ... })
to
do { ... } while (0)
?
Or do you have a different suggestion?
BTW, looking in the gcc-3.4.0 manual, I don't see the restrictions you
mention, and gcc-3.4.0 -Wall also does not complain about this usage.
Actually the manual explicitly says:
|(If you use some other kind of statement last within the braces, the
|construct has type `void', and thus effectively no value.)
which I would interpret as "Anything goes, as long as you don't use
the value of the statement expression".
- anton
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (4 preceding siblings ...)
2004-05-01 15:03 ` anton at a0 dot complang dot tuwien dot ac dot at
@ 2004-05-01 15:13 ` pinskia at gcc dot gnu dot org
2004-05-02 7:24 ` anton at a0 dot complang dot tuwien dot ac dot at
` (35 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-01 15:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-01 15:13 -------
The reason why I say this is because of on the tree-ssa, it does warn about using about void statements
as the end, and on the tree-ssa right now ICEs on the tree-ssa, see PR 15243. Also this is not
documented there is another bug for that, PR 772.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (5 preceding siblings ...)
2004-05-01 15:13 ` pinskia at gcc dot gnu dot org
@ 2004-05-02 7:24 ` anton at a0 dot complang dot tuwien dot ac dot at
2004-05-02 19:06 ` jsm at polyomino dot org dot uk
` (34 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: anton at a0 dot complang dot tuwien dot ac dot at @ 2004-05-02 7:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From anton at a0 dot complang dot tuwien dot ac dot at 2004-05-02 07:24 -------
Subject: Re: pessimization of "goto *"
pinskia at gcc dot gnu dot org wrote:
>
>
> ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-01 15:13 -------
> The reason why I say this is because of on the tree-ssa, it does warn about using about void statements
> as the end, and on the tree-ssa right now ICEs on the tree-ssa, see PR 15243. Also this is not
> documented there is another bug for that, PR 772.
And that refers to a discussion in the mailing list, and the only
mention of a problem with jumping out that I found there was in
<http://gcc.gnu.org/ml/gcc/2000-07/msg00721.html>. For this example
the semantics seem pretty obvious and well-defined to me (in contrast
to the jump-into example), and this was just a compiler bug.
If you find this bug hard to fix, it's ok with me if you document that
jumping out does not work and give a warning (and eventually an error)
on compiling it, and I will work around this restriction.
If you want, I can also prepare a version of the test file that uses
do...while(0) instead of statement expressions in some places.
- anton
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (6 preceding siblings ...)
2004-05-02 7:24 ` anton at a0 dot complang dot tuwien dot ac dot at
@ 2004-05-02 19:06 ` jsm at polyomino dot org dot uk
2004-05-04 15:06 ` anton at a0 dot complang dot tuwien dot ac dot at
` (33 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-05-02 19:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jsm at polyomino dot org dot uk 2004-05-02 19:06 -------
Subject: Re: pessimization of "goto *"
On Sun, 2 May 2004, anton at a0 dot complang dot tuwien dot ac dot at wrote:
> And that refers to a discussion in the mailing list, and the only
> mention of a problem with jumping out that I found there was in
> <http://gcc.gnu.org/ml/gcc/2000-07/msg00721.html>. For this example
> the semantics seem pretty obvious and well-defined to me (in contrast
> to the jump-into example), and this was just a compiler bug.
The semantics are neither obvious nor well-defined, because other parts of
the larger expression containing the statement expression might or might
not have been evaluated. The only thing in C giving rise to such a
situation (where parts of an expression might or might not have been
evaluated when a jump occurs) is setjmp/longjmp, and you should be able to
use longjmp in statement expressions; goto can't have such effects in C so
it's dubious allowing them in GNU C.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (7 preceding siblings ...)
2004-05-02 19:06 ` jsm at polyomino dot org dot uk
@ 2004-05-04 15:06 ` anton at a0 dot complang dot tuwien dot ac dot at
2004-05-06 4:45 ` pinskia at gcc dot gnu dot org
` (32 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: anton at a0 dot complang dot tuwien dot ac dot at @ 2004-05-04 15:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From anton at a0 dot complang dot tuwien dot ac dot at 2004-05-04 15:06 -------
Subject: Re: pessimization of "goto *"
jsm at polyomino dot org dot uk wrote:
>
>
> ------- Additional Comments From jsm at polyomino dot org dot uk 2004-05-02 19:06 -------
> Subject: Re: pessimization of "goto *"
>
> On Sun, 2 May 2004, anton at a0 dot complang dot tuwien dot ac dot at wrote:
>
> > And that refers to a discussion in the mailing list, and the only
> > mention of a problem with jumping out that I found there was in
> > <http://gcc.gnu.org/ml/gcc/2000-07/msg00721.html>. For this example
> > the semantics seem pretty obvious and well-defined to me (in contrast
> > to the jump-into example), and this was just a compiler bug.
>
> The semantics are neither obvious nor well-defined, because other parts of
> the larger expression containing the statement expression might or might
> not have been evaluated.
The example is:
a:
f ("%d\n", ({goto a;})
The only other part that might or might not have been evaluated is the
"%d\n"; since this has no side effect, it does not matter whether it
is evaluated or not. So the obvious (to me) and well-defined
semantics of this example is to be equivalent to
a: goto a;
In general, true, if the other parts of the expression have side
effects, the whole expression is undefined, but that's just the same
as in other cases with side effects in expression evaluation, so the
semantics still seem obvious to me.
> The only thing in C giving rise to such a
> situation (where parts of an expression might or might not have been
> evaluated when a jump occurs) is setjmp/longjmp, and you should be able to
> use longjmp in statement expressions; goto can't have such effects in C so
> it's dubious allowing them in GNU C.
Variable definitions also give rise to such situations (where parts of
an expression might or might not have been evaluated when the
definition occurs), and this may also lead to undefined behaviour, and
this cannot happen in C. Does this make allowing variable definitions
in statement expressions dubious in GNU C?
I don't think so (after all, they are used in the first example for
statement expressions), and I don't think that this kind of argument
is valid for other things that cannot occur in C expressions, either.
If only things were allowed in statement expressions that are allowed
in C expressions, then statement expressions would be redundant; you
could simply write "(expr, expr, expr)" instead of "({expr; expr;
expr;})".
- anton
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (8 preceding siblings ...)
2004-05-04 15:06 ` anton at a0 dot complang dot tuwien dot ac dot at
@ 2004-05-06 4:45 ` pinskia at gcc dot gnu dot org
2004-05-23 9:40 ` [Bug rtl-optimization/15242] " zlomek at gcc dot gnu dot org
` (31 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-06 4:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-06 04:45 -------
Confirmed a reduced testcase:
int f(int i, int j)
{
static void *a[5] = {&&b,&&c,&&d,&&e,&&f};
if (i >=5) i = 0; if (i<=0)i=5;
goto *a[i];
e:
i++; if (i >=5) i = 0; if (i<=0)i=5;
j++;
goto *a[i];
f:
i--; if (i >=5) i = 0; if (i<=0)i=5;
j--;
goto *a[i];
b:
i+=2; if (i >=5) i = 0; if (i<=0)i=5;
goto *a[i];
c:
i*=2; if (i >=5) i = 0; if (i<=0)i=5;
goto *a[i];
d:;
}
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-05-06 04:45:35
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (9 preceding siblings ...)
2004-05-06 4:45 ` pinskia at gcc dot gnu dot org
@ 2004-05-23 9:40 ` zlomek at gcc dot gnu dot org
2004-05-25 9:28 ` zlomek at gcc dot gnu dot org
` (30 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: zlomek at gcc dot gnu dot org @ 2004-05-23 9:40 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Last reconfirmed|2004-05-06 04:45:35 |2004-05-22 13:47:15
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (10 preceding siblings ...)
2004-05-23 9:40 ` [Bug rtl-optimization/15242] " zlomek at gcc dot gnu dot org
@ 2004-05-25 9:28 ` zlomek at gcc dot gnu dot org
2004-05-26 18:57 ` pinskia at gcc dot gnu dot org
` (29 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: zlomek at gcc dot gnu dot org @ 2004-05-25 9:28 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From zlomek at gcc dot gnu dot org 2004-05-24 14:03 -------
Proposed patch:
http://gcc.gnu.org/ml/gcc-patches/2004-05/msg01526.html
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (11 preceding siblings ...)
2004-05-25 9:28 ` zlomek at gcc dot gnu dot org
@ 2004-05-26 18:57 ` pinskia at gcc dot gnu dot org
2004-06-16 7:01 ` pinskia at gcc dot gnu dot org
` (28 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-26 18:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-05-26 12:29 -------
Newest Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-05/msg01670.html>.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (12 preceding siblings ...)
2004-05-26 18:57 ` pinskia at gcc dot gnu dot org
@ 2004-06-16 7:01 ` pinskia at gcc dot gnu dot org
2004-07-06 20:35 ` anton at mips dot complang dot tuwien dot ac dot at
` (27 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-16 7:01 UTC (permalink / raw)
To: gcc-bugs
--
Bug 15242 depends on bug 15243, which changed state.
Bug 15243 Summary: [3.5 regression] ICE on statement expression (return void) inside a statement expression
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15243
What |Old Value |New Value
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (13 preceding siblings ...)
2004-06-16 7:01 ` pinskia at gcc dot gnu dot org
@ 2004-07-06 20:35 ` anton at mips dot complang dot tuwien dot ac dot at
2004-07-06 22:00 ` pinskia at gcc dot gnu dot org
` (26 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: anton at mips dot complang dot tuwien dot ac dot at @ 2004-07-06 20:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From anton at mips dot complang dot tuwien dot ac dot at 2004-07-06 20:35 -------
Subject: Re: pessimization of "goto *"
pinskia at gcc dot gnu dot org wrote:
> Newest Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-05/msg01670.html>.
I tried this patch with gcc-3.5-20040523, and the problem was still
there, for both the reduced test case, and a variant (work around PR
15243) of the original testcase.
I also tried this patch with gcc-core-3.5-20040704, and it applies
cleanly, but then produces a compilation error:
../../gcc-3.5-20040704/gcc/bb-reorder.c: In function `duplicate_computed_gotos':
../../gcc-3.5-20040704/gcc/bb-reorder.c:1989: error: structure has no member named `computed_goto_common_label'
make[2]: *** [bb-reorder.o] Error 1
make[2]: Leaving directory `/nfs/nfstmp/anton/gcc-patched/gcc-3.5-20040704-i386/gcc'
- anton
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (14 preceding siblings ...)
2004-07-06 20:35 ` anton at mips dot complang dot tuwien dot ac dot at
@ 2004-07-06 22:00 ` pinskia at gcc dot gnu dot org
2004-07-07 4:49 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
` (25 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-06 22:00 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-07-06 22:00 -------
It looks like you can remove:
+ if (!cfun->computed_goto_common_label)
+ return;
from the patch.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (15 preceding siblings ...)
2004-07-06 22:00 ` pinskia at gcc dot gnu dot org
@ 2004-07-07 4:49 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
2004-07-07 13:34 ` zlomek at gcc dot gnu dot org
` (24 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: zlomj9am at artax dot karlin dot mff dot cuni dot cz @ 2004-07-07 4:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From zlomj9am at artax dot karlin dot mff dot cuni dot cz 2004-07-07 04:49 -------
Subject: Re: pessimization of "goto *"
> ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-07-06 22:00 -------
> It looks like you can remove:
> + if (!cfun->computed_goto_common_label)
> + return;
>
> from the patch.
cfun->computed_goto_common_label can be replaced by cfun->has_computed_jump.
The test is there not to scan the function if the computed goto is not
used in the function.
Josef
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (16 preceding siblings ...)
2004-07-07 4:49 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
@ 2004-07-07 13:34 ` zlomek at gcc dot gnu dot org
2004-07-08 13:03 ` anton at mips dot complang dot tuwien dot ac dot at
` (23 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: zlomek at gcc dot gnu dot org @ 2004-07-07 13:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From zlomek at gcc dot gnu dot org 2004-07-07 13:34 -------
> I tried this patch with gcc-3.5-20040523, and the problem was still
there
The optimization is enabled at -O2 (or -O -freorder-blocks).
If there is a uncond jump to a block containing a computed jump and the block is
small enough (several instructions) the block is copied to eliminate the uncond
jump.
When I was testing the patch with current mainline I have noticed that the
current_function_has_computed_jump flag is incorrectly unset in make_edges()
when compiling ef.i. IMHO the flag should not be set initialized to 0 (or 1 if
flag_reorder_blocks_and_partition) in make_edges() but somewhere earlier because
make_edges() can be called several times and only a subset of blocks may be
scanned for computed jumps in it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (17 preceding siblings ...)
2004-07-07 13:34 ` zlomek at gcc dot gnu dot org
@ 2004-07-08 13:03 ` anton at mips dot complang dot tuwien dot ac dot at
2004-07-16 6:50 ` zlomek at gcc dot gnu dot org
` (22 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: anton at mips dot complang dot tuwien dot ac dot at @ 2004-07-08 13:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From anton at mips dot complang dot tuwien dot ac dot at 2004-07-08 13:03 -------
Subject: Re: pessimization of "goto *"
zlomek at gcc dot gnu dot org wrote:
> The optimization is enabled at -O2
Not as far as I can tell (tried it on i386 with patched versions of
gcc-3.5-20040704 and gcc-3.5-20040523).
> (or -O -freorder-blocks).
That seems to work, though.
We would like to use -fno-reorder-blocks with
duplicate_computed_gotos, either through an extra option, or by just
having duplicate_computed_gotos all the time (at least for our code
these gotos were duplicated already in the source code, so duplicating
them again in the back end is closer to the idea of
-fno-reorder-blocks than not duplicating them).
> If there is a uncond jump to a block containing a computed jump and the block is
> small enough (several instructions) the block is copied to eliminate the uncond
> jump.
>
> When I was testing the patch with current mainline I have noticed that the
> current_function_has_computed_jump flag is incorrectly unset in make_edges()
> when compiling ef.i.
Ok, that explains why this patch does not work for ef.i.
One other thing I noticed is that apparently there is no combining
pass (or its tree-ssa equivalent) after duplicate_computed_gotos,
resulting in compiling code like
goto *a[i];
into
movl a.0(,%ebx,4), %eax
jmp *%eax
instead of
jmp *a.0(,%ebx,4)
Thanks for your efforts,
- anton
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (18 preceding siblings ...)
2004-07-08 13:03 ` anton at mips dot complang dot tuwien dot ac dot at
@ 2004-07-16 6:50 ` zlomek at gcc dot gnu dot org
2004-07-16 7:01 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
` (21 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: zlomek at gcc dot gnu dot org @ 2004-07-16 6:50 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
BugsThisDependsOn| |16585
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (19 preceding siblings ...)
2004-07-16 6:50 ` zlomek at gcc dot gnu dot org
@ 2004-07-16 7:01 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
2004-07-16 8:17 ` anton at mips dot complang dot tuwien dot ac dot at
` (20 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: zlomj9am at artax dot karlin dot mff dot cuni dot cz @ 2004-07-16 7:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From zlomj9am at artax dot karlin dot mff dot cuni dot cz 2004-07-16 07:01 -------
Subject: Re: pessimization of "goto *"
> > The optimization is enabled at -O2
> Not as far as I can tell (tried it on i386 with patched versions of
> gcc-3.5-20040704 and gcc-3.5-20040523).
Yes, it is enabled by the patch. The patch duplicates block with computed goto
to place where a uncond jump to the conputed goto block is if the block is
small enough.
The computed jump in the small testcase is not duplicated, because the uncond
jumps from other places do not jump to a basic block which contains the
computed jump but to other block:
f:
pushl %ebp
movl %esp, %ebp
pushl %ebx
movl 8(%ebp), %ebx
.p2align 2,,3
.L37:
cmpl $4, %ebx
jle .L39
.L34:
movl $5, %ebx
.L9:
movl a.1118(,%ebx,4), %eax
jmp *%eax
.p2align 2,,3
.L39:
testl %ebx, %ebx
jg .L9
jmp .L34
.p2align 2,,3
.L3:
popl %ebx
leave
ret
.p2align 2,,3
.L2:
sall %ebx
jmp .L37
.p2align 2,,3
.L1:
addl $2, %ebx
jmp .L37
.p2align 2,,3
.L5:
decl %ebx
jmp .L37
.p2align 2,,3
.L4:
incl %ebx
jmp .L37
However, I see that after the L39 there is a cond jump to the computed jump block.
This is not handled by my patch but could be.
> We would like to use -fno-reorder-blocks with
> duplicate_computed_gotos, either through an extra option, or by just
> having duplicate_computed_gotos all the time (at least for our code
> these gotos were duplicated already in the source code, so duplicating
> them again in the back end is closer to the idea of
> -fno-reorder-blocks than not duplicating them).
Adding an new flag is possible. However, I do not see why you explicitelly want
to disable reorder-blocks.
> One other thing I noticed is that apparently there is no combining
> pass (or its tree-ssa equivalent) after duplicate_computed_gotos,
> resulting in compiling code like
>
> goto *a[i];
>
> into
>
> movl a.0(,%ebx,4), %eax
> jmp *%eax
>
> instead of
>
> jmp *a.0(,%ebx,4)
The combiner should have already combined these insns before the duplication of
computed gotos is run. This pass just duplicates some insns.
Josef
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (20 preceding siblings ...)
2004-07-16 7:01 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
@ 2004-07-16 8:17 ` anton at mips dot complang dot tuwien dot ac dot at
2004-07-16 8:42 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
` (19 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: anton at mips dot complang dot tuwien dot ac dot at @ 2004-07-16 8:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From anton at mips dot complang dot tuwien dot ac dot at 2004-07-16 08:17 -------
Subject: Re: pessimization of "goto *"
zlomj9am at artax dot karlin dot mff dot cuni dot cz wrote:
> > > The optimization is enabled at -O2
> > Not as far as I can tell (tried it on i386 with patched versions of
> > gcc-3.5-20040704 and gcc-3.5-20040523).
>
> Yes, it is enabled by the patch. The patch duplicates block with computed goto
> to place where a uncond jump to the conputed goto block is if the block is
> small enough.
> The computed jump in the small testcase is not duplicated, because the uncond
> jumps from other places do not jump to a basic block which contains the
> computed jump but to other block:
...
Thanks for opening my eyes.
> > We would like to use -fno-reorder-blocks with
> > duplicate_computed_gotos, either through an extra option, or by just
> > having duplicate_computed_gotos all the time (at least for our code
> > these gotos were duplicated already in the source code, so duplicating
> > them again in the back end is closer to the idea of
> > -fno-reorder-blocks than not duplicating them).
>
> Adding an new flag is possible. However, I do not see why you explicitelly want
> to disable reorder-blocks.
We need it for the dynamic superinstruction optimization (aka
selective inlining, PLDI'98 p. 291) in Gforth and further
optimizations building on that (other people working on efficient
interpreters/dynamic code generators have the same problem; e.g., I
recently talked to Etienne Gagnon (http://sablevm.org/) about this;
qemu also uses -fno-reorder-blocks).
For dynamic superinstructions we need to ensure that the machine code
corresponding to source code between two labels is between the
addresses that gcc produces for the labels. The flag
-fno-reorder-blocks almost gives us that (but the sharing of the
"goto *"s breaks that).
Even for just plain interpreters (without dynamic superinstructions),
the sharing of the "goto *"s resulting from the merging of code after
conditional jumps (as shown in the simplified testcase) will often
reduce performance significantly through lower BTB accuracy. So for
performance one probably wants to use -fno-reorder-blocks there,
unless this results in merging the "goto *"s, as it does now.
> > One other thing I noticed is that apparently there is no combining
> > pass (or its tree-ssa equivalent) after duplicate_computed_gotos,
> > resulting in compiling code like
> >
> > goto *a[i];
> >
> > into
> >
> > movl a.0(,%ebx,4), %eax
> > jmp *%eax
> >
> > instead of
> >
> > jmp *a.0(,%ebx,4)
>
> The combiner should have already combined these insns before the duplication of
> computed gotos is run. This pass just duplicates some insns.
My guess is that the combiner does not combine these insns before
duplication, because they are in different basic blocks before
duplication. Without duplication the code would look like:
movl a.0(,%ebx,4), %eax
jmp .L9
...
.L9:
jmp *%eax
- anton
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (21 preceding siblings ...)
2004-07-16 8:17 ` anton at mips dot complang dot tuwien dot ac dot at
@ 2004-07-16 8:42 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
2004-10-03 20:25 ` bernd dot paysan at gmx dot de
` (18 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: zlomj9am at artax dot karlin dot mff dot cuni dot cz @ 2004-07-16 8:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From zlomj9am at artax dot karlin dot mff dot cuni dot cz 2004-07-16 08:42 -------
Subject: Re: pessimization of "goto *"
> > Adding an new flag is possible. However, I do not see why you explicitelly want
> > to disable reorder-blocks.
>
> We need it for the dynamic superinstruction optimization (aka
> selective inlining, PLDI'98 p. 291) in Gforth and further
> optimizations building on that (other people working on efficient
> interpreters/dynamic code generators have the same problem; e.g., I
> recently talked to Etienne Gagnon (http://sablevm.org/) about this;
> qemu also uses -fno-reorder-blocks).
>
> For dynamic superinstructions we need to ensure that the machine code
> corresponding to source code between two labels is between the
> addresses that gcc produces for the labels. The flag
> -fno-reorder-blocks almost gives us that (but the sharing of the
> "goto *"s breaks that).
I see.
> Even for just plain interpreters (without dynamic superinstructions),
> the sharing of the "goto *"s resulting from the merging of code after
> conditional jumps (as shown in the simplified testcase) will often
> reduce performance significantly through lower BTB accuracy. So for
> performance one probably wants to use -fno-reorder-blocks there,
> unless this results in merging the "goto *"s, as it does now.
I see. So duplication of computed jumps probably should be at -O
and have a special flag too.
Josef
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (22 preceding siblings ...)
2004-07-16 8:42 ` zlomj9am at artax dot karlin dot mff dot cuni dot cz
@ 2004-10-03 20:25 ` bernd dot paysan at gmx dot de
2004-10-04 12:21 ` giovannibajo at libero dot it
` (17 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: bernd dot paysan at gmx dot de @ 2004-10-03 20:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bernd dot paysan at gmx dot de 2004-10-03 20:25 -------
On Wednesday 07 July 2004 06:49, zlomj9am at artax dot karlin dot mff dot cuni
dot cz wrote:
> cfun->computed_goto_common_label can be replaced by
> cfun->has_computed_jump. The test is there not to scan the function if the
> computed goto is not used in the function.
Since your patch is still not in the gcc 4.0.0-xxx codebase, I've modified it
to work with the current CVS version. There's still the problem that the jump
does not combine with the previous instruction, and that therefore one
valuable (especially on x86!) register is used up. As trigger condition for
goto duplication I used the -fno-crossjumping switch, together with
optimization.
I've put the patch online under
http://www.jwdt.com/~paysan/gcc-4.0.0.patch
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (23 preceding siblings ...)
2004-10-03 20:25 ` bernd dot paysan at gmx dot de
@ 2004-10-04 12:21 ` giovannibajo at libero dot it
2004-10-25 21:10 ` steven at gcc dot gnu dot org
` (16 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-04 12:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-10-04 12:21 -------
Bernd, the patch needs to be posted to gcc-patches@ after a full bootstrap &
test cycle to gather attention. Probably Josef should take care of this (being
the assigneed of this bug).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (24 preceding siblings ...)
2004-10-04 12:21 ` giovannibajo at libero dot it
@ 2004-10-25 21:10 ` steven at gcc dot gnu dot org
2004-12-18 16:46 ` [Bug rtl-optimization/15242] [4.0 regression] " steven at gcc dot gnu dot org
` (15 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: steven at gcc dot gnu dot org @ 2004-10-25 21:10 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From steven at gcc dot gnu dot org 2004-10-25 21:10 -------
I have a patch that fixes this. I need to figure out a way to do it in a way
that doesn't require you to pass "-fno-crossjumping -fno-gcse" but I'll figure
out something...
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|zlomek at gcc dot gnu dot |steven at gcc dot gnu dot
|org |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [4.0 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (25 preceding siblings ...)
2004-10-25 21:10 ` steven at gcc dot gnu dot org
@ 2004-12-18 16:46 ` steven at gcc dot gnu dot org
2004-12-18 18:18 ` [Bug rtl-optimization/15242] [3.3/3.4/4.0 " pinskia at gcc dot gnu dot org
` (14 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: steven at gcc dot gnu dot org @ 2004-12-18 16:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From steven at gcc dot gnu dot org 2004-12-18 16:46 -------
Comes from factoring computed gotos, so this is a code quality regression.
--
What |Removed |Added
----------------------------------------------------------------------------
Summary|pessimization of "goto *" |[4.0 regression]
| |pessimization of "goto *"
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4/4.0 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (26 preceding siblings ...)
2004-12-18 16:46 ` [Bug rtl-optimization/15242] [4.0 regression] " steven at gcc dot gnu dot org
@ 2004-12-18 18:18 ` pinskia at gcc dot gnu dot org
2005-01-26 17:28 ` steven at gcc dot gnu dot org
` (13 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-18 18:18 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.0 regression] |[3.3/3.4/4.0 regression]
|pessimization of "goto *" |pessimization of "goto *"
Target Milestone|--- |3.4.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4/4.0 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (27 preceding siblings ...)
2004-12-18 18:18 ` [Bug rtl-optimization/15242] [3.3/3.4/4.0 " pinskia at gcc dot gnu dot org
@ 2005-01-26 17:28 ` steven at gcc dot gnu dot org
2005-01-27 13:45 ` pinskia at gcc dot gnu dot org
` (12 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-01-26 17:28 UTC (permalink / raw)
To: gcc-bugs
--
Bug 15242 depends on bug 16585, which changed state.
Bug 16585 Summary: current_function_has_computed_jump incorrectly changed in make_edges
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16585
What |Old Value |New Value
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4/4.0 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (28 preceding siblings ...)
2005-01-26 17:28 ` steven at gcc dot gnu dot org
@ 2005-01-27 13:45 ` pinskia at gcc dot gnu dot org
2005-02-01 10:04 ` cvs-commit at gcc dot gnu dot org
` (11 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-27 13:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-27 13:44 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-01/msg02001.html>.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4/4.0 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (29 preceding siblings ...)
2005-01-27 13:45 ` pinskia at gcc dot gnu dot org
@ 2005-02-01 10:04 ` cvs-commit at gcc dot gnu dot org
2005-02-01 10:11 ` [Bug rtl-optimization/15242] [3.3/3.4 " steven at gcc dot gnu dot org
` (10 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-02-01 10:04 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-02-01 10:03 -------
Subject: Bug 15242
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: steven@gcc.gnu.org 2005-02-01 10:03:27
Modified files:
gcc : ChangeLog basic-block.h bb-reorder.c
cfgcleanup.c params.def passes.c
gcc/doc : invoke.texi
Log message:
PR optimization/15242
* params.def (PARAM_MAX_GOTO_DUPLICATION_INSNS): New param.
* basic-block.h (duplicate_computed_gotos): Add prototype.
* bb-reorder.c (duplicate_computed_gotos): New function to
duplicate sufficiently small blocks ending in a computed jump.
* passes.c (rest_of_compilation): Call duplicate_computed_gotos
if not optimizing for size.
* cfgcleanup.c (try_crossjump_bb): If not optimizing for size,
never do tail merging for blocks ending in a computed jump.
* doc/invoke.texi: Document the max-goto-duplication-insns param.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7359&r2=2.7360
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/basic-block.h.diff?cvsroot=gcc&r1=1.236&r2=1.237
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/bb-reorder.c.diff?cvsroot=gcc&r1=1.88&r2=1.89
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfgcleanup.c.diff?cvsroot=gcc&r1=1.138&r2=1.139
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/params.def.diff?cvsroot=gcc&r1=1.53&r2=1.54
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/passes.c.diff?cvsroot=gcc&r1=2.64&r2=2.65
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/invoke.texi.diff?cvsroot=gcc&r1=1.571&r2=1.572
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (30 preceding siblings ...)
2005-02-01 10:04 ` cvs-commit at gcc dot gnu dot org
@ 2005-02-01 10:11 ` steven at gcc dot gnu dot org
2005-02-07 18:56 ` kazu at cs dot umass dot edu
` (9 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-02-01 10:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From steven at gcc dot gnu dot org 2005-02-01 10:11 -------
Should be fixed on mainline now.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|steven at gcc dot gnu dot |unassigned at gcc dot gnu
|org |dot org
Status|ASSIGNED |NEW
Summary|[3.3/3.4/4.0 regression] |[3.3/3.4 regression]
|pessimization of "goto *" |pessimization of "goto *"
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (31 preceding siblings ...)
2005-02-01 10:11 ` [Bug rtl-optimization/15242] [3.3/3.4 " steven at gcc dot gnu dot org
@ 2005-02-07 18:56 ` kazu at cs dot umass dot edu
2005-02-07 19:00 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: kazu at cs dot umass dot edu @ 2005-02-07 18:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kazu at cs dot umass dot edu 2005-02-07 05:28 -------
Is this PR fixed? If so, please close it.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |stevenb at suse dot de
Status|NEW |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (32 preceding siblings ...)
2005-02-07 18:56 ` kazu at cs dot umass dot edu
@ 2005-02-07 19:00 ` pinskia at gcc dot gnu dot org
2005-02-27 18:12 ` anton at mips dot complang dot tuwien dot ac dot at
` (7 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-07 19:00 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-02-07 05:32 -------
(In reply to comment #28)
> Is this PR fixed? If so, please close it.
it is fixed on the mainline but still not fixed on the 3.4 branch as this is a regression we should keep it
open until The RM says otherwise.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
Last reconfirmed|2004-12-20 01:17:59 |2005-02-07 05:32:48
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (33 preceding siblings ...)
2005-02-07 19:00 ` pinskia at gcc dot gnu dot org
@ 2005-02-27 18:12 ` anton at mips dot complang dot tuwien dot ac dot at
2005-03-10 12:48 ` steven at gcc dot gnu dot org
` (6 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: anton at mips dot complang dot tuwien dot ac dot at @ 2005-02-27 18:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From anton at mips dot complang dot tuwien dot ac dot at 2005-02-27 10:47 -------
Subject: Re: [3.3/3.4/4.0 regression] pessimization of "goto *"
steven at gcc dot gnu dot org wrote:
> Updated patch for this problem
Ok, I have now tried it with gcc-4.0-20050220 and gforth-0.6.2 on i386
and it works ok. There is a minor remaining regression related to this
issue:
gcc-4.0 compiles "goto **(ip-1);" into
0x804b50d <engine+1341>: mov 0xfffffffc(%ebx),%eax
0x804b510 <engine+1344>: jmp *%eax
gcc-2.95 compiles it into
0x804b103 <engine+227>: jmp *0xfffffffc(%ebx)
which looks better.
Maybe there should be another combining pass after the duplication of the indirect jumps. Should I create another PR for this?
Here are updated timing results (gforth-0.6.2 configured with
--enable-force-reg):
Pentium 4 2.26GHz; numbers are times in seconds user time
gcc-4.0-20050220
gcc-2.95.3 gcc-3.3 gcc-3.4.0 default no-reorder-blocks
dynamic no-dyn dynamic no-dyn no-dyn dynamic dynamic
siev 0.24 0.48 0.31 0.47 0.50 0.37 0.28
bubble 0.30 0.78 0.36 0.77 0.78 0.40 0.36
matrix 0.19 0.94 0.17 0.92 0.96 0.18 0.18
fib 0.34 0.57 0.41 0.58 0.59 0.43 0.40
- anton
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (34 preceding siblings ...)
2005-02-27 18:12 ` anton at mips dot complang dot tuwien dot ac dot at
@ 2005-03-10 12:48 ` steven at gcc dot gnu dot org
2005-03-12 21:38 ` anton at mips dot complang dot tuwien dot ac dot at
` (5 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-03-10 12:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From steven at gcc dot gnu dot org 2005-03-10 12:48 -------
> Maybe there should be another combining pass after the duplication
> of the indirect jumps. Should I create another PR for this?
There should not be another "combining" pass (you really mean constant
propagation). This new unfactoring stuff runs after register allocation,
so such a pass would not really help, except maybe to make the code look
prettier to you.
But, is this:
mov 0xfffffffc(%ebx),%eax
jmp *%eax
slower than this:
jmp *0xfffffffc(%ebx)
or have you not tried that (e.g. by hacking the assembly by hand)?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (35 preceding siblings ...)
2005-03-10 12:48 ` steven at gcc dot gnu dot org
@ 2005-03-12 21:38 ` anton at mips dot complang dot tuwien dot ac dot at
2005-03-12 21:54 ` stevenb at suse dot de
` (4 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: anton at mips dot complang dot tuwien dot ac dot at @ 2005-03-12 21:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From anton at mips dot complang dot tuwien dot ac dot at 2005-03-12 21:38 -------
Subject: Re: [3.3/3.4 regression] pessimization of "goto *"
steven at gcc dot gnu dot org wrote:
>
>
> ------- Additional Comments From steven at gcc dot gnu dot org 2005-03-10 12:48 -------
> > Maybe there should be another combining pass after the duplication
> > of the indirect jumps. Should I create another PR for this?
>
> There should not be another "combining" pass (you really mean constant
> propagation).
I meant "Instruction combination (`combine.c')". Not sure if this is
replaced by something else in the recent gccs. Why do you think I
mean constant propagation?
> This new unfactoring stuff runs after register allocation,
> so such a pass would not really help, except maybe to make the code look
> prettier to you.
Ouch. No way to fix that? That's the cost we wanted to avoid.
> But, is this:
>
> mov 0xfffffffc(%ebx),%eax
> jmp *%eax
>
> slower than this:
>
> jmp *0xfffffffc(%ebx)
>
> or have you not tried that (e.g. by hacking the assembly by hand)?
Ok, I hacked the assembly by hand, and this is what I got:
All numbers are user times in seconds for gforth-fast-0.6.2:
Pentium-4 2.26 GHz (i386 code):
no-dynamic no-super dynamic
combined? yes no yes no yes no
siev 0.47 0.49 0.36 0.36 0.33 0.33
bubble 0.81 0.81 0.52 0.53 0.47 0.47
matrix 1.03 1.01 0.30 0.30 0.36 0.35
fib 0.70 0.68 0.75 0.60 0.53 0.58
Opteron 2GHz (i386 code):
no-dynamic no-super dynamic
combined? yes no yes no yes no
siev 0.46 0.47 0.37 0.36 0.33 0.32
bubble 0.73 0.74 0.50 0.51 0.50 0.51
matrix 0.93 0.95 0.35 0.34 0.31 0.32
fib 0.63 0.64 0.49 0.50 0.44 0.45
"No-super" performs the same number of indirect branches (and anything
else) as "no-dynamic", but has better branch prediction. "Dynamic" is
like "no-super", but eliminates many of the indirect branches.
So, overall the instruction combination alone does not make much of a
difference on these CPUs.
- anton
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (36 preceding siblings ...)
2005-03-12 21:38 ` anton at mips dot complang dot tuwien dot ac dot at
@ 2005-03-12 21:54 ` stevenb at suse dot de
2005-04-03 13:24 ` schwab at suse dot de
` (3 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: stevenb at suse dot de @ 2005-03-12 21:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From stevenb at suse dot de 2005-03-12 21:54 -------
Subject: Re: [3.3/3.4 regression] pessimization of "goto *"
Combine runs before register allocation. You cannot run it after
register allocation. I don't think you can run it twice, even.
And no, after register allocation you are not magically going to
win back that register. Tough luck.
Given your numbers, replacing the reg with its known value might
still be a win. But I'm not going to do it ;-)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (37 preceding siblings ...)
2005-03-12 21:54 ` stevenb at suse dot de
@ 2005-04-03 13:24 ` schwab at suse dot de
2005-04-07 9:03 ` schwab at suse dot de
` (2 subsequent siblings)
41 siblings, 0 replies; 43+ messages in thread
From: schwab at suse dot de @ 2005-04-03 13:24 UTC (permalink / raw)
To: gcc-bugs
--
Bug 15242 depends on bug 20648, which changed state.
Bug 20648 Summary: [4.0/4.1 regression] ICE in cfg_layout_redirect_edge_and_branch_force
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20648
What |Old Value |New Value
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Status|NEW |ASSIGNED
Status|ASSIGNED |WAITING
Status|WAITING |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (38 preceding siblings ...)
2005-04-03 13:24 ` schwab at suse dot de
@ 2005-04-07 9:03 ` schwab at suse dot de
2005-04-07 14:45 ` schwab at suse dot de
2005-05-19 17:36 ` mmitchel at gcc dot gnu dot org
41 siblings, 0 replies; 43+ messages in thread
From: schwab at suse dot de @ 2005-04-07 9:03 UTC (permalink / raw)
To: gcc-bugs
--
Bug 15242 depends on bug 20648, which changed state.
Bug 20648 Summary: [4.0/4.1 regression] ICE in cfg_layout_redirect_edge_and_branch_force
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20648
What |Old Value |New Value
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (39 preceding siblings ...)
2005-04-07 9:03 ` schwab at suse dot de
@ 2005-04-07 14:45 ` schwab at suse dot de
2005-05-19 17:36 ` mmitchel at gcc dot gnu dot org
41 siblings, 0 replies; 43+ messages in thread
From: schwab at suse dot de @ 2005-04-07 14:45 UTC (permalink / raw)
To: gcc-bugs
--
Bug 15242 depends on bug 20648, which changed state.
Bug 20648 Summary: [4.0 regression] ICE in cfg_layout_redirect_edge_and_branch_force
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20648
What |Old Value |New Value
----------------------------------------------------------------------------
Status|REOPENED |ASSIGNED
Status|ASSIGNED |NEW
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread
* [Bug rtl-optimization/15242] [3.3/3.4 regression] pessimization of "goto *"
2004-05-01 14:27 [Bug optimization/15242] New: pessimization of "goto *" anton at mips dot complang dot tuwien dot ac dot at
` (40 preceding siblings ...)
2005-04-07 14:45 ` schwab at suse dot de
@ 2005-05-19 17:36 ` mmitchel at gcc dot gnu dot org
41 siblings, 0 replies; 43+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-05-19 17:36 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.4.4 |3.4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242
^ permalink raw reply [flat|nested] 43+ messages in thread