Commit a708f4b6 by Richard Sandiford Committed by Richard Sandiford

Make more use of simplify_gen_binary

This patch replaces various places that previously used:

  if (GET_CODE (y) == CONST_INT)
    ... plus_constant (..., x, [-]INTVAL (y)) ...
  else
    ... gen_rtx_PLUS/MINUS (..., x, y) ...

with single calls to simplify_gen_binary.  This allows
them to handle polynomial integers as well as constants.

2017-09-21  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* calls.c (compute_argument_addresses): Use simplify_gen_binary
	rather than choosing between plus_constant and gen_rtx_<CODE>.
	* expr.c (emit_push_insn): Likewise.
	(expand_expr_real_2): Likewise.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r253059
parent 6b1237e3
...@@ -2,6 +2,15 @@ ...@@ -2,6 +2,15 @@
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>
* calls.c (compute_argument_addresses): Use simplify_gen_binary
rather than choosing between plus_constant and gen_rtx_<CODE>.
* expr.c (emit_push_insn): Likewise.
(expand_expr_real_2): Likewise.
2017-09-21 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* loop-unroll.c (split_iv): Call copy_rtx on the step. * loop-unroll.c (split_iv): Call copy_rtx on the step.
2017-09-21 Richard Sandiford <richard.sandiford@linaro.org> 2017-09-21 Richard Sandiford <richard.sandiford@linaro.org>
...@@ -2197,11 +2197,7 @@ compute_argument_addresses (struct arg_data *args, rtx argblock, int num_actuals ...@@ -2197,11 +2197,7 @@ compute_argument_addresses (struct arg_data *args, rtx argblock, int num_actuals
if (POINTER_BOUNDS_P (args[i].tree_value)) if (POINTER_BOUNDS_P (args[i].tree_value))
continue; continue;
if (CONST_INT_P (offset)) addr = simplify_gen_binary (PLUS, Pmode, arg_reg, offset);
addr = plus_constant (Pmode, arg_reg, INTVAL (offset));
else
addr = gen_rtx_PLUS (Pmode, arg_reg, offset);
addr = plus_constant (Pmode, addr, arg_offset); addr = plus_constant (Pmode, addr, arg_offset);
if (args[i].partial != 0) if (args[i].partial != 0)
...@@ -2231,11 +2227,7 @@ compute_argument_addresses (struct arg_data *args, rtx argblock, int num_actuals ...@@ -2231,11 +2227,7 @@ compute_argument_addresses (struct arg_data *args, rtx argblock, int num_actuals
} }
set_mem_align (args[i].stack, align); set_mem_align (args[i].stack, align);
if (CONST_INT_P (slot_offset)) addr = simplify_gen_binary (PLUS, Pmode, arg_reg, slot_offset);
addr = plus_constant (Pmode, arg_reg, INTVAL (slot_offset));
else
addr = gen_rtx_PLUS (Pmode, arg_reg, slot_offset);
addr = plus_constant (Pmode, addr, arg_offset); addr = plus_constant (Pmode, addr, arg_offset);
if (args[i].partial != 0) if (args[i].partial != 0)
......
...@@ -4541,15 +4541,8 @@ emit_push_insn (rtx x, machine_mode mode, tree type, rtx size, ...@@ -4541,15 +4541,8 @@ emit_push_insn (rtx x, machine_mode mode, tree type, rtx size,
else else
#endif #endif
{ {
if (CONST_INT_P (args_so_far)) addr = simplify_gen_binary (PLUS, Pmode, args_addr, args_so_far);
addr dest = gen_rtx_MEM (mode, memory_address (mode, addr));
= memory_address (mode,
plus_constant (Pmode, args_addr,
INTVAL (args_so_far)));
else
addr = memory_address (mode, gen_rtx_PLUS (Pmode, args_addr,
args_so_far));
dest = gen_rtx_MEM (mode, addr);
/* We do *not* set_mem_attributes here, because incoming arguments /* We do *not* set_mem_attributes here, because incoming arguments
may overlap with sibling call outgoing arguments and we cannot may overlap with sibling call outgoing arguments and we cannot
...@@ -8565,14 +8558,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, ...@@ -8565,14 +8558,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
{ {
expand_operands (treeop0, treeop1, expand_operands (treeop0, treeop1,
NULL_RTX, &op0, &op1, modifier); NULL_RTX, &op0, &op1, modifier);
return simplify_gen_binary (MINUS, mode, op0, op1);
/* If the last operand is a CONST_INT, use plus_constant of
the negated constant. Else make the MINUS. */
if (CONST_INT_P (op1))
return REDUCE_BIT_FIELD (plus_constant (mode, op0,
-INTVAL (op1)));
else
return REDUCE_BIT_FIELD (gen_rtx_MINUS (mode, op0, op1));
} }
/* No sense saving up arithmetic to be done /* No sense saving up arithmetic to be done
......
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