From 11979e848b68c5b93ff18a4c45d97fcd8afe59f4 Mon Sep 17 00:00:00 2001 From: bernhardheld Date: Tue, 23 Aug 2005 20:22:54 +0000 Subject: [PATCH 1/1] * src/SDCCopt.c (convertToFcall): fixed modulus with divisors 1 and ffffffffu git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3876 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 5 +++++ src/SDCCopt.c | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 66aedfe7..5bfbaa86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-08-23 Bernhard Held + + * src/SDCCopt.c (convertToFcall): fixed modulus with divisors 1 and + ffffffffu + 2005-08-23 Maarten Brock * as/mcs51/aslink.h: completed lkrloc.c prototypes diff --git a/src/SDCCopt.c b/src/SDCCopt.c index 24376b29..bf6d4cbe 100644 --- a/src/SDCCopt.c +++ b/src/SDCCopt.c @@ -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)) { -- 2.30.2