* [PATCH] derive alias information from named address spaces.
@ 2011-09-20 10:07 Bingfeng Mei
2011-09-20 16:47 ` Richard Henderson
0 siblings, 1 reply; 3+ messages in thread
From: Bingfeng Mei @ 2011-09-20 10:07 UTC (permalink / raw)
To: gcc-patches; +Cc: Ulrich Weigand
Hello,
The following patch is to derive more alias information from named address
spaces using existing target hook. It was discussed in
http://gcc.gnu.org/ml/gcc/2011-09/msg00180.html
Bootstrapped and tested on x86-64. OK for trunk?
Thanks,
Bingfeng
2011-09-20 Bingfeng Mei <bmei@broadcom.com>
* alias.c (nonoverlapping_memrefs_p): derive alias information
from named addresss space using target hook.
(nonoverlapping_memrefs_p): ditto. (write_dependence_p): ditto.
(write_dependence_p): ditto.
Index: alias.c
===================================================================
--- alias.c (revision 178972)
+++ alias.c (working copy)
@@ -2306,11 +2306,19 @@ nonoverlapping_memrefs_p (const_rtx x, c
return 1;
/* If we have MEMs refering to different address spaces (which can
- potentially overlap), we cannot easily tell from the addresses
- whether the references overlap. */
+ potentially overlap), they are not aliased if neither is subset
+ of the other one. */
if (MEM_P (rtlx) && MEM_P (rtly)
&& MEM_ADDR_SPACE (rtlx) != MEM_ADDR_SPACE (rtly))
- return 0;
+ {
+ if (!targetm.addr_space.subset_p (MEM_ADDR_SPACE (rtlx),
+ MEM_ADDR_SPACE (rtly))
+ && !targetm.addr_space.subset_p (MEM_ADDR_SPACE (rtly),
+ MEM_ADDR_SPACE (rtlx)))
+ return 1;
+ else
+ return 0;
+ }
/* Get the base and offsets of both decls. If either is a register, we
know both are and are the same, so use that as the base. The only
@@ -2417,10 +2425,18 @@ true_dependence_1 (const_rtx mem, enum m
return 0;
/* If we have MEMs refering to different address spaces (which can
- potentially overlap), we cannot easily tell from the addresses
- whether the references overlap. */
+ potentially overlap), they are not aliased if neither is subset
+ of the other one. */
if (MEM_ADDR_SPACE (mem) != MEM_ADDR_SPACE (x))
- return 1;
+ {
+ if (!targetm.addr_space.subset_p (MEM_ADDR_SPACE (mem),
+ MEM_ADDR_SPACE (x))
+ && !targetm.addr_space.subset_p (MEM_ADDR_SPACE (x),
+ MEM_ADDR_SPACE (mem)))
+ return 0;
+ else
+ return 1;
+ }
if (! mem_addr)
{
@@ -2542,10 +2558,18 @@ write_dependence_p (const_rtx mem, const
return 0;
/* If we have MEMs refering to different address spaces (which can
- potentially overlap), we cannot easily tell from the addresses
- whether the references overlap. */
+ potentially overlap), they are not aliased if neither is subset
+ of the other one. */
if (MEM_ADDR_SPACE (mem) != MEM_ADDR_SPACE (x))
- return 1;
+ {
+ if (!targetm.addr_space.subset_p (MEM_ADDR_SPACE (mem),
+ MEM_ADDR_SPACE (x))
+ && !targetm.addr_space.subset_p (MEM_ADDR_SPACE (x),
+ MEM_ADDR_SPACE (mem)))
+ return 0;
+ else
+ return 1;
+ }
x_addr = XEXP (x, 0);
mem_addr = XEXP (mem, 0);
@@ -2637,10 +2661,18 @@ may_alias_p (const_rtx mem, const_rtx x)
return 0;
/* If we have MEMs refering to different address spaces (which can
- potentially overlap), we cannot easily tell from the addresses
- whether the references overlap. */
+ potentially overlap), they are not aliased if neither is subset
+ of the other one. */
if (MEM_ADDR_SPACE (mem) != MEM_ADDR_SPACE (x))
- return 1;
+ {
+ if (!targetm.addr_space.subset_p (MEM_ADDR_SPACE (mem),
+ MEM_ADDR_SPACE (x))
+ && !targetm.addr_space.subset_p (MEM_ADDR_SPACE (x),
+ MEM_ADDR_SPACE (mem)))
+ return 0;
+ else
+ return 1;
+ }
x_addr = XEXP (x, 0);
mem_addr = XEXP (mem, 0);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] derive alias information from named address spaces.
2011-09-20 10:07 [PATCH] derive alias information from named address spaces Bingfeng Mei
@ 2011-09-20 16:47 ` Richard Henderson
2011-09-22 13:32 ` Bingfeng Mei
0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2011-09-20 16:47 UTC (permalink / raw)
To: Bingfeng Mei; +Cc: gcc-patches, Ulrich Weigand
On 09/20/2011 01:46 AM, Bingfeng Mei wrote:
> if (MEM_P (rtlx) && MEM_P (rtly)
> && MEM_ADDR_SPACE (rtlx) != MEM_ADDR_SPACE (rtly))
> - return 0;
> + {
> + if (!targetm.addr_space.subset_p (MEM_ADDR_SPACE (rtlx),
> + MEM_ADDR_SPACE (rtly))
> + && !targetm.addr_space.subset_p (MEM_ADDR_SPACE (rtly),
> + MEM_ADDR_SPACE (rtlx)))
> + return 1;
> + else
> + return 0;
> + }
You have 4 copies of this. Please pull it out into
a new predicate function.
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] derive alias information from named address spaces.
2011-09-20 16:47 ` Richard Henderson
@ 2011-09-22 13:32 ` Bingfeng Mei
0 siblings, 0 replies; 3+ messages in thread
From: Bingfeng Mei @ 2011-09-22 13:32 UTC (permalink / raw)
To: Richard Henderson; +Cc: gcc-patches, Ulrich Weigand
Hello,
Here is the updated patch. OK now?
Thanks,
Bingfeng
2011-09-22 Bingfeng Mei <bmei@broadcom.com>
* alias.c (mems_in_disjoint_address_spaces_p) New function.
(nonoverlapping_memrefs_p): Use mems_in_disjoint_address_sapces_p
to derive alias information.
(nonoverlapping_memrefs_p): ditto. (write_dependence_p): ditto.
(write_dependence_p): ditto.
Index: alias.c
===================================================================
--- alias.c (revision 178972)
+++ alias.c (working copy)
@@ -155,6 +155,7 @@ static int base_alias_check (rtx, rtx, e
enum machine_mode);
static rtx find_base_value (rtx);
static int mems_in_disjoint_alias_sets_p (const_rtx, const_rtx);
+static int mems_in_disjoint_address_spaces_p (const_rtx, const_rtx);
static int insert_subset_children (splay_tree_node, void*);
static alias_set_entry get_alias_set_entry (alias_set_type);
static const_rtx fixed_scalar_and_varying_struct_p (const_rtx, const_rtx, rtx, rtx,
@@ -400,6 +401,17 @@ mems_in_disjoint_alias_sets_p (const_rtx
return ! alias_sets_conflict_p (MEM_ALIAS_SET (mem1), MEM_ALIAS_SET (mem2));
}
+/* Return nonzero if the address spaces for MEM1 and MEM2 are disjoint */
+static inline int
+mems_in_disjoint_address_spaces_p (const_rtx mem1, const_rtx mem2)
+{
+
+ return (!targetm.addr_space.subset_p (MEM_ADDR_SPACE (mem1),
+ MEM_ADDR_SPACE (mem2))
+ && !targetm.addr_space.subset_p (MEM_ADDR_SPACE (mem2),
+ MEM_ADDR_SPACE (mem1)));
+}
+
/* Insert the NODE into the splay tree given by DATA. Used by
record_alias_subset via splay_tree_foreach. */
@@ -2306,11 +2318,11 @@ nonoverlapping_memrefs_p (const_rtx x, c
return 1;
/* If we have MEMs refering to different address spaces (which can
- potentially overlap), we cannot easily tell from the addresses
- whether the references overlap. */
+ potentially overlap), they are not aliased if neither is subset
+ of the other one. */
if (MEM_P (rtlx) && MEM_P (rtly)
&& MEM_ADDR_SPACE (rtlx) != MEM_ADDR_SPACE (rtly))
- return 0;
+ return mems_in_disjoint_address_spaces_p (rtlx, rtly);
/* Get the base and offsets of both decls. If either is a register, we
know both are and are the same, so use that as the base. The only
@@ -2417,10 +2429,10 @@ true_dependence_1 (const_rtx mem, enum m
return 0;
/* If we have MEMs refering to different address spaces (which can
- potentially overlap), we cannot easily tell from the addresses
- whether the references overlap. */
+ potentially overlap), they are not aliased if neither is subset
+ of the other one. */
if (MEM_ADDR_SPACE (mem) != MEM_ADDR_SPACE (x))
- return 1;
+ return (!mems_in_disjoint_address_spaces_p (mem, x));
if (! mem_addr)
{
@@ -2542,10 +2554,10 @@ write_dependence_p (const_rtx mem, const
return 0;
/* If we have MEMs refering to different address spaces (which can
- potentially overlap), we cannot easily tell from the addresses
- whether the references overlap. */
+ potentially overlap), they are not aliased if neither is subset
+ of the other one. */
if (MEM_ADDR_SPACE (mem) != MEM_ADDR_SPACE (x))
- return 1;
+ return (!mems_in_disjoint_address_spaces_p (mem, x));
x_addr = XEXP (x, 0);
mem_addr = XEXP (mem, 0);
@@ -2637,10 +2649,10 @@ may_alias_p (const_rtx mem, const_rtx x)
return 0;
/* If we have MEMs refering to different address spaces (which can
- potentially overlap), we cannot easily tell from the addresses
- whether the references overlap. */
+ potentially overlap), they are not aliased if neither is subset
+ of the other one. */
if (MEM_ADDR_SPACE (mem) != MEM_ADDR_SPACE (x))
- return 1;
+ return (!mems_in_disjoint_address_spaces_p (mem, x));
x_addr = XEXP (x, 0);
mem_addr = XEXP (mem, 0);
> -----Original Message-----
> From: Richard Henderson [mailto:rth@redhat.com]
> Sent: 20 September 2011 17:15
> To: Bingfeng Mei
> Cc: gcc-patches@gcc.gnu.org; Ulrich Weigand
> Subject: Re: [PATCH] derive alias information from named address spaces.
>
> On 09/20/2011 01:46 AM, Bingfeng Mei wrote:
> > if (MEM_P (rtlx) && MEM_P (rtly)
> > && MEM_ADDR_SPACE (rtlx) != MEM_ADDR_SPACE (rtly))
> > - return 0;
> > + {
> > + if (!targetm.addr_space.subset_p (MEM_ADDR_SPACE (rtlx),
> > + MEM_ADDR_SPACE (rtly))
> > + && !targetm.addr_space.subset_p (MEM_ADDR_SPACE (rtly),
> > + MEM_ADDR_SPACE (rtlx)))
> > + return 1;
> > + else
> > + return 0;
> > + }
>
> You have 4 copies of this. Please pull it out into
> a new predicate function.
>
>
> r~
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-22 12:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-20 10:07 [PATCH] derive alias information from named address spaces Bingfeng Mei
2011-09-20 16:47 ` Richard Henderson
2011-09-22 13:32 ` Bingfeng Mei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).