]> git.gag.com Git - fw/sdcc/commitdiff
* src/SDCCicode.c (operandOperation): fixed EQ_OP bug, now same as in valCompare...
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 26 Feb 2004 20:51:08 +0000 (20:51 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 26 Feb 2004 20:51:08 +0000 (20:51 +0000)
* support/regression/tests/muldiv.c: mod sign follows dividend only

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

ChangeLog
src/SDCCicode.c
support/regression/tests/muldiv.c

index 35fa24b11ff19146b22985158e08d5cdd4e25c3c..aafd0fa0763841b45fc4743f57e3ae423d57b101 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,10 @@
        modified to finally use computeType() all over SDCC,
        see Feature Request #877103
        * src/SDCCval.h: cosmetic
+       * src/SDCCicode.c (operandOperation): fixed EQ_OP bug, now same as in
+       valCompare(); regression tested in muldiv.c
+       * support/regression/tests/muldiv.c (testMod): mod sign follows
+       dividend only
 
 2004-02-23 Bernhard Held <bernhard AT bernhardheld.de>
 
index 50e86608266fb19fe192faf1671198fbd4ae1bce..5c875c1a182ea55549b978a385537a60b4f43a63 100644 (file)
@@ -1219,22 +1219,32 @@ operandOperation (operand * left, operand * right,
                                 (TYPE_UDWORD) operandLitValue (right));
       break;
     case EQ_OP:
-      /* this op doesn't care about signedness */
-      {
-       TYPE_UDWORD l, r;
-
-       l = (TYPE_UDWORD) operandLitValue (left);
-       if (IS_CHAR(OP_VALUE(left)->type))
-         l &= 0xff;
-       else if (!IS_LONG (OP_VALUE(left)->type))
-         l &= 0xffff;
-       r = (TYPE_UDWORD) operandLitValue (right);
-       if (IS_CHAR(OP_VALUE(right)->type))
-         r &= 0xff;
-       else if (!IS_LONG (OP_VALUE(right)->type))
-         r &= 0xffff;
-       retval = operandFromLit (l == r);
-      }
+      if (IS_FLOAT (let) ||
+          IS_FLOAT (ret))
+       {
+         retval = operandFromLit (operandLitValue (left) ==
+                                  operandLitValue (right));
+       }
+      else
+       {
+         /* this op doesn't care about signedness */
+         TYPE_UDWORD l, r;
+
+         l = (TYPE_UDWORD) operandLitValue (left);
+         r = (TYPE_UDWORD) operandLitValue (right);
+         /* In order to correctly compare 'signed int' and 'unsigned int' it's
+            neccessary to strip them to 16 bit.
+            Literals are reduced to their cheapest type, therefore left and
+            right might have different types. It's neccessary to find a
+            common type: int (used for char too) or long */
+         if (!IS_LONG (let) &&
+             !IS_LONG (ret))
+           {
+             r = (TYPE_UWORD) r;
+             l = (TYPE_UWORD) l;
+           }
+         retval = operandFromLit (l == r);
+       }
       break;
     case '<':
       retval = operandFromLit (operandLitValue (left) <
index 63a3b72d6105d8074537f953ac2d148c4f7185f1..b354d35278fb7cfef2b613ae533489c3078f8f0b 100644 (file)
@@ -98,7 +98,6 @@ testMod(void)
     //    LOG(("i%%17 == 15 = %u\n", (int)(i%9)));
     ASSERT(i%17 == 15);
 
-#if MOD_SIGN_FOLLOWS_DIVIDEND
     //    LOG(("i%%-7 == 2 = %u\n", (int)i%-7));
     ASSERT(i%-7 == 2);
 
@@ -107,5 +106,4 @@ testMod(void)
     ASSERT(i%3 == -1);
     //    LOG(("i%%-5 == -4 = %u\n", (int)i%-5));
     ASSERT(i%-5 == -4);
-#endif
 }