X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCcse.c;h=1bff79e102f6ea631e3ddd69921710a554bd9d27;hb=9b4669d9f07c2e7d49e266e15b0478d64445e337;hp=45a0aef708ffb048489b391d6b610f53c41f9b08;hpb=fb5996bbed3f3c1f8fb964c75d4d0842323d9560;p=fw%2Fsdcc diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 45a0aef7..1bff79e1 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -326,16 +326,6 @@ DEFSETFUNC (findCheaperOp) (*opp)->isaddr = cop->isaddr; } - if ((*opp)->type==VALUE && - IS_SYMOP(cop) && IS_GENPTR(OP_SYMBOL(cop)->type)) { - // This is a value assigned to a gpointer - if (1) { - // this value is used for a cast, so we can not - *opp=NULL; - return 0; - } - } - return 1; } @@ -820,25 +810,28 @@ algebraicOpts (iCode * ic) } break; case CAST: - /* if this is a cast of a literal value */ - if (IS_OP_LITERAL (IC_RIGHT (ic))) - { - ic->op = '='; - IC_RIGHT (ic) = - operandFromValue (valCastLiteral (operandType (IC_LEFT (ic)), - operandLitValue (IC_RIGHT (ic)))); - IC_LEFT (ic) = NULL; - SET_ISADDR (IC_RESULT (ic), 0); - } - /* if casting to the same */ - if (compareType (operandType (IC_RESULT (ic)), - operandType (IC_RIGHT (ic))) == 1) - { - ic->op = '='; - IC_LEFT (ic) = NULL; - SET_ISADDR (IC_RESULT (ic), 0); - } - break; + { + sym_link *otype = operandType(IC_RIGHT(ic)); + sym_link *ctype = operandType(IC_LEFT(ic)); + /* if this is a cast of a literal value */ + if (IS_OP_LITERAL (IC_RIGHT (ic)) && + !(IS_GENPTR(ctype) && (IS_PTR(otype) && !IS_GENPTR(otype)))) { + ic->op = '='; + IC_RIGHT (ic) = + operandFromValue (valCastLiteral (operandType (IC_LEFT (ic)), + operandLitValue (IC_RIGHT (ic)))); + IC_LEFT (ic) = NULL; + SET_ISADDR (IC_RESULT (ic), 0); + } + /* if casting to the same */ + if (compareType (operandType (IC_RESULT (ic)), + operandType (IC_RIGHT (ic))) == 1) { + ic->op = '='; + IC_LEFT (ic) = NULL; + SET_ISADDR (IC_RESULT (ic), 0); + } + } + break; case '!': if (IS_OP_LITERAL (IC_LEFT (ic))) { @@ -1023,7 +1016,9 @@ ifxOptimize (iCode * ic, set * cseSet, /* too often, if it does happen then the user pays */ /* the price */ computeControlFlow (ebbs, count, 1); - werror (W_CONTROL_FLOW, ic->filename, ic->lineno); + if (!options.lessPedantic) { + werror (W_CONTROL_FLOW, ic->filename, ic->lineno); + } return; } @@ -1037,7 +1032,9 @@ ifxOptimize (iCode * ic, set * cseSet, remiCodeFromeBBlock (ebb, ic); computeControlFlow (ebbs, count, 1); - werror (W_CONTROL_FLOW, ic->filename, ic->lineno); + if (!options.lessPedantic) { + werror (W_CONTROL_FLOW, ic->filename, ic->lineno); + } return; }