Menu

#536 Optimize out once-used address for stm8

None
closed-fixed
None
5
2018-03-17
2017-09-21
No

Code like

int array[4];

void array_access(unsigned char index)
{
    array[index] = 0;
}

Results in a temporary for the array address for most ports. This increases register pressure. However, mcs51 can optimize out the temporary in register packing. This optimization should be ported to stm8 (and maybe z80 and related, but that's less important, since z80 has more registers than stm8).

Philipp

P.S.: See also https://github.com/tenbaht/sduino/issues/14#issuecomment-330904012

Discussion

  • Philipp Klaus Krause

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -9,7 +9,7 @@
     }
     ~~~~
    
    -Results in a temporary for the array address for most ports. This increases register pressure. However, mcs51 can optimize out the temporary in regsiter packing. This optimization should be ported to stm8 (and maybe z80 and related, but that's less important, since z80 has more registers tahn stm8).
    +Results in a temporary for the array address for most ports. This increases register pressure. However, mcs51 can optimize out the temporary in register packing. This optimization should be ported to stm8 (and maybe z80 and related, but that's less important, since z80 has more registers than stm8).
    
     Philipp
    
    • Group: -->
     
  • Philipp Klaus Krause

    • status: open --> closed-fixed
    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    Implemented in [r10280] by implementing basic support for rematerialization.
    And not just for once-used addresses. Rematerialization is handled in the register allocator, which can decide to even rematerialize addresses used multiple times, if the cost of rematerialization is less than the gain from reduced register pressure.

    Philipp

     

Log in to post a comment.

MongoDB Logo MongoDB