aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChangpeng Fang <changpeng.fang@amd.com>2010-06-25 18:25:00 +0000
committerSebastian Pop <spop@gcc.gnu.org>2010-06-25 18:25:00 +0000
commit1fbb509aacf96e6d4d344ea41fadca74cad7ee99 (patch)
tree30ce2860b1afc7397546e4427a13dcdcc2f04f2b
parentc14420e17389ea8cae7a847c7d1733c77b227399 (diff)
downloadgcc-1fbb509aacf96e6d4d344ea41fadca74cad7ee99.zip
gcc-1fbb509aacf96e6d4d344ea41fadca74cad7ee99.tar.gz
gcc-1fbb509aacf96e6d4d344ea41fadca74cad7ee99.tar.bz2
Enable prefetching at -O3 for AMD cpus.
2010-06-25 Changpeng Fang <changpeng.fang@amd.com> * common.opt (fprefetch-loop-arrays): Re-define -fprefetch-loop-arrays as a tri-state option with the initial value of -1. * tree-ssa-loop.c (gate_tree_ssa_loop_prefetch): Invoke prefetch pass only when flag_prefetch_loop_arrays > 0. * toplev.c (process_options): Note that, with tri-states, flag_prefetch_loop_arrays>0 means prefetching is enabled. * config/i386/i386.c (override_options): Enable prefetching at -O3 for a set of CPUs that sw prefetching is helpful. (software_prefetching_beneficial_p): New. Return TRUE if software prefetching is beneficial for the given CPU. From-SVN: r161391
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/common.opt2
-rw-r--r--gcc/config/i386/i386.c27
-rw-r--r--gcc/toplev.c6
-rw-r--r--gcc/tree-ssa-loop.c2
5 files changed, 46 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a1bc891..23818d9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2010-06-25 Changpeng Fang <changpeng.fang@amd.com>
+
+ * common.opt (fprefetch-loop-arrays): Re-define
+ -fprefetch-loop-arrays as a tri-state option with the initial
+ value of -1.
+ * tree-ssa-loop.c (gate_tree_ssa_loop_prefetch): Invoke prefetch
+ pass only when flag_prefetch_loop_arrays > 0.
+ * toplev.c (process_options): Note that, with tri-states,
+ flag_prefetch_loop_arrays>0 means prefetching is enabled.
+ * config/i386/i386.c (override_options): Enable prefetching at -O3
+ for a set of CPUs that sw prefetching is helpful.
+ (software_prefetching_beneficial_p): New. Return TRUE if software
+ prefetching is beneficial for the given CPU.
+
2010-06-25 H.J. Lu <hongjiu.lu@intel.com>
PR rtl-optimization/44326
diff --git a/gcc/common.opt b/gcc/common.opt
index 82a4e75..6ca787a 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -949,7 +949,7 @@ Common Report Var(flag_predictive_commoning) Optimization
Run predictive commoning optimization.
fprefetch-loop-arrays
-Common Report Var(flag_prefetch_loop_arrays) Optimization
+Common Report Var(flag_prefetch_loop_arrays) Init(-1) Optimization
Generate prefetch instructions, if available, for arrays in loops
fprofile
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 8957fe2..e0d8dc4 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2691,6 +2691,26 @@ ix86_target_string (int isa, int flags, const char *arch, const char *tune,
return ret;
}
+/* Return TRUE if software prefetching is beneficial for the
+ given CPU. */
+
+static bool
+software_prefetching_beneficial_p (void)
+{
+ switch (ix86_tune)
+ {
+ case PROCESSOR_GEODE:
+ case PROCESSOR_K6:
+ case PROCESSOR_ATHLON:
+ case PROCESSOR_K8:
+ case PROCESSOR_AMDFAM10:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
/* Function that is callable from the debugger to print the current
options. */
void
@@ -3535,6 +3555,13 @@ override_options (bool main_args_p)
if (!PARAM_SET_P (PARAM_L2_CACHE_SIZE))
set_param_value ("l2-cache-size", ix86_cost->l2_cache_size);
+ /* Enable sw prefetching at -O3 for CPUS that prefetching is helpful. */
+ if (flag_prefetch_loop_arrays < 0
+ && HAVE_prefetch
+ && optimize >= 3
+ && software_prefetching_beneficial_p ())
+ flag_prefetch_loop_arrays = 1;
+
/* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
can be optimized to ap = __builtin_next_arg (0). */
if (!TARGET_64BIT)
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 220c1f7..c22cb98 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2013,13 +2013,13 @@ process_options (void)
}
#ifndef HAVE_prefetch
- if (flag_prefetch_loop_arrays)
+ if (flag_prefetch_loop_arrays > 0)
{
warning (0, "-fprefetch-loop-arrays not supported for this target");
flag_prefetch_loop_arrays = 0;
}
#else
- if (flag_prefetch_loop_arrays && !HAVE_prefetch)
+ if (flag_prefetch_loop_arrays > 0 && !HAVE_prefetch)
{
warning (0, "-fprefetch-loop-arrays not supported for this target (try -march switches)");
flag_prefetch_loop_arrays = 0;
@@ -2028,7 +2028,7 @@ process_options (void)
/* This combination of options isn't handled for i386 targets and doesn't
make much sense anyway, so don't allow it. */
- if (flag_prefetch_loop_arrays && optimize_size)
+ if (flag_prefetch_loop_arrays > 0 && optimize_size)
{
warning (0, "-fprefetch-loop-arrays is not supported with -Os");
flag_prefetch_loop_arrays = 0;
diff --git a/gcc/tree-ssa-loop.c b/gcc/tree-ssa-loop.c
index 344cfa8..c9c5bbd 100644
--- a/gcc/tree-ssa-loop.c
+++ b/gcc/tree-ssa-loop.c
@@ -600,7 +600,7 @@ tree_ssa_loop_prefetch (void)
static bool
gate_tree_ssa_loop_prefetch (void)
{
- return flag_prefetch_loop_arrays != 0;
+ return flag_prefetch_loop_arrays > 0;
}
struct gimple_opt_pass pass_loop_prefetch =