]> git.gag.com Git - fw/sdcc/blobdiff - src/z80/peeph-z80.def
RFE #2484693 and peephole improvements
[fw/sdcc] / src / z80 / peeph-z80.def
index 6c258c09e468168acb30678f188cdd59c628ab02..c50c48e6ee548fa32898de7492986feb168a6285 100644 (file)
@@ -141,6 +141,16 @@ replace restart {
        ld      c,(hl)
 } if notUsed('a'), notUsed('hl')
 
+replace restart {
+       ld      de,#%2 + %3
+       ld      a,(de)
+       ld      e,a
+} by {
+       ; peephole 0j' used hl for #%2 + %3 instead of de, not going through a.
+       ld      hl,#%2 + %3
+       ld      e,(hl)
+} if notUsed('a'), notUsed('hl')
+
 replace restart {
        ex      de,hl
        push    hl
@@ -240,6 +250,32 @@ replace restart {
        ld      %4,a
 } if notVolatile(%1), operandsNotRelated(%1 %3), operandsNotRelated(%1 %2)
 
+replace restart {
+       ld      %1,a
+       ld      a,%2
+       adc     a,#%3
+       ld      %4,%1
+} by {
+       ld      %1,a
+       ; peephole 0t' loaded %4 from a instead of going through %1.
+       ld      %4,a
+       ld      a,%2
+       adc     a,#%3
+} if notVolatile(%1), operandsNotRelated(%1 %2), operandsNotRelated(%4 %2)
+
+replace restart {
+       ld      %1,a
+       ld      a,#%2
+       adc     a,#%3
+       ld      %4,%1
+} by {
+       ld      %1,a
+       ; peephole 0t'' loaded %4 from a instead of going through %1.
+       ld      %4,a
+       ld      a,#%2
+       adc     a,#%3
+} if notVolatile(%1)
+
 replace restart {
        ld      %1,(hl)
        ld      e,%1
@@ -533,7 +569,17 @@ replace restart {
 } by {
        ld      %1,a
        or      a,%2
-       ; peephole 17 removed load by reordering or arguments.
+       ; peephole 17a removed load by reordering or arguments.
+} if notVolatile(%1)
+
+replace restart {
+       ld      %1,a
+       ld      a,%2 (ix)
+       or      a,%1
+} by {
+       ld      %1,a
+       or      a,%2 (ix)
+       ; peephole 17b removed load by reordering or arguments.
 } if notVolatile(%1)
 
 replace restart {