News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Source code optimiser 1st attempt.

Started by hutch--, November 21, 2006, 01:56:48 AM

Previous topic - Next topic

hutch--

This has been a joy to get going but it seems to be running OK for an early prototype. It has about 25 seperate heuristics for analysing source code and does direct replacements for the single line changes, for the multiple line look ahead types it comments out unwanted code and for the replacement, it writes it before the unwanted code.

It has many limitations at the moment, it only works in lower case and it is only performing one line at a time look aheads so a number of the multiline techniques will not work if the code is spaced greater than single lines.

I have various targets for this app if I can get it up and going, unoptimised C source code from the asm output and the capacity to pass ordinary code through it to see if there are simple replacements that are worth performing.

It comes with a test file that shows what the replacement types are.

I am aware that the ADD/SUUB replacements for INC/DEC are not always valid but the original code is commented to the side so it can be easily enough restored.

PS: I should have mentioned that it uses QE to display the results and does not save it as a file so you will need to have QE on the same partition in the masm32 directory.

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

bushpilot

Thanks for posting this.   I am doing a similar optimizer for XBLite BASIC compiler, so I will look yours over for ideas.

Greg


Seb

Hi Hutch,

nice job, buddy. I'll sure be watching this thread for new versions as they come. :U

Ghirai

MASM32 Project/RadASM mirror - http://ghirai.com/hutch/mmi.html

hutch--

As soon as I get back into OPTI I have to write the parser for complex addressing mode [eax+ecx*4+64] etc ..... What I need are suggestion for single line replacements and short block replacements and/or modifications.

Any feedback would be appreciated with this project.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

daydreamer

Quote from: hutch-- on November 22, 2006, 07:52:40 AM
As soon as I get back into OPTI I have to write the parser for complex addressing mode [eax+ecx*4+64] etc ..... What I need are suggestion for single line replacements and short block replacements and/or modifications.

Any feedback would be appreciated with this project.
I think a real gain would be if you could replace if the C compiler writes alot of fsin and fcos to fsincos and in second pass put in SSE that performs two parallel sin, because cos= sin(+90degree)

if first fsin is used, after that fcos later down in program using same angle, replace fsin with fsincos and cache the cos result to be readin later?

daydreamer

should this be possible to do such exchanges?
example:

mov ecx,8000000
mov ebx,pointer
@@l1:fld [ebx*4]
fdiv [ebx*4+pointer2]
fstp [ebx*4]
add ebx,4
dec ecx
jne @@l1
 

with this

mov ecx,1000000
mov ebx,pointer
add ebx,ebx ;insert code to do a few scalar operations before loop to meet the requirement of
;16byte alignment on movaps
@@l1:movaps xmm0,[ebx*8] ;unrolled and reordered SSE instructions to make the most of units
rcpps xmm0,xmm0
mulps xmm0,[ebx*8+pointer2]
movaps xmm0,[ebx*8]
movaps xmm0,[ebx*8+16]
rcpps xmm0,xmm0
mulps xmm0,[ebx*8+pointer2+16]
movaps xmm0,[ebx*8+16]
add ebx,4
dec ecx
jne @@l1