This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR 58958: wrong aliasing info
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 5 Nov 2013 11:40:02 +0100 (CET)
- Subject: Re: PR 58958: wrong aliasing info
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1311012323530 dot 24250 at stedding dot saclay dot inria dot fr> <CAFiYyc0i9pNC=Jpz-1LpUx673fffJY0tDKAqD1AfYm_gbvmKcg at mail dot gmail dot com> <CAFiYyc0v-TwQACBDJ_0LORV4o7O6QBa3aFcDGD+1moZM4fYtYA at mail dot gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1311041215080 dot 4556 at stedding dot saclay dot inria dot fr> <CAFiYyc0of0u8J0Kg4p8hUnRDcEA+a9049HxL34hjTZ84pOdi+w at mail dot gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1311041758590 dot 7063 at stedding dot saclay dot inria dot fr> <e93ef27e-8ab3-47c0-a52d-3dbb0dc37168 at email dot android dot com>
On Mon, 4 Nov 2013, Richard Biener wrote:
Well, you cannot use the size argument unchanged for the null return
case. You could fallback to get_base_address and -1 size in that case.
Like this? Bootstrap+testsuite on x86_64-unknown-linux-gnu.
(I think I'll disable cilk for my future bootstraps: it takes forever and
confuses contrib/compare_tests)
2013-11-05 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/58958
gcc/
* tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Use
get_addr_base_and_unit_offset instead of get_ref_base_and_extent.
gcc/testsuite/
* gcc.dg/tree-ssa/pr58958.c: New file.
--
Marc Glisse
Index: gcc/testsuite/gcc.dg/tree-ssa/pr58958.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/pr58958.c (revision 0)
+++ gcc/testsuite/gcc.dg/tree-ssa/pr58958.c (working copy)
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+double a[10];
+int f(int n){
+ a[3]=9;
+ __builtin_memset(&a[n],3,sizeof(double));
+ return a[3]==9;
+}
+
+/* { dg-final { scan-tree-dump " == 9" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Property changes on: gcc/testsuite/gcc.dg/tree-ssa/pr58958.c
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: gcc/tree-ssa-alias.c
===================================================================
--- gcc/tree-ssa-alias.c (revision 204381)
+++ gcc/tree-ssa-alias.c (working copy)
@@ -559,41 +559,50 @@ ao_ref_alias_set (ao_ref *ref)
}
/* Init an alias-oracle reference representation from a gimple pointer
PTR and a gimple size SIZE in bytes. If SIZE is NULL_TREE the the
size is assumed to be unknown. The access is assumed to be only
to or after of the pointer target, not before it. */
void
ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size)
{
- HOST_WIDE_INT t1, t2, extra_offset = 0;
+ HOST_WIDE_INT t, extra_offset = 0;
ref->ref = NULL_TREE;
if (TREE_CODE (ptr) == SSA_NAME)
{
gimple stmt = SSA_NAME_DEF_STMT (ptr);
if (gimple_assign_single_p (stmt)
&& gimple_assign_rhs_code (stmt) == ADDR_EXPR)
ptr = gimple_assign_rhs1 (stmt);
else if (is_gimple_assign (stmt)
&& gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR
&& host_integerp (gimple_assign_rhs2 (stmt), 0)
- && (t1 = int_cst_value (gimple_assign_rhs2 (stmt))) >= 0)
+ && (t = int_cst_value (gimple_assign_rhs2 (stmt))) >= 0)
{
ptr = gimple_assign_rhs1 (stmt);
- extra_offset = BITS_PER_UNIT * t1;
+ extra_offset = BITS_PER_UNIT * t;
}
}
if (TREE_CODE (ptr) == ADDR_EXPR)
- ref->base = get_ref_base_and_extent (TREE_OPERAND (ptr, 0),
- &ref->offset, &t1, &t2);
+ {
+ ref->base = get_addr_base_and_unit_offset (TREE_OPERAND (ptr, 0), &t);
+ if (ref->base)
+ ref->offset = BITS_PER_UNIT * t;
+ else
+ {
+ size = NULL_TREE;
+ ref->offset = 0;
+ ref->base = get_base_address (TREE_OPERAND (ptr, 0));
+ }
+ }
else
{
ref->base = build2 (MEM_REF, char_type_node,
ptr, null_pointer_node);
ref->offset = 0;
}
ref->offset += extra_offset;
if (size
&& host_integerp (size, 0)
&& TREE_INT_CST_LOW (size) * BITS_PER_UNIT / BITS_PER_UNIT