--- gcc/ddg.c (/gcc-local/trunk) (revision 30596) +++ gcc/ddg.c (/gcc-local/export-ddg) (revision 30596) @@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. #include "expr.h" #include "bitmap.h" #include "ddg.h" +#include "tree-data-ref-export.h" /* A flag indicating that a ddg edge belongs to an SCC or not. */ enum edge_flag {NOT_IN_SCC = 0, IN_SCC}; @@ -333,12 +334,49 @@ build_inter_loop_deps (ddg_ptr g) } } +static int +walk_mems_2 (rtx *x, rtx mem) +{ + if (MEM_P (*x)) + { + if (may_alias_mems_by_ddr (mem, *x, 2)) + /* Indicate that dependence was determined and stop traversal. */ + return 1; + return -1; + } + return 0; +} + +static int +walk_mems_1 (rtx *x, rtx *pat) +{ + if (MEM_P (*x)) + { + /* Visit all MEMs in *PAT and check indepedence. */ + if (for_each_rtx (pat, (rtx_function) walk_mems_2, *x)) + /* Indicate that dependence was determined and stop traversal. */ + return 1; + return -1; + } + return 0; +} + +static bool +independent_by_exported_info (rtx insn1, rtx insn2) +{ + /* For each pair of MEMs in INSN1 and INSN2 check their independence. */ + return ! for_each_rtx (&PATTERN (insn1), (rtx_function) walk_mems_1, + &PATTERN (insn2)); +} /* Given two nodes, analyze their RTL insns and add inter-loop mem deps to ddg G. */ static void add_inter_loop_mem_dep (ddg_ptr g, ddg_node_ptr from, ddg_node_ptr to) { + if (independent_by_exported_info (from->insn, to->insn)) + /* Do not create edge if memory references are known to be independent. */ + return; if (mem_write_insn_p (from->insn)) { if (mem_read_insn_p (to->insn)) --- gcc/modulo-sched.c (/gcc-local/trunk) (revision 30596) +++ gcc/modulo-sched.c (/gcc-local/export-ddg) (revision 30596) @@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. #include "ddg.h" #include "timevar.h" #include "tree-pass.h" +#include "tree-data-ref-export.h" #ifdef INSN_SCHEDULING @@ -2331,6 +2354,7 @@ rest_of_handle_sms (void) basic_block bb; /* Collect loop information to be used in SMS. */ + ddg_export_disambiguate_only_intra_loop_deps (true); cfg_layout_initialize (0); sms_schedule (); @@ -2343,6 +2367,7 @@ rest_of_handle_sms (void) bb->aux = bb->next_bb; free_dominance_info (CDI_DOMINATORS); cfg_layout_finalize (); + ddg_export_disambiguate_only_intra_loop_deps (false); #endif /* INSN_SCHEDULING */ return 0; }