Page 1 of 1

[solved] OPTIMIZER-Flag - What asm optimizations?

Posted: Mon Sep 25, 2023 6:46 pm
by juergenkulow
What optimizations does /OPTIMIZER flag make in the ASM backend?

Since 6.01 beta 4: /OPTIMIZER:

Code: Select all

PureBasic 6.03 beta 9 LTS (Windows - x86)
Compiling H:\PB23_1\left.pb
Loading external libraries...
Starting compilation...
Optimizing asm output...      <-----------
14 lines processed.
Creating and launching executable.

- Feel the ..PuRe.. Power -

Re: OPTIMIZER-Flag - What asm optimizations?

Posted: Mon Sep 25, 2023 6:53 pm
by Kuron
This is detailed in the blog (with examples), all it has ever done is a single pass optimization on the ASM code.

That said, FASM is a multi-pass assembler that makes a lot of code optimizations. So, it would appear that FASM is optimizing the ASM code, in addition to the single pass that PB does?

Re: OPTIMIZER-Flag - What asm optimizations?

Posted: Mon Sep 25, 2023 7:43 pm
by luis
Kuron wrote: Mon Sep 25, 2023 6:53 pm This is detailed in the blog (with examples),
I've just quickly looked through all the posts and I didn't found one on the subject of ASM optimizations. Did I miss it ?

EDIT: My bad, I actually missed it, the title didn't help :)

Here it is: https://www.purebasic.fr/blog/?p=502
Kuron wrote: Mon Sep 25, 2023 6:53 pm That said, FASM is a multi-pass assembler that makes a lot of code optimizations.
I think it can optimize the size of the opcodes (to use the smaller ones when possible) but that's about it.
Unless you meant that... but it does not actually change the ASM code.

Re: OPTIMIZER-Flag - What asm optimizations?

Posted: Mon Sep 25, 2023 10:29 pm
by Kuron
luis wrote: Mon Sep 25, 2023 7:43 pm I think it can optimize the size of the opcodes (to use the smaller ones when possible) but that's about it.
Unless you meant that... but it does not actually change the ASM code.
Going strictly by this.

Re: OPTIMIZER-Flag - What asm optimizations?

Posted: Mon Sep 25, 2023 11:12 pm
by luis
Yes, that's it, optimizing the size of the code by trying to select the smallest opcodes, for example for the jumps, where you have opcodes for near or far jumps with different sizes.
But the ASM code stays the same and it's not optimized in any way.

Some comments about this from its forum
https://board.flatassembler.net/topic.php?t=8593

Re: OPTIMIZER-Flag - What asm optimizations?

Posted: Mon Sep 25, 2023 11:19 pm
by Kuron
You should get them to rewrite the wikipedia page to say what you want it to say. :wink:

Re: OPTIMIZER-Flag - What asm optimizations?

Posted: Mon Sep 25, 2023 11:26 pm
by luis
Kuron wrote: Mon Sep 25, 2023 11:19 pm You should get them to rewrite the wikipedia page to say what you want it to say. :wink:
Uh ? Already does that.
wikipedia wrote: It makes extensive code-size optimization and allows unconstrained forward referencing
It says "code-size" optimization and the second document linked there (number 7) talk about "code resolving" and that is what is used to select the optimal sized opcodes.

Re: OPTIMIZER-Flag - What asm optimizations?

Posted: Tue Sep 26, 2023 8:31 am
by juergenkulow
Is there a sample program for optimizing asm output?

Re: OPTIMIZER-Flag - What asm optimizations?

Posted: Tue Sep 26, 2023 12:59 pm
by Fred
You can use the --commented switch to compare between optimized and none optimized asm output