more compilerhangs
authorMatthias Braun <matze@braunis.de>
Mon, 14 Aug 2006 12:31:33 +0000 (12:31 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 14 Aug 2006 12:31:33 +0000 (12:31 +0000)
ir/be/test/compilerhang1.c
ir/be/test/compilerhang2.c [new file with mode: 0644]
ir/be/test/compilerhang3.c [new file with mode: 0644]

index 247f51c..5fbe4bb 100644 (file)
@@ -1,25 +1,8 @@
 /* Verify that flexible arrays can be initialized from STRING_CST
    constructors. */
 
-/* Baselines.  */
-struct {
-  char a1c;
-  char *a1p;
-} a1 = {
-  '4',
-  "62"
-};
-
-struct {
-  char a2c;
-  char a2p[2];
-} a2 = {
-  'v',
-  "cq"
-};
-
 /* The tests.  */
-struct {
+struct S3 {
   char a3c;
   char a3p[];
 } a3 = {
@@ -27,32 +10,8 @@ struct {
   "wx"
 };
 
-struct {
-  char a4c;
-  char a4p[];
-} a4 = {
-  '9',
-  { 'e', 'b' }
-};
-
 main()
 {
-  if (a1.a1c != '4')
-    abort();
-  if (a1.a1p[0] != '6')
-    abort();
-  if (a1.a1p[1] != '2')
-    abort();
-  if (a1.a1p[2] != '\0')
-    abort();
-
-  if (a2.a2c != 'v')
-    abort();
-  if (a2.a2p[0] != 'c')
-    abort();
-  if (a2.a2p[1] != 'q')
-    abort();
-
   if (a3.a3c != 'o')
     abort();
   if (a3.a3p[0] != 'w')
@@ -60,12 +19,5 @@ main()
   if (a3.a3p[1] != 'x')
     abort();
 
-  if (a4.a4c != '9')
-    abort();
-  if (a4.a4p[0] != 'e')
-    abort();
-  if (a4.a4p[1] != 'b')
-    abort();
-
   return 0;
 }
diff --git a/ir/be/test/compilerhang2.c b/ir/be/test/compilerhang2.c
new file mode 100644 (file)
index 0000000..491d5d6
--- /dev/null
@@ -0,0 +1,58 @@
+/* Macros to emit "L Nxx R" for each octal number xx between 000 and 037.  */
+#define OP1(L, N, R, I, J) L N##I##J R
+#define OP2(L, N, R, I) \
+    OP1(L, N, R, 0, I), OP1(L, N, R, 1, I), \
+    OP1(L, N, R, 2, I), OP1(L, N, R, 3, I)
+#define OP(L, N, R) \
+    OP2(L, N, R, 0), OP2(L, N, R, 1), OP2(L, N, R, 2), OP2(L, N, R, 3), \
+    OP2(L, N, R, 4), OP2(L, N, R, 5), OP2(L, N, R, 6), OP2(L, N, R, 7)
+
+/* Declare 32 unique variables with prefix N.  */
+#define DECLARE(N) OP (, N,)
+
+/* Copy 32 variables with prefix N from the array at ADDR.
+   Leave ADDR pointing to the end of the array.  */
+#define COPYIN(N, ADDR) OP (, N, = *(ADDR++))
+
+/* Likewise, but copy the other way.  */
+#define COPYOUT(N, ADDR) OP (*(ADDR++) =, N,)
+
+/* Add the contents of the array at ADDR to 32 variables with prefix N.
+   Leave ADDR pointing to the end of the array.  */
+#define ADD(N, ADDR) OP (, N, += *(ADDR++))
+
+volatile double gd[32];
+volatile float gf[32];
+
+void foo (int n)
+{
+  double DECLARE(d);
+  float DECLARE(f);
+  volatile double *pd;
+  volatile float *pf;
+  int i;
+
+  pd = gd; COPYIN (d, pd);
+  for (i = 0; i < n; i++)
+    {
+      pf = gf; COPYIN (f, pf);
+      pd = gd; ADD (d, pd);
+      pd = gd; ADD (d, pd);
+      pd = gd; ADD (d, pd);
+      pf = gf; COPYOUT (f, pf);
+    }
+  pd = gd; COPYOUT (d, pd);
+}
+
+int main ()
+{
+  int i;
+
+  for (i = 0; i < 32; i++)
+    gd[i] = i, gf[i] = i;
+  foo (1);
+  for (i = 0; i < 32; i++)
+    if (gd[i] != i * 4 || gf[i] != i)
+      abort ();
+  exit (0);
+}
diff --git a/ir/be/test/compilerhang3.c b/ir/be/test/compilerhang3.c
new file mode 100644 (file)
index 0000000..f06811c
--- /dev/null
@@ -0,0 +1,153 @@
+/* Test arithmetics on bitfields.  */
+
+extern void abort (void);
+extern void exit (int);
+
+unsigned int
+myrnd (void)
+{
+  static unsigned int s = 1388815473;
+  s *= 1103515245;
+  s += 12345;
+  return (s / 65536) % 2048;
+}
+
+#define T(S)                                   \
+struct S s##S;                                 \
+struct S retme##S (struct S x)                 \
+{                                              \
+  return x;                                    \
+}                                              \
+                                               \
+unsigned int fn1##S (unsigned int x)           \
+{                                              \
+  struct S y = s##S;                           \
+  y.k += x;                                    \
+  y = retme##S (y);                            \
+  return y.k;                                  \
+}                                              \
+                                               \
+unsigned int fn2##S (unsigned int x)           \
+{                                              \
+  struct S y = s##S;                           \
+  y.k += x;                                    \
+  y.k %= 15;                                   \
+  return y.k;                                  \
+}                                              \
+                                               \
+unsigned int retit##S (void)                   \
+{                                              \
+  return s##S.k;                               \
+}                                              \
+                                               \
+unsigned int fn3##S (unsigned int x)           \
+{                                              \
+  s##S.k += x;                                 \
+  return retit##S ();                          \
+}                                              \
+                                               \
+void test##S (void)                            \
+{                                              \
+  int i;                                       \
+  unsigned int mask, v, a, r;                  \
+  struct S x;                                  \
+  char *p = (char *) &s##S;                    \
+  for (i = 0; i < sizeof (s##S); ++i)          \
+    *p++ = myrnd ();                           \
+  if (__builtin_classify_type (s##S.l) == 8)   \
+    s##S.l = 5.25;                             \
+  s##S.k = -1;                                 \
+  mask = s##S.k;                               \
+  v = myrnd ();                                        \
+  a = myrnd ();                                        \
+  s##S.k = v;                                  \
+  x = s##S;                                    \
+  r = fn1##S (a);                              \
+  if (x.i != s##S.i || x.j != s##S.j           \
+      || x.k != s##S.k || x.l != s##S.l                \
+      || ((v + a) & mask) != r)                        \
+    abort ();                                  \
+  v = myrnd ();                                        \
+  a = myrnd ();                                        \
+  s##S.k = v;                                  \
+  x = s##S;                                    \
+  r = fn2##S (a);                              \
+  if (x.i != s##S.i || x.j != s##S.j           \
+      || x.k != s##S.k || x.l != s##S.l                \
+      || ((((v + a) & mask) % 15) & mask) != r)        \
+    abort ();                                  \
+  v = myrnd ();                                        \
+  a = myrnd ();                                        \
+  s##S.k = v;                                  \
+  x = s##S;                                    \
+  r = fn3##S (a);                              \
+  if (x.i != s##S.i || x.j != s##S.j           \
+      || s##S.k != r || x.l != s##S.l          \
+      || ((v + a) & mask) != r)                        \
+    abort ();                                  \
+}
+
+#ifdef __powerpc64__
+/* Temporary hack for broken PPC64 unaligned handling PR rtl-optimization/13674 */
+# define pck
+#else
+# define pck __attribute__((packed))
+#endif
+struct pck A { unsigned short i : 1, l : 1, j : 3, k : 11; }; T(A)
+struct pck B { unsigned short i : 4, j : 1, k : 11; unsigned int l; }; T(B)
+struct pck C { unsigned int l; unsigned short i : 4, j : 1, k : 11; }; T(C)
+struct pck D { unsigned long long l : 6, i : 6, j : 23, k : 29; }; T(D)
+struct pck E { unsigned long long l, i : 12, j : 23, k : 29; }; T(E)
+struct pck F { unsigned long long i : 12, j : 23, k : 29, l; }; T(F)
+struct pck G { unsigned short i : 1, j : 1, k : 6; unsigned long long l; }; T(G)
+struct pck H { unsigned short i : 6, j : 2, k : 8; unsigned long long l; }; T(H)
+struct pck I { unsigned short i : 1, j : 6, k : 1; unsigned long long l; }; T(I)
+struct pck J { unsigned short i : 1, j : 8, k : 7; unsigned short l; }; T(J)
+struct pck K { unsigned int k : 6, l : 1, j : 10, i : 15; }; T(K)
+struct pck L { unsigned int k : 6, j : 11, i : 15; unsigned int l; }; T(L)
+struct pck M { unsigned int l; unsigned short k : 6, j : 11, i : 15; }; T(M)
+struct pck N { unsigned long long l : 6, k : 6, j : 23, i : 29; }; T(N)
+struct pck O { unsigned long long l, k : 12, j : 23, i : 29; }; T(O)
+struct pck P { unsigned long long k : 12, j : 23, i : 29, l; }; T(P)
+struct pck Q { unsigned short k : 12, j : 1, i : 3; unsigned long long l; }; T(Q)
+struct pck R { unsigned short k : 2, j : 11, i : 3; unsigned long long l; }; T(R)
+struct pck S { unsigned short k : 1, j : 6, i : 9; unsigned long long l; }; T(S)
+struct pck T { unsigned short k : 1, j : 8, i : 7; unsigned short l; }; T(T)
+struct pck U { unsigned short j : 6, k : 1, i : 9; unsigned long long l; }; T(U)
+struct pck V { unsigned short j : 8, k : 1, i : 7; unsigned short l; }; T(V)
+struct pck W { long double l; unsigned int k : 12, j : 13, i : 7; }; T(W)
+struct pck X { unsigned int k : 12, j : 13, i : 7; long double l; }; T(X)
+struct pck Y { unsigned int k : 12, j : 11, i : 9; long double l; }; T(Y)
+struct pck Z { long double l; unsigned int j : 13, i : 7, k : 12; }; T(Z)
+
+int
+main (void)
+{
+  testA ();
+  testB ();
+  testC ();
+  testD ();
+  testE ();
+  testF ();
+  testG ();
+  testH ();
+  testI ();
+  testJ ();
+  testK ();
+  testL ();
+  testM ();
+  testN ();
+  testO ();
+  testP ();
+  testQ ();
+  testR ();
+  testS ();
+  testT ();
+  testU ();
+  testV ();
+  testW ();
+  testX ();
+  testY ();
+  testZ ();
+  exit (0);
+}