From 25b445778074199472238a6178f40ed1e0f39058 Mon Sep 17 00:00:00 2001 From: johanknol Date: Mon, 14 May 2001 14:07:38 +0000 Subject: [PATCH] fixed the int i=100; printf ("%d", i/8); bug, where i/8 was replaced by a short (==char :) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@819 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCcse.c | 5 ++++- src/SDCCicode.c | 8 +++++--- src/ds390/ralloc.c | 10 ++++++++++ src/mcs51/ralloc.c | 12 ++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/SDCCcse.c b/src/SDCCcse.c index b02adc0e..a092c703 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -300,7 +300,10 @@ DEFSETFUNC (findCheaperOp) IS_ITEMP (IC_RESULT (cdp->diCode))) *opp = IC_RESULT (cdp->diCode); - if ((*opp)&&(SPEC_USIGN(operandType (cop))==SPEC_USIGN(operandType (*opp)))) + if ((*opp) && + (SPEC_USIGN(operandType (cop))==SPEC_USIGN(operandType (*opp))) && + (SPEC_SHORT(operandType (cop))==SPEC_SHORT(operandType (*opp))) && + (SPEC_LONG(operandType (cop))==SPEC_LONG(operandType (*opp)))) { if ((isGlobalInNearSpace (cop) && diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 7a6f0505..29867e0f 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -48,6 +48,7 @@ operand *geniCodeArray (operand *, operand *,int); operand *geniCodeArray2Ptr (operand *); operand *geniCodeRValue (operand *, bool); operand *geniCodeDerefPtr (operand *,int); +int isLvaluereq(int lvl); #define PRINTFUNC(x) void x (FILE *of, iCode *ic, char *s) /* forward definition of ic print functions */ @@ -838,7 +839,7 @@ operand * operandOperation (operand * left, operand * right, int op, sym_link * type) { - sym_link *let , *ret; + sym_link *let , *ret=NULL; operand *retval = (operand *) 0; assert (isOperandLiteral (left)); @@ -1677,8 +1678,9 @@ geniCodeDivision (operand * left, operand * right) if (IS_LITERAL (retype) && !IS_FLOAT (letype) && (p2 = powof2 ((unsigned long) - floatFromVal (right->operand.valOperand)))) - ic = newiCode (RIGHT_OP, left, operandFromLit (p2)); /* right shift */ + floatFromVal (right->operand.valOperand)))) { + ic = newiCode (RIGHT_OP, left, operandFromLit (p2)); /* right shift */ + } else { ic = newiCode ('/', left, right); /* normal division */ diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index 782f7683..ccf99410 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -2213,6 +2213,16 @@ packForPush (iCode * ic, eBBlock * ebp) for (lic = ic; lic != dic ; lic = lic->prev) { if (bitVectBitValue(dbv,lic->key)) return ; } + /* make sure they have the same type */ + { + sym_link *itype=operandType(IC_LEFT(ic)); + sym_link *ditype=operandType(IC_RIGHT(dic)); + + if (SPEC_USIGN(itype)!=SPEC_USIGN(ditype) || + SPEC_SHORT(itype)!=SPEC_SHORT(ditype) || + SPEC_USIGN(itype)!=SPEC_USIGN(ditype)) + return; + } /* extend the live range of replaced operand if needed */ if (OP_SYMBOL(IC_RIGHT(dic))->liveTo < ic->seq) { OP_SYMBOL(IC_RIGHT(dic))->liveTo = ic->seq; diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index 76040b5b..447c9ff1 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -2183,6 +2183,8 @@ accuse: /*-----------------------------------------------------------------*/ /* packForPush - hueristics to reduce iCode for pushing */ /*-----------------------------------------------------------------*/ +catchMe() {} + static void packForPush (iCode * ic, eBBlock * ebp) { @@ -2212,6 +2214,16 @@ packForPush (iCode * ic, eBBlock * ebp) if (bitVectBitValue(dbv,lic->key)) return ; } + /* make sure they have the same type */ + { + sym_link *itype=operandType(IC_LEFT(ic)); + sym_link *ditype=operandType(IC_RIGHT(dic)); + + if (SPEC_USIGN(itype)!=SPEC_USIGN(ditype) || + SPEC_SHORT(itype)!=SPEC_SHORT(ditype) || + SPEC_USIGN(itype)!=SPEC_USIGN(ditype)) + return; + } /* extend the live range of replaced operand if needed */ if (OP_SYMBOL(IC_RIGHT(dic))->liveTo < ic->seq) { OP_SYMBOL(IC_RIGHT(dic))->liveTo = ic->seq; -- 2.30.2