+2008-01-20 Borut Razem <borut.razem AT siol.net>
+
+ * src/SDCCcse.c: partially fixed enhancement request
+ #1793872 - multiply by -1 not collapsed
+ * support/regression/tests/arithcsi.c: added regression test
+
2008-01-19 Maarten Brock <sourceforge.brock AT dse.nl>
* as/mcs51/asx8051.dsp: removed define SDK
case '*':
if (IS_OP_LITERAL (IC_LEFT (ic)))
{
+ double leftValue = operandLitValue (IC_LEFT (ic));
- if (operandLitValue (IC_LEFT (ic)) == 0.0)
+ if (leftValue == 0.0)
{
ic->op = '=';
IC_RIGHT (ic) = IC_LEFT (ic);
SET_RESULT_RIGHT (ic);
return;
}
- if (operandLitValue (IC_LEFT (ic)) == 1.0)
+ if (leftValue == 1.0)
{
/* '*' can have two unsigned chars as operands */
/* and an unsigned int as result. */
}
return;
}
+ if (leftValue == -1.0)
+ {
+ /* convert -1 * x to -x */
+ ic->op = UNARYMINUS;
+ IC_LEFT (ic) = IC_RIGHT (ic);
+ IC_RIGHT (ic) = NULL;
+ return;
+ }
}
if (IS_OP_LITERAL (IC_RIGHT (ic)))
{
+ double rightValue = operandLitValue (IC_RIGHT (ic));
- if (operandLitValue (IC_RIGHT (ic)) == 0.0)
+ if (rightValue == 0.0)
{
ic->op = '=';
IC_LEFT (ic) = NULL;
return;
}
- if (operandLitValue (IC_RIGHT (ic)) == 1.0)
+ if (rightValue == 1.0)
{
/* '*' can have two unsigned chars as operands */
/* and an unsigned int as result. */
}
return;
}
+ if (rightValue == -1.0)
+ {
+ /* convert x * -1 to -x */
+ ic->op = UNARYMINUS;
+ IC_RIGHT (ic) = NULL;
+ return;
+ }
}
break;
case '/':