From 404aa858eff3039d996d123c8ba8bbdc239f369c Mon Sep 17 00:00:00 2001 From: kvigor Date: Tue, 11 Mar 2003 20:41:48 +0000 Subject: [PATCH] Fix bug 700121 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2374 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 5 +++++ src/SDCCcse.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index 60e50bda..d6ef854a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-03-11 Kevin Vigor + + * src/SDCCcse.c: fix findCheaperOp to prevent replacing int types + with shorter literals. Fixes bug 700121. + 2003-03-11 * src/SDCCsymt.c (compareType): a (void *) can be assigned to any pointer diff --git a/src/SDCCcse.c b/src/SDCCcse.c index a3c8a027..00e9cfaf 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -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)); -- 2.30.2