Commit f138ea5c by Tamar Christina Committed by Tamar Christina

re PR middle-end/79665 (gcc's signed (x*x)/200 is slower than clang's)

2017-04-26  Tamar Christina  <tamar.christina@arm.com>

	PR middle-end/79665
	* expr.c (expand_expr_real_2): Move TRUNC_MOD_EXPR, FLOOR_MOD_EXPR,
	CEIL_MOD_EXPR, ROUND_MOD_EXPR cases.

From-SVN: r247307
parent b63d61f7
2017-04-27 Tamar Christina <tamar.christina@arm.com>
PR middle-end/79665
* expr.c (expand_expr_real_2): Move TRUNC_MOD_EXPR, FLOOR_MOD_EXPR,
CEIL_MOD_EXPR, ROUND_MOD_EXPR cases.
2017-04-27 Jakub Jelinek <jakub@redhat.com> 2017-04-27 Jakub Jelinek <jakub@redhat.com>
PR target/77728 PR target/77728
......
...@@ -8792,11 +8792,17 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, ...@@ -8792,11 +8792,17 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
expand_operands (treeop0, treeop1, subtarget, &op0, &op1, EXPAND_NORMAL); expand_operands (treeop0, treeop1, subtarget, &op0, &op1, EXPAND_NORMAL);
return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1, target, unsignedp)); return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1, target, unsignedp));
case TRUNC_MOD_EXPR:
case FLOOR_MOD_EXPR:
case CEIL_MOD_EXPR:
case ROUND_MOD_EXPR:
case TRUNC_DIV_EXPR: case TRUNC_DIV_EXPR:
case FLOOR_DIV_EXPR: case FLOOR_DIV_EXPR:
case CEIL_DIV_EXPR: case CEIL_DIV_EXPR:
case ROUND_DIV_EXPR: case ROUND_DIV_EXPR:
case EXACT_DIV_EXPR: case EXACT_DIV_EXPR:
{
/* If this is a fixed-point operation, then we cannot use the code /* If this is a fixed-point operation, then we cannot use the code
below because "expand_divmod" doesn't support sat/no-sat fixed-point below because "expand_divmod" doesn't support sat/no-sat fixed-point
divisions. */ divisions. */
...@@ -8810,6 +8816,8 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, ...@@ -8810,6 +8816,8 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
where some terms of the dividend have coeffs divisible by it. */ where some terms of the dividend have coeffs divisible by it. */
expand_operands (treeop0, treeop1, expand_operands (treeop0, treeop1,
subtarget, &op0, &op1, EXPAND_NORMAL); subtarget, &op0, &op1, EXPAND_NORMAL);
bool mod_p = code == TRUNC_MOD_EXPR || code == FLOOR_MOD_EXPR
|| code == CEIL_MOD_EXPR || code == ROUND_MOD_EXPR;
if (SCALAR_INT_MODE_P (mode) if (SCALAR_INT_MODE_P (mode)
&& optimize >= 2 && optimize >= 2
&& get_range_pos_neg (treeop0) == 1 && get_range_pos_neg (treeop0) == 1
...@@ -8821,11 +8829,11 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, ...@@ -8821,11 +8829,11 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
bool speed_p = optimize_insn_for_speed_p (); bool speed_p = optimize_insn_for_speed_p ();
do_pending_stack_adjust (); do_pending_stack_adjust ();
start_sequence (); start_sequence ();
rtx uns_ret = expand_divmod (0, code, mode, op0, op1, target, 1); rtx uns_ret = expand_divmod (mod_p, code, mode, op0, op1, target, 1);
rtx_insn *uns_insns = get_insns (); rtx_insn *uns_insns = get_insns ();
end_sequence (); end_sequence ();
start_sequence (); start_sequence ();
rtx sgn_ret = expand_divmod (0, code, mode, op0, op1, target, 0); rtx sgn_ret = expand_divmod (mod_p, code, mode, op0, op1, target, 0);
rtx_insn *sgn_insns = get_insns (); rtx_insn *sgn_insns = get_insns ();
end_sequence (); end_sequence ();
unsigned uns_cost = seq_cost (uns_insns, speed_p); unsigned uns_cost = seq_cost (uns_insns, speed_p);
...@@ -8838,8 +8846,8 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, ...@@ -8838,8 +8846,8 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
emit_insn (sgn_insns); emit_insn (sgn_insns);
return sgn_ret; return sgn_ret;
} }
return expand_divmod (0, code, mode, op0, op1, target, unsignedp); return expand_divmod (mod_p, code, mode, op0, op1, target, unsignedp);
}
case RDIV_EXPR: case RDIV_EXPR:
goto binop; goto binop;
...@@ -8849,16 +8857,6 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, ...@@ -8849,16 +8857,6 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
gcc_assert (temp); gcc_assert (temp);
return temp; return temp;
case TRUNC_MOD_EXPR:
case FLOOR_MOD_EXPR:
case CEIL_MOD_EXPR:
case ROUND_MOD_EXPR:
if (modifier == EXPAND_STACK_PARM)
target = 0;
expand_operands (treeop0, treeop1,
subtarget, &op0, &op1, EXPAND_NORMAL);
return expand_divmod (1, code, mode, op0, op1, target, unsignedp);
case FIXED_CONVERT_EXPR: case FIXED_CONVERT_EXPR:
op0 = expand_normal (treeop0); op0 = expand_normal (treeop0);
if (target == 0 || modifier == EXPAND_STACK_PARM) if (target == 0 || modifier == EXPAND_STACK_PARM)
......
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