aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/rs6000
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2004-08-20 19:07:10 +0000
committerDale Johannesen <dalej@gcc.gnu.org>2004-08-20 19:07:10 +0000
commit627b6fe2df0c59eb723dae340fa8d746aa7ce703 (patch)
tree0920c57a4ea94aaafb2b2c13f4c28274d6ab18ba /gcc/config/rs6000
parentb7d9c3aefea68d107ba21cf03aae88153dacf18f (diff)
downloadgcc-627b6fe2df0c59eb723dae340fa8d746aa7ce703.zip
gcc-627b6fe2df0c59eb723dae340fa8d746aa7ce703.tar.gz
gcc-627b6fe2df0c59eb723dae340fa8d746aa7ce703.tar.bz2
rs6000.c (rs6000_rtx_costs): Improve DIV/MOD.
2004-08-20 Dale Johannesen <dalej@apple.com> * config/rs6000/rs6000.c (rs6000_rtx_costs): Improve DIV/MOD. From-SVN: r86334
Diffstat (limited to 'gcc/config/rs6000')
-rw-r--r--gcc/config/rs6000/rs6000.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index f9792ec..3d78844 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -17064,6 +17064,9 @@ rs6000_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED,
|| ((outer_code == IOR || outer_code == XOR)
&& (CONST_OK_FOR_LETTER_P (INTVAL (x), 'K')
|| CONST_OK_FOR_LETTER_P (INTVAL (x), 'L')))
+ || ((outer_code == DIV || outer_code == UDIV
+ || outer_code == MOD || outer_code == UMOD)
+ && exact_log2 (INTVAL (x)) >= 0)
|| (outer_code == AND
&& (CONST_OK_FOR_LETTER_P (INTVAL (x), 'K')
|| CONST_OK_FOR_LETTER_P (INTVAL (x), 'L')
@@ -17232,20 +17235,30 @@ rs6000_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED,
: rs6000_cost->sdiv;
return false;
}
- if (GET_CODE (XEXP (x, 1)) == CONST_INT
- && exact_log2 (INTVAL (XEXP (x, 1))) >= 0)
- {
- *total = COSTS_N_INSNS (2);
- return false;
- }
/* FALLTHRU */
case UDIV:
case UMOD:
- if (GET_MODE (XEXP (x, 1)) == DImode)
- *total = rs6000_cost->divdi;
- else
- *total = rs6000_cost->divsi;
+ if (GET_CODE (XEXP (x, 1)) == CONST_INT
+ && exact_log2 (INTVAL (XEXP (x, 1))) >= 0)
+ {
+ if (code == DIV || code == MOD)
+ /* Shift, addze */
+ *total = COSTS_N_INSNS (2);
+ else
+ /* Shift */
+ *total = COSTS_N_INSNS (1);
+ }
+ else
+ {
+ if (GET_MODE (XEXP (x, 1)) == DImode)
+ *total = rs6000_cost->divdi;
+ else
+ *total = rs6000_cost->divsi;
+ }
+ /* Add in shift and subtract for MOD. */
+ if (code == MOD || code == UMOD)
+ *total += COSTS_N_INSNS (2);
return false;
case FFS: