takagi / pic

A native compiler for 8-bit PIC micro controllers written in Common Lisp.
MIT License
40 stars 3 forks source link

Reducible move instructions on a PIC function's return value #1

Closed takagi closed 9 years ago

takagi commented 9 years ago

Situation A PIC function's return value is stored into a local pseudo-register. When it is used as another PIC function's parameter, it is stored into an input pseudo-register again.

For example, the following expression:

(bar (foo))

is compiled into:

CALL     _FOO
MOVWF    L0
MOVF     L0,W
MOVWF    I0
CALL     _BAR

Problem There are reducible move instructions.

Solution When a PIC function's return value is just used as another PIC function's parameter, make it stored into an input pseudo-register directly.

CALL     _FOO
MOVWF    I0
CALL     _BAR
takagi commented 9 years ago

Fixed in a17ec9ab2ba226fb6e99d1185558dc99d5f30fe6 and 8bd8480f282f7f785c3e0c829f90577f6396c44d.