Gary Thomas: Code optimization bug in GCC-2.8 & EGCS

Gary Thomas g.thomas@opengroup.org
Fri Jan 30 23:41:00 GMT 1998


On 30-Jan-98 Jeffrey A Law wrote:
> 
>   In message < 9801301629.AA31568@rios1.watson.ibm.com >you write:
>   >   duplicate_loop_exit_text() in jump.c searches the exit test code
>   > to potentially duplicate it but limits the number of instructions to 20,
>   > from the comments:
>   > 
>   >   If the code is sufficiently simple, make a copy of it before INSN
>   >   Also, don't do this if the exit code is more than 20 insns.
>   > 
>   > I do not know how this heuristic was determined, but it seems to be
>   > incorrect for some PowerPC cases.  Gary's appended patch increases the
>   > value to 50 which fixes the particular example.
> [ ... ]
>   > I am not sure why *any* value for the search is
>   > appropriate -- especially on all architectures.
> It looks like someone just had to pick a number of instruction to
> stop the search.  It could be the case that this code pre-dates
> many of the machine dependent macros we've got for tuning purposes.
> I don't really know.
> 
> 
>   > From his explanation, it
>   > sounds like CSE reorganizes the code incorrectly and this patch simply
>   > masks that problem.
> Agreed.
> 

I spent many days trying to understand the "why" of this.  I believe that
in CSE, follow jumps only works properly if loops have been appropriately
"marked" (which is what fails to happen in JUMP in this case).  The CSE then
blindly optimizes away the first test (loop entry - above what should be
LOOP_VTOP).  I found that turning off CSE follow jumps kept the problem
from generating *icorrect* code at the expense of generating *non-optimal* code.

Correctly identified loops seem to work OK.  The failure here is that on the
PowerPC with signed characters, the loop exit code is "just a little too big."

> jeff

------------------------------------------------------------------------
Gary Thomas                              |
The Open Group / Research Institute      | "Fine wine is a necessity of
2 Avenue de Vignate                      |        life for me"
38610 Gieres - FRANCE                    |
+33 4 76 63 48 74                        |      Thomas Jefferson
email: g.thomas@opengroup.org            |
< http://www.opengroup.org/~gdt >          |
   ... opinions expressed here are mine  |
       and no one else would claim them! |
------------------------------------------------------------------------





More information about the Gcc mailing list