Re: Jack W. Crenshaw - Any clues how to optimize ?

"Bill A." <bill@megahits.com>
22 Apr 1999 02:30:28 -0400

          From comp.compilers

Related articles
Jack W. Crenshaw - Any clues how to optimize ? prinz@c2i.net (XlatB) (1999-04-09)
Re: Jack W. Crenshaw - Any clues how to optimize ? torbenm@diku.dk (Torben Mogensen) (1999-04-18)
Re: Jack W. Crenshaw - Any clues how to optimize ? whitten@netcom.com (David Whitten) (1999-04-18)
Re: Jack W. Crenshaw - Any clues how to optimize ? mallors@ips1.msfc.nasa.gov (1999-04-19)
Re: Jack W. Crenshaw - Any clues how to optimize ? bill@megahits.com (Bill A.) (1999-04-22)
Re: Jack W. Crenshaw - Any clues how to optimize ? andersh@maths.lth.se (Anders Holtsberg) (1999-05-03)
Re: Jack W. Crenshaw - Any clues how to optimize ? mikee@cetasoft.cog (1999-05-07)
| List of all articles for this month |
From: "Bill A." <bill@megahits.com>
Newsgroups: comp.compilers
Date: 22 Apr 1999 02:30:28 -0400
Organization: Posted via RemarQ Communities, Inc.
References: 99-04-034 99-04-051
Keywords: optimize

>In an ideal world, you can make the peep-hole optimizer look for the
>patterns to match in a table and get the 'translation' from the table
>as well. Generally, you may have to get the translation from a
>function call that looks at the pattern and the code that matched it
>and generates a 'translation' that fills in the blanks in the
>generated code from looking at the sequence/data that filled those
>blanks in the original code.


I did a peephole optmizer that had "don't care" strings in the search
patterns and then used what was matched there in the replacement
strings. I used /x80 for variable item number 1, /x81 for 2, and so
on. This significantly reduced the size of the table and eliminated
enumerating all registers in a common optimization string. For
example:


      "MOV \x80,0" would pair up with "XOR \x80,\x80"


So MOV BX,0 would become XOR BX,BX and MOV CL,0 would become XOR CL,CL.
Also:


    "MOV \x80,\x81", "PUSH \x80", "MOV \x80,\x81", "PUSH \x80" was replaced
with "MOV \x80,\x81", "PUSH \x80", "PUSH \x80"


As you can see, this covers many many combinations of a double load
and push of the same item - regardless of what was loaded. You can
carry this pretty far and even match two consecutive adds and combine
them into a assembly-time additin. For these cases, I used \xC0 as
above which meant match any constant value at this position. Having
this mechanism allows you to even detect the load of 0 and 1 and
change the pattern to an INCrement.


Bill


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.