Posted by
Igor Stasenko on
Jun 28, 2007; 7:16am
URL: https://forum.world.st/A-minor-issue-with-register-allocator-tp133467.html
I'm currently testing my asm-parser. And found it generates unneeded
instruction (mov eax,eax):
code of asm method:
message4: arg1 with: arg2
| b c |
self pragma: #cdecl.
c := arg1 + arg2.
b := arg1 / arg2.
^ c + b
produced intermediate by parser:
#(#(#block 1
#(#mov #(#add #(#argument #arg1) #(#argument #arg2)) #c)
#(#mov #(#div #(#argument #arg1) #(#argument #arg2) 'temp7D6') #b)
#(#return #(#add #c #b))))
then with transformed arguments and cdecl prologue/epilogue:
#(#(#block 1 #(#push #ebp) #(#mov #esp #ebp)) #(#block 3
#(#mov #(#add #(#mem #(#add #ebp -4)) #(#mem #(#add #ebp -8))) 't1')
#(#mov #(#div #(#mem #(#add #ebp -4)) #(#mem #(#add #ebp -8)) 't3') 't2')
#(#mov #(#add 't1' 't2') #eax) #(#jmp #block2)) #(#block 2 #(#mov #ebp
#esp) #(#pop #ebp) #(#ret)))
and then i using
LowLevelOptimiser ->InstructionSelector -> ColouringRegisterAllocator
-> JumpRemover :
#(#(#block 1 #(#push #ebp) #(#mov #esp #ebp)) #(#block 3 #(#mov #(-8
#ebp) #ebx) #(#add #(-4 #ebp) #ebx) #(#mov #(-4 #ebp) #eax) #(#mov
#(-8 #ebp) #ecx) #(#cdq) #(#div #ecx)
#(#mov #eax #eax)
#(#add #ebx #eax)) #(#block 2 #(#mov #ebp #esp) #(#pop #ebp) #(#ret)))
I suppose fix could be simple by testing in MedMov>>#visitWith: that
if reg1 = reg2 then return nil , which will be interpreted as no-op by
block.
version used: Exupery-wbk.261.
_______________________________________________
Exupery mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/exupery