Am 03.06.20 um 21:25 schrieb Sebastian Riedel:
> Is there a reason why one wouldn't use: (z80/gbz80)
> 
> replace restart {
>     ld    %2, %4
>     ld    %1, %3
> } by {
>     ; brought register pair into uniform order
>     ld    %1, %3
>     ld    %2, %4
> } if canAssign(%1%2 '#0x0102'), notSame(%2, %3)

WE try to avoid peephole rules that do not reduce code size, as can be
very dangerous: With the large number of peephole rules it is hard to
thnk about a given rule will interact with all others, and with rule
that do not reduce code size it is very easy to end up with an endless
loop (i.e. SDCC would hang in the peephole optimizer).
I guess exceptions could be made for rules that do not reduce code size
but reduce cycle count.

> replace {
>     ld    %1, #0x%3
>     ld    %2, #0x%4
> } by {
>     ld    %1%2, #0x%3%4
>     ; combined constant loads into register pair.
> } if canAssign(%1%2 '#0x0102')
> 

How about something like the following variant of your proposal?

replace {
    ld    %2, #0x%3
    ld    %1, #0x%4
} by {
    ld    %1%2, #0x%3%4
    ; combined constant loads into register pair.
} if canAssign(%1%2 '#0x0102')

replace {
    ld    %1, #0x%3
    ld    %2, #0x%4
} by {
    ld    %1%2, #0x%3%4
    ; combined constant loads into register pair.
} if canAssign(%1%2 '#0x0102')

We again would have only two rules, and this time both of them reduce
code size.


_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to