Re: Compiler Loop Unswitching





Tim Frink wrote:

Based on our metrics the single most important loop optimization
on application code is moving the test to the bottom when the first
compare is known at compile time. It halves the pipe line flushes
and is almost trivial to implement.

Could you explain what you mean with "first compare"? Maybe you could
provide a small code example?

for (i = 0; i < j; i++)
dosomething();

would generated something like

if (i<j) goto zz
yy:
dosomething();
i++;
goto yy:
zz:



for (i = 0; i < 29 ; i++)
dosomething();

if the compare were known at compile time
ie it is a constant in this case
do something will always be executed so the generated code can be

i = 0;
ll:
dosomething();
i++;
if (i < 29) goto ll

This will eliminate the goto yy and move the if ( ) to the end of the loop

Regards,

--
Walter Banks
Byte Craft Limited
Tel. (519) 888-6911
http://www.bytecraft.com
walter@xxxxxxxxxxxxx





.



Relevant Pages

  • Re: Compiler Loop Unswitching
    ... on application code is moving the test to the bottom when the first ... compare is known at compile time. ... Could you explain what you mean with "first compare"? ... if goto zz ...
    (comp.programming)
  • Re: Process one line of output only?...
    ... errorlevel I compare the output of fc to see if I get the message they ... I tried putting a goto in the unmatch condition but this is making the ... REM jumpout as it is enough for me to know the files don't match ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Process one line of output only?...
    ... errorlevel I compare the output of fc to see if I get the message they ... I tried putting a goto in the unmatch condition but this is making the ... REM jumpout as it is enough for me to know the files don't match ... On my computer fc does in fact return errorlevel .. ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Invalid Use of Null
    ... > table I need to compare the above record to the below record for ... > have no control over and can't change. ... > GoTo 800 ... control-of-flow constructs such as Do loops, For loops, If...Then and ...
    (microsoft.public.access.modulesdaovba)
  • Re: Process one line of output only?...
    ... errorlevel I compare the output of fc to see if I get the message they ... I tried putting a goto in the unmatch condition but this is making the ... REM jumpout as it is enough for me to know the files don't match ...
    (microsoft.public.win2000.cmdprompt.admin)