Improve interaction between temps and const_folding.

Unfortunately, this seems to overdo the decrementing, so it could be
dangerous, but the ruamoko directory builds properly.
This commit is contained in:
Bill Currie 2011-01-11 08:47:52 +09:00
parent abe471110c
commit 5b43fc1de3

View file

@ -217,17 +217,17 @@ do_op_float (int op, expr_t *e, expr_t *e1, expr_t *e2)
e->e.expr.type = type; e->e.expr.type = type;
if (op == '*' && is_constant (e1) && e1->e.float_val == 1) if (op == '*' && is_constant (e1) && e1->e.float_val == 1)
return e2; return dec_users (e2);
if (op == '*' && is_constant (e2) && e2->e.float_val == 1) if (op == '*' && is_constant (e2) && e2->e.float_val == 1)
return e1; return dec_users (e1);
if (op == '/' && is_constant (e2) && e2->e.float_val == 1) if (op == '/' && is_constant (e2) && e2->e.float_val == 1)
return e1; return dec_users (e1);
if (op == '+' && is_constant (e1) && e1->e.float_val == 0) if (op == '+' && is_constant (e1) && e1->e.float_val == 0)
return e2; return dec_users (e2);
if (op == '+' && is_constant (e2) && e2->e.float_val == 0) if (op == '+' && is_constant (e2) && e2->e.float_val == 0)
return e1; return dec_users (e1);
if (op == '-' && is_constant (e2) && e2->e.float_val == 0) if (op == '-' && is_constant (e2) && e2->e.float_val == 0)
return e1; return dec_users (e1);
if (op == '=' || op == 'b' || !is_constant (e1) || !is_constant (e2)) if (op == '=' || op == 'b' || !is_constant (e1) || !is_constant (e2))
return e; return e;
@ -343,19 +343,19 @@ do_op_vector (int op, expr_t *e, expr_t *e1, expr_t *e2)
if (op == '*' && is_constant (e1) && e1->type == ex_float if (op == '*' && is_constant (e1) && e1->type == ex_float
&& e1->e.float_val == 1) && e1->e.float_val == 1)
return e2; return dec_users (e2);
if (op == '*' && is_constant (e2) && e2->type == ex_float if (op == '*' && is_constant (e2) && e2->type == ex_float
&& e2->e.float_val == 1) && e2->e.float_val == 1)
return e1; return dec_users (e1);
if (op == '/' && is_constant (e2) && e2->type == ex_float if (op == '/' && is_constant (e2) && e2->type == ex_float
&& e2->e.float_val == 1) && e2->e.float_val == 1)
return e1; return dec_users (e1);
if (op == '+' && is_constant (e1) && VectorIsZero (e1->e.vector_val)) if (op == '+' && is_constant (e1) && VectorIsZero (e1->e.vector_val))
return e2; return dec_users (e2);
if (op == '+' && is_constant (e2) && VectorIsZero (e2->e.vector_val)) if (op == '+' && is_constant (e2) && VectorIsZero (e2->e.vector_val))
return e1; return dec_users (e1);
if (op == '-' && is_constant (e2) && VectorIsZero (e2->e.vector_val)) if (op == '-' && is_constant (e2) && VectorIsZero (e2->e.vector_val))
return e1; return dec_users (e1);
if (op == '=' || op == 'b' || !is_constant (e1) || !is_constant (e2)) if (op == '=' || op == 'b' || !is_constant (e1) || !is_constant (e2))
return e; return e;
@ -520,19 +520,19 @@ do_op_quaternion (int op, expr_t *e, expr_t *e1, expr_t *e2)
if (op == '*' && is_constant (e1) && e1->type == ex_float if (op == '*' && is_constant (e1) && e1->type == ex_float
&& e1->e.float_val == 1) && e1->e.float_val == 1)
return e2; return dec_users (e2);
if (op == '*' && is_constant (e2) && e2->type == ex_float if (op == '*' && is_constant (e2) && e2->type == ex_float
&& e2->e.float_val == 1) && e2->e.float_val == 1)
return e1; return dec_users (e1);
if (op == '/' && is_constant (e2) && e2->type == ex_float if (op == '/' && is_constant (e2) && e2->type == ex_float
&& e2->e.float_val == 1) && e2->e.float_val == 1)
return e1; return dec_users (e1);
if (op == '+' && is_constant (e1) && QuatIsZero (e1->e.quaternion_val)) if (op == '+' && is_constant (e1) && QuatIsZero (e1->e.quaternion_val))
return e2; return dec_users (e2);
if (op == '+' && is_constant (e2) && QuatIsZero (e2->e.quaternion_val)) if (op == '+' && is_constant (e2) && QuatIsZero (e2->e.quaternion_val))
return e1; return dec_users (e1);
if (op == '-' && is_constant (e2) && QuatIsZero (e2->e.quaternion_val)) if (op == '-' && is_constant (e2) && QuatIsZero (e2->e.quaternion_val))
return e1; return dec_users (e1);
if (op == '=' || op == 'b' || !is_constant (e1) || !is_constant (e2)) if (op == '=' || op == 'b' || !is_constant (e1) || !is_constant (e2))
return e; return e;
@ -603,17 +603,17 @@ do_op_integer (int op, expr_t *e, expr_t *e1, expr_t *e2)
} }
if (op == '*' && is_constant (e1) && e1->e.integer_val == 1) if (op == '*' && is_constant (e1) && e1->e.integer_val == 1)
return e2; return dec_users (e2);
if (op == '*' && is_constant (e2) && e2->e.integer_val == 1) if (op == '*' && is_constant (e2) && e2->e.integer_val == 1)
return e1; return dec_users (e1);
if (op == '/' && is_constant (e2) && e2->e.integer_val == 1) if (op == '/' && is_constant (e2) && e2->e.integer_val == 1)
return e1; return dec_users (e1);
if (op == '+' && is_constant (e1) && e1->e.integer_val == 0) if (op == '+' && is_constant (e1) && e1->e.integer_val == 0)
return e2; return dec_users (e2);
if (op == '+' && is_constant (e2) && e2->e.integer_val == 0) if (op == '+' && is_constant (e2) && e2->e.integer_val == 0)
return e1; return dec_users (e1);
if (op == '-' && is_constant (e2) && e2->e.integer_val == 0) if (op == '-' && is_constant (e2) && e2->e.integer_val == 0)
return e1; return dec_users (e1);
if (op == '=' || op == 'b' || !is_constant (e1) || !is_constant (e2)) if (op == '=' || op == 'b' || !is_constant (e1) || !is_constant (e2))
return e; return e;