Improved caching of pointers and division
[fw/sdcc] / src / z80 / peeph-z80.def
index cf5a83d4f7d1ec66a522cb456f06b6a85c0f6447..a1299d443ec0fccadfaf17907bf9ed36c4ef360f 100644 (file)
@@ -62,9 +62,17 @@ replace restart {
        ld      a,%3 (%1)
 } by {
        ; peephole 0d loaded %2 into a directly instead of going through %1.
-       ld      a,(#%2+%3)
+       ld      a,(#%2 + %3)
 } if notUsed(%1)
 
+replace restart {
+       ld      hl,#%1 + %2
+       ld      a, (hl)
+} by {
+       ; peephole 0d' loaded %2 into a directly instead of going through %1.
+       ld      a, (#%1 + %2)
+} if notUsed('hl')
+
 replace restart {
        srl     %1
        ld      a,%1
@@ -259,17 +267,16 @@ replace restart {
        ld      b, %2 (%3)
 } if notVolatile(%1), notUsed(%1)
 
-// Bug #2728445
-//replace restart {
-//     ld      %1,a
-//     ld      %2,%3
-//     ld      %4,%1
-//} by {
-//     ; peephole 0t loaded %4 from a instead of going through %1.
-//     ld      %1,a
-//     ld      %2,%3
-//     ld      %4,a
-//} if notVolatile(%1), operandsNotRelated(%1 %3), operandsNotRelated(%1 %2)
+replace restart {
+       ld      %1,a
+       ld      %2,%3
+       ld      %4,%1
+} by {
+       ; peephole 0t loaded %4 from a instead of going through %1.
+       ld      %1,a
+       ld      %2,%3
+       ld      %4,a
+} if notVolatile(%1), operandsNotRelated(%1 %3), operandsNotRelated(%1 %2)
 
 replace restart {
        ld      %1,a
@@ -404,13 +411,24 @@ replace restart {
 
 replace restart {
        ld      iy,#%1
-       ld      %2,%3 (%4)
+       ld      %2,%3 (iy)
 } by {
        ; peephole 0ze used hl instead of iy.
        ld      hl,#%1 + %3
        ld      %2,(hl)
 } if notUsed('iy'), notUsed('hl')
 
+replace restart {
+       ld      iy,#%1
+       ld      %2 (iy),%3
+       ld      l,%2 (iy)
+} by {
+       ; peephole 0ze' used hl instead of iy.
+       ld      hl,#%1 + %2
+       ld      (hl),%3
+       ld      l,(hl)
+} if notUsed('iy'), notUsed('h')
+
 replace restart {
        ld      iy,#%1
        ld      %2 (%3), %4