Commit dea148c4 by Kaz Kojima

sh.c (shiftcosts): Return MAX_COST when the first operand is CONST_INT.

	* config/sh/sh.c (shiftcosts): Return MAX_COST when the first
	operand is CONST_INT.  Take COSTS_N_INSNS into account.
	(sh_rtx_costs): Don't apply COSTS_N_INSNS to the return value
	of shiftcosts.

From-SVN: r184865
parent d289d284
2012-03-03 Kaz Kojima <kkojima@gcc.gnu.org>
* config/sh/sh.c (shiftcosts): Return MAX_COST when the first
operand is CONST_INT. Take COSTS_N_INSNS into account.
(sh_rtx_costs): Don't apply COSTS_N_INSNS to the return value
of shiftcosts.
2012-03-02 Richard Henderson <rth@redhat.com> 2012-03-02 Richard Henderson <rth@redhat.com>
* optabs.c (expand_atomic_test_and_set): Honor * optabs.c (expand_atomic_test_and_set): Honor
......
...@@ -2828,22 +2828,26 @@ shiftcosts (rtx x) ...@@ -2828,22 +2828,26 @@ shiftcosts (rtx x)
{ {
int value; int value;
/* There is no pattern for constant first operand. */
if (CONST_INT_P (XEXP (x, 0)))
return MAX_COST;
if (TARGET_SHMEDIA) if (TARGET_SHMEDIA)
return 1; return COSTS_N_INSNS (1);
if (GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD) if (GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
{ {
if (GET_MODE (x) == DImode if (GET_MODE (x) == DImode
&& CONST_INT_P (XEXP (x, 1)) && CONST_INT_P (XEXP (x, 1))
&& INTVAL (XEXP (x, 1)) == 1) && INTVAL (XEXP (x, 1)) == 1)
return 2; return COSTS_N_INSNS (2);
/* Everything else is invalid, because there is no pattern for it. */ /* Everything else is invalid, because there is no pattern for it. */
return MAX_COST; return MAX_COST;
} }
/* If shift by a non constant, then this will be expensive. */ /* If shift by a non constant, then this will be expensive. */
if (!CONST_INT_P (XEXP (x, 1))) if (!CONST_INT_P (XEXP (x, 1)))
return SH_DYNAMIC_SHIFT_COST; return COSTS_N_INSNS (SH_DYNAMIC_SHIFT_COST);
/* Otherwise, return the true cost in instructions. Cope with out of range /* Otherwise, return the true cost in instructions. Cope with out of range
shift counts more or less arbitrarily. */ shift counts more or less arbitrarily. */
...@@ -2855,10 +2859,10 @@ shiftcosts (rtx x) ...@@ -2855,10 +2859,10 @@ shiftcosts (rtx x)
/* If SH3, then we put the constant in a reg and use shad. */ /* If SH3, then we put the constant in a reg and use shad. */
if (cost > 1 + SH_DYNAMIC_SHIFT_COST) if (cost > 1 + SH_DYNAMIC_SHIFT_COST)
cost = 1 + SH_DYNAMIC_SHIFT_COST; cost = 1 + SH_DYNAMIC_SHIFT_COST;
return cost; return COSTS_N_INSNS (cost);
} }
else else
return shift_insns[value]; return COSTS_N_INSNS (shift_insns[value]);
} }
/* Return the cost of an AND/XOR/IOR operation. */ /* Return the cost of an AND/XOR/IOR operation. */
...@@ -3091,7 +3095,7 @@ sh_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, ...@@ -3091,7 +3095,7 @@ sh_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED,
case ASHIFT: case ASHIFT:
case ASHIFTRT: case ASHIFTRT:
case LSHIFTRT: case LSHIFTRT:
*total = COSTS_N_INSNS (shiftcosts (x)); *total = shiftcosts (x);
return true; return true;
case DIV: case DIV:
......
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