From f8ebe92b9c9264ea1e38ec65e754f970d95faec8 Mon Sep 17 00:00:00 2001 From: spth Date: Tue, 30 Dec 2008 22:29:12 +0000 Subject: [PATCH] minor addition improvement git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5311 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 6 ++++++ src/z80/gen.c | 7 ++++++- src/z80/peeph-z80.def | 30 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 34d809ca..124f5e00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-12-30 Philipp Klaus Krause + + * src/z80/gen.c, + src/z80/peeph-z80.def: + Minor addition improvement. + 2008-12-30 Raphael Neider * as/link/hc08/lkelf.c, as/link/lkaomf51.c, as/link/lklibr.c, diff --git a/src/z80/gen.c b/src/z80/gen.c index 817acecc..82117185 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -3994,7 +3994,12 @@ genPlus (iCode * ic) { _moveA (aopGet (AOP (IC_LEFT (ic)), offset, FALSE)); if (offset == 0) - emit2 ("add a,%s", aopGet (AOP (IC_RIGHT (ic)), offset, FALSE)); + { + if(size == 0 && AOP_TYPE (IC_RIGHT (ic)) == AOP_LIT && ulFromVal (AOP (IC_RIGHT (ic))->aopu.aop_lit) == 1) + emit2 ("inc a"); + else + emit2 ("add a,%s", aopGet (AOP (IC_RIGHT (ic)), offset, FALSE)); + } else emit2 ("adc a,%s", aopGet (AOP (IC_RIGHT (ic)), offset, FALSE)); aopPut (AOP (IC_RESULT (ic)), "a", offset++); diff --git a/src/z80/peeph-z80.def b/src/z80/peeph-z80.def index ba83efff..6c258c09 100644 --- a/src/z80/peeph-z80.def +++ b/src/z80/peeph-z80.def @@ -799,6 +799,36 @@ replace restart { //add %3, %4 } +replace restart { + ld l,%1 (ix) + ld h,%2 (ix) + ld a,(hl) + inc a + ld l,%1 (ix) + ld h,%2 (ix) + ld (hl),a +} by { + ld l,%1 (ix) + ld h,%2 (ix) + inc (hl) + ; peephole 42c incremented in (hl) instead of going through a. +} if notUsed('a') + +replace restart { + ld l,%1 (ix) + ld h,%2 (ix) + ld a,(hl) + dec a + ld l,%1 (ix) + ld h,%2 (ix) + ld (hl),a +} by { + ld l,%1 (ix) + ld h,%2 (ix) + dec (hl) + ; peephole 42d decremented in (hl) instead of going through a. +} if notUsed('a') + replace restart { ld %1,a ld a,%2 -- 2.30.2