* src/SDCCcse.c (findCheaperOp): fixed bug 1376320, copy signedness to replacing...
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 10 Dec 2005 20:43:31 +0000 (20:43 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 10 Dec 2005 20:43:31 +0000 (20:43 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4005 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCcse.c

index 336adeb7401aec60da18c2d7f31733b2b0b3f217..8ee78781ac0d117fad63e01d49a946d221a204a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-12-10 Bernhard Held <bernhard AT bernhardheld.de>
+
+       * src/SDCCcse.c (findCheaperOp): fixed bug 1376320, copy signedness to
+       replacing literals
+
 2005-12-08 Raphael Neider <rneider AT web.de>
 
        * src/pic/device.c: renamed is_shared to pic14_is_shared
index e56c84a581551a5fe36ceee9f9654e18a225f3b7..35a5df940f476513025bc343d0386ae13e69f198 100644 (file)
@@ -144,9 +144,11 @@ pcseDef (void *item, va_list ap)
 
 void ReplaceOpWithCheaperOp(operand **op, operand *cop) {
 #ifdef RANGEHUNT
-  printf ("ReplaceOpWithCheaperOp %s with %s: ",
-          IS_SYMOP((*op)) ? OP_SYMBOL((*op))->name : "!SYM",
-          IS_SYMOP(cop) ? OP_SYMBOL(cop)->name : "!SYM");
+  printf ("ReplaceOpWithCheaperOp\n\t");
+  printOperand (*op, stdout);
+  printf ("\nwith\t");
+  printOperand (cop, stdout);
+
   // if op is a register equivalent
   if (IS_ITEMP(cop) && IS_SYMOP((*op)) && OP_SYMBOL((*op))->isreqv) {
     operand **rop = &OP_SYMBOL((*op))->usl.spillLoc->reqv;
@@ -415,6 +417,15 @@ DEFSETFUNC (findCheaperOp)
           (*opp)->isaddr = cop->isaddr;
         }
 
+      /* copy signedness to literal operands */
+      if (IS_SPEC(operandType (cop)) && IS_SPEC(operandType (*opp))
+          && isOperandLiteral(*opp)
+          && SPEC_NOUN(operandType(*opp)) == SPEC_NOUN(operandType(cop))
+          && SPEC_USIGN(operandType(*opp)) != SPEC_USIGN(operandType(cop)))
+      {
+          SPEC_USIGN(operandType(*opp)) = SPEC_USIGN(operandType(cop));
+      }
+
       if (IS_SPEC(operandType (cop)) && IS_SPEC(operandType (*opp)) &&
           SPEC_NOUN(operandType(cop)) != SPEC_NOUN(operandType(*opp)))
         {