From 7b644bfb51ecccf5870f906aaf81c18d26302866 Mon Sep 17 00:00:00 2001 From: sandeep Date: Sat, 20 May 2000 20:26:38 +0000 Subject: [PATCH] fixed increment of struct element problem & added 2 peepholes git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@252 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCcse.c | 11 +++++++++++ src/mcs51/peeph.def | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 6a8771e6..4cec0bc5 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -973,6 +973,7 @@ DEFSETFUNC(diCodeForSym) int constFold (iCode *ic, set *cseSet) { iCode *dic = NULL; + iCode *ldic= NULL; /* this routine will change a = b + 10; c = a + 10; @@ -1006,6 +1007,16 @@ int constFold (iCode *ic, set *cseSet) if (!IS_OP_LITERAL(IC_RIGHT(dic))) return 0; + /* find the definition of the left operand + of dic.then check if this defined with a + get_pointer return 0 if the pointer size is + less than 2 (MCS51 specific) */ + if (!(applyToSet(cseSet,diCodeForSym,IC_LEFT(dic),&ldic))) + return 0; + + if (POINTER_GET(ldic) && getSize(operandType(IC_LEFT(ldic))) <= 1) + return 0; + /* it is if the operations are the same*/ /* the literal parts need to be added */ IC_LEFT(ic) = operandFromOperand(IC_LEFT(dic)); diff --git a/src/mcs51/peeph.def b/src/mcs51/peeph.def index 315c72f8..ef2963b9 100644 --- a/src/mcs51/peeph.def +++ b/src/mcs51/peeph.def @@ -1775,3 +1775,15 @@ replace { ; Peephole 220b removed bogus DPS set mov dps, #0x00 } + +replace { + mov %1 + %2,(%2 + %1) +} by { + ; Peephole 221a remove redundant move +} + +replace { + mov (%1 + %2 + %3),((%2 + %1) + %3) +} by { + ; Peephole 221b remove redundant move +} \ No newline at end of file -- 2.47.2