* src/SDCCpeeph.c (operandBaseName): added check for @Ri
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 19 Feb 2008 23:15:11 +0000 (23:15 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 19 Feb 2008 23:15:11 +0000 (23:15 +0000)
* src/mcs51/peeph.def (rule 177.c): added operandsNotRelated(%1 %3)
  fixes bug 1739475, thanks Robert Larice
  (rule 271): new, added

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5025 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCpeeph.c
src/mcs51/peeph.def

index 32724ce5159bf6eca011f64c2d5f6455888f6dcd..15cdfbd565ab8cadbf33ee07f3cee1fb896f82c2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-02-20 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * src/SDCCpeeph.c (operandBaseName): added check for @Ri
+       * src/mcs51/peeph.def (rule 177.c): added operandsNotRelated(%1 %3)
+         fixes bug 1739475, thanks Robert Larice
+         (rule 271): new, added
+
 2008-02-18 Borut Razem <borut.razem AT siol.net>
 
        * sim/ucsim/s51.src/Makefile.in: fixed error made in previous commit
index 871ca6768d519e3dc632224f70bb0f54f576ffda..97fbb3b54d4a6b0315a1db84317cc67011591489 100644 (file)
@@ -61,7 +61,7 @@ void pic16_peepRules2pCode(peepRule *);
 #endif
 
 /*-----------------------------------------------------------------*/
-/* pcDistance - afinds a label back ward or forward                */
+/* pcDistance - finds a label backward or forward                  */
 /*-----------------------------------------------------------------*/
 
 static int
@@ -74,16 +74,19 @@ pcDistance (lineNode * cpos, char *lbl, bool back)
   SNPRINTF (buff, sizeof(buff), "%s:", lbl);
   while (pl)
     {
-
       if (pl->line &&
           !pl->isComment &&
           !pl->isLabel &&
-          !pl->isDebug) {
-                if (port->peep.getSize) {
-                        dist += port->peep.getSize(pl);
-                } else {
-                        dist += 3;
-                }
+          !pl->isDebug)
+        {
+          if (port->peep.getSize)
+            {
+              dist += port->peep.getSize(pl);
+            }
+          else
+            {
+              dist += 3;
+            }
         }
 
       if (strncmp (pl->line, buff, strlen (buff)) == 0)
@@ -155,7 +158,7 @@ FBYNAME (labelInRange)
     return FALSE;
 
   /* calculate the label distance : the jump for reladdr can be
-     +/- 127 bytes, here Iam assuming that an average 8051
+     +/- 127 bytes, here I am assuming that an average 8051
      instruction is 2 bytes long, so if the label is more than
      63 intructions away, the label is considered out of range
      for a relative jump. we could get more precise this will
@@ -1045,6 +1048,9 @@ operandBaseName (const char *op)
         return "a";
       if (!strncmp (op, "ar", 2) && ISCHARDIGIT(*(op+2)) && !*(op+3))
         return op+1;
+      // bug 1739475, temp fix
+      if (op[0] == '@')
+        return operandBaseName(op+1);
     }
 
   return op;
index 92570a59380be45d2a569558e2412a5f701fa8e6..6f18fc5aad4631496a3d64ed7a16d7d1042b593b 100644 (file)
@@ -1317,7 +1317,7 @@ replace {
 } by {
        ;       Peephole 177.c  removed redundant mov
        mov     %1,%3
-} if notVolatile %1 %2
+} if notVolatile(%1 %2),operandsNotRelated(%1 %3)
 
 // applies to f.e. bug-408972.c
 // not before peephole 177.c
@@ -4661,6 +4661,24 @@ replace {
        ;       Peephole 270    removed redundant add
        add     a,#%1+%2
 }
+
+replace {
+       jz      %1
+       mov     %2,%4
+       sjmp    %3
+%1:
+       mov     %2,#0x00
+%3:
+} by {
+       jz      %1
+       ;       Peephole 271    optimized ternary operation (acc different)
+       mov     a,%4
+%1:
+       mov     %2,a
+%3:
+} if operandsNotRelated('a' 'dptr' %2), labelRefCount(%1 1), labelRefCountChange(%3 -1)
+
+
 replace restart {
        pop     ar%1
 } by {