This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix PR 44576: avoid huge compile times in compute_miss_rate
- From: Christian Borntraeger <borntraeger at de dot ibm dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: richard dot guenther at gmail dot com, uweigand at de dot ibm dot com, Changpeng dot Fang at amd dot com
- Date: Mon, 28 Jun 2010 09:42:52 +0200
- Subject: Fix PR 44576: avoid huge compile times in compute_miss_rate
This patches fixes the huge compile times in compute_miss_rate in
the prefetch pass.
This patch does not fix the other code size or compile time problems
that are tracked in PR44688.
2010-06-28 Christian Borntraeger <borntraeger@de.ibm.com>
PR middle-end/44576
* tree-ssa-loop-prefetch.c (PREFETCH_MAX_REFS_PER_LOOP): New.
* (loop_prefetch_arrays): Do not prefetch if the loop contains
too many memory references.
OK to apply?
2010-06-28 Christian Borntraeger <borntraeger@de.ibm.com>
PR middle-end/44576
* tree-ssa-loop-prefetch.c (PREFETCH_MAX_REFS_PER_LOOP): New.
* (loop_prefetch_arrays): Do not prefetch if the loop contains
too many memory references.
Index: gcc/tree-ssa-loop-prefetch.c
===================================================================
*** gcc/tree-ssa-loop-prefetch.c.orig
--- gcc/tree-ssa-loop-prefetch.c
*************** struct mem_ref_group
*** 237,242 ****
--- 237,253 ----
#define PREFETCH_MOD_TO_UNROLL_FACTOR_RATIO 4
#endif
+ /* Some of the prefetch calculations have >=quadratic complexity. We want
+ to avoid huge compile times and, therefore, want to limit the amount of
+ memory references per loop where we consider prefetching. In addition,
+ if a loop has a huge amount of memory references it is very likely that
+ the prefetch is not necessary due to reuse effects or even worse the
+ prefetch might compete with other cache lines that are used within the
+ loop. */
+ #ifndef PREFETCH_MAX_REFS_PER_LOOP
+ #define PREFETCH_MAX_REFS_PER_LOOP 200
+ #endif
+
/* The memory reference. */
struct mem_ref
*************** loop_prefetch_arrays (struct loop *loop)
*** 1734,1739 ****
--- 1745,1756 ----
/* Step 1: gather the memory references. */
refs = gather_memory_references (loop, &no_other_refs, &mem_ref_count);
+ if (mem_ref_count > PREFETCH_MAX_REFS_PER_LOOP) {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "Ignoring loop: too many references (%d)\n",
+ mem_ref_count);
+ goto fail;
+ }
/* Step 2: estimate the reuse effects. */
prune_by_reuse (refs);