Fix bug 700121
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 11 Mar 2003 20:41:48 +0000 (20:41 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 11 Mar 2003 20:41:48 +0000 (20:41 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2374 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCcse.c

index 60e50bdaa600c260f1ded1a8471e354b3194b2f0..d6ef854a6a88e2128c1ffa1b1e9c04909e997064 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-03-11 Kevin Vigor <kevin@vigor.nu>
+
+       * src/SDCCcse.c: fix findCheaperOp to prevent replacing int types
+       with shorter literals. Fixes bug 700121.
+
 2003-03-11    <johan@balder>
 
        * src/SDCCsymt.c (compareType): a (void *) can be assigned to any pointer
index a3c8a027c5cd111a077f4a7678e79691ef40f4ad..00e9cfafa58730ac9c0c17d468b634de7d87629f 100644 (file)
@@ -334,6 +334,7 @@ DEFSETFUNC (findCheaperOp)
   if ((*opp) && 
       (isOperandLiteral(*opp) || !checkSign || 
        (checkSign &&
+       IS_SPEC(operandType (cop)) && IS_SPEC(operandType (*opp)) &&
        (SPEC_USIGN(operandType (cop))==SPEC_USIGN(operandType (*opp)) &&
         (SPEC_LONG(operandType (cop))==SPEC_LONG(operandType (*opp)))))))
       {
@@ -358,6 +359,19 @@ DEFSETFUNC (findCheaperOp)
          *opp = operandFromOperand (*opp);
          (*opp)->isaddr = cop->isaddr;
        }
+         
+      if (IS_SPEC(operandType (cop)) && IS_SPEC(operandType (*opp)) &&
+         SPEC_NOUN(operandType(cop)) != SPEC_NOUN(operandType(*opp)))
+       {
+           //fprintf(stderr, 
+           //      "findCheaperOp: "
+           //      "was about to replace %s with %s, Kev says no.\n",
+           //      nounName(operandType(cop)),
+           //      nounName(operandType(*opp)));
+           *opp = NULL;
+           return 0;
+        }
+         
       LRH(printf ("findCheaperOp: %s < %s\n",\
              IS_SYMOP((*opp)) ? OP_SYMBOL((*opp))->name : "!SYM",\
              OP_SYMBOL(cop)->name));