+ break;
+ /* if both are the same for an comparison operators */
+ case EQ_OP:
+ case LE_OP:
+ case GE_OP:
+ if (isOperandEqual (IC_LEFT (ic), IC_RIGHT (ic)))
+ {
+ ic->op = '=';
+ IC_RIGHT (ic) = operandFromLit (1);
+ IC_LEFT (ic) = NULL;
+ SET_RESULT_RIGHT (ic);
+ }
+ break;
+ case NE_OP:
+ case '>':
+ case '<':
+ if (isOperandEqual (IC_LEFT (ic), IC_RIGHT (ic)))
+ {
+ ic->op = '=';
+ IC_RIGHT (ic) = operandFromLit (0);
+ IC_LEFT (ic) = NULL;
+ SET_RESULT_RIGHT (ic);
+ }
+ break;
+ case CAST:
+ {
+ 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)))
+ {
+ ic->op = '=';
+ IC_RIGHT (ic) =
+ (operandLitValue (IC_LEFT (ic)) == 0 ?
+ operandFromLit (1) : operandFromLit (0));
+ IC_LEFT (ic) = NULL;
+ SET_ISADDR (IC_RESULT (ic), 0);
+ }
+ break;
+ case BITWISEAND:
+ /* if both operands are equal */
+ /* if yes turn it into assignment */
+ if (isOperandEqual (IC_LEFT (ic), IC_RIGHT (ic)))
+ {
+ if (IS_OP_VOLATILE (IC_LEFT (ic)))
+ {
+ iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic));
+ IC_RESULT (newic) = IC_LEFT (ic);
+ newic->lineno = ic->lineno;
+ addiCodeToeBBlock (ebp, newic, ic->next);
+ }
+ ic->op = '=';
+ IC_LEFT (ic) = NULL;
+ SET_RESULT_RIGHT (ic);
+ return;
+ }
+ /* swap literal to right ic */
+ if (IS_OP_LITERAL (IC_LEFT (ic)))
+ {
+ operand *op;
+
+ op = IC_LEFT (ic);
+ IC_LEFT (ic) = IC_RIGHT (ic);
+ IC_RIGHT (ic) = op;
+ }
+ if (IS_OP_LITERAL (IC_RIGHT (ic)))
+ {
+ /* if BITWISEAND then check if one of them is a zero */
+ /* if yes turn it into 0 assignment */
+ if (operandLitValue (IC_RIGHT (ic)) == 0.0)
+ {
+ if (IS_OP_VOLATILE (IC_LEFT (ic)))
+ {
+ iCode *newic = newiCode (DUMMY_READ_VOLATILE, NULL, IC_LEFT (ic));
+ IC_RESULT (newic) = IC_LEFT (ic);
+ newic->lineno = ic->lineno;
+ addiCodeToeBBlock (ebp, newic, ic->next);
+ }
+ ic->op = '=';
+ IC_LEFT (ic) = NULL;
+ SET_RESULT_RIGHT (ic);
+ return;
+ }
+ /* if BITWISEAND then check if one of them is 0xff... */
+ /* if yes turn it into assignment */
+ {
+ unsigned val;
+
+ switch (getSize (operandType (IC_RIGHT (ic))))
+ {
+ case 1:
+ val = 0xff;
+ break;
+ case 2:
+ val = 0xffff;
+ break;
+ case 4:
+ val = 0xffffffff;
+ break;
+ default:
+ return;
+ }
+ if (((unsigned) operandLitValue (IC_RIGHT (ic)) & val) == val)
+ {
+ ic->op = '=';
+ IC_RIGHT (ic) = IC_LEFT (ic);
+ IC_LEFT (ic) = NULL;
+ SET_RESULT_RIGHT (ic);
+ return;
+ }
+ }