diff options
author | Venkataramanan Kumar <venkataramanan.kumar@amd.com> | 2012-10-09 15:48:45 +0000 |
---|---|---|
committer | Venkataramanan Kumar <vekumar@gcc.gnu.org> | 2012-10-09 15:48:45 +0000 |
commit | a5497b12385d3a21e336f068d5477574a78da94a (patch) | |
tree | 57e1fe2200c0ab02d5afebc842ab80d29b4aa98e /gcc/tree-ssa-loop-prefetch.c | |
parent | eeeef8f4f93036d2ea25325a3b681c338e7e143f (diff) | |
download | gcc-a5497b12385d3a21e336f068d5477574a78da94a.tar.gz |
Fix for PR53397 by making prefecthing less agressive
From-SVN: r192261
Diffstat (limited to 'gcc/tree-ssa-loop-prefetch.c')
-rw-r--r-- | gcc/tree-ssa-loop-prefetch.c | 77 |
1 files changed, 60 insertions, 17 deletions
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c index fe4df9a06f7..dcc65e19abb 100644 --- a/gcc/tree-ssa-loop-prefetch.c +++ b/gcc/tree-ssa-loop-prefetch.c @@ -278,29 +278,37 @@ struct mem_ref nontemporal one. */ }; -/* Dumps information about reference REF to FILE. */ - +/* Dumps information about memory reference */ static void -dump_mem_ref (FILE *file, struct mem_ref *ref) +dump_mem_details (FILE *file, tree base, tree step, + HOST_WIDE_INT delta, bool write_p) { - fprintf (file, "Reference %p:\n", (void *) ref); - - fprintf (file, " group %p (base ", (void *) ref->group); - print_generic_expr (file, ref->group->base, TDF_SLIM); + fprintf (file, "(base "); + print_generic_expr (file, base, TDF_SLIM); fprintf (file, ", step "); - if (cst_and_fits_in_hwi (ref->group->step)) - fprintf (file, HOST_WIDE_INT_PRINT_DEC, int_cst_value (ref->group->step)); + if (cst_and_fits_in_hwi (step)) + fprintf (file, HOST_WIDE_INT_PRINT_DEC, int_cst_value (step)); else - print_generic_expr (file, ref->group->step, TDF_TREE); + print_generic_expr (file, step, TDF_TREE); fprintf (file, ")\n"); - fprintf (file, " delta "); - fprintf (file, HOST_WIDE_INT_PRINT_DEC, ref->delta); + fprintf (file, HOST_WIDE_INT_PRINT_DEC, delta); fprintf (file, "\n"); + fprintf (file, " %s\n", write_p ? "write" : "read"); + fprintf (file, "\n"); +} - fprintf (file, " %s\n", ref->write_p ? "write" : "read"); +/* Dumps information about reference REF to FILE. */ - fprintf (file, "\n"); +static void +dump_mem_ref (FILE *file, struct mem_ref *ref) +{ + fprintf (file, "Reference %p:\n", (void *) ref); + + fprintf (file, " group %p ", (void *) ref->group); + + dump_mem_details (file, ref->group->base, ref->group->step, ref->delta, + ref->write_p); } /* Finds a group with BASE and STEP in GROUPS, or creates one if it does not @@ -537,9 +545,44 @@ gather_memory_references_ref (struct loop *loop, struct mem_ref_group **refs, if (may_be_nonaddressable_p (base)) return false; - /* Limit non-constant step prefetching only to the innermost loops. */ - if (!cst_and_fits_in_hwi (step) && loop->inner != NULL) - return false; + /* Limit non-constant step prefetching only to the innermost loops and + only when the step is loop invariant in the entire loop nest. */ + if (!cst_and_fits_in_hwi (step)) + { + if (loop->inner != NULL) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "Memory expression %p\n",(void *) ref ); + print_generic_expr (dump_file, ref, TDF_TREE); + fprintf (dump_file,":"); + dump_mem_details( dump_file, base, step, delta, write_p); + fprintf (dump_file, + "Ignoring %p, non-constant step prefetching is " + "limited to inner most loops \n", + (void *) ref); + } + return false; + } + else + { + if (!expr_invariant_in_loop_p (loop_outermost (loop), step)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "Memory expression %p\n",(void *) ref ); + print_generic_expr (dump_file, ref, TDF_TREE); + fprintf (dump_file,":"); + dump_mem_details(dump_file, base, step, delta, write_p); + fprintf (dump_file, + "Not prefetching, ignoring %p due to " + "loop variant step\n", + (void *) ref); + } + return false; + } + } + } /* Now we know that REF = &BASE + STEP * iter + DELTA, where DELTA and STEP are integer constants. */ |