Add a few testcases which I had floating around in a private tree. Most of these testcases failed in our private tree at one point due to local changes. Since it is always good to have more testcases, I decided to commit them.
I tested all of them on x86_64 with no failures. Thanks, Andrew ChangeLog: * gcc.c-torture/execute/memset-4.c: New test. * gcc.c-torture/execute/20110418-1.c: New test. * gcc.c-torture/execute/20141022-1.c: New test. * gcc.c-torture/execute/strcpy-2.c: New test. * gcc.c-torture/execute/20140212-2.c: New test. * gcc.c-torture/compile/20120913-1.c: New test. * gcc.c-torture/compile/20121010-1.c: New test. * gcc.c-torture/compile/20120917-1.c: New test. * gcc.c-torture/compile/20140110-1.c: New test. * gcc.c-torture/compile/20121220-1.c: New test. * gcc.c-torture/compile/20120822-1.c: New test. * gcc.c-torture/compile/20121027-1.c: New test. * gcc.c-torture/compile/20120830-2.c: New test.
Index: gcc.c-torture/execute/memset-4.c =================================================================== --- gcc.c-torture/execute/memset-4.c (revision 0) +++ gcc.c-torture/execute/memset-4.c (revision 0) @@ -0,0 +1,27 @@ +/* Test to make sure memset of small old size works + correctly. */ +#define SIZE 15 + +void f(char *a) __attribute__((noinline)); +void f(char *a) +{ + __builtin_memset (a, 0, SIZE); +} + + +int main(void) +{ + int i; + char b[SIZE]; + for(i = 0; i < sizeof(b); i++) + { + b[i] = i; + } + f(b); + for(i = 0; i < sizeof(b); i++) + { + if (0 != b[i]) + __builtin_abort (); + } + return 0; +} Index: gcc.c-torture/execute/20110418-1.c =================================================================== --- gcc.c-torture/execute/20110418-1.c (revision 0) +++ gcc.c-torture/execute/20110418-1.c (revision 0) @@ -0,0 +1,29 @@ +typedef unsigned long long uint64_t; +void f(uint64_t *a, uint64_t aa) __attribute__((noinline)); +void f(uint64_t *a, uint64_t aa) +{ + uint64_t new_value = aa; + uint64_t old_value = *a; + int bit_size = 32; + uint64_t mask = (uint64_t)(unsigned)(-1); + uint64_t tmp = old_value & mask; + new_value &= mask; + /* On overflow we need to add 1 in the upper bits */ + if (tmp > new_value) + new_value += 1ull<<bit_size; + /* Add in the upper bits from the old value */ + new_value += old_value & ~mask; + *a = new_value; +} +int main(void) +{ + uint64_t value, new_value, old_value; + value = 0x100000001; + old_value = value; + new_value = (value+1)&(uint64_t)(unsigned)(-1); + f(&value, new_value); + if (value != old_value+1) + __builtin_abort (); + return 0; +} + Index: gcc.c-torture/execute/20141022-1.c =================================================================== --- gcc.c-torture/execute/20141022-1.c (revision 0) +++ gcc.c-torture/execute/20141022-1.c (revision 0) @@ -0,0 +1,25 @@ +#define ABORT() do { __builtin_printf("assert.\n"); __builtin_abort (); }while(0) +int f(int a) __attribute__((noinline)); +int f(int a) +{ + int fem_key_src; + int D2930 = a & 4294967291; + fem_key_src = a == 6 ? 0 : 15; + fem_key_src = D2930 != 1 ? fem_key_src : 0; + return fem_key_src; +} + +int main(void) +{ + if (f(0) != 15) + ABORT (); + if (f(1) != 0) + ABORT (); + if (f(6) != 0) + ABORT (); + if (f(5) != 0) + ABORT (); + if (f(15) != 15) + ABORT (); + return 0; +} Index: gcc.c-torture/execute/strcpy-2.c =================================================================== --- gcc.c-torture/execute/strcpy-2.c (revision 0) +++ gcc.c-torture/execute/strcpy-2.c (revision 0) @@ -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; +} Index: gcc.c-torture/execute/20140212-2.c =================================================================== --- gcc.c-torture/execute/20140212-2.c (revision 0) +++ gcc.c-torture/execute/20140212-2.c (revision 0) @@ -0,0 +1,21 @@ +/* This used to fail as we would convert f into just return (unsigned int)usVlanID + which is wrong. */ + +int f(unsigned short usVlanID) __attribute__((noinline,noclone)); +int f(unsigned short usVlanID) +{ + unsigned int uiVlanID = 0xffffffff; + int i; + if ((unsigned short)0xffff != usVlanID) + uiVlanID = (unsigned int)usVlanID; + return uiVlanID; +} + +int main(void) +{ + if (f(1) != 1) + __builtin_abort (); + if (f(0xffff) != -1) + __builtin_abort (); + return 0; +} Index: gcc.c-torture/compile/20120913-1.c =================================================================== --- gcc.c-torture/compile/20120913-1.c (revision 0) +++ gcc.c-torture/compile/20120913-1.c (revision 0) @@ -0,0 +1,17 @@ +struct list_head { + struct list_head *next, *prev; +}; +struct dm_exception { + struct list_head hash_list; + unsigned long long old_chunk; + unsigned long long new_chunk; +}; +struct dm_exception *dm_lookup_exception(struct list_head *table, unsigned long long chunk) { + struct list_head *slot; + struct dm_exception *e; + slot = &table[0]; + e = (struct dm_exception *)slot->next; + for (; &e->hash_list != (slot);) + if (chunk <= (e->new_chunk>>56)) + return e; +} Index: gcc.c-torture/compile/20121010-1.c =================================================================== --- gcc.c-torture/compile/20121010-1.c (revision 0) +++ gcc.c-torture/compile/20121010-1.c (revision 0) @@ -0,0 +1,10 @@ +int _IO_getc(int*); +read_long(int *fp) +{ + unsigned char b0, b1, b2, b3; + b0 = _IO_getc (fp); + b1 = _IO_getc (fp); + b2 = _IO_getc (fp); + b3 = _IO_getc (fp); + return ((int)(((((b3 << 8) | b2) << 8) | b1) << 8) | b0); +} Index: gcc.c-torture/compile/20120917-1.c =================================================================== --- gcc.c-torture/compile/20120917-1.c (revision 0) +++ gcc.c-torture/compile/20120917-1.c (revision 0) @@ -0,0 +1,13 @@ +typedef long long curl_off_t; +int tool_seek_cb(void *userdata, curl_off_t offset, int whence) +{ + if(offset > 0x7FFFFFFFLL - 0x1LL) +{ + curl_off_t left = offset; + while(left) +{ + long step = (left > 0x7FFFFFFFLL - 0x1LL) ? 2147483647L - 1L : (long)left; + left -= step; + } + } +} Index: gcc.c-torture/compile/20140110-1.c =================================================================== --- gcc.c-torture/compile/20140110-1.c (revision 0) +++ gcc.c-torture/compile/20140110-1.c (revision 0) @@ -0,0 +1,14 @@ +typedef long unsigned int size_t; +struct RangeMapRange { + unsigned fromMin; + unsigned fromMax; + unsigned toMin; +}; +void reserve1(void); +void f(struct RangeMapRange *q1, size_t t) +{ + const struct RangeMapRange *q2 = q1 + t; + size_t n = q2 - q1; + if (n > 0) + reserve1(); +} Index: gcc.c-torture/compile/20121220-1.c =================================================================== --- gcc.c-torture/compile/20121220-1.c (revision 0) +++ gcc.c-torture/compile/20121220-1.c (revision 0) @@ -0,0 +1,14 @@ +typedef unsigned char uint8_t; +typedef unsigned int uint32_t; +static __attribute__ (( always_inline )) __inline__ +void rop_8_notsrc_or_dst(uint8_t *dst, uint8_t src) +{ + *dst = (~(src)) | (*dst); +} +void cirrus_colorexpand_notsrc_or_dst_8 (uint8_t * dst, int bits) +{ + uint8_t src; + uint32_t colors[2]; + src = colors[bits]; + rop_8_notsrc_or_dst(dst, src); +} Index: gcc.c-torture/compile/20120822-1.c =================================================================== --- gcc.c-torture/compile/20120822-1.c (revision 0) +++ gcc.c-torture/compile/20120822-1.c (revision 0) @@ -0,0 +1,11 @@ +int a; +int c; +int b; +void shr_long(int d, unsigned char s) +{ + long long dvd, div, mod; + dvd = b; + mod = dvd % s; + if (((c >> ((mod & 0xff) % 32)) & 1) == 0) + a = 1; +} Index: gcc.c-torture/compile/20121027-1.c =================================================================== --- gcc.c-torture/compile/20121027-1.c (revision 0) +++ gcc.c-torture/compile/20121027-1.c (revision 0) @@ -0,0 +1,13 @@ +extern int nc; +void f(void) +{ + unsigned char resp[1024]; + int c; + int bl = 0; + unsigned long long *dwords = (unsigned long long *)(resp + 5); + for (c=0; c<nc; c++) + { + ff(dwords[bl/64]); + bl++; + } +} Index: gcc.c-torture/compile/20120830-2.c =================================================================== --- gcc.c-torture/compile/20120830-2.c (revision 0) +++ gcc.c-torture/compile/20120830-2.c (revision 0) @@ -0,0 +1,5 @@ +ubidi_writeReordered_49( int *dest, const unsigned char *dirProps) +{ + if (!(1&(1UL<<*dirProps))) + *dest=1; +}