From: Michael Beck Date: Thu, 29 Jun 2006 09:50:59 +0000 (+0000) Subject: prefer arithmethic over pointer constants X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=c859421da6f261bd7dfae64a54b7c057105cd4b9;p=libfirm prefer arithmethic over pointer constants [r7963] --- diff --git a/ir/opt/reassoc.c b/ir/opt/reassoc.c index 3b33024eb..b0144db1c 100644 --- a/ir/opt/reassoc.c +++ b/ir/opt/reassoc.c @@ -87,8 +87,20 @@ static void get_comm_Binop_ops(ir_node *binop, ir_node **a, ir_node **c) assert(is_op_commutative(get_irn_op(binop))); switch (class_a + 2*class_b) { - case REAL_CONSTANT + 2*NO_CONSTANT: case REAL_CONSTANT + 2*REAL_CONSTANT: + /* if both are constants, one might be a + * pointer constant like NULL, return the other + */ + if (mode_is_reference(get_irn_mode(op_a))) { + *a = op_a; + *c = op_b; + } + else { + *a = op_b; + *c = op_a; + } + break; + case REAL_CONSTANT + 2*NO_CONSTANT: case REAL_CONSTANT + 2*REGION_CONST: case REGION_CONST + 2*NO_CONSTANT: *a = op_b;