* src/SDCCopt.c (convertToFcall): fixed modulus with divisors 1 and ffffffffu
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 23 Aug 2005 20:22:54 +0000 (20:22 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 23 Aug 2005 20:22:54 +0000 (20:22 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3876 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCopt.c

index 66aedfe7b1206b0f9564a8f47767f357bd01f73d..5bfbaa8656d1bc3523faa67fdde75a6bc62fc2fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-08-23 Bernhard Held <bernhard AT bernhardheld.de>
+
+       * src/SDCCopt.c (convertToFcall): fixed modulus with divisors 1 and
+       ffffffffu
+
 2005-08-23 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * as/mcs51/aslink.h: completed lkrloc.c prototypes
index 24376b29c05ce49d3f32f0c378513870714bc7e1..bf6d4cbee4fc01a534b652222eccb918ace0331a 100644 (file)
@@ -802,8 +802,16 @@ convertToFcall (eBBlock ** ebbs, int count)
           if (ic->op == '%' && isOperandLiteral(IC_RIGHT(ic)) &&
               IS_UNSIGNED(operandType(IC_LEFT(ic))))
             {
-              unsigned litVal = abs((int)operandLitValue(IC_RIGHT(ic)));
+              unsigned litVal = fabs(operandLitValue(IC_RIGHT(ic)));
 
+              /* modulo by 1: no remainder */
+              if (litVal == 1)
+                {
+                  ic->op = '=';
+                  IC_RIGHT (ic) = operandFromLit(0);
+                  IC_LEFT (ic) = NULL;
+                  continue;
+                }
               // See if literal value is a power of 2.
               while (litVal && !(litVal & 1))
                 {