Commit e098c169 by Hans-Peter Nilsson Committed by Hans-Peter Nilsson

re PR rtl-optimization/53176 (gcc.dg/lower-subreg-1.c FAILs)

	PR rtl-optimization/53176
	* rtlanal.c (rtx_cost): Adjust default cost for X with a
	UNITS_PER_WORD factor for all X according to the size of
	its mode, not just for SUBREGs with untieable modes.
	Handle SET.  Use factor * factor for MULT, DIV, UDIV,
	MOD, UMOD.

From-SVN: r189441
parent 8c15b4b0
2012-07-12 Hans-Peter Nilsson <hp@axis.com>
PR rtl-optimization/53176
* rtlanal.c (rtx_cost): Adjust default cost for X with a
UNITS_PER_WORD factor for all X according to the size of
its mode, not just for SUBREGs with untieable modes.
Handle SET. Use factor * factor for MULT, DIV, UDIV,
MOD, UMOD.
2012-07-12 Uros Bizjak <ubizjak@gmail.com> 2012-07-12 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (QImode and HImode cmove splitters): Merge * config/i386/i386.md (QImode and HImode cmove splitters): Merge
......
...@@ -3755,10 +3755,17 @@ rtx_cost (rtx x, enum rtx_code outer_code, int opno, bool speed) ...@@ -3755,10 +3755,17 @@ rtx_cost (rtx x, enum rtx_code outer_code, int opno, bool speed)
enum rtx_code code; enum rtx_code code;
const char *fmt; const char *fmt;
int total; int total;
int factor;
if (x == 0) if (x == 0)
return 0; return 0;
/* A size N times larger than UNITS_PER_WORD likely needs N times as
many insns, taking N times as long. */
factor = GET_MODE_SIZE (GET_MODE (x)) / UNITS_PER_WORD;
if (factor == 0)
factor = 1;
/* Compute the default costs of certain things. /* Compute the default costs of certain things.
Note that targetm.rtx_costs can override the defaults. */ Note that targetm.rtx_costs can override the defaults. */
...@@ -3766,20 +3773,31 @@ rtx_cost (rtx x, enum rtx_code outer_code, int opno, bool speed) ...@@ -3766,20 +3773,31 @@ rtx_cost (rtx x, enum rtx_code outer_code, int opno, bool speed)
switch (code) switch (code)
{ {
case MULT: case MULT:
total = COSTS_N_INSNS (5); /* Multiplication has time-complexity O(N*N), where N is the
number of units (translated from digits) when using
schoolbook long multiplication. */
total = factor * factor * COSTS_N_INSNS (5);
break; break;
case DIV: case DIV:
case UDIV: case UDIV:
case MOD: case MOD:
case UMOD: case UMOD:
total = COSTS_N_INSNS (7); /* Similarly, complexity for schoolbook long division. */
total = factor * factor * COSTS_N_INSNS (7);
break; break;
case USE: case USE:
/* Used in combine.c as a marker. */ /* Used in combine.c as a marker. */
total = 0; total = 0;
break; break;
case SET:
/* A SET doesn't have a mode, so let's look at the SET_DEST to get
the mode for the factor. */
factor = GET_MODE_SIZE (GET_MODE (SET_DEST (x))) / UNITS_PER_WORD;
if (factor == 0)
factor = 1;
/* Pass through. */
default: default:
total = COSTS_N_INSNS (1); total = factor * COSTS_N_INSNS (1);
} }
switch (code) switch (code)
...@@ -3792,8 +3810,7 @@ rtx_cost (rtx x, enum rtx_code outer_code, int opno, bool speed) ...@@ -3792,8 +3810,7 @@ rtx_cost (rtx x, enum rtx_code outer_code, int opno, bool speed)
/* If we can't tie these modes, make this expensive. The larger /* If we can't tie these modes, make this expensive. The larger
the mode, the more expensive it is. */ the mode, the more expensive it is. */
if (! MODES_TIEABLE_P (GET_MODE (x), GET_MODE (SUBREG_REG (x)))) if (! MODES_TIEABLE_P (GET_MODE (x), GET_MODE (SUBREG_REG (x))))
return COSTS_N_INSNS (2 return COSTS_N_INSNS (2 + factor);
+ GET_MODE_SIZE (GET_MODE (x)) / UNITS_PER_WORD);
break; break;
default: default:
......
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