flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
LocoDelAssembly 26 Oct 2008, 02:21
Something I've spotted:
Code: shl ebx, 2 add eax, ebx add eax, tLM Can be Code: lea eax, [eax+ebx*4+tLM] Could you tell more about this code, like what it does and how it will be traversed billons of times? It is inside a loop? It is important to know that so the code can be optimized to fit in its surrounding code better. |
|||
![]() |
|
r22 26 Oct 2008, 03:57
Code: ;;;ALIGN 16 mov eax, [infDat + edx*sizeof.INF_DAT + INF_DAT.x] mov ebx, [infDat + edx*sizeof.INF_DAT + INF_DAT.y] mov eax, [infInfo + INF_INFO.pos + eax*sizeof.INF_INFO] mov ebx, [infInfo + ebx*sizeof.INF_INFO + INF_INFO.pos] shl eax, 12 lea eax, [eax+ebx*4+tLM] mov eax, [eax] add eax, tLM Make sure the code is aligned if its in a loop or a function your calling. Proper code alignment can improve performance 5+% You'll take a penalty from all the consecutive reads/writes with EAX. But if you want to really optimize a piece of code you should start with the structure of the DATA the code is accessing. If you can't modify the underlying data structures your trying to access then the above (interleaving the eax/ebx MOVs, using LEA to combine the multiply and add [LocoDel's idea], and aligning the code will probably be your best bet. IF you CAN modify the underlying data structures then try to de-normalize, interleave the elements from the result sets to archive a structure you can access with SIMD to perform more of 'whatever the hell your code is doing' per iteration. |
|||
![]() |
|
baldr 26 Oct 2008, 04:27
ofoltd,
Or even better, simply Code: ;;; lea eax, [eax+ebx*4+tLM] ;;; mov eax, [eax] mov eax, [eax+ebx*4+tLM] |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.