From 017845ae07006e3d4f2b6dd99fc96a611b75df32 Mon Sep 17 00:00:00 2001 From: johanknol Date: Fri, 11 May 2001 10:59:48 +0000 Subject: [PATCH] fixed the foo[foo[5]+5]=10 bug git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@801 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- device/examples/ds390/ow390/owsesu.c | 1 - src/SDCCicode.c | 23 +++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/device/examples/ds390/ow390/owsesu.c b/device/examples/ds390/ow390/owsesu.c index 2a4adf79..d0acf558 100755 --- a/device/examples/ds390/ow390/owsesu.c +++ b/device/examples/ds390/ow390/owsesu.c @@ -64,7 +64,6 @@ int owAcquire(int portnum, char *port_zstr, char *return_msg) " aborting.\nClosing port %s.\n",port_zstr,port_zstr); return FALSE; } - printf (return_msg); // TODO: tini bug // detect DS2480 if (DS2480Detect(portnum)) diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 98c9da14..748a9daf 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -1699,12 +1699,22 @@ geniCodeMultiply (operand * left, operand * right,int resultIsInt) return operandFromValue (valMult (left->operand.valOperand, right->operand.valOperand)); + if (IS_LITERAL(retype)) { + p2 = powof2 ((unsigned long) floatFromVal (right->operand.valOperand)); + } + if (resultIsInt) { saveOption = options.ANSIint; options.ANSIint = 0; } resType = usualBinaryConversions (&left, &right); +#if 1 + rtype = operandType (right); + retype = getSpec (rtype); + ltype = operandType (left); + letype = getSpec (ltype); +#endif if (resultIsInt) { options.ANSIint = saveOption; @@ -1714,11 +1724,12 @@ geniCodeMultiply (operand * left, operand * right,int resultIsInt) /* if the right is a literal & power of 2 */ /* then make it a left shift */ - /*code generated for 1 byte * 1 byte literal = 2 bytes result is more efficient in most cases */ - /*than 2 bytes result = 2 bytes << literal if port as 1 byte muldiv */ - if (IS_LITERAL (retype) && !IS_FLOAT (letype) && - !((resultIsInt) && (getSize (resType) != getSize (ltype)) && (1 == port->muldiv.native_below)) && - (p2 = powof2 ((unsigned long) floatFromVal (right->operand.valOperand)))) + /* code generated for 1 byte * 1 byte literal = 2 bytes result is more + efficient in most cases than 2 bytes result = 2 bytes << literal + if port has 1 byte muldiv */ + if (p2 && !IS_FLOAT (letype) && + !((resultIsInt) && (getSize (resType) != getSize (ltype)) && + (port->muldiv.native_below == 1))) { if ((resultIsInt) && (getSize (resType) != getSize (ltype))) { @@ -1726,7 +1737,7 @@ geniCodeMultiply (operand * left, operand * right,int resultIsInt) left = geniCodeCast (resType, left, TRUE); ltype = operandType (left); } - ic = newiCode (LEFT_OP, left, operandFromLit (p2)); /* left shift */ + ic = newiCode (LEFT_OP, left, operandFromLit (p2)); /* left shift */ } else { -- 2.30.2