Define PREFETCH_MOD_TO_UNROLL_FACTOR_RATIO heuristic.
authorChangpeng Fang <changpeng.fang@amd.com>
Mon, 17 May 2010 22:33:53 +0000 (22:33 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Mon, 17 May 2010 22:33:53 +0000 (22:33 +0000)
2010-05-17  Changpeng Fang  <changpeng.fang@amd.com>

* tree-ssa-loop-prefetch.c (PREFETCH_MOD_TO_UNROLL_FACTOR_RATIO): New.
(schedule_prefetches): Do not generate a prefetch if the unroll factor
is far from what is required by the prefetch.

From-SVN: r159514

gcc/ChangeLog
gcc/tree-ssa-loop-prefetch.c

index f14820169850090c3104a1836da53f2e5a273b67..a0ba83aa970d5ae0fb6165273f06a201690ac378 100644 (file)
@@ -1,3 +1,9 @@
+2010-05-17  Changpeng Fang  <changpeng.fang@amd.com>
+
+       * tree-ssa-loop-prefetch.c (PREFETCH_MOD_TO_UNROLL_FACTOR_RATIO): New.
+       (schedule_prefetches): Do not generate a prefetch if the unroll factor
+       is far from what is required by the prefetch.
+
 2010-05-17  Jan Hubicka  <jh@suse.cz>
 
        * ipa-cp.c (ipcp_update_callgraph): Use ipa_is_param_used.
index f828ed3f1a1d06c84a2d2855bdd8b36ceb1857a5..4889604b6ab5740622b3b0c9df47aa5d40ca1384 100644 (file)
@@ -225,6 +225,17 @@ struct mem_ref_group
 
 #define PREFETCH_ALL           (~(unsigned HOST_WIDE_INT) 0)
 
+/* Do not generate a prefetch if the unroll factor is significantly less
+   than what is required by the prefetch.  This is to avoid redundant
+   prefetches.  For example, if prefetch_mod is 16 and unroll_factor is
+   1, this means prefetching requires unrolling the loop 16 times, but
+   the loop is not going to be unrolled.  In this case (ratio = 16),
+   prefetching is not likely to be beneficial.  */
+
+#ifndef PREFETCH_MOD_TO_UNROLL_FACTOR_RATIO
+#define PREFETCH_MOD_TO_UNROLL_FACTOR_RATIO 8
+#endif
+
 /* The memory reference.  */
 
 struct mem_ref
@@ -921,6 +932,12 @@ schedule_prefetches (struct mem_ref_group *groups, unsigned unroll_factor,
        if (!should_issue_prefetch_p (ref))
          continue;
 
+        /* The loop is far from being sufficiently unrolled for this
+           prefetch.  Do not generate prefetch to avoid many redudant
+           prefetches.  */
+        if (ref->prefetch_mod / unroll_factor > PREFETCH_MOD_TO_UNROLL_FACTOR_RATIO)
+          continue;
+
        /* If we need to prefetch the reference each PREFETCH_MOD iterations,
           and we unroll the loop UNROLL_FACTOR times, we need to insert
           ceil (UNROLL_FACTOR / PREFETCH_MOD) instructions in each