projects
/
fw
/
sdcc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* src/SDCCast.c (createIvalStruct, createIvalArray, createIvalPtr, createIval): imple...
[fw/sdcc]
/
src
/
SDCCcse.c
diff --git
a/src/SDCCcse.c
b/src/SDCCcse.c
index 83863baa234830078142284f6f23996615e10d52..e56c84a581551a5fe36ceee9f9654e18a225f3b7 100644
(file)
--- a/
src/SDCCcse.c
+++ b/
src/SDCCcse.c
@@
-148,7
+148,7
@@
void ReplaceOpWithCheaperOp(operand **op, operand *cop) {
IS_SYMOP((*op)) ? OP_SYMBOL((*op))->name : "!SYM",
IS_SYMOP(cop) ? OP_SYMBOL(cop)->name : "!SYM");
// if op is a register equivalent
IS_SYMOP((*op)) ? OP_SYMBOL((*op))->name : "!SYM",
IS_SYMOP(cop) ? OP_SYMBOL(cop)->name : "!SYM");
// if op is a register equivalent
- if (IS_ITEMP(cop) && OP_SYMBOL((*op))->isreqv) {
+ if (IS_ITEMP(cop) &&
IS_SYMOP((*op)) &&
OP_SYMBOL((*op))->isreqv) {
operand **rop = &OP_SYMBOL((*op))->usl.spillLoc->reqv;
if (isOperandEqual(*rop, *op)) {
printf ("true");
operand **rop = &OP_SYMBOL((*op))->usl.spillLoc->reqv;
if (isOperandEqual(*rop, *op)) {
printf ("true");
@@
-818,7
+818,8
@@
algebraicOpts (iCode * ic, eBBlock * ebp)
case '+':
/* if adding the same thing change to left shift by 1 */
if (IC_LEFT (ic)->key == IC_RIGHT (ic)->key &&
case '+':
/* if adding the same thing change to left shift by 1 */
if (IC_LEFT (ic)->key == IC_RIGHT (ic)->key &&
- !IS_FLOAT (operandType (IC_RESULT (ic))))
+ !(IS_FLOAT (operandType (IC_RESULT (ic)))
+ || IS_FIXED(operandType (IC_RESULT (ic)))))
{
ic->op = LEFT_OP;
IC_RIGHT (ic) = operandFromLit (1);
{
ic->op = LEFT_OP;
IC_RIGHT (ic) = operandFromLit (1);
@@
-829,8
+830,10
@@
algebraicOpts (iCode * ic, eBBlock * ebp)
if (IS_OP_LITERAL (IC_LEFT (ic)) &&
operandLitValue (IC_LEFT (ic)) == 0.0)
{
if (IS_OP_LITERAL (IC_LEFT (ic)) &&
operandLitValue (IC_LEFT (ic)) == 0.0)
{
- if (compareType (operandType (IC_RESULT (ic)),
- operandType (IC_RIGHT (ic)))<0)
+ int typematch;
+ typematch = compareType (operandType (IC_RESULT (ic)),
+ operandType (IC_RIGHT (ic)));
+ if (typematch<0)
{
ic->op = CAST;
IC_LEFT (ic) = operandFromLink (operandType (IC_RESULT (ic)));
{
ic->op = CAST;
IC_LEFT (ic) = operandFromLink (operandType (IC_RESULT (ic)));
@@
-839,6
+842,12
@@
algebraicOpts (iCode * ic, eBBlock * ebp)
{
ic->op = '=';
IC_LEFT (ic) = NULL;
{
ic->op = '=';
IC_LEFT (ic) = NULL;
+ if (typematch==0)
+ {
+ /* for completely different types, preserve the source type */
+ IC_RIGHT (ic) = operandFromOperand (IC_RIGHT (ic));
+ setOperandType (IC_RIGHT (ic), operandType (IC_RESULT (ic)));
+ }
}
SET_ISADDR (IC_RESULT (ic), 0);
SET_ISADDR (IC_RIGHT (ic), 0);
}
SET_ISADDR (IC_RESULT (ic), 0);
SET_ISADDR (IC_RIGHT (ic), 0);
@@
-847,8
+856,10
@@
algebraicOpts (iCode * ic, eBBlock * ebp)
if (IS_OP_LITERAL (IC_RIGHT (ic)) &&
operandLitValue (IC_RIGHT (ic)) == 0.0)
{
if (IS_OP_LITERAL (IC_RIGHT (ic)) &&
operandLitValue (IC_RIGHT (ic)) == 0.0)
{
- if (compareType (operandType (IC_RESULT (ic)),
- operandType (IC_LEFT (ic)))<0)
+ int typematch;
+ typematch = compareType (operandType (IC_RESULT (ic)),
+ operandType (IC_LEFT (ic)));
+ if (typematch<0)
{
ic->op = CAST;
IC_RIGHT (ic) = IC_LEFT (ic);
{
ic->op = CAST;
IC_RIGHT (ic) = IC_LEFT (ic);
@@
-859,6
+870,12
@@
algebraicOpts (iCode * ic, eBBlock * ebp)
ic->op = '=';
IC_RIGHT (ic) = IC_LEFT (ic);
IC_LEFT (ic) = NULL;
ic->op = '=';
IC_RIGHT (ic) = IC_LEFT (ic);
IC_LEFT (ic) = NULL;
+ if (typematch==0)
+ {
+ /* for completely different types, preserve the source type */
+ IC_RIGHT (ic) = operandFromOperand (IC_RIGHT (ic));
+ setOperandType (IC_RIGHT (ic), operandType (IC_RESULT (ic)));
+ }
}
SET_ISADDR (IC_RIGHT (ic), 0);
SET_ISADDR (IC_RESULT (ic), 0);
}
SET_ISADDR (IC_RIGHT (ic), 0);
SET_ISADDR (IC_RESULT (ic), 0);
@@
-1735,6
+1752,9
@@
static int isSignedOp (iCode *ic)
case RRC:
case RLC:
case GETHBIT:
case RRC:
case RLC:
case GETHBIT:
+ case GETABIT:
+ case GETBYTE:
+ case GETWORD:
case RIGHT_OP:
case CAST:
case ARRAYINIT:
case RIGHT_OP:
case CAST:
case ARRAYINIT: