Commit 7e0b4eae by Peter Bergner Committed by Peter Bergner

PR middle-end/PR28690

	PR middle-end/PR28690
	* optabs.c (expand_binop): (emit_cmp_and_jump_insns): Allow EQ compares.
	* rtlanal.c (commutative_operand_precedence): Prefer both REG_POINTER
	and MEM_POINTER operands over REG and MEM operands.
	(swap_commutative_operands_p): Change return value to bool.
	* rtl.h: Update the corresponding prototype.
	* tree-ssa-address.c (gen_addr_rtx): Use simplify_gen_binary
	instead of gen_rtx_PLUS.
	* simplify-rtx.c (simplify_plus_minus_op_data_cmp): Change return
	value to bool.  Change function arguments to rtx's and update code
	to match.
	(simplify_plus_minus): Update the simplify_plus_minus_op_data_cmp
	calls to match the new declaration.
	* simplify-rtx.c (simplify_associative_operation): Don't
	reorder simplify_binary_operation arguments.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r126852
parent de2b3a07
2007-07-23 Peter Bergner <bergner@vnet.ibm.com>
Jakub Jelinek <jakub@redhat.com>
PR middle-end/PR28690
* optabs.c (expand_binop): (emit_cmp_and_jump_insns): Allow EQ compares.
* rtlanal.c (commutative_operand_precedence): Prefer both REG_POINTER
and MEM_POINTER operands over REG and MEM operands.
(swap_commutative_operands_p): Change return value to bool.
* rtl.h: Update the corresponding prototype.
* tree-ssa-address.c (gen_addr_rtx): Use simplify_gen_binary
instead of gen_rtx_PLUS.
* simplify-rtx.c (simplify_plus_minus_op_data_cmp): Change return
value to bool. Change function arguments to rtx's and update code
to match.
(simplify_plus_minus): Update the simplify_plus_minus_op_data_cmp
calls to match the new declaration.
* simplify-rtx.c (simplify_associative_operation): Don't
reorder simplify_binary_operation arguments.
2007-07-23 Richard Sandiford <richard@codesourcery.com> 2007-07-23 Richard Sandiford <richard@codesourcery.com>
* config/mips/mips.c (override_options): Use mips_costs to derive * config/mips/mips.c (override_options): Use mips_costs to derive
......
...@@ -4070,9 +4070,11 @@ emit_cmp_and_jump_insns (rtx x, rtx y, enum rtx_code comparison, rtx size, ...@@ -4070,9 +4070,11 @@ emit_cmp_and_jump_insns (rtx x, rtx y, enum rtx_code comparison, rtx size,
/* Swap operands and condition to ensure canonical RTL. */ /* Swap operands and condition to ensure canonical RTL. */
if (swap_commutative_operands_p (x, y)) if (swap_commutative_operands_p (x, y))
{ {
/* If we're not emitting a branch, this means some caller /* If we're not emitting a branch, callers are required to pass
is out of sync. */ operands in an order conforming to canonical RTL. We relax this
gcc_assert (label); for commutative comparsions so callers using EQ don't need to do
swapping by hand. */
gcc_assert (label || (comparison == swap_condition (comparison)));
op0 = y, op1 = x; op0 = y, op1 = x;
comparison = swap_condition (comparison); comparison = swap_condition (comparison);
......
...@@ -1690,7 +1690,7 @@ extern int reg_referenced_p (rtx, rtx); ...@@ -1690,7 +1690,7 @@ extern int reg_referenced_p (rtx, rtx);
extern int reg_used_between_p (rtx, rtx, rtx); extern int reg_used_between_p (rtx, rtx, rtx);
extern int reg_set_between_p (rtx, rtx, rtx); extern int reg_set_between_p (rtx, rtx, rtx);
extern int commutative_operand_precedence (rtx); extern int commutative_operand_precedence (rtx);
extern int swap_commutative_operands_p (rtx, rtx); extern bool swap_commutative_operands_p (rtx, rtx);
extern int modified_between_p (rtx, rtx, rtx); extern int modified_between_p (rtx, rtx, rtx);
extern int no_labels_between_p (rtx, rtx); extern int no_labels_between_p (rtx, rtx);
extern int modified_in_p (rtx, rtx); extern int modified_in_p (rtx, rtx);
......
...@@ -2877,9 +2877,9 @@ commutative_operand_precedence (rtx op) ...@@ -2877,9 +2877,9 @@ commutative_operand_precedence (rtx op)
/* Constants always come the second operand. Prefer "nice" constants. */ /* Constants always come the second operand. Prefer "nice" constants. */
if (code == CONST_INT) if (code == CONST_INT)
return -7; return -8;
if (code == CONST_DOUBLE) if (code == CONST_DOUBLE)
return -6; return -7;
op = avoid_constant_pool_reference (op); op = avoid_constant_pool_reference (op);
code = GET_CODE (op); code = GET_CODE (op);
...@@ -2887,22 +2887,24 @@ commutative_operand_precedence (rtx op) ...@@ -2887,22 +2887,24 @@ commutative_operand_precedence (rtx op)
{ {
case RTX_CONST_OBJ: case RTX_CONST_OBJ:
if (code == CONST_INT) if (code == CONST_INT)
return -5; return -6;
if (code == CONST_DOUBLE) if (code == CONST_DOUBLE)
return -5;
return -4; return -4;
return -3;
case RTX_EXTRA: case RTX_EXTRA:
/* SUBREGs of objects should come second. */ /* SUBREGs of objects should come second. */
if (code == SUBREG && OBJECT_P (SUBREG_REG (op))) if (code == SUBREG && OBJECT_P (SUBREG_REG (op)))
return -2; return -3;
return 0; return 0;
case RTX_OBJ: case RTX_OBJ:
/* Complex expressions should be the first, so decrease priority /* Complex expressions should be the first, so decrease priority
of objects. */ of objects. Prefer pointer objects over non pointer objects. */
if ((REG_P (op) && REG_POINTER (op))
|| (MEM_P (op) && MEM_POINTER (op)))
return -1; return -1;
return -2;
case RTX_COMM_ARITH: case RTX_COMM_ARITH:
/* Prefer operands that are themselves commutative to be first. /* Prefer operands that are themselves commutative to be first.
...@@ -2929,7 +2931,7 @@ commutative_operand_precedence (rtx op) ...@@ -2929,7 +2931,7 @@ commutative_operand_precedence (rtx op)
/* Return 1 iff it is necessary to swap operands of commutative operation /* Return 1 iff it is necessary to swap operands of commutative operation
in order to canonicalize expression. */ in order to canonicalize expression. */
int bool
swap_commutative_operands_p (rtx x, rtx y) swap_commutative_operands_p (rtx x, rtx y)
{ {
return (commutative_operand_precedence (x) return (commutative_operand_precedence (x)
......
...@@ -52,7 +52,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA ...@@ -52,7 +52,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
static rtx neg_const_int (enum machine_mode, rtx); static rtx neg_const_int (enum machine_mode, rtx);
static bool plus_minus_operand_p (rtx); static bool plus_minus_operand_p (rtx);
static int simplify_plus_minus_op_data_cmp (const void *, const void *); static bool simplify_plus_minus_op_data_cmp (rtx, rtx);
static rtx simplify_plus_minus (enum rtx_code, enum machine_mode, rtx, rtx); static rtx simplify_plus_minus (enum rtx_code, enum machine_mode, rtx, rtx);
static rtx simplify_immed_subreg (enum machine_mode, rtx, enum machine_mode, static rtx simplify_immed_subreg (enum machine_mode, rtx, enum machine_mode,
unsigned int); unsigned int);
...@@ -1499,16 +1499,12 @@ simplify_associative_operation (enum rtx_code code, enum machine_mode mode, ...@@ -1499,16 +1499,12 @@ simplify_associative_operation (enum rtx_code code, enum machine_mode mode,
} }
/* Attempt to simplify "(a op b) op c" as "a op (b op c)". */ /* Attempt to simplify "(a op b) op c" as "a op (b op c)". */
tem = swap_commutative_operands_p (XEXP (op0, 1), op1) tem = simplify_binary_operation (code, mode, XEXP (op0, 1), op1);
? simplify_binary_operation (code, mode, op1, XEXP (op0, 1))
: simplify_binary_operation (code, mode, XEXP (op0, 1), op1);
if (tem != 0) if (tem != 0)
return simplify_gen_binary (code, mode, XEXP (op0, 0), tem); return simplify_gen_binary (code, mode, XEXP (op0, 0), tem);
/* Attempt to simplify "(a op b) op c" as "(a op c) op b". */ /* Attempt to simplify "(a op b) op c" as "(a op c) op b". */
tem = swap_commutative_operands_p (XEXP (op0, 0), op1) tem = simplify_binary_operation (code, mode, XEXP (op0, 0), op1);
? simplify_binary_operation (code, mode, op1, XEXP (op0, 0))
: simplify_binary_operation (code, mode, XEXP (op0, 0), op1);
if (tem != 0) if (tem != 0)
return simplify_gen_binary (code, mode, tem, XEXP (op0, 1)); return simplify_gen_binary (code, mode, tem, XEXP (op0, 1));
} }
...@@ -3313,23 +3309,21 @@ struct simplify_plus_minus_op_data ...@@ -3313,23 +3309,21 @@ struct simplify_plus_minus_op_data
short neg; short neg;
}; };
static int static bool
simplify_plus_minus_op_data_cmp (const void *p1, const void *p2) simplify_plus_minus_op_data_cmp (rtx x, rtx y)
{ {
const struct simplify_plus_minus_op_data *d1 = p1;
const struct simplify_plus_minus_op_data *d2 = p2;
int result; int result;
result = (commutative_operand_precedence (d2->op) result = (commutative_operand_precedence (y)
- commutative_operand_precedence (d1->op)); - commutative_operand_precedence (x));
if (result) if (result)
return result; return result > 0;
/* Group together equal REGs to do more simplification. */ /* Group together equal REGs to do more simplification. */
if (REG_P (d1->op) && REG_P (d2->op)) if (REG_P (x) && REG_P (y))
return REGNO (d1->op) - REGNO (d2->op); return REGNO (x) > REGNO (y);
else else
return 0; return false;
} }
static rtx static rtx
...@@ -3473,14 +3467,14 @@ simplify_plus_minus (enum rtx_code code, enum machine_mode mode, rtx op0, ...@@ -3473,14 +3467,14 @@ simplify_plus_minus (enum rtx_code code, enum machine_mode mode, rtx op0,
{ {
struct simplify_plus_minus_op_data save; struct simplify_plus_minus_op_data save;
j = i - 1; j = i - 1;
if (simplify_plus_minus_op_data_cmp (&ops[j], &ops[i]) < 0) if (!simplify_plus_minus_op_data_cmp (ops[j].op, ops[i].op))
continue; continue;
canonicalized = 1; canonicalized = 1;
save = ops[i]; save = ops[i];
do do
ops[j + 1] = ops[j]; ops[j + 1] = ops[j];
while (j-- && simplify_plus_minus_op_data_cmp (&ops[j], &save) > 0); while (j-- && simplify_plus_minus_op_data_cmp (ops[j].op, save.op));
ops[j + 1] = save; ops[j + 1] = save;
} }
......
...@@ -125,7 +125,7 @@ gen_addr_rtx (rtx symbol, rtx base, rtx index, rtx step, rtx offset, ...@@ -125,7 +125,7 @@ gen_addr_rtx (rtx symbol, rtx base, rtx index, rtx step, rtx offset,
if (base) if (base)
{ {
if (*addr) if (*addr)
*addr = gen_rtx_PLUS (Pmode, *addr, base); *addr = simplify_gen_binary (PLUS, Pmode, base, *addr);
else else
*addr = base; *addr = base;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment