gcc-patches@gcc.gnu.org
[Top] [All Lists]

[PATCH] Merge torture testcases from a-i branch

Subject: [PATCH] Merge torture testcases from a-i branch
From: Richard Guenther
Date: Sun, 29 Mar 2009 16:11:11 +0200 CEST
This makes the diff smaller.

Committed to trunk.

Richard.

2009-03-29  Richard Guenther  <rguenther@xxxxxxx>

        * gcc.c-torture/execute/20090113-1.c: New testcase.
        * gcc.c-torture/execute/20090113-2.c: Likewise.
        * gcc.c-torture/execute/20090113-3.c: Likewise.
        * gcc.c-torture/execute/20090207-1.c: Likewise.
        * gcc.c-torture/compile/20090114-1.c: Likewise.
        * gcc.c-torture/compile/20090328-1.c: Likewise.
        * gcc.dg/noncompile/920507-1.c: Fix out-of-bounds array access.

Index: gcc/testsuite/gcc.c-torture/execute/20090113-1.c
===================================================================
*** gcc/testsuite/gcc.c-torture/execute/20090113-1.c    (revision 0)
--- gcc/testsuite/gcc.c-torture/execute/20090113-1.c    (revision 0)
***************
*** 0 ****
--- 1,61 ----
+ typedef struct descriptor_dimension
+ {
+   int stride;
+   int lbound;
+   int ubound;
+ } descriptor_dimension;
+ typedef struct {
+     int *data;
+     int dtype;
+     descriptor_dimension dim[7];
+ } gfc_array_i4;
+ 
+ void
+ msum_i4 (gfc_array_i4 * const retarray,
+        gfc_array_i4 * const array,
+        const int * const pdim)
+ {
+   int count[7];
+   int extent[7];
+   int * dest;
+   const int * base;
+   int dim;
+   int n;
+   int len;
+ 
+   dim = (*pdim) - 1;
+   len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;
+ 
+   for (n = 0; n < dim; n++)
+     {
+       extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;
+       count[n] = 0;
+     }
+ 
+   dest = retarray->data;
+   base = array->data;
+ 
+   do
+     {
+       int result = 0;
+ 
+       for (n = 0; n < len; n++, base++)
+       result += *base;
+       *dest = result;
+ 
+       count[0]++;
+       dest += 1;
+     }
+   while (count[0] != extent[0]);
+ }
+ 
+ int main()
+ {
+   int rdata[3];
+   int adata[9];
+   gfc_array_i4 retarray = { rdata, 265, { { 1, 1, 3 } } };
+   gfc_array_i4 array = { adata, 266, { { 1, 1, 3 }, { 3, 1, 3 } } };
+   int dim = 2;
+   msum_i4 (&retarray, &array, &dim);
+   return 0;
+ }
Index: gcc/testsuite/gcc.c-torture/execute/20090113-2.c
===================================================================
*** gcc/testsuite/gcc.c-torture/execute/20090113-2.c    (revision 0)
--- gcc/testsuite/gcc.c-torture/execute/20090113-2.c    (revision 0)
***************
*** 0 ****
--- 1,160 ----
+ struct obstack {};
+ struct bitmap_head_def;
+ typedef struct bitmap_head_def *bitmap;
+ typedef const struct bitmap_head_def *const_bitmap;
+ typedef unsigned long BITMAP_WORD;
+ typedef struct bitmap_obstack
+ {
+   struct bitmap_element_def *elements;
+   struct bitmap_head_def *heads;
+   struct obstack obstack;
+ } bitmap_obstack;
+ typedef struct bitmap_element_def
+ {
+   struct bitmap_element_def *next;
+   struct bitmap_element_def *prev;
+   unsigned int indx;
+   BITMAP_WORD bits[((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u))];
+ } bitmap_element;
+ 
+ struct bitmap_descriptor;
+ 
+ typedef struct bitmap_head_def {
+     bitmap_element *first;
+     bitmap_element *current;
+     unsigned int indx;
+     bitmap_obstack *obstack;
+ } bitmap_head;
+ 
+ bitmap_element bitmap_zero_bits;
+ 
+ typedef struct
+ {
+   bitmap_element *elt1;
+   bitmap_element *elt2;
+   unsigned word_no;
+   BITMAP_WORD bits;
+ } bitmap_iterator;
+ 
+ static void __attribute__((noinline))
+ bmp_iter_set_init (bitmap_iterator *bi, const_bitmap map,
+                  unsigned start_bit, unsigned *bit_no)
+ {
+   bi->elt1 = map->first;
+   bi->elt2 = ((void *)0);
+ 
+   while (1)
+     {
+       if (!bi->elt1)
+       {
+         bi->elt1 = &bitmap_zero_bits;
+         break;
+       }
+ 
+       if (bi->elt1->indx >= start_bit / (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 
1u)) * (8 * 8 * 1u)))
+       break;
+       bi->elt1 = bi->elt1->next;
+     }
+ 
+   if (bi->elt1->indx != start_bit / (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 
1u)) * (8 * 8 * 1u)))
+     start_bit = bi->elt1->indx * (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u)) * 
(8 * 8 * 1u));
+ 
+   bi->word_no = start_bit / (8 * 8 * 1u) % ((128 + (8 * 8 * 1u) - 1) / (8 * 8 
* 1u));
+   bi->bits = bi->elt1->bits[bi->word_no];
+   bi->bits >>= start_bit % (8 * 8 * 1u);
+ 
+   start_bit += !bi->bits;
+ 
+   *bit_no = start_bit;
+ }
+ 
+ static void __attribute__((noinline))
+ bmp_iter_next (bitmap_iterator *bi, unsigned *bit_no)
+ {
+   bi->bits >>= 1;
+   *bit_no += 1;
+ }
+ 
+ static unsigned char __attribute__((noinline))
+ bmp_iter_set_tail (bitmap_iterator *bi, unsigned *bit_no)
+ {
+   while (!(bi->bits & 1))
+     {
+       bi->bits >>= 1;
+       *bit_no += 1;
+     }
+   return 1;
+ }
+ 
+ static __inline__ unsigned char
+ bmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)
+ {
+   unsigned bno = *bit_no;
+   BITMAP_WORD bits = bi->bits;
+   bitmap_element *elt1;
+ 
+   if (bits)
+     {
+       while (!(bits & 1))
+       {
+         bits >>= 1;
+         bno += 1;
+       }
+       *bit_no = bno;
+       return 1;
+     }
+ 
+   *bit_no = ((bno + 64 - 1) / 64 * 64);
+   bi->word_no++;
+ 
+   elt1 = bi->elt1;
+   while (1)
+     {
+       while (bi->word_no != 2)
+       {
+         bi->bits = elt1->bits[bi->word_no];
+         if (bi->bits)
+           {
+             bi->elt1 = elt1;
+             return bmp_iter_set_tail (bi, bit_no);
+           }
+         *bit_no += 64;
+         bi->word_no++;
+       }
+ 
+       elt1 = elt1->next;
+       if (!elt1)
+       {
+         bi->elt1 = elt1;
+         return 0;
+       }
+       *bit_no = elt1->indx * (2 * 64);
+       bi->word_no = 0;
+     }
+ }
+ 
+ extern void abort (void);
+ 
+ static void __attribute__((noinline)) catchme(int i)
+ {
+   if (i != 0 && i != 64)
+     abort ();
+ }
+ static void __attribute__((noinline)) foobar (bitmap_head *chain)
+ {
+   bitmap_iterator rsi;
+   unsigned int regno;
+   for (bmp_iter_set_init (&(rsi), (chain), (0), &(regno));
+        bmp_iter_set (&(rsi), &(regno));
+        bmp_iter_next (&(rsi), &(regno)))
+     catchme(regno);
+ }
+ 
+ int main()
+ {
+   bitmap_element elem = { (void *)0, (void *)0, 0, { 1, 1 } };
+   bitmap_head live_throughout = { &elem, &elem, 0, (void *)0 };
+   foobar (&live_throughout);
+   return 0;
+ }
+ 
Index: gcc/testsuite/gcc.c-torture/execute/20090113-3.c
===================================================================
*** gcc/testsuite/gcc.c-torture/execute/20090113-3.c    (revision 0)
--- gcc/testsuite/gcc.c-torture/execute/20090113-3.c    (revision 0)
***************
*** 0 ****
--- 1,138 ----
+ struct obstack {};
+ struct bitmap_head_def;
+ typedef struct bitmap_head_def *bitmap;
+ typedef const struct bitmap_head_def *const_bitmap;
+ typedef unsigned long BITMAP_WORD;
+ 
+ typedef struct bitmap_obstack
+ {
+   struct bitmap_element_def *elements;
+   struct bitmap_head_def *heads;
+   struct obstack obstack;
+ } bitmap_obstack;
+ typedef struct bitmap_element_def
+ {
+   struct bitmap_element_def *next;
+   struct bitmap_element_def *prev;
+   unsigned int indx;
+   BITMAP_WORD bits[(2)];
+ } bitmap_element;
+ 
+ struct bitmap_descriptor;
+ 
+ typedef struct bitmap_head_def {
+     bitmap_element *first;
+     bitmap_element *current;
+     unsigned int indx;
+     bitmap_obstack *obstack;
+ } bitmap_head;
+ 
+ bitmap_element bitmap_zero_bits;
+ 
+ typedef struct
+ {
+   bitmap_element *elt1;
+   bitmap_element *elt2;
+   unsigned word_no;
+   BITMAP_WORD bits;
+ } bitmap_iterator;
+ 
+ static __attribute__((noinline)) void
+ bmp_iter_set_init (bitmap_iterator *bi, const_bitmap map,
+                  unsigned start_bit, unsigned *bit_no)
+ {
+   bi->elt1 = map->first;
+   bi->elt2 = ((void *)0);
+ 
+   while (1)
+     {
+       if (!bi->elt1)
+       {
+         bi->elt1 = &bitmap_zero_bits;
+         break;
+       }
+ 
+       if (bi->elt1->indx >= start_bit / (128u))
+       break;
+       bi->elt1 = bi->elt1->next;
+     }
+ 
+   if (bi->elt1->indx != start_bit / (128u))
+     start_bit = bi->elt1->indx * (128u);
+ 
+   bi->word_no = start_bit / 64u % (2);
+   bi->bits = bi->elt1->bits[bi->word_no];
+   bi->bits >>= start_bit % 64u;
+ 
+   start_bit += !bi->bits;
+ 
+   *bit_no = start_bit;
+ }
+ 
+ static __inline__ __attribute__((always_inline)) void
+ bmp_iter_next (bitmap_iterator *bi, unsigned *bit_no)
+ {
+   bi->bits >>= 1;
+   *bit_no += 1;
+ }
+ 
+ static __inline__ __attribute__((always_inline)) unsigned char
+ bmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)
+ {
+   if (bi->bits)
+     {
+       while (!(bi->bits & 1))
+       {
+         bi->bits >>= 1;
+         *bit_no += 1;
+       }
+       return 1;
+     }
+ 
+   *bit_no = ((*bit_no + 64u - 1) / 64u * 64u);
+   bi->word_no++;
+ 
+   while (1)
+     {
+       while (bi->word_no != (2))
+       {
+         bi->bits = bi->elt1->bits[bi->word_no];
+         if (bi->bits)
+           {
+             while (!(bi->bits & 1))
+               {
+                 bi->bits >>= 1;
+                 *bit_no += 1;
+               }
+             return 1;
+           }
+         *bit_no += 64u;
+         bi->word_no++;
+       }
+ 
+       bi->elt1 = bi->elt1->next;
+       if (!bi->elt1)
+       return 0;
+       *bit_no = bi->elt1->indx * (128u);
+       bi->word_no = 0;
+     }
+ }
+ 
+ static void __attribute__((noinline))
+ foobar (bitmap_head *live_throughout)
+ {
+   bitmap_iterator rsi;
+   unsigned int regno;
+   for (bmp_iter_set_init (&(rsi), (live_throughout), (0), &(regno));
+        bmp_iter_set (&(rsi), &(regno));
+        bmp_iter_next (&(rsi), &(regno)))
+     ;
+ }
+ int main()
+ {
+   bitmap_element elem = { (void *)0, (void *)0, 0, { 1, 1 } };
+   bitmap_head live_throughout = { &elem, &elem, 0, (void *)0 };
+   foobar (&live_throughout);
+   return 0;
+ }
+ 
Index: gcc/testsuite/gcc.c-torture/execute/20090207-1.c
===================================================================
*** gcc/testsuite/gcc.c-torture/execute/20090207-1.c    (revision 0)
--- gcc/testsuite/gcc.c-torture/execute/20090207-1.c    (revision 0)
***************
*** 0 ****
--- 1,16 ----
+ int foo(int i)
+ {
+   int a[32];
+   a[1] = 3;
+   a[0] = 1;
+   a[i] = 2;
+   return a[0];
+ }
+ extern void abort (void);
+ int main()
+ {
+   if (foo (0) != 2
+       || foo (1) != 1)
+     abort ();
+   return 0;
+ }
Index: gcc/testsuite/gcc.c-torture/compile/20090114-1.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/20090114-1.c    (revision 0)
--- gcc/testsuite/gcc.c-torture/compile/20090114-1.c    (revision 0)
***************
*** 0 ****
--- 1,44 ----
+ typedef struct {
+     int MbInterlace;
+     int channel_type;
+ } InputParameters;
+ typedef struct {
+     int type;
+     int NumberofCodedPFrame;
+     int NumberofGOP;
+     int NumberofPPicture;
+     int FieldControl;
+     int Frame_Total_Number_MB;
+     int NumberofCodedMacroBlocks;
+     int BasicUnit;
+ } ImageParameters;
+ extern InputParameters *input;
+ extern ImageParameters *img;
+ long T;
+ void rc_init_pict(int fieldpic)
+ {
+   if(input->MbInterlace)
+     T = img->Frame_Total_Number_MB;
+   img->NumberofCodedMacroBlocks=0;
+   if(input->channel_type==1
+      && img->NumberofCodedPFrame==58)
+     T = 4;
+   if(fieldpic)
+     {
+       switch (img->type)
+       {
+         case 0:
+          if(img->NumberofCodedPFrame>0
+             && img->FieldControl==1)
+            T = 3;
+          if(img->NumberofPPicture==1)
+            T = 2;
+       }
+       if(img->type==0
+        && img->NumberofCodedPFrame>0)
+       T = 0;
+     }
+   if(img->type==0
+      && img->FieldControl==1)
+     T = 1;
+ }
Index: gcc/testsuite/gcc.c-torture/compile/20090328-1.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/20090328-1.c    (revision 0)
--- gcc/testsuite/gcc.c-torture/compile/20090328-1.c    (revision 0)
***************
*** 0 ****
--- 1,17 ----
+ union loc {  unsigned reg; signed offset; };
+ void __frame_state_for (volatile char *state_in, int x)
+ {
+   /* We should move all the loads out of this loop. Right now, we only
+      move one.  It takes two insertions because we insert a cast.  */
+     union loc fs;
+     int reg;
+     for (;;)     {
+         switch (x)  {
+           case 0:
+               *state_in = fs.reg;
+           case 1:
+               *state_in = fs.offset;
+       }
+     }
+ }
+ 
Index: gcc/testsuite/gcc.dg/noncompile/920507-1.c
===================================================================
*** gcc/testsuite/gcc.dg/noncompile/920507-1.c  (revision 145233)
--- gcc/testsuite/gcc.dg/noncompile/920507-1.c  (working copy)
*************** x(void)
*** 3,7 ****
  {
   register int *a asm("unknown_register");  /* { dg-error "invalid register" } 
*/
   int *v[1] = {a};
!  return v[1];
  }
--- 3,7 ----
  {
   register int *a asm("unknown_register");  /* { dg-error "invalid register" } 
*/
   int *v[1] = {a};
!  return v[0];
  }

<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH] Merge torture testcases from a-i branch, Richard Guenther <=