summaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorErick Ochoa <erick.ochoa@theobroma-systems.com>2020-06-17 17:36:28 +0200
committerErick Ochoa <erick.ochoa@theobroma-systems.com>2020-06-17 17:36:28 +0200
commit1ea9a204ef32fc5c3e1636c003ac68bd32cc2723 (patch)
tree2997c24c2e05fbf9928cd5119e17ec1d4120a9b6 /gcc/testsuite
parent2096c9d2a40a138e5d388d06b1c04839ac1fb91f (diff)
more pointer arithmetic
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c17
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c17
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c4
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c23
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c31
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c12
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c14
7 files changed, 35 insertions, 83 deletions
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c
index f93b642586e..d9f0ac13b55 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */
+/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */
#include <assert.h>
@@ -13,11 +13,12 @@ main ()
_Bool c;
};
struct astruct_s b[2];
- _Bool *first_of_second = &(b[1].a);
- _Bool *a_ptr = &(b[0].a);
- _Bool *c_from_a = ++a_ptr;
- _Bool *c_from_array = --first_of_second;
- _Bool test = c_from_a == c_from_array;
- assert (test);
- char compile_test[test ? 1 : -1];
+ _Bool *a_0_ptr = &(b[0].a);
+ _Bool *c_0_ptr = &(b[0].c);
+ _Bool *a_1_ptr = &(b[1].a);
+
+ _Bool *c_0_ptr_from_a_0_ptr = a_0_ptr + 1;
+ _Bool *c_0_ptr_from_a_1_ptr = a_1_ptr - 1;
+ assert(c_0_ptr_from_a_0_ptr == c_0_ptr);
+ assert(c_0_ptr_from_a_1_ptr == c_0_ptr);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c
deleted file mode 100644
index 080d8509c26..00000000000
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */
-
-int
-main ()
-{
- struct astruct_s
- {
- _Bool a;
- _Bool b;
- _Bool c;
- };
- struct astruct_s astruct;
- return 0;
-}
-
-// CLOBBERS :(
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c
index 68c75427640..869d2b622e0 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */
+/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */
#include <assert.h>
@@ -16,6 +16,8 @@ main ()
_Bool *a = &astruct.a;
_Bool *c = &astruct.c;
_Bool *c_1 = a + 1;
+ _Bool *a_1 = c - 1;
assert (c_1 == c);
+ assert (a_1 == a);
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c
index c86bce1f885..a4b1c516fb1 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c
@@ -1,9 +1,10 @@
/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */
+/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
+#include <stdio.h>
int
main ()
@@ -15,14 +16,16 @@ main ()
_Bool c;
};
struct astruct_s a[2];
- struct bstruct_s
- {
- _Bool a;
- _Bool c;
- };
struct astruct_s *a_0 = &(a[0]);
- struct astruct_s *a_1 = a_0 + 1;
- struct bstruct_s *b_0 = (struct bstruct_s *) a_0;
- struct bstruct_s *b_1 = b_0 + 1;
- assert ((struct bstruct_s *) a_1 == b_1);
+ struct astruct_s *a_1 = &(a[1]);
+ struct astruct_s *a_1_from_a_0 = a_0 + 1;
+ printf("%d %d\n", a_0->a, a_0->c);
+ // old new
+ // 0 a a
+ // 1 b c
+ // 2 c a
+ // 3 a c
+ // 4 b a
+ // 5 c c
+ assert(a_1 == a_1_from_a_0);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c
deleted file mode 100644
index f42acd18d93..00000000000
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */
-
-#include <assert.h>
-#include <stdio.h>
-#include <stddef.h>
-
-int
-main ()
-{
- struct astruct_s
- {
- _Bool a;
- _Bool b;
- _Bool c;
- _Bool d;
- };
- struct astruct_s a[2];
- struct bstruct_s
- {
- _Bool a;
- _Bool c;
- _Bool d;
- };
-
- struct astruct_s *a_0 = &(a[0]);
- struct astruct_s *a_1 = a_0 + 1;
- struct bstruct_s *b_0 = (struct bstruct_s *) a_0;
- struct bstruct_s *b_1 = b_0 + 1;
- assert ((struct bstruct_s *) a_1 == b_1);
-}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c
index ef4c1c10772..bf867b6cd43 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */
+/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis" } */
#include <assert.h>
#include <stdio.h>
@@ -23,9 +23,9 @@ main ()
_Bool d;
};
- struct astruct_s *a_0 = &(a[1]);
- struct astruct_s *a_1 = a_0 - 1;
- struct bstruct_s *b_0 = (struct bstruct_s *) a_0;
- struct bstruct_s *b_1 = b_0 - 1;
- assert ((struct bstruct_s *) a_1 == b_1);
+ struct astruct_s *a_1 = &(a[1]);
+ struct astruct_s *a_0 = a_1 - 1;
+ struct bstruct_s *b_1 = (struct bstruct_s *) a_1;
+ struct bstruct_s *b_0 = b_1 - 1;
+ assert ((struct bstruct_s *) a_0 != b_0);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c
index 7ec3c82a916..5d1cb281c76 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c
@@ -16,16 +16,10 @@ main (int argc, char **argv)
_Bool d;
};
struct astruct_s a[2];
- struct bstruct_s
- {
- _Bool a;
- _Bool c;
- _Bool d;
- };
-
struct astruct_s *a_0 = &(a[0]);
struct astruct_s *a_1 = a_0 + argc;
- struct bstruct_s *b_0 = (struct bstruct_s *) a_0;
- struct bstruct_s *b_1 = b_0 + argc;
- assert ((struct bstruct_s *) a_1 == b_1);
+ ptrdiff_t d = a_1 - a_0;
+ printf("%d %d %d\n", a_0->a, a_0->c, a_0->d);
+ printf("%d\n", d);
+
}