Changes between Version 14 and Version 15 of Commentary/Compiler/NewCodeGenStupidity


Ignore:
Timestamp:
Apr 14, 2011 10:01:19 AM (4 years ago)
Author:
ezyang
Comment:

instruction reordering

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/NewCodeGenStupidity

    v14 v15  
    174174This pattern essentially happens for every function, since we always assign incoming parameters to temporary variables before doing anything. 
    175175 
     176== Instruction reordering == 
     177 
     178We should be able to reorder instructions in order to decrease register pressure. Here's an example from 3586.hs 
     179 
     180{{{ 
     181        _cPY::I32 = I32[Sp - 24]; 
     182        I32[R1 + 4] = _cPY::I32; 
     183        I32[R1] = stg_IND_STATIC_info; 
     184        I32[Sp - 8] = _cPY::I32; 
     185        I32[Sp - 12] = stg_upd_frame_info; 
     186}}} 
     187 
     188R1 and Sp probably don't clobber each other, so we ought to use _cPY twice in quick succession. Fortunately stg_IND_STATIC_info is a constant so in this case the optimization doesn't help to much, but in other cases it might make sense. TODO Find better example