===================================================================
@@ -2239,8 +2239,11 @@ nonoverlapping_component_refs_p (const_r
found:
/* If we're left with accessing different fields of a structure, then no
- possible overlap, unless they are both bitfields. */
- if (TREE_CODE (typex) == RECORD_TYPE && fieldx != fieldy)
+ possible overlap, unless they are both bitfields.
+ ??? Pointer inequality is too fragile in the LTO compiler. */
+ if (TREE_CODE (typex) == RECORD_TYPE
+ && fieldx != fieldy
+ && DECL_NAME (fieldx) != DECL_NAME (fieldy))
return !(DECL_BIT_FIELD (fieldx) && DECL_BIT_FIELD (fieldy));
/* The comparison on the current field failed. If we're accessing
===================================================================
@@ -700,14 +700,78 @@ aliasing_component_refs_p (tree ref1,
return false;
}
+/* Return true if we can determine that component references X and Y, that are
+ within a common variable, cannot overlap. This is a generalized version of
+ nonoverlapping_component_refs_p under the common variable assumption. */
+
+static bool
+nonoverlapping_component_refs_of_decl_p (const_tree x, const_tree y)
+{
+ const_tree fieldx, fieldy, typex, typey, orig_y = y;
+
+ do
+ {
+ /* The comparison has to be done at a common type, since we don't
+ know how the inheritance hierarchy works. */
+ orig_y = y;
+ do
+ {
+ if (TREE_CODE (x) == COMPONENT_REF)
+ {
+ fieldx = TREE_OPERAND (x, 1);
+ typex = TYPE_MAIN_VARIANT (DECL_FIELD_CONTEXT (fieldx));
+
+ y = orig_y;
+ do
+ {
+ if (TREE_CODE (y) == COMPONENT_REF)
+ {
+ fieldy = TREE_OPERAND (y, 1);
+ typey = TYPE_MAIN_VARIANT (DECL_FIELD_CONTEXT (fieldy));
+
+ if (typex == typey)
+ goto found;
+ }
+ y = TREE_OPERAND (y, 0);
+ }
+ while (y && handled_component_p (y));
+ }
+ x = TREE_OPERAND (x, 0);
+ }
+ while (x && handled_component_p (x));
+ /* Never found a common type. */
+ return false;
+
+ found:
+ /* If we're left with accessing different fields of a structure,
+ then no overlap.
+ ??? Pointer inequality is too fragile in the LTO compiler. */
+ if (TREE_CODE (typex) == RECORD_TYPE
+ && fieldx != fieldy
+ && DECL_NAME (fieldx) != DECL_NAME (fieldy))
+ return true;
+
+ /* The comparison on the current field failed. If we're accessing
+ a very nested structure, look at the next outer level. */
+ x = TREE_OPERAND (x, 0);
+ y = TREE_OPERAND (y, 0);
+ }
+ while (x && y
+ && handled_component_p (x)
+ && handled_component_p (y));
+
+ 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));
@@ -718,7 +782,17 @@ decl_refs_may_alias_p (tree base1,
/* 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
@@ -1067,8 +1141,8 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref
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);
===================================================================
@@ -10,6 +10,8 @@ typedef struct {
unsigned short b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
@@ -26,8 +28,8 @@ 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++)
===================================================================
@@ -12,6 +12,8 @@ typedef struct {
int d;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -54,8 +56,8 @@ int main (void)
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);
===================================================================
@@ -17,6 +17,8 @@ typedef struct {
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr, int n)
{
@@ -102,8 +104,8 @@ int main (void)
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);
===================================================================
@@ -10,6 +10,8 @@ typedef struct {
unsigned char b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -62,8 +64,8 @@ int main (void)
{
arr[i].a = i;
arr[i].b = i * 2;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
===================================================================
@@ -18,6 +18,8 @@ typedef struct {
s check_res[N];
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -103,8 +105,8 @@ int main (void)
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);
===================================================================
@@ -84,8 +84,8 @@ int main (void)
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 ();
===================================================================
@@ -16,6 +16,8 @@ typedef struct {
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -76,8 +78,8 @@ int main (void)
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);
===================================================================
@@ -10,6 +10,8 @@ typedef struct {
unsigned short b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -46,8 +48,8 @@ int main (void)
{
arr[i].a = i;
arr[i].b = i * 2;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
===================================================================
@@ -15,6 +15,8 @@ typedef struct {
unsigned int b;
} ii;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
@@ -32,8 +34,8 @@ 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++)
===================================================================
@@ -18,6 +18,8 @@ typedef struct {
s check_res[N];
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -91,8 +93,8 @@ int main (void)
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);
===================================================================
@@ -16,6 +16,8 @@ typedef struct {
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -69,8 +71,8 @@ int main (void)
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);
===================================================================
@@ -12,6 +12,8 @@ typedef struct {
unsigned short d;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -59,8 +61,8 @@ int main (void)
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);
===================================================================
@@ -16,6 +16,8 @@ typedef struct {
int h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -68,8 +70,8 @@ int main (void)
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);
===================================================================
@@ -18,6 +18,8 @@ typedef struct {
s check_res[N];
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -80,8 +82,9 @@ int main (void)
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);
===================================================================
@@ -16,6 +16,8 @@ typedef struct {
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
@@ -34,8 +36,8 @@ 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++)
===================================================================
@@ -16,6 +16,8 @@ typedef struct {
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -89,8 +91,8 @@ int main (void)
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);
===================================================================
@@ -16,6 +16,8 @@ typedef struct {
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)
{
@@ -67,8 +69,8 @@ int main (void)
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 ();
===================================================================
@@ -10,6 +10,8 @@ typedef struct {
unsigned short b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
@@ -22,8 +24,8 @@ 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++)
===================================================================
@@ -16,6 +16,8 @@ typedef struct {
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -74,8 +76,8 @@ int main (void)
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);
===================================================================
@@ -12,6 +12,8 @@ typedef struct {
unsigned short d;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
@@ -27,8 +29,8 @@ 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++)
===================================================================
@@ -16,6 +16,8 @@ typedef struct {
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
@@ -35,8 +37,8 @@ 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++)
===================================================================
@@ -16,6 +16,8 @@ typedef struct {
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
@@ -50,8 +52,8 @@ 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++)
===================================================================
@@ -15,6 +15,8 @@ typedef struct {
unsigned int b;
} ii;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr, ii *iarr)
{
@@ -62,8 +64,8 @@ int main (void)
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);
===================================================================
@@ -10,6 +10,8 @@ typedef struct {
unsigned char b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr)
{
@@ -45,8 +47,8 @@ int main (void)
{
arr[i].a = i;
arr[i].b = i * 2;
- if (arr[i].a == 178)
- abort();
+ if (y) /* Avoid vectorization. */
+ abort ();
}
main1 (arr);
===================================================================
@@ -10,6 +10,8 @@ typedef struct {
unsigned char b;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
@@ -22,8 +24,8 @@ 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++)
===================================================================
@@ -12,6 +12,8 @@ typedef struct {
s buffer1[N], buffer2[N];
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s * __restrict__ pIn, s* __restrict__ pOut)
{
@@ -61,8 +63,8 @@ int main (void)
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 ();
===================================================================
@@ -15,6 +15,8 @@ typedef struct {
unsigned int b;
} ii;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 (s *arr, ii *iarr)
{
@@ -62,8 +64,8 @@ int main (void)
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);
===================================================================
@@ -16,6 +16,8 @@ typedef struct {
unsigned char h;
} s;
+volatile int y = 0;
+
__attribute__ ((noinline)) int
main1 ()
{
@@ -45,8 +47,8 @@ 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++)