aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Belevantsev <abel@ispras.ru>2009-04-22 15:41:35 +0000
committerAndrey Belevantsev <abel@ispras.ru>2009-04-22 15:41:35 +0000
commit942488f80e45da570bc8c96ac727d95149ee6092 (patch)
tree2cab6892e0329f552e79a4ba8df699609b9c9dfc
parent559168f0d9460b28e314ce8aed0efc9252278c97 (diff)
Apply Jakub's patch for PR39794.
* alias-export.c (walk_mems): New. (remove_exported_ddg_data): New. (init_ddg_info): Allow disambiguation using inter loop deps. * alias-export.h (remove_exported_ddg_data): Export. * loop-unroll.c (apply_opt_in_copies): Use it for removing saved ddg information from insns in unrolled loop. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/alias-export@146591 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/alias-export.c26
-rw-r--r--gcc/alias-export.h1
-rw-r--r--gcc/alias.c10
-rw-r--r--gcc/cse.c4
-rw-r--r--gcc/cselib.c4
-rw-r--r--gcc/dse.c48
-rw-r--r--gcc/gcse.c4
-rw-r--r--gcc/loop-unroll.c7
-rw-r--r--gcc/rtl.h2
10 files changed, 93 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dc0f752000e..315ae446218 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2009-04-22 Andrey Belevantsev <abel@ispras.ru>
+
+ Apply Jakub's patch for PR39794.
+ * alias-export.c (walk_mems): New.
+ (remove_exported_ddg_data): New.
+ (init_ddg_info): Allow disambiguation using inter loop deps.
+ * alias-export.h (remove_exported_ddg_data): Export.
+ * loop-unroll.c (apply_opt_in_copies): Use it for removing saved
+ ddg information from insns in unrolled loop.
+
2009-04-16 Andrey Belevantsev <abel@ispras.ru>
* alias-export.c (uids_to_decls): Remove. Remove all uses.
diff --git a/gcc/alias-export.c b/gcc/alias-export.c
index 46caea5e1e0..25a67572632 100644
--- a/gcc/alias-export.c
+++ b/gcc/alias-export.c
@@ -818,7 +818,7 @@ init_ddg_info (void)
= htab_create (1, (htab_hash) htab_hash_datarefs_pair,
(htab_eq) htab_eq_datarefs_pair,
(htab_del) htab_del_datarefs_pair);
- ddg_info->disambiguate_only_intra_loop_deps = true;
+ ddg_info->disambiguate_only_intra_loop_deps = false;
}
/* Save the data reference DRF in the ddg_info structure. */
@@ -1027,6 +1027,30 @@ print_ddg_export_stats (void)
ddg_info->alias_success_nonzero_dist = 0;
}
+/* A callback for for_each_rtx to remove exported data for mems. */
+static int
+walk_mems (rtx *x, void *data ATTRIBUTE_UNUSED)
+{
+ if (MEM_P (*x) && MEM_ORIG_EXPR (*x) && find_dataref (MEM_ORIG_EXPR (*x)))
+ {
+ tree_dataref td;
+
+ td.ref = MEM_ORIG_EXPR (*x);
+ htab_remove_elt (ddg_info->tree_to_dataref, &td);
+
+ return -1;
+ }
+ return 0;
+}
+
+/* Remove saved dependency data for INSN. Used when INSN is in the loop that
+ was unrolled. */
+void
+remove_exported_ddg_data (rtx insn)
+{
+ for_each_rtx (&PATTERN (insn), walk_mems, NULL);
+}
+
#if 0
void
ddg_export_disambiguate_only_intra_loop_deps (bool b)
diff --git a/gcc/alias-export.h b/gcc/alias-export.h
index 01f4f958534..88bfefddfff 100644
--- a/gcc/alias-export.h
+++ b/gcc/alias-export.h
@@ -33,6 +33,7 @@ extern bool alias_export_test (tree, tree);
extern bool ddg_export_may_alias_p (tree, tree, int);
extern void replace_var_in_datarefs (tree, tree);
+extern void remove_exported_ddg_data (rtx);
#endif /* GCC_ALIAS_EXPORT_H */
diff --git a/gcc/alias.c b/gcc/alias.c
index a3f2eff0dfe..b7c8554981d 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -2338,14 +2338,13 @@ true_dependence (const_rtx mem, enum machine_mode mem_mode, const_rtx x,
Variant of true_dependence which assumes MEM has already been
canonicalized (hence we no longer do that here).
The mem_addr argument has been added, since true_dependence computed
- this value prior to canonicalizing. */
+ this value prior to canonicalizing.
+ If x_addr is non-NULL, it is used in preference of XEXP (x, 0). */
int
canon_true_dependence (const_rtx mem, enum machine_mode mem_mode, rtx mem_addr,
- const_rtx x, bool (*varies) (const_rtx, bool))
+ const_rtx x, rtx x_addr, bool (*varies) (const_rtx, bool))
{
- rtx x_addr;
-
if (MEM_VOLATILE_P (x) && MEM_VOLATILE_P (mem))
return 1;
@@ -2373,7 +2372,8 @@ canon_true_dependence (const_rtx mem, enum machine_mode mem_mode, rtx mem_addr,
if (nonoverlapping_memrefs_p (x, mem))
return 0;
- x_addr = get_addr (XEXP (x, 0));
+ if (! x_addr)
+ x_addr = get_addr (XEXP (x, 0));
if (! base_alias_check (x_addr, mem_addr, GET_MODE (x), mem_mode))
return 0;
diff --git a/gcc/cse.c b/gcc/cse.c
index 04f52fb7d77..c16181e376d 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -1,6 +1,6 @@
/* Common subexpression elimination for GNU compiler.
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GCC.
@@ -1658,7 +1658,7 @@ check_dependence (rtx *x, void *data)
{
struct check_dependence_data *d = (struct check_dependence_data *) data;
if (*x && MEM_P (*x))
- return canon_true_dependence (d->exp, d->mode, d->addr, *x,
+ return canon_true_dependence (d->exp, d->mode, d->addr, *x, NULL_RTX,
cse_rtx_varies_p);
else
return 0;
diff --git a/gcc/cselib.c b/gcc/cselib.c
index 945a4a118de..b040231deb5 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -1,6 +1,6 @@
/* Common subexpression elimination library for GNU compiler.
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008
+ 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GCC.
@@ -1483,7 +1483,7 @@ cselib_invalidate_mem (rtx mem_rtx)
}
if (num_mems < PARAM_VALUE (PARAM_MAX_CSELIB_MEMORY_LOCATIONS)
&& ! canon_true_dependence (mem_rtx, GET_MODE (mem_rtx), mem_addr,
- x, cselib_rtx_varies_p))
+ x, NULL_RTX, cselib_rtx_varies_p))
{
has_mem = true;
num_mems++;
diff --git a/gcc/dse.c b/gcc/dse.c
index a35f07bb113..cb2ad7cb559 100644
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -1286,7 +1286,7 @@ static rtx get_stored_val (store_info_t, enum machine_mode, HOST_WIDE_INT,
static int
record_store (rtx body, bb_info_t bb_info)
{
- rtx mem, rhs, const_rhs;
+ rtx mem, rhs, const_rhs, mem_addr;
HOST_WIDE_INT offset = 0;
HOST_WIDE_INT width = 0;
alias_set_type spill_alias_set;
@@ -1456,6 +1456,20 @@ record_store (rtx body, bb_info_t bb_info)
ptr = active_local_stores;
last = NULL;
redundant_reason = NULL;
+ mem = canon_rtx (mem);
+ if (spill_alias_set || group_id < 0)
+ {
+ cselib_lookup (XEXP (mem, 0), Pmode, 1);
+ mem_addr = cselib_subst_to_values (XEXP (mem, 0));
+ }
+ else
+ {
+ group_info_t group
+ = VEC_index (group_info_t, rtx_group_vec, group_id);
+ mem_addr = group->canon_base_mem;
+ if (offset)
+ mem_addr = gen_rtx_PLUS (GET_MODE (mem_addr), mem_addr, GEN_INT (offset));
+ }
while (ptr)
{
@@ -1547,13 +1561,13 @@ record_store (rtx body, bb_info_t bb_info)
if (canon_true_dependence (s_info->mem,
GET_MODE (s_info->mem),
s_info->mem_addr,
- mem, rtx_varies_p))
+ mem, mem_addr, rtx_varies_p))
{
s_info->rhs = NULL;
s_info->const_rhs = NULL;
}
}
-
+
/* An insn can be deleted if every position of every one of
its s_infos is zero. */
if (any_positions_needed_p (s_info)
@@ -1580,9 +1594,9 @@ record_store (rtx body, bb_info_t bb_info)
/* Finish filling in the store_info. */
store_info->next = insn_info->store_rec;
insn_info->store_rec = store_info;
- store_info->mem = canon_rtx (mem);
+ store_info->mem = mem;
store_info->alias_set = spill_alias_set;
- store_info->mem_addr = get_addr (XEXP (mem, 0));
+ store_info->mem_addr = mem_addr;
store_info->cse_base = base;
if (width > HOST_BITS_PER_WIDE_INT)
{
@@ -2006,7 +2020,7 @@ replace_read (store_info_t store_info, insn_info_t store_insn,
static int
check_mem_read_rtx (rtx *loc, void *data)
{
- rtx mem = *loc;
+ rtx mem = *loc, mem_addr;
bb_info_t bb_info;
insn_info_t insn_info;
HOST_WIDE_INT offset = 0;
@@ -2058,6 +2072,19 @@ check_mem_read_rtx (rtx *loc, void *data)
read_info->end = offset + width;
read_info->next = insn_info->read_rec;
insn_info->read_rec = read_info;
+ if (spill_alias_set || group_id < 0)
+ {
+ cselib_lookup (XEXP (mem, 0), Pmode, 1);
+ mem_addr = cselib_subst_to_values (XEXP (mem, 0));
+ }
+ else
+ {
+ group_info_t group
+ = VEC_index (group_info_t, rtx_group_vec, group_id);
+ mem_addr = group->canon_base_mem;
+ if (offset)
+ mem_addr = gen_rtx_PLUS (GET_MODE (mem_addr), mem_addr, GEN_INT (offset));
+ }
/* We ignore the clobbers in store_info. The is mildly aggressive,
but there really should not be a clobber followed by a read. */
@@ -2128,7 +2155,7 @@ check_mem_read_rtx (rtx *loc, void *data)
= canon_true_dependence (store_info->mem,
GET_MODE (store_info->mem),
store_info->mem_addr,
- mem, rtx_varies_p);
+ mem, mem_addr, rtx_varies_p);
else if (group_id == store_info->group_id)
{
@@ -2139,7 +2166,7 @@ check_mem_read_rtx (rtx *loc, void *data)
= canon_true_dependence (store_info->mem,
GET_MODE (store_info->mem),
store_info->mem_addr,
- mem, rtx_varies_p);
+ mem, mem_addr, rtx_varies_p);
/* If this read is just reading back something that we just
stored, rewrite the read. */
@@ -2224,7 +2251,7 @@ check_mem_read_rtx (rtx *loc, void *data)
remove = canon_true_dependence (store_info->mem,
GET_MODE (store_info->mem),
store_info->mem_addr,
- mem, rtx_varies_p);
+ mem, mem_addr, rtx_varies_p);
if (remove)
{
@@ -3067,7 +3094,8 @@ scan_reads_nospill (insn_info_t insn_info, bitmap gen, bitmap kill)
&& canon_true_dependence (group->base_mem,
QImode,
group->canon_base_mem,
- read_info->mem, rtx_varies_p))
+ read_info->mem, NULL_RTX,
+ rtx_varies_p))
{
if (kill)
bitmap_ior_into (kill, group->group_kill);
diff --git a/gcc/gcse.c b/gcc/gcse.c
index 00f09862cb6..3195c989c5e 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -1,7 +1,7 @@
/* Global common subexpression elimination/Partial redundancy elimination
and global constant/copy propagation for GNU compiler.
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007, 2008 Free Software Foundation, Inc.
+ 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of GCC.
@@ -2512,7 +2512,7 @@ compute_transp (const_rtx x, int indx, sbitmap *bmap, int set_p)
dest_addr = XEXP (list_entry, 0);
if (canon_true_dependence (dest, GET_MODE (dest), dest_addr,
- x, rtx_addr_varies_p))
+ x, NULL_RTX, rtx_addr_varies_p))
{
if (set_p)
SET_BIT (bmap[bb_index], indx);
diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index dfead07648d..6d39325c2f3 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "expr.h"
#include "hashtab.h"
#include "recog.h"
+#include "alias-export.h"
/* This pass performs loop unrolling and peeling. We only perform these
optimizations on innermost loops (with single exception) because
@@ -2207,6 +2208,9 @@ apply_opt_in_copies (struct opt_info *opt_info,
expand_var_during_unrolling (ves, insn);
}
}
+
+ if (flag_ddg_export)
+ remove_exported_ddg_data (insn);
orig_insn = NEXT_INSN (orig_insn);
}
}
@@ -2245,6 +2249,9 @@ apply_opt_in_copies (struct opt_info *opt_info,
if (!INSN_P (orig_insn))
continue;
+
+ if (flag_ddg_export)
+ remove_exported_ddg_data (orig_insn);
ivts_templ.insn = orig_insn;
if (opt_info->insns_to_split)
diff --git a/gcc/rtl.h b/gcc/rtl.h
index b95a5b79df8..484f7bf4427 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2305,7 +2305,7 @@ extern rtx canon_rtx (rtx);
extern int true_dependence (const_rtx, enum machine_mode, const_rtx, bool (*)(const_rtx, bool));
extern rtx get_addr (rtx);
extern int canon_true_dependence (const_rtx, enum machine_mode, rtx, const_rtx,
- bool (*)(const_rtx, bool));
+ rtx, bool (*)(const_rtx, bool));
extern int read_dependence (const_rtx, const_rtx);
extern int anti_dependence (const_rtx, const_rtx);
extern int output_dependence (const_rtx, const_rtx);