Rewrote 8-bit multiplication by constant, implements #1898231
[fw/sdcc] / src / z80 / peeph.def
index 90b1b2b154463a4e50e44e1ac38b62687a6e3b98..1dc435b89a5e2ce209b25770e910aa53efa4f122 100644 (file)
@@ -23,14 +23,6 @@ replace restart {
        ; peephole 1 removed redundant load.
 } if notVolatile(%1)
 
-replace restart {
-       ld      %1,%3
-       ld      %1,%2
-} by {
-       ; peephole 2 removed dead load into %1
-       ld      %1,%2
-} if notVolatile(%1 %3), operandsNotSame
-
 replace restart {
        jp      NC,%1
        jp      %2
@@ -456,6 +448,22 @@ replace restart {
        ld      %1,a
 } if notVolatile(%1)
 
+// sdcc does not use the H flag. sla resets it, while add sets it.
+// To ensure that the state of the H flag is not changed by this
+// peephole uncomment the add %3, %4 at the end (since it overwrite the H flag).
+replace restart {
+       ld      %1, a
+       sla     %1
+       ld      a, %2
+       //add   %3, %4
+} by {
+       add     a, a
+       ; peephole 42a shifts in accumulator insted of %1
+       ld      %1, a
+       ld      a, %2
+       //add   %3, %4
+}
+
 replace restart {
        ld      %1,a
        ld      a,%2