2006-04-25 Bernhard Held <bernhard AT bernhardheld.de>
* src/SDCCast.c (decorateType): partial fix for RFE 1475769,
- remove cast to same type
+ remove cast to same type
+ * src/SDCCast.c (decorateType): fix for RFE 1475742,
+ optimize 'ifx (op == 0)' resp. 'ifx (op != 0)'
2006-04-24 Bernhard Held <bernhard AT bernhardheld.de>
goto errorTreeReturn;
}
}
+
/* if unsigned value < 0 then always false */
/* if (unsigned value) > 0 then '(unsigned value) ? 1 : 0' */
if (SPEC_USIGN(LETYPE(tree)) &&
tree->right); /* val 0 */
tree->right->lineno = tree->lineno;
tree->right->left->lineno = tree->lineno;
- decorateType (tree->right, RESULT_TYPE_NONE);
+ tree->decorated = 0;
+ return decorateType (tree, resultType);
}
}
+
+ /* 'ifx (op == 0)' -> 'ifx (!(op))' */
+ if (IS_LITERAL(RTYPE(tree)) &&
+ floatFromVal (valFromType (RETYPE (tree))) == 0 &&
+ tree->opval.op == EQ_OP &&
+ resultType == RESULT_TYPE_IFX)
+ {
+ tree->opval.op = '!';
+ tree->right = NULL;
+ tree->decorated = 0;
+ return decorateType (tree, resultType);
+ }
+
/* if they are both literal then */
/* rewrite the tree */
if (IS_LITERAL (RTYPE (tree)) &&