------- Comment #4 from anton at mips dot complang dot tuwien dot ac dot at
2005-12-06 21:46 -------
Subject: Re: pessimization of goto * ("computed goto")
pinskia at gcc dot gnu dot org wrote:
> __asm__(""); makes stuff worse.
I just applied the following patch to engine1.i:
--- engine1.i 2005-12-06 22:34:08.000000000 +0100
+++ engine1.i~ 2005-12-06 19:04:12.000000000 +0100
@@ -17562,7 +17562,7 @@
{
# 188 "./java.vmg"
{
- { if ((aArray) == ((void *)0)) { __asm__(""); goto
*throw_nullpointerexception; } };
+ { if ((aArray) == ((void *)0)) { goto *throw_nullpointerexception; } };
{ if (( ((java_arrayheader*)(aArray))->size ) <= (u4) (iIndex)) {
arrayindexoutofbounds_index = (iIndex); goto
*throw_arrayindexoutofboundsexception; } };
;
vResult = ((((java_intarray*)(aArray))->data)[iIndex]);
The result looks much better; in particular, instead of the
je .L995
I now get:
jne .L762
movq -136(%rbp), %rdx
.LBE46:
.loc 2 231 0
jmp *%rdx
.L762:
I.e., a separate indirect jump for improved branch prediction (not
important in this case, because this indirect branch will rarely be
used). More importantly, no direct branches to far-away places which
did destroy the relocatability (and thus suitability for "selective
inlining") of this code fragment.
So, no, the code is not worse, but much better. I hope this
workaround will continue to work in future versions.
- anton
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25285