[test-suite] r374156 - Add GCC Torture Suite Sources
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 9 04:01:53 PDT 2019
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58277-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58277-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58277-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58277-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,98 @@
+/* PR tree-optimization/58277 */
+
+extern void abort (void);
+static int a[1], b, c, e, i, j, k, m, q[] = { 1, 1 }, t;
+int volatile d;
+int **r;
+static int ***volatile s = &r;
+int f, g, o, x;
+static int *volatile h = &f, *p;
+char n;
+
+static void
+fn1 ()
+{
+ b = a[a[a[a[a[a[a[a[b]]]]]]]];
+ b = a[a[a[a[a[a[a[a[b]]]]]]]];
+ b = a[a[b]];
+ b = a[a[a[a[a[a[a[a[b]]]]]]]];
+ b = a[a[a[a[a[a[a[a[b]]]]]]]];
+}
+
+static int
+fn2 ()
+{
+ n = 0;
+ for (; g; t++)
+ {
+ for (;; m++)
+ {
+ d;
+ int *u;
+ int **v[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, &u, 0, 0, 0, 0, &u, &u, &u, &u, &u, &u, &u, 0,
+ &u, 0, &u, &u, &u, 0, &u, &u, 0, &u, &u, &u, &u, 0, &u, &u, &u,
+ &u, &u, 0, &u, &u, 0, &u, 0, &u, &u, 0, &u, &u, &u, &u, &u, 0,
+ &u, 0, 0, 0, &u, &u, &u, 0, 0, &u, &u, &u, 0, &u, 0, &u, &u
+ };
+ int ***w[] = { &v[0] };
+ if (*p)
+ break;
+ return 0;
+ }
+ *h = 0;
+ }
+ return 1;
+}
+
+static void
+fn3 ()
+{
+ int *y[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ for (; i; i++)
+ x = 0;
+ if (fn2 ())
+ {
+ int *z[6] = { };
+ for (; n < 1; n++)
+ *h = 0;
+ int t1[7];
+ for (; c; c++)
+ o = t1[0];
+ for (; e; e--)
+ {
+ int **t2 = &y[0];
+ int ***t3 = &t2;
+ *t3 = &z[0];
+ }
+ }
+ *s = 0;
+ for (n = 0;; n = 0)
+ {
+ int t4 = 0;
+ if (q[n])
+ break;
+ *r = &t4;
+ }
+}
+
+int
+main ()
+{
+ for (; j; j--)
+ a[0] = 0;
+ fn3 ();
+ for (; k; k++)
+ fn1 ();
+ fn1 ();
+
+ if (n)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58364.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58364.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58364.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58364.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+/* PR tree-optimization/58364 */
+
+int a = 1, b, c;
+
+int
+foo (int x)
+{
+ return x < 0 ? 1 : x;
+}
+
+int
+main ()
+{
+ if (foo (a > c == (b = 0)))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58365.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58365.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58365.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58365.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+/* PR rtl-optimization/58365 */
+
+extern void abort (void);
+
+struct S
+{
+ volatile int a;
+ int b, c, d, e;
+} f;
+static struct S g, h;
+int i = 1;
+
+char
+foo (void)
+{
+ return i;
+}
+
+static struct S
+bar (void)
+{
+ if (foo ())
+ return f;
+ return g;
+}
+
+int
+main ()
+{
+ h = bar ();
+ f.b = 1;
+ if (h.b != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58385.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58385.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58385.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58385.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR tree-optimization/58385 */
+
+extern void abort (void);
+
+int a, b = 1;
+
+int
+foo ()
+{
+ b = 0;
+ return 0;
+}
+
+int
+main ()
+{
+ ((0 || a) & foo () >= 0) <= 1 && 1;
+ if (b)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58387.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58387.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58387.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58387.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,11 @@
+extern void abort(void);
+
+int a = -1;
+
+int main ()
+{
+ int b = a == 0 ? 0 : -a;
+ if (b < 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58419.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58419.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58419.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58419.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+__attribute__((__noinline__))
+void
+dummy ()
+{
+ asm volatile("");
+}
+
+int a, g, i, k, *p;
+signed char b;
+char e;
+short c, h;
+static short *d = &c;
+
+char
+foo (int p1, int p2)
+{
+ return p1 - p2;
+}
+
+int
+bar ()
+{
+ short *q = &c;
+ *q = 1;
+ *p = 0;
+ return 0;
+}
+
+int
+main ()
+{
+ for (b = -22; b >= -29; b--)
+ {
+ short *l = &h;
+ char *m = &e;
+ *l = a;
+ g = foo (*m = k && *d, 1 > i) || bar ();
+ }
+ dummy();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58431.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58431.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58431.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58431.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+char a, h;
+int b, d, e, g, j, k;
+volatile int c;
+short i;
+
+int
+main ()
+{
+ int m;
+
+ m = i ^= 1;
+ for (b = 0; b < 1; b++)
+ {
+ char o = m;
+ g = k;
+ j = j || c;
+ if (a != o)
+ for (; d < 1; d++)
+ ;
+ else
+ {
+ char *p = &h;
+ *p = 1;
+ for (; e; e++)
+ ;
+ }
+ }
+
+ if (h != 0)
+ __builtin_abort();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58564.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58564.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58564.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58564.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+/* PR middle-end/58564 */
+
+extern void abort (void);
+int a, b;
+short *c, **d = &c;
+
+int
+main ()
+{
+ b = (0, 0 > ((&c == d) & (1 && (a ^ 1)))) | 0U;
+ if (b != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58570.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58570.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58570.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58570.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* { dg-require-effective-target int32plus } */
+#pragma pack(1)
+struct S
+{
+ int f0:15;
+ int f1:29;
+};
+
+int e = 1, i;
+static struct S d[6];
+
+int
+main (void)
+{
+ if (e)
+ {
+ d[i].f0 = 1;
+ d[i].f1 = 1;
+ }
+ if (d[0].f1 != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58574.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58574.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58574.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58574.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,219 @@
+/* PR target/58574 */
+
+__attribute__((noinline, noclone)) double
+foo (double x)
+{
+ double t;
+ switch ((int) x)
+ {
+ case 0:
+ t = 2 * x - 1;
+ return 0.70878e-3 + (0.71234e-3 + (0.35779e-5 + (0.17403e-7 + (0.81710e-10 + (0.36885e-12 + 0.15917e-14 * t) * t) * t) * t) * t) * t;
+ case 1:
+ t = 2 * x - 3;
+ return 0.21479e-2 + (0.72686e-3 + (0.36843e-5 + (0.18071e-7 + (0.85496e-10 + (0.38852e-12 + 0.16868e-14 * t) * t) * t) * t) * t) * t;
+ case 2:
+ t = 2 * x - 5;
+ return 0.36165e-2 + (0.74182e-3 + (0.37948e-5 + (0.18771e-7 + (0.89484e-10 + (0.40935e-12 + 0.17872e-14 * t) * t) * t) * t) * t) * t;
+ case 3:
+ t = 2 * x - 7;
+ return 0.51154e-2 + (0.75722e-3 + (0.39096e-5 + (0.19504e-7 + (0.93687e-10 + (0.43143e-12 + 0.18939e-14 * t) * t) * t) * t) * t) * t;
+ case 4:
+ t = 2 * x - 9;
+ return 0.66457e-2 + (0.77310e-3 + (0.40289e-5 + (0.20271e-7 + (0.98117e-10 + (0.45484e-12 + 0.20076e-14 * t) * t) * t) * t) * t) * t;
+ case 5:
+ t = 2 * x - 11;
+ return 0.82082e-2 + (0.78946e-3 + (0.41529e-5 + (0.21074e-7 + (0.10278e-9 + (0.47965e-12 + 0.21285e-14 * t) * t) * t) * t) * t) * t;
+ case 6:
+ t = 2 * x - 13;
+ return 0.98039e-2 + (0.80633e-3 + (0.42819e-5 + (0.21916e-7 + (0.10771e-9 + (0.50595e-12 + 0.22573e-14 * t) * t) * t) * t) * t) * t;
+ case 7:
+ t = 2 * x - 15;
+ return 0.11433e-1 + (0.82372e-3 + (0.44160e-5 + (0.22798e-7 + (0.11291e-9 + (0.53386e-12 + 0.23944e-14 * t) * t) * t) * t) * t) * t;
+ case 8:
+ t = 2 * x - 17;
+ return 0.13099e-1 + (0.84167e-3 + (0.45555e-5 + (0.23723e-7 + (0.11839e-9 + (0.56346e-12 + 0.25403e-14 * t) * t) * t) * t) * t) * t;
+ case 9:
+ t = 2 * x - 19;
+ return 0.14800e-1 + (0.86018e-3 + (0.47008e-5 + (0.24694e-7 + (0.12418e-9 + (0.59486e-12 + 0.26957e-14 * t) * t) * t) * t) * t) * t;
+ case 10:
+ t = 2 * x - 21;
+ return 0.16540e-1 + (0.87928e-3 + (0.48520e-5 + (0.25711e-7 + (0.13030e-9 + (0.62820e-12 + 0.28612e-14 * t) * t) * t) * t) * t) * t;
+ case 11:
+ t = 2 * x - 23;
+ return 0.18318e-1 + (0.89900e-3 + (0.50094e-5 + (0.26779e-7 + (0.13675e-9 + (0.66358e-12 + 0.30375e-14 * t) * t) * t) * t) * t) * t;
+ case 12:
+ t = 2 * x - 25;
+ return 0.20136e-1 + (0.91936e-3 + (0.51734e-5 + (0.27900e-7 + (0.14357e-9 + (0.70114e-12 + 0.32252e-14 * t) * t) * t) * t) * t) * t;
+ case 13:
+ t = 2 * x - 27;
+ return 0.21996e-1 + (0.94040e-3 + (0.53443e-5 + (0.29078e-7 + (0.15078e-9 + (0.74103e-12 + 0.34251e-14 * t) * t) * t) * t) * t) * t;
+ case 14:
+ t = 2 * x - 29;
+ return 0.23898e-1 + (0.96213e-3 + (0.55225e-5 + (0.30314e-7 + (0.15840e-9 + (0.78340e-12 + 0.36381e-14 * t) * t) * t) * t) * t) * t;
+ case 15:
+ t = 2 * x - 31;
+ return 0.25845e-1 + (0.98459e-3 + (0.57082e-5 + (0.31613e-7 + (0.16646e-9 + (0.82840e-12 + 0.38649e-14 * t) * t) * t) * t) * t) * t;
+ case 16:
+ t = 2 * x - 33;
+ return 0.27837e-1 + (0.10078e-2 + (0.59020e-5 + (0.32979e-7 + (0.17498e-9 + (0.87622e-12 + 0.41066e-14 * t) * t) * t) * t) * t) * t;
+ case 17:
+ t = 2 * x - 35;
+ return 0.29877e-1 + (0.10318e-2 + (0.61041e-5 + (0.34414e-7 + (0.18399e-9 + (0.92703e-12 + 0.43639e-14 * t) * t) * t) * t) * t) * t;
+ case 18:
+ t = 2 * x - 37;
+ return 0.31965e-1 + (0.10566e-2 + (0.63151e-5 + (0.35924e-7 + (0.19353e-9 + (0.98102e-12 + 0.46381e-14 * t) * t) * t) * t) * t) * t;
+ case 19:
+ t = 2 * x - 39;
+ return 0.34104e-1 + (0.10823e-2 + (0.65354e-5 + (0.37512e-7 + (0.20362e-9 + (0.10384e-11 + 0.49300e-14 * t) * t) * t) * t) * t) * t;
+ case 20:
+ t = 2 * x - 41;
+ return 0.36295e-1 + (0.11089e-2 + (0.67654e-5 + (0.39184e-7 + (0.21431e-9 + (0.10994e-11 + 0.52409e-14 * t) * t) * t) * t) * t) * t;
+ case 21:
+ t = 2 * x - 43;
+ return 0.38540e-1 + (0.11364e-2 + (0.70058e-5 + (0.40943e-7 + (0.22563e-9 + (0.11642e-11 + 0.55721e-14 * t) * t) * t) * t) * t) * t;
+ case 22:
+ t = 2 * x - 45;
+ return 0.40842e-1 + (0.11650e-2 + (0.72569e-5 + (0.42796e-7 + (0.23761e-9 + (0.12332e-11 + 0.59246e-14 * t) * t) * t) * t) * t) * t;
+ case 23:
+ t = 2 * x - 47;
+ return 0.43201e-1 + (0.11945e-2 + (0.75195e-5 + (0.44747e-7 + (0.25030e-9 + (0.13065e-11 + 0.63000e-14 * t) * t) * t) * t) * t) * t;
+ case 24:
+ t = 2 * x - 49;
+ return 0.45621e-1 + (0.12251e-2 + (0.77941e-5 + (0.46803e-7 + (0.26375e-9 + (0.13845e-11 + 0.66996e-14 * t) * t) * t) * t) * t) * t;
+ case 25:
+ t = 2 * x - 51;
+ return 0.48103e-1 + (0.12569e-2 + (0.80814e-5 + (0.48969e-7 + (0.27801e-9 + (0.14674e-11 + 0.71249e-14 * t) * t) * t) * t) * t) * t;
+ case 26:
+ t = 2 * x - 59;
+ return 0.58702e-1 + (0.13962e-2 + (0.93714e-5 + (0.58882e-7 + (0.34414e-9 + (0.18552e-11 + 0.91160e-14 * t) * t) * t) * t) * t) * t;
+ case 30:
+ t = 2 * x - 79;
+ return 0.90908e-1 + (0.18544e-2 + (0.13903e-4 + (0.95549e-7 + (0.59752e-9 + (0.33656e-11 + 0.16815e-13 * t) * t) * t) * t) * t) * t;
+ case 40:
+ t = 2 * x - 99;
+ return 0.13443e0 + (0.25474e-2 + (0.21385e-4 + (0.15996e-6 + (0.10585e-8 + (0.61258e-11 + 0.30412e-13 * t) * t) * t) * t) * t) * t;
+ case 50:
+ t = 2 * x - 119;
+ return 0.19540e0 + (0.36342e-2 + (0.34096e-4 + (0.27479e-6 + (0.18934e-8 + (0.11021e-10 + 0.52931e-13 * t) * t) * t) * t) * t) * t;
+ case 60:
+ t = 2 * x - 121;
+ return 0.20281e0 + (0.37739e-2 + (0.35791e-4 + (0.29038e-6 + (0.20068e-8 + (0.11673e-10 + 0.55790e-13 * t) * t) * t) * t) * t) * t;
+ case 61:
+ t = 2 * x - 123;
+ return 0.21050e0 + (0.39206e-2 + (0.37582e-4 + (0.30691e-6 + (0.21270e-8 + (0.12361e-10 + 0.58770e-13 * t) * t) * t) * t) * t) * t;
+ case 62:
+ t = 2 * x - 125;
+ return 0.21849e0 + (0.40747e-2 + (0.39476e-4 + (0.32443e-6 + (0.22542e-8 + (0.13084e-10 + 0.61873e-13 * t) * t) * t) * t) * t) * t;
+ case 63:
+ t = 2 * x - 127;
+ return 0.22680e0 + (0.42366e-2 + (0.41477e-4 + (0.34300e-6 + (0.23888e-8 + (0.13846e-10 + 0.65100e-13 * t) * t) * t) * t) * t) * t;
+ case 64:
+ t = 2 * x - 129;
+ return 0.23545e0 + (0.44067e-2 + (0.43594e-4 + (0.36268e-6 + (0.25312e-8 + (0.14647e-10 + 0.68453e-13 * t) * t) * t) * t) * t) * t;
+ case 65:
+ t = 2 * x - 131;
+ return 0.24444e0 + (0.45855e-2 + (0.45832e-4 + (0.38352e-6 + (0.26819e-8 + (0.15489e-10 + 0.71933e-13 * t) * t) * t) * t) * t) * t;
+ case 66:
+ t = 2 * x - 133;
+ return 0.25379e0 + (0.47735e-2 + (0.48199e-4 + (0.40561e-6 + (0.28411e-8 + (0.16374e-10 + 0.75541e-13 * t) * t) * t) * t) * t) * t;
+ case 67:
+ t = 2 * x - 135;
+ return 0.26354e0 + (0.49713e-2 + (0.50702e-4 + (0.42901e-6 + (0.30095e-8 + (0.17303e-10 + 0.79278e-13 * t) * t) * t) * t) * t) * t;
+ case 68:
+ t = 2 * x - 137;
+ return 0.27369e0 + (0.51793e-2 + (0.53350e-4 + (0.45379e-6 + (0.31874e-8 + (0.18277e-10 + 0.83144e-13 * t) * t) * t) * t) * t) * t;
+ case 69:
+ t = 2 * x - 139;
+ return 0.28426e0 + (0.53983e-2 + (0.56150e-4 + (0.48003e-6 + (0.33752e-8 + (0.19299e-10 + 0.87139e-13 * t) * t) * t) * t) * t) * t;
+ case 70:
+ t = 2 * x - 141;
+ return 0.29529e0 + (0.56288e-2 + (0.59113e-4 + (0.50782e-6 + (0.35735e-8 + (0.20369e-10 + 0.91262e-13 * t) * t) * t) * t) * t) * t;
+ case 71:
+ t = 2 * x - 143;
+ return 0.30679e0 + (0.58714e-2 + (0.62248e-4 + (0.53724e-6 + (0.37827e-8 + (0.21490e-10 + 0.95513e-13 * t) * t) * t) * t) * t) * t;
+ case 72:
+ t = 2 * x - 145;
+ return 0.31878e0 + (0.61270e-2 + (0.65564e-4 + (0.56837e-6 + (0.40035e-8 + (0.22662e-10 + 0.99891e-13 * t) * t) * t) * t) * t) * t;
+ case 73:
+ t = 2 * x - 147;
+ return 0.33130e0 + (0.63962e-2 + (0.69072e-4 + (0.60133e-6 + (0.42362e-8 + (0.23888e-10 + 0.10439e-12 * t) * t) * t) * t) * t) * t;
+ case 74:
+ t = 2 * x - 149;
+ return 0.34438e0 + (0.66798e-2 + (0.72783e-4 + (0.63619e-6 + (0.44814e-8 + (0.25168e-10 + 0.10901e-12 * t) * t) * t) * t) * t) * t;
+ case 75:
+ t = 2 * x - 151;
+ return 0.35803e0 + (0.69787e-2 + (0.76710e-4 + (0.67306e-6 + (0.47397e-8 + (0.26505e-10 + 0.11376e-12 * t) * t) * t) * t) * t) * t;
+ case 76:
+ t = 2 * x - 153;
+ return 0.37230e0 + (0.72938e-2 + (0.80864e-4 + (0.71206e-6 + (0.50117e-8 + (0.27899e-10 + 0.11862e-12 * t) * t) * t) * t) * t) * t;
+ case 77:
+ t = 2 * x - 155;
+ return 0.38722e0 + (0.76260e-2 + (0.85259e-4 + (0.75329e-6 + (0.52979e-8 + (0.29352e-10 + 0.12360e-12 * t) * t) * t) * t) * t) * t;
+ case 78:
+ t = 2 * x - 157;
+ return 0.40282e0 + (0.79762e-2 + (0.89909e-4 + (0.79687e-6 + (0.55989e-8 + (0.30866e-10 + 0.12868e-12 * t) * t) * t) * t) * t) * t;
+ case 79:
+ t = 2 * x - 159;
+ return 0.41914e0 + (0.83456e-2 + (0.94827e-4 + (0.84291e-6 + (0.59154e-8 + (0.32441e-10 + 0.13387e-12 * t) * t) * t) * t) * t) * t;
+ case 80:
+ t = 2 * x - 161;
+ return 0.43621e0 + (0.87352e-2 + (0.10002e-3 + (0.89156e-6 + (0.62480e-8 + (0.34079e-10 + 0.13917e-12 * t) * t) * t) * t) * t) * t;
+ case 81:
+ t = 2 * x - 163;
+ return 0.45409e0 + (0.91463e-2 + (0.10553e-3 + (0.94293e-6 + (0.65972e-8 + (0.35782e-10 + 0.14455e-12 * t) * t) * t) * t) * t) * t;
+ case 82:
+ t = 2 * x - 165;
+ return 0.47282e0 + (0.95799e-2 + (0.11135e-3 + (0.99716e-6 + (0.69638e-8 + (0.37549e-10 + 0.15003e-12 * t) * t) * t) * t) * t) * t;
+ case 83:
+ t = 2 * x - 167;
+ return 0.49243e0 + (0.10037e-1 + (0.11750e-3 + (0.10544e-5 + (0.73484e-8 + (0.39383e-10 + 0.15559e-12 * t) * t) * t) * t) * t) * t;
+ case 84:
+ t = 2 * x - 169;
+ return 0.51298e0 + (0.10520e-1 + (0.12400e-3 + (0.11147e-5 + (0.77517e-8 + (0.41283e-10 + 0.16122e-12 * t) * t) * t) * t) * t) * t;
+ case 85:
+ t = 2 * x - 171;
+ return 0.53453e0 + (0.11030e-1 + (0.13088e-3 + (0.11784e-5 + (0.81743e-8 + (0.43252e-10 + 0.16692e-12 * t) * t) * t) * t) * t) * t;
+ case 86:
+ t = 2 * x - 173;
+ return 0.55712e0 + (0.11568e-1 + (0.13815e-3 + (0.12456e-5 + (0.86169e-8 + (0.45290e-10 + 0.17268e-12 * t) * t) * t) * t) * t) * t;
+ case 87:
+ t = 2 * x - 175;
+ return 0.58082e0 + (0.12135e-1 + (0.14584e-3 + (0.13164e-5 + (0.90803e-8 + (0.47397e-10 + 0.17850e-12 * t) * t) * t) * t) * t) * t;
+ case 88:
+ t = 2 * x - 177;
+ return 0.60569e0 + (0.12735e-1 + (0.15396e-3 + (0.13909e-5 + (0.95651e-8 + (0.49574e-10 + 0.18435e-12 * t) * t) * t) * t) * t) * t;
+ case 89:
+ t = 2 * x - 179;
+ return 0.63178e0 + (0.13368e-1 + (0.16254e-3 + (0.14695e-5 + (0.10072e-7 + (0.51822e-10 + 0.19025e-12 * t) * t) * t) * t) * t) * t;
+ case 90:
+ t = 2 * x - 181;
+ return 0.65918e0 + (0.14036e-1 + (0.17160e-3 + (0.15521e-5 + (0.10601e-7 + (0.54140e-10 + 0.19616e-12 * t) * t) * t) * t) * t) * t;
+ case 91:
+ t = 2 * x - 183;
+ return 0.68795e0 + (0.14741e-1 + (0.18117e-3 + (0.16392e-5 + (0.11155e-7 + (0.56530e-10 + 0.20209e-12 * t) * t) * t) * t) * t) * t;
+ case 92:
+ t = 2 * x - 185;
+ return 0.71818e0 + (0.15486e-1 + (0.19128e-3 + (0.17307e-5 + (0.11732e-7 + (0.58991e-10 + 0.20803e-12 * t) * t) * t) * t) * t) * t;
+ case 93:
+ t = 2 * x - 187;
+ return 0.74993e0 + (0.16272e-1 + (0.20195e-3 + (0.18269e-5 + (0.12335e-7 + (0.61523e-10 + 0.21395e-12 * t) * t) * t) * t) * t) * t;
+ }
+ return 1.0;
+}
+
+int
+main ()
+{
+#ifdef __s390x__
+ {
+ register unsigned long r5 __asm ("r5");
+ r5 = 0xdeadbeefUL;
+ asm volatile ("":"+r" (r5));
+ }
+#endif
+ double d = foo (78.4);
+ if (d < 0.38 || d > 0.42)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58640-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58640-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58640-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58640-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+extern void abort (void);
+
+int a[20], b, c;
+
+int
+fn1 ()
+{
+ int d, e, f, g = 0;
+
+ a[12] = 1;
+ for (e = 0; e < 3; e++)
+ for (d = 0; d < 2; d++)
+ {
+ for (f = 0; f < 2; f++)
+ {
+ g ^= a[12] > 1;
+ if (g)
+ return 0;
+ if (b)
+ break;
+ }
+ for (c = 0; c < 1; c++)
+ a[d] = a[e * 3 + 9];
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ fn1 ();
+ if (a[0] != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58640.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58640.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58640.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58640.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+int a, b, c, d = 1, e;
+
+static signed char
+foo ()
+{
+ int f, g = a;
+
+ for (f = 1; f < 3; f++)
+ for (; b < 1; b++)
+ {
+ if (d)
+ for (c = 0; c < 4; c++)
+ for (f = 0; f < 3; f++)
+ {
+ for (e = 0; e < 1; e++)
+ a = g;
+ if (f)
+ break;
+ }
+ else if (f)
+ continue;
+ return 0;
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ foo ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58662.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58662.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58662.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58662.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+extern void abort (void);
+
+int a, c, d;
+volatile int b;
+
+static int
+foo (int p1, short p2)
+{
+ return p1 / p2;
+}
+
+int
+main ()
+{
+ char e;
+ d = foo (a == 0, (0, 35536));
+ e = d % 14;
+ b = e && c;
+ if (b != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58726.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58726.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58726.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58726.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* PR rtl-optimization/58726 */
+
+int a, c;
+union { int f1; int f2 : 1; } b;
+
+short
+foo (short p)
+{
+ return p < 0 ? p : a;
+}
+
+int
+main ()
+{
+ if (sizeof (short) * __CHAR_BIT__ != 16
+ || sizeof (int) * __CHAR_BIT__ != 32)
+ return 0;
+ b.f1 = 56374;
+ unsigned short d;
+ int e = b.f2;
+ d = e == 0 ? b.f1 : 0;
+ c = foo (d);
+ if (c != (short) 56374)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58831.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58831.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58831.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58831.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,40 @@
+#include <assert.h>
+
+int a, *b, c, d, f, **i, p, q, *r;
+short o, j;
+
+static int __attribute__((noinline, noclone))
+fn1 (int *p1, int **p2)
+{
+ int **e = &b;
+ for (; p; p++)
+ *p1 = 1;
+ *e = *p2 = &d;
+
+ assert (r);
+
+ return c;
+}
+
+static int ** __attribute__((noinline, noclone))
+fn2 (void)
+{
+ for (f = 0; f != 42; f++)
+ {
+ int *g[3] = {0, 0, 0};
+ for (o = 0; o; o--)
+ for (; a > 1;)
+ {
+ int **h[1] = { &g[2] };
+ }
+ }
+ return &r;
+}
+
+int
+main (void)
+{
+ i = fn2 ();
+ fn1 (b, i);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58943.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58943.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58943.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58943.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* PR c/58943 */
+
+unsigned int x[1] = { 2 };
+
+unsigned int
+foo (void)
+{
+ x[0] |= 128;
+ return 1;
+}
+
+int
+main ()
+{
+ x[0] |= foo ();
+ if (x[0] != 131)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58984.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58984.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58984.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58984.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,57 @@
+/* PR tree-optimization/58984 */
+
+struct S { int f0 : 8; int : 6; int f1 : 5; };
+struct T { char f0; int : 6; int f1 : 5; };
+
+int a, *c = &a, e, n, b, m;
+
+static int
+foo (struct S p)
+{
+ const unsigned short *f[36];
+ for (; e < 2; e++)
+ {
+ const unsigned short **i = &f[0];
+ *c ^= 1;
+ if (p.f1)
+ {
+ *i = 0;
+ return b;
+ }
+ }
+ return 0;
+}
+
+static int
+bar (struct T p)
+{
+ const unsigned short *f[36];
+ for (; e < 2; e++)
+ {
+ const unsigned short **i = &f[0];
+ *c ^= 1;
+ if (p.f1)
+ {
+ *i = 0;
+ return b;
+ }
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ struct S o = { 1, 1 };
+ foo (o);
+ m = n || o.f0;
+ if (a != 1)
+ __builtin_abort ();
+ e = 0;
+ struct T p = { 1, 1 };
+ bar (p);
+ m |= n || p.f0;
+ if (a != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59014-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59014-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59014-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59014-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* PR tree-optimization/59014 */
+
+__attribute__((noinline, noclone)) long long int
+foo (long long int x, long long int y)
+{
+ if (((int) x | (int) y) != 0)
+ return 6;
+ return x + y;
+}
+
+int
+main ()
+{
+ if (sizeof (long long) == sizeof (int))
+ return 0;
+ int shift_half = sizeof (int) * __CHAR_BIT__ / 2;
+ long long int x = (3LL << shift_half) << shift_half;
+ long long int y = (5LL << shift_half) << shift_half;
+ long long int z = foo (x, y);
+ if (z != ((8LL << shift_half) << shift_half))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59014.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59014.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59014.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59014.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR tree-optimization/59014 */
+
+int a = 2, b, c, d;
+
+int
+foo ()
+{
+ for (;; c++)
+ if ((b > 0) | (a & 1))
+ ;
+ else
+ {
+ d = a;
+ return 0;
+ }
+}
+
+int
+main ()
+{
+ foo ();
+ if (d != 2)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59101.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59101.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59101.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59101.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+/* PR target/59101 */
+
+__attribute__((noinline, noclone)) int
+foo (int a)
+{
+ return (~a & 4102790424LL) > 0 | 6;
+}
+
+int
+main ()
+{
+ if (foo (0) != 7)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59221.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59221.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59221.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59221.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* { dg-xfail-if "ptxas crashes" { nvptx-*-* } { "*" } { "-O0" "-Os" } } */
+
+
+int a = 1, b, d;
+short e;
+
+int
+main ()
+{
+ for (; b; b++)
+ ;
+ short f = a;
+ int g = 15;
+ e = f ? f : 1 << g;
+ int h = e;
+ d = h == 83647 ? 0 : h;
+ if (d != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59229.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59229.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59229.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59229.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+int i;
+
+__attribute__((noinline, noclone)) void
+bar (char *p)
+{
+ if (i < 1 || i > 6)
+ __builtin_abort ();
+ if (__builtin_memcmp (p, "abcdefg", i + 1) != 0)
+ __builtin_abort ();
+ __builtin_memset (p, ' ', 7);
+}
+
+__attribute__((noinline, noclone)) void
+foo (char *p, unsigned long l)
+{
+ if (l < 1 || l > 6)
+ return;
+ char buf[7];
+ __builtin_memcpy (buf, p, l + 1);
+ bar (buf);
+}
+
+int
+main ()
+{
+ for (i = 0; i < 16; i++)
+ foo ("abcdefghijklmnop", i);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59358.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59358.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59358.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59358.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,44 @@
+/* PR tree-optimization/59358 */
+
+__attribute__((noinline, noclone)) int
+foo (int *x, int y)
+{
+ int z = *x;
+ if (y > z && y <= 16)
+ while (y > z)
+ z *= 2;
+ return z;
+}
+
+int
+main ()
+{
+ int i;
+ for (i = 1; i < 17; i++)
+ {
+ int j = foo (&i, 16);
+ int k;
+ if (i >= 8 && i <= 15)
+ k = 16 + (i - 8) * 2;
+ else if (i >= 4 && i <= 7)
+ k = 16 + (i - 4) * 4;
+ else if (i == 3)
+ k = 24;
+ else
+ k = 16;
+ if (j != k)
+ __builtin_abort ();
+ j = foo (&i, 7);
+ if (i >= 7)
+ k = i;
+ else if (i >= 4)
+ k = 8 + (i - 4) * 2;
+ else if (i == 3)
+ k = 12;
+ else
+ k = 8;
+ if (j != k)
+ __builtin_abort ();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59387.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59387.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59387.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59387.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* PR tree-optimization/59387 */
+
+int a, *d, **e = &d, f;
+char c;
+struct S { int f1; } b;
+
+int
+main ()
+{
+ for (a = -19; a; a++)
+ {
+ for (b.f1 = 0; b.f1 < 24; b.f1++)
+ c--;
+ *e = &f;
+ if (!d)
+ return 0;
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59388.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59388.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59388.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59388.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,11 @@
+/* PR tree-optimization/59388 */
+
+int a;
+struct S { unsigned int f:1; } b;
+
+int
+main ()
+{
+ a = (0 < b.f) | b.f;
+ return a;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59413.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59413.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59413.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59413.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR tree-optimization/59413 */
+
+typedef unsigned int uint32_t;
+
+uint32_t a;
+int b;
+
+int
+main ()
+{
+ uint32_t c;
+ for (a = 7; a <= 1; a++)
+ {
+ char d = a;
+ c = d;
+ b = a == c;
+ }
+ if (a != 7)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59643.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59643.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59643.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59643.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,39 @@
+/* PR tree-optimization/59643 */
+
+#define N 32
+
+__attribute__((noinline, noclone)) void
+foo (double *a, double *b, double *c, double d, double e, int n)
+{
+ int i;
+ for (i = 1; i < n - 1; i++)
+ a[i] = d * (b[i] + c[i] + a[i - 1] + a[i + 1]) + e * a[i];
+}
+
+double expected[] = {
+ 0.0, 10.0, 44.0, 110.0, 232.0, 490.0, 1020.0, 2078.0, 4152.0, 8314.0,
+ 16652.0, 33326.0, 66664.0, 133354.0, 266748.0, 533534.0, 1067064.0,
+ 2134138.0, 4268300.0, 8536622.0, 17073256.0, 34146538.0, 68293116.0,
+ 136586270.0, 273172536.0, 546345082.0, 1092690188.0, 2185380398.0,
+ 4370760808.0, 8741521642.0, 17483043324.0, 6.0
+};
+
+int
+main ()
+{
+ int i;
+ double a[N], b[N], c[N];
+ if (__DBL_MANT_DIG__ <= 35)
+ return 0;
+ for (i = 0; i < N; i++)
+ {
+ a[i] = (i & 3) * 2.0;
+ b[i] = (i & 7) - 4;
+ c[i] = i & 7;
+ }
+ foo (a, b, c, 2.0, 3.0, N);
+ for (i = 0; i < N; i++)
+ if (a[i] != expected[i])
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59747.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59747.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59747.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr59747.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+extern void abort (void);
+extern void exit (int);
+
+int a[6], c = 1, d;
+short e;
+
+int __attribute__ ((noinline))
+fn1 (int p)
+{
+ return a[p];
+}
+
+int
+main ()
+{
+ if (sizeof (long long) != 8)
+ exit (0);
+
+ a[0] = 1;
+ if (c)
+ e--;
+ d = e;
+ long long f = e;
+ if (fn1 ((f >> 56) & 1) != 0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60003.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60003.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60003.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60003.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,49 @@
+/* PR tree-optimization/60003 */
+/* { dg-require-effective-target indirect_jumps } */
+
+extern void abort (void);
+
+unsigned long long jmp_buf[5];
+
+__attribute__((noinline, noclone)) void
+baz (void)
+{
+ __builtin_longjmp (&jmp_buf, 1);
+}
+
+void
+bar (void)
+{
+ baz ();
+}
+
+__attribute__((noinline, noclone)) int
+foo (int x)
+{
+ int a = 0;
+
+ if (__builtin_setjmp (&jmp_buf) == 0)
+ {
+ while (1)
+ {
+ a = 1;
+ bar (); /* OK if baz () instead */
+ }
+ }
+ else
+ {
+ if (a == 0)
+ return 0;
+ else
+ return x;
+ }
+}
+
+int
+main ()
+{
+ if (foo (1) == 0)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60017.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60017.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60017.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60017.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+/* PR target/60017 */
+
+extern void abort (void);
+
+struct S0
+{
+ short m0;
+ short m1;
+};
+
+struct S1
+{
+ unsigned m0:1;
+ char m1[2][2];
+ struct S0 m2[2];
+};
+
+struct S1 x = { 1, {{2, 3}, {4, 5}}, {{6, 7}, {8, 9}} };
+
+struct S1 func (void)
+{
+ return x;
+}
+
+int main (void)
+{
+ struct S1 ret = func ();
+
+ if (ret.m2[1].m1 != 9)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60062.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60062.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60062.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60062.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR target/60062 */
+
+int a;
+
+static void
+foo (const char *p1, int p2)
+{
+ if (__builtin_strcmp (p1, "hello") != 0)
+ __builtin_abort ();
+}
+
+static void
+bar (const char *p1)
+{
+ if (__builtin_strcmp (p1, "hello") != 0)
+ __builtin_abort ();
+}
+
+__attribute__((optimize (0))) int
+main ()
+{
+ foo ("hello", a);
+ bar ("hello");
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60072.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60072.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60072.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60072.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+/* PR target/60072 */
+
+int c = 1;
+
+__attribute__ ((optimize (1)))
+static int *foo (int *p)
+{
+ return p;
+}
+
+int
+main ()
+{
+ *foo (&c) = 2;
+ return c - 2;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60454.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60454.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60454.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60454.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+#ifdef __UINT32_TYPE__
+typedef __UINT32_TYPE__ uint32_t;
+#else
+typedef unsigned uint32_t;
+#endif
+
+#define __fake_const_swab32(x) ((uint32_t)( \
+ (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
+ (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
+ (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 8) | \
+ (((uint32_t)(x) & (uint32_t)0x0000ff00UL) ) | \
+ (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
+
+/* Previous version of bswap optimization would detect byte swap when none
+ happen. This test aims at catching such wrong detection to avoid
+ regressions. */
+
+__attribute__ ((noinline, noclone)) uint32_t
+fake_swap32 (uint32_t in)
+{
+ return __fake_const_swab32 (in);
+}
+
+int main(void)
+{
+ if (sizeof (uint32_t) * __CHAR_BIT__ != 32)
+ return 0;
+ if (fake_swap32 (0x12345678UL) != 0x78567E12UL)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60822.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60822.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60822.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60822.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* { dg-require-effective-target int32plus } */
+struct X {
+ char fill0[800000];
+ int a;
+ char fill1[900000];
+ int b;
+};
+
+int __attribute__((noinline,noclone))
+Avg(struct X *p, int s)
+{
+ return (s * (long long)(p->a + p->b)) >> 17;
+}
+
+struct X x;
+
+int main()
+{
+ x.a = 1 << 17;
+ x.b = 2 << 17;
+ if (Avg(&x, 1) != 3)
+ __builtin_abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60960.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60960.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60960.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr60960.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+/* PR tree-optimization/60960 */
+
+typedef unsigned char v4qi __attribute__ ((vector_size (4)));
+
+__attribute__((noinline, noclone)) v4qi
+f1 (v4qi v)
+{
+ return v / 2;
+}
+
+__attribute__((noinline, noclone)) v4qi
+f2 (v4qi v)
+{
+ return v / (v4qi) { 2, 2, 2, 2 };
+}
+
+__attribute__((noinline, noclone)) v4qi
+f3 (v4qi x, v4qi y)
+{
+ return x / y;
+}
+
+int
+main ()
+{
+ v4qi x = { 5, 5, 5, 5 };
+ v4qi y = { 2, 2, 2, 2 };
+ v4qi z = f1 (x);
+ if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)
+ __builtin_abort ();
+ z = f2 (x);
+ if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)
+ __builtin_abort ();
+ z = f3 (x, y);
+ if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,39 @@
+#ifdef __INT32_TYPE__
+typedef __INT32_TYPE__ int32_t;
+#else
+typedef int int32_t;
+#endif
+
+#ifdef __UINT32_TYPE__
+typedef __UINT32_TYPE__ uint32_t;
+#else
+typedef unsigned uint32_t;
+#endif
+
+#define __fake_const_swab32(x) ((uint32_t)( \
+ (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
+ (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
+ (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
+ (( (int32_t)(x) & (int32_t)0xff000000UL) >> 24)))
+
+/* Previous version of bswap optimization failed to consider sign extension
+ and as a result would replace an expression *not* doing a bswap by a
+ bswap. */
+
+__attribute__ ((noinline, noclone)) uint32_t
+fake_bswap32 (uint32_t in)
+{
+ return __fake_const_swab32 (in);
+}
+
+int
+main(void)
+{
+ if (sizeof (int32_t) * __CHAR_BIT__ != 32)
+ return 0;
+ if (sizeof (uint32_t) * __CHAR_BIT__ != 32)
+ return 0;
+ if (fake_bswap32 (0x87654321) != 0xffffff87)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,40 @@
+#ifdef __INT16_TYPE__
+typedef __INT16_TYPE__ int16_t;
+#else
+typedef short int16_t;
+#endif
+
+#ifdef __UINT32_TYPE__
+typedef __UINT32_TYPE__ uint32_t;
+#else
+typedef unsigned uint32_t;
+#endif
+
+#define __fake_const_swab32(x) ((uint32_t)( \
+ (((uint32_t) (x) & (uint32_t)0x000000ffUL) << 24) | \
+ (((uint32_t)(int16_t)(x) & (uint32_t)0x00ffff00UL) << 8) | \
+ (((uint32_t) (x) & (uint32_t)0x00ff0000UL) >> 8) | \
+ (((uint32_t) (x) & (uint32_t)0xff000000UL) >> 24)))
+
+
+/* Previous version of bswap optimization failed to consider sign extension
+ and as a result would replace an expression *not* doing a bswap by a
+ bswap. */
+
+__attribute__ ((noinline, noclone)) uint32_t
+fake_bswap32 (uint32_t in)
+{
+ return __fake_const_swab32 (in);
+}
+
+int
+main(void)
+{
+ if (sizeof (uint32_t) * __CHAR_BIT__ != 32)
+ return 0;
+ if (sizeof (int16_t) * __CHAR_BIT__ != 16)
+ return 0;
+ if (fake_bswap32 (0x81828384) != 0xff838281)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61306-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+short a = -1;
+int b;
+char c;
+
+int
+main ()
+{
+ c = a;
+ b = a | c;
+ if (b != -1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61375.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61375.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61375.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61375.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+#ifdef __UINT64_TYPE__
+typedef __UINT64_TYPE__ uint64_t;
+#else
+typedef unsigned long long uint64_t;
+#endif
+
+#ifndef __SIZEOF_INT128__
+#define __int128 long long
+#endif
+
+/* Some version of bswap optimization would ICE when analyzing a mask constant
+ too big for an uint64_t variable (PR210931). */
+
+__attribute__ ((noinline, noclone)) uint64_t
+uint128_central_bitsi_ior (unsigned __int128 in1, uint64_t in2)
+{
+ __int128 mask = (__int128)0xffff << 56;
+ return ((in1 & mask) >> 56) | in2;
+}
+
+int
+main(int argc, char **argv)
+{
+ __int128 in = 1;
+#ifdef __SIZEOF_INT128__
+ in <<= 64;
+#endif
+ if (sizeof (uint64_t) * __CHAR_BIT__ != 64)
+ return 0;
+ if (sizeof (unsigned __int128) * __CHAR_BIT__ != 128)
+ return 0;
+ if (uint128_central_bitsi_ior (in, 2) != 0x102)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61517.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61517.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61517.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61517.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+int a, b, *c = &a;
+unsigned short d;
+
+int
+main ()
+{
+ unsigned int e = a;
+ *c = 1;
+ if (!b)
+ {
+ d = e;
+ *c = d | e;
+ }
+
+ if (a != 0)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61673.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61673.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61673.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61673.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,50 @@
+/* PR rtl-optimization/61673 */
+
+char e;
+
+__attribute__((noinline, noclone)) void
+bar (char x)
+{
+ if (x != 0x54 && x != (char) 0x87)
+ __builtin_abort ();
+}
+
+__attribute__((noinline, noclone)) void
+foo (const char *x)
+{
+ char d = x[0];
+ int c = d;
+ if ((c >= 0 && c <= 0x7f) == 0)
+ e = d;
+ bar (d);
+}
+
+__attribute__((noinline, noclone)) void
+baz (const char *x)
+{
+ char d = x[0];
+ int c = d;
+ if ((c >= 0 && c <= 0x7f) == 0)
+ e = d;
+}
+
+int
+main ()
+{
+ const char c[] = { 0x54, 0x87 };
+ e = 0x21;
+ foo (c);
+ if (e != 0x21)
+ __builtin_abort ();
+ foo (c + 1);
+ if (e != (char) 0x87)
+ __builtin_abort ();
+ e = 0x21;
+ baz (c);
+ if (e != 0x21)
+ __builtin_abort ();
+ baz (c + 1);
+ if (e != (char) 0x87)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61682.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61682.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61682.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61682.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+/* PR tree-optimization/61682 */
+
+int a, b;
+static int *c = &b;
+
+int
+main ()
+{
+ int *d = &a;
+ for (a = 0; a < 12; a++)
+ *c |= *d / 9;
+
+ if (b != 1)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61725.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61725.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61725.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr61725.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+/* PR tree-optimization/61725 */
+
+int
+main ()
+{
+ int x;
+ for (x = -128; x <= 128; x++)
+ {
+ int a = __builtin_ffs (x);
+ if (x == 0 && a != 0)
+ __builtin_abort ();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr62151.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr62151.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr62151.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr62151.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+/* PR rtl-optimization/62151 */
+
+int a, c, d, e, f, g, h, i;
+short b;
+
+int
+fn1 ()
+{
+ b = 0;
+ for (;;)
+ {
+ int j[2];
+ j[f] = 0;
+ if (h)
+ d = 0;
+ else
+ {
+ for (; f; f++)
+ ;
+ for (a = 0; a < 1; a++)
+ for (;;)
+ {
+ i = b & ((b ^ 1) & 83647) ? b : b - 1;
+ g = 1 ? i : 0;
+ e = j[0];
+ if (c)
+ break;
+ return 0;
+ }
+ }
+ }
+}
+
+int
+main ()
+{
+ fn1 ();
+ if (g != -1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63209.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63209.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63209.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63209.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+static int Sub(int a, int b) {
+ return b -a;
+}
+
+static unsigned Select(unsigned a, unsigned b, unsigned c) {
+ const int pa_minus_pb =
+ Sub((a >> 8) & 0xff, (b >> 8) & 0xff) +
+ Sub((a >> 0) & 0xff, (b >> 0) & 0xff);
+ return (pa_minus_pb <= 0) ? a : b;
+}
+
+__attribute__((noinline)) unsigned Predictor(unsigned left, const unsigned* const top) {
+ const unsigned pred = Select(top[1], left, top[0]);
+ return pred;
+}
+
+int main(void) {
+ const unsigned top[2] = {0xff7a7a7a, 0xff7a7a7a};
+ const unsigned left = 0xff7b7b7b;
+ const unsigned pred = Predictor(left, top /*+ 1*/);
+ if (pred == left)
+ return 0;
+ return 1;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63302.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63302.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63302.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63302.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,60 @@
+/* PR tree-optimization/63302 */
+
+#ifdef __SIZEOF_INT128__
+#if __SIZEOF_INT128__ * __CHAR_BIT__ == 128
+#define USE_INT128
+#endif
+#endif
+#if __SIZEOF_LONG_LONG__ * __CHAR_BIT__ == 64
+#define USE_LLONG
+#endif
+
+#ifdef USE_INT128
+__attribute__((noinline, noclone)) int
+foo (__int128 x)
+{
+ __int128 v = x & (((__int128) -1 << 63) | 0x7ff);
+
+ return v == 0 || v == ((__int128) -1 << 63);
+}
+#endif
+
+#ifdef USE_LLONG
+__attribute__((noinline, noclone)) int
+bar (long long x)
+{
+ long long v = x & (((long long) -1 << 31) | 0x7ff);
+
+ return v == 0 || v == ((long long) -1 << 31);
+}
+#endif
+
+int
+main ()
+{
+#ifdef USE_INT128
+ if (foo (0) != 1
+ || foo (1) != 0
+ || foo (0x800) != 1
+ || foo (0x801) != 0
+ || foo ((__int128) 1 << 63) != 0
+ || foo ((__int128) -1 << 63) != 1
+ || foo (((__int128) -1 << 63) | 1) != 0
+ || foo (((__int128) -1 << 63) | 0x800) != 1
+ || foo (((__int128) -1 << 63) | 0x801) != 0)
+ __builtin_abort ();
+#endif
+#ifdef USE_LLONG
+ if (bar (0) != 1
+ || bar (1) != 0
+ || bar (0x800) != 1
+ || bar (0x801) != 0
+ || bar (1LL << 31) != 0
+ || bar (-1LL << 31) != 1
+ || bar ((-1LL << 31) | 1) != 0
+ || bar ((-1LL << 31) | 0x800) != 1
+ || bar ((-1LL << 31) | 0x801) != 0)
+ __builtin_abort ();
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63641.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63641.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63641.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63641.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,54 @@
+/* PR tree-optimization/63641 */
+
+__attribute__ ((noinline, noclone)) int
+foo (unsigned char b)
+{
+ if (0x0 <= b && b <= 0x8)
+ goto lab;
+ if (b == 0x0b)
+ goto lab;
+ if (0x0e <= b && b <= 0x1a)
+ goto lab;
+ if (0x1c <= b && b <= 0x1f)
+ goto lab;
+ return 0;
+lab:
+ return 1;
+}
+
+__attribute__ ((noinline, noclone)) int
+bar (unsigned char b)
+{
+ if (0x0 <= b && b <= 0x8)
+ goto lab;
+ if (b == 0x0b)
+ goto lab;
+ if (0x0e <= b && b <= 0x1a)
+ goto lab;
+ if (0x3c <= b && b <= 0x3f)
+ goto lab;
+ return 0;
+lab:
+ return 1;
+}
+
+char tab1[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 };
+char tab2[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 };
+
+int
+main ()
+{
+ int i;
+ asm volatile ("" : : : "memory");
+ for (i = 0; i < 256; i++)
+ if (foo (i) != (i < 32 ? tab1[i] : 0))
+ __builtin_abort ();
+ for (i = 0; i < 256; i++)
+ if (bar (i) != (i < 64 ? tab2[i] : 0))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63659.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63659.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63659.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63659.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+/* PR rtl-optimization/63659 */
+
+int a, b, c, *d = &b, g, h, i;
+unsigned char e;
+char f;
+
+int
+main ()
+{
+ while (a)
+ {
+ for (a = 0; a; a++)
+ for (; c; c++)
+ ;
+ if (i)
+ break;
+ }
+
+ char j = c, k = -1, l;
+ l = g = j >> h;
+ f = l == 0 ? k : k % l;
+ e = 0 ? 0 : f;
+ *d = e;
+
+ if (b != 255)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63843.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63843.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63843.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr63843.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+/* PR rtl-optimization/63843 */
+
+static inline __attribute__ ((always_inline))
+unsigned short foo (unsigned short v)
+{
+ return (v << 8) | (v >> 8);
+}
+
+unsigned short __attribute__ ((noinline, noclone, hot))
+bar (unsigned char *x)
+{
+ unsigned int a;
+ unsigned short b;
+ __builtin_memcpy (&a, &x[0], sizeof (a));
+ a ^= 0x80808080U;
+ __builtin_memcpy (&x[0], &a, sizeof (a));
+ __builtin_memcpy (&b, &x[2], sizeof (b));
+ return foo (b);
+}
+
+int
+main ()
+{
+ unsigned char x[8] = { 0x01, 0x01, 0x01, 0x01 };
+ if (__CHAR_BIT__ == 8
+ && sizeof (short) == 2
+ && sizeof (int) == 4
+ && bar (x) != 0x8181U)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64006.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64006.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64006.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64006.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* PR tree-optimization/64006 */
+
+int v;
+
+long __attribute__ ((noinline, noclone))
+test (long *x, int y)
+{
+ int i;
+ long s = 1;
+ for (i = 0; i < y; i++)
+ if (__builtin_mul_overflow (s, x[i], &s))
+ v++;
+ return s;
+}
+
+int
+main ()
+{
+ long d[7] = { 975, 975, 975, 975, 975, 975, 975 };
+ long r = test (d, 7);
+ if (sizeof (long) * __CHAR_BIT__ == 64 && v != 1)
+ __builtin_abort ();
+ else if (sizeof (long) * __CHAR_BIT__ == 32 && v != 4)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64242.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64242.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64242.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64242.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,37 @@
+/* { dg-require-effective-target indirect_jumps } */
+
+extern void abort (void);
+
+__attribute ((noinline)) void
+broken_longjmp (void *p)
+{
+ void *buf[32];
+ __builtin_memcpy (buf, p, 5 * sizeof (void*));
+ __builtin_memset (p, 0, 5 * sizeof (void*));
+ /* Corrupts stack pointer... */
+ __builtin_longjmp (buf, 1);
+}
+
+volatile int x = 0;
+char *volatile p;
+char *volatile q;
+
+int
+main ()
+{
+ void *buf[5];
+ p = __builtin_alloca (x);
+ q = __builtin_alloca (x);
+ if (!__builtin_setjmp (buf))
+ broken_longjmp (buf);
+
+ /* Compute expected next alloca offset - some targets don't align properly
+ and allocate too much. */
+ p = q + (q - p);
+
+ /* Fails if stack pointer corrupted. */
+ if (p != __builtin_alloca (x))
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64255.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64255.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64255.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64255.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* PR rtl-optimization/64255 */
+
+__attribute__((noinline, noclone)) void
+bar (long i, unsigned long j)
+{
+ if (i != 1 || j != 1)
+ __builtin_abort ();
+}
+
+__attribute__((noinline, noclone)) void
+foo (long i)
+{
+ unsigned long j;
+
+ if (!i)
+ return;
+ j = i >= 0 ? (unsigned long) i : - (unsigned long) i;
+ if ((i >= 0 ? (unsigned long) i : - (unsigned long) i) != j)
+ __builtin_abort ();
+ bar (i, j);
+}
+
+int
+main ()
+{
+ foo (1);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64260.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64260.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64260.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64260.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/64260 */
+
+int a = 1, b;
+
+void
+foo (char p)
+{
+ int t = 0;
+ for (; b < 1; b++)
+ {
+ int *s = &a;
+ if (--t)
+ *s &= p;
+ *s &= 1;
+ }
+}
+
+int
+main ()
+{
+ foo (0);
+ if (a != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64682.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64682.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64682.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64682.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* PR rtl-optimization/64682 */
+
+int a, b = 1;
+
+__attribute__((noinline, noclone)) void
+foo (int x)
+{
+ if (x != 5)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 56; i++)
+ for (; a; a--)
+ ;
+ int *c = &b;
+ if (*c)
+ *c = 1 % (unsigned int) *c | 5;
+
+ foo (b);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64718.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64718.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64718.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64718.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+static int __attribute__ ((noinline, noclone))
+swap (int x)
+{
+ return (unsigned short) ((unsigned short) x << 8 | (unsigned short) x >> 8);
+}
+
+static int a = 0x1234;
+
+int
+main (void)
+{
+ int b = 0x1234;
+ if (swap (a) != 0x3412)
+ __builtin_abort ();
+ if (swap (b) != 0x3412)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64756.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64756.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64756.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64756.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* PR rtl-optimization/64756 */
+
+int a, *tmp, **c = &tmp;
+volatile int d;
+static int *volatile *e = &tmp;
+unsigned int f;
+
+static void
+fn1 (int *p)
+{
+ int g;
+ for (; f < 1; f++)
+ for (g = 1; g >= 0; g--)
+ {
+ d || d;
+ *c = p;
+
+ if (tmp != &a)
+ __builtin_abort ();
+
+ *e = 0;
+ }
+}
+
+int
+main ()
+{
+ fn1 (&a);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64957.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64957.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64957.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64957.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* PR rtl-optimization/64957 */
+
+__attribute__((noinline, noclone)) int
+foo (int b)
+{
+ return (((b ^ 5) | 1) ^ 5) | 1;
+}
+
+__attribute__((noinline, noclone)) int
+bar (int b)
+{
+ return (((b ^ ~5) & ~1) ^ ~5) & ~1;
+}
+
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 16; i++)
+ if (foo (i) != (i | 1) || bar (i) != (i & ~1))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64979.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64979.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64979.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr64979.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+/* PR target/64979 */
+
+#include <stdarg.h>
+
+void __attribute__((noinline, noclone))
+bar (int x, va_list *ap)
+{
+ if (ap)
+ {
+ int i;
+ for (i = 0; i < 10; i++)
+ if (i != va_arg (*ap, int))
+ __builtin_abort ();
+ if (va_arg (*ap, double) != 0.5)
+ __builtin_abort ();
+ }
+}
+
+void __attribute__((noinline, noclone))
+foo (int x, ...)
+{
+ va_list ap;
+ int n;
+
+ va_start (ap, x);
+ n = va_arg (ap, int);
+ bar (x, (va_list *) ((n == 0) ? ((void *) 0) : &ap));
+ va_end (ap);
+}
+
+int
+main ()
+{
+ foo (100, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0.5);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65053-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65053-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65053-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65053-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+/* PR tree-optimization/65053 */
+
+int i;
+
+__attribute__ ((noinline, noclone))
+unsigned int foo (void)
+{
+ return 0;
+}
+
+int
+main ()
+{
+ unsigned int u = -1;
+ if (u == -1)
+ {
+ unsigned int n = foo ();
+ if (n > 0)
+ u = n - 1;
+ }
+
+ while (u != -1)
+ {
+ asm ("" : "+g" (u));
+ u = -1;
+ i = 1;
+ }
+
+ if (i)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65053-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65053-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65053-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65053-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+/* PR tree-optimization/65053 */
+
+int i;
+unsigned int x;
+
+int
+main ()
+{
+ asm volatile ("" : "+g" (x));
+ unsigned int n = x;
+ unsigned int u = 32;
+ if (n >= 32)
+ __builtin_abort ();
+ if (n != 0)
+ u = n + 32;
+
+ while (u != 32)
+ {
+ asm ("" : : "g" (u));
+ u = 32;
+ i = 1;
+ }
+
+ if (i)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65170.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65170.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65170.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65170.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+/* PR tree-optimization/65170 */
+
+#ifdef __SIZEOF_INT128__
+typedef unsigned __int128 V;
+typedef unsigned long long int H;
+#else
+typedef unsigned long long int V;
+typedef unsigned int H;
+#endif
+
+__attribute__((noinline, noclone)) void
+foo (V b, V c)
+{
+ V a;
+ b &= (H) -1;
+ c &= (H) -1;
+ a = b * c;
+ if (a != 1)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ foo (1, 1);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* PR tree-optimization/65215 */
+
+static inline unsigned int
+foo (unsigned int x)
+{
+ return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);
+}
+
+__attribute__((noinline, noclone)) unsigned int
+bar (unsigned long long *x)
+{
+ return foo (*x);
+}
+
+int
+main ()
+{
+ if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)
+ return 0;
+ unsigned long long l = foo (0xdeadbeefU) | 0xfeedbea800000000ULL;
+ if (bar (&l) != 0xdeadbeefU)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* PR tree-optimization/65215 */
+
+static inline unsigned int
+foo (unsigned int x)
+{
+ return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);
+}
+
+__attribute__((noinline, noclone)) unsigned long long
+bar (unsigned long long *x)
+{
+ return ((unsigned long long) foo (*x) << 32) | foo (*x >> 32);
+}
+
+int
+main ()
+{
+ if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)
+ return 0;
+ unsigned long long l = foo (0xfeedbea8U) | ((unsigned long long) foo (0xdeadbeefU) << 32);
+ if (bar (&l) != 0xfeedbea8deadbeefULL)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+/* PR tree-optimization/65215 */
+
+struct S { unsigned long long l1 : 24, l2 : 8, l3 : 32; };
+
+static inline unsigned int
+foo (unsigned int x)
+{
+ return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);
+}
+
+__attribute__((noinline, noclone)) unsigned long long
+bar (struct S *x)
+{
+ unsigned long long x1 = foo (((unsigned int) x->l1 << 8) | x->l2);
+ unsigned long long x2 = foo (x->l3);
+ return (x2 << 32) | x1;
+}
+
+int
+main ()
+{
+ if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)
+ return 0;
+ struct S s = { 0xdeadbeU, 0xefU, 0xfeedbea8U };
+ unsigned long long l = bar (&s);
+ if (foo (l >> 32) != s.l3
+ || (foo (l) >> 8) != s.l1
+ || (foo (l) & 0xff) != s.l2)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+/* PR tree-optimization/65215 */
+
+struct S { unsigned long long l1 : 48; };
+
+static inline unsigned int
+foo (unsigned int x)
+{
+ return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);
+}
+
+__attribute__((noinline, noclone)) unsigned int
+bar (struct S *x)
+{
+ return foo (x->l1);
+}
+
+int
+main ()
+{
+ if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)
+ return 0;
+ struct S s;
+ s.l1 = foo (0xdeadbeefU) | (0xfeedULL << 32);
+ if (bar (&s) != 0xdeadbeefU)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65215-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+/* PR tree-optimization/65215 */
+
+__attribute__((noinline, noclone)) unsigned int
+foo (unsigned char *p)
+{
+ return ((unsigned int) p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+}
+
+__attribute__((noinline, noclone)) unsigned int
+bar (unsigned char *p)
+{
+ return ((unsigned int) p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
+}
+
+struct S { unsigned int a; unsigned char b[5]; };
+
+int
+main ()
+{
+ struct S s = { 1, { 2, 3, 4, 5, 6 } };
+ if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4)
+ return 0;
+ if (foo (&s.b[1]) != 0x03040506U
+ || bar (&s.b[1]) != 0x06050403U)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65216.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65216.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65216.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65216.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* PR tree-optimization/65216 */
+
+int a, b = 62, e;
+volatile int c, d;
+
+int
+main ()
+{
+ int f = 0;
+ for (a = 0; a < 2; a++)
+ {
+ b &= (8 ^ f) & 1;
+ for (e = 0; e < 6; e++)
+ if (c)
+ f = d;
+ }
+ if (b != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65369.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65369.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65369.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65369.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,46 @@
+/* PR tree-optimization/65369 */
+#include <stdint.h>
+
+static const char data[] =
+ "12345678901234567890123456789012345678901234567890"
+ "123456789012345678901234567890";
+
+__attribute__ ((noinline))
+static void foo (const unsigned int *buf)
+{
+ if (__builtin_memcmp (buf, data, 64))
+ __builtin_abort ();
+}
+
+__attribute__ ((noinline))
+static void bar (const unsigned char *block)
+{
+ uint32_t buf[16];
+ __builtin_memcpy (buf + 0, block + 0, 4);
+ __builtin_memcpy (buf + 1, block + 4, 4);
+ __builtin_memcpy (buf + 2, block + 8, 4);
+ __builtin_memcpy (buf + 3, block + 12, 4);
+ __builtin_memcpy (buf + 4, block + 16, 4);
+ __builtin_memcpy (buf + 5, block + 20, 4);
+ __builtin_memcpy (buf + 6, block + 24, 4);
+ __builtin_memcpy (buf + 7, block + 28, 4);
+ __builtin_memcpy (buf + 8, block + 32, 4);
+ __builtin_memcpy (buf + 9, block + 36, 4);
+ __builtin_memcpy (buf + 10, block + 40, 4);
+ __builtin_memcpy (buf + 11, block + 44, 4);
+ __builtin_memcpy (buf + 12, block + 48, 4);
+ __builtin_memcpy (buf + 13, block + 52, 4);
+ __builtin_memcpy (buf + 14, block + 56, 4);
+ __builtin_memcpy (buf + 15, block + 60, 4);
+ foo (buf);
+}
+
+int
+main ()
+{
+ unsigned char input[sizeof data + 16] __attribute__((aligned (16)));
+ __builtin_memset (input, 0, sizeof input);
+ __builtin_memcpy (input + 1, data, sizeof data);
+ bar (input + 1);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65401.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65401.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65401.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65401.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,59 @@
+/* PR rtl-optimization/65401 */
+
+struct S { unsigned short s[64]; };
+
+__attribute__((noinline, noclone)) void
+foo (struct S *x)
+{
+ unsigned int i;
+ unsigned char *s;
+
+ s = (unsigned char *) x->s;
+ for (i = 0; i < 64; i++)
+ x->s[i] = s[i * 2] | (s[i * 2 + 1] << 8);
+}
+
+__attribute__((noinline, noclone)) void
+bar (struct S *x)
+{
+ unsigned int i;
+ unsigned char *s;
+
+ s = (unsigned char *) x->s;
+ for (i = 0; i < 64; i++)
+ x->s[i] = (s[i * 2] << 8) | s[i * 2 + 1];
+}
+
+int
+main ()
+{
+ unsigned int i;
+ struct S s;
+ if (sizeof (unsigned short) != 2)
+ return 0;
+ for (i = 0; i < 64; i++)
+ s.s[i] = i + ((64 - i) << 8);
+ foo (&s);
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ for (i = 0; i < 64; i++)
+ if (s.s[i] != (64 - i) + (i << 8))
+ __builtin_abort ();
+#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ for (i = 0; i < 64; i++)
+ if (s.s[i] != i + ((64 - i) << 8))
+ __builtin_abort ();
+#endif
+ for (i = 0; i < 64; i++)
+ s.s[i] = i + ((64 - i) << 8);
+ bar (&s);
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ for (i = 0; i < 64; i++)
+ if (s.s[i] != (64 - i) + (i << 8))
+ __builtin_abort ();
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ for (i = 0; i < 64; i++)
+ if (s.s[i] != i + ((64 - i) << 8))
+ __builtin_abort ();
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65418-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65418-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65418-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65418-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* PR tree-optimization/65418 */
+
+__attribute__((noinline, noclone)) int
+foo (int x)
+{
+ if (x == -216 || x == -132 || x == -218 || x == -146)
+ return 1;
+ return 0;
+}
+
+int
+main ()
+{
+ volatile int i;
+ for (i = -230; i < -120; i++)
+ if (foo (i) != (i == -216 || i == -132 || i == -218 || i == -146))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65418-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65418-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65418-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65418-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* PR tree-optimization/65418 */
+
+__attribute__((noinline, noclone)) int
+foo (int x)
+{
+ if (x == -216 || x == -211 || x == -218 || x == -205 || x == -223)
+ return 1;
+ return 0;
+}
+
+int
+main ()
+{
+ volatile int i;
+ for (i = -230; i < -200; i++)
+ if (foo (i) != (i == -216 || i == -211 || i == -218 || i == -205 || i == -223))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65427.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65427.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65427.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65427.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,34 @@
+/* PR tree-optimization/65427 */
+
+typedef int V __attribute__ ((vector_size (8 * sizeof (int))));
+V a, b, c, d, e, f;
+
+__attribute__((noinline, noclone)) void
+foo (int x, int y)
+{
+ do
+ {
+ if (x)
+ d = a ^ c;
+ else
+ d = a ^ b;
+ }
+ while (y);
+}
+
+int
+main ()
+{
+ a = (V) { 1, 2, 3, 4, 5, 6, 7, 8 };
+ b = (V) { 0x40, 0x80, 0x40, 0x80, 0x40, 0x80, 0x40, 0x80 };
+ e = (V) { 0x41, 0x82, 0x43, 0x84, 0x45, 0x86, 0x47, 0x88 };
+ foo (0, 0);
+ if (__builtin_memcmp (&d, &e, sizeof (V)) != 0)
+ __builtin_abort ();
+ c = (V) { 0x80, 0x40, 0x80, 0x40, 0x80, 0x40, 0x80, 0x40 };
+ f = (V) { 0x81, 0x42, 0x83, 0x44, 0x85, 0x46, 0x87, 0x48 };
+ foo (1, 0);
+ if (__builtin_memcmp (&d, &f, sizeof (V)) != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65648.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65648.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65648.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65648.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,34 @@
+/* PR target/65648 */
+
+int a = 0, *b = 0, c = 0;
+static int d = 0;
+short e = 1;
+static long long f = 0;
+long long *i = &f;
+unsigned char j = 0;
+
+__attribute__((noinline, noclone)) void
+foo (int x, int *y)
+{
+ asm volatile ("" : : "r" (x), "r" (y) : "memory");
+}
+
+__attribute__((noinline, noclone)) void
+bar (const char *x, long long y)
+{
+ asm volatile ("" : : "r" (x), "r" (&y) : "memory");
+ if (y != 0)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ int k = 0;
+ b = &k;
+ j = (!a) - (c <= e);
+ *i = j;
+ foo (a, &k);
+ bar ("", f);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65956.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65956.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65956.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr65956.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,67 @@
+/* PR target/65956 */
+
+struct A { char *a; int b; long long c; };
+char v[3];
+
+__attribute__((noinline, noclone)) void
+fn1 (char *x, char *y)
+{
+ if (x != &v[1] || y != &v[2])
+ __builtin_abort ();
+ v[1]++;
+}
+
+__attribute__((noinline, noclone)) int
+fn2 (char *x)
+{
+ asm volatile ("" : "+g" (x) : : "memory");
+ return x == &v[0];
+}
+
+__attribute__((noinline, noclone)) void
+fn3 (const char *x)
+{
+ if (x[0] != 0)
+ __builtin_abort ();
+}
+
+static struct A
+foo (const char *x, struct A y, struct A z)
+{
+ struct A r = { 0, 0, 0 };
+ if (y.b && z.b)
+ {
+ if (fn2 (y.a) && fn2 (z.a))
+ switch (x[0])
+ {
+ case '|':
+ break;
+ default:
+ fn3 (x);
+ }
+ fn1 (y.a, z.a);
+ }
+ return r;
+}
+
+__attribute__((noinline, noclone)) int
+bar (int x, struct A *y)
+{
+ switch (x)
+ {
+ case 219:
+ foo ("+", y[-2], y[0]);
+ case 220:
+ foo ("-", y[-2], y[0]);
+ }
+}
+
+int
+main ()
+{
+ struct A a[3] = { { &v[1], 1, 1LL }, { &v[0], 0, 0LL }, { &v[2], 2, 2LL } };
+ bar (220, a + 2);
+ if (v[1] != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66187.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66187.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66187.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66187.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+/* PR tree-optimization/66187 */
+
+int a = 1, e = -1;
+short b, f;
+
+int
+main ()
+{
+ f = e;
+ int g = b < 0 ? 0 : f + b;
+ if ((g & -4) < 0)
+ a = 0;
+ if (a)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66233.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66233.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66233.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66233.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* PR tree-optimization/66233 */
+
+unsigned int v[8];
+
+__attribute__((noinline, noclone)) void
+foo (void)
+{
+ int i;
+ for (i = 0; i < 8; i++)
+ v[i] = (float) i;
+}
+
+int
+main ()
+{
+ unsigned int i;
+ foo ();
+ for (i = 0; i < 8; i++)
+ if (v[i] != i)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66556.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66556.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66556.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66556.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,53 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+extern void abort (void);
+
+struct {
+ unsigned f2;
+ unsigned f3 : 15;
+ unsigned f5 : 3;
+ short f6;
+} b = {0x7f8000, 6, 5, 0}, g = {8, 0, 5, 0};
+
+short d, l;
+int a, c, h = 8;
+volatile char e[237] = {4};
+short *f = &d;
+short i[5] = {3};
+char j;
+int *k = &c;
+
+int
+fn1 (unsigned p1) { return -p1; }
+
+void
+fn2 (char p1)
+{
+ a = p1;
+ e[0];
+}
+
+short
+fn3 ()
+{
+ *k = 4;
+ return *f;
+}
+
+int
+main ()
+{
+
+ unsigned m;
+ short *n = &i[4];
+
+ m = fn1 ((h && j) <= b.f5);
+ l = m > g.f3;
+ *n = 3;
+ fn2 (b.f2 >> 15);
+ if ((a & 0xff) != 0xff)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66757.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66757.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66757.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66757.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+/* PR tree-optimization/66757 */
+/* Testcase by Zhendong Su <su at cs.ucdavis.edu> */
+
+int a, b;
+
+int
+main (void)
+{
+ unsigned int t = (unsigned char) (~b);
+
+ if ((t ^ 1) / 255)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66940.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66940.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66940.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr66940.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+long long __attribute__ ((noinline, noclone))
+foo (long long ival)
+{
+ if (ival <= 0)
+ return -0x7fffffffffffffffL - 1;
+
+ return 0x7fffffffffffffffL;
+}
+
+int
+main (void)
+{
+ if (foo (-1) != (-0x7fffffffffffffffL - 1))
+ __builtin_abort ();
+
+ if (foo (1) != 0x7fffffffffffffffL)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67037.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67037.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67037.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67037.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,49 @@
+long (*extfunc)();
+
+static inline void lstrcpynW( short *d, const short *s, int n )
+{
+ unsigned int count = n;
+
+ while ((count > 1) && *s)
+ {
+ count--;
+ *d++ = *s++;
+ }
+ if (count) *d = 0;
+}
+
+int __attribute__((noinline,noclone))
+badfunc(int u0, int u1, int u2, int u3,
+ short *fsname, unsigned int fsname_len)
+{
+ static const short ntfsW[] = {'N','T','F','S',0};
+ char superblock[2048+3300];
+ int ret = 0;
+ short *p;
+
+ if (extfunc())
+ return 0;
+ p = (void *)extfunc();
+ if (p != 0)
+ goto done;
+
+ extfunc(superblock);
+
+ lstrcpynW(fsname, ntfsW, fsname_len);
+
+ ret = 1;
+done:
+ return ret;
+}
+
+static long f()
+{
+ return 0;
+}
+
+int main()
+{
+ short buf[6];
+ extfunc = f;
+ return !badfunc(0, 0, 0, 0, buf, 6);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67226.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67226.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67226.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67226.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,42 @@
+struct assembly_operand
+{
+ int type, value, symtype, symflags, marker;
+};
+
+struct assembly_operand to_input, from_input;
+
+void __attribute__ ((__noinline__, __noclone__))
+assemblez_1 (int internal_number, struct assembly_operand o1)
+{
+ if (o1.type != from_input.type)
+ __builtin_abort ();
+}
+
+void __attribute__ ((__noinline__, __noclone__))
+t0 (struct assembly_operand to, struct assembly_operand from)
+{
+ if (to.value == 0)
+ assemblez_1 (32, from);
+ else
+ __builtin_abort ();
+}
+
+int
+main (void)
+{
+ to_input.value = 0;
+ to_input.type = 1;
+ to_input.symtype = 2;
+ to_input.symflags = 3;
+ to_input.marker = 4;
+
+ from_input.value = 5;
+ from_input.type = 6;
+ from_input.symtype = 7;
+ from_input.symflags = 8;
+ from_input.marker = 9;
+
+ t0 (to_input, from_input);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67714.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67714.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67714.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67714.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+unsigned int b;
+int c;
+
+signed char
+fn1 ()
+{
+ signed char d;
+ for (int i = 0; i < 1; i++)
+ d = -15;
+ return d;
+}
+
+int
+main (void)
+{
+ for (c = 0; c < 1; c++)
+ b = 0;
+ char e = fn1 ();
+ signed char f = e ^ b;
+ volatile int g = (int) f;
+
+ if (g != -15)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67781.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67781.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67781.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67781.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+/* { dg-require-effective-target int32plus } */
+#ifdef __UINT32_TYPE__
+typedef __UINT32_TYPE__ uint32_t;
+#else
+typedef unsigned uint32_t;
+#endif
+
+#ifdef __UINT8_TYPE__
+typedef __UINT8_TYPE__ uint8_t;
+#else
+typedef unsigned char uint8_t;
+#endif
+
+struct
+{
+ uint32_t a;
+ uint8_t b;
+} s = { 0x123456, 0x78 };
+
+int pr67781()
+{
+ uint32_t c = (s.a << 8) | s.b;
+ return c;
+}
+
+int
+main ()
+{
+ if (sizeof (uint32_t) * __CHAR_BIT__ != 32)
+ return 0;
+
+ if (pr67781 () != 0x12345678)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67929_1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67929_1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67929_1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr67929_1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+int __attribute__ ((noinline, noclone))
+foo (float a)
+{
+ return a * 4.9f;
+}
+
+
+int
+main (void)
+{
+ if (foo (10.0f) != 49)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68143_1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68143_1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68143_1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68143_1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+#define NULL 0
+
+struct stuff
+{
+ int a;
+ int b;
+ int c;
+ int d;
+ int e;
+ char *f;
+ int g;
+};
+
+void __attribute__ ((noinline))
+bar (struct stuff *x)
+{
+ if (x->g != 2)
+ __builtin_abort ();
+}
+
+int
+main (int argc, char** argv)
+{
+ struct stuff x = {0, 0, 0, 0, 0, NULL, 0};
+ x.a = 100;
+ x.d = 100;
+ x.g = 2;
+ /* Struct should now look like {100, 0, 0, 100, 0, 0, 0, 2}. */
+ bar (&x);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68185.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68185.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68185.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68185.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+/* { dg-skip-if "ptxas crashes or executes incorrectly" { nvptx-*-* } { "-O0" "-Os" } { "" } } Reported 2015-11-20 */
+
+int a, b, d = 1, e, f, o, u, w = 1, z;
+short c, q, t;
+
+int
+main ()
+{
+ char g;
+ for (; d; d--)
+ {
+ while (o)
+ for (; e;)
+ {
+ c = b;
+ int h = o = z;
+ for (; u;)
+ for (; a;)
+ ;
+ }
+ if (t < 1)
+ g = w;
+ f = g;
+ g && (q = 1);
+ }
+
+ if (q != 1)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68249.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68249.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68249.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68249.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+/* PR rtl-optimization/68249 */
+
+int a, b, c, g, k, l, m, n;
+char h;
+
+void
+fn1 ()
+{
+ for (; k; k++)
+ {
+ m = b || c < 0 || c > 1 ? : c;
+ g = l = n || m < 0 || (m > 1) > 1 >> m ? : 1 << m;
+ }
+ l = b + 1;
+ for (; b < 1; b++)
+ h = a + 1;
+}
+
+int
+main ()
+{
+ char j;
+ for (; a < 1; a++)
+ {
+ fn1 ();
+ if (h)
+ j = h;
+ if (j > c)
+ g = 0;
+ }
+
+ if (h != 1)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68250.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68250.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68250.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68250.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,40 @@
+/* PR rtl-optimization/68250 */
+
+signed char a, b, h, k, l, m, o;
+short c, d, n;
+int e, f, g, j, q;
+
+void
+fn1 (void)
+{
+ int p = b || a;
+ n = o > 0 || d > 1 >> o ? d : d << o;
+ for (; j; j++)
+ m = c < 0 || m || c << p;
+ l = f + 1;
+ for (; f < 1; f = 1)
+ k = h + 1;
+}
+
+__attribute__((noinline, noclone)) void
+fn2 (int k)
+{
+ if (k != 1)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ signed char i;
+ for (; e < 1; e++)
+ {
+ fn1 ();
+ if (k)
+ i = k;
+ if (i > q)
+ g = 0;
+ }
+ fn2 (k);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68321.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68321.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68321.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68321.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+/* PR rtl-optimization/68321 */
+
+int e = 1, u = 5, t2, t5, i, k;
+int a[1], b, m;
+char n, t;
+
+int
+fn1 (int p1)
+{
+ int g[1];
+ for (;;)
+ {
+ if (p1 / 3)
+ for (; t5;)
+ u || n;
+ t2 = p1 & 4;
+ if (b + 1)
+ return 0;
+ u = g[0];
+ }
+}
+
+int
+main ()
+{
+ for (; e >= 0; e--)
+ {
+ char c;
+ if (!m)
+ c = t;
+ fn1 (c);
+ }
+
+ if (a[t2] != 0)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68328.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68328.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68328.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68328.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,44 @@
+int a, b, c = 1, d = 1, e;
+
+__attribute__ ((noinline, noclone))
+ int foo (void)
+{
+ asm volatile ("":::"memory");
+ return 4195552;
+}
+
+__attribute__ ((noinline, noclone))
+ void bar (int x, int y)
+{
+ asm volatile (""::"g" (x), "g" (y):"memory");
+ if (y == 0)
+ __builtin_abort ();
+}
+
+int
+baz (int x)
+{
+ char g, h;
+ int i, j;
+
+ foo ();
+ for (;;)
+ {
+ if (c)
+ h = d;
+ g = h < x ? h : 0;
+ i = (signed char) ((unsigned char) (g - 120) ^ 1);
+ j = i > 97;
+ if (a - j)
+ bar (0x123456, 0);
+ if (!b)
+ return e;
+ }
+}
+
+int
+main ()
+{
+ baz (2);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68376-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68376-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68376-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68376-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* PR rtl-optimization/68376 */
+
+int a, b, c = 1;
+signed char d;
+
+int
+main ()
+{
+ for (; a < 1; a++)
+ for (; b < 1; b++)
+ {
+ signed char e = ~d;
+ if (d < 1)
+ e = d;
+ d = e;
+ if (!c)
+ __builtin_abort ();
+ }
+
+ if (d != 0)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68376-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68376-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68376-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68376-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,73 @@
+/* PR rtl-optimization/68376 */
+
+extern void abort (void);
+
+__attribute__((noinline, noclone)) int
+f1 (int x)
+{
+ return x < 0 ? ~x : x;
+}
+
+__attribute__((noinline, noclone)) int
+f2 (int x)
+{
+ return x < 0 ? x : ~x;
+}
+
+__attribute__((noinline, noclone)) int
+f3 (int x)
+{
+ return x <= 0 ? ~x : x;
+}
+
+__attribute__((noinline, noclone)) int
+f4 (int x)
+{
+ return x <= 0 ? x : ~x;
+}
+
+__attribute__((noinline, noclone)) int
+f5 (int x)
+{
+ return x >= 0 ? ~x : x;
+}
+
+__attribute__((noinline, noclone)) int
+f6 (int x)
+{
+ return x >= 0 ? x : ~x;
+}
+
+__attribute__((noinline, noclone)) int
+f7 (int x)
+{
+ return x > 0 ? ~x : x;
+}
+
+__attribute__((noinline, noclone)) int
+f8 (int x)
+{
+ return x > 0 ? x : ~x;
+}
+
+int
+main ()
+{
+ if (f1 (5) != 5 || f1 (-5) != 4 || f1 (0) != 0)
+ abort ();
+ if (f2 (5) != -6 || f2 (-5) != -5 || f2 (0) != -1)
+ abort ();
+ if (f3 (5) != 5 || f3 (-5) != 4 || f3 (0) != -1)
+ abort ();
+ if (f4 (5) != -6 || f4 (-5) != -5 || f4 (0) != 0)
+ abort ();
+ if (f5 (5) != -6 || f5 (-5) != -5 || f5 (0) != -1)
+ abort ();
+ if (f6 (5) != 5 || f6 (-5) != 4 || f6 (0) != 0)
+ abort ();
+ if (f7 (5) != -6 || f7 (-5) != -5 || f7 (0) != 0)
+ abort ();
+ if (f8 (5) != 5 || f8 (-5) != 4 || f8 (0) != -1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68381.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68381.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68381.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68381.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* { dg-options "-O -fexpensive-optimizations -fno-tree-bit-ccp" } */
+
+__attribute__ ((noinline, noclone))
+int
+foo (unsigned short x, unsigned short y)
+{
+ int r;
+ if (__builtin_mul_overflow (x, y, &r))
+ __builtin_abort ();
+ return r;
+}
+
+int
+main (void)
+{
+ int x = 1;
+ int y = 2;
+ if (foo (x, y) != x * y)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68390.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68390.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68390.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68390.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+__attribute__ ((noinline))
+double direct(int x, ...)
+{
+ return x*x;
+}
+
+__attribute__ ((noinline))
+double broken(double (*indirect)(int x, ...), int v)
+{
+ return indirect(v);
+}
+
+int main ()
+{
+ double d1, d2;
+ int i = 2;
+ d1 = broken (direct, i);
+ if (d1 != i*i)
+ {
+ __builtin_abort ();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68506.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68506.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68506.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68506.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,63 @@
+/* { dg-options "-fno-builtin-abort" } */
+
+int a, b, m, n, o, p, s, u, i;
+char c, q, y;
+short d;
+unsigned char e;
+static int f, h;
+static short g, r, v;
+unsigned t;
+
+extern void abort ();
+
+int
+fn1 (int p1)
+{
+ return a ? p1 : p1 + a;
+}
+
+unsigned char
+fn2 (unsigned char p1, int p2)
+{
+ return p2 >= 2 ? p1 : p1 >> p2;
+}
+
+static short
+fn3 ()
+{
+ int w, x = 0;
+ for (; p < 31; p++)
+ {
+ s = fn1 (c | ((1 && c) == c));
+ t = fn2 (s, x);
+ c = (unsigned) c > -(unsigned) ((o = (m = d = t) == p) <= 4UL) && n;
+ v = -c;
+ y = 1;
+ for (; y; y++)
+ e = v == 1;
+ d = 0;
+ for (; h != 2;)
+ {
+ for (;;)
+ {
+ if (!m)
+ abort ();
+ r = 7 - f;
+ x = e = i | r;
+ q = u * g;
+ w = b == q;
+ if (w)
+ break;
+ }
+ break;
+ }
+ }
+ return x;
+}
+
+int
+main ()
+{
+ fn3 ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68532.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68532.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68532.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68532.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* { dg-options "-O2 -ftree-vectorize -fno-vect-cost-model" } */
+/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */
+
+#define SIZE 128
+unsigned short _Alignas (16) in[SIZE];
+
+__attribute__ ((noinline)) int
+test (unsigned short sum, unsigned short *in, int x)
+{
+ for (int j = 0; j < SIZE; j += 8)
+ sum += in[j] * x;
+ return sum;
+}
+
+int
+main ()
+{
+ for (int i = 0; i < SIZE; i++)
+ in[i] = i;
+ if (test (0, in, 1) != 960)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68624.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68624.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68624.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68624.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+int b, c, d, e = 1, f, g, h, j;
+
+static int
+fn1 ()
+{
+ int a = c;
+ if (h)
+ return 9;
+ g = (c || b) % e;
+ if ((g || f) && b)
+ return 9;
+ e = d;
+ for (c = 0; c > -4; c--)
+ ;
+ if (d)
+ c--;
+ j = c;
+ return d;
+}
+
+int
+main ()
+{
+ fn1 ();
+
+ if (c != -4)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68648.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68648.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68648.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68648.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* { dg-require-effective-target int32plus } */
+int __attribute__ ((noinline))
+foo (void)
+{
+ return 123;
+}
+
+int __attribute__ ((noinline))
+bar (void)
+{
+ int c = 1;
+ c |= 4294967295 ^ (foo () | 4073709551608);
+ return c;
+}
+
+int
+main ()
+{
+ if (bar () != 0x83fd4005)
+ __builtin_abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68841.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68841.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68841.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68841.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+static inline int
+foo (int *x, int y)
+{
+ int z = *x;
+ while (y > z)
+ z *= 2;
+ return z;
+}
+
+int
+main ()
+{
+ int i;
+ for (i = 1; i < 17; i++)
+ {
+ int j;
+ int k;
+ j = foo (&i, 7);
+ if (i >= 7)
+ k = i;
+ else if (i >= 4)
+ k = 8 + (i - 4) * 2;
+ else if (i == 3)
+ k = 12;
+ else
+ k = 8;
+ if (j != k)
+ __builtin_abort ();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68911.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68911.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68911.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr68911.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+extern void abort (void);
+
+char a;
+int b, c;
+short d;
+
+int main ()
+{
+ unsigned e = 2;
+ unsigned timeout = 0;
+
+ for (; c < 2; c++)
+ {
+ int f = ~e / 7;
+ if (f)
+ a = e = ~(b && d);
+ while (e < 94)
+ {
+ e++;
+ if (++timeout > 100)
+ goto die;
+ }
+ }
+ return 0;
+die:
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69097-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69097-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69097-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69097-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+/* PR tree-optimization/69097 */
+
+int a, b;
+unsigned int c;
+
+int
+main ()
+{
+ int d = b;
+ b = ~(~a + (~d | b));
+ a = ~(~c >> b);
+ c = a % b;
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69097-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69097-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69097-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69097-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* PR tree-optimization/69097 */
+
+__attribute__((noinline, noclone)) int
+f1 (int x, int y)
+{
+ return x % y;
+}
+
+__attribute__((noinline, noclone)) int
+f2 (int x, int y)
+{
+ return x % -y;
+}
+
+__attribute__((noinline, noclone)) int
+f3 (int x, int y)
+{
+ int z = -y;
+ return x % z;
+}
+
+int
+main ()
+{
+ if (f1 (-__INT_MAX__ - 1, 1) != 0
+ || f2 (-__INT_MAX__ - 1, -1) != 0
+ || f3 (-__INT_MAX__ - 1, -1) != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+#include <stdlib.h>
+int a, b, d, f;
+char c;
+static int *e = &d;
+int main() {
+ int g = -1L;
+ *e = g;
+ c = 4;
+ for (; c >= 14; c++)
+ *e = 1;
+ f = a == 0;
+ *e ^= f;
+ int h = ~d;
+ if (d)
+ b = h;
+ if (h)
+ exit (0);
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+
+#include <stdlib.h>
+
+int a, *c, d, e, g, f;
+short b;
+
+int
+fn1 ()
+{
+ int h = d != 10;
+ if (h > g)
+ asm volatile ("" : : : "memory");
+ if (h == 10)
+ {
+ int *i = 0;
+ a = 0;
+ for (; a < 7; a++)
+ for (; *i;)
+ ;
+ }
+ else
+ {
+ b = e / h;
+ return f;
+ }
+ c = &h;
+ abort ();
+}
+
+int
+main ()
+{
+ fn1 ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+#include <stdlib.h>
+
+static int a[40] = {7, 5, 3, 3, 0, 0, 3};
+short b;
+int c = 5;
+int main() {
+ b = 0;
+ for (; b <= 3; b++)
+ if (a[b + 6] ^ (0 || c))
+ ;
+ else
+ break;
+ if (b != 4)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69320-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+#include <stdlib.h>
+
+int a;
+char b, d;
+short c;
+short fn1(int p1, int p2) { return p2 >= 2 ? p1 : p1 > p2; }
+
+int main() {
+ int *e = &a, *f = &a;
+ b = 1;
+ for (; b <= 9; b++) {
+ c = *e != 5 || d;
+ *f = fn1(c || b, a);
+ }
+ if ((long long) a != 1)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69403.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69403.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69403.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69403.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* PR target/69403. */
+
+int a, b, c;
+
+__attribute__ ((__noinline__)) int
+fn1 ()
+{
+ if ((b | (a != (a & c))) == 1)
+ __builtin_abort ();
+ return 0;
+}
+
+int
+main (void)
+{
+ a = 5;
+ c = 1;
+ b = 6;
+ return fn1 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69447.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69447.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69447.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69447.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned int u32;
+typedef unsigned long long u64;
+
+u64 __attribute__((noinline, noclone))
+foo(u8 u8_0, u16 u16_0, u64 u64_0, u8 u8_1, u16 u16_1, u64 u64_1, u64 u64_2, u8 u8_3, u64 u64_3)
+{
+ u64_1 *= 0x7730;
+ u64_3 *= u64_3;
+ u16_1 |= u64_3;
+ u64_3 -= 2;
+ u8_3 /= u64_2;
+ u8_0 |= 3;
+ u64_3 %= u8_0;
+ u8_0 -= 1;
+ return u8_0 + u16_0 + u64_0 + u8_1 + u16_1 + u64_1 + u8_3 + u64_3;
+}
+
+int main()
+{
+ unsigned x = foo(1, 1, 1, 1, 1, 1, 1, 1, 1);
+ if (x != 0x7737)
+ __builtin_abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69691.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69691.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69691.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr69691.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,127 @@
+/* PR rtl-optimization/69691 */
+
+char u[] = { 46, 97, 99, 104, 52, 0 };
+char *v[] = { u, 0 };
+struct S { char a[10]; struct S *b[31]; };
+struct S r[7], *r2 = r;
+static struct S *w = 0;
+
+__attribute__((noinline, noclone)) int
+fn (int x)
+{
+ if (__builtin_strchr (u, x) || x == 96)
+ return x;
+ __builtin_abort ();
+}
+
+__attribute__((noinline, noclone)) int
+foo (char x)
+{
+ if (x == 0)
+ __builtin_abort ();
+ if (fn (x) >= 96 && fn (x) <= 122)
+ return (fn (x) - 96);
+ else if (x == 46)
+ return 0;
+ else
+ {
+ __builtin_printf ("foo %d\n", x);
+ return -1;
+ }
+}
+
+__attribute__((noinline, noclone)) void
+bar (char **x)
+{
+ char **b, c, *d, e[500], *f, g[10];
+ int z, l, h, i;
+ struct S *s;
+
+ w = r2++;
+ for (b = x; *b; b++)
+ {
+ __builtin_strcpy (e, *b);
+ f = e;
+ do
+ {
+ d = __builtin_strchr (f, 32);
+ if (d)
+ *d = 0;
+ l = __builtin_strlen (f);
+ h = 0;
+ s = w;
+ __builtin_memset (g, 0, sizeof (g));
+ for (z = 0; z < l; z++)
+ {
+ c = f[z];
+ if (c >= 48 && c <= 57)
+ g[h] = c - 48;
+ else
+ {
+ i = foo (c);
+ if (!s->b[i])
+ {
+ s->b[i] = r2++;
+ if (r2 == &r[7])
+ __builtin_abort ();
+ }
+ s = s->b[i];
+ h++;
+ }
+ }
+ __builtin_memcpy (s->a, g, 10);
+ if (d)
+ f = d + 1;
+ }
+ while (d);
+ }
+}
+
+__attribute__((noinline, noclone)) void
+baz (char *x)
+{
+ char a[300], b[300];
+ int z, y, t, l;
+ struct S *s;
+
+ l = __builtin_strlen (x);
+ *a = 96;
+ for (z = 0; z < l; z++)
+ {
+ a[z + 1] = fn ((unsigned int) x[z]);
+ if (foo (a[z + 1]) <= 0)
+ return;
+ }
+ a[l + 1] = 96;
+ l += 2;
+ __builtin_memset (b, 0, l + 2);
+
+ if (!w)
+ return;
+
+ for (z = 0; z < l; z++)
+ {
+ s = w;
+ for (y = z; y < l; y++)
+ {
+ s = s->b[foo (a[y])];
+ if (!s)
+ break;
+ for (t = 0; t <= y - z + 2; t++)
+ if (s->a[t] > b[z + t])
+ b[z + t] = s->a[t];
+ }
+ }
+ for (z = 3; z < l - 2; z++)
+ if ((b[z] & 1) == 1)
+ asm ("");
+}
+
+int
+main ()
+{
+ bar (v);
+ char c[] = { 97, 97, 97, 97, 97, 0 };
+ baz (c);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70005.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70005.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70005.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70005.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+
+unsigned char a = 6;
+int b, c;
+
+static void
+fn1 ()
+{
+ int i = a > 1 ? 1 : a, j = 6 & (c = a && (b = a));
+ int d = 0, e = a, f = ~c, g = b || a;
+ unsigned char h = ~a;
+ if (a)
+ f = j;
+ if (h && g)
+ d = a;
+ i = -~(f * d * h) + c && (e || i) ^ f;
+ if (i != 1)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ fn1 ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70127.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70127.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70127.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70127.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* PR tree-optimization/70127 */
+
+struct S { int f; signed int g : 2; } a[1], c = {5, 1}, d;
+short b;
+
+__attribute__((noinline, noclone)) void
+foo (int x)
+{
+ if (x != 1)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ while (b++ <= 0)
+ {
+ struct S e = {1, 1};
+ d = e = a[0] = c;
+ }
+ foo (a[0].g);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70222-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70222-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70222-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70222-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* PR rtl-optimization/70222 */
+
+int a = 1;
+unsigned int b = 2;
+int c = 0;
+int d = 0;
+
+void
+foo ()
+{
+ int e = ((-(c >= c)) < b) > ((int) (-1ULL >> ((a / a) * 15)));
+ d = -e;
+}
+
+__attribute__((noinline, noclone)) void
+bar (int x)
+{
+ if (x != -1)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
+ foo ();
+ bar (d);
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70222-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70222-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70222-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70222-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* PR rtl-optimization/70222 */
+
+#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
+__attribute__((noinline, noclone)) unsigned int
+foo (int x)
+{
+ unsigned long long y = -1ULL >> x;
+ return (unsigned int) y >> 31;
+}
+#endif
+
+int
+main ()
+{
+#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
+ if (foo (15) != 1 || foo (32) != 1 || foo (33) != 0)
+ __builtin_abort ();
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70429.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70429.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70429.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70429.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+/* PR rtl-optimization/70429 */
+
+__attribute__((noinline, noclone)) int
+foo (int a)
+{
+ return (int) (0x14ff6e2207db5d1fLL >> a) >> 4;
+}
+
+int
+main ()
+{
+ if (sizeof (int) != 4 || sizeof (long long) != 8 || __CHAR_BIT__ != 8)
+ return 0;
+ if (foo (1) != 0x3edae8 || foo (2) != -132158092)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70460.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70460.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70460.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70460.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+/* { dg-require-effective-target indirect_jumps } */
+/* { dg-require-effective-target label_values } */
+/* { dg-skip-if "label differences not supported" { avr-*-* } } */
+
+/* PR rtl-optimization/70460 */
+
+int c;
+
+__attribute__((noinline, noclone)) void
+foo (int x)
+{
+ static int b[] = { &&lab1 - &&lab0, &&lab2 - &&lab0 };
+ void *a = &&lab0 + b[x];
+ goto *a;
+lab1:
+ c += 2;
+lab2:
+ c++;
+lab0:
+ ;
+}
+
+int
+main ()
+{
+ foo (0);
+ if (c != 3)
+ __builtin_abort ();
+ foo (1);
+ if (c != 4)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70566.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70566.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70566.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70566.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,47 @@
+/* PR target/70566. */
+
+#define NULL 0
+
+struct mystruct
+{
+ unsigned int f1 : 1;
+ unsigned int f2 : 1;
+ unsigned int f3 : 1;
+};
+
+__attribute__ ((noinline)) void
+myfunc (int a, void *b)
+{
+}
+__attribute__ ((noinline)) int
+myfunc2 (void *a)
+{
+ return 0;
+}
+
+static void
+set_f2 (struct mystruct *user, int f2)
+{
+ if (user->f2 != f2)
+ myfunc (myfunc2 (NULL), NULL);
+ else
+ __builtin_abort ();
+}
+
+__attribute__ ((noinline)) void
+foo (void *data)
+{
+ struct mystruct *user = data;
+ if (!user->f2)
+ set_f2 (user, 1);
+}
+
+int
+main (void)
+{
+ struct mystruct a;
+ a.f1 = 1;
+ a.f2 = 0;
+ foo (&a);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70586.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70586.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70586.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70586.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* PR tree-optimization/70586 */
+
+int a, e, f;
+short b, c, d;
+
+int
+foo (int x, int y)
+{
+ return (y == 0 || (x && y == 1)) ? x : x % y;
+}
+
+static short
+bar (void)
+{
+ int i = foo (c, f);
+ f = foo (d, 2);
+ int g = foo (b, c);
+ int h = foo (g > 0, c);
+ c = (3 >= h ^ 7) <= foo (i, c);
+ if (foo (e, 1))
+ return a;
+ return 0;
+}
+
+int
+main ()
+{
+ bar ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70602.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70602.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70602.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70602.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* PR tree-optimization/70602 */
+/* { dg-require-effective-target int32plus } */
+
+struct __attribute__((packed)) S
+{
+ int s : 1;
+ int t : 20;
+};
+
+int a, b, c;
+
+int
+main ()
+{
+ for (; a < 1; a++)
+ {
+ struct S e[] = { {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9}, {0, 9}, {0, 9},
+ {0, 0}, {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9}, {0, 9},
+ {0, 9}, {0, 0}, {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9} };
+ b = b || e[0].s;
+ c = e[0].t;
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70903.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70903.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70903.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr70903.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+typedef unsigned char V8 __attribute__ ((vector_size (32)));
+typedef unsigned int V32 __attribute__ ((vector_size (32)));
+typedef unsigned long long V64 __attribute__ ((vector_size (32)));
+
+static V32 __attribute__ ((noinline, noclone))
+foo (V64 x)
+{
+ V64 y = (V64)(V8){((V8)(V64){65535, x[0]})[1]};
+ return (V32){y[0], 255};
+}
+
+int main ()
+{
+ V32 x = foo ((V64){});
+// __builtin_printf ("%08x %08x %08x %08x %08x %08x %08x %08x\n", x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7]);
+ if (x[1] != 255)
+ __builtin_abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71083.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71083.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71083.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71083.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,45 @@
+__extension__ typedef __UINT32_TYPE__ uint32_t;
+
+struct lock_chain {
+ uint32_t irq_context: 2,
+ depth: 6,
+ base: 24;
+};
+
+__attribute__((noinline, noclone))
+struct lock_chain * foo (struct lock_chain *chain)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ chain[i+1].base = chain[i].base;
+ }
+ return chain;
+}
+
+struct lock_chain1 {
+ char x;
+ unsigned short base;
+} __attribute__((packed));
+
+__attribute__((noinline, noclone))
+struct lock_chain1 * bar (struct lock_chain1 *chain)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ chain[i+1].base = chain[i].base;
+ }
+ return chain;
+}
+
+struct lock_chain test [101];
+struct lock_chain1 test1 [101];
+
+int
+main ()
+{
+ foo (test);
+ bar (test1);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71335.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71335.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71335.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71335.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+int a;
+int
+main ()
+{
+ int b = 0;
+ while (a < 0 || b)
+ {
+ b = 0;
+ for (; b < 9; b++)
+ ;
+ }
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71494.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71494.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71494.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71494.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* PR middle-end/71494 */
+/* { dg-require-effective-target label_values } */
+
+int
+main ()
+{
+ void *label = &&out;
+ int i = 0;
+ void test (void)
+ {
+ label = &&out2;
+ goto *label;
+ out2:;
+ i++;
+ }
+ goto *label;
+ out:
+ i += 2;
+ test ();
+ if (i != 3)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71550.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71550.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71550.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71550.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+
+extern void exit (int);
+
+int a = 3, b, c, f, g, h;
+unsigned d;
+char *e;
+
+int
+main ()
+{
+ for (; a; a--)
+ {
+ int i;
+ if (h && i)
+ __builtin_printf ("%d%d", c, f);
+ i = 0;
+ for (; i < 2; i++)
+ if (g)
+ for (; d < 10; d++)
+ b = *e;
+ i = 0;
+ for (; i < 1; i++)
+ ;
+ }
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71554.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71554.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71554.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71554.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* PR target/71554 */
+
+int v;
+
+__attribute__ ((noinline, noclone)) void
+bar (void)
+{
+ v++;
+}
+
+__attribute__ ((noinline, noclone))
+void
+foo (unsigned int x)
+{
+ signed int y = ((-__INT_MAX__ - 1) / 2);
+ signed int r;
+ if (__builtin_mul_overflow (x, y, &r))
+ bar ();
+}
+
+int
+main ()
+{
+ foo (2);
+ if (v)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71626-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71626-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71626-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71626-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* PR middle-end/71626 */
+
+typedef __INTPTR_TYPE__ V __attribute__((__vector_size__(sizeof (__INTPTR_TYPE__))));
+
+__attribute__((noinline, noclone)) V
+foo ()
+{
+ V v = { (__INTPTR_TYPE__) foo };
+ return v;
+}
+
+int
+main ()
+{
+ V v = foo ();
+ if (v[0] != (__INTPTR_TYPE__) foo)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71626-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71626-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71626-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71626-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,4 @@
+/* PR middle-end/71626 */
+/* { dg-additional-options "-fpic" { target fpic } } */
+
+#include "pr71626-1.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71631.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71631.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71631.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71631.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+/* PR tree-optimization/71631 */
+
+volatile char v;
+int a = 1, b = 1, c = 1;
+
+void
+foo (const char *s)
+{
+ while (*s++)
+ v = *s;
+}
+
+int
+main ()
+{
+ volatile int d = 1;
+ volatile int e = 1;
+ int f = 1 / a;
+ int g = 1U < f;
+ int h = 2 + g;
+ int i = 3 % h;
+ int j = e && b;
+ int k = 1 == c;
+ int l = d != 0;
+ short m = (short) (-1 * i * l);
+ short x = j * (k * m);
+ if (i == 1)
+ foo ("AB");
+ if (x != -1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71700.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71700.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71700.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr71700.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+struct S
+{
+ signed f0 : 16;
+ unsigned f1 : 1;
+};
+
+int b;
+static struct S c[] = {{-1, 0}, {-1, 0}};
+struct S d;
+
+int
+main ()
+{
+ struct S e = c[0];
+ d = e;
+ if (d.f1 != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr7284-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr7284-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr7284-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr7284-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* Signed left-shift is implementation-defined in C89 (and see
+ DR#081), not undefined. Bug 7284 from Al Grant (AlGrant at
+ myrealbox.com). */
+
+/* { dg-require-effective-target int32plus } */
+/* { dg-options "-std=c89" } */
+
+extern void abort (void);
+extern void exit (int);
+
+int
+f (int n)
+{
+ return (n << 24) / (1 << 23);
+}
+
+volatile int x = 128;
+
+int
+main (void)
+{
+ if (f(x) != -256)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77718.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77718.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77718.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77718.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR middle-end/77718 */
+
+char a[64] __attribute__((aligned (8)));
+
+__attribute__((noinline, noclone)) int
+foo (void)
+{
+ return __builtin_memcmp ("bbbbbb", a, 6);
+}
+
+__attribute__((noinline, noclone)) int
+bar (void)
+{
+ return __builtin_memcmp (a, "bbbbbb", 6);
+}
+
+int
+main ()
+{
+ __builtin_memset (a, 'a', sizeof (a));
+ if (((foo () < 0) ^ ('a' > 'b'))
+ || ((bar () < 0) ^ ('a' < 'b')))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77766.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77766.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77766.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77766.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+char a;
+short b, d = 5, h;
+char c[1];
+int e, f = 4, g, j;
+int main() {
+ int i;
+ for (; f; f = a) {
+ g = 0;
+ for (; g <= 32; ++g) {
+ i = 0;
+ for (; i < 3; i++)
+ while (1 > d)
+ if (c[b])
+ break;
+ L:
+ if (j)
+ break;
+ }
+ }
+ e = 0;
+ for (; e; e = 0) {
+ d++;
+ for (; h;)
+ goto L;
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77767.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77767.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77767.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr77767.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+/* PR c/77767 */
+
+void
+foo (int a, int b[a++], int c, int d[c++])
+{
+ if (a != 2 || c != 2)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ int e[10];
+ foo (1, e, 1, e);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78170.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78170.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78170.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78170.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,39 @@
+/* { dg-require-effective-target int32plus } */
+
+/* PR tree-optimization/78170.
+ Check that sign-extended store to a bitfield
+ doesn't overwrite other fields. */
+
+int a, b, d;
+
+struct S0
+{
+ int f0;
+ int f1;
+ int f2;
+ int f3;
+ int f4;
+ int f5:15;
+ int f6:17;
+ int f7:2;
+ int f8:30;
+} c;
+
+void fn1 ()
+{
+ d = b = 1;
+ for (; b; b = a)
+ {
+ struct S0 e = { 0, 0, 0, 0, 0, 0, 1, 0, 1 };
+ c = e;
+ c.f6 = -1;
+ }
+}
+
+int main ()
+{
+ fn1 ();
+ if (c.f7 != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78378.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78378.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78378.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78378.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+/* PR rtl-optimization/78378 */
+
+unsigned long long __attribute__ ((noinline, noclone))
+foo (unsigned long long x)
+{
+ x <<= 41;
+ x /= 232;
+ return 1 + (unsigned short) x;
+}
+
+int
+main ()
+{
+ unsigned long long x = foo (1);
+ if (x != 0x2c24)
+ __builtin_abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78436.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78436.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78436.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78436.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* PR tree-optimization/78436 */
+
+struct S
+{
+ long int a : 24;
+ signed char b : 8;
+} s;
+
+__attribute__((noinline, noclone)) void
+foo ()
+{
+ s.b = 0;
+ s.a = -1193165L;
+}
+
+int
+main ()
+{
+ foo ();
+ if (s.b != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78438.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78438.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78438.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78438.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* PR target/78438 */
+
+char a = 0;
+int b = 197412621;
+
+__attribute__ ((noinline, noclone))
+void foo ()
+{
+ a = 0 > (short) (b >> 11);
+}
+
+int
+main ()
+{
+ asm volatile ("" : : : "memory");
+ if (__CHAR_BIT__ != 8 || sizeof (short) != 2 || sizeof (int) < 4)
+ return 0;
+ foo ();
+ if (a != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78477.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78477.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78477.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78477.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+/* PR rtl-optimization/78477 */
+
+unsigned a;
+unsigned short b;
+
+unsigned
+foo (unsigned x)
+{
+ b = x;
+ a >>= (b & 1);
+ b = 1 | (b << 5);
+ b >>= 15;
+ x = (unsigned char) b > ((2 - (unsigned char) b) & 1);
+ b = 0;
+ return x;
+}
+
+int
+main ()
+{
+ if (__CHAR_BIT__ != 8 || sizeof (short) != 2 || sizeof (int) < 4)
+ return 0;
+ unsigned x = foo (12345);
+ if (x != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78559.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78559.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78559.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78559.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+/* PR rtl-optimization/78559 */
+
+int g = 20;
+int d = 0;
+
+short
+fn2 (int p1, int p2)
+{
+ return p2 >= 2 || 5 >> p2 ? p1 : p1 << p2;
+}
+
+int
+main ()
+{
+ int result = 0;
+lbl_2582:
+ if (g)
+ {
+ for (int c = -3; c; c++)
+ result = fn2 (1, g);
+ }
+ else
+ {
+ for (int i = 0; i < 2; i += 2)
+ if (d)
+ goto lbl_2582;
+ }
+ if (result != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78586.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78586.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78586.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78586.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+/* PR tree-optimization/78586 */
+
+void
+foo (unsigned long x)
+{
+ char a[30];
+ unsigned long b = __builtin_sprintf (a, "%lu", x);
+ if (b != 4)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ foo (1000);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78617.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78617.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78617.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78617.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+int a = 0;
+int d = 1;
+int f = 1;
+
+int fn1() {
+ return a || 1 >> a;
+}
+
+int fn2(int p1, int p2) {
+ return p2 >= 2 ? p1 : p1 >> 1;
+}
+
+int fn3(int p1) {
+ return d ^ p1;
+}
+
+int fn4(int p1, int p2) {
+ return fn3(!d > fn2((f = fn1() - 1000) || p2, p1));
+}
+
+int main() {
+ if (fn4(0, 0) != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78622.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78622.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78622.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78622.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+/* PR middle-end/78622 - [7 Regression] -Wformat-overflow/-fprintf-return-value
+ incorrect with overflow/wrapping
+ { dg-skip-if "Requires %hhd format" { hppa*-*-hpux* } }
+ { dg-require-effective-target c99_runtime }
+ { dg-additional-options "-Wformat-overflow=2" } */
+
+__attribute__((noinline, noclone)) int
+foo (int x)
+{
+ if (x < 4096 + 8 || x >= 4096 + 256 + 8)
+ return -1;
+
+ char buf[5];
+ int n = __builtin_snprintf (buf, sizeof buf, "%hhd", x + 1);
+ __builtin_printf ("\"%hhd\" => %i\n", x + 1, n);
+ return n;
+}
+
+int
+main (void)
+{
+ if (__SCHAR_MAX__ != 127 || __CHAR_BIT__ != 8 || __SIZEOF_INT__ != 4)
+ return 0;
+
+ if (foo (4095 + 9) != 1
+ || foo (4095 + 32) != 2
+ || foo (4095 + 127) != 3
+ || foo (4095 + 128) != 4
+ || foo (4095 + 240) != 3
+ || foo (4095 + 248) != 2
+ || foo (4095 + 255) != 2
+ || foo (4095 + 256) != 1)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78675.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78675.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78675.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78675.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+/* PR tree-optimization/78675 */
+
+long int a;
+
+__attribute__((noinline, noclone)) long int
+foo (long int x)
+{
+ long int b;
+ while (a < 1)
+ {
+ b = a && x;
+ ++a;
+ }
+ return b;
+}
+
+int
+main ()
+{
+ if (foo (0) != 0)
+ __builtin_abort ();
+ a = 0;
+ if (foo (1) != 0)
+ __builtin_abort ();
+ a = 0;
+ if (foo (25) != 0)
+ __builtin_abort ();
+ a = -64;
+ if (foo (0) != 0)
+ __builtin_abort ();
+ a = -64;
+ if (foo (1) != 0)
+ __builtin_abort ();
+ a = -64;
+ if (foo (25) != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78720.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78720.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78720.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78720.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+/* PR tree-optimization/78720 */
+
+__attribute__((noinline, noclone)) long int
+foo (signed char x)
+{
+ return x < 0 ? 0x80000L : 0L;
+}
+
+__attribute__((noinline, noclone)) long int
+bar (signed char x)
+{
+ return x < 0 ? 0x80L : 0L;
+}
+
+__attribute__((noinline, noclone)) long int
+baz (signed char x)
+{
+ return x < 0 ? 0x20L : 0L;
+}
+
+int
+main ()
+{
+ if (foo (-1) != 0x80000L || bar (-1) != 0x80L || baz (-1) != 0x20L
+ || foo (0) != 0L || bar (0) != 0L || baz (0) != 0L
+ || foo (31) != 0L || bar (31) != 0L || baz (31) != 0L)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78726.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78726.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78726.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78726.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* PR tree-optimization/78726 */
+
+unsigned char b = 36, c = 173;
+unsigned int d;
+
+__attribute__((noinline, noclone)) void
+foo (void)
+{
+ unsigned a = ~b;
+ d = a * c * c + 1023094746U * a;
+}
+
+int
+main ()
+{
+ if (__SIZEOF_INT__ != 4 || __CHAR_BIT__ != 8)
+ return 0;
+ asm volatile ("" : : "g" (&b), "g" (&c) : "memory");
+ foo ();
+ if (d != 799092689U)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78791.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78791.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78791.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78791.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* PR target/78791 */
+
+__attribute__((used, noinline, noclone)) unsigned long long
+foo (unsigned long long x, unsigned long long y, unsigned long long z)
+{
+ unsigned long long a = x / y;
+ unsigned long long b = x % y;
+ a |= z;
+ b ^= z;
+ return a + b;
+}
+
+int
+main ()
+{
+ if (foo (64, 7, 0) != 10 || foo (28, 3, 2) != 14)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78856.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78856.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78856.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr78856.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+extern void exit (int);
+
+int a, b, c, d, e, f[3];
+
+int main()
+{
+ while (d)
+ while (1)
+ ;
+ int g = 0, h, i = 0;
+ for (; g < 21; g += 9)
+ {
+ int j = 1;
+ for (h = 0; h < 3; h++)
+ f[h] = 1;
+ for (; j < 10; j++) {
+ d = i && (b ? 0 : c);
+ i = 1;
+ if (g)
+ a = e;
+ }
+ }
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79043.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79043.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79043.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79043.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR ipa/78791 */
+
+int val;
+
+int *ptr = &val;
+float *ptr2 = &val;
+
+static
+__attribute__((always_inline, optimize ("-fno-strict-aliasing")))
+typepun ()
+{
+ *ptr2=0;
+}
+
+main()
+{
+ *ptr=1;
+ typepun ();
+ if (*ptr)
+ __builtin_abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79121.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79121.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79121.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79121.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,42 @@
+#if __SIZEOF_INT__ < 4
+ __extension__ typedef __UINT32_TYPE__ uint32_t;
+ __extension__ typedef __INT32_TYPE__ int32_t;
+#else
+ typedef unsigned uint32_t;
+ typedef int int32_t;
+#endif
+
+extern void abort (void);
+
+__attribute__ ((noinline, noclone)) unsigned long long f1 (int32_t x)
+{
+ return ((unsigned long long) x) << 4;
+}
+
+__attribute__ ((noinline, noclone)) long long f2 (uint32_t x)
+{
+ return ((long long) x) << 4;
+}
+
+__attribute__ ((noinline, noclone)) unsigned long long f3 (uint32_t x)
+{
+ return ((unsigned long long) x) << 4;
+}
+
+__attribute__ ((noinline, noclone)) long long f4 (int32_t x)
+{
+ return ((long long) x) << 4;
+}
+
+int main ()
+{
+ if (f1 (0xf0000000) != 0xffffffff00000000)
+ abort ();
+ if (f2 (0xf0000000) != 0xf00000000)
+ abort ();
+ if (f3 (0xf0000000) != 0xf00000000)
+ abort ();
+ if (f4 (0xf0000000) != 0xffffffff00000000)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79286.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79286.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79286.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79286.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+int a = 0, c = 0;
+static int d[][8] = {};
+
+int main ()
+{
+ int e;
+ for (int b = 0; b < 4; b++)
+ {
+ __builtin_printf ("%d\n", b, e);
+ while (a && c++)
+ e = d[300000000000000000][0];
+ }
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79327.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79327.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79327.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79327.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* PR tree-optimization/79327 */
+/* { dg-require-effective-target c99_runtime } */
+
+volatile int a;
+
+int
+main (void)
+{
+ int i;
+ char buf[64];
+ if (__builtin_sprintf (buf, "%#hho", a) != 1)
+ __builtin_abort ();
+ if (__builtin_sprintf (buf, "%#hhx", a) != 1)
+ __builtin_abort ();
+ a = 1;
+ if (__builtin_sprintf (buf, "%#hho", a) != 2)
+ __builtin_abort ();
+ if (__builtin_sprintf (buf, "%#hhx", a) != 3)
+ __builtin_abort ();
+ a = 127;
+ if (__builtin_sprintf (buf, "%#hho", a) != 4)
+ __builtin_abort ();
+ if (__builtin_sprintf (buf, "%#hhx", a) != 4)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79354.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79354.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79354.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79354.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* PR target/79354 */
+
+int b, f, g;
+float e;
+unsigned long d;
+
+__attribute__((noinline, noclone)) void
+foo (int *a)
+{
+ for (g = 0; g < 32; g++)
+ if (f)
+ {
+ e = d;
+ __builtin_memcpy (&b, &e, sizeof (float));
+ b = *a;
+ }
+}
+
+int
+main ()
+{
+ int h = 5;
+ f = 1;
+ asm volatile ("" : : : "memory");
+ foo (&h);
+ asm volatile ("" : : : "memory");
+ foo (&b);
+ asm volatile ("" : : : "memory");
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79388.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79388.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79388.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79388.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* PR rtl-optimization/79388 */
+/* { dg-additional-options "-fno-tree-coalesce-vars" } */
+
+unsigned int a, c;
+
+__attribute__ ((noinline, noclone)) unsigned int
+foo (unsigned int p)
+{
+ p |= 1;
+ p &= 0xfffe;
+ p %= 0xffff;
+ c = p;
+ return a + p;
+}
+
+int
+main (void)
+{
+ int x = foo (6);
+ if (x != 6)
+ __builtin_abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79450.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79450.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79450.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79450.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* PR rtl-optimization/79450 */
+
+unsigned int
+foo (unsigned char x, unsigned long long y)
+{
+ do
+ {
+ x &= !y;
+ x %= 24;
+ }
+ while (x < y);
+ return x + y;
+}
+
+int
+main (void)
+{
+ unsigned int x = foo (1, 0);
+ if (x != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79737-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79737-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79737-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79737-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,43 @@
+/* PR tree-optimization/79737 */
+
+#if __SIZEOF_INT__ < 4
+ __extension__ typedef __INT32_TYPE__ int32_t;
+#else
+ typedef int int32_t;
+#endif
+
+#pragma pack(1)
+struct S
+{
+ int32_t b:18;
+ int32_t c:1;
+ int32_t d:24;
+ int32_t e:15;
+ int32_t f:14;
+} i;
+int g, j, k;
+static struct S h;
+
+void
+foo ()
+{
+ for (j = 0; j < 6; j++)
+ k = 0;
+ for (; k < 3; k++)
+ {
+ struct S m = { 5, 0, -5, 9, 5 };
+ h = m;
+ if (g)
+ i = m;
+ h.e = 0;
+ }
+}
+
+int
+main ()
+{
+ foo ();
+ if (h.e != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79737-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79737-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79737-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr79737-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,47 @@
+/* PR tree-optimization/79737 */
+
+#if __SIZEOF_INT__ < 4
+ __extension__ typedef __INT32_TYPE__ int32_t;
+#else
+ typedef int int32_t;
+#endif
+
+#pragma pack(1)
+struct S
+{
+ int32_t b:18;
+ int32_t c:1;
+ int32_t d:24;
+ int32_t e:15;
+ int32_t f:14;
+} i, j;
+
+void
+foo ()
+{
+ i.e = 0;
+ i.b = 5;
+ i.c = 0;
+ i.d = -5;
+ i.f = 5;
+}
+
+void
+bar ()
+{
+ j.b = 5;
+ j.c = 0;
+ j.d = -5;
+ j.e = 0;
+ j.f = 5;
+}
+
+int
+main ()
+{
+ foo ();
+ bar ();
+ asm volatile ("" : : : "memory");
+ if (i.b != j.b || i.c != j.c || i.d != j.d || i.e != j.e || i.f != j.f)
+ __builtin_abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80153.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80153.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80153.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80153.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,48 @@
+/* PR tree-optimization/80153 */
+
+void check (int, int, int) __attribute__((noinline));
+void check (int c, int c2, int val)
+{
+ if (!val) {
+ __builtin_abort();
+ }
+}
+
+static const char *buf;
+static int l, i;
+
+void _fputs(const char *str) __attribute__((noinline));
+void _fputs(const char *str)
+{
+ buf = str;
+ i = 0;
+ l = __builtin_strlen(buf);
+}
+
+char _fgetc() __attribute__((noinline));
+char _fgetc()
+{
+ char val = buf[i];
+ i++;
+ if (i > l)
+ return -1;
+ else
+ return val;
+}
+
+static const char *string = "oops!\n";
+
+int main(void)
+{
+ int i;
+ int c;
+
+ _fputs(string);
+
+ for (i = 0; i < __builtin_strlen(string); i++) {
+ c = _fgetc();
+ check(c, string[i], c == string[i]);
+ }
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80421.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80421.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80421.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80421.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,121 @@
+/* PR middle-end/80421 */
+
+__attribute__ ((noinline, noclone)) void
+baz (const char *t, ...)
+{
+ asm volatile (""::"r" (t):"memory");
+ if (*t == 'T')
+ __builtin_abort ();
+}
+
+unsigned int
+foo (char x)
+{
+ baz ("x %c\n", x);
+ switch (x)
+ {
+ default:
+ baz ("case default\n");
+ if (x == 'D' || x == 'I')
+ baz ("This should never be reached.\n");
+ return 0;
+ case 'D':
+ baz ("case 'D'\n");
+ return 0;
+ case 'I':
+ baz ("case 'I'\n");
+ return 0;
+ }
+}
+
+void
+bar (void)
+{
+ int a = 2;
+ int b = 5;
+ char c[] = {
+ 2, 4, 1, 2, 5, 5, 2, 4, 4, 0, 0, 0, 0, 0, 0, 3, 4, 4, 2, 4,
+ 1, 2, 5, 5, 2, 4, 1, 0, 0, 0, 2, 4, 4, 3, 4, 3, 3, 5, 1, 3,
+ 5, 5, 2, 4, 4, 2, 4, 1, 3, 5, 3, 3, 5, 1, 3, 5, 1, 2, 4, 4,
+ 2, 4, 2, 3, 5, 1, 3, 5, 1, 3, 5, 5, 2, 4, 1, 2, 4, 2, 3, 5,
+ 3, 3, 5, 1, 3, 5, 5, 2, 4, 1, 2, 4, 1, 3, 5, 3, 3, 5, 1, 3,
+ 5, 5, 2, 4, 4, 2, 4, 1, 3, 5, 3, 3, 5, 1, 3, 5, 1, 2, 4, 1,
+ 2, 4, 2, 3, 5, 1, 3, 5, 1, 3, 5, 1, 2, 4, 1, 2, 4, 1, 3, 5,
+ 1, 3, 5, 1, 3, 5, 1, 2, 4, 4, 2, 4, 1, 3, 5, 1, 3, 5, 1, 3,
+ 5, 5, 2, 4, 4, 2, 4, 2, 3, 5, 3, 3, 5, 1, 3, 5, 5, 2, 4, 4,
+ 2, 4, 1, 3, 5, 3, 3, 5, 1, 3, 5, 1, 2, 5, 5, 2, 4, 2, 3, 5,
+ 1, 3, 4, 1, 3, 5, 1, 2, 5, 5, 2, 4, 1, 2, 5, 1, 3, 5, 3, 3,
+ 5, 1, 2, 5, 5, 2, 4, 2, 2, 5, 1, 3, 5, 3, 3, 5, 1, 2, 5, 1,
+ 2, 4, 1, 2, 5, 2, 3, 5, 1, 3, 5, 1, 2, 5, 1, 2, 4, 2, 2, 5,
+ 1, 3, 5, 1, 3, 5, 1, 2, 5, 5, 2, 4, 2, 2, 5, 2, 3, 5, 3, 3,
+ 5, 1, 2, 5, 5, 2, 4, 2, 2, 5, 2, 3, 5, 3, 3, 5, 1, 2, 5, 5,
+ 2, 4, 2, 2, 5, 1, 3, 5, 3, 3, 5, 1, 2, 5, 5, 2, 4, 2, 2, 5,
+ 1, 3, 5, 3, 3, 5, 1, 2, 5, 1, 2, 4, 1, 2, 5, 2, 3, 5, 1, 3,
+ 5, 1, 2, 5, 5, 2, 4, 2, 2, 5, 2, 3, 5, 3, 3, 5, 1, 2, 5, 5,
+ 2, 4, 1, 2, 5, 1, 3, 5, 3, 3, 5, 1, 2, 5, 5, 2, 4, 2, 2, 5,
+ 1, 3, 5, 3, 3, 5, 1, 2, 5, 5, 2, 4, 2, 2, 5, 1, 3, 5, 3, 3,
+ 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ char *f = c + 390;
+ int i, j, e, g, h;
+ char k, l;
+ i = 26;
+ j = 25;
+ k = l = 'M';
+ h = 2;
+ while (i > 0)
+ {
+ int x = i - a;
+ x = x > 0 ? x : 0;
+ x = j - x;
+ g = x * 3 + h;
+ switch (f[g])
+ {
+ case 1:
+ --i;
+ --j;
+ h = 2;
+ f -= b * 3;
+ k = 'M';
+ break;
+ case 2:
+ --i;
+ h = 0;
+ f -= b * 3;
+ k = 'I';
+ break;
+ case 3:
+ --i;
+ h = 2;
+ f -= b * 3;
+ k = 'I';
+ break;
+ case 4:
+ --j;
+ h = 1;
+ k = 'D';
+ break;
+ case 5:
+ --j;
+ h = 2;
+ k = 'D';
+ break;
+ }
+ if (k == l)
+ ++e;
+ else
+ {
+ foo (l);
+ l = k;
+ }
+ }
+}
+
+int
+main ()
+{
+ char l = 'D';
+ foo (l);
+ bar ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80501.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80501.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80501.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80501.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* PR rtl-optimization/80501 */
+
+signed char v = 0;
+
+static signed char
+foo (int x, int y)
+{
+ return x << y;
+}
+
+__attribute__((noinline, noclone)) int
+bar (void)
+{
+ return foo (v >= 0, __CHAR_BIT__ - 1) >= 1;
+}
+
+int
+main ()
+{
+ if (sizeof (int) > sizeof (char) && bar () != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80692.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80692.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80692.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr80692.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target dfp } */
+
+int main () {
+ _Decimal64 d64 = -0.DD;
+
+ if (d64 != 0.DD)
+ __builtin_abort ();
+
+ if (d64 != -0.DD)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81281.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81281.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81281.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81281.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+/* PR sanitizer/81281 */
+
+void
+foo (unsigned p, unsigned a, unsigned b)
+{
+ unsigned q = p + 7;
+ if (a - (1U + __INT_MAX__) >= 2)
+ __builtin_unreachable ();
+ int d = p + b;
+ int c = p + a;
+ if (c - d != __INT_MAX__)
+ __builtin_abort ();
+}
+
+void
+bar (unsigned p, unsigned a)
+{
+ unsigned q = p + 7;
+ if (a - (1U + __INT_MAX__) >= 2)
+ __builtin_unreachable ();
+ int c = p;
+ int d = p + a;
+ if (c - d != -__INT_MAX__ - 1)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ foo (-1U, 1U + __INT_MAX__, 1U);
+ bar (-1U, 1U + __INT_MAX__);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81423.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81423.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81423.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81423.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,39 @@
+/* PR rtl-optimization/81423 */
+
+extern void abort (void);
+
+unsigned long long int ll = 0;
+unsigned long long int ull1 = 1ULL;
+unsigned long long int ull2 = 12008284144813806346ULL;
+unsigned long long int ull3;
+
+unsigned long long int __attribute__ ((noinline))
+foo (void)
+{
+ ll = -5597998501375493990LL;
+
+ ll = (unsigned int) (5677365550390624949LL - ll) - (ull1 > 0);
+ unsigned long long int ull3;
+ ull3 = (unsigned int)
+ (2067854353LL <<
+ (((ll + -2129105131LL) ^ 10280750144413668236ULL) -
+ 10280750143997242009ULL)) >> ((2873442921854271231ULL | ull2)
+ - 12098357307243495419ULL);
+
+ return ull3;
+}
+
+int
+main (void)
+{
+ /* We need a long long of exactly 64 bits and int of exactly 32 bits
+ for this test. */
+ if (__SIZEOF_LONG_LONG__ * __CHAR_BIT__ != 64
+ || __SIZEOF_INT__ * __CHAR_BIT__ != 32)
+ return 0;
+
+ ull3 = foo ();
+ if (ull3 != 3998784)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81503.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81503.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81503.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81503.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+unsigned short a = 41461;
+unsigned short b = 3419;
+#if __SIZEOF_INT__ >= 4
+int c = 0;
+
+void foo() {
+ if (a + b * ~(0 != 5))
+ c = -~(b * ~(0 != 5)) + 2147483647;
+}
+#else
+__INT32_TYPE__ c = 0;
+
+void foo() {
+ if (a + b * ~((__INT32_TYPE__)(0 != 5)))
+ c = -~(b * ~((__INT32_TYPE__)(0 != 5))) + 2147483647;
+}
+#endif
+
+int main() {
+ foo();
+ if (c != 2147476810)
+ return -1;
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81555.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81555.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81555.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81555.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* PR tree-optimization/81555 */
+
+unsigned int a = 1, d = 0xfaeU, e = 0xe376U;
+_Bool b = 0, f = 1;
+unsigned char g = 1;
+
+void
+foo (void)
+{
+ _Bool c = a != b;
+ if (c)
+ f = 0;
+ if (e & c & (unsigned char)d & c)
+ g = 0;
+}
+
+int
+main ()
+{
+ foo ();
+ if (f || g != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81556.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81556.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81556.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81556.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* PR tree-optimization/81556 */
+
+unsigned long long int b = 0xb82ff73c5c020599ULL;
+unsigned long long int c = 0xd4e8188733a29d8eULL;
+unsigned long long int d = 2, f = 1, g = 0, h = 0;
+unsigned long long int e = 0xf27771784749f32bULL;
+
+__attribute__((noinline, noclone)) void
+foo (void)
+{
+ _Bool a = d > 1;
+ g = f % ((d > 1) << 9);
+ h = a & (e & (a & b & c));
+}
+
+int
+main ()
+{
+ foo ();
+ if (g != 1 || h != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81588.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81588.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81588.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81588.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,45 @@
+/* PR tree-optimization/81588 */
+
+__attribute__((noinline, noclone)) int
+bar (int x)
+{
+ __asm volatile ("" : : "g" (x) : "memory");
+}
+
+__attribute__((noinline, noclone)) int
+foo (unsigned x, long long y)
+{
+ if (y < 0)
+ return 0;
+ if (y < (long long) (4 * x))
+ {
+ bar (y);
+ return 1;
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ volatile unsigned x = 10;
+ volatile long long y = -10000;
+ if (foo (x, y) != 0)
+ __builtin_abort ();
+ y = -1;
+ if (foo (x, y) != 0)
+ __builtin_abort ();
+ y = 0;
+ if (foo (x, y) != 1)
+ __builtin_abort ();
+ y = 39;
+ if (foo (x, y) != 1)
+ __builtin_abort ();
+ y = 40;
+ if (foo (x, y) != 0)
+ __builtin_abort ();
+ y = 10000;
+ if (foo (x, y) != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81913.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81913.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81913.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr81913.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* PR tree-optimization/81913 */
+
+typedef __UINT8_TYPE__ u8;
+typedef __UINT32_TYPE__ u32;
+
+static u32
+b (u8 d, u32 e, u32 g)
+{
+ do
+ {
+ e += g + 1;
+ d--;
+ }
+ while (d >= (u8) e);
+
+ return e;
+}
+
+int
+main (void)
+{
+ u32 x = b (1, -0x378704, ~0xba64fc);
+ if (x != 0xd93190d0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82192.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82192.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82192.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82192.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* PR rtl-optimization/82192 */
+
+unsigned long long int a = 0x95dd3d896f7422e2ULL;
+struct S { unsigned int m : 13; } b;
+
+__attribute__((noinline, noclone)) void
+foo (void)
+{
+ b.m = ((unsigned) a) >> (0x644eee9667723bf7LL
+ | a & ~0xdee27af8U) - 0x644eee9667763bd8LL;
+}
+
+int
+main ()
+{
+ if (__INT_MAX__ != 0x7fffffffULL)
+ return 0;
+ foo ();
+ if (b.m != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82210.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82210.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82210.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82210.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+/* PR c/82210 */
+/* { dg-require-effective-target alloca } */
+
+void
+foo (int size)
+{
+ int i;
+ struct S {
+ __attribute__((aligned (16))) struct T { short c; } a[size];
+ int b[size];
+ } s;
+
+ for (i = 0; i < size; i++)
+ s.a[i].c = 0x1234;
+ for (i = 0; i < size; i++)
+ s.b[i] = 0;
+ for (i = 0; i < size; i++)
+ if (s.a[i].c != 0x1234 || s.b[i] != 0)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ foo (15);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82387.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82387.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82387.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82387.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+/* PR tree-optimization/82387 */
+
+struct A { int b; };
+int f = 1;
+
+struct A
+foo (void)
+{
+ struct A h[] = {
+ {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1},
+ {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1},
+ {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1},
+ {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1},
+ {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1},
+ {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1},
+ {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1},
+ };
+ return h[24];
+}
+
+int
+main ()
+{
+ struct A i = foo (), j = i;
+ j.b && (f = 0);
+ return f;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82388.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82388.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82388.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82388.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+/* PR tree-optimization/82388 */
+
+struct A { int b; int c; int d; } e;
+
+struct A
+foo (void)
+{
+ struct A h[30] = {{0,0,0}};
+ return h[29];
+}
+
+int
+main ()
+{
+ e = foo ();
+ return e.b;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82524.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82524.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82524.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82524.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,37 @@
+/* PR target/82524 */
+
+struct S { unsigned char b, g, r, a; };
+union U { struct S c; unsigned v; };
+
+static inline unsigned char
+foo (unsigned char a, unsigned char b)
+{
+ return ((a + 1) * b) >> 8;
+}
+
+__attribute__((noinline, noclone)) unsigned
+bar (union U *x, union U *y)
+{
+ union U z;
+ unsigned char v = x->c.a;
+ unsigned char w = foo (y->c.a, 255 - v);
+ z.c.r = foo (x->c.r, v) + foo (y->c.r, w);
+ z.c.g = foo (x->c.g, v) + foo (y->c.g, w);
+ z.c.b = foo (x->c.b, v) + foo (y->c.b, w);
+ z.c.a = 0;
+ return z.v;
+}
+
+int
+main ()
+{
+ union U a, b, c;
+ if ((unsigned char) ~0 != 255 || sizeof (unsigned) != 4)
+ return 0;
+ a.c = (struct S) { 255, 255, 255, 0 };
+ b.c = (struct S) { 255, 255, 255, 255 };
+ c.v = bar (&a, &b);
+ if (c.c.b != 255 || c.c.g != 255 || c.c.r != 255 || c.c.a != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82954.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82954.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82954.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr82954.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* PR tree-optimization/82954 */
+
+__attribute__((noipa)) void
+foo (int *__restrict p, int *__restrict q)
+{
+ p[0] = p[0] ^ 1;
+ p[1] = p[1] ^ 2;
+ p[2] = p[2] ^ q[2];
+ p[3] = p[3] ^ q[3];
+}
+
+int
+main ()
+{
+ int p[4] = { 16, 32, 64, 128 };
+ int q[4] = { 8, 4, 2, 1 };
+ asm volatile ("" : : "g" (p), "g" (q) : "memory");
+ foo (p, q);
+ if (p[0] != 17 || p[1] != 34 || p[2] != 66 || p[3] != 129)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83269.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83269.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83269.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83269.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+/* PR tree-optimization/83269 */
+
+int
+main ()
+{
+#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ > 4 && __CHAR_BIT__ == 8
+ volatile unsigned char a = 1;
+ long long b = 0x80000000L;
+ int c = -((int)(-b) - (-0x7fffffff * a));
+ if (c != 1)
+ __builtin_abort ();
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83298.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83298.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83298.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83298.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,11 @@
+
+int a, b, c = 1;
+
+int main ()
+{
+ for (; b < 1; b++)
+ ;
+ if (!(c * (a < 1)))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83362.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83362.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83362.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83362.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+typedef __UINT8_TYPE__ u8;
+typedef __UINT32_TYPE__ u32;
+
+u32 a, b, d, e;
+u8 c;
+
+static u32 __attribute__ ((noinline, noclone))
+foo (u32 p)
+{
+ do
+ {
+ e /= 0xfff;
+ if (p > c)
+ d = 0;
+ e -= 3;
+ e *= b <= a;
+ }
+ while (e >= 88030);
+ return e;
+}
+
+int
+main (void)
+{
+ u32 x = foo (1164);
+ if (x != 0xfd)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83383.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83383.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83383.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83383.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR tree-optimization/83383 */
+
+unsigned long long int a = 16ULL;
+unsigned char b = 195;
+unsigned long long int c = ~0ULL;
+unsigned char d = 1;
+unsigned long long int e[2] = { 3625445792498952486ULL, 0 };
+unsigned long long int f[2] = { 0, 8985037393681294663ULL };
+unsigned long long int g = 5052410635626804928ULL;
+
+void
+foo ()
+{
+ a = ((signed char) a) < b;
+ c = (d ? e[0] : 0) - (f[1] * a ? 1 : g);
+}
+
+int
+main()
+{
+ foo ();
+ if (a != 1 || c != 3625445792498952485ULL)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83477.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83477.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83477.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr83477.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+int yf = 0;
+
+void
+pl (int q5, int nd)
+{
+ unsigned int hp = q5;
+ int zx = (q5 == 0) ? hp : (hp / q5);
+
+ yf = ((nd < 2) * zx != 0) ? nd : 0;
+}
+
+int
+main (void)
+{
+ pl (1, !yf);
+ if (yf != 1)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84169.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84169.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84169.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84169.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/84169 */
+
+#ifdef __SIZEOF_INT128__
+typedef unsigned __int128 T;
+#else
+typedef unsigned long long T;
+#endif
+
+T b;
+
+static __attribute__ ((noipa)) T
+foo (T c, T d, T e, T f, T g, T h)
+{
+ __builtin_mul_overflow ((unsigned char) h, -16, &h);
+ return b + h;
+}
+
+int
+main ()
+{
+ T x = foo (0, 0, 0, 0, 0, 4);
+ if (x != -64)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84339.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84339.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84339.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84339.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* PR tree-optimization/84339 */
+
+struct S { int a; char b[1]; };
+
+__attribute__((noipa)) int
+foo (struct S *p)
+{
+ return __builtin_strlen (&p->b[0]);
+}
+
+__attribute__((noipa)) int
+bar (struct S *p)
+{
+ return __builtin_strlen (p->b);
+}
+
+int
+main ()
+{
+ struct S *p = __builtin_malloc (sizeof (struct S) + 16);
+ if (p)
+ {
+ p->a = 1;
+ __builtin_strcpy (p->b, "abcdefg");
+ if (foo (p) != 7 || bar (p) != 7)
+ __builtin_abort ();
+ __builtin_free (p);
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84478.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84478.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84478.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84478.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,49 @@
+/* PR tree-optimization/84478 */
+
+long poolptr;
+unsigned char *strpool;
+static const char *poolfilearr[] = {
+ "mu",
+ "",
+#define A "x",
+#define B A "xx", A A "xxx", A A A A A
+#define C B B B B B B B B B B
+#define D C C C C C C C C C C
+ D C C C C C C C B B B
+ ((void *)0)
+};
+
+__attribute__((noipa)) long
+makestring (void)
+{
+ return 1;
+}
+
+__attribute__((noipa)) long
+loadpoolstrings (long spare_size)
+{
+ const char *s;
+ long g = 0;
+ int i = 0, j = 0;
+ while ((s = poolfilearr[j++]))
+ {
+ int l = __builtin_strlen (s);
+ i += l;
+ if (i >= spare_size) return 0;
+ while (l-- > 0) strpool[poolptr++] = *s++;
+ g = makestring ();
+ }
+ return g;
+}
+
+int
+main ()
+{
+ strpool = __builtin_malloc (4000);
+ if (!strpool)
+ return 0;
+ asm volatile ("" : : : "memory");
+ volatile int r = loadpoolstrings (4000);
+ __builtin_free (strpool);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84521.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84521.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84521.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84521.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,53 @@
+/* { dg-require-effective-target indirect_jumps } */
+/* { dg-additional-options "-fomit-frame-pointer -fno-inline" } */
+
+extern void abort (void);
+
+void
+broken_longjmp (void *p)
+{
+ __builtin_longjmp (p, 1);
+}
+
+volatile int x = 256;
+void *volatile p = (void*)&x;
+void *volatile p1;
+
+void
+test (void)
+{
+ void *buf[5];
+ void *volatile q = p;
+
+ if (!__builtin_setjmp (buf))
+ broken_longjmp (buf);
+
+ /* Fails if stack pointer corrupted. */
+ if (p != q)
+ abort ();
+}
+
+void
+test2 (void)
+{
+ void *volatile q = p;
+ p1 = __builtin_alloca (x);
+ test ();
+
+ /* Fails if frame pointer corrupted. */
+ if (p != q)
+ abort ();
+}
+
+int
+main (void)
+{
+ void *volatile q = p;
+ test ();
+ test2 ();
+ /* Fails if stack pointer corrupted. */
+ if (p != q)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84524.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84524.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84524.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84524.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+/* PR target/84524 */
+
+__attribute__((noipa)) void
+foo (unsigned short *x)
+{
+ unsigned short i, v;
+ unsigned char j;
+ for (i = 0; i < 256; i++)
+ {
+ v = i << 8;
+ for (j = 0; j < 8; j++)
+ if (v & 0x8000)
+ v = (v << 1) ^ 0x1021;
+ else
+ v = v << 1;
+ x[i] = v;
+ }
+}
+
+int
+main ()
+{
+ unsigned short a[256];
+
+ foo (a);
+ for (int i = 0; i < 256; i++)
+ {
+ unsigned short v = i << 8;
+ for (int j = 0; j < 8; j++)
+ {
+ asm volatile ("" : "+r" (v));
+ if (v & 0x8000)
+ v = (v << 1) ^ 0x1021;
+ else
+ v = v << 1;
+ }
+ if (a[i] != v)
+ __builtin_abort ();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84748.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84748.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84748.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr84748.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,34 @@
+/* { dg-require-effective-target int128 } */
+
+typedef unsigned __int128 u128;
+
+int a, c, d;
+u128 b;
+
+unsigned long long g0, g1;
+
+void
+store (unsigned long long a0, unsigned long long a1)
+{
+ g0 = a0;
+ g1 = a1;
+}
+
+void
+foo (void)
+{
+ b += a;
+ c = d != 84347;
+ b /= c;
+ u128 x = b;
+ store (x >> 0, x >> 64);
+}
+
+int
+main (void)
+{
+ foo ();
+ if (g0 != 0 || g1 != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85095.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85095.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85095.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85095.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,52 @@
+/* PR target/85095 */
+
+__attribute__((noipa)) unsigned long
+f1 (unsigned long a, unsigned long b)
+{
+ unsigned long i = __builtin_add_overflow (a, b, &a);
+ return a + i;
+}
+
+__attribute__((noipa)) unsigned long
+f2 (unsigned long a, unsigned long b)
+{
+ unsigned long i = __builtin_add_overflow (a, b, &a);
+ return a - i;
+}
+
+__attribute__((noipa)) unsigned long
+f3 (unsigned int a, unsigned int b)
+{
+ unsigned int i = __builtin_add_overflow (a, b, &a);
+ return a + i;
+}
+
+__attribute__((noipa)) unsigned long
+f4 (unsigned int a, unsigned int b)
+{
+ unsigned int i = __builtin_add_overflow (a, b, &a);
+ return a - i;
+}
+
+int
+main ()
+{
+ if (f1 (16UL, -18UL) != -2UL
+ || f1 (16UL, -17UL) != -1UL
+ || f1 (16UL, -16UL) != 1UL
+ || f1 (16UL, -15UL) != 2UL
+ || f2 (24UL, -26UL) != -2UL
+ || f2 (24UL, -25UL) != -1UL
+ || f2 (24UL, -24UL) != -1UL
+ || f2 (24UL, -23UL) != 0UL
+ || f3 (32U, -34U) != -2U
+ || f3 (32U, -33U) != -1U
+ || f3 (32U, -32U) != 1U
+ || f3 (32U, -31U) != 2U
+ || f4 (35U, -37U) != -2U
+ || f4 (35U, -36U) != -1U
+ || f4 (35U, -35U) != -1U
+ || f4 (35U, -34U) != 0U)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85156.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85156.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85156.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85156.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR tree-optimization/85156 */
+
+int x, y;
+
+__attribute__((noipa)) int
+foo (int z)
+{
+ if (__builtin_expect (x ? y != 0 : 0, z++))
+ return 7;
+ return z;
+}
+
+int
+main ()
+{
+ x = 1;
+ asm volatile ("" : "+m" (x), "+m" (y));
+ if (foo (10) != 11)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85169.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85169.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85169.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85169.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* PR target/85169 */
+
+typedef char V __attribute__((vector_size (64)));
+
+static void __attribute__ ((noipa))
+foo (V *p)
+{
+ V v = *p;
+ v[63] = 1;
+ *p = v;
+}
+
+int
+main ()
+{
+ V v = (V) { };
+ foo (&v);
+ for (unsigned i = 0; i < 64; i++)
+ if (v[i] != (i == 63))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85331.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85331.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85331.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85331.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* PR tree-optimization/85331 */
+
+typedef double V __attribute__((vector_size (2 * sizeof (double))));
+typedef long long W __attribute__((vector_size (2 * sizeof (long long))));
+
+__attribute__((noipa)) void
+foo (V *r)
+{
+ V y = { 1.0, 2.0 };
+ W m = { 10000000001LL, 0LL };
+ *r = __builtin_shuffle (y, m);
+}
+
+int
+main ()
+{
+ V r;
+ foo (&r);
+ if (r[0] != 2.0 || r[1] != 1.0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85529-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85529-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85529-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85529-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* PR tree-optimization/85529 */
+
+struct S { int a; };
+
+int b, c = 1, d, e, f;
+static int g;
+volatile struct S s;
+
+signed char
+foo (signed char i, int j)
+{
+ return i < 0 ? i : i << j;
+}
+
+int
+main ()
+{
+ signed char k = -83;
+ if (!d)
+ goto L;
+ k = e || f;
+L:
+ for (; b < 1; b++)
+ s.a != (k < foo (k, 2) && (c = k = g));
+ if (c != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85529-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85529-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85529-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85529-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR tree-optimization/85529 */
+
+__attribute__((noipa)) int
+foo (int x)
+{
+ x &= 63;
+ x -= 50;
+ x |= 1;
+ if (x < 0)
+ return 1;
+ int y = x >> 2;
+ if (x >= y)
+ return 1;
+ return 0;
+}
+
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 63; i++)
+ if (foo (i) != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR target/85582 */
+
+int a, b, d = 2, e;
+long long c = 1;
+
+int
+main ()
+{
+ int g = 6;
+L1:
+ e = d;
+ if (a)
+ goto L1;
+ g--;
+ int i = c >> ~(~e | ~g);
+L2:
+ c = (b % c) * i;
+ if (!e)
+ goto L2;
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,51 @@
+/* PR target/85582 */
+
+#ifdef __SIZEOF_INT128__
+typedef __int128 S;
+typedef unsigned __int128 U;
+#else
+typedef long long S;
+typedef unsigned long long U;
+#endif
+
+__attribute__((noipa)) S
+f1 (S x, int y)
+{
+ x = x << (y & 5);
+ x += y;
+ return x;
+}
+
+__attribute__((noipa)) S
+f2 (S x, int y)
+{
+ x = x >> (y & 5);
+ x += y;
+ return x;
+}
+
+__attribute__((noipa)) U
+f3 (U x, int y)
+{
+ x = x >> (y & 5);
+ x += y;
+ return x;
+}
+
+int
+main ()
+{
+ S a = (S) 1 << (sizeof (S) * __CHAR_BIT__ - 7);
+ S b = f1 (a, 12);
+ if (b != ((S) 1 << (sizeof (S) * __CHAR_BIT__ - 3)) + 12)
+ __builtin_abort ();
+ S c = (U) 1 << (sizeof (S) * __CHAR_BIT__ - 1);
+ S d = f2 (c, 12);
+ if ((U) d != ((U) 0x1f << (sizeof (S) * __CHAR_BIT__ - 5)) + 12)
+ __builtin_abort ();
+ U e = (U) 1 << (sizeof (U) * __CHAR_BIT__ - 1);
+ U f = f3 (c, 12);
+ if (f != ((U) 1 << (sizeof (U) * __CHAR_BIT__ - 5)) + 12)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85582-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,55 @@
+/* PR target/85582 */
+
+#ifdef __SIZEOF_INT128__
+typedef __int128 S;
+typedef unsigned __int128 U;
+#else
+typedef long long S;
+typedef unsigned long long U;
+#endif
+
+__attribute__((noipa)) U
+f1 (U x, int y)
+{
+ return x << (y & -2);
+}
+
+__attribute__((noipa)) S
+f2 (S x, int y)
+{
+ return x >> (y & -2);
+}
+
+__attribute__((noipa)) U
+f3 (U x, int y)
+{
+ return x >> (y & -2);
+}
+
+int
+main ()
+{
+ U a = (U) 1 << (sizeof (U) * __CHAR_BIT__ - 7);
+ if (f1 (a, 5) != ((U) 1 << (sizeof (S) * __CHAR_BIT__ - 3)))
+ __builtin_abort ();
+ S b = (U) 0x101 << (sizeof (S) * __CHAR_BIT__ / 2 - 7);
+ if (f1 (b, sizeof (S) * __CHAR_BIT__ / 2) != (U) 0x101 << (sizeof (S) * __CHAR_BIT__ - 7))
+ __builtin_abort ();
+ if (f1 (b, sizeof (S) * __CHAR_BIT__ / 2 + 2) != (U) 0x101 << (sizeof (S) * __CHAR_BIT__ - 5))
+ __builtin_abort ();
+ S c = (U) 1 << (sizeof (S) * __CHAR_BIT__ - 1);
+ if ((U) f2 (c, 5) != ((U) 0x1f << (sizeof (S) * __CHAR_BIT__ - 5)))
+ __builtin_abort ();
+ if ((U) f2 (c, sizeof (S) * __CHAR_BIT__ / 2) != ((U) -1 << (sizeof (S) * __CHAR_BIT__ / 2 - 1)))
+ __builtin_abort ();
+ if ((U) f2 (c, sizeof (S) * __CHAR_BIT__ / 2 + 2) != ((U) -1 << (sizeof (S) * __CHAR_BIT__ / 2 - 3)))
+ __builtin_abort ();
+ U d = (U) 1 << (sizeof (S) * __CHAR_BIT__ - 1);
+ if (f3 (c, 5) != ((U) 0x1 << (sizeof (S) * __CHAR_BIT__ - 5)))
+ __builtin_abort ();
+ if (f3 (c, sizeof (S) * __CHAR_BIT__ / 2) != ((U) 1 << (sizeof (S) * __CHAR_BIT__ / 2 - 1)))
+ __builtin_abort ();
+ if (f3 (c, sizeof (S) * __CHAR_BIT__ / 2 + 2) != ((U) 1 << (sizeof (S) * __CHAR_BIT__ / 2 - 3)))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85756.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85756.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85756.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr85756.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,50 @@
+/* PR target/85756 */
+
+#if __CHAR_BIT__ == 8 && __SIZEOF_SHORT__ == 2 && __SIZEOF_INT__ == 4
+int a, c, *e, f, h = 10;
+short b;
+unsigned int p;
+
+__attribute__((noipa)) void
+bar (int a)
+{
+ asm volatile ("" : : "r" (a) : "memory");
+}
+
+void
+foo ()
+{
+ unsigned j = 1, m = 430523;
+ int k, n = 1, *l = &h;
+lab:
+ p = m;
+ m = -((~65535U | j) - n);
+ f = b << ~(n - 8);
+ n = (m || b) ^ f;
+ j = p;
+ if (p < m)
+ *l = k < 3;
+ if (!n)
+ l = &k;
+ if (c)
+ {
+ bar (a);
+ goto lab;
+ }
+ if (!*l)
+ *e = 1;
+}
+
+int
+main ()
+{
+ foo ();
+ return 0;
+}
+#else
+int
+main ()
+{
+ return 0;
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86231.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86231.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86231.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86231.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* PR tree-optimization/86231 */
+
+#define ONE ((void *) 1)
+#define TWO ((void *) 2)
+
+__attribute__((noipa)) int
+foo (void *p, int x)
+{
+ if (p == ONE) return 0;
+ if (!p)
+ p = x ? TWO : ONE;
+ return p == ONE ? 0 : 1;
+}
+
+int v[8];
+
+int
+main ()
+{
+ if (foo ((void *) 0, 0) != 0
+ || foo ((void *) 0, 1) != 1
+ || foo (ONE, 0) != 0
+ || foo (ONE, 1) != 0
+ || foo (TWO, 0) != 1
+ || foo (TWO, 1) != 1
+ || foo (&v[7], 0) != 1
+ || foo (&v[7], 1) != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86492.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86492.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86492.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86492.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,34 @@
+/* PR tree-optimization/86492 */
+
+union U
+{
+ unsigned int r;
+ struct S
+ {
+ unsigned int a:12;
+ unsigned int b:4;
+ unsigned int c:16;
+ } f;
+};
+
+__attribute__((noipa)) unsigned int
+foo (unsigned int x)
+{
+ union U u;
+ u.r = 0;
+ u.f.c = x;
+ u.f.b = 0xe;
+ return u.r;
+}
+
+int
+main ()
+{
+ union U u;
+ if (__CHAR_BIT__ * __SIZEOF_INT__ != 32 || sizeof (u.r) != sizeof (u.f))
+ return 0;
+ u.r = foo (0x72);
+ if (u.f.a != 0 || u.f.b != 0xe || u.f.c != 0x72)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86528.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86528.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86528.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86528.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+// { dg-require-effective-target alloca }
+/* PR middle-end/86528 */
+
+void __attribute__((noinline, noclone))
+test(char *data, __SIZE_TYPE__ len)
+{
+ static char const appended[] = "/./";
+ char *buf = __builtin_alloca (len + sizeof appended);
+ __builtin_memcpy (buf, data, len);
+ __builtin_strcpy (buf + len, &appended[data[len - 1] == '/']);
+ if (__builtin_strcmp(buf, "test1234/./"))
+ __builtin_abort();
+}
+
+int
+main()
+{
+ char *arg = "test1234/";
+ test(arg, __builtin_strlen(arg));
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86714.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86714.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86714.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86714.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* PR tree-optimization/86714 - tree-ssa-forwprop.c confused by too
+ long initializer
+
+ The excessively long initializer for a[0] is undefined but this
+ test verifies that the excess elements are not considered a part
+ of the value of the array as a matter of QoI. */
+
+const char a[2][3] = { "1234", "xyz" };
+char b[6];
+
+void *pb = b;
+
+int main ()
+{
+ __builtin_memcpy (b, a, 4);
+ __builtin_memset (b + 4, 'a', 2);
+
+ if (b[0] != '1' || b[1] != '2' || b[2] != '3'
+ || b[3] != 'x' || b[4] != 'a' || b[5] != 'a')
+ __builtin_abort ();
+
+ if (__builtin_memcmp (pb, "123xaa", 6))
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86844.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86844.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86844.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr86844.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* PR tree-optimization/86844 */
+
+__attribute__((noipa)) void
+foo (int *p)
+{
+ *p = 0;
+ *((char *)p + 3) = 1;
+ *((char *)p + 1) = 2;
+ *((char *)p + 2) = *((char *)p + 6);
+}
+
+int
+main ()
+{
+ int a[2] = { -1, 0 };
+ if (sizeof (int) != 4)
+ return 0;
+ ((char *)a)[6] = 3;
+ foo (a);
+ if (((char *)a)[0] != 0 || ((char *)a)[1] != 2
+ || ((char *)a)[2] != 3 || ((char *)a)[3] != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87053.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87053.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87053.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87053.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+/* PR middle-end/87053 */
+
+const union
+{ struct {
+ char x[4];
+ char y[4];
+ };
+ struct {
+ char z[8];
+ };
+} u = {{"1234", "567"}};
+
+int main ()
+{
+ if (__builtin_strlen (u.z) != 7)
+ __builtin_abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87290.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87290.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87290.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87290.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,63 @@
+/* PR middle-end/87290 */
+
+int c;
+
+__attribute__((noipa)) void
+f0 (void)
+{
+ c++;
+}
+
+__attribute__((noipa)) int
+f1 (int x)
+{
+ return x % 16 == 13;
+}
+
+__attribute__((noipa)) int
+f2 (int x)
+{
+ return x % 16 == -13;
+}
+
+__attribute__((noipa)) void
+f3 (int x)
+{
+ if (x % 16 == 13)
+ f0 ();
+}
+
+__attribute__((noipa)) void
+f4 (int x)
+{
+ if (x % 16 == -13)
+ f0 ();
+}
+
+int
+main ()
+{
+ int i, j;
+ for (i = -30; i < 30; i++)
+ {
+ if (f1 (13 + i * 16) != (i >= 0) || f2 (-13 + i * 16) != (i <= 0))
+ __builtin_abort ();
+ f3 (13 + i * 16);
+ if (c != (i >= 0))
+ __builtin_abort ();
+ f4 (-13 + i * 16);
+ if (c != 1 + (i == 0))
+ __builtin_abort ();
+ for (j = 1; j < 16; j++)
+ {
+ if (f1 (13 + i * 16 + j) || f2 (-13 + i * 16 + j))
+ __builtin_abort ();
+ f3 (13 + i * 16 + j);
+ f4 (-13 + i * 16 + j);
+ }
+ if (c != 1 + (i == 0))
+ __builtin_abort ();
+ c = 0;
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87623.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87623.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87623.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr87623.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,34 @@
+/* PR middle-end/87623 */
+/* Testcase by George Thopas <george.thopas at gmail.com> */
+
+struct be {
+ unsigned short pad[1];
+ unsigned char a;
+ unsigned char b;
+} __attribute__((scalar_storage_order("big-endian")));
+
+typedef struct be t_be;
+
+struct le {
+ unsigned short pad[3];
+ unsigned char a;
+ unsigned char b;
+};
+
+typedef struct le t_le;
+
+int a_or_b_different(t_be *x,t_le *y)
+{
+ return (x->a != y->a) || (x->b != y->b);
+}
+
+int main (void)
+{
+ t_be x = { .a=1, .b=2 };
+ t_le y = { .a=1, .b=2 };
+
+ if (a_or_b_different(&x,&y))
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88693.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88693.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88693.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88693.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,54 @@
+/* PR tree-optimization/88693 */
+
+__attribute__((noipa)) void
+foo (char *p)
+{
+ if (__builtin_strlen (p) != 9)
+ __builtin_abort ();
+}
+
+__attribute__((noipa)) void
+quux (char *p)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ if (p[i] != 'x')
+ __builtin_abort ();
+}
+
+__attribute__((noipa)) void
+qux (void)
+{
+ char b[100];
+ __builtin_memset (b, 'x', sizeof (b));
+ quux (b);
+}
+
+__attribute__((noipa)) void
+bar (void)
+{
+ static unsigned char u[9] = "abcdefghi";
+ char b[100];
+ __builtin_memcpy (b, u, sizeof (u));
+ b[sizeof (u)] = 0;
+ foo (b);
+}
+
+__attribute__((noipa)) void
+baz (void)
+{
+ static unsigned char u[] = { 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r' };
+ char b[100];
+ __builtin_memcpy (b, u, sizeof (u));
+ b[sizeof (u)] = 0;
+ foo (b);
+}
+
+int
+main ()
+{
+ qux ();
+ bar ();
+ baz ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88714.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88714.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88714.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88714.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,43 @@
+/* PR bootstrap/88714 */
+
+struct S { int a, b, c; int *d; };
+struct T { int *e, *f, *g; } *t = 0;
+int *o = 0;
+
+__attribute__((noipa))
+void bar (int *x, int y, int z, int w)
+{
+ if (w == -1)
+ {
+ if (x != 0 || y != 0 || z != 0)
+ __builtin_abort ();
+ }
+ else if (w != 0 || x != t->g || y != 0 || z != 12)
+ __builtin_abort ();
+}
+
+__attribute__((noipa)) void
+foo (struct S *x, struct S *y, int *z, int w)
+{
+ *o = w;
+ if (w)
+ bar (0, 0, 0, -1);
+ x->d = z;
+ if (y->d)
+ y->c = y->c + y->d[0];
+ bar (t->g, 0, y->c, 0);
+}
+
+int
+main ()
+{
+ int a[4] = { 8, 9, 10, 11 };
+ struct S s = { 1, 2, 3, &a[0] };
+ struct T u = { 0, 0, &a[3] };
+ o = &a[2];
+ t = &u;
+ foo (&s, &s, &a[1], 5);
+ if (s.c != 12 || s.d != &a[1])
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88739.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88739.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88739.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88739.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,59 @@
+/* PR tree-optimization/88739 */
+#if __SIZEOF_SHORT__ == 2 && __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8
+struct A
+{
+ unsigned int a, b, c;
+ unsigned int d : 30;
+ unsigned int e : 2;
+};
+
+union U
+{
+ struct A f;
+ unsigned int g[4];
+ unsigned short h[8];
+ unsigned char i[16];
+};
+volatile union U v = { .f.d = 0x4089 };
+
+__attribute__((noipa)) void
+bar (int x)
+{
+ static int i;
+ switch (i++)
+ {
+ case 0: if (x != v.f.d) __builtin_abort (); break;
+ case 1: if (x != v.f.e) __builtin_abort (); break;
+ case 2: if (x != v.g[3]) __builtin_abort (); break;
+ case 3: if (x != v.h[6]) __builtin_abort (); break;
+ case 4: if (x != v.h[7]) __builtin_abort (); break;
+ default: __builtin_abort (); break;
+ }
+}
+
+void
+foo (unsigned int x)
+{
+ union U u;
+ u.f.d = x >> 2;
+ u.f.e = 0;
+ bar (u.f.d);
+ bar (u.f.e);
+ bar (u.g[3]);
+ bar (u.h[6]);
+ bar (u.h[7]);
+}
+
+int
+main ()
+{
+ foo (0x10224);
+ return 0;
+}
+#else
+int
+main ()
+{
+ return 0;
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88904.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88904.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88904.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr88904.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+/* PR rtl-optimization/88904 */
+
+volatile int v;
+
+__attribute__((noipa)) void
+bar (const char *x, const char *y, int z)
+{
+ if (!v)
+ __builtin_abort ();
+ asm volatile ("" : "+g" (x));
+ asm volatile ("" : "+g" (y));
+ asm volatile ("" : "+g" (z));
+}
+
+#define my_assert(e) ((e) ? (void) 0 : bar (#e, __FILE__, __LINE__))
+
+typedef struct {
+ unsigned M1;
+ unsigned M2 : 1;
+ int : 0;
+ unsigned M3 : 1;
+} S;
+
+S
+foo ()
+{
+ S result = {0, 0, 1};
+ return result;
+}
+
+int
+main ()
+{
+ S ret = foo ();
+ my_assert (ret.M2 == 0);
+ my_assert (ret.M3 == 1);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89195.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89195.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89195.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89195.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* PR rtl-optimization/89195 */
+/* { dg-require-effective-target int32plus } */
+
+struct S { unsigned i : 24; };
+
+volatile unsigned char x;
+
+__attribute__((noipa)) int
+foo (struct S d)
+{
+ return d.i & x;
+}
+
+int
+main ()
+{
+ struct S d = { 0x123456 };
+ x = 0x75;
+ if (foo (d) != (0x56 & 0x75))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89369.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89369.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89369.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89369.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,69 @@
+/* PR target/89369 */
+
+#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8 && __CHAR_BIT__ == 8
+struct S { unsigned int u[4]; };
+
+static void
+foo (struct S *out, struct S const *in, int shift)
+{
+ unsigned long long th, tl, oh, ol;
+ th = ((unsigned long long) in->u[3] << 32) | in->u[2];
+ tl = ((unsigned long long) in->u[1] << 32) | in->u[0];
+ oh = th >> (shift * 8);
+ ol = tl >> (shift * 8);
+ ol |= th << (64 - shift * 8);
+ out->u[1] = ol >> 32;
+ out->u[0] = ol;
+ out->u[3] = oh >> 32;
+ out->u[2] = oh;
+}
+
+static void
+bar (struct S *out, struct S const *in, int shift)
+{
+ unsigned long long th, tl, oh, ol;
+ th = ((unsigned long long) in->u[3] << 32) | in->u[2];
+ tl = ((unsigned long long) in->u[1] << 32) | in->u[0];
+ oh = th << (shift * 8);
+ ol = tl << (shift * 8);
+ oh |= tl >> (64 - shift * 8);
+ out->u[1] = ol >> 32;
+ out->u[0] = ol;
+ out->u[3] = oh >> 32;
+ out->u[2] = oh;
+}
+
+__attribute__((noipa)) static void
+baz (struct S *r, struct S *a, struct S *b, struct S *c, struct S *d)
+{
+ struct S x, y;
+ bar (&x, a, 1);
+ foo (&y, c, 1);
+ r->u[0] = a->u[0] ^ x.u[0] ^ ((b->u[0] >> 11) & 0xdfffffefU) ^ y.u[0] ^ (d->u[0] << 18);
+ r->u[1] = a->u[1] ^ x.u[1] ^ ((b->u[1] >> 11) & 0xddfecb7fU) ^ y.u[1] ^ (d->u[1] << 18);
+ r->u[2] = a->u[2] ^ x.u[2] ^ ((b->u[2] >> 11) & 0xbffaffffU) ^ y.u[2] ^ (d->u[2] << 18);
+ r->u[3] = a->u[3] ^ x.u[3] ^ ((b->u[3] >> 11) & 0xbffffff6U) ^ y.u[3] ^ (d->u[3] << 18);
+}
+
+int
+main ()
+{
+ struct S a[] = { { 0x000004d3, 0xbc5448db, 0xf22bde9f, 0xebb44f8f },
+ { 0x03a32799, 0x60be8246, 0xa2d266ed, 0x7aa18536 },
+ { 0x15a38518, 0xcf655ce1, 0xf3e09994, 0x50ef69fe },
+ { 0x88274b07, 0xe7c94866, 0xc0ea9f47, 0xb6a83c43 },
+ { 0xcd0d0032, 0x5d47f5d7, 0x5a0afbf6, 0xaea87b24 },
+ { 0, 0, 0, 0 } };
+ baz (&a[5], &a[0], &a[1], &a[2], &a[3]);
+ if (a[4].u[0] != a[5].u[0] || a[4].u[1] != a[5].u[1]
+ || a[4].u[2] != a[5].u[2] || a[4].u[3] != a[5].u[3])
+ __builtin_abort ();
+ return 0;
+}
+#else
+int
+main ()
+{
+ return 0;
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89434.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89434.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89434.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89434.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+/* PR target/89434 */
+
+#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8 && __CHAR_BIT__ == 8
+long g = 0;
+
+static inline unsigned long long
+foo (unsigned long long u)
+{
+ unsigned x;
+ __builtin_mul_overflow (-1, g, &x);
+ u |= (unsigned) u < (unsigned short) x;
+ return x - u;
+}
+
+int
+main ()
+{
+ unsigned long long x = foo (0x222222222ULL);
+ if (x != 0xfffffffddddddddeULL)
+ __builtin_abort ();
+ return 0;
+}
+#else
+int
+main ()
+{
+ return 0;
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89634.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89634.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89634.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89634.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,40 @@
+/* PR rtl-optimization/89634 */
+
+static unsigned long *
+foo (unsigned long *x)
+{
+ return x + (1 + *x);
+}
+
+__attribute__((noipa)) unsigned long
+bar (unsigned long *x)
+{
+ unsigned long c, d = 1, e, *f, g, h = 0, i;
+ for (e = *x - 1; e > 0; e--)
+ {
+ f = foo (x + 1);
+ for (i = 1; i < e; i++)
+ f = foo (f);
+ c = *f;
+ if (c == 2)
+ d *= 2;
+ else
+ {
+ i = (c - 1) / 2 - 1;
+ g = (2 * i + 1) * (d + 1) + (2 * d + 1);
+ if (g > h)
+ h = g;
+ d *= c;
+ }
+ }
+ return h;
+}
+
+int
+main ()
+{
+ unsigned long a[18] = { 4, 2, -200, 200, 2, -400, 400, 3, -600, 0, 600, 5, -100, -66, 0, 66, 100, __LONG_MAX__ / 8 + 1 };
+ if (bar (a) != 17)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89826.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89826.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89826.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr89826.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+typedef unsigned int u32;
+typedef unsigned long long u64;
+u64 a;
+u32 b;
+
+u64
+foo (u32 d)
+{
+ a -= d ? 0 : ~a;
+ return a + b;
+}
+
+int
+main (void)
+{
+ u64 x = foo (2);
+ if (x != 0)
+ __builtin_abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr90025.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr90025.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr90025.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr90025.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* PR middle-end/90025 */
+
+__attribute__((noipa)) void
+bar (char *p)
+{
+ int i;
+ for (i = 0; i < 6; i++)
+ if (p[i] != "foobar"[i])
+ __builtin_abort ();
+ for (; i < 32; i++)
+ if (p[i] != '\0')
+ __builtin_abort ();
+}
+
+__attribute__((noipa)) void
+foo (unsigned int x)
+{
+ char s[32] = { 'f', 'o', 'o', 'b', 'a', 'r', 0 };
+ ((unsigned int *) s)[2] = __builtin_bswap32 (x);
+ bar (s);
+}
+
+int
+main ()
+{
+ foo (0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr90949.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr90949.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr90949.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr90949.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,42 @@
+void __attribute__ ((noipa, noinline)) my_puts (const char *str) { }
+
+void __attribute__ ((noipa, noinline)) my_free (void *p) { }
+
+
+struct Node
+{
+ struct Node *child;
+};
+
+struct Node space[2] = { };
+
+struct Node * __attribute__ ((noipa, noinline)) my_malloc (int bytes)
+{
+ return &space[0];
+}
+
+void
+walk (struct Node *module, int cleanup)
+{
+ if (module == 0)
+ {
+ return;
+ }
+ if (!cleanup)
+ {
+ my_puts ("No cleanup");
+ }
+ walk (module->child, cleanup);
+ if (cleanup)
+ {
+ my_free (module);
+ }
+}
+
+int
+main ()
+{
+ struct Node *node = my_malloc (sizeof (struct Node));
+ node->child = 0;
+ walk (node, 1);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr91137.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr91137.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr91137.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr91137.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+long long a;
+unsigned b;
+int c[70];
+int d[70][70];
+int e;
+
+__attribute__ ((noinline)) void f(long long *g, int p2) {
+ *g = p2;
+}
+
+__attribute__ ((noinline)) void fn2() {
+ for (int j = 0; j < 70; j++) {
+ for (int i = 0; i < 70; i++) {
+ if (b)
+ c[i] = 0;
+ for (int l = 0; l < 70; l++)
+ d[i][1] = d[l][i];
+ }
+ for (int k = 0; k < 70; k++)
+ e = c[0];
+ }
+}
+
+int main() {
+ b = 5;
+ for (int j = 0; j < 70; ++j)
+ c[j] = 2075593088;
+ fn2();
+ f(&a, e);
+ if (a)
+ __builtin_abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* { dg-skip-if "requires io" { freestanding } } */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+#define test(ret, args...) \
+ printf (args); \
+ if (printf (args) != ret) \
+ abort ();
+ test (5, "hello");
+ test (6, "hello\n");
+ test (1, "a");
+ test (0, "");
+ test (5, "%s", "hello");
+ test (6, "%s", "hello\n");
+ test (1, "%s", "a");
+ test (0, "%s", "");
+ test (1, "%c", 'x');
+ test (7, "%s\n", "hello\n");
+ test (2, "%d\n", 0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,61 @@
+/* Verify that calls to printf don't get eliminated even if their
+ result on success can be computed at compile time (they can fail).
+ The calls can still be transformed into those of other functions.
+ { dg-require-effective-target unwrapped }
+ { dg-skip-if "requires io" { freestanding } } */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+__attribute__ ((noipa)) void
+write_file (void)
+{
+ printf ("1");
+ printf ("%c", '2');
+ printf ("%c%c", '3', '4');
+ printf ("%s", "5");
+ printf ("%s%s", "6", "7");
+ printf ("%i", 8);
+ printf ("%.1s\n", "9x");
+}
+
+
+int main (void)
+{
+ char *tmpfname = tmpnam (0);
+ FILE *f = freopen (tmpfname, "w", stdout);
+ if (!f)
+ {
+ perror ("fopen for writing");
+ return 1;
+ }
+
+ write_file ();
+ fclose (f);
+
+ f = fopen (tmpfname, "r");
+ if (!f)
+ {
+ perror ("fopen for reading");
+ remove (tmpfname);
+ return 1;
+ }
+
+ char buf[12] = "";
+ if (1 != fscanf (f, "%s", buf))
+ {
+ perror ("fscanf");
+ fclose (f);
+ remove (tmpfname);
+ return 1;
+ }
+
+ fclose (f);
+ remove (tmpfname);
+
+ if (strcmp (buf, "123456789"))
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-chk-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-chk-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-chk-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/printf-chk-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,51 @@
+/* { dg-skip-if "requires io" { freestanding } } */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+volatile int should_optimize;
+
+int
+__attribute__((noinline))
+__printf_chk (int flag, const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+#ifdef __OPTIMIZE__
+ if (should_optimize)
+ abort ();
+#endif
+ should_optimize = 1;
+ va_start (ap, fmt);
+ ret = vprintf (fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+int
+main (void)
+{
+#define test(ret, opt, args...) \
+ should_optimize = opt; \
+ __printf_chk (1, args); \
+ if (!should_optimize) \
+ abort (); \
+ should_optimize = 0; \
+ if (__printf_chk (1, args) != ret) \
+ abort (); \
+ if (!should_optimize) \
+ abort ();
+ test (5, 0, "hello");
+ test (6, 1, "hello\n");
+ test (1, 1, "a");
+ test (0, 1, "");
+ test (5, 0, "%s", "hello");
+ test (6, 1, "%s", "hello\n");
+ test (1, 1, "%s", "a");
+ test (0, 1, "%s", "");
+ test (1, 1, "%c", 'x');
+ test (7, 1, "%s\n", "hello\n");
+ test (2, 0, "%d\n", 0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pta-field-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pta-field-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pta-field-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pta-field-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+struct Foo {
+ int *p;
+ int *q;
+};
+
+void __attribute__((noinline))
+bar (int **x)
+{
+ struct Foo *f = (struct Foo *)x;
+ *(f->q) = 0;
+}
+
+int foo(void)
+{
+ struct Foo f;
+ int i = 1, j = 2;
+ f.p = &i;
+ f.q = &j;
+ bar(&f.p);
+ return j;
+}
+
+extern void abort (void);
+int main()
+{
+ if (foo () != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pta-field-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pta-field-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pta-field-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pta-field-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+struct Foo {
+ int *p;
+ int *q;
+};
+
+void __attribute__((noinline))
+bar (int **x)
+{
+ struct Foo *f = (struct Foo *)(x - 1);
+ *(f->p) = 0;
+}
+
+int foo(void)
+{
+ struct Foo f;
+ int i = 1, j = 2;
+ f.p = &i;
+ f.q = &j;
+ bar(&f.q);
+ return i;
+}
+
+extern void abort (void);
+int main()
+{
+ if (foo () != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ptr-arith-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ptr-arith-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ptr-arith-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ptr-arith-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+char *
+f (char *s, unsigned int i)
+{
+ return &s[i + 3 - 1];
+}
+
+main ()
+{
+ char *str = "abcdefghijkl";
+ char *x2 = f (str, 12);
+ if (str + 14 != x2)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pure-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pure-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pure-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pure-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,91 @@
+
+/* Origin: Kaveh Ghazi <ghazi at caip.rutgers.edu> 2002-05-27. */
+
+/* Use a different function for each test so the link failures
+ indicate which one is broken. */
+extern void link_error0 (void);
+extern void link_error1 (void);
+extern void link_error2 (void);
+extern void link_error3 (void);
+extern void link_error4 (void);
+extern void link_error5 (void);
+extern void link_error6 (void);
+extern void link_error7 (void);
+
+extern int i;
+
+extern int func0 (int) __attribute__ ((__pure__));
+extern int func1 (int) __attribute__ ((__const__));
+
+/* GCC should automatically detect attributes for these functions.
+ At -O3 They'll be inlined, but that's ok. */
+static int func2 (int a) { return i + a; } /* pure */
+static int func3 (int a) { return a * 3; } /* const */
+static int func4 (int a) { return func0(a) + a; } /* pure */
+static int func5 (int a) { return a + func1(a); } /* const */
+static int func6 (int a) { return func2(a) + a; } /* pure */
+static int func7 (int a) { return a + func3(a); } /* const */
+
+int main ()
+{
+ int i[10], r;
+
+ i[0] = 0;
+ r = func0(0);
+ if (i[0])
+ link_error0();
+
+ i[1] = 0;
+ r = func1(0);
+ if (i[1])
+ link_error1();
+
+ i[2] = 0;
+ r = func2(0);
+ if (i[2])
+ link_error2();
+
+ i[3] = 0;
+ r = func3(0);
+ if (i[3])
+ link_error3();
+
+ i[4] = 0;
+ r = func4(0);
+ if (i[4])
+ link_error4();
+
+ i[5] = 0;
+ r = func5(0);
+ if (i[5])
+ link_error5();
+
+ i[6] = 0;
+ r = func6(0);
+ if (i[6])
+ link_error6();
+
+ i[7] = 0;
+ r = func7(0);
+ if (i[7])
+ link_error7();
+
+ return r;
+}
+
+int func0 (int a) { return a - i; } /* pure */
+int func1 (int a) { return a - a; } /* const */
+
+int i = 2;
+
+#ifndef __OPTIMIZE__
+/* Avoid link failures when not optimizing. */
+void link_error0() {}
+void link_error1() {}
+void link_error2() {}
+void link_error3() {}
+void link_error4() {}
+void link_error5() {}
+void link_error6() {}
+void link_error7() {}
+#endif /* ! __OPTIMIZE__ */
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pushpop_macro.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pushpop_macro.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pushpop_macro.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pushpop_macro.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+extern void abort ();
+
+#define _ 2
+#pragma push_macro("_")
+#undef _
+#define _ 1
+#pragma pop_macro("_")
+
+int main ()
+{
+ if (_ != 2)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/regstack-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/regstack-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/regstack-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/regstack-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+long double C = 5;
+long double U = 1;
+long double Y2 = 11;
+long double Y1 = 17;
+long double X, Y, Z, T, R, S;
+main ()
+{
+ X = (C + U) * Y2;
+ Y = C - U - U;
+ Z = C + U + U;
+ T = (C - U) * Y1;
+ X = X - (Z + U);
+ R = Y * Y1;
+ S = Z * Y2;
+ T = T - Y;
+ Y = (U - Y) + R;
+ Z = S - (Z + U + U);
+ R = (Y2 + U) * Y1;
+ Y1 = Y2 * Y1;
+ R = R - Y2;
+ Y1 = Y1 - 0.5L;
+ if (Z != 68. || Y != 49. || X != 58. || Y1 != 186.5 || R != 193. || S != 77.
+ || T != 65. || Y2 != 11.)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/restrict-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/restrict-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/restrict-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/restrict-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+/* PR rtl-optimization/16536
+ Origin: Jeremy Denise <jeremy.denise at libertysurf.fr>
+ Reduced: Wolfgang Bangerth <bangerth at dealii.org>
+ Volker Reichelt <reichelt at igpm.rwth-aachen.de> */
+/* { dg-options "-fgnu89-inline" } */
+
+extern void abort ();
+
+typedef struct
+{
+ int i, dummy;
+} A;
+
+inline A foo (const A* p, const A* q)
+{
+ return (A){p->i+q->i};
+}
+
+void bar (A* __restrict__ p)
+{
+ *p=foo(p,p);
+ if (p->i!=2)
+ abort();
+}
+
+int main ()
+{
+ A a={1};
+ bar(&a);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/return-addr.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/return-addr.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/return-addr.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/return-addr.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,122 @@
+/* Test to verify that a function that returns either the address
+ of a local variable or a non-local via a MAX_EXPR or MIN_EXPR
+ doesn't return null when the result of the expression is
+ the latter. */
+
+#define NOIPA __attribute__ ((noclone, noinline, noipa))
+
+#define A(expr) \
+ ((expr) \
+ ? (void)0 \
+ : (__builtin_printf ("assertion failed on line %i: %s\n", \
+ __LINE__, #expr), \
+ __builtin_abort ()))
+
+
+typedef __UINTPTR_TYPE__ uintptr_t;
+
+/* Return a bigger value than P. The address still points (just
+ past) the local variable pointed to by P so the caller does
+ return the address of a local variable but that's hidden from
+ GCC by the attribute and the point of the test is to verify
+ that the address in the return statement in the caller isn't
+ replaced by null when GCC cannot prove the address doesn't
+ reference a non-local variable. */
+
+NOIPA char* get_max_2 (char *p)
+{
+ return p + 1;
+}
+
+NOIPA char* get_max_3 (char *p, char *q)
+{
+ return p < q ? q + 1 : p + 1;
+}
+
+/* Analogous to the above. The expressions are undefined because
+ they form an address prior to the beginning of the object but
+ it's hidden from GCC by the attributes. */
+
+NOIPA char* get_min_2 (char *p)
+{
+ return p - 1;
+}
+
+NOIPA char* get_min_3 (char *p, char *q)
+{
+ return p < q ? p - 1 : q - 1;
+}
+
+
+NOIPA void* test_max_2 (void)
+{
+ char c;
+
+ char *p = get_max_2 (&c);
+
+ void *q = p > &c ? p : &c; /* MAX_EXPR */
+ return q;
+}
+
+NOIPA void* test_max_3 (void)
+{
+ char c;
+ char d;
+
+ char *p = get_max_3 (&c, &d);
+
+ void *q = p < &c ? &c < &d ? &d : &c : p;
+ return q;
+}
+
+NOIPA void* test_min_2 (void)
+{
+ char c;
+
+ char *p = get_min_2 (&c);
+
+ void *q = p < &c ? p : &c; /* MIN_EXPR" */
+ return q;
+}
+
+NOIPA void* test_min_3 (void)
+{
+ char c;
+ char d;
+
+ char *p = get_min_3 (&c, &d);
+
+ void *q = p > &c ? &c > &d ? &d : &c : p;
+ return q;
+}
+
+NOIPA void* test_min_3_phi (int i)
+{
+ char a, b;
+
+ char *p0 = &a;
+ char *p1 = &b;
+ char *p2 = get_min_3 (&a, &b);
+ char *p3 = get_min_3 (&a, &b);
+
+ char *p4 = p2 < p0 ? p2 : p0;
+ char *p5 = p3 < p1 ? p3 : p1;
+
+ __builtin_printf ("%p %p %p %p\n", p2, p3, p4, p5);
+
+ if (i == 1)
+ return p4;
+ else
+ return p5;
+}
+
+int main ()
+{
+ A (0 != test_max_2 ());
+ A (0 != test_max_3 ());
+
+ A (0 != test_min_2 ());
+ A (0 != test_min_3 ());
+
+ A (0 != test_min_3_phi (0));
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,86 @@
+#define vector(elcount, type) \
+__attribute__((vector_size((elcount)*sizeof(type)))) type
+
+#define vidx(type, vec, idx) (*((type *) &(vec) + idx))
+
+#define operl(a, b, op) (a op b)
+#define operr(a, b, op) (b op a)
+
+#define check(type, count, vec0, vec1, num, op, lr) \
+do {\
+ int __i; \
+ for (__i = 0; __i < count; __i++) {\
+ if (vidx (type, vec1, __i) != oper##lr (num, vidx (type, vec0, __i), op)) \
+ __builtin_abort (); \
+ }\
+} while (0)
+
+#define veccompare(type, count, v0, v1) \
+do {\
+ int __i; \
+ for (__i = 0; __i < count; __i++) { \
+ if (vidx (type, v0, __i) != vidx (type, v1, __i)) \
+ __builtin_abort (); \
+ } \
+} while (0)
+
+volatile int one = 1;
+
+int main (int argc, char *argv[]) {
+#define fvec_2 (vector(4, float)){2., 2., 2., 2.}
+#define dvec_2 (vector(2, double)){2., 2.}
+
+
+ vector(8, short) v0 = {one, 1, 2, 3, 4, 5, 6, 7};
+ vector(8, short) v1;
+
+ vector(4, float) f0 = {1., 2., 3., 4.};
+ vector(4, float) f1, f2;
+
+ vector(2, double) d0 = {1., 2.};
+ vector(2, double) d1, d2;
+
+
+
+ v1 = 2 + v0; check (short, 8, v0, v1, 2, +, l);
+ v1 = 2 - v0; check (short, 8, v0, v1, 2, -, l);
+ v1 = 2 * v0; check (short, 8, v0, v1, 2, *, l);
+ v1 = 2 / v0; check (short, 8, v0, v1, 2, /, l);
+ v1 = 2 % v0; check (short, 8, v0, v1, 2, %, l);
+ v1 = 2 ^ v0; check (short, 8, v0, v1, 2, ^, l);
+ v1 = 2 & v0; check (short, 8, v0, v1, 2, &, l);
+ v1 = 2 | v0; check (short, 8, v0, v1, 2, |, l);
+ v1 = 2 << v0; check (short, 8, v0, v1, 2, <<, l);
+ v1 = 2 >> v0; check (short, 8, v0, v1, 2, >>, l);
+
+ v1 = v0 + 2; check (short, 8, v0, v1, 2, +, r);
+ v1 = v0 - 2; check (short, 8, v0, v1, 2, -, r);
+ v1 = v0 * 2; check (short, 8, v0, v1, 2, *, r);
+ v1 = v0 / 2; check (short, 8, v0, v1, 2, /, r);
+ v1 = v0 % 2; check (short, 8, v0, v1, 2, %, r);
+ v1 = v0 ^ 2; check (short, 8, v0, v1, 2, ^, r);
+ v1 = v0 & 2; check (short, 8, v0, v1, 2, &, r);
+ v1 = v0 | 2; check (short, 8, v0, v1, 2, |, r);
+
+ f1 = 2. + f0; f2 = fvec_2 + f0; veccompare (float, 4, f1, f2);
+ f1 = 2. - f0; f2 = fvec_2 - f0; veccompare (float, 4, f1, f2);
+ f1 = 2. * f0; f2 = fvec_2 * f0; veccompare (float, 4, f1, f2);
+ f1 = 2. / f0; f2 = fvec_2 / f0; veccompare (float, 4, f1, f2);
+
+ f1 = f0 + 2.; f2 = f0 + fvec_2; veccompare (float, 4, f1, f2);
+ f1 = f0 - 2.; f2 = f0 - fvec_2; veccompare (float, 4, f1, f2);
+ f1 = f0 * 2.; f2 = f0 * fvec_2; veccompare (float, 4, f1, f2);
+ f1 = f0 / 2.; f2 = f0 / fvec_2; veccompare (float, 4, f1, f2);
+
+ d1 = 2. + d0; d2 = dvec_2 + d0; veccompare (double, 2, d1, d2);
+ d1 = 2. - d0; d2 = dvec_2 - d0; veccompare (double, 2, d1, d2);
+ d1 = 2. * d0; d2 = dvec_2 * d0; veccompare (double, 2, d1, d2);
+ d1 = 2. / d0; d2 = dvec_2 / d0; veccompare (double, 2, d1, d2);
+
+ d1 = d0 + 2.; d2 = d0 + dvec_2; veccompare (double, 2, d1, d2);
+ d1 = d0 - 2.; d2 = d0 - dvec_2; veccompare (double, 2, d1, d2);
+ d1 = d0 * 2.; d2 = d0 * dvec_2; veccompare (double, 2, d1, d2);
+ d1 = d0 / 2.; d2 = d0 / dvec_2; veccompare (double, 2, d1, d2);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,62 @@
+#define vector(elcount, type) \
+__attribute__((vector_size((elcount)*sizeof(type)))) type
+
+#define vidx(type, vec, idx) (*((type *) &(vec) + idx))
+
+#define operl(a, b, op) (a op b)
+#define operr(a, b, op) (b op a)
+
+#define check(type, count, vec0, vec1, num, op, lr) \
+do {\
+ int __i; \
+ for (__i = 0; __i < count; __i++) {\
+ if (vidx (type, vec1, __i) != oper##lr (num, vidx (type, vec0, __i), op)) \
+ __builtin_abort (); \
+ }\
+} while (0)
+
+#define veccompare(type, count, v0, v1) \
+do {\
+ int __i; \
+ for (__i = 0; __i < count; __i++) { \
+ if (vidx (type, v0, __i) != vidx (type, v1, __i)) \
+ __builtin_abort (); \
+ } \
+} while (0)
+
+
+long __attribute__ ((noinline)) vlng () { return (long)42; }
+int __attribute__ ((noinline)) vint () { return (int) 43; }
+short __attribute__ ((noinline)) vsrt () { return (short)42; }
+char __attribute__ ((noinline)) vchr () { return (char)42; }
+
+
+int main (int argc, char *argv[]) {
+ vector(16, char) c0 = {argc, 1,2,3,4,5,6,7, argc, 1,2,3,4,5,6,7};
+ vector(16, char) c1;
+
+ vector(8, short) s0 = {argc, 1,2,3,4,5,6,7};
+ vector(8, short) s1;
+
+ vector(4, int) i0 = {argc, 1, 2, 3};
+ vector(4, int) i1;
+
+ vector(2, long) l0 = {argc, 1};
+ vector(2, long) l1;
+
+ c1 = vchr() + c0; check (char, 16, c0, c1, vchr(), +, l);
+
+ s1 = vsrt() + s0; check (short, 8, s0, s1, vsrt(), +, l);
+ s1 = vchr() + s0; check (short, 8, s0, s1, vchr(), +, l);
+
+ i1 = vint() * i0; check (int, 4, i0, i1, vint(), *, l);
+ i1 = vsrt() * i0; check (int, 4, i0, i1, vsrt(), *, l);
+ i1 = vchr() * i0; check (int, 4, i0, i1, vchr(), *, l);
+
+ l1 = vlng() * l0; check (long, 2, l0, l1, vlng(), *, l);
+ l1 = vint() * l0; check (long, 2, l0, l1, vint(), *, l);
+ l1 = vsrt() * l0; check (long, 2, l0, l1, vsrt(), *, l);
+ l1 = vchr() * l0; check (long, 2, l0, l1, vchr(), *, l);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scal-to-vec3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,48 @@
+#define vector(elcount, type) \
+__attribute__((vector_size((elcount)*sizeof(type)))) type
+
+#define vidx(type, vec, idx) (*((type *) &(vec) + idx))
+
+#define veccompare(type, count, v0, v1) \
+do {\
+ int __i; \
+ for (__i = 0; __i < count; __i++) { \
+ if (vidx (type, v0, __i) != vidx (type, v1, __i)) \
+ __builtin_abort (); \
+ } \
+} while (0)
+
+
+int main (int argc, char *argv[]) {
+#define fvec_2 (vector(4, float)){2., 2., 2., 2.}
+#define dvec_2 (vector(2, double)){2., 2.}
+
+ vector(4, float) f0 = {1., 2., 3., 4.};
+ vector(4, float) f1, f2;
+
+ vector(2, double) d0 = {1., 2.};
+ vector(2, double) d1, d2;
+
+
+ f1 = 2 + f0; f2 = fvec_2 + f0; veccompare (float, 4, f1, f2);
+ f1 = 2 - f0; f2 = fvec_2 - f0; veccompare (float, 4, f1, f2);
+ f1 = 2 * f0; f2 = fvec_2 * f0; veccompare (float, 4, f1, f2);
+ f1 = 2 / f0; f2 = fvec_2 / f0; veccompare (float, 4, f1, f2);
+
+ f1 = f0 + 2; f2 = f0 + fvec_2; veccompare (float, 4, f1, f2);
+ f1 = f0 - 2; f2 = f0 - fvec_2; veccompare (float, 4, f1, f2);
+ f1 = f0 * 2; f2 = f0 * fvec_2; veccompare (float, 4, f1, f2);
+ f1 = f0 / 2; f2 = f0 / fvec_2; veccompare (float, 4, f1, f2);
+
+ d1 = 2 + d0; d2 = dvec_2 + d0; veccompare (double, 2, d1, d2);
+ d1 = 2 - d0; d2 = dvec_2 - d0; veccompare (double, 2, d1, d2);
+ d1 = 2 * d0; d2 = dvec_2 * d0; veccompare (double, 2, d1, d2);
+ d1 = 2 / d0; d2 = dvec_2 / d0; veccompare (double, 2, d1, d2);
+
+ d1 = d0 + 2; d2 = d0 + dvec_2; veccompare (double, 2, d1, d2);
+ d1 = d0 - 2; d2 = d0 - dvec_2; veccompare (double, 2, d1, d2);
+ d1 = d0 * 2; d2 = d0 * dvec_2; veccompare (double, 2, d1, d2);
+ d1 = d0 / 2; d2 = d0 / dvec_2; veccompare (double, 2, d1, d2);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scope-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scope-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scope-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/scope-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+int v = 3;
+
+f ()
+{
+ int v = 4;
+ {
+ extern int v;
+ if (v != 3)
+ abort ();
+ }
+}
+
+main ()
+{
+ f ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftdi-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftdi-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftdi-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftdi-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* { dg-require-effective-target longlong64 } */
+
+long long a = 568513516876543756;
+long long b = -754324895235774564;
+unsigned long long c = 156789543257562457;
+
+long long expected_a[64] = {568513516876543756, 1137027033753087512, 2274054067506175024, 4548108135012350048, 9096216270024700096, -254311533660151424, -508623067320302848, -1017246134640605696, -2034492269281211392, -4068984538562422784, -8137969077124845568, 2170805919459860480, 4341611838919720960, 8683223677839441920, -1080296718030667776, -2160593436061335552, -4321186872122671104, -8642373744245342208, 1161996585218867200, 2323993170437734400, 4647986340875468800, -9150771391958614016, 145201289792323584, 290402579584647168, 580805159169294336, 1161610318338588672, 2323220636677177344, 4646441273354354688, -9153861527000842240, 139021019707867136, 278042039415734272, 556084078831468544, 1112168157662937088, 2224336315325874176, 4448672630651748352, 8897345261303496704, -652053551102558208, -1304107102205116416, -2608214204410232832, -5216428408820465664, 8013887256068620288, -2418969561572311040, -4837939123144622080, 8770865827420307456, -905012418868936704, -1810024837737873408, -3620049675475746816, -7240099350951493632, 3966545371806564352, 7933090743613128704, -2580562586483294208, -5161125172966588416, 8124493727776374784, -2197756618156802048, -4395513236313604096, -8791026472627208192, 864691128455135232, 1729382256910270464, 3458764513820540928, 6917529027641081856, -4611686018427387904, -9223372036854775808ULL, 0, 0};
+long long expected_b[64] = {-754324895235774564, -377162447617887282, -188581223808943641, -94290611904471821, -47145305952235911, -23572652976117956, -11786326488058978, -5893163244029489, -2946581622014745, -1473290811007373, -736645405503687, -368322702751844, -184161351375922, -92080675687961, -46040337843981, -23020168921991, -11510084460996, -5755042230498, -2877521115249, -1438760557625, -719380278813, -359690139407, -179845069704, -89922534852, -44961267426, -22480633713, -11240316857, -5620158429, -2810079215, -1405039608, -702519804, -351259902, -175629951, -87814976, -43907488, -21953744, -10976872, -5488436, -2744218, -1372109, -686055, -343028, -171514, -85757, -42879, -21440, -10720, -5360, -2680, -1340, -670, -335, -168, -84, -42, -21, -11, -6, -3, -2, -1, -1, -1, -1};
+unsigned long long expected_c[64] = {156789543257562457, 78394771628781228, 39197385814390614, 19598692907195307, 9799346453597653, 4899673226798826, 2449836613399413, 1224918306699706, 612459153349853, 306229576674926, 153114788337463, 76557394168731, 38278697084365, 19139348542182, 9569674271091, 4784837135545, 2392418567772, 1196209283886, 598104641943, 299052320971, 149526160485, 74763080242, 37381540121, 18690770060, 9345385030, 4672692515, 2336346257, 1168173128, 584086564, 292043282, 146021641, 73010820, 36505410, 18252705, 9126352, 4563176, 2281588, 1140794, 570397, 285198, 142599, 71299, 35649, 17824, 8912, 4456, 2228, 1114, 557, 278, 139, 69, 34, 17, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0};
+
+int
+main (void)
+{
+ int i;
+
+ for (i = 0; i < 64; i++)
+ {
+ if ((a << i) != expected_a[i]
+ || (b >> i) != expected_b[i]
+ || (c >> i) != expected_c[i])
+ __builtin_abort ();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftdi.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftdi.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftdi.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftdi.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* { dg-require-effective-target int32plus } */
+
+/* Failed on sparc with -mv8plus because sparc.c:set_extends() thought
+ erroneously that SImode ASHIFT chops the upper bits, it does not. */
+
+typedef unsigned long long uint64;
+
+void g(uint64 x, int y, int z, uint64 *p)
+{
+ unsigned w = ((x >> y) & 0xffffffffULL) << (z & 0x1f);
+ *p |= (w & 0xffffffffULL) << z;
+}
+
+int main(void)
+{
+ uint64 a = 0;
+ g(0xdeadbeef01234567ULL, 0, 0, &a);
+ return (a == 0x01234567) ? 0 : 1;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftopt-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftopt-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftopt-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/shiftopt-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,66 @@
+/* Copyright (C) 2002 Free Software Foundation
+
+ Check that constant folding of shift operations is working.
+
+ Roger Sayle, 10th October 2002. */
+
+extern void abort (void);
+extern void link_error (void);
+
+void
+utest (unsigned int x)
+{
+ if (x >> 0 != x)
+ link_error ();
+
+ if (x << 0 != x)
+ link_error ();
+
+ if (0 << x != 0)
+ link_error ();
+
+ if (0 >> x != 0)
+ link_error ();
+
+ if (-1 >> x != -1)
+ link_error ();
+
+ if (~0 >> x != ~0)
+ link_error ();
+}
+
+void
+stest (int x)
+{
+ if (x >> 0 != x)
+ link_error ();
+
+ if (x << 0 != x)
+ link_error ();
+
+ if (0 << x != 0)
+ link_error ();
+
+ if (0 >> x != 0)
+ link_error ();
+}
+
+int
+main ()
+{
+ utest(9);
+ utest(0);
+
+ stest(9);
+ stest(0);
+
+ return 0;
+}
+
+#ifndef __OPTIMIZE__
+void
+link_error ()
+{
+ abort ();
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,74 @@
+/* Origin: Aldy Hernandez <aldyh at redhat.com>
+
+ Purpose: Test generic SIMD support. This test should work
+ regardless of if the target has SIMD instructions.
+*/
+
+typedef int __attribute__((mode(SI))) __attribute__((vector_size (16))) vecint;
+typedef int __attribute__((mode(SI))) siint;
+
+vecint i = { 150, 100, 150, 200 };
+vecint j = { 10, 13, 20, 30 };
+vecint k;
+
+union {
+ vecint v;
+ siint i[4];
+} res;
+
+/* This should go away once we can use == and != on vector types. */
+void
+verify (siint a1, siint a2, siint a3, siint a4,
+ siint b1, siint b2, siint b3, siint b4)
+{
+ if (a1 != b1
+ || a2 != b2
+ || a3 != b3
+ || a4 != b4)
+ abort ();
+}
+
+int
+main ()
+{
+ k = i + j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 160, 113, 170, 230);
+
+ k = i * j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 1500, 1300, 3000, 6000);
+
+ k = i / j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 15, 7, 7, 6);
+
+ k = i & j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 2, 4, 20, 8);
+
+ k = i | j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 158, 109, 150, 222);
+
+ k = i ^ j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 156, 105, 130, 214);
+
+ k = -i;
+ res.v = k;
+ verify (res.i[0], res.i[1], res.i[2], res.i[3],
+ -150, -100, -150, -200);
+
+ k = ~i;
+ res.v = k;
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], -151, -101, -151, -201);
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,72 @@
+/*
+ Purpose: Test generic SIMD support, V8HImode. This test should work
+ regardless of if the target has SIMD instructions.
+*/
+
+typedef short __attribute__((vector_size (16))) vecint;
+
+vecint i = { 150, 100, 150, 200, 0, 0, 0, 0 };
+vecint j = { 10, 13, 20, 30, 1, 1, 1, 1 };
+vecint k;
+
+union {
+ vecint v;
+ short i[8];
+} res;
+
+/* This should go away once we can use == and != on vector types. */
+void
+verify (int a1, int a2, int a3, int a4,
+ int b1, int b2, int b3, int b4)
+{
+ if (a1 != b1
+ || a2 != b2
+ || a3 != b3
+ || a4 != b4)
+ abort ();
+}
+
+int
+main ()
+{
+ k = i + j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 160, 113, 170, 230);
+
+ k = i * j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 1500, 1300, 3000, 6000);
+
+ k = i / j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 15, 7, 7, 6);
+
+ k = i & j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 2, 4, 20, 8);
+
+ k = i | j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 158, 109, 150, 222);
+
+ k = i ^ j;
+ res.v = k;
+
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], 156, 105, 130, 214);
+
+ k = -i;
+ res.v = k;
+ verify (res.i[0], res.i[1], res.i[2], res.i[3],
+ -150, -100, -150, -200);
+
+ k = ~i;
+ res.v = k;
+ verify (res.i[0], res.i[1], res.i[2], res.i[3], -151, -101, -151, -201);
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* { dg-require-effective-target stdint_types } */
+#include <stdint.h>
+typedef int32_t __attribute__((vector_size(8))) v2si;
+int64_t s64;
+
+static inline int64_t
+__ev_convert_s64 (v2si a)
+{
+ return (int64_t) a;
+}
+
+int main()
+{
+ union { int64_t ll; int32_t i[2]; } endianness_test;
+ endianness_test.ll = 1;
+ int32_t little_endian = endianness_test.i[0];
+ s64 = __ev_convert_s64 ((v2si){1,0xffffffff});
+ if (s64 != (little_endian ? 0xffffffff00000001LL : 0x1ffffffffLL))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,59 @@
+/* Test saving and restoring of SIMD registers. */
+
+typedef short Q __attribute__((vector_size(8)));
+
+Q q1 = {1, 2}, q2 = {3, 4}, q3 = {5, 6}, q4 = {7, 8};
+
+Q w1, w2, w3, w4;
+Q z1, z2, z3, z4;
+
+volatile int dummy;
+
+void __attribute__((__noinline__))
+func0 (void)
+{
+ dummy = 1;
+}
+
+void __attribute__((__noinline__))
+func1 (void)
+{
+ Q a, b;
+ a = q1 * q2;
+ b = q3 * q4;
+ w1 = a;
+ w2 = b;
+ func0 ();
+ w3 = a;
+ w4 = b;
+}
+
+void __attribute__((__noinline__))
+func2 (void)
+{
+ Q a, b;
+ a = q1 + q2;
+ b = q3 - q4;
+ z1 = a;
+ z2 = b;
+ func1 ();
+ z3 = a;
+ z4 = b;
+}
+
+int
+main (void)
+{
+ func2 ();
+
+ if (memcmp (&w1, &w3, sizeof (Q)) != 0)
+ abort ();
+ if (memcmp (&w2, &w4, sizeof (Q)) != 0)
+ abort ();
+ if (memcmp (&z1, &z3, sizeof (Q)) != 0)
+ abort ();
+ if (memcmp (&z2, &z4, sizeof (Q)) != 0)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-6.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-6.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-6.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/simd-6.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+extern void abort (void);
+extern int memcmp (const void *, const void *, __SIZE_TYPE__);
+
+typedef unsigned char v8qi __attribute__((vector_size(8)));
+
+v8qi foo(v8qi x, v8qi y)
+{
+ return x * y;
+}
+
+int main()
+{
+ v8qi a = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ v8qi b = { 3, 3, 3, 3, 3, 3, 3, 3 };
+ v8qi c = { 3, 6, 9, 12, 15, 18, 21, 24 };
+ v8qi r;
+
+ r = foo (a, b);
+ if (memcmp (&r, &c, 8) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ssad-run.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ssad-run.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ssad-run.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ssad-run.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,49 @@
+extern void abort ();
+extern int abs (int __x) __attribute__ ((__nothrow__, __leaf__)) __attribute__ ((__const__));
+
+static int
+foo (signed char *w, int i, signed char *x, int j)
+{
+ int tot = 0;
+ for (int a = 0; a < 16; a++)
+ {
+ for (int b = 0; b < 16; b++)
+ tot += abs (w[b] - x[b]);
+ w += i;
+ x += j;
+ }
+ return tot;
+}
+
+void
+bar (signed char *w, signed char *x, int i, int *result)
+{
+ *result = foo (w, 16, x, i);
+}
+
+int
+main (void)
+{
+ signed char m[256];
+ signed char n[256];
+ int sum, i;
+
+ for (i = 0; i < 256; ++i)
+ if (i % 2 == 0)
+ {
+ m[i] = (i % 8) * 2 + 1;
+ n[i] = -(i % 8);
+ }
+ else
+ {
+ m[i] = -((i % 8) * 2 + 2);
+ n[i] = -((i % 8) >> 1);
+ }
+
+ bar (m, n, 16, &sum);
+
+ if (sum != 2368)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,156 @@
+#include <stdarg.h>
+
+extern void abort (void);
+
+int foo_arg, bar_arg;
+long x;
+double d;
+va_list gap;
+va_list *pap;
+
+void
+foo (int v, va_list ap)
+{
+ switch (v)
+ {
+ case 5: foo_arg = va_arg (ap, int); break;
+ default: abort ();
+ }
+}
+
+void
+bar (int v)
+{
+ if (v == 0x4006)
+ {
+ if (va_arg (gap, double) != 17.0
+ || va_arg (gap, long) != 129L)
+ abort ();
+ }
+ else if (v == 0x4008)
+ {
+ if (va_arg (*pap, long long) != 14LL
+ || va_arg (*pap, long double) != 131.0L
+ || va_arg (*pap, int) != 17)
+ abort ();
+ }
+ bar_arg = v;
+}
+
+void
+f0 (int i, ...)
+{
+}
+
+void
+f1 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ va_end (ap);
+}
+
+void
+f2 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ bar (d);
+ x = va_arg (ap, long);
+ bar (x);
+ va_end (ap);
+}
+
+void
+f3 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ d = va_arg (ap, double);
+ va_end (ap);
+}
+
+void
+f4 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ x = va_arg (ap, double);
+ foo (i, ap);
+ va_end (ap);
+}
+
+void
+f5 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ va_copy (gap, ap);
+ bar (i);
+ va_end (ap);
+ va_end (gap);
+}
+
+void
+f6 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ bar (d);
+ va_arg (ap, long);
+ va_arg (ap, long);
+ x = va_arg (ap, long);
+ bar (x);
+ va_end (ap);
+}
+
+void
+f7 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ pap = ≈
+ bar (i);
+ va_end (ap);
+}
+
+void
+f8 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ pap = ≈
+ bar (i);
+ d = va_arg (ap, double);
+ va_end (ap);
+}
+
+int
+main (void)
+{
+ f0 (1);
+ f1 (2);
+ d = 31.0;
+ f2 (3, 28L);
+ if (bar_arg != 28 || x != 28)
+ abort ();
+ f3 (4, 131.0);
+ if (d != 131.0)
+ abort ();
+ f4 (5, 16.0, 128);
+ if (x != 16 || foo_arg != 128)
+ abort ();
+ f5 (0x4006, 17.0, 129L);
+ if (bar_arg != 0x4006)
+ abort ();
+ f6 (7, 12L, 14L, -31L);
+ if (bar_arg != -31)
+ abort ();
+ f7 (0x4008, 14LL, 131.0L, 17, 26.0);
+ if (bar_arg != 0x4008)
+ abort ();
+ f8 (0x4008, 14LL, 131.0L, 17, 27.0);
+ if (bar_arg != 0x4008 || d != 27.0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,180 @@
+#include <stdarg.h>
+
+extern void abort (void);
+
+int foo_arg, bar_arg;
+long x;
+double d;
+va_list gap;
+
+void
+foo (int v, va_list ap)
+{
+ switch (v)
+ {
+ case 5:
+ foo_arg = va_arg (ap, int);
+ foo_arg += va_arg (ap, double);
+ foo_arg += va_arg (ap, long long);
+ break;
+ case 8:
+ foo_arg = va_arg (ap, long long);
+ foo_arg += va_arg (ap, double);
+ break;
+ case 11:
+ foo_arg = va_arg (ap, int);
+ foo_arg += va_arg (ap, long double);
+ break;
+ default:
+ abort ();
+ }
+}
+
+void
+bar (int v)
+{
+ if (v == 0x4002)
+ {
+ if (va_arg (gap, int) != 13 || va_arg (gap, double) != -14.0)
+ abort ();
+ }
+ bar_arg = v;
+}
+
+void
+f1 (int i, ...)
+{
+ va_start (gap, i);
+ x = va_arg (gap, long);
+ va_end (gap);
+}
+
+void
+f2 (int i, ...)
+{
+ va_start (gap, i);
+ bar (i);
+ va_end (gap);
+}
+
+void
+f3 (int i, ...)
+{
+ va_list aps[10];
+ va_start (aps[4], i);
+ x = va_arg (aps[4], long);
+ va_end (aps[4]);
+}
+
+void
+f4 (int i, ...)
+{
+ va_list aps[10];
+ va_start (aps[4], i);
+ bar (i);
+ va_end (aps[4]);
+}
+
+void
+f5 (int i, ...)
+{
+ va_list aps[10];
+ va_start (aps[4], i);
+ foo (i, aps[4]);
+ va_end (aps[4]);
+}
+
+struct A { int i; va_list g; va_list h[2]; };
+
+void
+f6 (int i, ...)
+{
+ struct A a;
+ va_start (a.g, i);
+ x = va_arg (a.g, long);
+ va_end (a.g);
+}
+
+void
+f7 (int i, ...)
+{
+ struct A a;
+ va_start (a.g, i);
+ bar (i);
+ va_end (a.g);
+}
+
+void
+f8 (int i, ...)
+{
+ struct A a;
+ va_start (a.g, i);
+ foo (i, a.g);
+ va_end (a.g);
+}
+
+void
+f10 (int i, ...)
+{
+ struct A a;
+ va_start (a.h[1], i);
+ x = va_arg (a.h[1], long);
+ va_end (a.h[1]);
+}
+
+void
+f11 (int i, ...)
+{
+ struct A a;
+ va_start (a.h[1], i);
+ bar (i);
+ va_end (a.h[1]);
+}
+
+void
+f12 (int i, ...)
+{
+ struct A a;
+ va_start (a.h[1], i);
+ foo (i, a.h[1]);
+ va_end (a.h[1]);
+}
+
+int
+main (void)
+{
+ f1 (1, 79L);
+ if (x != 79L)
+ abort ();
+ f2 (0x4002, 13, -14.0);
+ if (bar_arg != 0x4002)
+ abort ();
+ f3 (3, 2031L);
+ if (x != 2031)
+ abort ();
+ f4 (4, 18);
+ if (bar_arg != 4)
+ abort ();
+ f5 (5, 1, 19.0, 18LL);
+ if (foo_arg != 38)
+ abort ();
+ f6 (6, 18L);
+ if (x != 18L)
+ abort ();
+ f7 (7);
+ if (bar_arg != 7)
+ abort ();
+ f8 (8, 2031LL, 13.0);
+ if (foo_arg != 2044)
+ abort ();
+ f10 (9, 180L);
+ if (x != 180L)
+ abort ();
+ f11 (10);
+ if (bar_arg != 10)
+ abort ();
+ f12 (11, 2030, 12.0L);
+ if (foo_arg != 2042)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,166 @@
+#include <stdarg.h>
+
+extern void abort (void);
+
+int foo_arg, bar_arg;
+long x;
+double d;
+va_list gap;
+struct S1 { int i; double d; int j; double e; } s1;
+struct S2 { double d; long i; } s2;
+int y;
+
+void
+bar (int v)
+{
+ bar_arg = v;
+}
+
+void
+f1 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ while (i-- > 0)
+ x = va_arg (ap, long);
+ va_end (ap);
+}
+
+void
+f2 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ while (i-- > 0)
+ d = va_arg (ap, double);
+ va_end (ap);
+}
+
+void
+f3 (int i, ...)
+{
+ va_list ap;
+ int j = i;
+ while (j-- > 0)
+ {
+ va_start (ap, i);
+ x = va_arg (ap, long);
+ va_end (ap);
+ bar (x);
+ }
+}
+
+void
+f4 (int i, ...)
+{
+ va_list ap;
+ int j = i;
+ while (j-- > 0)
+ {
+ va_start (ap, i);
+ d = va_arg (ap, double);
+ va_end (ap);
+ bar (d + 4.0);
+ }
+}
+
+void
+f5 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ while (i-- > 0)
+ s1 = va_arg (ap, struct S1);
+ va_end (ap);
+}
+
+void
+f6 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ while (i-- > 0)
+ s2 = va_arg (ap, struct S2);
+ va_end (ap);
+}
+
+void
+f7 (int i, ...)
+{
+ va_list ap;
+ int j = i;
+ while (j-- > 0)
+ {
+ va_start (ap, i);
+ s1 = va_arg (ap, struct S1);
+ va_end (ap);
+ bar (s1.i);
+ }
+}
+
+void
+f8 (int i, ...)
+{
+ va_list ap;
+ int j = i;
+ while (j-- > 0)
+ {
+ va_start (ap, i);
+ s2 = va_arg (ap, struct S2);
+ y = va_arg (ap, int);
+ va_end (ap);
+ bar (s2.i);
+ }
+}
+
+int
+main (void)
+{
+ struct S1 a1, a3;
+ struct S2 a2, a4;
+
+ f1 (7, 1L, 2L, 3L, 5L, 7L, 9L, 11L, 13L);
+ if (x != 11L)
+ abort ();
+ f2 (6, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0);
+ if (d != 32.0)
+ abort ();
+ f3 (2, 1L, 3L);
+ if (bar_arg != 1L || x != 1L)
+ abort ();
+ f4 (2, 17.0, 19.0);
+ if (bar_arg != 21 || d != 17.0)
+ abort ();
+ a1.i = 131;
+ a1.j = 251;
+ a1.d = 15.0;
+ a1.e = 191.0;
+ a3 = a1;
+ a3.j = 254;
+ a3.e = 178.0;
+ f5 (2, a1, a3, a1);
+ if (s1.i != 131 || s1.j != 254 || s1.d != 15.0 || s1.e != 178.0)
+ abort ();
+ f5 (3, a1, a3, a1);
+ if (s1.i != 131 || s1.j != 251 || s1.d != 15.0 || s1.e != 191.0)
+ abort ();
+ a2.i = 138;
+ a2.d = 16.0;
+ a4.i = 257;
+ a4.d = 176.0;
+ f6 (2, a2, a4, a2);
+ if (s2.i != 257 || s2.d != 176.0)
+ abort ();
+ f6 (3, a2, a4, a2);
+ if (s2.i != 138 || s2.d != 16.0)
+ abort ();
+ f7 (2, a3, a1, a1);
+ if (s1.i != 131 || s1.j != 254 || s1.d != 15.0 || s1.e != 178.0)
+ abort ();
+ if (bar_arg != 131)
+ abort ();
+ f8 (3, a4, a2, a2);
+ if (s2.i != 257 || s2.d != 176.0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stdarg-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,137 @@
+#include <stdarg.h>
+
+extern void abort (void);
+long x, y;
+
+inline void __attribute__((always_inline))
+f1i (va_list ap)
+{
+ x = va_arg (ap, double);
+ x += va_arg (ap, long);
+ x += va_arg (ap, double);
+}
+
+void
+f1 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ f1i (ap);
+ va_end (ap);
+}
+
+inline void __attribute__((always_inline))
+f2i (va_list ap)
+{
+ y = va_arg (ap, int);
+ y += va_arg (ap, long);
+ y += va_arg (ap, double);
+ f1i (ap);
+}
+
+void
+f2 (int i, ...)
+{
+ va_list ap;
+ va_start (ap, i);
+ f2i (ap);
+ va_end (ap);
+}
+
+long
+f3h (int i, long arg0, long arg1, long arg2, long arg3)
+{
+ return i + arg0 + arg1 + arg2 + arg3;
+}
+
+long
+f3 (int i, ...)
+{
+ long t, arg0, arg1, arg2, arg3;
+ va_list ap;
+
+ va_start (ap, i);
+ switch (i)
+ {
+ case 0:
+ t = f3h (i, 0, 0, 0, 0);
+ break;
+ case 1:
+ arg0 = va_arg (ap, long);
+ t = f3h (i, arg0, 0, 0, 0);
+ break;
+ case 2:
+ arg0 = va_arg (ap, long);
+ arg1 = va_arg (ap, long);
+ t = f3h (i, arg0, arg1, 0, 0);
+ break;
+ case 3:
+ arg0 = va_arg (ap, long);
+ arg1 = va_arg (ap, long);
+ arg2 = va_arg (ap, long);
+ t = f3h (i, arg0, arg1, arg2, 0);
+ break;
+ case 4:
+ arg0 = va_arg (ap, long);
+ arg1 = va_arg (ap, long);
+ arg2 = va_arg (ap, long);
+ arg3 = va_arg (ap, long);
+ t = f3h (i, arg0, arg1, arg2, arg3);
+ break;
+ default:
+ abort ();
+ }
+ va_end (ap);
+
+ return t;
+}
+
+void
+f4 (int i, ...)
+{
+ va_list ap;
+
+ va_start (ap, i);
+ switch (i)
+ {
+ case 4:
+ y = va_arg (ap, double);
+ break;
+ case 5:
+ y = va_arg (ap, double);
+ y += va_arg (ap, double);
+ break;
+ default:
+ abort ();
+ }
+ f1i (ap);
+ va_end (ap);
+}
+
+int
+main (void)
+{
+ f1 (3, 16.0, 128L, 32.0);
+ if (x != 176L)
+ abort ();
+ f2 (6, 5, 7L, 18.0, 19.0, 17L, 64.0);
+ if (x != 100L || y != 30L)
+ abort ();
+ if (f3 (0) != 0)
+ abort ();
+ if (f3 (1, 18L) != 19L)
+ abort ();
+ if (f3 (2, 18L, 100L) != 120L)
+ abort ();
+ if (f3 (3, 18L, 100L, 300L) != 421L)
+ abort ();
+ if (f3 (4, 18L, 71L, 64L, 86L) != 243L)
+ abort ();
+ f4 (4, 6.0, 9.0, 16L, 18.0);
+ if (x != 43L || y != 6L)
+ abort ();
+ f4 (5, 7.0, 21.0, 1.0, 17L, 126.0);
+ if (x != 144L || y != 28L)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stkalign.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stkalign.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stkalign.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/stkalign.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,44 @@
+/* { dg-options "-fno-inline" } */
+/* Check that stack alignment is not affected by variables not placed
+ on the stack. */
+
+#include <assert.h>
+
+#define ALIGNMENT 64
+
+unsigned test(unsigned n, unsigned p)
+{
+ static struct { char __attribute__((__aligned__(ALIGNMENT))) c; } s;
+ unsigned x;
+
+ assert(__alignof__(s) == ALIGNMENT);
+ asm ("" : "=g" (x), "+m" (s) : "0" (&x));
+
+ return n ? test(n - 1, x) : (x ^ p);
+}
+
+unsigned test2(unsigned n, unsigned p)
+{
+ static struct { char c; } s;
+ unsigned x;
+
+ assert(__alignof__(s) != ALIGNMENT);
+ asm ("" : "=g" (x), "+m" (s) : "0" (&x));
+
+ return n ? test2(n - 1, x) : (x ^ p);
+}
+
+int main (int argc, char *argv[] __attribute__((unused)))
+{
+ unsigned int x, y;
+
+ x = test(argc, 0);
+ x |= test(argc + 1, 0);
+ x |= test(argc + 2, 0);
+
+ y = test2(argc, 0);
+ y |= test2(argc + 1, 0);
+ y |= test2(argc + 2, 0);
+
+ return (x & (ALIGNMENT - 1)) == 0 && (y & (ALIGNMENT - 1)) != 0 ? 1 : 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcmp-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcmp-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcmp-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcmp-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,131 @@
+/* Copyright (C) 2002 Free Software Foundation.
+
+ Test strcmp with various combinations of pointer alignments and lengths to
+ make sure any optimizations in the library are correct.
+
+ Written by Michael Meissner, March 9, 2002. */
+
+#include <string.h>
+#include <stddef.h>
+
+#ifndef MAX_OFFSET
+#define MAX_OFFSET (sizeof (long long))
+#endif
+
+#ifndef MAX_TEST
+#define MAX_TEST (8 * sizeof (long long))
+#endif
+
+#ifndef MAX_EXTRA
+#define MAX_EXTRA (sizeof (long long))
+#endif
+
+#define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA + 2)
+
+static union {
+ unsigned char buf[MAX_LENGTH];
+ long long align_int;
+ long double align_fp;
+} u1, u2;
+
+void
+test (const unsigned char *s1, const unsigned char *s2, int expected)
+{
+ int value = strcmp ((char *) s1, (char *) s2);
+
+ if (expected < 0 && value >= 0)
+ abort ();
+ else if (expected == 0 && value != 0)
+ abort ();
+ else if (expected > 0 && value <= 0)
+ abort ();
+}
+
+main ()
+{
+ size_t off1, off2, len, i;
+ unsigned char *buf1, *buf2;
+ unsigned char *mod1, *mod2;
+ unsigned char *p1, *p2;
+
+ for (off1 = 0; off1 < MAX_OFFSET; off1++)
+ for (off2 = 0; off2 < MAX_OFFSET; off2++)
+ for (len = 0; len < MAX_TEST; len++)
+ {
+ p1 = u1.buf;
+ for (i = 0; i < off1; i++)
+ *p1++ = '\0';
+
+ buf1 = p1;
+ for (i = 0; i < len; i++)
+ *p1++ = 'a';
+
+ mod1 = p1;
+ for (i = 0; i < MAX_EXTRA+2; i++)
+ *p1++ = 'x';
+
+ p2 = u2.buf;
+ for (i = 0; i < off2; i++)
+ *p2++ = '\0';
+
+ buf2 = p2;
+ for (i = 0; i < len; i++)
+ *p2++ = 'a';
+
+ mod2 = p2;
+ for (i = 0; i < MAX_EXTRA+2; i++)
+ *p2++ = 'x';
+
+ mod1[0] = '\0';
+ mod2[0] = '\0';
+ test (buf1, buf2, 0);
+
+ mod1[0] = 'a';
+ mod1[1] = '\0';
+ mod2[0] = '\0';
+ test (buf1, buf2, +1);
+
+ mod1[0] = '\0';
+ mod2[0] = 'a';
+ mod2[1] = '\0';
+ test (buf1, buf2, -1);
+
+ mod1[0] = 'b';
+ mod1[1] = '\0';
+ mod2[0] = 'c';
+ mod2[1] = '\0';
+ test (buf1, buf2, -1);
+
+ mod1[0] = 'c';
+ mod1[1] = '\0';
+ mod2[0] = 'b';
+ mod2[1] = '\0';
+ test (buf1, buf2, +1);
+
+ mod1[0] = 'b';
+ mod1[1] = '\0';
+ mod2[0] = (unsigned char)'\251';
+ mod2[1] = '\0';
+ test (buf1, buf2, -1);
+
+ mod1[0] = (unsigned char)'\251';
+ mod1[1] = '\0';
+ mod2[0] = 'b';
+ mod2[1] = '\0';
+ test (buf1, buf2, +1);
+
+ mod1[0] = (unsigned char)'\251';
+ mod1[1] = '\0';
+ mod2[0] = (unsigned char)'\252';
+ mod2[1] = '\0';
+ test (buf1, buf2, -1);
+
+ mod1[0] = (unsigned char)'\252';
+ mod1[1] = '\0';
+ mod2[0] = (unsigned char)'\251';
+ mod2[1] = '\0';
+ test (buf1, buf2, +1);
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcpy-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcpy-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcpy-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcpy-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,75 @@
+/* Copyright (C) 2002 Free Software Foundation.
+
+ Test strcpy with various combinations of pointer alignments and lengths to
+ make sure any optimizations in the library are correct. */
+
+#include <string.h>
+
+#ifndef MAX_OFFSET
+#define MAX_OFFSET (sizeof (long long))
+#endif
+
+#ifndef MAX_COPY
+#define MAX_COPY (10 * sizeof (long long))
+#endif
+
+#ifndef MAX_EXTRA
+#define MAX_EXTRA (sizeof (long long))
+#endif
+
+#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + 1 + MAX_EXTRA)
+
+/* Use a sequence length that is not divisible by two, to make it more
+ likely to detect when words are mixed up. */
+#define SEQUENCE_LENGTH 31
+
+static union {
+ char buf[MAX_LENGTH];
+ long long align_int;
+ long double align_fp;
+} u1, u2;
+
+main ()
+{
+ int off1, off2, len, i;
+ char *p, *q, c;
+
+ for (off1 = 0; off1 < MAX_OFFSET; off1++)
+ for (off2 = 0; off2 < MAX_OFFSET; off2++)
+ for (len = 1; len < MAX_COPY; len++)
+ {
+ for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)
+ {
+ u1.buf[i] = 'a';
+ if (c >= 'A' + SEQUENCE_LENGTH)
+ c = 'A';
+ u2.buf[i] = c;
+ }
+ u2.buf[off2 + len] = '\0';
+
+ p = strcpy (u1.buf + off1, u2.buf + off2);
+ if (p != u1.buf + off1)
+ abort ();
+
+ q = u1.buf;
+ for (i = 0; i < off1; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)
+ {
+ if (c >= 'A' + SEQUENCE_LENGTH)
+ c = 'A';
+ if (*q != c)
+ abort ();
+ }
+
+ if (*q++ != '\0')
+ abort ();
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcpy-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcpy-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcpy-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strcpy-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* Test to make sure strcpy works correctly. */
+#define STRING "Hi!THE"
+
+const char a[] = STRING;
+
+void f(char *a) __attribute__((noinline));
+void f(char *a)
+{
+ __builtin_strcpy (a, STRING);
+}
+
+
+int main(void)
+{
+ int i;
+ char b[sizeof(a)] = {};
+ f(b);
+ for(i = 0; i < sizeof(b); i++)
+ {
+ if (a[i] != b[i])
+ __builtin_abort ();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+typedef struct
+{
+ short s __attribute__ ((aligned(2), packed));
+ double d __attribute__ ((aligned(2), packed));
+} TRIAL;
+
+int
+check (TRIAL *t)
+{
+ if (t->s != 1 || t->d != 16.0)
+ return 1;
+ return 0;
+}
+
+main ()
+{
+ TRIAL trial;
+
+ trial.s = 1;
+ trial.d = 16.0;
+
+ if (check (&trial) != 0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+typedef struct
+{
+ short a __attribute__ ((aligned (2),packed));
+ short *ap[2] __attribute__ ((aligned (2),packed));
+} A;
+
+main ()
+{
+ short i, j = 1;
+ A a, *ap = &a;
+ ap->ap[j] = &i;
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+typedef struct
+{
+ short i __attribute__ ((aligned (2),packed));
+ int f[2] __attribute__ ((aligned (2),packed));
+} A;
+
+f (ap)
+ A *ap;
+{
+ short i, j = 1;
+
+ i = ap->f[1];
+ i += ap->f[j];
+ for (j = 0; j < 2; j++)
+ i += ap->f[j];
+
+ return i;
+}
+
+main ()
+{
+ A a;
+ a.f[0] = 100;
+ a.f[1] = 13;
+ if (f (&a) != 139)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-pack-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+typedef struct
+{
+ unsigned char a __attribute__((packed));
+ unsigned short b __attribute__((packed));
+} three_char_t;
+
+unsigned char
+my_set_a (void)
+{
+ return 0xab;
+}
+
+unsigned short
+my_set_b (void)
+{
+ return 0x1234;
+}
+
+main ()
+{
+ three_char_t three_char;
+
+ three_char.a = my_set_a ();
+ three_char.b = my_set_b ();
+ if (three_char.a != 0xab || three_char.b != 0x1234)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-stdarg-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-stdarg-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-stdarg-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-stdarg-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,61 @@
+#include <stdarg.h>
+
+struct tiny
+{
+ char c;
+ char d;
+ char e;
+ char f;
+ char g;
+};
+
+f (int n, ...)
+{
+ struct tiny x;
+ int i;
+
+ va_list ap;
+ va_start (ap,n);
+ for (i = 0; i < n; i++)
+ {
+ x = va_arg (ap,struct tiny);
+ if (x.c != i + 10)
+ abort();
+ if (x.d != i + 20)
+ abort();
+ if (x.e != i + 30)
+ abort();
+ if (x.f != i + 40)
+ abort();
+ if (x.g != i + 50)
+ abort();
+ }
+ {
+ long x = va_arg (ap, long);
+ if (x != 123)
+ abort();
+ }
+ va_end (ap);
+}
+
+main ()
+{
+ struct tiny x[3];
+ x[0].c = 10;
+ x[1].c = 11;
+ x[2].c = 12;
+ x[0].d = 20;
+ x[1].d = 21;
+ x[2].d = 22;
+ x[0].e = 30;
+ x[1].e = 31;
+ x[2].e = 32;
+ x[0].f = 40;
+ x[1].f = 41;
+ x[2].f = 42;
+ x[0].g = 50;
+ x[1].g = 51;
+ x[2].g = 52;
+ f (3, x[0], x[1], x[2], (long) 123);
+ exit(0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-varg-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-varg-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-varg-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strct-varg-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,42 @@
+#include <stdarg.h>
+
+struct s { int x, y; };
+
+f (int attr, ...)
+{
+ struct s va_values;
+ va_list va;
+ int i;
+
+ va_start (va, attr);
+
+ if (attr != 2)
+ abort ();
+
+ va_values = va_arg (va, struct s);
+ if (va_values.x != 0xaaaa || va_values.y != 0x5555)
+ abort ();
+
+ attr = va_arg (va, int);
+ if (attr != 3)
+ abort ();
+
+ va_values = va_arg (va, struct s);
+ if (va_values.x != 0xffff || va_values.y != 0x1111)
+ abort ();
+
+ va_end (va);
+}
+
+main ()
+{
+ struct s a, b;
+
+ a.x = 0xaaaa;
+ a.y = 0x5555;
+ b.x = 0xffff;
+ b.y = 0x1111;
+
+ f (2, a, 3, b);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-17.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-17.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-17.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-17.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,45 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Test strcpy optimizations don't evaluate side-effects twice.
+
+ Written by Jakub Jelinek, June 23, 2003. */
+
+typedef __SIZE_TYPE__ size_t;
+extern char *strcpy (char *, const char *);
+extern int memcmp (const void *, const void *, size_t);
+extern void abort (void);
+extern void exit (int);
+
+size_t
+test1 (char *s, size_t i)
+{
+ strcpy (s, "foobarbaz" + i++);
+ return i;
+}
+
+size_t
+check2 (void)
+{
+ static size_t r = 5;
+ if (r != 5)
+ abort ();
+ return ++r;
+}
+
+void
+test2 (char *s)
+{
+ strcpy (s, "foobarbaz" + check2 ());
+}
+
+int
+main (void)
+{
+ char buf[10];
+ if (test1 (buf, 7) != 8 || memcmp (buf, "az", 3))
+ abort ();
+ test2 (buf);
+ if (memcmp (buf, "baz", 4))
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-18.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-18.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-18.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-18.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,75 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Test equal pointer optimizations don't break anything.
+
+ Written by Roger Sayle, July 14, 2003. */
+
+extern void abort ();
+typedef __SIZE_TYPE__ size_t;
+
+extern void *memcpy(void*, const void*, size_t);
+extern void *mempcpy(void*, const void*, size_t);
+extern void *memmove(void*, const void*, size_t);
+extern char *strcpy(char*, const char*);
+extern int memcmp(const void*, const void*, size_t);
+extern int strcmp(const char*, const char*);
+extern int strncmp(const char*, const char*, size_t);
+
+
+void test1 (void *ptr)
+{
+ if (memcpy(ptr,ptr,8) != ptr)
+ abort ();
+}
+
+void test2 (char *ptr)
+{
+ if (mempcpy(ptr,ptr,8) != ptr+8)
+ abort ();
+}
+
+void test3 (void *ptr)
+{
+ if (memmove(ptr,ptr,8) != ptr)
+ abort ();
+}
+
+void test4 (char *ptr)
+{
+ if (strcpy(ptr,ptr) != ptr)
+ abort ();
+}
+
+void test5 (void *ptr)
+{
+ if (memcmp(ptr,ptr,8) != 0)
+ abort ();
+}
+
+void test6 (const char *ptr)
+{
+ if (strcmp(ptr,ptr) != 0)
+ abort ();
+}
+
+void test7 (const char *ptr)
+{
+ if (strncmp(ptr,ptr,8) != 0)
+ abort ();
+}
+
+
+int main ()
+{
+ char buf[10];
+
+ test1 (buf);
+ test2 (buf);
+ test3 (buf);
+ test4 (buf);
+ test5 (buf);
+ test6 (buf);
+ test7 (buf);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/string-opt-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,107 @@
+/* Copyright (C) 2000 Free Software Foundation.
+
+ Ensure builtin strlen, strcmp, strchr, strrchr and strncpy
+ perform correctly.
+
+ Written by Jakub Jelinek, 11/7/2000. */
+
+extern void abort (void);
+extern __SIZE_TYPE__ strlen (const char *);
+extern int strcmp (const char *, const char *);
+extern char *strchr (const char *, int);
+extern char *strrchr (const char *, int);
+extern char *strncpy (char *, const char *, __SIZE_TYPE__);
+extern void *memset (void *, int, __SIZE_TYPE__);
+extern int memcmp (const void *, const void *, __SIZE_TYPE__);
+
+int x = 6;
+int y = 1;
+char *bar = "hi world";
+char buf [64];
+
+int main()
+{
+ const char *const foo = "hello world";
+ char dst [64];
+
+ if (strlen (bar) != 8)
+ abort ();
+ if (strlen (bar + (++x & 2)) != 6)
+ abort ();
+ if (x != 7)
+ abort ();
+ if (strlen (foo + (x++, 6)) != 5)
+ abort ();
+ if (x != 8)
+ abort ();
+ if (strlen (foo + (++x & 1)) != 10)
+ abort ();
+ if (x != 9)
+ abort ();
+ if (strcmp (foo + (x -= 6), "lo world"))
+ abort ();
+ if (x != 3)
+ abort ();
+ if (strcmp (foo, bar) >= 0)
+ abort ();
+ if (strcmp (foo, bar + (x++ & 1)) >= 0)
+ abort ();
+ if (x != 4)
+ abort ();
+ if (strchr (foo + (x++ & 7), 'l') != foo + 9)
+ abort ();
+ if (x != 5)
+ abort ();
+ if (strchr (bar, 'o') != bar + 4)
+ abort ();
+ if (strchr (bar, '\0') != bar + 8)
+ abort ();
+ if (strrchr (bar, 'x'))
+ abort ();
+ if (strrchr (bar, 'o') != bar + 4)
+ abort ();
+ if (strcmp (foo + (x++ & 1), "ello world" + (--y & 1)))
+ abort ();
+ if (x != 6 || y != 0)
+ abort ();
+ dst[5] = ' ';
+ dst[6] = '\0';
+ x = 5;
+ y = 1;
+ if (strncpy (dst + 1, foo + (x++ & 3), 4) != dst + 1
+ || x != 6
+ || strcmp (dst + 1, "ello "))
+ abort ();
+ memset (dst, ' ', sizeof dst);
+ if (strncpy (dst + (++x & 1), (y++ & 3) + "foo", 10) != dst + 1
+ || x != 7
+ || y != 2
+ || memcmp (dst, " oo\0\0\0\0\0\0\0\0 ", 12))
+ abort ();
+ memset (dst, ' ', sizeof dst);
+ if (strncpy (dst, "hello", 8) != dst || memcmp (dst, "hello\0\0\0 ", 9))
+ abort ();
+ x = '!';
+ memset (buf, ' ', sizeof buf);
+ if (memset (buf, x++, ++y) != buf
+ || x != '!' + 1
+ || y != 3
+ || memcmp (buf, "!!!", 3))
+ abort ();
+ if (memset (buf + y++, '-', 8) != buf + 3
+ || y != 4
+ || memcmp (buf, "!!!--------", 11))
+ abort ();
+ x = 10;
+ if (memset (buf + ++x, 0, y++) != buf + 11
+ || x != 11
+ || y != 5
+ || memcmp (buf + 8, "---\0\0\0", 7))
+ abort ();
+ if (memset (buf + (x += 4), 0, 6) != buf + 15
+ || x != 15
+ || memcmp (buf + 10, "-\0\0\0\0\0\0\0\0\0", 11))
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,57 @@
+/* Copyright (C) 2002 Free Software Foundation.
+
+ Test strlen with various combinations of pointer alignments and lengths to
+ make sure any optimizations in the library are correct.
+
+ Written by Michael Meissner, March 9, 2002. */
+
+#include <string.h>
+#include <stddef.h>
+
+#ifndef MAX_OFFSET
+#define MAX_OFFSET (sizeof (long long))
+#endif
+
+#ifndef MAX_TEST
+#define MAX_TEST (8 * sizeof (long long))
+#endif
+
+#ifndef MAX_EXTRA
+#define MAX_EXTRA (sizeof (long long))
+#endif
+
+#define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA + 1)
+
+static union {
+ char buf[MAX_LENGTH];
+ long long align_int;
+ long double align_fp;
+} u;
+
+main ()
+{
+ size_t off, len, len2, i;
+ char *p;
+
+ for (off = 0; off < MAX_OFFSET; off++)
+ for (len = 0; len < MAX_TEST; len++)
+ {
+ p = u.buf;
+ for (i = 0; i < off; i++)
+ *p++ = '\0';
+
+ for (i = 0; i < len; i++)
+ *p++ = 'a';
+
+ *p++ = '\0';
+ for (i = 0; i < MAX_EXTRA; i++)
+ *p++ = 'b';
+
+ p = u.buf + off;
+ len2 = strlen (p);
+ if (len != len2)
+ abort ();
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,210 @@
+/* PR tree-optimization/86532 - Wrong code due to a wrong strlen folding */
+
+extern __SIZE_TYPE__ strlen (const char*);
+
+static const char a[2][3] = { "1", "12" };
+static const char b[2][2][5] = { { "1", "12" }, { "123", "1234" } };
+
+volatile int v0 = 0;
+volatile int v1 = 1;
+volatile int v2 = 2;
+
+#define A(expr) \
+ ((expr) ? (void)0 : (__builtin_printf ("assertion on line %i: %s\n", \
+ __LINE__, #expr), \
+ __builtin_abort ()))
+
+void test_array_ref_2_3 (void)
+{
+ A (strlen (a[v0]) == 1);
+ A (strlen (&a[v0][v0]) == 1);
+ A (strlen (&a[0][v0]) == 1);
+ A (strlen (&a[v0][0]) == 1);
+
+ A (strlen (a[v1]) == 2);
+ A (strlen (&a[v1][0]) == 2);
+ A (strlen (&a[1][v0]) == 2);
+ A (strlen (&a[v1][v0]) == 2);
+
+ A (strlen (&a[v1][1]) == 1);
+ A (strlen (&a[v1][1]) == 1);
+
+ A (strlen (&a[v1][2]) == 0);
+ A (strlen (&a[v1][v2]) == 0);
+
+ int i0 = 0;
+ int i1 = i0 + 1;
+ int i2 = i1 + 1;
+
+ A (strlen (a[v0]) == 1);
+ A (strlen (&a[v0][v0]) == 1);
+ A (strlen (&a[i0][v0]) == 1);
+ A (strlen (&a[v0][i0]) == 1);
+
+ A (strlen (a[v1]) == 2);
+ A (strlen (&a[v1][i0]) == 2);
+ A (strlen (&a[i1][v0]) == 2);
+ A (strlen (&a[v1][v0]) == 2);
+
+ A (strlen (&a[v1][i1]) == 1);
+ A (strlen (&a[v1][i1]) == 1);
+
+ A (strlen (&a[v1][i2]) == 0);
+ A (strlen (&a[v1][v2]) == 0);
+}
+
+void test_array_off_2_3 (void)
+{
+ A (strlen (a[0] + 0) == 1);
+ A (strlen (a[0] + v0) == 1);
+ A (strlen (a[v0] + 0) == 1);
+ A (strlen (a[v0] + v0) == 1);
+
+ A (strlen (a[v1] + 0) == 2);
+ A (strlen (a[1] + v0) == 2);
+ A (strlen (a[v1] + 0) == 2);
+ A (strlen (a[v1] + v0) == 2);
+
+ A (strlen (a[v1] + 1) == 1);
+ A (strlen (a[v1] + v1) == 1);
+
+ A (strlen (a[v1] + 2) == 0);
+ A (strlen (a[v1] + v2) == 0);
+
+ int i0 = 0;
+ int i1 = i0 + 1;
+ int i2 = i1 + 1;
+
+ A (strlen (a[i0] + i0) == 1);
+ A (strlen (a[i0] + v0) == 1);
+ A (strlen (a[v0] + i0) == 1);
+ A (strlen (a[v0] + v0) == 1);
+
+ A (strlen (a[v1] + i0) == 2);
+ A (strlen (a[i1] + v0) == 2);
+ A (strlen (a[v1] + i0) == 2);
+ A (strlen (a[v1] + v0) == 2);
+
+ A (strlen (a[v1] + i1) == 1);
+ A (strlen (a[v1] + v1) == 1);
+
+ A (strlen (a[v1] + i2) == 0);
+ A (strlen (a[v1] + v2) == 0);
+}
+
+void test_array_ref_2_2_5 (void)
+{
+ A (strlen (b[0][v0]) == 1);
+ A (strlen (b[v0][0]) == 1);
+
+ A (strlen (&b[0][0][v0]) == 1);
+ A (strlen (&b[0][v0][0]) == 1);
+ A (strlen (&b[v0][0][0]) == 1);
+
+ A (strlen (&b[0][v0][v0]) == 1);
+ A (strlen (&b[v0][0][v0]) == 1);
+ A (strlen (&b[v0][v0][0]) == 1);
+
+ A (strlen (b[0][v1]) == 2);
+ A (strlen (b[v1][0]) == 3);
+
+ A (strlen (&b[0][0][v1]) == 0);
+ A (strlen (&b[0][v1][0]) == 2);
+ A (strlen (&b[v0][0][0]) == 1);
+
+ A (strlen (&b[0][v0][v0]) == 1);
+ A (strlen (&b[v0][0][v0]) == 1);
+ A (strlen (&b[v0][v0][0]) == 1);
+
+ A (strlen (&b[0][v1][v1]) == 1);
+ A (strlen (&b[v1][0][v1]) == 2);
+ A (strlen (&b[v1][v1][0]) == 4);
+ A (strlen (&b[v1][v1][1]) == 3);
+ A (strlen (&b[v1][v1][2]) == 2);
+
+ int i0 = 0;
+ int i1 = i0 + 1;
+ int i2 = i1 + 1;
+
+ A (strlen (b[i0][v0]) == 1);
+ A (strlen (b[v0][i0]) == 1);
+
+ A (strlen (&b[i0][i0][v0]) == 1);
+ A (strlen (&b[i0][v0][i0]) == 1);
+ A (strlen (&b[v0][i0][i0]) == 1);
+
+ A (strlen (&b[i0][v0][v0]) == 1);
+ A (strlen (&b[v0][i0][v0]) == 1);
+ A (strlen (&b[v0][v0][i0]) == 1);
+
+ A (strlen (b[i0][v1]) == 2);
+ A (strlen (b[v1][i0]) == 3);
+
+ A (strlen (&b[i0][i0][v1]) == 0);
+ A (strlen (&b[i0][v1][i0]) == 2);
+ A (strlen (&b[v0][i0][i0]) == 1);
+
+ A (strlen (&b[i0][v0][v0]) == 1);
+ A (strlen (&b[v0][i0][v0]) == 1);
+ A (strlen (&b[v0][v0][i0]) == 1);
+
+ A (strlen (&b[i0][v1][v1]) == 1);
+ A (strlen (&b[v1][i0][v1]) == 2);
+ A (strlen (&b[v1][v1][i0]) == 4);
+ A (strlen (&b[v1][v1][i1]) == 3);
+ A (strlen (&b[v1][v1][i2]) == 2);
+}
+
+void test_array_off_2_2_5 (void)
+{
+ A (strlen (b[0][0] + v0) == 1);
+ A (strlen (b[0][v0] + v0) == 1);
+ A (strlen (b[v0][0] + v0) == 1);
+ A (strlen (b[v0][v0] + v0) == 1);
+
+ A (strlen (b[0][0] + v1) == 0);
+ A (strlen (b[0][v1] + 0) == 2);
+ A (strlen (b[v0][0] + 0) == 1);
+
+ A (strlen (b[0][v0] + v0) == 1);
+ A (strlen (b[v0][0] + v0) == 1);
+ A (strlen (b[v0][v0] + 0) == 1);
+
+ A (strlen (b[0][v1] + v1) == 1);
+ A (strlen (b[v1][0] + v1) == 2);
+ A (strlen (b[v1][v1] + 0) == 4);
+ A (strlen (b[v1][v1] + 1) == 3);
+ A (strlen (b[v1][v1] + 2) == 2);
+
+ int i0 = 0;
+ int i1 = i0 + 1;
+ int i2 = i1 + 1;
+
+ A (strlen (b[i0][i0] + v0) == 1);
+ A (strlen (b[i0][v0] + v0) == 1);
+ A (strlen (b[v0][i0] + v0) == 1);
+ A (strlen (b[v0][v0] + v0) == 1);
+
+ A (strlen (b[i0][i0] + v1) == 0);
+ A (strlen (b[i0][v1] + i0) == 2);
+ A (strlen (b[v0][i0] + i0) == 1);
+
+ A (strlen (b[i0][v0] + v0) == 1);
+ A (strlen (b[v0][i0] + v0) == 1);
+ A (strlen (b[v0][v0] + i0) == 1);
+
+ A (strlen (b[i0][v1] + v1) == 1);
+ A (strlen (b[v1][i0] + v1) == 2);
+ A (strlen (b[v1][v1] + i0) == 4);
+ A (strlen (b[v1][v1] + i1) == 3);
+ A (strlen (b[v1][v1] + i2) == 2);
+}
+
+int main ()
+{
+ test_array_ref_2_3 ();
+ test_array_off_2_3 ();
+
+ test_array_ref_2_2_5 ();
+ test_array_off_2_2_5 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,132 @@
+/* PR tree-optimization/86532 - Wrong code due to a wrong strlen folding
+ starting with r262522
+ Exercise strlen() with a multi-dimensional array of strings with
+ embedded nuls. */
+
+extern __SIZE_TYPE__ strlen (const char*);
+
+static const char a[2][3][9] = {
+ { "1", "1\0002" },
+ { "12\0003", "123\0004" }
+};
+
+volatile int v0 = 0;
+volatile int v1 = 1;
+volatile int v2 = 2;
+volatile int v3 = 3;
+volatile int v4 = 4;
+volatile int v5 = 5;
+volatile int v6 = 6;
+volatile int v7 = 7;
+
+#define A(expr) \
+ ((expr) ? (void)0 : (__builtin_printf ("assertion on line %i: %s\n", \
+ __LINE__, #expr), \
+ __builtin_abort ()))
+
+void test_array_ref (void)
+{
+ int i0 = 0;
+ int i1 = i0 + 1;
+ int i2 = i1 + 1;
+ int i3 = i2 + 1;
+ int i4 = i3 + 1;
+ int i5 = i4 + 1;
+ int i6 = i5 + 1;
+ int i7 = i6 + 1;
+
+ A (strlen (a[0][0]) == 1);
+ A (strlen (a[0][1]) == 1);
+
+ A (strlen (a[1][0]) == 2);
+ A (strlen (a[1][1]) == 3);
+
+ A (strlen (&a[0][0][0]) == 1);
+ A (strlen (&a[0][1][0]) == 1);
+
+ A (strlen (&a[1][0][0]) == 2);
+ A (strlen (&a[1][1][0]) == 3);
+
+ A (strlen (&a[0][0][0] + 1) == 0);
+ A (strlen (&a[0][1][0] + 1) == 0);
+ A (strlen (&a[0][1][0] + 2) == 1);
+ A (strlen (&a[0][1][0] + 3) == 0);
+ A (strlen (&a[0][1][0] + 7) == 0);
+
+ A (strlen (&a[1][0][0] + 1) == 1);
+ A (strlen (&a[1][1][0] + 1) == 2);
+ A (strlen (&a[1][1][0] + 2) == 1);
+ A (strlen (&a[1][1][0] + 7) == 0);
+
+
+ A (strlen (a[i0][i0]) == 1);
+ A (strlen (a[i0][i1]) == 1);
+
+ A (strlen (a[i1][i0]) == 2);
+ A (strlen (a[i1][i1]) == 3);
+
+ A (strlen (&a[i0][i0][i0]) == 1);
+ A (strlen (&a[i0][i1][i0]) == 1);
+ A (strlen (&a[i0][i1][i1]) == 0);
+ A (strlen (&a[i0][i1][i2]) == 1);
+ A (strlen (&a[i0][i1][i3]) == 0);
+ A (strlen (&a[i0][i1][i3]) == 0);
+
+ A (strlen (&a[i1][i0][i0]) == 2);
+ A (strlen (&a[i1][i1][i0]) == 3);
+ A (strlen (&a[i1][i1][i1]) == 2);
+ A (strlen (&a[i1][i1][i2]) == 1);
+ A (strlen (&a[i1][i1][i3]) == 0);
+ A (strlen (&a[i1][i1][i4]) == 1);
+ A (strlen (&a[i1][i1][i5]) == 0);
+ A (strlen (&a[i1][i1][i6]) == 0);
+ A (strlen (&a[i1][i1][i7]) == 0);
+
+ A (strlen (&a[i0][i0][i0] + i1) == 0);
+ A (strlen (&a[i0][i1][i0] + i1) == 0);
+ A (strlen (&a[i0][i1][i0] + i7) == 0);
+
+ A (strlen (&a[i1][i0][i0] + i1) == 1);
+ A (strlen (&a[i1][i1][i0] + i1) == 2);
+ A (strlen (&a[i1][i1][i0] + i2) == 1);
+ A (strlen (&a[i1][i1][i0] + i3) == 0);
+ A (strlen (&a[i1][i1][i0] + i4) == 1);
+ A (strlen (&a[i1][i1][i0] + i5) == 0);
+ A (strlen (&a[i1][i1][i0] + i6) == 0);
+ A (strlen (&a[i1][i1][i0] + i7) == 0);
+
+
+ A (strlen (a[i0][i0]) == 1);
+ A (strlen (a[i0][i1]) == 1);
+
+ A (strlen (a[i1][i0]) == 2);
+ A (strlen (a[i1][i1]) == 3);
+
+ A (strlen (&a[i0][i0][i0]) == 1);
+ A (strlen (&a[i0][i1][i0]) == 1);
+
+ A (strlen (&a[i1][i0][i0]) == 2);
+ A (strlen (&a[i1][i1][i0]) == 3);
+
+ A (strlen (&a[i0][i0][i0] + v1) == 0);
+ A (strlen (&a[i0][i0][i0] + v2) == 0);
+ A (strlen (&a[i0][i0][i0] + v7) == 0);
+
+ A (strlen (&a[i0][i1][i0] + v1) == 0);
+ A (strlen (&a[i0][i1][i0] + v2) == 1);
+ A (strlen (&a[i0][i1][i0] + v3) == 0);
+
+ A (strlen (&a[i1][i0][i0] + v1) == 1);
+ A (strlen (&a[i1][i1][i0] + v1) == 2);
+ A (strlen (&a[i1][i1][i0] + v2) == 1);
+ A (strlen (&a[i1][i1][i0] + v3) == 0);
+ A (strlen (&a[i1][i1][i0] + v4) == 1);
+ A (strlen (&a[i1][i1][i0] + v5) == 0);
+ A (strlen (&a[i1][i1][i0] + v6) == 0);
+ A (strlen (&a[i1][i1][i0] + v7) == 0);
+}
+
+int main (void)
+{
+ test_array_ref ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,232 @@
+/* PR tree-optimization/86622 - incorrect strlen of array of array plus
+ variable offset
+ Exercise strlen() with a multi-dimensional array of strings with
+ offsets. */
+
+extern int printf (const char*, ...);
+extern __SIZE_TYPE__ strlen (const char*);
+
+typedef char A28[28];
+typedef A28 A3_28[3];
+typedef A3_28 A2_3_28[2];
+
+static const A2_3_28 a = {
+ /* [0][0] [0][1] [0][2] */
+ { "1\00012", "123\0001234", "12345\000123456" },
+ /* [1][0] [1][1] [1][2] */
+ { "1234567\00012345678", "123456789\0001234567890", "12345678901\000123456789012" }
+};
+
+volatile int v0 = 0;
+volatile int v1 = 1;
+volatile int v2 = 2;
+volatile int v3 = 3;
+volatile int v4 = 4;
+volatile int v5 = 5;
+volatile int v6 = 6;
+volatile int v7 = 7;
+
+#define A(expr, N) \
+ ((strlen (expr) == N) \
+ ? (void)0 : (printf ("line %i: strlen (%s = \"%s\") != %i\n", \
+ __LINE__, #expr, expr, N), \
+ __builtin_abort ()))
+
+/* Verify that strlen() involving pointer to array arguments computes
+ the correct result. */
+
+void test_array_ptr (void)
+{
+ /* Compute the length of the string at the refeenced array. */
+ A (*(&a[0][0] + 0), 1);
+ A (*(&a[0][0] + 1), 3);
+ A (*(&a[0][0] + 2), 5);
+
+ A (*(&a[0][1] - 1), 1);
+ A (*(&a[0][1] + 0), 3);
+ A (*(&a[0][1] + 1), 5);
+
+ A (*(&a[0][2] - 2), 1);
+ A (*(&a[0][2] - 1), 3);
+ A (*(&a[0][2] + 0), 5);
+
+ A (*(&a[1][0] + 0), 7);
+ A (*(&a[1][0] + 1), 9);
+ A (*(&a[1][0] + 2), 11);
+
+ A (*(&a[1][1] - 1), 7);
+ A (*(&a[1][1] + 0), 9);
+ A (*(&a[1][1] + 1), 11);
+
+ A (*(&a[1][2] - 2), 7);
+ A (*(&a[1][2] - 1), 9);
+ A (*(&a[1][2] - 0), 11);
+
+ /* Compute the length of the string past the first nul. */
+ A (*(&a[0][0] + 0) + 2, 2);
+ A (*(&a[0][0] + 1) + 4, 4);
+ A (*(&a[0][0] + 2) + 6, 6);
+
+ /* Compute the length of the string past the second nul. */
+ A (*(&a[0][0] + 0) + 5, 0);
+ A (*(&a[0][0] + 1) + 10, 0);
+ A (*(&a[0][0] + 2) + 14, 0);
+
+ int i0 = 0;
+ int i1 = i0 + 1;
+ int i2 = i1 + 1;
+ int i3 = i2 + 1;
+ int i4 = i3 + 1;
+ int i5 = i4 + 1;
+
+ A (*(&a[0][0] + i0), 1);
+ A (*(&a[0][0] + i1), 3);
+ A (*(&a[0][0] + i2), 5);
+
+ A (*(&a[0][1] - i1), 1);
+ A (*(&a[0][1] + i0), 3);
+ A (*(&a[0][1] + i1), 5);
+
+ A (*(&a[0][2] - i2), 1);
+ A (*(&a[0][2] - i1), 3);
+ A (*(&a[0][2] + i0), 5);
+
+ A (*(&a[1][0] + i0), 7);
+ A (*(&a[1][0] + i1), 9);
+ A (*(&a[1][0] + i2), 11);
+
+ A (*(&a[1][1] - i1), 7);
+ A (*(&a[1][1] + i0), 9);
+ A (*(&a[1][1] + i1), 11);
+
+ A (*(&a[1][2] - i2), 7);
+ A (*(&a[1][2] - i1), 9);
+ A (*(&a[1][2] - i0), 11);
+
+
+ A (*(&a[i0][i0] + i0), 1);
+ A (*(&a[i0][i0] + i1), 3);
+ A (*(&a[i0][i0] + i2), 5);
+
+ A (*(&a[i0][i1] - i1), 1);
+ A (*(&a[i0][i1] + i0), 3);
+ A (*(&a[i0][i1] + i1), 5);
+
+ A (*(&a[i0][i2] - i2), 1);
+ A (*(&a[i0][i2] - i1), 3);
+ A (*(&a[i0][i2] + i0), 5);
+
+ A (*(&a[i1][i0] + i0), 7);
+ A (*(&a[i1][i0] + i1), 9);
+ A (*(&a[i1][i0] + i2), 11);
+
+ A (*(&a[i1][i1] - i1), 7);
+ A (*(&a[i1][i1] + i0), 9);
+ A (*(&a[i1][i1] + i1), 11);
+
+ A (*(&a[i1][i2] - i2), 7);
+ A (*(&a[i1][i2] - i1), 9);
+ A (*(&a[i1][i2] - i0), 11);
+
+
+ A (*(&a[i0][i0] + v0), 1);
+ A (*(&a[i0][i0] + v1), 3);
+ A (*(&a[i0][i0] + v2), 5);
+
+ A (*(&a[i0][i1] - v1), 1);
+ A (*(&a[i0][i1] + v0), 3);
+ A (*(&a[i0][i1] + v1), 5);
+
+ A (*(&a[i0][i2] - v2), 1);
+ A (*(&a[i0][i2] - v1), 3);
+ A (*(&a[i0][i2] + v0), 5);
+
+ A (*(&a[i1][i0] + v0), 7);
+ A (*(&a[i1][i0] + v1), 9);
+ A (*(&a[i1][i0] + v2), 11);
+
+ A (*(&a[i1][i1] - v1), 7);
+ A (*(&a[i1][i1] + v0), 9);
+ A (*(&a[i1][i1] + v1), 11);
+
+ A (*(&a[i1][i2] - v2), 7);
+ A (*(&a[i1][i2] - v1), 9);
+ A (*(&a[i1][i2] - v0), 11);
+
+
+ A (*(&a[i0][i0] + v0) + i1, 0);
+ A (*(&a[i0][i0] + v1) + i2, 1);
+ A (*(&a[i0][i0] + v2) + i3, 2);
+
+ A (*(&a[i0][i1] - v1) + v1, 0);
+ A (*(&a[i0][i1] + v0) + v3, 0);
+ A (*(&a[i0][i1] + v1) + v5, 0);
+
+ A (*(&a[i0][v1] - i1) + i1, 0);
+ A (*(&a[i0][v1] + i0) + i3, 0);
+ A (*(&a[i0][v1] + i1) + i5, 0);
+}
+
+static const A3_28* const pa0 = &a[0];
+static const A3_28* const pa1 = &a[1];
+
+static const A3_28* const paa[] = { &a[0], &a[1] };
+
+/* Verify that strlen() involving pointers and arrays of pointers
+ to array arguments computes the correct result. */
+
+void test_ptr_array (void)
+{
+ int i0 = 0;
+ int i1 = i0 + 1;
+ int i2 = i1 + 1;
+ int i3 = i2 + 1;
+
+ A (*((*pa0) + i0), 1);
+ A (*((*pa0) + i1), 3);
+ A (*((*pa0) + i2), 5);
+
+ A (*(pa0[0] + i0), 1);
+ A (*(pa0[0] + i1), 3);
+ A (*(pa0[0] + i2), 5);
+
+ A ((*pa0)[i0] + i1, 0);
+ A ((*pa0)[i1] + i2, 1);
+ A ((*pa0)[i2] + i3, 2);
+
+
+ A (*((*pa1) + i0), 7);
+ A (*((*pa1) + i1), 9);
+ A (*((*pa1) + i2), 11);
+
+ A (*(pa1[0] + i0), 7);
+ A (*(pa1[0] + i1), 9);
+ A (*(pa1[0] + i2), 11);
+
+ A ((*pa1)[i0] + i1, 6);
+ A ((*pa1)[i1] + i2, 7);
+ A ((*pa1)[i2] + i3, 8);
+
+ A (*(*(paa[0]) + i0), 1);
+ A (*(*(paa[0]) + i1), 3);
+ A (*(*(paa[0]) + i2), 5);
+
+ A (*(*(paa[1]) + i0), 7);
+ A (*(*(paa[1]) + i1), 9);
+ A (*(*(paa[1]) + i2), 11);
+
+ A (*(*(paa[1]) - i1), 5);
+ A (*(*(paa[1]) - i2), 3);
+ A (*(*(paa[1]) - i3), 1);
+
+ A (*(*(paa[0]) + i0) + i1, 0);
+ A (*(*(paa[0]) + i1) + i2, 1);
+ A (*(*(paa[0]) + i2) + i3, 2);
+}
+
+int main (void)
+{
+ test_array_ptr ();
+
+ test_ptr_array ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,653 @@
+/* Test to verify that even strictly undefined strlen() calls with
+ unterminated character arrays yield the "expected" results when
+ the terminating nul is present in a subsequent suobobject. */
+
+extern __SIZE_TYPE__ strlen (const char *);
+
+unsigned nfails;
+
+#define A(expr, N) \
+ do { \
+ const char *s = (expr); \
+ unsigned n = strlen (s); \
+ ((n == N) \
+ ? 0 \
+ : (__builtin_printf ("line %i: strlen (%s = \"%s\")" \
+ " == %u failed\n", \
+ __LINE__, #expr, s, N), \
+ ++nfails)); \
+ } while (0)
+
+
+int idx;
+
+
+const char ca[][4] = {
+ { '1', '2', '3', '4' }, { '5' },
+ { '1', '2', '3', '4' }, { '5', '6' },
+ { '1', '2', '3', '4' }, { '5', '6', '7' },
+ { '1', '2', '3', '4' }, { '5', '6', '7', '8' },
+ { '9' }
+};
+
+static void test_const_global_arrays (void)
+{
+ A (ca[0], 5);
+ A (&ca[0][0], 5);
+ A (&ca[0][1], 4);
+ A (&ca[0][3], 2);
+
+ int i = 0;
+ A (ca[i], 5);
+ A (&ca[i][0], 5);
+ A (&ca[i][1], 4);
+ A (&ca[i][3], 2);
+
+ int j = i;
+ A (&ca[i][i], 5);
+ A (&ca[i][j + 1], 4);
+ A (&ca[i][j + 2], 3);
+
+ A (&ca[idx][i], 5);
+ A (&ca[idx][j + 1], 4);
+ A (&ca[idx][j + 2], 3);
+
+ A (&ca[idx][idx], 5);
+ A (&ca[idx][idx + 1], 4);
+ A (&ca[idx][idx + 2], 3);
+
+ A (&ca[0][++j], 4);
+ A (&ca[0][++j], 3);
+ A (&ca[0][++j], 2);
+
+ if (j != 3)
+ ++nfails;
+}
+
+
+static void test_const_local_arrays (void)
+{
+ const char a[][4] = {
+ { '1', '2', '3', '4' }, { '5' },
+ { '1', '2', '3', '4' }, { '5', '6' },
+ { '1', '2', '3', '4' }, { '5', '6', '7' },
+ { '1', '2', '3', '4' }, { '5', '6', '7', '8' },
+ { '9' }
+ };
+
+ A (a[0], 5);
+ A (&a[0][0], 5);
+ A (&a[0][1], 4);
+ A (&a[0][3], 2);
+
+ int i = 0;
+ A (a[i], 5);
+ A (&a[i][0], 5);
+ A (&a[i][1], 4);
+ A (&a[i][3], 2);
+
+ int j = i;
+ A (&a[i][i], 5);
+ A (&a[i][j + 1], 4);
+ A (&a[i][j + 2], 3);
+
+ A (&a[idx][i], 5);
+ A (&a[idx][j + 1], 4);
+ A (&a[idx][j + 2], 3);
+
+ A (&a[idx][idx], 5);
+ A (&a[idx][idx + 1], 4);
+ A (&a[idx][idx + 2], 3);
+
+ A (&a[0][++j], 4);
+ A (&a[0][++j], 3);
+ A (&a[0][++j], 2);
+
+ if (j != 3)
+ ++nfails;
+}
+
+
+char va[][4] = {
+ { '1', '2', '3', '4' }, { '5' },
+ { '1', '2', '3', '4' }, { '5', '6' },
+ { '1', '2', '3', '4' }, { '5', '6', '7' },
+ { '1', '2', '3', '4' }, { '5', '6', '7', '8' },
+ { '9' }
+};
+
+static void test_nonconst_global_arrays (void)
+{
+ {
+ A (va[0], 5);
+ A (&va[0][0], 5);
+ A (&va[0][1], 4);
+ A (&va[0][3], 2);
+
+ int i = 0;
+ A (va[i], 5);
+ A (&va[i][0], 5);
+ A (&va[i][1], 4);
+ A (&va[i][3], 2);
+
+ int j = i;
+ A (&va[i][i], 5);
+ A (&va[i][j + 1], 4);
+ A (&va[i][j + 2], 3);
+
+ A (&va[idx][i], 5);
+ A (&va[idx][j + 1], 4);
+ A (&va[idx][j + 2], 3);
+
+ A (&va[idx][idx], 5);
+ A (&va[idx][idx + 1], 4);
+ A (&va[idx][idx + 2], 3);
+ }
+
+ {
+ A (va[2], 6);
+ A (&va[2][0], 6);
+ A (&va[2][1], 5);
+ A (&va[2][3], 3);
+
+ int i = 2;
+ A (va[i], 6);
+ A (&va[i][0], 6);
+ A (&va[i][1], 5);
+ A (&va[i][3], 3);
+
+ int j = i - 1;
+ A (&va[i][j - 1], 6);
+ A (&va[i][j], 5);
+ A (&va[i][j + 1], 4);
+
+ A (&va[idx + 2][i - 1], 5);
+ A (&va[idx + 2][j], 5);
+ A (&va[idx + 2][j + 1], 4);
+ }
+
+ int j = 0;
+
+ A (&va[0][++j], 4);
+ A (&va[0][++j], 3);
+ A (&va[0][++j], 2);
+
+ if (j != 3)
+ ++nfails;
+}
+
+
+static void test_nonconst_local_arrays (void)
+{
+ char a[][4] = {
+ { '1', '2', '3', '4' }, { '5' },
+ { '1', '2', '3', '4' }, { '5', '6' },
+ { '1', '2', '3', '4' }, { '5', '6', '7' },
+ { '1', '2', '3', '4' }, { '5', '6', '7', '8' },
+ { '9' }
+ };
+
+ A (a[0], 5);
+ A (&a[0][0], 5);
+ A (&a[0][1], 4);
+ A (&a[0][3], 2);
+
+ int i = 0;
+ A (a[i], 5);
+ A (&a[i][0], 5);
+ A (&a[i][1], 4);
+ A (&a[i][3], 2);
+
+ int j = i;
+ A (&a[i][i], 5);
+ A (&a[i][j + 1], 4);
+ A (&a[i][j + 2], 3);
+
+ A (&a[idx][i], 5);
+ A (&a[idx][j + 1], 4);
+ A (&a[idx][j + 2], 3);
+
+ A (&a[idx][idx], 5);
+ A (&a[idx][idx + 1], 4);
+ A (&a[idx][idx + 2], 3);
+
+ A (&a[0][++j], 4);
+ A (&a[0][++j], 3);
+ A (&a[0][++j], 2);
+
+ if (j != 3)
+ ++nfails;
+}
+
+
+struct MemArrays { char a[4], b[4]; };
+
+const struct MemArrays cma[] = {
+ { { '1', '2', '3', '4' }, { '5' } },
+ { { '1', '2', '3', '4' }, { '5', '6' } },
+ { { '1', '2', '3', '4' }, { '5', '6' } },
+ { { '1', '2', '3', '4' }, { '5', '6', '7' } },
+ { { '1', '2', '3', '4' }, { '5', '6', '7', '8' } },
+ { { '9' }, { '\0' } }
+};
+
+static void test_const_global_member_arrays (void)
+{
+ {
+ A (cma[0].a, 5);
+ A (&cma[0].a[0], 5);
+ A (&cma[0].a[1], 4);
+ A (&cma[0].a[2], 3);
+
+ int i = 0;
+ A (cma[i].a, 5);
+ A (&cma[i].a[0], 5);
+ A (&cma[i].a[1], 4);
+ A (&cma[i].a[2], 3);
+
+ int j = i;
+ A (&cma[i].a[j], 5);
+ A (&cma[i].a[j + 1], 4);
+ A (&cma[i].a[j + 2], 3);
+
+ A (&cma[idx].a[i], 5);
+ A (&cma[idx].a[j + 1], 4);
+ A (&cma[idx].a[j + 2], 3);
+
+ A (&cma[idx].a[idx], 5);
+ A (&cma[idx].a[idx + 1], 4);
+ A (&cma[idx].a[idx + 2], 3);
+ }
+
+ {
+ A (cma[1].a, 6);
+ A (&cma[1].a[0], 6);
+ A (&cma[1].a[1], 5);
+ A (&cma[1].a[2], 4);
+
+ int i = 1;
+ A (cma[i].a, 6);
+ A (&cma[i].a[0], 6);
+ A (&cma[i].a[1], 5);
+ A (&cma[i].a[2], 4);
+
+ int j = i - 1;
+ A (&cma[i].a[j], 6);
+ A (&cma[i].a[j + 1], 5);
+ A (&cma[i].a[j + 2], 4);
+
+ A (&cma[idx + 1].a[j], 6);
+ A (&cma[idx + 1].a[j + 1], 5);
+ A (&cma[idx + 1].a[j + 2], 4);
+
+ A (&cma[idx + 1].a[idx], 6);
+ A (&cma[idx + 1].a[idx + 1], 5);
+ A (&cma[idx + 1].a[idx + 2], 4);
+ }
+
+ {
+ A (cma[4].a, 9);
+ A (&cma[4].a[0], 9);
+ A (&cma[4].a[1], 8);
+ A (&cma[4].b[0], 5);
+
+ int i = 4;
+ A (cma[i].a, 9);
+ A (&cma[i].a[0], 9);
+ A (&cma[i].a[1], 8);
+ A (&cma[i].b[0], 5);
+
+ int j = i - 1;
+ A (&cma[i].a[j], 6);
+ A (&cma[i].a[j + 1], 5);
+ A (&cma[i].b[j - 2], 4);
+
+ A (&cma[idx + 4].a[j], 6);
+ A (&cma[idx + 4].a[j + 1], 5);
+ A (&cma[idx + 4].b[j - 2], 4);
+
+ A (&cma[idx + 4].a[idx], 9);
+ A (&cma[idx + 4].a[idx + 1], 8);
+ A (&cma[idx + 4].b[idx + 1], 4);
+ }
+}
+
+
+static void test_const_local_member_arrays (void)
+{
+ const struct MemArrays ma[] = {
+ { { '1', '2', '3', '4' }, { '5' } },
+ { { '1', '2', '3', '4' }, { '5', '6' } },
+ { { '1', '2', '3', '4' }, { '5', '6' } },
+ { { '1', '2', '3', '4' }, { '5', '6', '7' } },
+ { { '1', '2', '3', '4' }, { '5', '6', '7', '8' } },
+ { { '9' }, { '\0' } }
+ };
+
+ {
+ A (ma[0].a, 5);
+ A (&ma[0].a[0], 5);
+ A (&ma[0].a[1], 4);
+ A (&ma[0].a[2], 3);
+
+ int i = 0;
+ A (ma[i].a, 5);
+ A (&ma[i].a[0], 5);
+ A (&ma[i].a[1], 4);
+ A (&ma[i].a[2], 3);
+
+ int j = i;
+ A (&ma[i].a[j], 5);
+ A (&ma[i].a[j + 1], 4);
+ A (&ma[i].a[j + 2], 3);
+
+ A (&ma[idx].a[i], 5);
+ A (&ma[idx].a[j + 1], 4);
+ A (&ma[idx].a[j + 2], 3);
+
+ A (&ma[idx].a[idx], 5);
+ A (&ma[idx].a[idx + 1], 4);
+ A (&ma[idx].a[idx + 2], 3);
+ }
+
+ {
+ A (ma[1].a, 6);
+ A (&ma[1].a[0], 6);
+ A (&ma[1].a[1], 5);
+ A (&ma[1].a[2], 4);
+
+ int i = 1;
+ A (ma[i].a, 6);
+ A (&ma[i].a[0], 6);
+ A (&ma[i].a[1], 5);
+ A (&ma[i].a[2], 4);
+
+ int j = i - 1;
+ A (&ma[i].a[j], 6);
+ A (&ma[i].a[j + 1], 5);
+ A (&ma[i].a[j + 2], 4);
+
+ A (&ma[idx + 1].a[j], 6);
+ A (&ma[idx + 1].a[j + 1], 5);
+ A (&ma[idx + 1].a[j + 2], 4);
+
+ A (&ma[idx + 1].a[idx], 6);
+ A (&ma[idx + 1].a[idx + 1], 5);
+ A (&ma[idx + 1].a[idx + 2], 4);
+ }
+
+ {
+ A (ma[4].a, 9);
+ A (&ma[4].a[0], 9);
+ A (&ma[4].a[1], 8);
+ A (&ma[4].b[0], 5);
+
+ int i = 4;
+ A (ma[i].a, 9);
+ A (&ma[i].a[0], 9);
+ A (&ma[i].a[1], 8);
+ A (&ma[i].b[0], 5);
+
+ int j = i - 1;
+ A (&ma[i].a[j], 6);
+ A (&ma[i].a[j + 1], 5);
+ A (&ma[i].b[j - 2], 4);
+
+ A (&ma[idx + 4].a[j], 6);
+ A (&ma[idx + 4].a[j + 1], 5);
+ A (&ma[idx + 4].b[j - 2], 4);
+
+ A (&ma[idx + 4].a[idx], 9);
+ A (&ma[idx + 4].a[idx + 1], 8);
+ A (&ma[idx + 4].b[idx + 1], 4);
+ }
+}
+
+struct MemArrays vma[] = {
+ { { '1', '2', '3', '4' }, { '5' } },
+ { { '1', '2', '3', '4' }, { '5', '6' } },
+ { { '1', '2', '3', '4' }, { '5', '6' } },
+ { { '1', '2', '3', '4' }, { '5', '6', '7' } },
+ { { '1', '2', '3', '4' }, { '5', '6', '7', '8' } },
+ { { '9' }, { '\0' } }
+};
+
+static void test_nonconst_global_member_arrays (void)
+{
+ {
+ A (vma[0].a, 5);
+ A (&vma[0].a[0], 5);
+ A (&vma[0].a[1], 4);
+ A (&vma[0].a[2], 3);
+
+ int i = 0;
+ A (vma[i].a, 5);
+ A (&vma[i].a[0], 5);
+ A (&vma[i].a[1], 4);
+ A (&vma[i].a[2], 3);
+
+ int j = i;
+ A (&vma[i].a[j], 5);
+ A (&vma[i].a[j + 1], 4);
+ A (&vma[i].a[j + 2], 3);
+
+ A (&vma[idx].a[i], 5);
+ A (&vma[idx].a[j + 1], 4);
+ A (&vma[idx].a[j + 2], 3);
+
+ A (&vma[idx].a[idx], 5);
+ A (&vma[idx].a[idx + 1], 4);
+ A (&vma[idx].a[idx + 2], 3);
+ }
+
+ {
+ A (vma[1].a, 6);
+ A (&vma[1].a[0], 6);
+ A (&vma[1].a[1], 5);
+ A (&vma[1].a[2], 4);
+
+ int i = 1;
+ A (vma[i].a, 6);
+ A (&vma[i].a[0], 6);
+ A (&vma[i].a[1], 5);
+ A (&vma[i].a[2], 4);
+
+ int j = i - 1;
+ A (&vma[i].a[j], 6);
+ A (&vma[i].a[j + 1], 5);
+ A (&vma[i].a[j + 2], 4);
+
+ A (&vma[idx + 1].a[j], 6);
+ A (&vma[idx + 1].a[j + 1], 5);
+ A (&vma[idx + 1].a[j + 2], 4);
+
+ A (&vma[idx + 1].a[idx], 6);
+ A (&vma[idx + 1].a[idx + 1], 5);
+ A (&vma[idx + 1].a[idx + 2], 4);
+ }
+
+ {
+ A (vma[4].a, 9);
+ A (&vma[4].a[0], 9);
+ A (&vma[4].a[1], 8);
+ A (&vma[4].b[0], 5);
+
+ int i = 4;
+ A (vma[i].a, 9);
+ A (&vma[i].a[0], 9);
+ A (&vma[i].a[1], 8);
+ A (&vma[i].b[0], 5);
+
+ int j = i - 1;
+ A (&vma[i].a[j], 6);
+ A (&vma[i].a[j + 1], 5);
+ A (&vma[i].b[j - 2], 4);
+
+ A (&vma[idx + 4].a[j], 6);
+ A (&vma[idx + 4].a[j + 1], 5);
+ A (&vma[idx + 4].b[j - 2], 4);
+
+ A (&vma[idx + 4].a[idx], 9);
+ A (&vma[idx + 4].a[idx + 1], 8);
+ A (&vma[idx + 4].b[idx + 1], 4);
+ }
+}
+
+
+static void test_nonconst_local_member_arrays (void)
+{
+ struct MemArrays ma[] = {
+ { { '1', '2', '3', '4' }, { '5' } },
+ { { '1', '2', '3', '4' }, { '5', '6' } },
+ { { '1', '2', '3', '4' }, { '5', '6' } },
+ { { '1', '2', '3', '4' }, { '5', '6', '7' } },
+ { { '1', '2', '3', '4' }, { '5', '6', '7', '8' } },
+ { { '9' }, { '\0' } }
+ };
+
+ {
+ A (ma[0].a, 5);
+ A (&ma[0].a[0], 5);
+ A (&ma[0].a[1], 4);
+ A (&ma[0].a[2], 3);
+
+ int i = 0;
+ A (ma[i].a, 5);
+ A (&ma[i].a[0], 5);
+ A (&ma[i].a[1], 4);
+ A (&ma[i].a[2], 3);
+
+ int j = i;
+ A (&ma[i].a[j], 5);
+ A (&ma[i].a[j + 1], 4);
+ A (&ma[i].a[j + 2], 3);
+
+ A (&ma[idx].a[i], 5);
+ A (&ma[idx].a[j + 1], 4);
+ A (&ma[idx].a[j + 2], 3);
+
+ A (&ma[idx].a[idx], 5);
+ A (&ma[idx].a[idx + 1], 4);
+ A (&ma[idx].a[idx + 2], 3);
+ }
+
+ {
+ A (ma[1].a, 6);
+ A (&ma[1].a[0], 6);
+ A (&ma[1].a[1], 5);
+ A (&ma[1].a[2], 4);
+
+ int i = 1;
+ A (ma[i].a, 6);
+ A (&ma[i].a[0], 6);
+ A (&ma[i].a[1], 5);
+ A (&ma[i].a[2], 4);
+
+ int j = i - 1;
+ A (&ma[i].a[j], 6);
+ A (&ma[i].a[j + 1], 5);
+ A (&ma[i].a[j + 2], 4);
+
+ A (&ma[idx + 1].a[j], 6);
+ A (&ma[idx + 1].a[j + 1], 5);
+ A (&ma[idx + 1].a[j + 2], 4);
+
+ A (&ma[idx + 1].a[idx], 6);
+ A (&ma[idx + 1].a[idx + 1], 5);
+ A (&ma[idx + 1].a[idx + 2], 4);
+ }
+
+ {
+ A (ma[4].a, 9);
+ A (&ma[4].a[0], 9);
+ A (&ma[4].a[1], 8);
+ A (&ma[4].b[0], 5);
+
+ int i = 4;
+ A (ma[i].a, 9);
+ A (&ma[i].a[0], 9);
+ A (&ma[i].a[1], 8);
+ A (&ma[i].b[0], 5);
+
+ int j = i - 1;
+ A (&ma[i].a[j], 6);
+ A (&ma[i].a[j + 1], 5);
+ A (&ma[i].b[j - 2], 4);
+
+ A (&ma[idx + 4].a[j], 6);
+ A (&ma[idx + 4].a[j + 1], 5);
+ A (&ma[idx + 4].b[j - 2], 4);
+
+ A (&ma[idx + 4].a[idx], 9);
+ A (&ma[idx + 4].a[idx + 1], 8);
+ A (&ma[idx + 4].b[idx + 1], 4);
+ }
+}
+
+
+union UnionMemberArrays
+{
+ struct { char a[4], b[4]; } a;
+ struct { char a[8]; } c;
+};
+
+const union UnionMemberArrays cu = {
+ { { '1', '2', '3', '4' }, { '5', } }
+};
+
+static void test_const_union_member_arrays (void)
+{
+ A (cu.a.a, 5);
+ A (cu.a.b, 1);
+ A (cu.c.a, 5);
+
+ const union UnionMemberArrays clu = {
+ { { '1', '2', '3', '4' }, { '5', '6' } }
+ };
+
+ A (clu.a.a, 6);
+ A (clu.a.b, 2);
+ A (clu.c.a, 6);
+}
+
+
+union UnionMemberArrays vu = {
+ { { '1', '2', '3', '4' }, { '5', '6' } }
+};
+
+static void test_nonconst_union_member_arrays (void)
+{
+ A (vu.a.a, 6);
+ A (vu.a.b, 2);
+ A (vu.c.a, 6);
+
+ union UnionMemberArrays lvu = {
+ { { '1', '2', '3', '4' }, { '5', '6', '7' } }
+ };
+
+ A (lvu.a.a, 7);
+ A (lvu.a.b, 3);
+ A (lvu.c.a, 7);
+}
+
+
+int main (void)
+{
+ test_const_global_arrays ();
+ test_const_local_arrays ();
+
+ test_nonconst_global_arrays ();
+ test_nonconst_local_arrays ();
+
+ test_const_global_member_arrays ();
+ test_const_local_member_arrays ();
+
+ test_nonconst_global_member_arrays ();
+ test_nonconst_local_member_arrays ();
+
+ test_const_union_member_arrays ();
+ test_nonconst_union_member_arrays ();
+
+ if (nfails)
+ __builtin_abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-6.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-6.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-6.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-6.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,113 @@
+/* Test to verify that strlen() calls with conditional expressions
+ and unterminated arrays or pointers to such things as arguments
+ are evaluated without making assumptions about array sizes. */
+
+extern __SIZE_TYPE__ strlen (const char *);
+
+unsigned nfails;
+
+#define A(expr, N) \
+ do { \
+ const char *_s = (expr); \
+ unsigned _n = strlen (_s); \
+ ((_n == N) \
+ ? 0 \
+ : (__builtin_printf ("line %i: strlen ((%s) = (\"%s\"))" \
+ " == %u failed\n", \
+ __LINE__, #expr, _s, N), \
+ ++nfails)); \
+ } while (0)
+
+
+volatile int i0 = 0;
+
+const char ca[2][3] = { "12" };
+const char cb[2][3] = { { '1', '2', '3', }, { '4' } };
+
+char va[2][3] = { "123" };
+char vb[2][3] = { { '1', '2', '3', }, { '4', '5' } };
+
+const char *s = "123456";
+
+
+static void test_binary_cond_expr_global (void)
+{
+ A (i0 ? "1" : ca[0], 2);
+ A (i0 ? ca[0] : "123", 3);
+
+ /* The call to strlen (cb[0]) is strictly undefined because the array
+ isn't nul-terminated. This test verifies that the strlen range
+ optimization doesn't assume that the argument is necessarily nul
+ terminated.
+ Ditto for strlen (vb[0]). */
+ A (i0 ? "1" : cb[0], 4); /* GCC 8.2 failure */
+ A (i0 ? cb[0] : "12", 2);
+
+ A (i0 ? "1" : va[0], 3); /* GCC 8.2 failure */
+ A (i0 ? va[0] : "1234", 4);
+
+ A (i0 ? "1" : vb[0], 5); /* GCC 8.2 failure */
+ A (i0 ? vb[0] : "12", 2);
+}
+
+
+static void test_binary_cond_expr_local (void)
+{
+ const char lca[2][3] = { "12" };
+ const char lcb[2][3] = { { '1', '2', '3', }, { '4' } };
+
+ char lva[2][3] = { "123" };
+ char lvb[2][3] = { { '1', '2', '3', }, { '4', '5' } };
+
+ /* Also undefined as above. */
+ A (i0 ? "1" : lca[0], 2);
+ A (i0 ? lca[0] : "123", 3);
+
+ A (i0 ? "1" : lcb[0], 4); /* GCC 8.2 failure */
+ A (i0 ? lcb[0] : "12", 2);
+
+ A (i0 ? "1" : lva[0], 3); /* GCC 8.2 failure */
+ A (i0 ? lva[0] : "1234", 4);
+
+ A (i0 ? "1" : lvb[0], 5); /* GCC 8.2 failure */
+ A (i0 ? lvb[0] : "12", 2);
+}
+
+
+static void test_ternary_cond_expr (void)
+{
+ /* Also undefined. */
+ A (i0 == 0 ? s : i0 == 1 ? vb[0] : "123", 6);
+ A (i0 == 0 ? vb[0] : i0 == 1 ? s : "123", 5);
+ A (i0 == 0 ? "123" : i0 == 1 ? s : vb[0], 3);
+}
+
+
+const char (*pca)[3] = &ca[0];
+const char (*pcb)[3] = &cb[0];
+
+char (*pva)[3] = &va[0];
+char (*pvb)[3] = &vb[0];
+
+static void test_binary_cond_expr_arrayptr (void)
+{
+ /* Also undefined. */
+ A (i0 ? *pca : *pcb, 4); /* GCC 8.2 failure */
+ A (i0 ? *pcb : *pca, 2);
+
+ A (i0 ? *pva : *pvb, 5); /* GCC 8.2 failure */
+ A (i0 ? *pvb : *pva, 3);
+}
+
+
+int main (void)
+{
+ test_binary_cond_expr_global ();
+ test_binary_cond_expr_local ();
+
+ test_ternary_cond_expr ();
+ test_binary_cond_expr_arrayptr ();
+
+ if (nfails)
+ __builtin_abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-7.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-7.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-7.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strlen-7.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,37 @@
+/* Test to verify that a strlen() call with a pointer to a dynamic type
+ doesn't make assumptions based on the static type of the original
+ pointer. See g++.dg/init/strlen.C for the corresponding C++ test. */
+
+struct A { int i; char a[1]; void (*p)(); };
+struct B { char a[sizeof (struct A) - __builtin_offsetof (struct A, a)]; };
+
+__attribute__ ((noipa)) void
+init (char *d, const char *s)
+{
+ __builtin_strcpy (d, s);
+}
+
+struct B b;
+
+__attribute__ ((noipa)) void
+test_dynamic_type (struct A *p)
+{
+ /* The following call is undefined because it writes past the end
+ of the p->a subobject, but the corresponding GIMPLE considers
+ it valid and there's apparently no way to distinguish invalid
+ cases from ones like it that might be valid. If/when GIMPLE
+ changes to make this possible this test can be removed. */
+ char *q = (char*)__builtin_memcpy (p->a, &b, sizeof b);
+
+ init (q, "foobar");
+
+ if (6 != __builtin_strlen (q))
+ __builtin_abort();
+}
+
+int main (void)
+{
+ struct A *p = (struct A*)__builtin_malloc (sizeof *p);
+ test_dynamic_type (p);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strncmp-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strncmp-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strncmp-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/strncmp-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,141 @@
+/* { dg-xfail-if "kernel strncmp does not perform unsigned comparisons" { vxworks_kernel } } */
+/* Copyright (C) 2002 Free Software Foundation.
+
+ Test strncmp with various combinations of pointer alignments and lengths to
+ make sure any optimizations in the library are correct.
+
+ Written by Michael Meissner, March 9, 2002. */
+
+#include <string.h>
+#include <stddef.h>
+
+#ifndef MAX_OFFSET
+#define MAX_OFFSET (sizeof (long long))
+#endif
+
+#ifndef MAX_TEST
+#define MAX_TEST (8 * sizeof (long long))
+#endif
+
+#ifndef MAX_EXTRA
+#define MAX_EXTRA (sizeof (long long))
+#endif
+
+#define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA)
+
+static union {
+ unsigned char buf[MAX_LENGTH];
+ long long align_int;
+ long double align_fp;
+} u1, u2;
+
+void
+test (const unsigned char *s1, const unsigned char *s2, size_t len, int expected)
+{
+ int value = strncmp ((char *) s1, (char *) s2, len);
+
+ if (expected < 0 && value >= 0)
+ abort ();
+ else if (expected == 0 && value != 0)
+ abort ();
+ else if (expected > 0 && value <= 0)
+ abort ();
+}
+
+main ()
+{
+ size_t off1, off2, len, i;
+ unsigned char *buf1, *buf2;
+ unsigned char *mod1, *mod2;
+ unsigned char *p1, *p2;
+
+ for (off1 = 0; off1 < MAX_OFFSET; off1++)
+ for (off2 = 0; off2 < MAX_OFFSET; off2++)
+ for (len = 0; len < MAX_TEST; len++)
+ {
+ p1 = u1.buf;
+ for (i = 0; i < off1; i++)
+ *p1++ = '\0';
+
+ buf1 = p1;
+ for (i = 0; i < len; i++)
+ *p1++ = 'a';
+
+ mod1 = p1;
+ for (i = 0; i < MAX_EXTRA; i++)
+ *p1++ = 'x';
+
+ p2 = u2.buf;
+ for (i = 0; i < off2; i++)
+ *p2++ = '\0';
+
+ buf2 = p2;
+ for (i = 0; i < len; i++)
+ *p2++ = 'a';
+
+ mod2 = p2;
+ for (i = 0; i < MAX_EXTRA; i++)
+ *p2++ = 'x';
+
+ mod1[0] = '\0';
+ mod2[0] = '\0';
+ test (buf1, buf2, MAX_LENGTH, 0);
+ test (buf1, buf2, len, 0);
+
+ mod1[0] = 'a';
+ mod1[1] = '\0';
+ mod2[0] = '\0';
+ test (buf1, buf2, MAX_LENGTH, +1);
+ test (buf1, buf2, len, 0);
+
+ mod1[0] = '\0';
+ mod2[0] = 'a';
+ mod2[1] = '\0';
+ test (buf1, buf2, MAX_LENGTH, -1);
+ test (buf1, buf2, len, 0);
+
+ mod1[0] = 'b';
+ mod1[1] = '\0';
+ mod2[0] = 'c';
+ mod2[1] = '\0';
+ test (buf1, buf2, MAX_LENGTH, -1);
+ test (buf1, buf2, len, 0);
+
+ mod1[0] = 'c';
+ mod1[1] = '\0';
+ mod2[0] = 'b';
+ mod2[1] = '\0';
+ test (buf1, buf2, MAX_LENGTH, +1);
+ test (buf1, buf2, len, 0);
+
+ mod1[0] = 'b';
+ mod1[1] = '\0';
+ mod2[0] = (unsigned char)'\251';
+ mod2[1] = '\0';
+ test (buf1, buf2, MAX_LENGTH, -1);
+ test (buf1, buf2, len, 0);
+
+ mod1[0] = (unsigned char)'\251';
+ mod1[1] = '\0';
+ mod2[0] = 'b';
+ mod2[1] = '\0';
+ test (buf1, buf2, MAX_LENGTH, +1);
+ test (buf1, buf2, len, 0);
+
+ mod1[0] = (unsigned char)'\251';
+ mod1[1] = '\0';
+ mod2[0] = (unsigned char)'\252';
+ mod2[1] = '\0';
+ test (buf1, buf2, MAX_LENGTH, -1);
+ test (buf1, buf2, len, 0);
+
+ mod1[0] = (unsigned char)'\252';
+ mod1[1] = '\0';
+ mod2[0] = (unsigned char)'\251';
+ mod2[1] = '\0';
+ test (buf1, buf2, MAX_LENGTH, +1);
+ test (buf1, buf2, len, 0);
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-aliasing-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-aliasing-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-aliasing-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-aliasing-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+struct S { float f; };
+int __attribute__((noinline))
+foo (int *r, struct S *p)
+{
+ int *q = (int *)&p->f;
+ int i = *q;
+ *r = 0;
+ return i + *q;
+}
+extern void abort (void);
+int main()
+{
+ int i = 1;
+ if (foo (&i, (struct S *)&i) != 1)
+ abort ();
+ return (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-cpy-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-cpy-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-cpy-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-cpy-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,43 @@
+/* powerpc64-linux gcc miscompiled this due to rs6000.c:expand_block_move
+ not setting mem aliasing info correctly for the code implementing the
+ structure assignment. */
+
+struct termios
+{
+ unsigned int a;
+ unsigned int b;
+ unsigned int c;
+ unsigned int d;
+ unsigned char pad[28];
+};
+
+struct tty_driver
+{
+ unsigned char pad1[38];
+ struct termios t __attribute__ ((aligned (8)));
+};
+
+static struct termios zero_t;
+static struct tty_driver pty;
+
+void ini (void)
+{
+ pty.t = zero_t;
+ pty.t.a = 1;
+ pty.t.b = 2;
+ pty.t.c = 3;
+ pty.t.d = 4;
+}
+
+int main (void)
+{
+ extern void abort (void);
+
+ ini ();
+ if (pty.t.a != 1
+ || pty.t.b != 2
+ || pty.t.c != 3
+ || pty.t.d != 4)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+struct S
+{
+ char f1;
+ int f2[2];
+};
+
+struct S object = {'X', 8, 9};
+
+main ()
+{
+ if (object.f1 != 'X' || object.f2[0] != 8 || object.f2[1] != 9)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+struct {
+ int a:4;
+ int :4;
+ int b:4;
+ int c:4;
+} x = { 2,3,4 };
+
+main ()
+{
+ if (x.a != 2)
+ abort ();
+ if (x.b != 3)
+ abort ();
+ if (x.c != 4)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,11 @@
+struct
+{
+ unsigned int f1:1, f2:1, f3:3, f4:3, f5:2, f6:1, f7:1;
+} result = {1, 1, 7, 7, 3, 1, 1};
+
+main ()
+{
+ if ((result.f3 & ~7) != 0 || (result.f4 & ~7) != 0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ini-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+struct s {
+ int a[3];
+ int c[3];
+};
+
+struct s s = {
+ c: {1, 2, 3}
+};
+
+main()
+{
+ if (s.c[0] != 1)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ret-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ret-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ret-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ret-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <string.h>
+
+char out[100];
+
+typedef struct { double d; int i[3]; } B;
+typedef struct { char c[33],c1; } X;
+
+char c1 = 'a';
+char c2 = 127;
+char c3 = (char)128;
+char c4 = (char)255;
+char c5 = -1;
+
+double d1 = 0.1;
+double d2 = 0.2;
+double d3 = 0.3;
+double d4 = 0.4;
+double d5 = 0.5;
+double d6 = 0.6;
+double d7 = 0.7;
+double d8 = 0.8;
+double d9 = 0.9;
+
+B B1 = {0.1,{1,2,3}};
+B B2 = {0.2,{5,4,3}};
+X X1 = {"abcdefghijklmnopqrstuvwxyzABCDEF", 'G'};
+X X2 = {"123",'9'};
+X X3 = {"return-return-return",'R'};
+
+X f (B a, char b, double c, B d)
+{
+ static X xr = {"return val", 'R'};
+ X r;
+ r = xr;
+ r.c1 = b;
+ sprintf (out, "X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})",
+ a.d, a.i[0], a.i[1], a.i[2], b, c, d.d, d.i[0], d.i[1], d.i[2]);
+ return r;
+}
+
+X (*fp) (B, char, double, B) = &f;
+
+main ()
+{
+ X Xr;
+ char tmp[100];
+
+ Xr = f (B1, c2, d3, B2);
+ strcpy (tmp, out);
+ Xr.c[0] = Xr.c1 = '\0';
+ Xr = (*fp) (B1, c2, d3, B2);
+ if (strcmp (tmp, out))
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ret-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ret-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ret-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/struct-ret-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+typedef struct
+{
+ unsigned char a __attribute__ ((packed));
+ unsigned short b __attribute__ ((packed));
+} three_byte_t;
+
+unsigned char
+f (void)
+{
+ return 0xab;
+}
+
+unsigned short
+g (void)
+{
+ return 0x1234;
+}
+
+main ()
+{
+ three_byte_t three_byte;
+
+ three_byte.a = f ();
+ three_byte.b = g ();
+ if (three_byte.a != 0xab || three_byte.b != 0x1234)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/switch-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/switch-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/switch-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/switch-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,56 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Test that switch statements suitable using case bit tests are
+ implemented correctly.
+
+ Written by Roger Sayle, 01/25/2001. */
+
+extern void abort (void);
+
+int
+foo (int x)
+{
+ switch (x)
+ {
+ case 4:
+ case 6:
+ case 9:
+ case 11:
+ return 30;
+ }
+ return 31;
+}
+
+int
+main ()
+{
+ int i, r;
+
+ for (i=-1; i<66; i++)
+ {
+ r = foo (i);
+ if (i == 4)
+ {
+ if (r != 30)
+ abort ();
+ }
+ else if (i == 6)
+ {
+ if (r != 30)
+ abort ();
+ }
+ else if (i == 9)
+ {
+ if (r != 30)
+ abort ();
+ }
+ else if (i == 11)
+ {
+ if (r != 30)
+ abort ();
+ }
+ else if (r != 31)
+ abort ();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/tstdi-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/tstdi-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/tstdi-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/tstdi-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,139 @@
+#define FALSE 140
+#define TRUE 13
+
+feq (x)
+ long long int x;
+{
+ if (x == 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+fne (x)
+ long long int x;
+{
+ if (x != 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+flt (x)
+ long long int x;
+{
+ if (x < 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+fge (x)
+ long long int x;
+{
+ if (x >= 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+fgt (x)
+ long long int x;
+{
+ if (x > 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+fle (x)
+ long long int x;
+{
+ if (x <= 0)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+main ()
+{
+ if (feq (0LL) != TRUE)
+ abort ();
+ if (feq (-1LL) != FALSE)
+ abort ();
+ if (feq (0x8000000000000000LL) != FALSE)
+ abort ();
+ if (feq (0x8000000000000001LL) != FALSE)
+ abort ();
+ if (feq (1LL) != FALSE)
+ abort ();
+ if (feq (0x7fffffffffffffffLL) != FALSE)
+ abort ();
+
+ if (fne (0LL) != FALSE)
+ abort ();
+ if (fne (-1LL) != TRUE)
+ abort ();
+ if (fne (0x8000000000000000LL) != TRUE)
+ abort ();
+ if (fne (0x8000000000000001LL) != TRUE)
+ abort ();
+ if (fne (1LL) != TRUE)
+ abort ();
+ if (fne (0x7fffffffffffffffLL) != TRUE)
+ abort ();
+
+ if (flt (0LL) != FALSE)
+ abort ();
+ if (flt (-1LL) != TRUE)
+ abort ();
+ if (flt (0x8000000000000000LL) != TRUE)
+ abort ();
+ if (flt (0x8000000000000001LL) != TRUE)
+ abort ();
+ if (flt (1LL) != FALSE)
+ abort ();
+ if (flt (0x7fffffffffffffffLL) != FALSE)
+ abort ();
+
+ if (fge (0LL) != TRUE)
+ abort ();
+ if (fge (-1LL) != FALSE)
+ abort ();
+ if (fge (0x8000000000000000LL) != FALSE)
+ abort ();
+ if (fge (0x8000000000000001LL) != FALSE)
+ abort ();
+ if (fge (1LL) != TRUE)
+ abort ();
+ if (fge (0x7fffffffffffffffLL) != TRUE)
+ abort ();
+
+ if (fgt (0LL) != FALSE)
+ abort ();
+ if (fgt (-1LL) != FALSE)
+ abort ();
+ if (fgt (0x8000000000000000LL) != FALSE)
+ abort ();
+ if (fgt (0x8000000000000001LL) != FALSE)
+ abort ();
+ if (fgt (1LL) != TRUE)
+ abort ();
+ if (fgt (0x7fffffffffffffffLL) != TRUE)
+ abort ();
+
+ if (fle (0LL) != TRUE)
+ abort ();
+ if (fle (-1LL) != TRUE)
+ abort ();
+ if (fle (0x8000000000000000LL) != TRUE)
+ abort ();
+ if (fle (0x8000000000000001LL) != TRUE)
+ abort ();
+ if (fle (1LL) != FALSE)
+ abort ();
+ if (fle (0x7fffffffffffffffLL) != FALSE)
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/unroll-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/unroll-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/unroll-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/unroll-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* { dg-options "-fgnu89-inline" } */
+
+extern void abort (void);
+extern void exit (int);
+
+inline int
+f (int x)
+{
+ return (x + 1);
+}
+
+int
+main (void)
+{
+ int a = 0 ;
+
+ while ( (f(f(f(f(f(f(f(f(f(f(1))))))))))) + a < 12 )
+ {
+ a++;
+ exit (0);
+ }
+ if (a != 1)
+ abort();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/usad-run.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/usad-run.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/usad-run.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/usad-run.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,49 @@
+extern void abort ();
+extern int abs (int __x) __attribute__ ((__nothrow__, __leaf__)) __attribute__ ((__const__));
+
+static int
+foo (unsigned char *w, int i, unsigned char *x, int j)
+{
+ int tot = 0;
+ for (int a = 0; a < 16; a++)
+ {
+ for (int b = 0; b < 16; b++)
+ tot += abs (w[b] - x[b]);
+ w += i;
+ x += j;
+ }
+ return tot;
+}
+
+void
+bar (unsigned char *w, unsigned char *x, int i, int *result)
+{
+ *result = foo (w, 16, x, i);
+}
+
+int
+main (void)
+{
+ unsigned char m[256];
+ unsigned char n[256];
+ int sum, i;
+
+ for (i = 0; i < 256; ++i)
+ if (i % 2 == 0)
+ {
+ m[i] = (i % 8) * 2 + 1;
+ n[i] = -(i % 8);
+ }
+ else
+ {
+ m[i] = -((i % 8) * 2 + 2);
+ n[i] = -((i % 8) >> 1);
+ }
+
+ bar (m, n, 16, &sum);
+
+ if (sum != 32384)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/user-printf.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/user-printf.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/user-printf.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/user-printf.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,65 @@
+/* Verify that calls to a function declared wiith attribute format (printf)
+ don't get eliminated even if their result on success can be computed at
+ compile time (they can fail).
+ { dg-require-effective-target unwrapped }
+ { dg-skip-if "requires io" { freestanding } } */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void __attribute__ ((format (printf, 1, 2), noipa))
+user_print (const char *fmt, ...)
+{
+ va_list va;
+ va_start (va, fmt);
+ vfprintf (stdout, fmt, va);
+ va_end (va);
+}
+
+int main (void)
+{
+ char *tmpfname = tmpnam (0);
+ FILE *f = freopen (tmpfname, "w", stdout);
+ if (!f)
+ {
+ perror ("fopen for writing");
+ return 1;
+ }
+
+ user_print ("1");
+ user_print ("%c", '2');
+ user_print ("%c%c", '3', '4');
+ user_print ("%s", "5");
+ user_print ("%s%s", "6", "7");
+ user_print ("%i", 8);
+ user_print ("%.1s\n", "9x");
+
+ fclose (f);
+
+ f = fopen (tmpfname, "r");
+ if (!f)
+ {
+ perror ("fopen for reading");
+ remove (tmpfname);
+ return 1;
+ }
+
+ char buf[12] = "";
+ if (1 != fscanf (f, "%s", buf))
+ {
+ perror ("fscanf");
+ fclose (f);
+ remove (tmpfname);
+ return 1;
+ }
+
+ fclose (f);
+ remove (tmpfname);
+
+ if (strcmp (buf, "123456789"))
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/usmul.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/usmul.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/usmul.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/usmul.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+/* { dg-require-effective-target int32plus } */
+int __attribute__ ((noinline)) foo (short x, unsigned short y)
+{
+ return x * y;
+}
+
+int __attribute__ ((noinline)) bar (unsigned short x, short y)
+{
+ return x * y;
+}
+
+int main ()
+{
+ if (foo (-2, 0xffff) != -131070)
+ abort ();
+ if (foo (2, 0xffff) != 131070)
+ abort ();
+ if (foo (-32768, 0x8000) != -1073741824)
+ abort ();
+ if (foo (32767, 0x8000) != 1073709056)
+ abort ();
+
+ if (bar (0xffff, -2) != -131070)
+ abort ();
+ if (bar (0xffff, 2) != 131070)
+ abort ();
+ if (bar (0x8000, -32768) != -1073741824)
+ abort ();
+ if (bar (0x8000, 32767) != 1073709056)
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+#include <stdarg.h>
+
+typedef unsigned long L;
+f (L p0, L p1, L p2, L p3, L p4, L p5, L p6, L p7, L p8, ...)
+{
+ va_list select;
+
+ va_start (select, p8);
+
+ if (va_arg (select, L) != 10)
+ abort ();
+ if (va_arg (select, L) != 11)
+ abort ();
+ if (va_arg (select, L) != 0)
+ abort ();
+
+ va_end (select);
+}
+
+main ()
+{
+ f (1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 0L);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-10.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-10.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-10.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-10.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,248 @@
+/* This is a modfied version of va-arg-9.c to test va_copy. */
+
+#include <stdarg.h>
+
+#ifndef va_copy
+#define va_copy __va_copy
+#endif
+
+extern __SIZE_TYPE__ strlen (const char *);
+
+int
+to_hex (unsigned int a)
+{
+ static char hex[] = "0123456789abcdef";
+
+ if (a > 15)
+ abort ();
+ return hex[a];
+}
+
+void
+fap (int i, char* format, va_list ap)
+{
+ va_list apc;
+ char *formatc;
+
+ va_copy (apc, ap);
+ formatc = format;
+
+ if (strlen (format) != 16 - i)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ while (*formatc)
+ if (*formatc++ != to_hex (va_arg (apc, int)))
+ abort ();
+}
+
+void
+f0 (char* format, ...)
+{
+ va_list ap;
+
+ va_start (ap, format);
+ fap(0, format, ap);
+ va_end(ap);
+}
+
+void
+f1 (int a1, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(1, format, ap);
+ va_end(ap);
+}
+
+void
+f2 (int a1, int a2, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(2, format, ap);
+ va_end(ap);
+}
+
+void
+f3 (int a1, int a2, int a3, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(3, format, ap);
+ va_end(ap);
+}
+
+void
+f4 (int a1, int a2, int a3, int a4, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(4, format, ap);
+ va_end(ap);
+}
+
+void
+f5 (int a1, int a2, int a3, int a4, int a5,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(5, format, ap);
+ va_end(ap);
+}
+
+void
+f6 (int a1, int a2, int a3, int a4, int a5,
+ int a6,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(6, format, ap);
+ va_end(ap);
+}
+
+void
+f7 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(7, format, ap);
+ va_end(ap);
+}
+
+void
+f8 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(8, format, ap);
+ va_end(ap);
+}
+
+void
+f9 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(9, format, ap);
+ va_end(ap);
+}
+
+void
+f10 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(10, format, ap);
+ va_end(ap);
+}
+
+void
+f11 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(11, format, ap);
+ va_end(ap);
+}
+
+void
+f12 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(12, format, ap);
+ va_end(ap);
+}
+
+void
+f13 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12, int a13,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(13, format, ap);
+ va_end(ap);
+}
+
+void
+f14 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12, int a13, int a14,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(14, format, ap);
+ va_end(ap);
+}
+
+void
+f15 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12, int a13, int a14, int a15,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(15, format, ap);
+ va_end(ap);
+}
+
+main ()
+{
+ char *f = "0123456789abcdef";
+
+ f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);
+ f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);
+ f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);
+ f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);
+ f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);
+ f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);
+ f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);
+ f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-11.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-11.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-11.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-11.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+/* Test va_arg when the result is ignored and only the pointer increment
+ side effect is used. */
+#include <stdarg.h>
+
+static int
+foo (int a, ...)
+{
+ va_list va;
+ int i, res;
+
+ va_start (va, a);
+
+ for (i = 0; i < 4; ++i)
+ (void) va_arg (va, int);
+
+ res = va_arg (va, int);
+
+ va_end (va);
+
+ return res;
+}
+
+int
+main (void)
+{
+ if (foo (5, 4, 3, 2, 1, 0))
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-12.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-12.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-12.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-12.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+#include <stdarg.h>
+
+/*typedef unsigned long L;*/
+typedef double L;
+void f (L p0, L p1, L p2, L p3, L p4, L p5, L p6, L p7, L p8, ...)
+{
+ va_list select;
+
+ va_start (select, p8);
+
+ if (va_arg (select, L) != 10.)
+ abort ();
+ if (va_arg (select, L) != 11.)
+ abort ();
+ if (va_arg (select, L) != 0.)
+ abort ();
+
+ va_end (select);
+}
+
+int main ()
+{
+ f (1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 0.);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-13.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-13.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-13.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-13.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+/* derived from mozilla source code */
+
+#include <stdarg.h>
+
+typedef struct {
+ void *stream;
+ va_list ap;
+ int nChar;
+} ScanfState;
+
+void dummy (va_list vap)
+{
+ if (va_arg (vap, int) != 1234) abort();
+ return;
+}
+
+void test (int fmt, ...)
+{
+ ScanfState state, *statep;
+
+ statep = &state;
+
+ va_start (statep->ap, fmt);
+ dummy (statep->ap);
+ va_end (statep->ap);
+
+ va_start (state.ap, fmt);
+ dummy (state.ap);
+ va_end (state.ap);
+
+ return;
+}
+
+int main (void)
+{
+ test (456, 1234);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-14.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-14.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-14.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-14.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,45 @@
+#include <stdarg.h>
+
+va_list global;
+
+void vat(va_list param, ...)
+{
+ va_list local;
+
+ va_start (local, param);
+ va_copy (global, local);
+ va_copy (param, local);
+ if (va_arg (local, int) != 1)
+ abort();
+ va_end (local);
+ if (va_arg (global, int) != 1)
+ abort();
+ va_end (global);
+ if (va_arg (param, int) != 1)
+ abort();
+ va_end (param);
+
+ va_start (param, param);
+ va_start (global, param);
+ va_copy (local, param);
+ if (va_arg (local, int) != 1)
+ abort();
+ va_end (local);
+ va_copy (local, global);
+ if (va_arg (local, int) != 1)
+ abort();
+ va_end (local);
+ if (va_arg (global, int) != 1)
+ abort();
+ va_end (global);
+ if (va_arg (param, int) != 1)
+ abort();
+ va_end (param);
+}
+
+int main(void)
+{
+ va_list t;
+ vat (t, 1);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-15.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-15.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-15.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-15.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,44 @@
+#include <stdarg.h>
+
+void vafunction (char *dummy, ...)
+{
+ double darg;
+ int iarg;
+ int flag = 0;
+ int i;
+ va_list ap;
+
+ va_start(ap, dummy);
+ for (i = 1; i <= 18; i++, flag++)
+ {
+ if (flag & 1)
+ {
+ darg = va_arg (ap, double);
+ if (darg != (double)i)
+ abort();
+ }
+ else
+ {
+ iarg = va_arg (ap, int);
+ if (iarg != i)
+ abort();
+ }
+ }
+ va_end(ap);
+}
+
+int main (void)
+{
+ vafunction( "",
+ 1, 2.,
+ 3, 4.,
+ 5, 6.,
+ 7, 8.,
+ 9, 10.,
+ 11, 12.,
+ 13, 14.,
+ 15, 16.,
+ 17, 18. );
+ exit(0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-16.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-16.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-16.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-16.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+#include <stdarg.h>
+
+typedef double TYPE;
+
+void vafunction (TYPE dummy1, TYPE dummy2, ...)
+{
+ va_list ap;
+
+ va_start(ap, dummy2);
+ if (dummy1 != 888.)
+ abort();
+ if (dummy2 != 999.)
+ abort();
+ if (va_arg (ap, TYPE) != 1.)
+ abort();
+ if (va_arg (ap, TYPE) != 2.)
+ abort();
+ if (va_arg (ap, TYPE) != 3.)
+ abort();
+ if (va_arg (ap, TYPE) != 4.)
+ abort();
+ if (va_arg (ap, TYPE) != 5.)
+ abort();
+ if (va_arg (ap, TYPE) != 6.)
+ abort();
+ if (va_arg (ap, TYPE) != 7.)
+ abort();
+ if (va_arg (ap, TYPE) != 8.)
+ abort();
+ if (va_arg (ap, TYPE) != 9.)
+ abort();
+ va_end(ap);
+}
+
+
+int main (void)
+{
+ vafunction( 888., 999., 1., 2., 3., 4., 5., 6., 7., 8., 9. );
+ exit(0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-17.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-17.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-17.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-17.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,37 @@
+#include <stdarg.h>
+
+typedef double TYPE;
+
+void vafunction (char *dummy, ...)
+{
+ va_list ap;
+
+ va_start(ap, dummy);
+ if (va_arg (ap, TYPE) != 1.)
+ abort();
+ if (va_arg (ap, TYPE) != 2.)
+ abort();
+ if (va_arg (ap, TYPE) != 3.)
+ abort();
+ if (va_arg (ap, TYPE) != 4.)
+ abort();
+ if (va_arg (ap, TYPE) != 5.)
+ abort();
+ if (va_arg (ap, TYPE) != 6.)
+ abort();
+ if (va_arg (ap, TYPE) != 7.)
+ abort();
+ if (va_arg (ap, TYPE) != 8.)
+ abort();
+ if (va_arg (ap, TYPE) != 9.)
+ abort();
+ va_end(ap);
+}
+
+
+int main (void)
+{
+ vafunction( "", 1., 2., 3., 4., 5., 6., 7., 8., 9. );
+ exit(0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-18.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-18.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-18.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-18.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+#include <stdarg.h>
+
+typedef double L;
+void f (L p0, L p1, L p2, L p3, L p4, L p5, L p6, L p7, L p8, ...)
+{
+ va_list select;
+
+ va_start (select, p8);
+
+ if (va_arg (select, int) != 10)
+ abort ();
+ if (va_arg (select, int) != 11)
+ abort ();
+ if (va_arg (select, int) != 12)
+ abort ();
+
+ va_end (select);
+}
+
+int main ()
+{
+ f (1., 2., 3., 4., 5., 6., 7., 8., 9., 10, 11, 12);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-19.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-19.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-19.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-19.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,37 @@
+#include <stdarg.h>
+
+typedef int TYPE;
+
+void vafunction (char *dummy, ...)
+{
+ va_list ap;
+
+ va_start(ap, dummy);
+ if (va_arg (ap, TYPE) != 1)
+ abort();
+ if (va_arg (ap, TYPE) != 2)
+ abort();
+ if (va_arg (ap, TYPE) != 3)
+ abort();
+ if (va_arg (ap, TYPE) != 4)
+ abort();
+ if (va_arg (ap, TYPE) != 5)
+ abort();
+ if (va_arg (ap, TYPE) != 6)
+ abort();
+ if (va_arg (ap, TYPE) != 7)
+ abort();
+ if (va_arg (ap, TYPE) != 8)
+ abort();
+ if (va_arg (ap, TYPE) != 9)
+ abort();
+ va_end(ap);
+}
+
+
+int main (void)
+{
+ vafunction( "", 1, 2, 3, 4, 5, 6, 7, 8, 9 );
+ exit(0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,292 @@
+/* The purpose of this test is to catch edge cases when arguments are passed
+ in regs and on the stack. We test 16 cases, trying to catch multiple
+ targets (some use 3 regs for argument passing, some use 12, etc.).
+ We test both the arguments and the `lastarg' (the argument to va_start). */
+
+#include <stdarg.h>
+
+extern __SIZE_TYPE__ strlen ();
+
+int
+to_hex (unsigned int a)
+{
+ static char hex[] = "0123456789abcdef";
+
+ if (a > 15)
+ abort ();
+ return hex[a];
+}
+
+void
+f0 (char* format, ...)
+{
+ va_list ap;
+
+ va_start (ap, format);
+ if (strlen (format) != 16 - 0)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f1 (int a1, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 1)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f2 (int a1, int a2, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 2)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f3 (int a1, int a2, int a3, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 3)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f4 (int a1, int a2, int a3, int a4, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 4)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f5 (int a1, int a2, int a3, int a4, int a5,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 5)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f6 (int a1, int a2, int a3, int a4, int a5,
+ int a6,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 6)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f7 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 7)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f8 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 8)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f9 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 9)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f10 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 10)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f11 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 11)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f12 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 12)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f13 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12, int a13,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 13)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f14 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12, int a13, int a14,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 14)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+void
+f15 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12, int a13, int a14, int a15,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (strlen (format) != 16 - 15)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+ va_end(ap);
+}
+
+main ()
+{
+ char *f = "0123456789abcdef";
+
+ f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);
+ f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);
+ f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);
+ f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);
+ f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);
+ f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);
+ f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);
+ f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-20.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-20.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-20.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-20.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+#include <stdarg.h>
+
+void foo(va_list v)
+{
+ unsigned long long x = va_arg (v, unsigned long long);
+ if (x != 16LL)
+ abort();
+}
+
+void bar(char c, char d, ...)
+{
+ va_list v;
+ va_start(v, d);
+ foo(v);
+ va_end(v);
+}
+
+int main(void)
+{
+ bar(0, 0, 16LL);
+ exit(0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-21.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-21.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-21.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-21.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,48 @@
+/* Copyright (C) 2000 Free Software Foundation.
+
+ If the argument to va_end() has side effects, test whether side
+ effects from that argument are honored.
+
+ Written by Kaveh R. Ghazi, 10/31/2000. */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef __GNUC__
+#define __attribute__(x)
+#endif
+
+static void __attribute__ ((__format__ (__printf__, 1, 2)))
+doit (const char *s, ...)
+{
+ va_list *ap_array[3], **ap_ptr = ap_array;
+
+ ap_array[0] = malloc (sizeof(va_list));
+ ap_array[1] = NULL;
+ ap_array[2] = malloc (sizeof(va_list));
+
+ va_start (*ap_array[0], s);
+ vprintf (s, **ap_ptr);
+ /* Increment the va_list pointer once. */
+ va_end (**ap_ptr++);
+
+ /* Increment the va_list pointer a second time. */
+ ap_ptr++;
+
+ va_start (*ap_array[2], s);
+ /* If we failed to increment ap_ptr twice, then the parameter passed
+ in here will dereference NULL and should cause a crash. */
+ vprintf (s, **ap_ptr);
+ va_end (**ap_ptr);
+
+ /* Just in case, If *ap_ptr is NULL abort anyway. */
+ if (*ap_ptr == 0)
+ abort();
+}
+
+int main()
+{
+ doit ("%s", "hello world\n");
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-22.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-22.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-22.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-22.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,78 @@
+#include <stdarg.h>
+
+extern void abort (void);
+extern void exit (int);
+
+void bar (int n, int c)
+{
+ static int lastn = -1, lastc = -1;
+
+ if (lastn != n)
+ {
+ if (lastc != lastn)
+ abort ();
+ lastc = 0;
+ lastn = n;
+ }
+
+ if (c != (char) (lastc ^ (n << 3)))
+ abort ();
+ lastc++;
+}
+
+#define D(N) typedef struct { char x[N]; } A##N;
+D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
+D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
+D(16) D(31) D(32) D(35) D(72)
+#undef D
+
+void foo (int size, ...)
+{
+#define D(N) A##N a##N;
+D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
+D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
+D(16) D(31) D(32) D(35) D(72)
+#undef D
+ va_list ap;
+ int i;
+
+ if (size != 21)
+ abort ();
+ va_start (ap, size);
+#define D(N) \
+ a##N = va_arg (ap, typeof (a##N)); \
+ for (i = 0; i < N; i++) \
+ bar (N, a##N.x[i]);
+D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
+D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
+D(16) D(31) D(32) D(35) D(72)
+#undef D
+ va_end (ap);
+}
+
+int main (void)
+{
+#define D(N) A##N a##N;
+D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
+D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
+D(16) D(31) D(32) D(35) D(72)
+#undef D
+ int i;
+
+#define D(N) \
+ for (i = 0; i < N; i++) \
+ a##N.x[i] = i ^ (N << 3);
+D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
+D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
+D(16) D(31) D(32) D(35) D(72)
+#undef D
+
+ foo (21
+#define D(N) , a##N
+D(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)
+D(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)
+D(16) D(31) D(32) D(35) D(72)
+#undef D
+ );
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-23.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-23.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-23.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-23.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* PR 9700 */
+/* Alpha got the base address for the va_list incorrect when there was
+ a structure that was passed partially in registers and partially on
+ the stack. */
+
+#include <stdarg.h>
+
+struct two { long x, y; };
+
+void foo(int a, int b, int c, int d, int e, struct two f, int g, ...)
+{
+ va_list args;
+ int h;
+
+ va_start(args, g);
+ h = va_arg(args, int);
+ if (g != 1 || h != 2)
+ abort ();
+}
+
+int main()
+{
+ struct two t = { 0, 0 };
+ foo(0, 0, 0, 0, 0, t, 1, 2);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-24.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-24.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-24.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-24.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,96 @@
+/* The purpose of this code is to test argument passing of a tuple of
+ 11 integers, with the break point between named and unnamed arguments
+ at every possible position. */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int errors = 0;
+
+static void
+verify (const char *tcase, int n[11])
+{
+ int i;
+ for (i = 0; i <= 10; i++)
+ if (n[i] != i)
+ {
+ printf (" %s: n[%d] = %d expected %d\n", tcase, i, n[i], i);
+ errors++;
+ }
+}
+
+#define STR(x) #x
+
+#define p(i) int q##i,
+#define P(i) n[i] = q##i;
+
+#define p0 p(0)
+#define p1 p(1)
+#define p2 p(2)
+#define p3 p(3)
+#define p4 p(4)
+#define p5 p(5)
+#define p6 p(6)
+#define p7 p(7)
+#define p8 p(8)
+#define p9 p(9)
+
+#define P0 P(0)
+#define P1 P(1)
+#define P2 P(2)
+#define P3 P(3)
+#define P4 P(4)
+#define P5 P(5)
+#define P6 P(6)
+#define P7 P(7)
+#define P8 P(8)
+#define P9 P(9)
+
+#define TCASE(x, params, vecinit) \
+static void \
+varargs##x (params ...) \
+{ \
+ va_list ap; \
+ int n[11]; \
+ int i; \
+ \
+ va_start (ap, q##x); \
+ vecinit \
+ for (i = x + 1; i <= 10; i++) \
+ n[i] = va_arg (ap, int); \
+ va_end (ap); \
+ \
+ verify (STR(varargs##x), n); \
+}
+
+#define TEST(x) varargs##x (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+
+TCASE(0, p0 , P0 )
+TCASE(1, p0 p1 , P0 P1 )
+TCASE(2, p0 p1 p2 , P0 P1 P2 )
+TCASE(3, p0 p1 p2 p3 , P0 P1 P2 P3 )
+TCASE(4, p0 p1 p2 p3 p4 , P0 P1 P2 P3 P4 )
+TCASE(5, p0 p1 p2 p3 p4 p5 , P0 P1 P2 P3 P4 P5 )
+TCASE(6, p0 p1 p2 p3 p4 p5 p6 , P0 P1 P2 P3 P4 P5 P6 )
+TCASE(7, p0 p1 p2 p3 p4 p5 p6 p7 , P0 P1 P2 P3 P4 P5 P6 P7 )
+TCASE(8, p0 p1 p2 p3 p4 p5 p6 p7 p8 , P0 P1 P2 P3 P4 P5 P6 P7 P8 )
+TCASE(9, p0 p1 p2 p3 p4 p5 p6 p7 p8 p9, P0 P1 P2 P3 P4 P5 P6 P7 P8 P9)
+
+int main(void)
+{
+ TEST(0);
+ TEST(1);
+ TEST(2);
+ TEST(3);
+ TEST(4);
+ TEST(5);
+ TEST(6);
+ TEST(7);
+ TEST(8);
+ TEST(9);
+
+ if (errors)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-26.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-26.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-26.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-26.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+#include <stdarg.h>
+
+double f (float f1, float f2, float f3, float f4,
+ float f5, float f6, ...)
+{
+ va_list ap;
+ double d;
+
+ va_start (ap, f6);
+ d = va_arg (ap, double);
+ va_end (ap);
+ return d;
+}
+
+int main ()
+{
+ if (f (1, 2, 3, 4, 5, 6, 7.0) != 7.0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+/* On the i960 any arg bigger than 16 bytes causes all subsequent args
+ to be passed on the stack. We test this. */
+
+#include <stdarg.h>
+
+typedef struct {
+ char a[32];
+} big;
+
+void
+f (big x, char *s, ...)
+{
+ va_list ap;
+
+ if (x.a[0] != 'a' || x.a[1] != 'b' || x.a[2] != 'c')
+ abort ();
+ va_start (ap, s);
+ if (va_arg (ap, int) != 42)
+ abort ();
+ if (va_arg (ap, int) != 'x')
+ abort ();
+ if (va_arg (ap, int) != 0)
+ abort ();
+ va_end (ap);
+}
+
+main ()
+{
+ static big x = { "abc" };
+
+ f (x, "", 42, 'x', 0);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,44 @@
+#include <stdarg.h>
+
+va_double (int n, ...)
+{
+ va_list args;
+
+ va_start (args, n);
+
+ if (va_arg (args, double) != 3.141592)
+ abort ();
+ if (va_arg (args, double) != 2.71827)
+ abort ();
+ if (va_arg (args, double) != 2.2360679)
+ abort ();
+ if (va_arg (args, double) != 2.1474836)
+ abort ();
+
+ va_end (args);
+}
+
+va_long_double (int n, ...)
+{
+ va_list args;
+
+ va_start (args, n);
+
+ if (va_arg (args, long double) != 3.141592L)
+ abort ();
+ if (va_arg (args, long double) != 2.71827L)
+ abort ();
+ if (va_arg (args, long double) != 2.2360679L)
+ abort ();
+ if (va_arg (args, long double) != 2.1474836L)
+ abort ();
+
+ va_end (args);
+}
+
+main ()
+{
+ va_double (4, 3.141592, 2.71827, 2.2360679, 2.1474836);
+ va_long_double (4, 3.141592L, 2.71827L, 2.2360679L, 2.1474836L);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-6.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-6.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-6.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-6.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+#include <stdarg.h>
+
+f (int n, ...)
+{
+ va_list args;
+
+ va_start (args, n);
+
+ if (va_arg (args, int) != 10)
+ abort ();
+ if (va_arg (args, long long) != 10000000000LL)
+ abort ();
+ if (va_arg (args, int) != 11)
+ abort ();
+ if (va_arg (args, long double) != 3.14L)
+ abort ();
+ if (va_arg (args, int) != 12)
+ abort ();
+ if (va_arg (args, int) != 13)
+ abort ();
+ if (va_arg (args, long long) != 20000000000LL)
+ abort ();
+ if (va_arg (args, int) != 14)
+ abort ();
+ if (va_arg (args, double) != 2.72)
+ abort ();
+
+ va_end(args);
+}
+
+main ()
+{
+ f (4, 10, 10000000000LL, 11, 3.14L, 12, 13, 20000000000LL, 14, 2.72);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-7.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-7.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-7.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-7.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+/* Origin: Franz Sirl <Franz.Sirl-kernel at lauterbach.com> */
+/* { dg-options "-fgnu89-inline" } */
+
+extern void abort (void);
+extern void exit (int);
+
+#include <stdarg.h>
+
+inline void
+debug(int i1, int i2, int i3, int i4, int i5, int i6, int i7,
+ double f1, double f2, double f3, double f4, double f5,
+ double f6, double f7, double f8, double f9, ...)
+{
+ va_list ap;
+
+ va_start (ap, f9);
+
+ if (va_arg (ap,int) != 8)
+ abort ();
+ if (va_arg (ap,int) != 9)
+ abort ();
+ if (va_arg (ap,int) != 10)
+ abort ();
+
+ va_end (ap);
+}
+
+int
+main(void)
+{
+ debug (1, 2, 3, 4, 5, 6, 7,
+ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0,
+ 8, 9, 10);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-8.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-8.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-8.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-8.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,45 @@
+/* Origin: Franz Sirl <Franz.Sirl-kernel at lauterbach.com> */
+/* { dg-options "-fgnu89-inline" } */
+
+extern void abort (void);
+extern void exit (int);
+
+#include <stdarg.h>
+#include <limits.h>
+
+#if __LONG_LONG_MAX__ == 9223372036854775807LL
+
+typedef long long int INT64;
+
+inline void
+debug(int i1, int i2, int i3, int i4, int i5,
+ int i6, int i7, int i8, int i9, ...)
+{
+ va_list ap;
+
+ va_start (ap, i9);
+
+ if (va_arg (ap,int) != 10)
+ abort ();
+ if (va_arg (ap,INT64) != 0x123400005678LL)
+ abort ();
+
+ va_end (ap);
+}
+
+int
+main(void)
+{
+ debug(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0x123400005678LL);
+ exit(0);
+}
+
+#else
+
+int
+main(void)
+{
+ exit(0);
+}
+
+#endif /* long long 64 bits */
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-9.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-9.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-9.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-9.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,236 @@
+/* This is a modfied version of va-arg-2.c to test passing a va_list as
+ a parameter to another function. */
+
+#include <stdarg.h>
+
+extern __SIZE_TYPE__ strlen (const char *);
+
+int
+to_hex (unsigned int a)
+{
+ static char hex[] = "0123456789abcdef";
+
+ if (a > 15)
+ abort ();
+ return hex[a];
+}
+
+void
+fap (int i, char* format, va_list ap)
+{
+ if (strlen (format) != 16 - i)
+ abort ();
+ while (*format)
+ if (*format++ != to_hex (va_arg (ap, int)))
+ abort ();
+}
+
+void
+f0 (char* format, ...)
+{
+ va_list ap;
+
+ va_start (ap, format);
+ fap(0, format, ap);
+ va_end(ap);
+}
+
+void
+f1 (int a1, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(1, format, ap);
+ va_end(ap);
+}
+
+void
+f2 (int a1, int a2, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(2, format, ap);
+ va_end(ap);
+}
+
+void
+f3 (int a1, int a2, int a3, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(3, format, ap);
+ va_end(ap);
+}
+
+void
+f4 (int a1, int a2, int a3, int a4, char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(4, format, ap);
+ va_end(ap);
+}
+
+void
+f5 (int a1, int a2, int a3, int a4, int a5,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(5, format, ap);
+ va_end(ap);
+}
+
+void
+f6 (int a1, int a2, int a3, int a4, int a5,
+ int a6,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(6, format, ap);
+ va_end(ap);
+}
+
+void
+f7 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(7, format, ap);
+ va_end(ap);
+}
+
+void
+f8 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(8, format, ap);
+ va_end(ap);
+}
+
+void
+f9 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(9, format, ap);
+ va_end(ap);
+}
+
+void
+f10 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(10, format, ap);
+ va_end(ap);
+}
+
+void
+f11 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(11, format, ap);
+ va_end(ap);
+}
+
+void
+f12 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(12, format, ap);
+ va_end(ap);
+}
+
+void
+f13 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12, int a13,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(13, format, ap);
+ va_end(ap);
+}
+
+void
+f14 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12, int a13, int a14,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(14, format, ap);
+ va_end(ap);
+}
+
+void
+f15 (int a1, int a2, int a3, int a4, int a5,
+ int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12, int a13, int a14, int a15,
+ char* format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ fap(15, format, ap);
+ va_end(ap);
+}
+
+main ()
+{
+ char *f = "0123456789abcdef";
+
+ f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+ f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);
+ f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);
+ f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);
+ f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);
+ f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);
+ f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);
+ f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);
+ f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-pack-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-pack-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-pack-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-pack-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,143 @@
+/* __builtin_va_arg_pack () builtin tests. */
+
+#include <stdarg.h>
+
+extern void abort (void);
+
+int v1 = 8;
+long int v2 = 3;
+void *v3 = (void *) &v2;
+struct A { char c[16]; } v4 = { "foo" };
+long double v5 = 40;
+char seen[20];
+int cnt;
+
+__attribute__ ((noinline)) int
+foo1 (int x, int y, ...)
+{
+ int i;
+ long int l;
+ void *v;
+ struct A a;
+ long double ld;
+ va_list ap;
+
+ va_start (ap, y);
+ if (x < 0 || x >= 20 || seen[x])
+ abort ();
+ seen[x] = ++cnt;
+ if (y != 6)
+ abort ();
+ i = va_arg (ap, int);
+ if (i != 5)
+ abort ();
+ switch (x)
+ {
+ case 0:
+ i = va_arg (ap, int);
+ if (i != 9 || v1 != 9)
+ abort ();
+ a = va_arg (ap, struct A);
+ if (__builtin_memcmp (a.c, v4.c, sizeof (a.c)) != 0)
+ abort ();
+ v = (void *) va_arg (ap, struct A *);
+ if (v != (void *) &v4)
+ abort ();
+ l = va_arg (ap, long int);
+ if (l != 3 || v2 != 4)
+ abort ();
+ break;
+ case 1:
+ ld = va_arg (ap, long double);
+ if (ld != 41 || v5 != ld)
+ abort ();
+ i = va_arg (ap, int);
+ if (i != 8)
+ abort ();
+ v = va_arg (ap, void *);
+ if (v != &v2)
+ abort ();
+ break;
+ case 2:
+ break;
+ default:
+ abort ();
+ }
+ va_end (ap);
+ return x;
+}
+
+__attribute__ ((noinline)) int
+foo2 (int x, int y, ...)
+{
+ long long int ll;
+ void *v;
+ struct A a, b;
+ long double ld;
+ va_list ap;
+
+ va_start (ap, y);
+ if (x < 0 || x >= 20 || seen[x])
+ abort ();
+ seen[x] = ++cnt | 64;
+ if (y != 10)
+ abort ();
+ switch (x)
+ {
+ case 11:
+ break;
+ case 12:
+ ld = va_arg (ap, long double);
+ if (ld != 41 || v5 != 40)
+ abort ();
+ a = va_arg (ap, struct A);
+ if (__builtin_memcmp (a.c, v4.c, sizeof (a.c)) != 0)
+ abort ();
+ b = va_arg (ap, struct A);
+ if (__builtin_memcmp (b.c, v4.c, sizeof (b.c)) != 0)
+ abort ();
+ v = va_arg (ap, void *);
+ if (v != &v2)
+ abort ();
+ ll = va_arg (ap, long long int);
+ if (ll != 16LL)
+ abort ();
+ break;
+ case 2:
+ break;
+ default:
+ abort ();
+ }
+ va_end (ap);
+ return x + 8;
+}
+
+__attribute__ ((noinline)) int
+foo3 (void)
+{
+ return 6;
+}
+
+extern inline __attribute__ ((always_inline, gnu_inline)) int
+bar (int x, ...)
+{
+ if (x < 10)
+ return foo1 (x, foo3 (), 5, __builtin_va_arg_pack ());
+ return foo2 (x, foo3 () + 4, __builtin_va_arg_pack ());
+}
+
+int
+main (void)
+{
+ if (bar (0, ++v1, v4, &v4, v2++) != 0)
+ abort ();
+ if (bar (1, ++v5, 8, v3) != 1)
+ abort ();
+ if (bar (2) != 2)
+ abort ();
+ if (bar (v1 + 2) != 19)
+ abort ();
+ if (bar (v1 + 3, v5--, v4, v4, v3, 16LL) != 20)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-trap-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-trap-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-trap-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/va-arg-trap-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+/* Undefined behavior from a call to va_arg with a type other than
+ that of the argument passed (in particular, with a type such as
+ "float" that can never be the type of an argument passed through
+ "...") does not appear until after the va_list expression is
+ evaluated. PR 38483. */
+/* Origin: Joseph Myers <joseph at codesourcery.com> */
+
+#include <stdarg.h>
+
+extern void exit (int);
+extern void abort (void);
+
+va_list ap;
+float f;
+
+va_list *
+foo (void)
+{
+ exit (0);
+ return ≈
+}
+
+void
+bar (int i, ...)
+{
+ va_start (ap, i);
+ f = va_arg (*foo (), float);
+ va_end (ap);
+}
+
+int
+main (void)
+{
+ bar (1, 0);
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vfprintf-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vfprintf-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vfprintf-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vfprintf-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,55 @@
+/* { dg-skip-if "requires io" { freestanding } } */
+
+#ifndef test
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+void
+inner (int x, ...)
+{
+ va_list ap, ap2;
+ va_start (ap, x);
+ va_start (ap2, x);
+
+ switch (x)
+ {
+#define test(n, ret, fmt, args) \
+ case n: \
+ vfprintf (stdout, fmt, ap); \
+ if (vfprintf (stdout, fmt, ap2) != ret) \
+ abort (); \
+ break;
+#include "vfprintf-1.c"
+#undef test
+ default:
+ abort ();
+ }
+
+ va_end (ap);
+ va_end (ap2);
+}
+
+int
+main (void)
+{
+#define test(n, ret, fmt, args) \
+ inner args;
+#include "vfprintf-1.c"
+#undef test
+ return 0;
+}
+
+#else
+ test (0, 5, "hello", (0));
+ test (1, 6, "hello\n", (1));
+ test (2, 1, "a", (2));
+ test (3, 0, "", (3));
+ test (4, 5, "%s", (4, "hello"));
+ test (5, 6, "%s", (5, "hello\n"));
+ test (6, 1, "%s", (6, "a"));
+ test (7, 0, "%s", (7, ""));
+ test (8, 1, "%c", (8, 'x'));
+ test (9, 7, "%s\n", (9, "hello\n"));
+ test (10, 2, "%d\n", (10, 0));
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vfprintf-chk-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vfprintf-chk-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vfprintf-chk-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vfprintf-chk-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,75 @@
+/* { dg-skip-if "requires io" { freestanding } } */
+
+#ifndef test
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+volatile int should_optimize;
+
+int
+__attribute__((noinline))
+__vfprintf_chk (FILE *f, int flag, const char *fmt, va_list ap)
+{
+#ifdef __OPTIMIZE__
+ if (should_optimize)
+ abort ();
+#endif
+ should_optimize = 1;
+ return vfprintf (f, fmt, ap);
+}
+
+void
+inner (int x, ...)
+{
+ va_list ap, ap2;
+ va_start (ap, x);
+ va_start (ap2, x);
+
+ switch (x)
+ {
+#define test(n, ret, opt, fmt, args) \
+ case n: \
+ should_optimize = opt; \
+ __vfprintf_chk (stdout, 1, fmt, ap); \
+ if (! should_optimize) \
+ abort (); \
+ should_optimize = 0; \
+ if (__vfprintf_chk (stdout, 1, fmt, ap2) != ret) \
+ abort (); \
+ if (! should_optimize) \
+ abort (); \
+ break;
+#include "vfprintf-chk-1.c"
+#undef test
+ default:
+ abort ();
+ }
+
+ va_end (ap);
+ va_end (ap2);
+}
+
+int
+main (void)
+{
+#define test(n, ret, opt, fmt, args) \
+ inner args;
+#include "vfprintf-chk-1.c"
+#undef test
+ return 0;
+}
+
+#else
+ test (0, 5, 1, "hello", (0));
+ test (1, 6, 1, "hello\n", (1));
+ test (2, 1, 1, "a", (2));
+ test (3, 0, 1, "", (3));
+ test (4, 5, 0, "%s", (4, "hello"));
+ test (5, 6, 0, "%s", (5, "hello\n"));
+ test (6, 1, 0, "%s", (6, "a"));
+ test (7, 0, 0, "%s", (7, ""));
+ test (8, 1, 0, "%c", (8, 'x'));
+ test (9, 7, 0, "%s\n", (9, "hello\n"));
+ test (10, 2, 0, "%d\n", (10, 0));
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vla-dealloc-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vla-dealloc-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vla-dealloc-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vla-dealloc-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+/* VLAs should be deallocated on a jump to before their definition,
+ including a jump to a label in an inner scope. PR 19771. */
+/* { dg-require-effective-target alloca } */
+
+#if (__SIZEOF_INT__ <= 2)
+#define LIMIT 10000
+#else
+#define LIMIT 1000000
+#endif
+
+void *volatile p;
+
+int
+main (void)
+{
+ int n = 0;
+ if (0)
+ {
+ lab:;
+ }
+ int x[n % 1000 + 1];
+ x[0] = 1;
+ x[n % 1000] = 2;
+ p = x;
+ n++;
+ if (n < LIMIT)
+ goto lab;
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vprintf-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vprintf-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vprintf-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vprintf-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,55 @@
+/* { dg-skip-if "requires io" { freestanding } } */
+
+#ifndef test
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+void
+inner (int x, ...)
+{
+ va_list ap, ap2;
+ va_start (ap, x);
+ va_start (ap2, x);
+
+ switch (x)
+ {
+#define test(n, ret, fmt, args) \
+ case n: \
+ vprintf (fmt, ap); \
+ if (vprintf (fmt, ap2) != ret) \
+ abort (); \
+ break;
+#include "vprintf-1.c"
+#undef test
+ default:
+ abort ();
+ }
+
+ va_end (ap);
+ va_end (ap2);
+}
+
+int
+main (void)
+{
+#define test(n, ret, fmt, args) \
+ inner args;
+#include "vprintf-1.c"
+#undef test
+ return 0;
+}
+
+#else
+ test (0, 5, "hello", (0));
+ test (1, 6, "hello\n", (1));
+ test (2, 1, "a", (2));
+ test (3, 0, "", (3));
+ test (4, 5, "%s", (4, "hello"));
+ test (5, 6, "%s", (5, "hello\n"));
+ test (6, 1, "%s", (6, "a"));
+ test (7, 0, "%s", (7, ""));
+ test (8, 1, "%c", (8, 'x'));
+ test (9, 7, "%s\n", (9, "hello\n"));
+ test (10, 2, "%d\n", (10, 0));
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vprintf-chk-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vprintf-chk-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vprintf-chk-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vprintf-chk-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,75 @@
+/* { dg-skip-if "requires io" { freestanding } } */
+
+#ifndef test
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+volatile int should_optimize;
+
+int
+__attribute__((noinline))
+__vprintf_chk (int flag, const char *fmt, va_list ap)
+{
+#ifdef __OPTIMIZE__
+ if (should_optimize)
+ abort ();
+#endif
+ should_optimize = 1;
+ return vprintf (fmt, ap);
+}
+
+void
+inner (int x, ...)
+{
+ va_list ap, ap2;
+ va_start (ap, x);
+ va_start (ap2, x);
+
+ switch (x)
+ {
+#define test(n, ret, opt, fmt, args) \
+ case n: \
+ should_optimize = opt; \
+ __vprintf_chk (1, fmt, ap); \
+ if (! should_optimize) \
+ abort (); \
+ should_optimize = 0; \
+ if (__vprintf_chk (1, fmt, ap2) != ret) \
+ abort (); \
+ if (! should_optimize) \
+ abort (); \
+ break;
+#include "vprintf-chk-1.c"
+#undef test
+ default:
+ abort ();
+ }
+
+ va_end (ap);
+ va_end (ap2);
+}
+
+int
+main (void)
+{
+#define test(n, ret, opt, fmt, args) \
+ inner args;
+#include "vprintf-chk-1.c"
+#undef test
+ return 0;
+}
+
+#else
+ test (0, 5, 0, "hello", (0));
+ test (1, 6, 1, "hello\n", (1));
+ test (2, 1, 1, "a", (2));
+ test (3, 0, 1, "", (3));
+ test (4, 5, 0, "%s", (4, "hello"));
+ test (5, 6, 0, "%s", (5, "hello\n"));
+ test (6, 1, 0, "%s", (6, "a"));
+ test (7, 0, 0, "%s", (7, ""));
+ test (8, 1, 0, "%c", (8, 'x'));
+ test (9, 7, 0, "%s\n", (9, "hello\n"));
+ test (10, 2, 0, "%d\n", (10, 0));
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+
+extern void abort ();
+extern void exit (int);
+
+int f (int a) {
+ if (a != 2) {
+ a = -a;
+ if (a == 2)
+ return 0;
+ return 1;
+ }
+ return 1;
+}
+
+int main (int argc, char *argv[]) {
+ if (f (-2))
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+extern void abort ();
+extern void exit (int);
+
+int f (int a) {
+ if (a != 2) {
+ a = a > 0 ? a : -a;
+ if (a == 2)
+ return 0;
+ return 1;
+ }
+ return 1;
+}
+
+int main (int argc, char *argv[]) {
+ if (f (-2))
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+extern void abort ();
+extern void exit (int);
+
+int f (int a) {
+ if (a < 12) {
+ if (a > -15) {
+ a = a > 0 ? a : -a;
+ if (a == 2)
+ return 0;
+ return 1;
+ }
+ }
+ return 1;
+}
+
+int main (int argc, char *argv[]) {
+ if (f (-2))
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+extern void exit (int);
+extern void abort ();
+
+void test(int x, int y)
+{
+ int c;
+
+ if (x == 1) abort();
+ if (y == 1) abort();
+
+ c = x / y;
+
+ if (c != 1) abort();
+}
+
+int main()
+{
+ test(2, 2);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* { dg-require-effective-target int32plus } */
+extern void exit (int);
+extern void abort ();
+
+void test(unsigned int a, unsigned int b)
+{
+ if (a < 5)
+ abort();
+ if (b < 5)
+ abort();
+ if (a + b != 0U)
+ abort();
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned int x = 0x80000000;
+ test(x, x);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-6.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-6.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-6.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-6.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+/* { dg-require-effective-target int32plus } */
+#include <limits.h>
+
+extern void exit (int);
+extern void abort ();
+
+void test01(unsigned int a, unsigned int b)
+{
+ if (a < 5)
+ abort();
+ if (b < 5)
+ abort();
+ if (a - b != 5)
+ abort();
+}
+
+void test02(unsigned int a, unsigned int b)
+{
+ if (a >= 12)
+ if (b > 15)
+ if (a - b < UINT_MAX - 15U)
+ abort ();
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned x = 0x80000000;
+ test01(x + 5, x);
+ test02(14, 16);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-7.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-7.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-7.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/vrp-7.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+
+void abort (void);
+
+struct T
+{
+ int b : 1;
+} t;
+
+void __attribute__((noinline)) foo (int f)
+{
+ t.b = (f & 0x10) ? 1 : 0;
+}
+
+int main (void)
+{
+ foo (0x10);
+ if (!t.b)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/wchar_t-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/wchar_t-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/wchar_t-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/wchar_t-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+/* { dg-options "-finput-charset=utf-8" } */
+typedef __WCHAR_TYPE__ wchar_t;
+wchar_t x[] = L"Ã";
+wchar_t y = L'Ã';
+extern void abort (void);
+extern void exit (int);
+
+int main (void)
+{
+ if (sizeof (x) / sizeof (wchar_t) != 2)
+ abort ();
+ if (x[0] != L'Ã' || x[1] != L'\0')
+ abort ();
+ if (y != L'Ã')
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+#define C L'\400'
+
+#if C
+#define zero (!C)
+#else
+#define zero C
+#endif
+
+main()
+{
+ if (zero != 0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,11 @@
+#include <stddef.h>
+
+const wchar_t ws[] = L"foo";
+
+int
+main (void)
+{
+ if (ws[0] != L'f' || ws[1] != L'o' || ws[2] != L'o' || ws[3] != L'\0')
+ abort();
+ exit(0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/widechar-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+extern void abort (void);
+extern void exit (int);
+
+static int f(char *x)
+{
+ return __builtin_strlen(x);
+}
+
+int foo ()
+{
+ return f((char*)&L"abcdef"[0]);
+}
+
+
+int
+main()
+{
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ if (foo () != 0)
+ abort ();
+#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ if (foo () != 1)
+ abort ();
+#endif
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zero-struct-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zero-struct-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zero-struct-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zero-struct-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+struct g{};
+char y[3];
+char *f = &y[0];
+char *ff = &y[0];
+void h(void)
+{
+ struct g t;
+ *((struct g*)(f++)) = *((struct g*)(ff++));
+ *((struct g*)(f++)) = (struct g){};
+ t = *((struct g*)(ff++));
+}
+
+void abort (void);
+
+int main(void)
+{
+ h();
+ if (f != &y[2])
+ abort();
+ if (ff != &y[2])
+ abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zero-struct-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zero-struct-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zero-struct-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zero-struct-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+void abort (void);
+int ii;
+typedef struct {} raw_spinlock_t;
+typedef struct {
+ raw_spinlock_t raw_lock;
+} spinlock_t;
+raw_spinlock_t one_raw_spinlock (void)
+{
+ raw_spinlock_t raw_lock;
+ ii++;
+ return raw_lock;
+}
+int main(void)
+{
+ spinlock_t lock = (spinlock_t) { .raw_lock = one_raw_spinlock() };
+ if (ii != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zerolen-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zerolen-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zerolen-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zerolen-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+extern void abort (void);
+extern void exit (int);
+
+union iso_directory_record {
+ char carr[4];
+ struct {
+ unsigned char name_len [1];
+ char name [0];
+ } u;
+} entry;
+
+void set(union iso_directory_record *);
+
+int main (void)
+{
+ union iso_directory_record *de;
+
+ de = &entry;
+ set(de);
+
+ if (de->u.name_len[0] == 1 && de->u.name[0] == 0)
+ exit (0);
+ else
+ abort ();
+}
+
+void set (union iso_directory_record *p)
+{
+ p->carr[0] = 1;
+ p->carr[1] = 0;
+ return;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zerolen-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zerolen-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zerolen-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/zerolen-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* { dg-skip-if "assumes absence of larger-than-word padding" { epiphany-*-* } } */
+extern void abort(void);
+
+typedef int word __attribute__((mode(word)));
+
+struct foo
+{
+ word x;
+ word y[0];
+};
+
+int main()
+{
+ if (sizeof(word) != sizeof(struct foo))
+ abort();
+ if (__alignof__(word) != __alignof__(struct foo))
+ abort();
+ return 0;
+}
More information about the llvm-commits
mailing list