![]() |
Unnecessary Push/Pop - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15) +---- Thread: Unnecessary Push/Pop (/showthread.php?tid=233) |
Unnecessary Push/Pop - britlion - 06-03-2010 Not sure why the .asm ends up this way, but each time it pulls a parameter in a sub or function it seems to do this: Code: push hl Why stack the HL register before loading the A register each time, and then unstack it immediately afterwards? Re: Unnecessary Push/Pop - boriel - 06-03-2010 britlion Wrote:Not sure why the .asm ends up this way, but each time it pulls a parameter in a sub or function it seems to do this:Where is that happening? I need more context information (E.g. put a function listing so I can generate the .asm code). -O3, by the way should remove this. Re: Unnecessary Push/Pop - britlion - 06-04-2010 Straight to assembler, without O3 - Code: SUB pokethis(value as uByte) Turns the relevant part into: Code: _pokethis: With O3, it does certainly see the optimization, showing that the optimizer module is very impressive!: Code: _pokethis: The other thing that I'm curious about (as I noted in the other post, with this code in it), is that it doesn't load HL with [@label+1] - it loads it with @label, and then does inc HL. This isn't optimized by -O3. Re: Unnecessary Push/Pop - boriel - 06-04-2010 britlion Wrote:Straight to assembler, without O3 -And it's OK: POKE Expr1, Expr2 could be something like: Code: POKE 10, 2 Code: POKE SIN(EXP(3*LN 52)) / RND * 72, RND *45 + USR "a" OR 1 Optimization in the backend stage (pipeline, -O3) knows this (to some extent). Britlion Wrote:With O3, it does certainly see the optimization, showing that the optimizer module is very impressive!;-) thx! Britlion Wrote:The other thing that I'm curious about (as I noted in the other post, with this code in it), is that it doesn't load HL with [@label+1] - it loads it with @label, and then does inc HL. This isn't optimized by -O3.I'll answer that in the other topic, BTW, moved to Whislist forum. |