From patchwork Mon Jun 28 07:42:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix PR 44576: avoid huge compile times in compute_miss_rate Date: Sun, 27 Jun 2010 21:42:52 -0000 From: Christian Borntraeger X-Patchwork-Id: 57117 Message-Id: <4C28527C.4070406@de.ibm.com> To: Gcc Patch List Cc: richard.guenther@gmail.com, uweigand@de.ibm.com, Changpeng.Fang@amd.com 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 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 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);