fixed increment of struct element problem & added 2 peepholes
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 20 May 2000 20:26:38 +0000 (20:26 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 20 May 2000 20:26:38 +0000 (20:26 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@252 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCcse.c
src/mcs51/peeph.def

index 6a8771e6c8ead600e1e22e6d08a9a93a17294d00..4cec0bc55e0b644469cd8149f1196b2e20a22f3c 100644 (file)
@@ -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));    
index 315c72f86bec058045486709bcdf783e266ddaa6..ef2963b914ef7558eb63440ad8a53310ba67280f 100644 (file)
@@ -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