* tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): New.
(decl_refs_may_alias_p): Add REF1 and REF2 parameters.
Use nonoverlapping_component_refs_of_decl_p to disambiguate component
references.
(refs_may_alias_p_1): Adjust call to decl_refs_may_alias_p.
* tree-streamer.c (record_common_node): Adjust reference in comment.
From-SVN: r198024
+2013-04-17 Eric Botcazou <ebotcazou@adacore.com>
+
+ * tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): New.
+ (decl_refs_may_alias_p): Add REF1 and REF2 parameters.
+ Use nonoverlapping_component_refs_of_decl_p to disambiguate component
+ references.
+ (refs_may_alias_p_1): Adjust call to decl_refs_may_alias_p.
+ * tree-streamer.c (record_common_node): Adjust reference in comment.
+
2013-04-17 Terry Guo <terry.guo@arm.com>
* config/arm/cortex-m4.md: Add a new bypass.
+2013-04-17 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/discr41.ad[sb]: New test.
+ * gcc.dg/tree-ssa/ssa-fre-38.c: Likewise.
+ * gcc.dg/vect/slp-24-big-array.c: Beef up anti-vectorization trick.
+ * gcc.dg/vect/slp-24.c: Likewise.
+ * gcc.dg/vect/vect-strided-a-mult.c: Likewise.
+ * gcc.dg/vect/vect-strided-a-u16-i2.c: Likewise.
+ * gcc.dg/vect/vect-strided-a-u16-i4.c: Likewise.
+ * gcc.dg/vect/vect-strided-a-u16-mult.c: Likewise.
+ * gcc.dg/vect/vect-strided-a-u8-i2-gap.c: Likewise.
+ * gcc.dg/vect/vect-strided-a-u8-i8-gap2-big-array.c: Likewise.
+ * gcc.dg/vect/vect-strided-a-u8-i8-gap2.c: Likewise.
+ * gcc.dg/vect/vect-strided-a-u8-i8-gap7-big-array.c: Likewise.
+ * gcc.dg/vect/vect-strided-a-u8-i8-gap7.c: Likewise.
+ * gcc.dg/vect/vect-strided-mult-char-ls.c: Likewise.
+ * gcc.dg/vect/vect-strided-mult.c: Likewise.
+ * gcc.dg/vect/vect-strided-same-dr.c: Likewise.
+ * gcc.dg/vect/vect-strided-u16-i2.c: Likewise.
+ * gcc.dg/vect/vect-strided-u16-i4.c: Likewise.
+ * gcc.dg/vect/vect-strided-u32-i4.c: Likewise.
+ * gcc.dg/vect/vect-strided-u32-i8.c: Likewise.
+ * gcc.dg/vect/vect-strided-u8-i2-gap.c: Likewise.
+ * gcc.dg/vect/vect-strided-u8-i2.c: Likewise.
+ * gcc.dg/vect/vect-strided-u8-i8-gap2-big-array.c: Likewise.
+ * gcc.dg/vect/vect-strided-u8-i8-gap2.c: Likewise.
+ * gcc.dg/vect/vect-strided-u8-i8-gap4-big-array.c: Likewise.
+ * gcc.dg/vect/vect-strided-u8-i8-gap4-unknown.c: Likewise.
+ * gcc.dg/vect/vect-strided-u8-i8-gap4.c: Likewise.
+ * gcc.dg/vect/vect-strided-u8-i8-gap7-big-array.c: Likewise.
+ * gcc.dg/vect/vect-strided-u8-i8-gap7.c: Likewise.
+ * gcc.dg/vect/vect-strided-u8-i8.c: Likewise.
+
2013-04-17 Janne Blomqvist <jb@gcc.gnu.org>
- PR fortran/40958
- * lib/gcc-dg.exp (scan-module): Uncompress module file before
- scanning.
- * gfortran.dg/module_md5_1.f90: Remove.
+ PR fortran/40958
+ * lib/gcc-dg.exp (scan-module): Uncompress module file before scanning.
+ * gfortran.dg/module_md5_1.f90: Remove.
2013-04-16 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-fre1" } */
+
+struct S { int i; int j; };
+
+struct U
+{
+ struct S a[10];
+} u;
+
+int foo (int n, int i, int j)
+{
+ u.a[n].i = i;
+ u.a[n].j = j;
+ return u.a[n].i;
+}
+
+/* We should remove the redundant load. */
+
+/* { dg-final { scan-tree-dump-not "= u.a\\\[n_2\\(D\\)\\\].i" "fre1" } } */
+/* { dg-final { cleanup-tree-dump "fre1" } } */
arr[i].b = i * 2 + 10;
arr[i].c = 17;
arr[i].d = i+34;
- if (arr[i].a == 178)
- abort ();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
check_vect ();
unsigned char ub[N*2] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
unsigned char uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+volatile int y = 0;
+
void
main1 (unsigned char x, unsigned char max_result, unsigned char min_result, s *arr)
{
arr[i].b = i * 2 + 10;
arr[i].c = 17;
arr[i].d = i+34;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
check_vect ();
unsigned int b;
} ii;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
arr[i].b = i * 2;
iarr[i].a = i;
iarr[i].b = i * 3;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
for (i = 0; i < N; i++)
unsigned short b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
{
arr[i].a = i;
arr[i].b = i * 2;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
for (i = 0; i < N; i++)
unsigned short d;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
arr[i].b = i * 2;
arr[i].c = 17;
arr[i].d = i+34;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
for (i = 0; i < N; i++)
unsigned short b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
arr[i].a = i;
arr[i].b = i * 2;
iarr[i] = i * 3;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
for (i = 0; i < N; i++)
unsigned char b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
{
arr[i].a = i;
arr[i].b = i * 2;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
for (i = 0; i < N; i++)
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
check_res[i].h = arr[i].f;
check_res[i].g = arr[i].f - arr[i].a;
- if (arr[i].a == 178)
- abort ();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
for (i = 0; i < N; i++)
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
arr[i].f = i * 2 + 2;
arr[i].g = i - 3;
arr[i].h = 56;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
for (i = 0; i < N; i++)
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
check_res[i].h = arr[i].d;
check_res[i].g = u + t;
- if (arr[i].a == 178)
- abort ();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
for (i = 0; i < N; i++)
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
arr[i].f = i * 5;
arr[i].g = i - 3;
arr[i].h = 67;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
for (i = 0; i < N; i++)
unsigned int b;
} ii;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr, ii *iarr)
{
arr[i].b = i * 2;
iarr[i].a = i;
iarr[i].b = i * 3;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr, iarr);
unsigned int b;
} ii;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr, ii *iarr)
{
arr[i].b = i * 2;
iarr[i].a = i;
iarr[i].b = i * 3;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr, iarr);
s buffer1[N], buffer2[N];
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s * __restrict__ pIn, s* __restrict__ pOut)
{
buffer1[i].b = i + 8;
buffer2[i].a = i * 3;
buffer2[i].b = i * 2;
- if (buffer1[i].a == 500)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
check_vect ();
unsigned short b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
{
arr[i].a = i;
arr[i].b = i * 2;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
unsigned short d;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
arr[i].b = i * 2;
arr[i].c = 17;
arr[i].d = i+34;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
int d;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
arr[i].b = i * 2;
arr[i].c = 17;
arr[i].d = i+34;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
int h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
arr[i].f = i * 5;
arr[i].g = i - 3;
arr[i].h = 56;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
unsigned char b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
{
arr[i].a = i;
arr[i].b = i * 2;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
unsigned char b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
{
arr[i].a = i;
arr[i].b = i * 2;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
s check_res[N];
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
check_res[i].e = arr[i].f - arr[i].b;
check_res[i].h = arr[i].f;
check_res[i].g = arr[i].f - arr[i].b;
- if (arr[i].a == 178)
- abort ();
+
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
arr[i].f = i * 2 + 2;
arr[i].g = i - 3;
arr[i].h = 56;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
s check_res[N];
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
check_res[i].h = arr[i].c;
check_res[i].g = arr[i].b + arr[i].c;
- if (arr[i].a == 178)
- abort ();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr, int n)
{
arr[i].f = 16;
arr[i].g = 3;
arr[i].h = 56;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr, N-2);
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
arr[i].f = i * 5;
arr[i].g = i - 3;
arr[i].h = 56;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
s check_res[N];
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
check_res[i].h = arr[i].d;
check_res[i].g = u + t;
- if (arr[i].a == 178)
- abort ();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
arr[i].f = i * 5;
arr[i].g = i - 3;
arr[i].h = 67;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
arr[i].f = i + 5;
arr[i].g = i + 3;
arr[i].h = 67;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
--- /dev/null
+-- { dg-do compile }
+-- { dg-options "-O" }
+
+package body Discr41 is
+
+ function F return Rec is
+ Ret : Rec (0);
+ begin
+ return Ret;
+ end;
+
+end Discr41;
--- /dev/null
+package Discr41 is
+
+ type Vector is array (Positive range <>) of Long_Float;
+
+ type Date is record
+ LF : Long_Float := 0.0;
+ end record;
+
+ type Date_Vector is array (Positive range <>) of Date;
+
+ type Rec (D : Natural) is record
+ B1 : Boolean := False;
+ DL : Date_Vector (1 .. D);
+ VL : Vector (1 .. D) := (others => 0.0);
+ B2 : Boolean := True;
+ end record;
+
+ function F return Rec;
+
+end Discr41;
return false;
}
+/* Return true if we can determine that component references REF1 and REF2,
+ that are within a common DECL, cannot overlap. */
+
+static bool
+nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2)
+{
+ vec<tree, va_stack> component_refs1;
+ vec<tree, va_stack> component_refs2;
+
+ vec_stack_alloc (tree, component_refs1, 16);
+ vec_stack_alloc (tree, component_refs2, 16);
+
+ /* Create the stack of handled components for REF1. */
+ while (handled_component_p (ref1))
+ {
+ component_refs1.safe_push (ref1);
+ ref1 = TREE_OPERAND (ref1, 0);
+ }
+ if (TREE_CODE (ref1) == MEM_REF)
+ {
+ if (!integer_zerop (TREE_OPERAND (ref1, 1)))
+ goto may_overlap;
+ ref1 = TREE_OPERAND (TREE_OPERAND (ref1, 0), 0);
+ }
+
+ /* Create the stack of handled components for REF2. */
+ while (handled_component_p (ref2))
+ {
+ component_refs2.safe_push (ref2);
+ ref2 = TREE_OPERAND (ref2, 0);
+ }
+ if (TREE_CODE (ref2) == MEM_REF)
+ {
+ if (!integer_zerop (TREE_OPERAND (ref2, 1)))
+ goto may_overlap;
+ ref2 = TREE_OPERAND (TREE_OPERAND (ref2, 0), 0);
+ }
+
+ /* We must have the same base DECL. */
+ gcc_assert (ref1 == ref2);
+
+ /* Pop the stacks in parallel and examine the COMPONENT_REFs of the same
+ rank. This is sufficient because we start from the same DECL and you
+ cannot reference several fields at a time with COMPONENT_REFs (unlike
+ with ARRAY_RANGE_REFs for arrays) so you always need the same number
+ of them to access a sub-component, unless you're in a union, in which
+ case the return value will precisely be false. */
+ while (true)
+ {
+ do
+ {
+ if (component_refs1.is_empty ())
+ goto may_overlap;
+ ref1 = component_refs1.pop ();
+ }
+ while (!RECORD_OR_UNION_TYPE_P (TREE_TYPE (TREE_OPERAND (ref1, 0))));
+
+ do
+ {
+ if (component_refs2.is_empty ())
+ goto may_overlap;
+ ref2 = component_refs2.pop ();
+ }
+ while (!RECORD_OR_UNION_TYPE_P (TREE_TYPE (TREE_OPERAND (ref2, 0))));
+
+ /* Beware of BIT_FIELD_REF. */
+ if (TREE_CODE (ref1) != COMPONENT_REF
+ || TREE_CODE (ref2) != COMPONENT_REF)
+ goto may_overlap;
+
+ tree field1 = TREE_OPERAND (ref1, 1);
+ tree field2 = TREE_OPERAND (ref2, 1);
+
+ /* ??? We cannot simply use the type of operand #0 of the refs here
+ as the Fortran compiler smuggles type punning into COMPONENT_REFs
+ for common blocks instead of using unions like everyone else. */
+ tree type1 = TYPE_MAIN_VARIANT (DECL_CONTEXT (field1));
+ tree type2 = TYPE_MAIN_VARIANT (DECL_CONTEXT (field2));
+
+ /* We cannot disambiguate fields in a union or qualified union. */
+ if (type1 != type2 || TREE_CODE (type1) != RECORD_TYPE)
+ goto may_overlap;
+
+ /* Different fields of the same record type cannot overlap. */
+ if (field1 != field2)
+ {
+ component_refs1.release ();
+ component_refs2.release ();
+ return true;
+ }
+ }
+
+may_overlap:
+ component_refs1.release ();
+ component_refs2.release ();
+ return false;
+}
+
/* Return true if two memory references based on the variables BASE1
and BASE2 constrained to [OFFSET1, OFFSET1 + MAX_SIZE1) and
- [OFFSET2, OFFSET2 + MAX_SIZE2) may alias. */
+ [OFFSET2, OFFSET2 + MAX_SIZE2) may alias. REF1 and REF2
+ if non-NULL are the complete memory reference trees. */
static bool
-decl_refs_may_alias_p (tree base1,
+decl_refs_may_alias_p (tree ref1, tree base1,
HOST_WIDE_INT offset1, HOST_WIDE_INT max_size1,
- tree base2,
+ tree ref2, tree base2,
HOST_WIDE_INT offset2, HOST_WIDE_INT max_size2)
{
gcc_checking_assert (DECL_P (base1) && DECL_P (base2));
/* If both references are based on the same variable, they cannot alias if
the accesses do not overlap. */
- return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
+ if (!ranges_overlap_p (offset1, max_size1, offset2, max_size2))
+ return false;
+
+ /* For components with variable position, the above test isn't sufficient,
+ so we disambiguate component references manually. */
+ if (ref1 && ref2
+ && handled_component_p (ref1) && handled_component_p (ref2)
+ && nonoverlapping_component_refs_of_decl_p (ref1, ref2))
+ return false;
+
+ return true;
}
/* Return true if an indirect reference based on *PTR1 constrained
var1_p = DECL_P (base1);
var2_p = DECL_P (base2);
if (var1_p && var2_p)
- return decl_refs_may_alias_p (base1, offset1, max_size1,
- base2, offset2, max_size2);
+ return decl_refs_may_alias_p (ref1->ref, base1, offset1, max_size1,
+ ref2->ref, base2, offset2, max_size2);
ind1_p = (TREE_CODE (base1) == MEM_REF
|| TREE_CODE (base1) == TARGET_MEM_REF);
/* The FIELD_DECLs of structures should be shared, so that every
COMPONENT_REF uses the same tree node when referencing a field.
Pointer equality between FIELD_DECLs is used by the alias
- machinery to compute overlapping memory references (See
- nonoverlapping_component_refs_p). */
- tree f;
- for (f = TYPE_FIELDS (node); f; f = TREE_CHAIN (f))
+ machinery to compute overlapping component references (see
+ nonoverlapping_component_refs_p and
+ nonoverlapping_component_refs_of_decl_p). */
+ for (tree f = TYPE_FIELDS (node); f; f = TREE_CHAIN (f))
record_common_node (cache, f);
}
}