fixed the
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 14 May 2001 14:07:38 +0000 (14:07 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 14 May 2001 14:07:38 +0000 (14:07 +0000)
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
src/SDCCicode.c
src/ds390/ralloc.c
src/mcs51/ralloc.c

index b02adc0e708917510a9424c6d523ec99fc410ac5..a092c70310abcdf37c29663957992e86ca7ac6b9 100644 (file)
@@ -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) &&
index 7a6f05055cfd8ffe3e409fe540f7b72c765152c5..29867e0fd6caa001b7d6ac912747f3e1b1dff807 100644 (file)
@@ -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 */
index 782f768317a1d0bb1a9898a81ad40c23e3eeeed0..ccf9941091c727a5445fabf4c6808381da18b3b4 100644 (file)
@@ -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;
index 76040b5bf6dd7f73c69ee9406098c11d16fa211a..447c9ff11ce6be4341154476860fcaa7f87e2c0a 100644 (file)
@@ -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;