aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/pr48335-1.c48
-rw-r--r--gcc/testsuite/gcc.dg/pr48335-2.c58
-rw-r--r--gcc/testsuite/gcc.dg/pr48335-3.c48
-rw-r--r--gcc/testsuite/gcc.dg/pr48335-4.c39
-rw-r--r--gcc/testsuite/gcc.dg/pr48335-5.c38
-rw-r--r--gcc/testsuite/gcc.dg/pr48335-6.c46
-rw-r--r--gcc/testsuite/gcc.dg/pr48335-7.c38
-rw-r--r--gcc/testsuite/gcc.dg/pr48335-8.c31
8 files changed, 346 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr48335-1.c b/gcc/testsuite/gcc.dg/pr48335-1.c
new file mode 100644
index 0000000..7a022ea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48335-1.c
@@ -0,0 +1,48 @@
+/* PR middle-end/48335 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-sra" } */
+
+typedef long long T __attribute__((may_alias));
+
+struct S
+{
+ _Complex float d __attribute__((aligned (8)));
+};
+
+void bar (struct S);
+
+void
+f1 (T x)
+{
+ struct S s;
+ *(T *) &s.d = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f2 (int x)
+{
+ struct S s = { .d = 0.0f };
+ *(char *) &s.d = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f3 (int x)
+{
+ struct S s = { .d = 0.0f };
+ ((char *) &s.d)[2] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f4 (int x, int y)
+{
+ struct S s = { .d = 0.0f };
+ ((char *) &s.d)[y] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
diff --git a/gcc/testsuite/gcc.dg/pr48335-2.c b/gcc/testsuite/gcc.dg/pr48335-2.c
new file mode 100644
index 0000000..a37c079
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48335-2.c
@@ -0,0 +1,58 @@
+/* PR middle-end/48335 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-sra" } */
+
+typedef long long T __attribute__((may_alias, aligned (1)));
+typedef short U __attribute__((may_alias, aligned (1)));
+
+struct S
+{
+ _Complex float d __attribute__((aligned (8)));
+};
+
+void bar (struct S);
+
+void
+f1 (T x)
+{
+ struct S s;
+ *(T *) ((char *) &s.d + 1) = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f2 (int x)
+{
+ struct S s = { .d = 0.0f };
+ ((U *)((char *) &s.d + 1))[0] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f3 (int x)
+{
+ struct S s = { .d = 0.0f };
+ ((U *)((char *) &s.d + 1))[1] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f4 (int x)
+{
+ struct S s = { .d = 0.0f };
+ ((U *)((char *) &s.d + 1))[2] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f5 (int x)
+{
+ struct S s = { .d = 0.0f };
+ ((U *)((char *) &s.d + 1))[3] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
diff --git a/gcc/testsuite/gcc.dg/pr48335-3.c b/gcc/testsuite/gcc.dg/pr48335-3.c
new file mode 100644
index 0000000..9041f59
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48335-3.c
@@ -0,0 +1,48 @@
+/* PR middle-end/48335 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-sra" } */
+
+typedef short U __attribute__((may_alias, aligned (1)));
+
+struct S
+{
+ double d;
+};
+
+void bar (struct S);
+
+void
+f1 (int x)
+{
+ struct S s = { .d = 0.0 };
+ ((U *)((char *) &s.d + 1))[0] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f2 (int x)
+{
+ struct S s = { .d = 0.0 };
+ ((U *)((char *) &s.d + 1))[1] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f3 (int x)
+{
+ struct S s = { .d = 0.0 };
+ ((U *)((char *) &s.d + 1))[2] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f4 (int x)
+{
+ struct S s = { .d = 0.0 };
+ ((U *)((char *) &s.d + 1))[3] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
diff --git a/gcc/testsuite/gcc.dg/pr48335-4.c b/gcc/testsuite/gcc.dg/pr48335-4.c
new file mode 100644
index 0000000..98e9e1e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48335-4.c
@@ -0,0 +1,39 @@
+/* PR middle-end/48335 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-sra" } */
+
+typedef short U __attribute__((may_alias, aligned (1)));
+
+struct S
+{
+ double d;
+};
+
+void bar (struct S);
+
+void
+f1 (int x)
+{
+ struct S s = { .d = 0.0 };
+ ((U *)((char *) &s.d + 1))[-1] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f2 (int x)
+{
+ struct S s = { .d = 0.0 };
+ ((U *)((char *) &s.d + 1))[-2] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
+
+void
+f3 (int x)
+{
+ struct S s = { .d = 0.0 };
+ ((U *)((char *) &s.d + 1))[5] = x;
+ __real__ s.d *= 7.0;
+ bar (s);
+}
diff --git a/gcc/testsuite/gcc.dg/pr48335-5.c b/gcc/testsuite/gcc.dg/pr48335-5.c
new file mode 100644
index 0000000..b189548
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48335-5.c
@@ -0,0 +1,38 @@
+/* PR middle-end/48335 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-sra" } */
+
+typedef long long T __attribute__((may_alias));
+
+struct S
+{
+ _Complex float d __attribute__((aligned (8)));
+};
+
+int
+f1 (struct S x)
+{
+ struct S s = x;
+ return *(T *) &s.d;
+}
+
+int
+f2 (struct S x)
+{
+ struct S s = x;
+ return *(char *) &s.d;
+}
+
+int
+f3 (struct S x)
+{
+ struct S s = x;
+ return ((char *) &s.d)[2];
+}
+
+int
+f4 (struct S x, int y)
+{
+ struct S s = x;
+ return ((char *) &s.d)[y];
+}
diff --git a/gcc/testsuite/gcc.dg/pr48335-6.c b/gcc/testsuite/gcc.dg/pr48335-6.c
new file mode 100644
index 0000000..769130c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48335-6.c
@@ -0,0 +1,46 @@
+/* PR middle-end/48335 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-sra" } */
+
+typedef long long T __attribute__((may_alias, aligned (1)));
+typedef short U __attribute__((may_alias, aligned (1)));
+
+struct S
+{
+ _Complex float d __attribute__((aligned (8)));
+};
+
+T
+f1 (struct S x)
+{
+ struct S s = x;
+ return *(T *) ((char *) &s.d + 1);
+}
+
+int
+f2 (struct S x)
+{
+ struct S s = x;
+ return ((U *)((char *) &s.d + 1))[0];
+}
+
+int
+f3 (struct S x)
+{
+ struct S s = x;
+ return ((U *)((char *) &s.d + 1))[1];
+}
+
+int
+f4 (struct S x)
+{
+ struct S s = x;
+ return ((U *)((char *) &s.d + 1))[2];
+}
+
+int
+f5 (struct S x)
+{
+ struct S s = x;
+ return ((U *)((char *) &s.d + 1))[3];
+}
diff --git a/gcc/testsuite/gcc.dg/pr48335-7.c b/gcc/testsuite/gcc.dg/pr48335-7.c
new file mode 100644
index 0000000..ddb15ee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48335-7.c
@@ -0,0 +1,38 @@
+/* PR middle-end/48335 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-sra" } */
+
+typedef short U __attribute__((may_alias, aligned (1)));
+
+struct S
+{
+ double d;
+};
+
+int
+f1 (struct S x)
+{
+ struct S s = x;
+ return ((U *)((char *) &s.d + 1))[0];
+}
+
+int
+f2 (struct S x)
+{
+ struct S s = x;
+ return ((U *)((char *) &s.d + 1))[1];
+}
+
+int
+f3 (struct S x)
+{
+ struct S s = x;
+ return ((U *)((char *) &s.d + 1))[2];
+}
+
+int
+f4 (struct S x)
+{
+ struct S s = x;
+ return ((U *)((char *) &s.d + 1))[3];
+}
diff --git a/gcc/testsuite/gcc.dg/pr48335-8.c b/gcc/testsuite/gcc.dg/pr48335-8.c
new file mode 100644
index 0000000..bb06c15
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr48335-8.c
@@ -0,0 +1,31 @@
+/* PR middle-end/48335 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-sra" } */
+
+typedef short U __attribute__((may_alias, aligned (1)));
+
+struct S
+{
+ double d;
+};
+
+int
+f1 (struct S x)
+{
+ struct S s = x;
+ return ((U *)((char *) &s.d + 1))[-1];
+}
+
+int
+f2 (struct S x)
+{
+ struct S s = x;
+ return ((U *)((char *) &s.d + 1))[-2];
+}
+
+int
+f3 (struct S x)
+{
+ struct S s = x;
+ return ((U *)((char *) &s.d + 1))[5];
+}