Allow fold_constants to handle some math identities

Such as x*0 -> 0, x*1 -> x, x+0 ->x, etc.
This commit is contained in:
Bill Currie 2019-06-09 22:34:23 +09:00
parent c98d1ff08c
commit 3196bcc851

View file

@ -1458,7 +1458,7 @@ fold_constants (expr_t *e)
if (e->type == ex_uexpr) {
e1 = e->e.expr.e1;
if (!e1 || !is_constant (e1)) {
if (!e1) {
return e;
}
op = e->e.expr.op;
@ -1473,7 +1473,7 @@ fold_constants (expr_t *e)
} else if (e->type == ex_expr) {
e1 = e->e.expr.e1;
e2 = e->e.expr.e2;
if (!is_constant (e1) || !is_constant (e2)) {
if (!is_constant (e1) && !is_constant (e2)) {
return e;
}