From c859421da6f261bd7dfae64a54b7c057105cd4b9 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Thu, 29 Jun 2006 09:50:59 +0000 Subject: [PATCH] prefer arithmethic over pointer constants [r7963] --- ir/opt/reassoc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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; -- 2.20.1