Patchwork Fix PR 44576: avoid huge compile times in compute_miss_rate

login
register
mail settings
Submitter Christian Borntraeger
Date June 28, 2010, 7:42 a.m.
Message ID <4C28527C.4070406@de.ibm.com>
Download mbox | patch
Permalink /patch/57117/
State New
Headers show

Comments

Christian Borntraeger - June 28, 2010, 7:42 a.m.
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?
Richard Guenther - June 28, 2010, 10:04 a.m.
On Mon, Jun 28, 2010 at 9:42 AM, Christian Borntraeger
<borntraeger@de.ibm.com> wrote:
> 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?

No.  Please instead do some profiling work and take a stab at
improving the algorithm instead.  There are several places which
are quadratic in compile-time in gcc, so I don't see why prefetching
should be particular bad.

Richard.

Patch

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);