[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/bf64-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bf64-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bf64-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bf64-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+/* { dg-xfail-if "ABI specifies bitfields cannot exceed 32 bits" { mcore-*-* } } */
+struct tmp
+{
+ long long int pad : 12;
+ long long int field : 52;
+};
+
+struct tmp2
+{
+ long long int field : 52;
+ long long int pad : 12;
+};
+
+struct tmp
+sub (struct tmp tmp)
+{
+ tmp.field |= 0x0008765412345678LL;
+ return tmp;
+}
+
+struct tmp2
+sub2 (struct tmp2 tmp2)
+{
+ tmp2.field |= 0x0008765412345678LL;
+ return tmp2;
+}
+
+main()
+{
+ struct tmp tmp = {0x123, 0xFFF000FFF000FLL};
+ struct tmp2 tmp2 = {0xFFF000FFF000FLL, 0x123};
+
+ tmp = sub (tmp);
+ tmp2 = sub2 (tmp2);
+
+ if (tmp.pad != 0x123 || tmp.field != 0xFFFFFF541FFF567FLL)
+ abort ();
+ if (tmp2.pad != 0x123 || tmp2.field != 0xFFFFFF541FFF567FLL)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,54 @@
+/* Copyright 2002 Free Software Foundation, Inc.
+
+ Tests correct signedness of operations on bitfields; in particular
+ that integer promotions are done correctly, including the case when
+ casts are present.
+
+ The C front end was eliding the cast of an unsigned bitfield to
+ unsigned as a no-op, when in fact it forces a conversion to a
+ full-width unsigned int. (At the time of writing, the C++ front end
+ has a different bug; it erroneously promotes the uncast unsigned
+ bitfield to an unsigned int).
+
+ Source: Neil Booth, 25 Jan 2002, based on PR 3325 (and 3326, which
+ is a different manifestation of the same bug).
+*/
+
+extern void abort ();
+
+int
+main(int argc, char *argv[])
+{
+ struct x { signed int i : 7; unsigned int u : 7; } bit;
+
+ unsigned int u;
+ int i;
+ unsigned int unsigned_result = -13U % 61;
+ int signed_result = -13 % 61;
+
+ bit.u = 61, u = 61;
+ bit.i = -13, i = -13;
+
+ if (i % u != unsigned_result)
+ abort ();
+ if (i % (unsigned int) u != unsigned_result)
+ abort ();
+
+ /* Somewhat counter-intuitively, bit.u is promoted to an int, making
+ the operands and result an int. */
+ if (i % bit.u != signed_result)
+ abort ();
+
+ if (bit.i % bit.u != signed_result)
+ abort ();
+
+ /* But with a cast to unsigned int, the unsigned int is promoted to
+ itself as a no-op, and the operands and result are unsigned. */
+ if (i % (unsigned int) bit.u != unsigned_result)
+ abort ();
+
+ if (bit.i % (unsigned int) bit.u != unsigned_result)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* Test whether bit field boundaries aren't advanced if bit field type
+ has alignment large enough. */
+extern void abort (void);
+extern void exit (int);
+
+struct A {
+ unsigned short a : 5;
+ unsigned short b : 5;
+ unsigned short c : 6;
+};
+
+struct B {
+ unsigned short a : 5;
+ unsigned short b : 3;
+ unsigned short c : 8;
+};
+
+int main ()
+{
+ /* If short is not at least 16 bits wide, don't test anything. */
+ if ((unsigned short) 65521 != 65521)
+ exit (0);
+
+ if (sizeof (struct A) != sizeof (struct B))
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,54 @@
+/* Test that operations on bit-fields yield results reduced to bit-field
+ type. */
+/* Origin: Joseph Myers <jsm at polyomino.org.uk> */
+
+extern void exit (int);
+extern void abort (void);
+
+struct s {
+ unsigned long long u33: 33;
+ unsigned long long u40: 40;
+ unsigned long long u41: 41;
+};
+
+struct s a = { 0x100000, 0x100000, 0x100000 };
+struct s b = { 0x100000000ULL, 0x100000000ULL, 0x100000000ULL };
+struct s c = { 0x1FFFFFFFFULL, 0, 0 };
+
+int
+main (void)
+{
+ if (a.u33 * a.u33 != 0 || a.u33 * a.u40 != 0 || a.u40 * a.u33 != 0
+ || a.u40 * a.u40 != 0)
+ abort ();
+ if (a.u33 * a.u41 != 0x10000000000ULL
+ || a.u40 * a.u41 != 0x10000000000ULL
+ || a.u41 * a.u33 != 0x10000000000ULL
+ || a.u41 * a.u40 != 0x10000000000ULL
+ || a.u41 * a.u41 != 0x10000000000ULL)
+ abort ();
+ if (b.u33 + b.u33 != 0)
+ abort ();
+ if (b.u33 + b.u40 != 0x200000000ULL
+ || b.u33 + b.u41 != 0x200000000ULL
+ || b.u40 + b.u33 != 0x200000000ULL
+ || b.u40 + b.u40 != 0x200000000ULL
+ || b.u40 + b.u41 != 0x200000000ULL
+ || b.u41 + b.u33 != 0x200000000ULL
+ || b.u41 + b.u40 != 0x200000000ULL
+ || b.u41 + b.u41 != 0x200000000ULL)
+ abort ();
+ if (a.u33 - b.u33 != 0x100100000ULL
+ || a.u33 - b.u40 != 0xFF00100000ULL
+ || a.u33 - b.u41 != 0x1FF00100000ULL
+ || a.u40 - b.u33 != 0xFF00100000ULL
+ || a.u40 - b.u40 != 0xFF00100000ULL
+ || a.u40 - b.u41 != 0x1FF00100000ULL
+ || a.u41 - b.u33 != 0x1FF00100000ULL
+ || a.u41 - b.u40 != 0x1FF00100000ULL
+ || a.u41 - b.u41 != 0x1FF00100000ULL)
+ abort ();
+ if (++c.u33 != 0 || --c.u40 != 0xFFFFFFFFFFULL || c.u41-- != 0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* When comparisons of bit-fields to unsigned constants got shortened,
+ the shortened signed constant was wrongly marked as overflowing,
+ leading to a later integer_zerop failure and misoptimization.
+
+ Related to bug tree-optimization/16437 but shows the problem on
+ 32-bit systems. */
+/* Origin: Joseph Myers <jsm at polyomino.org.uk> */
+
+/* { dg-require-effective-target int32plus } */
+
+extern void abort (void);
+
+struct s { int a:12, b:20; };
+
+struct s x = { -123, -456 };
+
+int
+main (void)
+{
+ if (x.a != -123U || x.b != -456U)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+/* See http://gcc.gnu.org/ml/gcc/2009-06/msg00072.html. */
+
+extern void abort (void);
+
+struct s
+{
+ unsigned long long a:2;
+ unsigned long long b:40;
+ unsigned long long c:22;
+};
+
+__attribute__ ((noinline)) void
+g (unsigned long long a, unsigned long long b)
+{
+ asm ("");
+ if (a != b)
+ abort ();
+}
+
+__attribute__ ((noinline)) void
+f (struct s s, unsigned long long b)
+{
+ asm ("");
+ g (((unsigned long long) (s.b-8)) + 8, b);
+}
+
+int
+main ()
+{
+ struct s s = {1, 10, 3};
+ struct s t = {1, 2, 3};
+ f (s, 10);
+ f (t, 0x10000000002);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-6.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-6.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-6.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-6.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* { dg-require-effective-target int32plus } */
+union U
+{
+ const int a;
+ unsigned b : 20;
+};
+
+static union U u = { 0x12345678 };
+
+/* Constant folding used to fail to account for endianness when folding a
+ union. */
+
+int
+main (void)
+{
+#ifdef __BYTE_ORDER__
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ return u.b - 0x45678;
+#else
+ return u.b - 0x12345;
+#endif
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-7.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-7.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-7.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bitfld-7.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* { dg-require-effective-target int32plus } */
+union U
+{
+ const int a;
+ unsigned b : 24;
+};
+
+static union U u = { 0x12345678 };
+
+/* Constant folding used to fail to account for endianness when folding a
+ union. */
+
+int
+main (void)
+{
+#ifdef __BYTE_ORDER__
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ return u.b - 0x345678;
+#else
+ return u.b - 0x123456;
+#endif
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bswap-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bswap-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bswap-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bswap-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,51 @@
+/* Test __builtin_bswap64 . */
+
+unsigned long long g(unsigned long long a) __attribute__((noinline));
+unsigned long long g(unsigned long long a)
+{
+ return __builtin_bswap64(a);
+}
+
+
+unsigned long long f(unsigned long long c)
+{
+ union {
+ unsigned long long a;
+ unsigned char b[8];
+ } a, b;
+ a.a = c;
+ b.b[0] = a.b[7];
+ b.b[1] = a.b[6];
+ b.b[2] = a.b[5];
+ b.b[3] = a.b[4];
+ b.b[4] = a.b[3];
+ b.b[5] = a.b[2];
+ b.b[6] = a.b[1];
+ b.b[7] = a.b[0];
+ return b.a;
+}
+
+int main(void)
+{
+ unsigned long long i;
+ /* The rest of the testcase assumes 8 byte long long. */
+ if (sizeof(i) != sizeof(char)*8)
+ return 0;
+ if (f(0x12) != g(0x12))
+ __builtin_abort();
+ if (f(0x1234) != g(0x1234))
+ __builtin_abort();
+ if (f(0x123456) != g(0x123456))
+ __builtin_abort();
+ if (f(0x12345678ull) != g(0x12345678ull))
+ __builtin_abort();
+ if (f(0x1234567890ull) != g(0x1234567890ull))
+ __builtin_abort();
+ if (f(0x123456789012ull) != g(0x123456789012ull))
+ __builtin_abort();
+ if (f(0x12345678901234ull) != g(0x12345678901234ull))
+ __builtin_abort();
+ if (f(0x1234567890123456ull) != g(0x1234567890123456ull))
+ __builtin_abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bswap-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bswap-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bswap-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/bswap-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,136 @@
+/* { dg-require-effective-target int32plus } */
+
+#ifdef __UINT32_TYPE__
+typedef __UINT32_TYPE__ uint32_t;
+#else
+typedef __UINT32_TYPE__ unsigned;
+#endif
+
+struct bitfield {
+ unsigned char f0:7;
+ unsigned char :1;
+ unsigned char f1:7;
+ unsigned char :1;
+ unsigned char f2:7;
+ unsigned char :1;
+ unsigned char f3:7;
+};
+
+struct ok {
+ unsigned char f0;
+ unsigned char f1;
+ unsigned char f2;
+ unsigned char f3;
+};
+
+union bf_or_uint32 {
+ struct ok inval;
+ struct bitfield bfval;
+};
+
+__attribute__ ((noinline, noclone)) uint32_t
+partial_read_le32 (union bf_or_uint32 in)
+{
+ return in.bfval.f0 | (in.bfval.f1 << 8)
+ | (in.bfval.f2 << 16) | (in.bfval.f3 << 24);
+}
+
+__attribute__ ((noinline, noclone)) uint32_t
+partial_read_be32 (union bf_or_uint32 in)
+{
+ return in.bfval.f3 | (in.bfval.f2 << 8)
+ | (in.bfval.f1 << 16) | (in.bfval.f0 << 24);
+}
+
+__attribute__ ((noinline, noclone)) uint32_t
+fake_read_le32 (char *x, char *y)
+{
+ unsigned char c0, c1, c2, c3;
+
+ c0 = x[0];
+ c1 = x[1];
+ *y = 1;
+ c2 = x[2];
+ c3 = x[3];
+ return c0 | c1 << 8 | c2 << 16 | c3 << 24;
+}
+
+__attribute__ ((noinline, noclone)) uint32_t
+fake_read_be32 (char *x, char *y)
+{
+ unsigned char c0, c1, c2, c3;
+
+ c0 = x[0];
+ c1 = x[1];
+ *y = 1;
+ c2 = x[2];
+ c3 = x[3];
+ return c3 | c2 << 8 | c1 << 16 | c0 << 24;
+}
+
+__attribute__ ((noinline, noclone)) uint32_t
+incorrect_read_le32 (char *x, char *y)
+{
+ unsigned char c0, c1, c2, c3;
+
+ c0 = x[0];
+ c1 = x[1];
+ c2 = x[2];
+ c3 = x[3];
+ *y = 1;
+ return c0 | c1 << 8 | c2 << 16 | c3 << 24;
+}
+
+__attribute__ ((noinline, noclone)) uint32_t
+incorrect_read_be32 (char *x, char *y)
+{
+ unsigned char c0, c1, c2, c3;
+
+ c0 = x[0];
+ c1 = x[1];
+ c2 = x[2];
+ c3 = x[3];
+ *y = 1;
+ return c3 | c2 << 8 | c1 << 16 | c0 << 24;
+}
+
+int
+main ()
+{
+ union bf_or_uint32 bfin;
+ uint32_t out;
+ char cin[] = { 0x83, 0x85, 0x87, 0x89 };
+
+ if (sizeof (uint32_t) * __CHAR_BIT__ != 32)
+ return 0;
+ bfin.inval = (struct ok) { 0x83, 0x85, 0x87, 0x89 };
+ out = partial_read_le32 (bfin);
+ /* Test what bswap would do if its check are not strict enough instead of
+ what is the expected result as there is too many possible results with
+ bitfields. */
+ if (out == 0x89878583)
+ __builtin_abort ();
+ bfin.inval = (struct ok) { 0x83, 0x85, 0x87, 0x89 };
+ out = partial_read_be32 (bfin);
+ /* Test what bswap would do if its check are not strict enough instead of
+ what is the expected result as there is too many possible results with
+ bitfields. */
+ if (out == 0x83858789)
+ __builtin_abort ();
+ out = fake_read_le32 (cin, &cin[2]);
+ if (out != 0x89018583)
+ __builtin_abort ();
+ cin[2] = 0x87;
+ out = fake_read_be32 (cin, &cin[2]);
+ if (out != 0x83850189)
+ __builtin_abort ();
+ cin[2] = 0x87;
+ out = incorrect_read_le32 (cin, &cin[2]);
+ if (out != 0x89878583)
+ __builtin_abort ();
+ cin[2] = 0x87;
+ out = incorrect_read_be32 (cin, &cin[2]);
+ if (out != 0x83858789)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/built-in-setjmp.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/built-in-setjmp.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/built-in-setjmp.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/built-in-setjmp.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,42 @@
+/* { dg-require-effective-target indirect_jumps } */
+/* { dg-require-effective-target alloca } */
+
+extern int strcmp(const char *, const char *);
+extern char *strcpy(char *, const char *);
+extern void abort(void);
+extern void exit(int);
+
+void *buf[20];
+
+void __attribute__((noinline))
+sub2 (void)
+{
+ __builtin_longjmp (buf, 1);
+}
+
+int
+main ()
+{
+ char *p = (char *) __builtin_alloca (20);
+
+ strcpy (p, "test");
+
+ if (__builtin_setjmp (buf))
+ {
+ if (strcmp (p, "test") != 0)
+ abort ();
+
+ exit (0);
+ }
+
+ {
+ int *q = (int *) __builtin_alloca (p[2] * sizeof (int));
+ int i;
+
+ for (i = 0; i < p[2]; i++)
+ q[i] = 0;
+
+ while (1)
+ sub2 ();
+ }
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-bitops-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-bitops-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-bitops-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-bitops-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,281 @@
+#include <limits.h>
+#include <assert.h>
+
+#if __INT_MAX__ > 2147483647L
+# if __INT_MAX__ >= 9223372036854775807L
+# define BITSIZEOF_INT 64
+# else
+# define BITSIZEOF_INT 32
+# endif
+#else
+# if __INT_MAX__ >= 2147483647L
+# define BITSIZEOF_INT 32
+# else
+# define BITSIZEOF_INT 16
+# endif
+#endif
+
+#if __LONG_MAX__ > 2147483647L
+# if __LONG_MAX__ >= 9223372036854775807L
+# define BITSIZEOF_LONG 64
+# else
+# define BITSIZEOF_LONG 32
+# endif
+#else
+# define BITSIZEOF_LONG 32
+#endif
+
+#if __LONG_LONG_MAX__ > 2147483647L
+# if __LONG_LONG_MAX__ >= 9223372036854775807L
+# define BITSIZEOF_LONG_LONG 64
+# else
+# define BITSIZEOF_LONG_LONG 32
+# endif
+#else
+# define BITSIZEOF_LONG_LONG 32
+#endif
+
+#define MAKE_FUNS(suffix, type) \
+int my_ffs##suffix(type x) { \
+ int i; \
+ if (x == 0) \
+ return 0; \
+ for (i = 0; i < CHAR_BIT * sizeof (type); i++) \
+ if (x & ((type) 1 << i)) \
+ break; \
+ return i + 1; \
+} \
+ \
+int my_ctz##suffix(type x) { \
+ int i; \
+ for (i = 0; i < CHAR_BIT * sizeof (type); i++) \
+ if (x & ((type) 1 << i)) \
+ break; \
+ return i; \
+} \
+ \
+int my_clz##suffix(type x) { \
+ int i; \
+ for (i = 0; i < CHAR_BIT * sizeof (type); i++) \
+ if (x & ((type) 1 << ((CHAR_BIT * sizeof (type)) - i - 1))) \
+ break; \
+ return i; \
+} \
+ \
+int my_clrsb##suffix(type x) { \
+ int i; \
+ int leading = (x >> CHAR_BIT * sizeof (type) - 1) & 1; \
+ for (i = 1; i < CHAR_BIT * sizeof (type); i++) \
+ if (((x >> ((CHAR_BIT * sizeof (type)) - i - 1)) & 1) \
+ != leading) \
+ break; \
+ return i - 1; \
+} \
+ \
+int my_popcount##suffix(type x) { \
+ int i; \
+ int count = 0; \
+ for (i = 0; i < CHAR_BIT * sizeof (type); i++) \
+ if (x & ((type) 1 << i)) \
+ count++; \
+ return count; \
+} \
+ \
+int my_parity##suffix(type x) { \
+ int i; \
+ int count = 0; \
+ for (i = 0; i < CHAR_BIT * sizeof (type); i++) \
+ if (x & ((type) 1 << i)) \
+ count++; \
+ return count & 1; \
+}
+
+MAKE_FUNS (, unsigned);
+MAKE_FUNS (l, unsigned long);
+MAKE_FUNS (ll, unsigned long long);
+
+extern void abort (void);
+extern void exit (int);
+
+#define NUMS16 \
+ { \
+ 0x0000U, \
+ 0x0001U, \
+ 0x8000U, \
+ 0x0002U, \
+ 0x4000U, \
+ 0x0100U, \
+ 0x0080U, \
+ 0xa5a5U, \
+ 0x5a5aU, \
+ 0xcafeU, \
+ 0xffffU \
+ }
+
+#define NUMS32 \
+ { \
+ 0x00000000UL, \
+ 0x00000001UL, \
+ 0x80000000UL, \
+ 0x00000002UL, \
+ 0x40000000UL, \
+ 0x00010000UL, \
+ 0x00008000UL, \
+ 0xa5a5a5a5UL, \
+ 0x5a5a5a5aUL, \
+ 0xcafe0000UL, \
+ 0x00cafe00UL, \
+ 0x0000cafeUL, \
+ 0xffffffffUL \
+ }
+
+#define NUMS64 \
+ { \
+ 0x0000000000000000ULL, \
+ 0x0000000000000001ULL, \
+ 0x8000000000000000ULL, \
+ 0x0000000000000002ULL, \
+ 0x4000000000000000ULL, \
+ 0x0000000100000000ULL, \
+ 0x0000000080000000ULL, \
+ 0xa5a5a5a5a5a5a5a5ULL, \
+ 0x5a5a5a5a5a5a5a5aULL, \
+ 0xcafecafe00000000ULL, \
+ 0x0000cafecafe0000ULL, \
+ 0x00000000cafecafeULL, \
+ 0xffffffffffffffffULL \
+ }
+
+unsigned int ints[] =
+#if BITSIZEOF_INT == 64
+NUMS64;
+#elif BITSIZEOF_INT == 32
+NUMS32;
+#else
+NUMS16;
+#endif
+
+unsigned long longs[] =
+#if BITSIZEOF_LONG == 64
+NUMS64;
+#else
+NUMS32;
+#endif
+
+unsigned long long longlongs[] =
+#if BITSIZEOF_LONG_LONG == 64
+NUMS64;
+#else
+NUMS32;
+#endif
+
+#define N(table) (sizeof (table) / sizeof (table[0]))
+
+int
+main (void)
+{
+ int i;
+
+ for (i = 0; i < N(ints); i++)
+ {
+ if (__builtin_ffs (ints[i]) != my_ffs (ints[i]))
+ abort ();
+ if (ints[i] != 0
+ && __builtin_clz (ints[i]) != my_clz (ints[i]))
+ abort ();
+ if (ints[i] != 0
+ && __builtin_ctz (ints[i]) != my_ctz (ints[i]))
+ abort ();
+ if (__builtin_clrsb (ints[i]) != my_clrsb (ints[i]))
+ abort ();
+ if (__builtin_popcount (ints[i]) != my_popcount (ints[i]))
+ abort ();
+ if (__builtin_parity (ints[i]) != my_parity (ints[i]))
+ abort ();
+ }
+
+ for (i = 0; i < N(longs); i++)
+ {
+ if (__builtin_ffsl (longs[i]) != my_ffsl (longs[i]))
+ abort ();
+ if (longs[i] != 0
+ && __builtin_clzl (longs[i]) != my_clzl (longs[i]))
+ abort ();
+ if (longs[i] != 0
+ && __builtin_ctzl (longs[i]) != my_ctzl (longs[i]))
+ abort ();
+ if (__builtin_clrsbl (longs[i]) != my_clrsbl (longs[i]))
+ abort ();
+ if (__builtin_popcountl (longs[i]) != my_popcountl (longs[i]))
+ abort ();
+ if (__builtin_parityl (longs[i]) != my_parityl (longs[i]))
+ abort ();
+ }
+
+ for (i = 0; i < N(longlongs); i++)
+ {
+ if (__builtin_ffsll (longlongs[i]) != my_ffsll (longlongs[i]))
+ abort ();
+ if (longlongs[i] != 0
+ && __builtin_clzll (longlongs[i]) != my_clzll (longlongs[i]))
+ abort ();
+ if (longlongs[i] != 0
+ && __builtin_ctzll (longlongs[i]) != my_ctzll (longlongs[i]))
+ abort ();
+ if (__builtin_clrsbll (longlongs[i]) != my_clrsbll (longlongs[i]))
+ abort ();
+ if (__builtin_popcountll (longlongs[i]) != my_popcountll (longlongs[i]))
+ abort ();
+ if (__builtin_parityll (longlongs[i]) != my_parityll (longlongs[i]))
+ abort ();
+ }
+
+ /* Test constant folding. */
+
+#define TEST(x, suffix) \
+ if (__builtin_ffs##suffix (x) != my_ffs##suffix (x)) \
+ abort (); \
+ if (x != 0 && __builtin_clz##suffix (x) != my_clz##suffix (x)) \
+ abort (); \
+ if (x != 0 && __builtin_ctz##suffix (x) != my_ctz##suffix (x)) \
+ abort (); \
+ if (__builtin_clrsb##suffix (x) != my_clrsb##suffix (x)) \
+ abort (); \
+ if (__builtin_popcount##suffix (x) != my_popcount##suffix (x)) \
+ abort (); \
+ if (__builtin_parity##suffix (x) != my_parity##suffix (x)) \
+ abort ();
+
+#if BITSIZEOF_INT == 32
+ TEST(0x00000000UL,);
+ TEST(0x00000001UL,);
+ TEST(0x80000000UL,);
+ TEST(0x40000000UL,);
+ TEST(0x00010000UL,);
+ TEST(0x00008000UL,);
+ TEST(0xa5a5a5a5UL,);
+ TEST(0x5a5a5a5aUL,);
+ TEST(0xcafe0000UL,);
+ TEST(0x00cafe00UL,);
+ TEST(0x0000cafeUL,);
+ TEST(0xffffffffUL,);
+#endif
+
+#if BITSIZEOF_LONG_LONG == 64
+ TEST(0x0000000000000000ULL, ll);
+ TEST(0x0000000000000001ULL, ll);
+ TEST(0x8000000000000000ULL, ll);
+ TEST(0x0000000000000002ULL, ll);
+ TEST(0x4000000000000000ULL, ll);
+ TEST(0x0000000100000000ULL, ll);
+ TEST(0x0000000080000000ULL, ll);
+ TEST(0xa5a5a5a5a5a5a5a5ULL, ll);
+ TEST(0x5a5a5a5a5a5a5a5aULL, ll);
+ TEST(0xcafecafe00000000ULL, ll);
+ TEST(0x0000cafecafe0000ULL, ll);
+ TEST(0x00000000cafecafeULL, ll);
+ TEST(0xffffffffffffffffULL, ll);
+#endif
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-constant.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-constant.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-constant.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-constant.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* PR optimization/8423. */
+
+#define btest(x) __builtin_constant_p(x) ? "1" : "0"
+
+#ifdef __OPTIMIZE__
+void
+foo (char *i)
+{
+ if (*i == '0')
+ abort ();
+}
+#else
+void
+foo (char *i)
+{
+}
+#endif
+
+int
+main (void)
+{
+ int size = sizeof (int);
+ foo (btest (size));
+ foo (btest (size));
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,69 @@
+/* Test that __builtin_prefetch does no harm.
+
+ Prefetch using all valid combinations of rw and locality values.
+ These must be compile-time constants. */
+
+#define NO_TEMPORAL_LOCALITY 0
+#define LOW_TEMPORAL_LOCALITY 1
+#define MODERATE_TEMPORAL_LOCALITY 1
+#define HIGH_TEMPORAL_LOCALITY 3
+
+#define WRITE_ACCESS 1
+#define READ_ACCESS 0
+
+enum locality { none, low, moderate, high };
+enum rw { read, write };
+
+int arr[10];
+
+void
+good_const (const int *p)
+{
+ __builtin_prefetch (p, 0, 0);
+ __builtin_prefetch (p, 0, 1);
+ __builtin_prefetch (p, 0, 2);
+ __builtin_prefetch (p, READ_ACCESS, 3);
+ __builtin_prefetch (p, 1, NO_TEMPORAL_LOCALITY);
+ __builtin_prefetch (p, 1, LOW_TEMPORAL_LOCALITY);
+ __builtin_prefetch (p, 1, MODERATE_TEMPORAL_LOCALITY);
+ __builtin_prefetch (p, WRITE_ACCESS, HIGH_TEMPORAL_LOCALITY);
+}
+
+void
+good_enum (const int *p)
+{
+ __builtin_prefetch (p, read, none);
+ __builtin_prefetch (p, read, low);
+ __builtin_prefetch (p, read, moderate);
+ __builtin_prefetch (p, read, high);
+ __builtin_prefetch (p, write, none);
+ __builtin_prefetch (p, write, low);
+ __builtin_prefetch (p, write, moderate);
+ __builtin_prefetch (p, write, high);
+}
+
+void
+good_expr (const int *p)
+{
+ __builtin_prefetch (p, 1 - 1, 6 - (2 * 3));
+ __builtin_prefetch (p, 1 + 0, 1 + 2);
+}
+
+void
+good_vararg (const int *p)
+{
+ __builtin_prefetch (p, 0, 3);
+ __builtin_prefetch (p, 0);
+ __builtin_prefetch (p, 1);
+ __builtin_prefetch (p);
+}
+
+int
+main ()
+{
+ good_const (arr);
+ good_enum (arr);
+ good_expr (arr);
+ good_vararg (arr);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,152 @@
+/* Test that __builtin_prefetch does no harm.
+
+ Prefetch data using a variety of storage classes and address
+ expressions. */
+
+int glob_int_arr[100];
+int *glob_ptr_int = glob_int_arr;
+int glob_int = 4;
+
+static stat_int_arr[100];
+static int *stat_ptr_int = stat_int_arr;
+static int stat_int;
+
+struct S {
+ int a;
+ short b, c;
+ char d[8];
+ struct S *next;
+};
+
+struct S str;
+struct S *ptr_str = &str;
+
+/* Prefetch global variables using the address of the variable. */
+
+void
+simple_global ()
+{
+ __builtin_prefetch (glob_int_arr, 0, 0);
+ __builtin_prefetch (glob_ptr_int, 0, 0);
+ __builtin_prefetch (&glob_int, 0, 0);
+}
+
+/* Prefetch file-level static variables using the address of the variable. */
+
+void
+simple_file ()
+{
+ __builtin_prefetch (stat_int_arr, 0, 0);
+ __builtin_prefetch (stat_ptr_int, 0, 0);
+ __builtin_prefetch (&stat_int, 0, 0);
+}
+
+/* Prefetch local static variables using the address of the variable. */
+
+void
+simple_static_local ()
+{
+ static int gx[100];
+ static int *hx = gx;
+ static int ix;
+ __builtin_prefetch (gx, 0, 0);
+ __builtin_prefetch (hx, 0, 0);
+ __builtin_prefetch (&ix, 0, 0);
+}
+
+/* Prefetch local stack variables using the address of the variable. */
+
+void
+simple_local ()
+{
+ int gx[100];
+ int *hx = gx;
+ int ix;
+ __builtin_prefetch (gx, 0, 0);
+ __builtin_prefetch (hx, 0, 0);
+ __builtin_prefetch (&ix, 0, 0);
+}
+
+/* Prefetch arguments using the address of the variable. */
+
+void
+simple_arg (int g[100], int *h, int i)
+{
+ __builtin_prefetch (g, 0, 0);
+ __builtin_prefetch (h, 0, 0);
+ __builtin_prefetch (&i, 0, 0);
+}
+
+/* Prefetch using address expressions involving global variables. */
+
+void
+expr_global (void)
+{
+ __builtin_prefetch (&str, 0, 0);
+ __builtin_prefetch (ptr_str, 0, 0);
+ __builtin_prefetch (&str.b, 0, 0);
+ __builtin_prefetch (&ptr_str->b, 0, 0);
+ __builtin_prefetch (&str.d, 0, 0);
+ __builtin_prefetch (&ptr_str->d, 0, 0);
+ __builtin_prefetch (str.next, 0, 0);
+ __builtin_prefetch (ptr_str->next, 0, 0);
+ __builtin_prefetch (str.next->d, 0, 0);
+ __builtin_prefetch (ptr_str->next->d, 0, 0);
+
+ __builtin_prefetch (&glob_int_arr, 0, 0);
+ __builtin_prefetch (glob_ptr_int, 0, 0);
+ __builtin_prefetch (&glob_int_arr[2], 0, 0);
+ __builtin_prefetch (&glob_ptr_int[3], 0, 0);
+ __builtin_prefetch (glob_int_arr+3, 0, 0);
+ __builtin_prefetch (glob_int_arr+glob_int, 0, 0);
+ __builtin_prefetch (glob_ptr_int+5, 0, 0);
+ __builtin_prefetch (glob_ptr_int+glob_int, 0, 0);
+}
+
+/* Prefetch using address expressions involving local variables. */
+
+void
+expr_local (void)
+{
+ int b[10];
+ int *pb = b;
+ struct S t;
+ struct S *pt = &t;
+ int j = 4;
+
+ __builtin_prefetch (&t, 0, 0);
+ __builtin_prefetch (pt, 0, 0);
+ __builtin_prefetch (&t.b, 0, 0);
+ __builtin_prefetch (&pt->b, 0, 0);
+ __builtin_prefetch (&t.d, 0, 0);
+ __builtin_prefetch (&pt->d, 0, 0);
+ __builtin_prefetch (t.next, 0, 0);
+ __builtin_prefetch (pt->next, 0, 0);
+ __builtin_prefetch (t.next->d, 0, 0);
+ __builtin_prefetch (pt->next->d, 0, 0);
+
+ __builtin_prefetch (&b, 0, 0);
+ __builtin_prefetch (pb, 0, 0);
+ __builtin_prefetch (&b[2], 0, 0);
+ __builtin_prefetch (&pb[3], 0, 0);
+ __builtin_prefetch (b+3, 0, 0);
+ __builtin_prefetch (b+j, 0, 0);
+ __builtin_prefetch (pb+5, 0, 0);
+ __builtin_prefetch (pb+j, 0, 0);
+}
+
+int
+main ()
+{
+ simple_global ();
+ simple_file ();
+ simple_static_local ();
+ simple_local ();
+ simple_arg (glob_int_arr, glob_ptr_int, glob_int);
+
+ str.next = &str;
+ expr_global ();
+ expr_local ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,113 @@
+/* Test that __builtin_prefetch does no harm.
+
+ Prefetch data using a variety of storage classes and address
+ expressions with volatile variables and pointers. */
+
+int glob_int_arr[100];
+int glob_int = 4;
+volatile int glob_vol_int_arr[100];
+int * volatile glob_vol_ptr_int = glob_int_arr;
+volatile int *glob_ptr_vol_int = glob_vol_int_arr;
+volatile int * volatile glob_vol_ptr_vol_int = glob_vol_int_arr;
+volatile int glob_vol_int;
+
+static stat_int_arr[100];
+static volatile int stat_vol_int_arr[100];
+static int * volatile stat_vol_ptr_int = stat_int_arr;
+static volatile int *stat_ptr_vol_int = stat_vol_int_arr;
+static volatile int * volatile stat_vol_ptr_vol_int = stat_vol_int_arr;
+static volatile int stat_vol_int;
+
+struct S {
+ int a;
+ short b, c;
+ char d[8];
+ struct S *next;
+};
+
+struct S str;
+volatile struct S vol_str;
+struct S * volatile vol_ptr_str = &str;
+volatile struct S *ptr_vol_str = &vol_str;
+volatile struct S * volatile vol_ptr_vol_str = &vol_str;
+
+/* Prefetch volatile global variables using the address of the variable. */
+
+void
+simple_vol_global ()
+{
+ __builtin_prefetch (glob_vol_int_arr, 0, 0);
+ __builtin_prefetch (glob_vol_ptr_int, 0, 0);
+ __builtin_prefetch (glob_ptr_vol_int, 0, 0);
+ __builtin_prefetch (glob_vol_ptr_vol_int, 0, 0);
+ __builtin_prefetch (&glob_vol_int, 0, 0);
+}
+
+/* Prefetch volatile static variables using the address of the variable. */
+
+void
+simple_vol_file ()
+{
+ __builtin_prefetch (stat_vol_int_arr, 0, 0);
+ __builtin_prefetch (stat_vol_ptr_int, 0, 0);
+ __builtin_prefetch (stat_ptr_vol_int, 0, 0);
+ __builtin_prefetch (stat_vol_ptr_vol_int, 0, 0);
+ __builtin_prefetch (&stat_vol_int, 0, 0);
+}
+
+/* Prefetch using address expressions involving volatile global variables. */
+
+void
+expr_vol_global (void)
+{
+ __builtin_prefetch (&vol_str, 0, 0);
+ __builtin_prefetch (ptr_vol_str, 0, 0);
+ __builtin_prefetch (vol_ptr_str, 0, 0);
+ __builtin_prefetch (vol_ptr_vol_str, 0, 0);
+ __builtin_prefetch (&vol_str.b, 0, 0);
+ __builtin_prefetch (&ptr_vol_str->b, 0, 0);
+ __builtin_prefetch (&vol_ptr_str->b, 0, 0);
+ __builtin_prefetch (&vol_ptr_vol_str->b, 0, 0);
+ __builtin_prefetch (&vol_str.d, 0, 0);
+ __builtin_prefetch (&vol_ptr_str->d, 0, 0);
+ __builtin_prefetch (&ptr_vol_str->d, 0, 0);
+ __builtin_prefetch (&vol_ptr_vol_str->d, 0, 0);
+ __builtin_prefetch (vol_str.next, 0, 0);
+ __builtin_prefetch (vol_ptr_str->next, 0, 0);
+ __builtin_prefetch (ptr_vol_str->next, 0, 0);
+ __builtin_prefetch (vol_ptr_vol_str->next, 0, 0);
+ __builtin_prefetch (vol_str.next->d, 0, 0);
+ __builtin_prefetch (vol_ptr_str->next->d, 0, 0);
+ __builtin_prefetch (ptr_vol_str->next->d, 0, 0);
+ __builtin_prefetch (vol_ptr_vol_str->next->d, 0, 0);
+
+ __builtin_prefetch (&glob_vol_int_arr, 0, 0);
+ __builtin_prefetch (glob_vol_ptr_int, 0, 0);
+ __builtin_prefetch (glob_ptr_vol_int, 0, 0);
+ __builtin_prefetch (glob_vol_ptr_vol_int, 0, 0);
+ __builtin_prefetch (&glob_vol_int_arr[2], 0, 0);
+ __builtin_prefetch (&glob_vol_ptr_int[3], 0, 0);
+ __builtin_prefetch (&glob_ptr_vol_int[3], 0, 0);
+ __builtin_prefetch (&glob_vol_ptr_vol_int[3], 0, 0);
+ __builtin_prefetch (glob_vol_int_arr+3, 0, 0);
+ __builtin_prefetch (glob_vol_int_arr+glob_vol_int, 0, 0);
+ __builtin_prefetch (glob_vol_ptr_int+5, 0, 0);
+ __builtin_prefetch (glob_ptr_vol_int+5, 0, 0);
+ __builtin_prefetch (glob_vol_ptr_vol_int+5, 0, 0);
+ __builtin_prefetch (glob_vol_ptr_int+glob_vol_int, 0, 0);
+ __builtin_prefetch (glob_ptr_vol_int+glob_vol_int, 0, 0);
+ __builtin_prefetch (glob_vol_ptr_vol_int+glob_vol_int, 0, 0);
+}
+
+int
+main ()
+{
+ simple_vol_global ();
+ simple_vol_file ();
+
+ str.next = &str;
+ vol_str.next = &str;
+ expr_vol_global ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,271 @@
+/* Test that __builtin_prefetch does no harm.
+
+ Check that the expression containing the address to prefetch is
+ evaluated if it has side effects, even if the target does not support
+ data prefetch. Check changes to pointers and to array indices that are
+ either global variables or arguments. */
+
+#define ARRSIZE 100
+
+int arr[ARRSIZE];
+int *ptr = &arr[20];
+int arrindex = 4;
+
+/* Check that assignment within a prefetch argument is evaluated. */
+
+int
+assign_arg_ptr (int *p)
+{
+ int *q;
+ __builtin_prefetch ((q = p), 0, 0);
+ return q == p;
+}
+
+int
+assign_glob_ptr (void)
+{
+ int *q;
+ __builtin_prefetch ((q = ptr), 0, 0);
+ return q == ptr;
+}
+
+int
+assign_arg_idx (int *p, int i)
+{
+ int j;
+ __builtin_prefetch (&p[j = i], 0, 0);
+ return j == i;
+}
+
+int
+assign_glob_idx (void)
+{
+ int j;
+ __builtin_prefetch (&ptr[j = arrindex], 0, 0);
+ return j == arrindex;
+}
+
+/* Check that pre/post increment/decrement within a prefetch argument are
+ evaluated. */
+
+int
+preinc_arg_ptr (int *p)
+{
+ int *q;
+ q = p + 1;
+ __builtin_prefetch (++p, 0, 0);
+ return p == q;
+}
+
+int
+preinc_glob_ptr (void)
+{
+ int *q;
+ q = ptr + 1;
+ __builtin_prefetch (++ptr, 0, 0);
+ return ptr == q;
+}
+
+int
+postinc_arg_ptr (int *p)
+{
+ int *q;
+ q = p + 1;
+ __builtin_prefetch (p++, 0, 0);
+ return p == q;
+}
+
+int
+postinc_glob_ptr (void)
+{
+ int *q;
+ q = ptr + 1;
+ __builtin_prefetch (ptr++, 0, 0);
+ return ptr == q;
+}
+
+int
+predec_arg_ptr (int *p)
+{
+ int *q;
+ q = p - 1;
+ __builtin_prefetch (--p, 0, 0);
+ return p == q;
+}
+
+int
+predec_glob_ptr (void)
+{
+ int *q;
+ q = ptr - 1;
+ __builtin_prefetch (--ptr, 0, 0);
+ return ptr == q;
+}
+
+int
+postdec_arg_ptr (int *p)
+{
+ int *q;
+ q = p - 1;
+ __builtin_prefetch (p--, 0, 0);
+ return p == q;
+}
+
+int
+postdec_glob_ptr (void)
+{
+ int *q;
+ q = ptr - 1;
+ __builtin_prefetch (ptr--, 0, 0);
+ return ptr == q;
+}
+
+int
+preinc_arg_idx (int *p, int i)
+{
+ int j = i + 1;
+ __builtin_prefetch (&p[++i], 0, 0);
+ return i == j;
+}
+
+
+int
+preinc_glob_idx (void)
+{
+ int j = arrindex + 1;
+ __builtin_prefetch (&ptr[++arrindex], 0, 0);
+ return arrindex == j;
+}
+
+int
+postinc_arg_idx (int *p, int i)
+{
+ int j = i + 1;
+ __builtin_prefetch (&p[i++], 0, 0);
+ return i == j;
+}
+
+int
+postinc_glob_idx (void)
+{
+ int j = arrindex + 1;
+ __builtin_prefetch (&ptr[arrindex++], 0, 0);
+ return arrindex == j;
+}
+
+int
+predec_arg_idx (int *p, int i)
+{
+ int j = i - 1;
+ __builtin_prefetch (&p[--i], 0, 0);
+ return i == j;
+}
+
+int
+predec_glob_idx (void)
+{
+ int j = arrindex - 1;
+ __builtin_prefetch (&ptr[--arrindex], 0, 0);
+ return arrindex == j;
+}
+
+int
+postdec_arg_idx (int *p, int i)
+{
+ int j = i - 1;
+ __builtin_prefetch (&p[i--], 0, 0);
+ return i == j;
+}
+
+int
+postdec_glob_idx (void)
+{
+ int j = arrindex - 1;
+ __builtin_prefetch (&ptr[arrindex--], 0, 0);
+ return arrindex == j;
+}
+
+/* Check that function calls within the first prefetch argument are
+ evaluated. */
+
+int getptrcnt = 0;
+
+int *
+getptr (int *p)
+{
+ getptrcnt++;
+ return p + 1;
+}
+
+int
+funccall_arg_ptr (int *p)
+{
+ __builtin_prefetch (getptr (p), 0, 0);
+ return getptrcnt == 1;
+}
+
+int getintcnt = 0;
+
+int
+getint (int i)
+{
+ getintcnt++;
+ return i + 1;
+}
+
+int
+funccall_arg_idx (int *p, int i)
+{
+ __builtin_prefetch (&p[getint (i)], 0, 0);
+ return getintcnt == 1;
+}
+
+int
+main ()
+{
+ if (!assign_arg_ptr (ptr))
+ abort ();
+ if (!assign_glob_ptr ())
+ abort ();
+ if (!assign_arg_idx (ptr, 4))
+ abort ();
+ if (!assign_glob_idx ())
+ abort ();
+ if (!preinc_arg_ptr (ptr))
+ abort ();
+ if (!preinc_glob_ptr ())
+ abort ();
+ if (!postinc_arg_ptr (ptr))
+ abort ();
+ if (!postinc_glob_ptr ())
+ abort ();
+ if (!predec_arg_ptr (ptr))
+ abort ();
+ if (!predec_glob_ptr ())
+ abort ();
+ if (!postdec_arg_ptr (ptr))
+ abort ();
+ if (!postdec_glob_ptr ())
+ abort ();
+ if (!preinc_arg_idx (ptr, 3))
+ abort ();
+ if (!preinc_glob_idx ())
+ abort ();
+ if (!postinc_arg_idx (ptr, 3))
+ abort ();
+ if (!postinc_glob_idx ())
+ abort ();
+ if (!predec_arg_idx (ptr, 3))
+ abort ();
+ if (!predec_glob_idx ())
+ abort ();
+ if (!postdec_arg_idx (ptr, 3))
+ abort ();
+ if (!postdec_glob_idx ())
+ abort ();
+ if (!funccall_arg_ptr (ptr))
+ abort ();
+ if (!funccall_arg_idx (ptr, 3))
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,60 @@
+/* Test that __builtin_prefetch does no harm.
+
+ Use addresses that are unlikely to be word-aligned. Some targets
+ have alignment requirements for prefetch addresses, so make sure the
+ compiler takes care of that. This fails if it aborts, anything else
+ is OK. */
+
+struct S {
+ short a;
+ short b;
+ char c[8];
+} s;
+
+char arr[100];
+char *ptr = arr;
+int idx = 3;
+
+void
+arg_ptr (char *p)
+{
+ __builtin_prefetch (p, 0, 0);
+}
+
+void
+arg_idx (char *p, int i)
+{
+ __builtin_prefetch (&p[i], 0, 0);
+}
+
+void
+glob_ptr (void)
+{
+ __builtin_prefetch (ptr, 0, 0);
+}
+
+void
+glob_idx (void)
+{
+ __builtin_prefetch (&ptr[idx], 0, 0);
+}
+
+int
+main ()
+{
+ __builtin_prefetch (&s.b, 0, 0);
+ __builtin_prefetch (&s.c[1], 0, 0);
+
+ arg_ptr (&s.c[1]);
+ arg_ptr (ptr+3);
+ arg_idx (ptr, 3);
+ arg_idx (ptr+1, 2);
+ idx = 3;
+ glob_ptr ();
+ glob_idx ();
+ ptr++;
+ idx = 2;
+ glob_ptr ();
+ glob_idx ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-6.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-6.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-6.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-prefetch-6.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,46 @@
+/* Test that __builtin_prefetch does no harm.
+
+ Data prefetch should not fault if used with an invalid address. */
+
+#include <limits.h>
+
+#define ARRSIZE 65
+int *bad_addr[ARRSIZE];
+int arr_used;
+
+/* Fill bad_addr with a range of values in the hopes that on any target
+ some will be invalid addresses. */
+void
+init_addrs (void)
+{
+ int i;
+ int bits_per_ptr = sizeof (void *) * 8;
+ for (i = 0; i < bits_per_ptr; i++)
+ bad_addr[i] = (void *)(1UL << i);
+ arr_used = bits_per_ptr + 1; /* The last element used is zero. */
+}
+
+void
+prefetch_for_read (void)
+{
+ int i;
+ for (i = 0; i < ARRSIZE; i++)
+ __builtin_prefetch (bad_addr[i], 0, 0);
+}
+
+void
+prefetch_for_write (void)
+{
+ int i;
+ for (i = 0; i < ARRSIZE; i++)
+ __builtin_prefetch (bad_addr[i], 1, 0);
+}
+
+int
+main ()
+{
+ init_addrs ();
+ prefetch_for_read ();
+ prefetch_for_write ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-types-compatible-p.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-types-compatible-p.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-types-compatible-p.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtin-types-compatible-p.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+int i;
+double d;
+
+/* Make sure we return a constant. */
+float rootbeer[__builtin_types_compatible_p (int, typeof(i))];
+
+typedef enum { hot, dog, poo, bear } dingos;
+typedef enum { janette, laura, amanda } cranberry;
+
+typedef float same1;
+typedef float same2;
+
+int main (void);
+
+int main (void)
+{
+ /* Compatible types. */
+ if (!(__builtin_types_compatible_p (int, const int)
+ && __builtin_types_compatible_p (typeof (hot), int)
+ && __builtin_types_compatible_p (typeof (hot), typeof (laura))
+ && __builtin_types_compatible_p (int[5], int[])
+ && __builtin_types_compatible_p (same1, same2)))
+ abort ();
+
+ /* Incompatible types. */
+ if (__builtin_types_compatible_p (char *, int)
+ || __builtin_types_compatible_p (char *, const char *)
+ || __builtin_types_compatible_p (long double, double)
+ || __builtin_types_compatible_p (typeof (i), typeof (d))
+ || __builtin_types_compatible_p (typeof (dingos), typeof (cranberry))
+ || __builtin_types_compatible_p (char, int)
+ || __builtin_types_compatible_p (char *, char **))
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,50 @@
+/* Verify that structure return doesn't invoke memcpy on
+ overlapping objects. */
+
+extern void abort (void);
+extern int inside_main;
+typedef __SIZE_TYPE__ size_t;
+
+struct S {
+ char stuff[1024];
+};
+
+union U {
+ struct {
+ int space;
+ struct S s;
+ } a;
+ struct {
+ struct S s;
+ int space;
+ } b;
+};
+
+struct S f(struct S *p)
+{
+ return *p;
+}
+
+void g(union U *p)
+{
+}
+
+void *memcpy(void *a, const void *b, size_t len)
+{
+ if (inside_main)
+ {
+ if (a < b && a+len > b)
+ abort ();
+ if (b < a && b+len > a)
+ abort ();
+ return a;
+ }
+ else
+ {
+ char *dst = (char *) a;
+ const char *src = (const char *) b;
+ while (len--)
+ *dst++ = *src++;
+ return a;
+ }
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* Verify that structure return doesn't invoke memcpy on
+ overlapping objects. */
+
+extern void abort (void);
+
+struct S {
+ char stuff[1024];
+};
+
+union U {
+ struct {
+ int space;
+ struct S s;
+ } a;
+ struct {
+ struct S s;
+ int space;
+ } b;
+};
+
+struct S f(struct S *);
+void g(union U *);
+
+void main_test(void)
+{
+ union U u;
+ u.b.s = f(&u.a.s);
+ u.a.s = f(&u.b.s);
+ g(&u);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/20010124-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,10 @@
+load_lib target-supports.exp
+
+if [istarget "nvptx-*-*"] {
+ # This test uses memcpy for block move in the same file as it
+ # defines it. The two decls are not the same, by design, and we
+ # end up emitting a definition of memcpy, along with a .extern
+ # declaration. This confuses the ptx assembler.
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+extern void abort (void);
+extern int abs_called;
+extern int inside_main;
+
+/* The labs call should have been optimized, but the abs call
+ shouldn't have been. */
+
+int
+abs (int x)
+{
+ if (inside_main)
+ abs_called = 1;
+ return (x < 0 ? -x : x);
+}
+
+long
+labs (long x)
+{
+ if (inside_main)
+ abort ();
+ return (x < 0 ? -x : x);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* Test for -fno-builtin-FUNCTION. */
+/* Origin: Joseph Myers <jsm28 at cam.ac.uk>. */
+/* GCC normally handles abs and labs as built-in functions even without
+ optimization. So test that with -fno-builtin-abs, labs is so handled
+ but abs isn't. */
+
+int abs_called = 0;
+
+extern int abs (int);
+extern long labs (long);
+extern void abort (void);
+
+void
+main_test (void)
+{
+ if (labs (0) != 0)
+ abort ();
+ if (abs (0) != 0)
+ abort ();
+ if (!abs_called)
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,2 @@
+set additional_flags -fno-builtin-abs
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-2-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-2-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-2-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-2-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/abs.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,106 @@
+/* Test for builtin abs, labs, llabs, imaxabs. */
+/* Origin: Joseph Myers <jsm28 at cam.ac.uk> */
+
+#include <limits.h>
+typedef __INTMAX_TYPE__ intmax_t;
+#define INTMAX_MAX __INTMAX_MAX__
+
+extern int abs (int);
+extern long labs (long);
+extern long long llabs (long long);
+extern intmax_t imaxabs (intmax_t);
+extern void abort (void);
+extern void link_error (void);
+
+void
+main_test (void)
+{
+ /* For each type, test both runtime and compile time (constant folding)
+ optimization. */
+ volatile int i0 = 0, i1 = 1, im1 = -1, imin = -INT_MAX, imax = INT_MAX;
+ volatile long l0 = 0L, l1 = 1L, lm1 = -1L, lmin = -LONG_MAX, lmax = LONG_MAX;
+ volatile long long ll0 = 0LL, ll1 = 1LL, llm1 = -1LL;
+ volatile long long llmin = -__LONG_LONG_MAX__, llmax = __LONG_LONG_MAX__;
+ volatile intmax_t imax0 = 0, imax1 = 1, imaxm1 = -1;
+ volatile intmax_t imaxmin = -INTMAX_MAX, imaxmax = INTMAX_MAX;
+ if (abs (i0) != 0)
+ abort ();
+ if (abs (0) != 0)
+ link_error ();
+ if (abs (i1) != 1)
+ abort ();
+ if (abs (1) != 1)
+ link_error ();
+ if (abs (im1) != 1)
+ abort ();
+ if (abs (-1) != 1)
+ link_error ();
+ if (abs (imin) != INT_MAX)
+ abort ();
+ if (abs (-INT_MAX) != INT_MAX)
+ link_error ();
+ if (abs (imax) != INT_MAX)
+ abort ();
+ if (abs (INT_MAX) != INT_MAX)
+ link_error ();
+ if (labs (l0) != 0L)
+ abort ();
+ if (labs (0L) != 0L)
+ link_error ();
+ if (labs (l1) != 1L)
+ abort ();
+ if (labs (1L) != 1L)
+ link_error ();
+ if (labs (lm1) != 1L)
+ abort ();
+ if (labs (-1L) != 1L)
+ link_error ();
+ if (labs (lmin) != LONG_MAX)
+ abort ();
+ if (labs (-LONG_MAX) != LONG_MAX)
+ link_error ();
+ if (labs (lmax) != LONG_MAX)
+ abort ();
+ if (labs (LONG_MAX) != LONG_MAX)
+ link_error ();
+ if (llabs (ll0) != 0LL)
+ abort ();
+ if (llabs (0LL) != 0LL)
+ link_error ();
+ if (llabs (ll1) != 1LL)
+ abort ();
+ if (llabs (1LL) != 1LL)
+ link_error ();
+ if (llabs (llm1) != 1LL)
+ abort ();
+ if (llabs (-1LL) != 1LL)
+ link_error ();
+ if (llabs (llmin) != __LONG_LONG_MAX__)
+ abort ();
+ if (llabs (-__LONG_LONG_MAX__) != __LONG_LONG_MAX__)
+ link_error ();
+ if (llabs (llmax) != __LONG_LONG_MAX__)
+ abort ();
+ if (llabs (__LONG_LONG_MAX__) != __LONG_LONG_MAX__)
+ link_error ();
+ if (imaxabs (imax0) != 0)
+ abort ();
+ if (imaxabs (0) != 0)
+ link_error ();
+ if (imaxabs (imax1) != 1)
+ abort ();
+ if (imaxabs (1) != 1)
+ link_error ();
+ if (imaxabs (imaxm1) != 1)
+ abort ();
+ if (imaxabs (-1) != 1)
+ link_error ();
+ if (imaxabs (imaxmin) != INTMAX_MAX)
+ abort ();
+ if (imaxabs (-INTMAX_MAX) != INTMAX_MAX)
+ link_error ();
+ if (imaxabs (imaxmax) != INTMAX_MAX)
+ abort ();
+ if (imaxabs (INTMAX_MAX) != INTMAX_MAX)
+ link_error ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-3-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-3-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-3-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-3-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/abs.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/abs-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,102 @@
+/* Test for builtin abs, labs, llabs, imaxabs. Test for __builtin versions. */
+/* Origin: Joseph Myers <jsm28 at cam.ac.uk> */
+
+#include <limits.h>
+typedef __INTMAX_TYPE__ intmax_t;
+#define INTMAX_MAX __INTMAX_MAX__
+
+extern void abort (void);
+extern void link_error (void);
+
+void
+main_test (void)
+{
+ /* For each type, test both runtime and compile time (constant folding)
+ optimization. */
+ volatile int i0 = 0, i1 = 1, im1 = -1, imin = -INT_MAX, imax = INT_MAX;
+ volatile long l0 = 0L, l1 = 1L, lm1 = -1L, lmin = -LONG_MAX, lmax = LONG_MAX;
+ volatile long long ll0 = 0LL, ll1 = 1LL, llm1 = -1LL;
+ volatile long long llmin = -__LONG_LONG_MAX__, llmax = __LONG_LONG_MAX__;
+ volatile intmax_t imax0 = 0, imax1 = 1, imaxm1 = -1;
+ volatile intmax_t imaxmin = -INTMAX_MAX, imaxmax = INTMAX_MAX;
+ if (__builtin_abs (i0) != 0)
+ abort ();
+ if (__builtin_abs (0) != 0)
+ link_error ();
+ if (__builtin_abs (i1) != 1)
+ abort ();
+ if (__builtin_abs (1) != 1)
+ link_error ();
+ if (__builtin_abs (im1) != 1)
+ abort ();
+ if (__builtin_abs (-1) != 1)
+ link_error ();
+ if (__builtin_abs (imin) != INT_MAX)
+ abort ();
+ if (__builtin_abs (-INT_MAX) != INT_MAX)
+ link_error ();
+ if (__builtin_abs (imax) != INT_MAX)
+ abort ();
+ if (__builtin_abs (INT_MAX) != INT_MAX)
+ link_error ();
+ if (__builtin_labs (l0) != 0L)
+ abort ();
+ if (__builtin_labs (0L) != 0L)
+ link_error ();
+ if (__builtin_labs (l1) != 1L)
+ abort ();
+ if (__builtin_labs (1L) != 1L)
+ link_error ();
+ if (__builtin_labs (lm1) != 1L)
+ abort ();
+ if (__builtin_labs (-1L) != 1L)
+ link_error ();
+ if (__builtin_labs (lmin) != LONG_MAX)
+ abort ();
+ if (__builtin_labs (-LONG_MAX) != LONG_MAX)
+ link_error ();
+ if (__builtin_labs (lmax) != LONG_MAX)
+ abort ();
+ if (__builtin_labs (LONG_MAX) != LONG_MAX)
+ link_error ();
+ if (__builtin_llabs (ll0) != 0LL)
+ abort ();
+ if (__builtin_llabs (0LL) != 0LL)
+ link_error ();
+ if (__builtin_llabs (ll1) != 1LL)
+ abort ();
+ if (__builtin_llabs (1LL) != 1LL)
+ link_error ();
+ if (__builtin_llabs (llm1) != 1LL)
+ abort ();
+ if (__builtin_llabs (-1LL) != 1LL)
+ link_error ();
+ if (__builtin_llabs (llmin) != __LONG_LONG_MAX__)
+ abort ();
+ if (__builtin_llabs (-__LONG_LONG_MAX__) != __LONG_LONG_MAX__)
+ link_error ();
+ if (__builtin_llabs (llmax) != __LONG_LONG_MAX__)
+ abort ();
+ if (__builtin_llabs (__LONG_LONG_MAX__) != __LONG_LONG_MAX__)
+ link_error ();
+ if (__builtin_imaxabs (imax0) != 0)
+ abort ();
+ if (__builtin_imaxabs (0) != 0)
+ link_error ();
+ if (__builtin_imaxabs (imax1) != 1)
+ abort ();
+ if (__builtin_imaxabs (1) != 1)
+ link_error ();
+ if (__builtin_imaxabs (imaxm1) != 1)
+ abort ();
+ if (__builtin_imaxabs (-1) != 1)
+ link_error ();
+ if (__builtin_imaxabs (imaxmin) != INTMAX_MAX)
+ abort ();
+ if (__builtin_imaxabs (-INTMAX_MAX) != INTMAX_MAX)
+ link_error ();
+ if (__builtin_imaxabs (imaxmax) != INTMAX_MAX)
+ abort ();
+ if (__builtin_imaxabs (INTMAX_MAX) != INTMAX_MAX)
+ link_error ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/builtins.exp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/builtins.exp?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/builtins.exp (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/builtins.exp Wed Oct 9 04:01:46 2019
@@ -0,0 +1,60 @@
+# Copyright (C) 2003-2019 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This harness is for testing builtin support. Each test has two files:
+#
+# - foo.c defines the main testing function, main_test().
+# - foo-lib.c implements the library functions that foo.c is testing.
+#
+# The functions in foo-lib.c will often want to abort on certain inputs.
+# They can use the global variable inside_main to see whether they are
+# being called from the test program or part of the common runtime.
+#
+# In many cases, the library functions will behave as normal at -O0
+# and abort when optimisation is enabled. Such implementations should
+# go into the lib/ directory so that they can be included by any test
+# that needs them. They shouldn't call any external functions in case
+# those functions were overridden too.
+
+load_lib torture-options.exp
+load_lib c-torture.exp
+
+torture-init
+set-torture-options $C_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS
+
+set additional_flags "-fno-tree-dse -fno-tree-loop-distribute-patterns -fno-tracer -fno-ipa-ra"
+if [istarget "powerpc-*-darwin*"] {
+ lappend additional_flags "-Wl,-multiply_defined,suppress"
+}
+if { [istarget *-*-eabi*]
+ || [istarget *-*-elf]
+ || [istarget *-*-mingw*]
+ || [istarget *-*-rtems*] } {
+ lappend additional_flags "-Wl,--allow-multiple-definition"
+}
+
+foreach src [lsort [find $srcdir/$subdir *.c]] {
+ if {![string match *-lib.c $src] && [runtest_file_p $runtests $src]} {
+ c-torture-execute [list $src \
+ [file root $src]-lib.c \
+ $srcdir/$subdir/lib/main.c] \
+ $additional_flags
+ }
+}
+
+torture-finish
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/chk.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/chk.h?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/chk.h (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/chk.h Wed Oct 9 04:01:46 2019
@@ -0,0 +1,92 @@
+#ifndef os
+# define os(ptr) __builtin_object_size (ptr, 0)
+#endif
+
+/* This is one of the alternatives for object size checking.
+ If dst has side-effects, size checking will never be done. */
+#undef memcpy
+#define memcpy(dst, src, len) \
+ __builtin___memcpy_chk (dst, src, len, os (dst))
+#undef mempcpy
+#define mempcpy(dst, src, len) \
+ __builtin___mempcpy_chk (dst, src, len, os (dst))
+#undef memmove
+#define memmove(dst, src, len) \
+ __builtin___memmove_chk (dst, src, len, os (dst))
+#undef memset
+#define memset(dst, val, len) \
+ __builtin___memset_chk (dst, val, len, os (dst))
+#undef strcpy
+#define strcpy(dst, src) \
+ __builtin___strcpy_chk (dst, src, os (dst))
+#undef stpcpy
+#define stpcpy(dst, src) \
+ __builtin___stpcpy_chk (dst, src, os (dst))
+#undef strcat
+#define strcat(dst, src) \
+ __builtin___strcat_chk (dst, src, os (dst))
+#undef strncpy
+#define strncpy(dst, src, len) \
+ __builtin___strncpy_chk (dst, src, len, os (dst))
+#undef stpncpy
+#define stpncpy(dst, src, len) \
+ __builtin___stpncpy_chk (dst, src, len, os (dst))
+#undef strncat
+#define strncat(dst, src, len) \
+ __builtin___strncat_chk (dst, src, len, os (dst))
+#undef sprintf
+#define sprintf(dst, ...) \
+ __builtin___sprintf_chk (dst, 0, os (dst), __VA_ARGS__)
+#undef vsprintf
+#define vsprintf(dst, fmt, ap) \
+ __builtin___vsprintf_chk (dst, 0, os (dst), fmt, ap)
+#undef snprintf
+#define snprintf(dst, len, ...) \
+ __builtin___snprintf_chk (dst, len, 0, os (dst), __VA_ARGS__)
+#undef vsnprintf
+#define vsnprintf(dst, len, fmt, ap) \
+ __builtin___vsnprintf_chk (dst, len, 0, os (dst), fmt, ap)
+
+/* Now "redefine" even builtins for the purpose of testing. */
+#undef __builtin_memcpy
+#define __builtin_memcpy(dst, src, len) memcpy (dst, src, len)
+#undef __builtin_mempcpy
+#define __builtin_mempcpy(dst, src, len) mempcpy (dst, src, len)
+#undef __builtin_memmove
+#define __builtin_memmove(dst, src, len) memmove (dst, src, len)
+#undef __builtin_memset
+#define __builtin_memset(dst, val, len) memset (dst, val, len)
+#undef __builtin_strcpy
+#define __builtin_strcpy(dst, src) strcpy (dst, src)
+#undef __builtin_stpcpy
+#define __builtin_stpcpy(dst, src) stpcpy (dst, src)
+#undef __builtin_strcat
+#define __builtin_strcat(dst, src) strcat (dst, src)
+#undef __builtin_strncpy
+#define __builtin_strncpy(dst, src, len) strncpy (dst, src, len)
+#undef __builtin_strncat
+#define __builtin_strncat(dst, src, len) strncat (dst, src, len)
+#undef __builtin_sprintf
+#define __builtin_sprintf(dst, ...) sprintf (dst, __VA_ARGS__)
+#undef __builtin_vsprintf
+#define __builtin_vsprintf(dst, fmt, ap) vsprintf (dst, fmt, ap)
+#undef __builtin_snprintf
+#define __builtin_snprintf(dst, len, ...) snprintf (dst, len, __VA_ARGS__)
+#undef __builtin_vsnprintf
+#define __builtin_vsnprintf(dst, len, fmt, ap) vsnprintf (dst, len, fmt, ap)
+
+extern void *chk_fail_buf[];
+extern volatile int chk_fail_allowed, chk_calls;
+extern volatile int memcpy_disallowed, mempcpy_disallowed, memmove_disallowed;
+extern volatile int memset_disallowed, strcpy_disallowed, stpcpy_disallowed;
+extern volatile int strncpy_disallowed, stpncpy_disallowed, strcat_disallowed;
+extern volatile int strncat_disallowed, sprintf_disallowed, vsprintf_disallowed;
+extern volatile int snprintf_disallowed, vsnprintf_disallowed;
+
+/* A storage class that ensures that declarations bind locally. We want
+ to test non-static declarations where we know it is safe to do so. */
+#if __PIC__ && !__PIE__
+#define LOCAL static
+#else
+#define LOCAL
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/complex-1-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/complex-1-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/complex-1-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/complex-1-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,70 @@
+extern int inside_main;
+extern void abort (void);
+#ifdef __OPTIMIZE__
+#define ABORT_INSIDE_MAIN do { if (inside_main) abort (); } while (0)
+#else
+#define ABORT_INSIDE_MAIN do { } while (0)
+#endif
+
+static float _Complex
+conjf (float _Complex z)
+{
+ ABORT_INSIDE_MAIN;
+ return ~z;
+}
+
+static double _Complex
+conj (double _Complex z)
+{
+ ABORT_INSIDE_MAIN;
+ return ~z;
+}
+
+static long double _Complex
+conjl (long double _Complex z)
+{
+ ABORT_INSIDE_MAIN;
+ return ~z;
+}
+
+static float
+crealf (float _Complex z)
+{
+ ABORT_INSIDE_MAIN;
+ return __real__ z;
+}
+
+static double
+creal (double _Complex z)
+{
+ ABORT_INSIDE_MAIN;
+ return __real__ z;
+}
+
+static long double
+creall (long double _Complex z)
+{
+ ABORT_INSIDE_MAIN;
+ return __real__ z;
+}
+
+static float
+cimagf (float _Complex z)
+{
+ ABORT_INSIDE_MAIN;
+ return __imag__ z;
+}
+
+static double
+cimag (double _Complex z)
+{
+ ABORT_INSIDE_MAIN;
+ return __imag__ z;
+}
+
+static long double
+cimagl (long double _Complex z)
+{
+ ABORT_INSIDE_MAIN;
+ return __imag__ z;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/complex-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/complex-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/complex-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/complex-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,102 @@
+/* Test for builtin conj, creal, cimag. */
+/* Origin: Joseph Myers <jsm28 at cam.ac.uk> */
+
+extern float _Complex conjf (float _Complex);
+extern double _Complex conj (double _Complex);
+extern long double _Complex conjl (long double _Complex);
+
+extern float crealf (float _Complex);
+extern double creal (double _Complex);
+extern long double creall (long double _Complex);
+
+extern float cimagf (float _Complex);
+extern double cimag (double _Complex);
+extern long double cimagl (long double _Complex);
+
+extern void abort (void);
+extern void link_error (void);
+
+void
+main_test (void)
+{
+ /* For each type, test both runtime and compile time (constant folding)
+ optimization. */
+ volatile float _Complex fc = 1.0F + 2.0iF;
+ volatile double _Complex dc = 1.0 + 2.0i;
+ volatile long double _Complex ldc = 1.0L + 2.0iL;
+ /* Test floats. */
+ if (conjf (fc) != 1.0F - 2.0iF)
+ abort ();
+ if (__builtin_conjf (fc) != 1.0F - 2.0iF)
+ abort ();
+ if (conjf (1.0F + 2.0iF) != 1.0F - 2.0iF)
+ link_error ();
+ if (__builtin_conjf (1.0F + 2.0iF) != 1.0F - 2.0iF)
+ link_error ();
+ if (crealf (fc) != 1.0F)
+ abort ();
+ if (__builtin_crealf (fc) != 1.0F)
+ abort ();
+ if (crealf (1.0F + 2.0iF) != 1.0F)
+ link_error ();
+ if (__builtin_crealf (1.0F + 2.0iF) != 1.0F)
+ link_error ();
+ if (cimagf (fc) != 2.0F)
+ abort ();
+ if (__builtin_cimagf (fc) != 2.0F)
+ abort ();
+ if (cimagf (1.0F + 2.0iF) != 2.0F)
+ link_error ();
+ if (__builtin_cimagf (1.0F + 2.0iF) != 2.0F)
+ link_error ();
+ /* Test doubles. */
+ if (conj (dc) != 1.0 - 2.0i)
+ abort ();
+ if (__builtin_conj (dc) != 1.0 - 2.0i)
+ abort ();
+ if (conj (1.0 + 2.0i) != 1.0 - 2.0i)
+ link_error ();
+ if (__builtin_conj (1.0 + 2.0i) != 1.0 - 2.0i)
+ link_error ();
+ if (creal (dc) != 1.0)
+ abort ();
+ if (__builtin_creal (dc) != 1.0)
+ abort ();
+ if (creal (1.0 + 2.0i) != 1.0)
+ link_error ();
+ if (__builtin_creal (1.0 + 2.0i) != 1.0)
+ link_error ();
+ if (cimag (dc) != 2.0)
+ abort ();
+ if (__builtin_cimag (dc) != 2.0)
+ abort ();
+ if (cimag (1.0 + 2.0i) != 2.0)
+ link_error ();
+ if (__builtin_cimag (1.0 + 2.0i) != 2.0)
+ link_error ();
+ /* Test long doubles. */
+ if (conjl (ldc) != 1.0L - 2.0iL)
+ abort ();
+ if (__builtin_conjl (ldc) != 1.0L - 2.0iL)
+ abort ();
+ if (conjl (1.0L + 2.0iL) != 1.0L - 2.0iL)
+ link_error ();
+ if (__builtin_conjl (1.0L + 2.0iL) != 1.0L - 2.0iL)
+ link_error ();
+ if (creall (ldc) != 1.0L)
+ abort ();
+ if (__builtin_creall (ldc) != 1.0L)
+ abort ();
+ if (creall (1.0L + 2.0iL) != 1.0L)
+ link_error ();
+ if (__builtin_creall (1.0L + 2.0iL) != 1.0L)
+ link_error ();
+ if (cimagl (ldc) != 2.0L)
+ abort ();
+ if (__builtin_cimagl (ldc) != 2.0L)
+ abort ();
+ if (cimagl (1.0L + 2.0iL) != 2.0L)
+ link_error ();
+ if (__builtin_cimagl (1.0L + 2.0iL) != 2.0L)
+ link_error ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/fprintf.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,61 @@
+/* Copyright (C) 2001 Free Software Foundation.
+
+ Ensure all expected transformations of builtin fprintf occur and
+ that we honor side effects in the arguments.
+
+ Written by Kaveh R. Ghazi, 1/7/2001. */
+
+#include <stdio.h>
+extern int fprintf_unlocked (FILE *, const char *, ...);
+extern void abort(void);
+
+void
+main_test (void)
+{
+ FILE *s_array[] = {stdout, NULL}, **s_ptr = s_array;
+ const char *const s1 = "hello world";
+ const char *const s2[] = { s1, 0 }, *const*s3;
+
+ fprintf (*s_ptr, "");
+ fprintf (*s_ptr, "%s", "");
+ fprintf (*s_ptr, "%s", "hello");
+ fprintf (*s_ptr, "%s", "\n");
+ fprintf (*s_ptr, "%s", *s2);
+ s3 = s2;
+ fprintf (*s_ptr, "%s", *s3++);
+ if (s3 != s2+1 || *s3 != 0)
+ abort();
+ s3 = s2;
+ fprintf (*s_ptr++, "%s", *s3++);
+ if (s3 != s2+1 || *s3 != 0 || s_ptr != s_array+1 || *s_ptr != 0)
+ abort();
+
+ s_ptr = s_array;
+ fprintf (*s_ptr, "%c", '\n');
+ fprintf (*s_ptr, "%c", **s2);
+ s3 = s2;
+ fprintf (*s_ptr, "%c", **s3++);
+ if (s3 != s2+1 || *s3 != 0)
+ abort();
+ s3 = s2;
+ fprintf (*s_ptr++, "%c", **s3++);
+ if (s3 != s2+1 || *s3 != 0 || s_ptr != s_array+1 || *s_ptr != 0)
+ abort();
+
+ s_ptr = s_array;
+ fprintf (*s_ptr++, "hello world");
+ if (s_ptr != s_array+1 || *s_ptr != 0)
+ abort();
+ s_ptr = s_array;
+ fprintf (*s_ptr, "\n");
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ __builtin_fprintf (*s_ptr, "%s", "hello world\n");
+ /* Check the unlocked style, these evaluate to nothing to avoid
+ problems on systems without the unlocked functions. */
+ fprintf_unlocked (*s_ptr, "");
+ __builtin_fprintf_unlocked (*s_ptr, "");
+ fprintf_unlocked (*s_ptr, "%s", "");
+ __builtin_fprintf_unlocked (*s_ptr, "%s", "");
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fprintf.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,7 @@
+load_lib target-supports.exp
+
+if { [check_effective_target_freestanding] } {
+ return 1;
+}
+
+return 0;
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stddef.h>
+extern void abort (void);
+extern int inside_main;
+extern size_t strlen(const char *);
+int
+fputs(const char *string, FILE *stream)
+{
+ size_t n = strlen(string);
+ size_t r;
+#if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
+ if (inside_main)
+ abort();
+#endif
+ r = fwrite (string, 1, n, stream);
+ return n > r ? EOF : 0;
+}
+
+/* Locking stdio doesn't matter for the purposes of this test. */
+int
+fputs_unlocked(const char *string, FILE *stream)
+{
+ return fputs (string, stream);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,65 @@
+/* Copyright (C) 2000, 2001 Free Software Foundation.
+
+ Ensure all expected transformations of builtin fputs occur and that
+ we honor side effects in the stream argument.
+
+ Written by Kaveh R. Ghazi, 10/30/2000. */
+
+#include <stdio.h>
+extern void abort(void);
+
+int i;
+
+void
+main_test(void)
+{
+ FILE *s_array[] = {stdout, NULL}, **s_ptr = s_array;
+ const char *const s1 = "hello world";
+
+ fputs ("", *s_ptr);
+ fputs ("\n", *s_ptr);
+ fputs ("bye", *s_ptr);
+ fputs (s1, *s_ptr);
+ fputs (s1+5, *s_ptr);
+ fputs (s1+10, *s_ptr);
+ fputs (s1+11, *s_ptr);
+
+ /* Check side-effects when transforming fputs -> NOP. */
+ fputs ("", *s_ptr++);
+ if (s_ptr != s_array+1 || *s_ptr != 0)
+ abort();
+
+ /* Check side-effects when transforming fputs -> fputc. */
+ s_ptr = s_array;
+ fputs ("\n", *s_ptr++);
+ if (s_ptr != s_array+1 || *s_ptr != 0)
+ abort();
+
+ /* Check side-effects when transforming fputs -> fwrite. */
+ s_ptr = s_array;
+ fputs ("hello\n", *s_ptr++);
+ if (s_ptr != s_array+1 || *s_ptr != 0)
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ s_ptr = s_array;
+ __builtin_fputs ("", *s_ptr);
+ /* These builtin stubs are called by __builtin_fputs, ensure their
+ prototypes are set correctly too. */
+ __builtin_fputc ('\n', *s_ptr);
+ __builtin_fwrite ("hello\n", 1, 6, *s_ptr);
+ /* Check the unlocked style, these evaluate to nothing to avoid
+ problems on systems without the unlocked functions. */
+ fputs_unlocked ("", *s_ptr);
+ __builtin_fputs_unlocked ("", *s_ptr);
+
+ /* Check side-effects in conditional expression. */
+ s_ptr = s_array;
+ fputs (i++ ? "f" : "x", *s_ptr++);
+ if (s_ptr != s_array+1 || *s_ptr != 0 || i != 1)
+ abort();
+ fputs (--i ? "\n" : "\n", *--s_ptr);
+ if (s_ptr != s_array || i != 0)
+ abort();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/fputs.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,7 @@
+load_lib target-supports.exp
+
+if { [check_effective_target_freestanding] } {
+ return 1;
+}
+
+return 0;
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/abs.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/abs.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/abs.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/abs.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+extern int inside_main;
+extern void abort (void);
+#ifdef __OPTIMIZE__
+#define ABORT_INSIDE_MAIN do { if (inside_main) abort (); } while (0)
+#else
+#define ABORT_INSIDE_MAIN do { } while (0)
+#endif
+
+typedef __INTMAX_TYPE__ intmax_t;
+
+__attribute__ ((__noinline__))
+int
+abs (int x)
+{
+ ABORT_INSIDE_MAIN;
+ return x < 0 ? -x : x;
+}
+
+__attribute__ ((__noinline__))
+long
+labs (long x)
+{
+ ABORT_INSIDE_MAIN;
+ return x < 0 ? -x : x;
+}
+
+__attribute__ ((__noinline__))
+long long
+llabs (long long x)
+{
+ ABORT_INSIDE_MAIN;
+ return x < 0 ? -x : x;
+}
+
+__attribute__ ((__noinline__))
+intmax_t
+imaxabs (intmax_t x)
+{
+ ABORT_INSIDE_MAIN;
+ return x < 0 ? -x : x;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/bfill.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/bfill.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/bfill.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/bfill.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+void
+bfill (void *s, __SIZE_TYPE__ n, int ch)
+{
+ char *p;
+
+ for (p = s; n-- > 0; p++)
+ *p = ch;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/bzero.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/bzero.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/bzero.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/bzero.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+void
+bzero (void *s, __SIZE_TYPE__ n)
+{
+ char *p;
+
+ for (p = s; n-- > 0; p++)
+ *p = 0;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,519 @@
+#include <stdarg.h>
+#ifdef __unix__
+#include <sys/types.h>
+#endif
+
+/* If some target has a Max alignment less than 16, please create
+ a #ifdef around the alignment and add your alignment. */
+#ifdef __pdp11__
+#define ALIGNMENT 2
+#else
+#define ALIGNMENT 16
+#endif
+
+extern void abort (void);
+
+extern int inside_main;
+void *chk_fail_buf[256] __attribute__((aligned (ALIGNMENT)));
+volatile int chk_fail_allowed, chk_calls;
+volatile int memcpy_disallowed, mempcpy_disallowed, memmove_disallowed;
+volatile int memset_disallowed, strcpy_disallowed, stpcpy_disallowed;
+volatile int strncpy_disallowed, stpncpy_disallowed, strcat_disallowed;
+volatile int strncat_disallowed, sprintf_disallowed, vsprintf_disallowed;
+volatile int snprintf_disallowed, vsnprintf_disallowed;
+extern __SIZE_TYPE__ strlen (const char *);
+extern int vsprintf (char *, const char *, va_list);
+
+void __attribute__((noreturn))
+__chk_fail (void)
+{
+ if (chk_fail_allowed)
+ __builtin_longjmp (chk_fail_buf, 1);
+ abort ();
+}
+
+void *
+memcpy (void *dst, const void *src, __SIZE_TYPE__ n)
+{
+ const char *srcp;
+ char *dstp;
+
+#ifdef __OPTIMIZE__
+ if (memcpy_disallowed && inside_main)
+ abort ();
+#endif
+
+ srcp = src;
+ dstp = dst;
+ while (n-- != 0)
+ *dstp++ = *srcp++;
+
+ return dst;
+}
+
+void *
+__memcpy_chk (void *dst, const void *src, __SIZE_TYPE__ n, __SIZE_TYPE__ size)
+{
+ /* If size is -1, GCC should always optimize the call into memcpy. */
+ if (size == (__SIZE_TYPE__) -1)
+ abort ();
+ ++chk_calls;
+ if (n > size)
+ __chk_fail ();
+ return memcpy (dst, src, n);
+}
+
+void *
+mempcpy (void *dst, const void *src, __SIZE_TYPE__ n)
+{
+ const char *srcp;
+ char *dstp;
+
+#ifdef __OPTIMIZE__
+ if (mempcpy_disallowed && inside_main)
+ abort ();
+#endif
+
+ srcp = src;
+ dstp = dst;
+ while (n-- != 0)
+ *dstp++ = *srcp++;
+
+ return dstp;
+}
+
+void *
+__mempcpy_chk (void *dst, const void *src, __SIZE_TYPE__ n, __SIZE_TYPE__ size)
+{
+ /* If size is -1, GCC should always optimize the call into mempcpy. */
+ if (size == (__SIZE_TYPE__) -1)
+ abort ();
+ ++chk_calls;
+ if (n > size)
+ __chk_fail ();
+ return mempcpy (dst, src, n);
+}
+
+void *
+memmove (void *dst, const void *src, __SIZE_TYPE__ n)
+{
+ const char *srcp;
+ char *dstp;
+
+#ifdef __OPTIMIZE__
+ if (memmove_disallowed && inside_main)
+ abort ();
+#endif
+
+ srcp = src;
+ dstp = dst;
+ if (srcp < dstp)
+ while (n-- != 0)
+ dstp[n] = srcp[n];
+ else
+ while (n-- != 0)
+ *dstp++ = *srcp++;
+
+ return dst;
+}
+
+void *
+__memmove_chk (void *dst, const void *src, __SIZE_TYPE__ n, __SIZE_TYPE__ size)
+{
+ /* If size is -1, GCC should always optimize the call into memmove. */
+ if (size == (__SIZE_TYPE__) -1)
+ abort ();
+ ++chk_calls;
+ if (n > size)
+ __chk_fail ();
+ return memmove (dst, src, n);
+}
+
+void *
+memset (void *dst, int c, __SIZE_TYPE__ n)
+{
+ while (n-- != 0)
+ n[(char *) dst] = c;
+
+ /* Single-byte memsets should be done inline when optimisation
+ is enabled. Do this after the copy in case we're being called to
+ initialize bss. */
+#ifdef __OPTIMIZE__
+ if (memset_disallowed && inside_main && n < 2)
+ abort ();
+#endif
+
+ return dst;
+}
+
+void *
+__memset_chk (void *dst, int c, __SIZE_TYPE__ n, __SIZE_TYPE__ size)
+{
+ /* If size is -1, GCC should always optimize the call into memset. */
+ if (size == (__SIZE_TYPE__) -1)
+ abort ();
+ ++chk_calls;
+ if (n > size)
+ __chk_fail ();
+ return memset (dst, c, n);
+}
+
+char *
+strcpy (char *d, const char *s)
+{
+ char *r = d;
+#ifdef __OPTIMIZE__
+ if (strcpy_disallowed && inside_main)
+ abort ();
+#endif
+ while ((*d++ = *s++));
+ return r;
+}
+
+char *
+__strcpy_chk (char *d, const char *s, __SIZE_TYPE__ size)
+{
+ /* If size is -1, GCC should always optimize the call into strcpy. */
+ if (size == (__SIZE_TYPE__) -1)
+ abort ();
+ ++chk_calls;
+ if (strlen (s) >= size)
+ __chk_fail ();
+ return strcpy (d, s);
+}
+
+char *
+stpcpy (char *dst, const char *src)
+{
+#ifdef __OPTIMIZE__
+ if (stpcpy_disallowed && inside_main)
+ abort ();
+#endif
+
+ while (*src != 0)
+ *dst++ = *src++;
+
+ *dst = 0;
+ return dst;
+}
+
+char *
+__stpcpy_chk (char *d, const char *s, __SIZE_TYPE__ size)
+{
+ /* If size is -1, GCC should always optimize the call into stpcpy. */
+ if (size == (__SIZE_TYPE__) -1)
+ abort ();
+ ++chk_calls;
+ if (strlen (s) >= size)
+ __chk_fail ();
+ return stpcpy (d, s);
+}
+
+char *
+stpncpy (char *dst, const char *src, __SIZE_TYPE__ n)
+{
+#ifdef __OPTIMIZE__
+ if (stpncpy_disallowed && inside_main)
+ abort ();
+#endif
+
+ for (; *src && n; n--)
+ *dst++ = *src++;
+
+ char *ret = dst;
+
+ while (n--)
+ *dst++ = 0;
+
+ return ret;
+}
+
+
+char *
+__stpncpy_chk (char *s1, const char *s2, __SIZE_TYPE__ n, __SIZE_TYPE__ size)
+{
+ /* If size is -1, GCC should always optimize the call into stpncpy. */
+ if (size == (__SIZE_TYPE__) -1)
+ abort ();
+ ++chk_calls;
+ if (n > size)
+ __chk_fail ();
+ return stpncpy (s1, s2, n);
+}
+
+char *
+strncpy (char *s1, const char *s2, __SIZE_TYPE__ n)
+{
+ char *dest = s1;
+#ifdef __OPTIMIZE__
+ if (strncpy_disallowed && inside_main)
+ abort();
+#endif
+ for (; *s2 && n; n--)
+ *s1++ = *s2++;
+ while (n--)
+ *s1++ = 0;
+ return dest;
+}
+
+char *
+__strncpy_chk (char *s1, const char *s2, __SIZE_TYPE__ n, __SIZE_TYPE__ size)
+{
+ /* If size is -1, GCC should always optimize the call into strncpy. */
+ if (size == (__SIZE_TYPE__) -1)
+ abort ();
+ ++chk_calls;
+ if (n > size)
+ __chk_fail ();
+ return strncpy (s1, s2, n);
+}
+
+char *
+strcat (char *dst, const char *src)
+{
+ char *p = dst;
+
+#ifdef __OPTIMIZE__
+ if (strcat_disallowed && inside_main)
+ abort ();
+#endif
+
+ while (*p)
+ p++;
+ while ((*p++ = *src++))
+ ;
+ return dst;
+}
+
+char *
+__strcat_chk (char *d, const char *s, __SIZE_TYPE__ size)
+{
+ /* If size is -1, GCC should always optimize the call into strcat. */
+ if (size == (__SIZE_TYPE__) -1)
+ abort ();
+ ++chk_calls;
+ if (strlen (d) + strlen (s) >= size)
+ __chk_fail ();
+ return strcat (d, s);
+}
+
+char *
+strncat (char *s1, const char *s2, __SIZE_TYPE__ n)
+{
+ char *dest = s1;
+ char c;
+#ifdef __OPTIMIZE__
+ if (strncat_disallowed && inside_main)
+ abort();
+#endif
+ while (*s1) s1++;
+ c = '\0';
+ while (n > 0)
+ {
+ c = *s2++;
+ *s1++ = c;
+ if (c == '\0')
+ return dest;
+ n--;
+ }
+ if (c != '\0')
+ *s1 = '\0';
+ return dest;
+}
+
+char *
+__strncat_chk (char *d, const char *s, __SIZE_TYPE__ n, __SIZE_TYPE__ size)
+{
+ __SIZE_TYPE__ len = strlen (d), n1 = n;
+ const char *s1 = s;
+
+ /* If size is -1, GCC should always optimize the call into strncat. */
+ if (size == (__SIZE_TYPE__) -1)
+ abort ();
+ ++chk_calls;
+ while (len < size && n1 > 0)
+ {
+ if (*s1++ == '\0')
+ break;
+ ++len;
+ --n1;
+ }
+
+ if (len >= size)
+ __chk_fail ();
+ return strncat (d, s, n);
+}
+
+/* No chk test in GCC testsuite needs more bytes than this.
+ As we can't expect vsnprintf to be available on the target,
+ assume 4096 bytes is enough. */
+static char chk_sprintf_buf[4096];
+
+int
+__sprintf_chk (char *str, int flag, __SIZE_TYPE__ size, const char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+ /* If size is -1 and flag 0, GCC should always optimize the call into
+ sprintf. */
+ if (size == (__SIZE_TYPE__) -1 && flag == 0)
+ abort ();
+ ++chk_calls;
+#ifdef __OPTIMIZE__
+ if (sprintf_disallowed && inside_main)
+ abort();
+#endif
+ va_start (ap, fmt);
+ ret = vsprintf (chk_sprintf_buf, fmt, ap);
+ va_end (ap);
+ if (ret >= 0)
+ {
+ if (ret >= size)
+ __chk_fail ();
+ memcpy (str, chk_sprintf_buf, ret + 1);
+ }
+ return ret;
+}
+
+int
+__vsprintf_chk (char *str, int flag, __SIZE_TYPE__ size, const char *fmt,
+ va_list ap)
+{
+ int ret;
+
+ /* If size is -1 and flag 0, GCC should always optimize the call into
+ vsprintf. */
+ if (size == (__SIZE_TYPE__) -1 && flag == 0)
+ abort ();
+ ++chk_calls;
+#ifdef __OPTIMIZE__
+ if (vsprintf_disallowed && inside_main)
+ abort();
+#endif
+ ret = vsprintf (chk_sprintf_buf, fmt, ap);
+ if (ret >= 0)
+ {
+ if (ret >= size)
+ __chk_fail ();
+ memcpy (str, chk_sprintf_buf, ret + 1);
+ }
+ return ret;
+}
+
+int
+__snprintf_chk (char *str, __SIZE_TYPE__ len, int flag, __SIZE_TYPE__ size,
+ const char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+ /* If size is -1 and flag 0, GCC should always optimize the call into
+ snprintf. */
+ if (size == (__SIZE_TYPE__) -1 && flag == 0)
+ abort ();
+ ++chk_calls;
+ if (size < len)
+ __chk_fail ();
+#ifdef __OPTIMIZE__
+ if (snprintf_disallowed && inside_main)
+ abort();
+#endif
+ va_start (ap, fmt);
+ ret = vsprintf (chk_sprintf_buf, fmt, ap);
+ va_end (ap);
+ if (ret >= 0)
+ {
+ if (ret < len)
+ memcpy (str, chk_sprintf_buf, ret + 1);
+ else
+ {
+ memcpy (str, chk_sprintf_buf, len - 1);
+ str[len - 1] = '\0';
+ }
+ }
+ return ret;
+}
+
+int
+__vsnprintf_chk (char *str, __SIZE_TYPE__ len, int flag, __SIZE_TYPE__ size,
+ const char *fmt, va_list ap)
+{
+ int ret;
+
+ /* If size is -1 and flag 0, GCC should always optimize the call into
+ vsnprintf. */
+ if (size == (__SIZE_TYPE__) -1 && flag == 0)
+ abort ();
+ ++chk_calls;
+ if (size < len)
+ __chk_fail ();
+#ifdef __OPTIMIZE__
+ if (vsnprintf_disallowed && inside_main)
+ abort();
+#endif
+ ret = vsprintf (chk_sprintf_buf, fmt, ap);
+ if (ret >= 0)
+ {
+ if (ret < len)
+ memcpy (str, chk_sprintf_buf, ret + 1);
+ else
+ {
+ memcpy (str, chk_sprintf_buf, len - 1);
+ str[len - 1] = '\0';
+ }
+ }
+ return ret;
+}
+
+int
+snprintf (char *str, __SIZE_TYPE__ len, const char *fmt, ...)
+{
+ int ret;
+ va_list ap;
+
+#ifdef __OPTIMIZE__
+ if (snprintf_disallowed && inside_main)
+ abort();
+#endif
+ va_start (ap, fmt);
+ ret = vsprintf (chk_sprintf_buf, fmt, ap);
+ va_end (ap);
+ if (ret >= 0)
+ {
+ if (ret < len)
+ memcpy (str, chk_sprintf_buf, ret + 1);
+ else if (len)
+ {
+ memcpy (str, chk_sprintf_buf, len - 1);
+ str[len - 1] = '\0';
+ }
+ }
+ return ret;
+}
+
+/* uClibc's vsprintf calls vsnprintf. */
+#ifndef __UCLIBC__
+int
+vsnprintf (char *str, __SIZE_TYPE__ len, const char *fmt, va_list ap)
+{
+ int ret;
+
+#ifdef __OPTIMIZE__
+ if (vsnprintf_disallowed && inside_main)
+ abort();
+#endif
+ ret = vsprintf (chk_sprintf_buf, fmt, ap);
+ if (ret >= 0)
+ {
+ if (ret < len)
+ memcpy (str, chk_sprintf_buf, ret + 1);
+ else if (len)
+ {
+ memcpy (str, chk_sprintf_buf, len - 1);
+ str[len - 1] = '\0';
+ }
+ }
+ return ret;
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/fprintf.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/fprintf.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/fprintf.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/fprintf.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdarg.h>
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+int
+fprintf (FILE *fp, const char *string, ...)
+{
+ va_list ap;
+ int r;
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort();
+#endif
+ va_start (ap, string);
+ r = vfprintf (fp, string, ap);
+ va_end (ap);
+ return r;
+}
+
+/* Locking stdio doesn't matter for the purposes of this test. */
+__attribute__ ((__noinline__))
+int
+fprintf_unlocked (FILE *fp, const char *string, ...)
+{
+ va_list ap;
+ int r;
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort();
+#endif
+ va_start (ap, string);
+ r = vfprintf (fp, string, ap);
+ va_end (ap);
+ return r;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/main.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/main.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/main.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/main.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+extern void abort(void);
+extern void main_test (void);
+extern void abort (void);
+int inside_main;
+
+int
+main ()
+{
+ inside_main = 1;
+ main_test ();
+ inside_main = 0;
+ return 0;
+}
+
+/* When optimizing, all the constant cases should have been
+ constant folded, so no calls to link_error should remain.
+ In any case, link_error should not be called. */
+
+#ifndef __OPTIMIZE__
+void
+link_error (void)
+{
+ abort ();
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memchr.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memchr.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memchr.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memchr.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+extern void abort(void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+void *
+memchr (const void *s, int c, __SIZE_TYPE__ n)
+{
+ const unsigned char uc = c;
+ const unsigned char *sp;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ sp = s;
+ for (; n != 0; ++sp, --n)
+ if (*sp == uc)
+ return (void *) sp;
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memcmp.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memcmp.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memcmp.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memcmp.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+extern void abort(void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+int
+memcmp (const void *s1, const void *s2, __SIZE_TYPE__ len)
+{
+ const unsigned char *sp1, *sp2;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ sp1 = s1;
+ sp2 = s2;
+ while (len != 0 && *sp1 == *sp2)
+ sp1++, sp2++, len--;
+
+ if (len == 0)
+ return 0;
+ return *sp1 - *sp2;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memmove.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memmove.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memmove.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memmove.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+void *
+memmove (void *dst, const void *src, __SIZE_TYPE__ n)
+{
+ char *dstp;
+ const char *srcp;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ srcp = src;
+ dstp = dst;
+ if (srcp < dstp)
+ while (n-- != 0)
+ dstp[n] = srcp[n];
+ else
+ while (n-- != 0)
+ *dstp++ = *srcp++;
+
+ return dst;
+}
+
+void
+bcopy (const void *src, void *dst, __SIZE_TYPE__ n)
+{
+ memmove (dst, src, n);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/mempcpy.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/mempcpy.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/mempcpy.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/mempcpy.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+void *
+mempcpy (void *dst, const void *src, __SIZE_TYPE__ n)
+{
+ const char *srcp;
+ char *dstp;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ srcp = src;
+ dstp = dst;
+ while (n-- != 0)
+ *dstp++ = *srcp++;
+
+ return dstp;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memset.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memset.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memset.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/memset.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+void *
+memset (void *dst, int c, __SIZE_TYPE__ n)
+{
+ while (n-- != 0)
+ n[(char *) dst] = c;
+
+ /* Single-byte memsets should be done inline when optimisation
+ is enabled. Do this after the copy in case we're being called to
+ initialize bss. */
+#ifdef __OPTIMIZE__
+ if (inside_main && n < 2)
+ abort ();
+#endif
+
+ return dst;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/printf.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/printf.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/printf.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/printf.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <stdarg.h>
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+int
+printf (const char *string, ...)
+{
+ va_list ap;
+ int r;
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort();
+#endif
+ va_start (ap, string);
+ r = vprintf (string, ap);
+ va_end (ap);
+ return r;
+}
+
+
+/* Locking stdio doesn't matter for the purposes of this test. */
+__attribute__ ((__noinline__))
+int
+printf_unlocked (const char *string, ...)
+{
+ va_list ap;
+ int r;
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort();
+#endif
+ va_start (ap, string);
+ r = vprintf (string, ap);
+ va_end (ap);
+ return r;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/sprintf.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/sprintf.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/sprintf.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/sprintf.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdarg.h>
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+int
+(sprintf) (char *buf, const char *fmt, ...)
+{
+ va_list ap;
+ int r;
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+ va_start (ap, fmt);
+ r = vsprintf (buf, fmt, ap);
+ va_end (ap);
+ return r;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/stpcpy.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/stpcpy.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/stpcpy.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/stpcpy.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+char *
+stpcpy (char *dst, const char *src)
+{
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ while (*src != 0)
+ *dst++ = *src++;
+
+ *dst = 0;
+ return dst;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcat.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcat.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcat.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcat.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+extern int inside_main;
+extern void abort(void);
+
+__attribute__ ((__noinline__))
+char *
+strcat (char *dst, const char *src)
+{
+ char *p = dst;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ while (*p)
+ p++;
+ while ((*p++ = *src++))
+ ;
+ return dst;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strchr.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strchr.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strchr.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strchr.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+char *
+strchr (const char *s, int c)
+{
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ for (;;)
+ {
+ if (*s == c)
+ return (char *) s;
+ if (*s == 0)
+ return 0;
+ s++;
+ }
+}
+
+__attribute__ ((__noinline__))
+char *
+index (const char *s, int c)
+{
+ return strchr (s, c);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcmp.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcmp.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcmp.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcmp.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+int
+strcmp (const char *s1, const char *s2)
+{
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ while (*s1 != 0 && *s1 == *s2)
+ s1++, s2++;
+
+ if (*s1 == 0 || *s2 == 0)
+ return (unsigned char) *s1 - (unsigned char) *s2;
+ return *s1 - *s2;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcpy.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcpy.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcpy.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcpy.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+char *
+strcpy (char *d, const char *s)
+{
+ char *r = d;
+#if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
+ if (inside_main)
+ abort ();
+#endif
+ while ((*d++ = *s++));
+ return r;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcspn.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcspn.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcspn.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strcspn.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+__SIZE_TYPE__
+strcspn (const char *s1, const char *s2)
+{
+ const char *p, *q;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort();
+#endif
+
+ for (p = s1; *p; p++)
+ for (q = s2; *q; q++)
+ if (*p == *q)
+ goto found;
+
+ found:
+ return p - s1;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strlen.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strlen.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strlen.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strlen.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+__SIZE_TYPE__
+strlen (const char *s)
+{
+ __SIZE_TYPE__ i;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ i = 0;
+ while (s[i] != 0)
+ i++;
+
+ return i;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncat.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncat.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncat.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncat.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+extern void abort(void);
+extern int inside_main;
+
+typedef __SIZE_TYPE__ size_t;
+
+__attribute__ ((__noinline__))
+char *
+strncat (char *s1, const char *s2, size_t n)
+{
+ char *dest = s1;
+ char c = '\0';
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort();
+#endif
+ while (*s1) s1++;
+ c = '\0';
+ while (n > 0)
+ {
+ c = *s2++;
+ *s1++ = c;
+ if (c == '\0')
+ return dest;
+ n--;
+ }
+ if (c != '\0')
+ *s1 = '\0';
+ return dest;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncmp.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncmp.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncmp.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncmp.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+extern void abort (void);
+extern int inside_main;
+
+typedef __SIZE_TYPE__ size_t;
+
+__attribute__ ((__noinline__))
+int
+strncmp(const char *s1, const char *s2, size_t n)
+{
+ const unsigned char *u1 = (const unsigned char *)s1;
+ const unsigned char *u2 = (const unsigned char *)s2;
+ unsigned char c1, c2;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort();
+#endif
+
+ while (n > 0)
+ {
+ c1 = *u1++, c2 = *u2++;
+ if (c1 == '\0' || c1 != c2)
+ return c1 - c2;
+ n--;
+ }
+ return c1 - c2;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncpy.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncpy.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncpy.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strncpy.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+extern void abort(void);
+extern int inside_main;
+
+typedef __SIZE_TYPE__ size_t;
+
+__attribute__ ((__noinline__))
+char *
+strncpy(char *s1, const char *s2, size_t n)
+{
+ char *dest = s1;
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort();
+#endif
+ for (; *s2 && n; n--)
+ *s1++ = *s2++;
+ while (n--)
+ *s1++ = 0;
+ return dest;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strnlen.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strnlen.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strnlen.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strnlen.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+typedef __SIZE_TYPE__ size_t;
+
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+size_t
+strnlen (const char *s, size_t n)
+{
+ size_t i;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ i = 0;
+ while (s[i] != 0 && n--)
+ i++;
+
+ return i;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strpbrk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strpbrk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strpbrk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strpbrk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+char *
+strpbrk(const char *s1, const char *s2)
+{
+ const char *p;
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+ while (*s1)
+ {
+ for (p = s2; *p; p++)
+ if (*s1 == *p)
+ return (char *)s1;
+ s1++;
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strrchr.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strrchr.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strrchr.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strrchr.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+char *
+strrchr (const char *s, int c)
+{
+ __SIZE_TYPE__ i;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ i = 0;
+ while (s[i] != 0)
+ i++;
+
+ do
+ if (s[i] == c)
+ return (char *) s + i;
+ while (i-- != 0);
+
+ return 0;
+}
+
+__attribute__ ((__noinline__))
+char *
+rindex (const char *s, int c)
+{
+ return strrchr (s, c);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strspn.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strspn.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strspn.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strspn.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+__SIZE_TYPE__
+strcspn (const char *s1, const char *s2)
+{
+ const char *p, *q;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort();
+#endif
+
+ for (p = s1; *p; p++)
+ {
+ for (q = s2; *q; q++)
+ if (*p == *q)
+ goto proceed;
+ break;
+
+ proceed:;
+ }
+ return p - s1;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strstr.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strstr.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strstr.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/lib/strstr.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+extern void abort (void);
+extern int inside_main;
+
+__attribute__ ((__noinline__))
+char *
+strstr(const char *s1, const char *s2)
+{
+ const char *p, *q;
+
+#ifdef __OPTIMIZE__
+ if (inside_main)
+ abort ();
+#endif
+
+ /* deliberately dumb algorithm */
+ for (; *s1; s1++)
+ {
+ p = s1, q = s2;
+ while (*q && *p)
+ {
+ if (*q != *p)
+ break;
+ p++, q++;
+ }
+ if (*q == 0)
+ return (char *)s1;
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memchr-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memchr-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memchr-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memchr-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/memchr.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memchr.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memchr.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memchr.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memchr.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+/* Copyright (C) 2007 Free Software Foundation.
+
+ Ensure all expected transformations of builtin memchr occur
+ and perform correctly.
+
+ Written by Paolo Carlini, 10/5/2007. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern void *memchr (const void *, int, size_t);
+
+void
+main_test (void)
+{
+ const char* const foo1 = "hello world";
+
+ if (memchr (foo1, 'x', 11))
+ abort ();
+ if (memchr (foo1, 'o', 11) != foo1 + 4)
+ abort ();
+ if (memchr (foo1, 'w', 2))
+ abort ();
+ if (memchr (foo1 + 5, 'o', 6) != foo1 + 7)
+ abort ();
+ if (memchr (foo1, 'd', 11) != foo1 + 10)
+ abort ();
+ if (memchr (foo1, 'd', 10))
+ abort ();
+ if (memchr (foo1, '\0', 11))
+ abort ();
+ if (memchr (foo1, '\0', 12) != foo1 + 11)
+ abort ();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_memchr (foo1, 'r', 11) != foo1 + 8)
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcmp-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcmp-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcmp-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcmp-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/memcmp.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcmp.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcmp.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcmp.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcmp.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+/* Copyright (C) 2001 Free Software Foundation.
+
+ Ensure that short builtin memcmp are optimized and perform correctly.
+ On architectures with a cmpstrsi instruction, this test doesn't determine
+ which optimization is being performed, but it does check for correctness.
+
+ Written by Roger Sayle, 12/02/2001.
+ Additional tests by Roger Sayle after PR 3508, 12/26/2001. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern int memcmp (const void *, const void *, size_t);
+extern char *strcpy (char *, const char *);
+extern void link_error (void);
+
+void
+main_test (void)
+{
+ char str[8];
+
+ strcpy (str, "3141");
+
+ if ( memcmp (str, str+2, 0) != 0 )
+ abort ();
+ if ( memcmp (str+1, str+3, 0) != 0 )
+ abort ();
+
+ if ( memcmp (str+1, str+3, 1) != 0 )
+ abort ();
+ if ( memcmp (str, str+2, 1) >= 0 )
+ abort ();
+ if ( memcmp (str+2, str, 1) <= 0 )
+ abort ();
+
+ if (memcmp ("abcd", "efgh", 4) >= 0)
+ link_error ();
+ if (memcmp ("abcd", "abcd", 4) != 0)
+ link_error ();
+ if (memcmp ("efgh", "abcd", 4) <= 0)
+ link_error ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,479 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __memcpy_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+
+#include "chk.h"
+
+const char s1[] = "123";
+char p[32] = "";
+volatile char *s2 = "defg"; /* prevent constant propagation to happen when whole program assumptions are made. */
+volatile char *s3 = "FGH"; /* prevent constant propagation to happen when whole program assumptions are made. */
+volatile size_t l1 = 1; /* prevent constant propagation to happen when whole program assumptions are made. */
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ int i;
+
+#if defined __i386__ || defined __x86_64__
+ /* The functions below might not be optimized into direct stores on all
+ arches. It depends on how many instructions would be generated and
+ what limits the architecture chooses in STORE_BY_PIECES_P. */
+ memcpy_disallowed = 1;
+#endif
+
+ /* All the memcpy calls in this routine except last have fixed length, so
+ object size checking should be done at compile time if optimizing. */
+ chk_calls = 0;
+
+ if (memcpy (p, "ABCDE", 6) != p || memcmp (p, "ABCDE", 6))
+ abort ();
+ if (memcpy (p + 16, "VWX" + 1, 2) != p + 16
+ || memcmp (p + 16, "WX\0\0", 5))
+ abort ();
+ if (memcpy (p + 1, "", 1) != p + 1 || memcmp (p, "A\0CDE", 6))
+ abort ();
+ if (memcpy (p + 3, "FGHI", 4) != p + 3 || memcmp (p, "A\0CFGHI", 8))
+ abort ();
+
+ i = 8;
+ memcpy (p + 20, "qrstu", 6);
+ memcpy (p + 25, "QRSTU", 6);
+ if (memcpy (p + 25 + 1, s1, 3) != p + 25 + 1
+ || memcmp (p + 25, "Q123U", 6))
+ abort ();
+
+ if (memcpy (memcpy (p, "abcdEFG", 4) + 4, "efg", 4) != p + 4
+ || memcmp (p, "abcdefg", 8))
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_memcpy (p, "ABCDE", 6) != p || memcmp (p, "ABCDE", 6))
+ abort ();
+
+ memcpy (p + 5, s3, 1);
+ if (memcmp (p, "ABCDEFg", 8))
+ abort ();
+
+ memcpy_disallowed = 0;
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+
+ memcpy (p + 6, s1 + 1, l1);
+ if (memcmp (p, "ABCDEF2", 8))
+ abort ();
+
+ /* The above memcpy copies into an object with known size, but
+ unknown length, so it should be a __memcpy_chk call. */
+ if (chk_calls != 1)
+ abort ();
+}
+
+long buf1[64];
+char *buf2 = (char *) (buf1 + 32);
+long buf5[20];
+char buf7[20];
+
+void
+__attribute__((noinline))
+test2_sub (long *buf3, char *buf4, char *buf6, int n)
+{
+ int i = 0;
+
+ /* All the memcpy/__builtin_memcpy/__builtin___memcpy_chk
+ calls in this routine are either fixed length, or have
+ side-effects in __builtin_object_size arguments, or
+ dst doesn't point into a known object. */
+ chk_calls = 0;
+
+ /* These should probably be handled by store_by_pieces on most arches. */
+ if (memcpy (buf1, "ABCDEFGHI", 9) != (char *) buf1
+ || memcmp (buf1, "ABCDEFGHI\0", 11))
+ abort ();
+
+ if (memcpy (buf1, "abcdefghijklmnopq", 17) != (char *) buf1
+ || memcmp (buf1, "abcdefghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_memcpy (buf3, "ABCDEF", 6) != (char *) buf1
+ || memcmp (buf1, "ABCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_memcpy (buf3, "a", 1) != (char *) buf1
+ || memcmp (buf1, "aBCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (memcpy ((char *) buf3 + 2, "bcd" + ++i, 2) != (char *) buf1 + 2
+ || memcmp (buf1, "aBcdEFghijklmnopq\0", 19)
+ || i != 1)
+ abort ();
+
+ /* These should probably be handled by move_by_pieces on most arches. */
+ if (memcpy ((char *) buf3 + 4, buf5, 6) != (char *) buf1 + 4
+ || memcmp (buf1, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_memcpy ((char *) buf1 + ++i + 8, (char *) buf5 + 1, 1)
+ != (char *) buf1 + 10
+ || memcmp (buf1, "aBcdRSTUVWSlmnopq\0", 19)
+ || i != 2)
+ abort ();
+
+ if (memcpy ((char *) buf3 + 14, buf6, 2) != (char *) buf1 + 14
+ || memcmp (buf1, "aBcdRSTUVWSlmnrsq\0", 19))
+ abort ();
+
+ if (memcpy (buf3, buf5, 8) != (char *) buf1
+ || memcmp (buf1, "RSTUVWXYVWSlmnrsq\0", 19))
+ abort ();
+
+ if (memcpy (buf3, buf5, 17) != (char *) buf1
+ || memcmp (buf1, "RSTUVWXYZ01234567\0", 19))
+ abort ();
+
+ __builtin_memcpy (buf3, "aBcdEFghijklmnopq\0", 19);
+
+ /* These should be handled either by movmemendM or memcpy
+ call. */
+
+ /* buf3 points to an unknown object, so __memcpy_chk should not be done. */
+ if (memcpy ((char *) buf3 + 4, buf5, n + 6) != (char *) buf1 + 4
+ || memcmp (buf1, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ /* This call has side-effects in dst, therefore no checking. */
+ if (__builtin___memcpy_chk ((char *) buf1 + ++i + 8, (char *) buf5 + 1,
+ n + 1, os ((char *) buf1 + ++i + 8))
+ != (char *) buf1 + 11
+ || memcmp (buf1, "aBcdRSTUVWkSmnopq\0", 19)
+ || i != 3)
+ abort ();
+
+ if (memcpy ((char *) buf3 + 14, buf6, n + 2) != (char *) buf1 + 14
+ || memcmp (buf1, "aBcdRSTUVWkSmnrsq\0", 19))
+ abort ();
+
+ i = 1;
+
+ /* These might be handled by store_by_pieces. */
+ if (memcpy (buf2, "ABCDEFGHI", 9) != buf2
+ || memcmp (buf2, "ABCDEFGHI\0", 11))
+ abort ();
+
+ if (memcpy (buf2, "abcdefghijklmnopq", 17) != buf2
+ || memcmp (buf2, "abcdefghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_memcpy (buf4, "ABCDEF", 6) != buf2
+ || memcmp (buf2, "ABCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_memcpy (buf4, "a", 1) != buf2
+ || memcmp (buf2, "aBCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (memcpy (buf4 + 2, "bcd" + i++, 2) != buf2 + 2
+ || memcmp (buf2, "aBcdEFghijklmnopq\0", 19)
+ || i != 2)
+ abort ();
+
+ /* These might be handled by move_by_pieces. */
+ if (memcpy (buf4 + 4, buf7, 6) != buf2 + 4
+ || memcmp (buf2, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ /* Side effect. */
+ if (__builtin___memcpy_chk (buf2 + i++ + 8, buf7 + 1, 1,
+ os (buf2 + i++ + 8))
+ != buf2 + 10
+ || memcmp (buf2, "aBcdRSTUVWSlmnopq\0", 19)
+ || i != 3)
+ abort ();
+
+ if (memcpy (buf4 + 14, buf6, 2) != buf2 + 14
+ || memcmp (buf2, "aBcdRSTUVWSlmnrsq\0", 19))
+ abort ();
+
+ __builtin_memcpy (buf4, "aBcdEFghijklmnopq\0", 19);
+
+ /* These should be handled either by movmemendM or memcpy
+ call. */
+ if (memcpy (buf4 + 4, buf7, n + 6) != buf2 + 4
+ || memcmp (buf2, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ /* Side effect. */
+ if (__builtin___memcpy_chk (buf2 + i++ + 8, buf7 + 1, n + 1,
+ os (buf2 + i++ + 8))
+ != buf2 + 11
+ || memcmp (buf2, "aBcdRSTUVWkSmnopq\0", 19)
+ || i != 4)
+ abort ();
+
+ if (memcpy (buf4 + 14, buf6, n + 2) != buf2 + 14
+ || memcmp (buf2, "aBcdRSTUVWkSmnrsq\0", 19))
+ abort ();
+
+ if (chk_calls)
+ abort ();
+}
+
+void
+__attribute__((noinline))
+test2 (void)
+{
+ long *x;
+ char *y;
+ int z;
+ __builtin_memcpy (buf5, "RSTUVWXYZ0123456789", 20);
+ __builtin_memcpy (buf7, "RSTUVWXYZ0123456789", 20);
+ __asm ("" : "=r" (x) : "0" (buf1));
+ __asm ("" : "=r" (y) : "0" (buf2));
+ __asm ("" : "=r" (z) : "0" (0));
+ test2_sub (x, y, "rstuvwxyz", z);
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+ size_t l;
+
+ /* The following calls should do runtime checking
+ - length is not known, but destination is. */
+ chk_calls = 0;
+ memcpy (a.buf1 + 2, s3, l1);
+ memcpy (r, s3, l1 + 1);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ memcpy (r, s2, l1 + 2);
+ memcpy (r + 2, s3, l1);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ memcpy (r, s2, l1);
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ memcpy (a.buf1 + 2, s3, 1);
+ memcpy (r, s3, 2);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ memcpy (r, s2, 3);
+ r = buf3;
+ l = 4;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1], l = 2;
+ else if (i == l1)
+ r = &a.buf2[7], l = 3;
+ else if (i == l1 + 1)
+ r = &buf3[5], l = 4;
+ else if (i == l1 + 2)
+ r = &a.buf1[9], l = 1;
+ }
+ memcpy (r, s2, 1);
+ /* Here, l is known to be at most 4 and __builtin_object_size (&buf3[16], 0)
+ is 4, so this doesn't need runtime checking. */
+ memcpy (&buf3[16], s2, l);
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test4 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ memcpy (&a.buf2[9], s2, l1 + 1);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ memcpy (&a.buf2[7], s3, strlen (s3) + 1);
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ memcpy (&buf3[19], "ab", 2);
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+#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 + 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;
+
+void
+__attribute__((noinline))
+test5 (void)
+{
+ 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;
+ }
+
+ p = memcpy (u1.buf + off1, u2.buf + off2, len);
+ 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 ();
+ }
+
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+ }
+}
+
+#define TESTSIZE 80
+
+char srcb[TESTSIZE] __attribute__ ((aligned));
+char dstb[TESTSIZE] __attribute__ ((aligned));
+
+void
+__attribute__((noinline))
+check (char *test, char *match, int n)
+{
+ if (memcmp (test, match, n))
+ abort ();
+}
+
+#define TN(n) \
+{ memset (dstb, 0, n); memcpy (dstb, srcb, n); check (dstb, srcb, n); }
+#define T(n) \
+TN (n) \
+TN ((n) + 1) \
+TN ((n) + 2) \
+TN ((n) + 3)
+
+void
+__attribute__((noinline))
+test6 (void)
+{
+ int i;
+
+ chk_calls = 0;
+
+ for (i = 0; i < sizeof (srcb); ++i)
+ srcb[i] = 'a' + i % 26;
+
+ T (0);
+ T (4);
+ T (8);
+ T (12);
+ T (16);
+ T (20);
+ T (24);
+ T (28);
+ T (32);
+ T (36);
+ T (40);
+ T (44);
+ T (48);
+ T (52);
+ T (56);
+ T (60);
+ T (64);
+ T (68);
+ T (72);
+ T (76);
+
+ /* All memcpy calls in this routine have constant arguments. */
+ if (chk_calls)
+ abort ();
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (l1) : "0" (l1));
+ test1 ();
+ test2 ();
+ test3 ();
+ test4 ();
+ test5 ();
+ test6 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memcpy-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test4 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-2-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-2-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-2-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-2-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,7 @@
+#include "lib/memmove.c"
+#ifdef __vxworks
+/* The RTP C library uses bzero and bfill, both of which are defined
+ in the same file as bcopy. */
+#include "lib/bzero.c"
+#include "lib/bfill.c"
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Check builtin memmove and bcopy optimization when length is 1.
+
+ Written by Jakub Jelinek, 9/14/2004. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern void *memmove (void *, const void *, size_t);
+extern void bcopy (const void *, void *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+
+char p[32] = "abcdefg";
+char *q = p + 4;
+
+void
+main_test (void)
+{
+ /* memmove with length 1 can be optimized into memcpy if it can be
+ expanded inline. */
+ if (memmove (p + 2, p + 3, 1) != p + 2 || memcmp (p, "abddefg", 8))
+ abort ();
+ if (memmove (p + 1, p + 1, 1) != p + 1 || memcmp (p, "abddefg", 8))
+ abort ();
+ if (memmove (q, p + 4, 1) != p + 4 || memcmp (p, "abddefg", 8))
+ abort ();
+ bcopy (p + 5, p + 6, 1);
+ if (memcmp (p, "abddeff", 8))
+ abort ();
+ bcopy (p + 1, p + 1, 1);
+ if (memcmp (p, "abddeff", 8))
+ abort ();
+ bcopy (q, p + 4, 1);
+ if (memcmp (p, "abddeff", 8))
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,579 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __memcpy_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern void *memmove (void *, const void *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+
+#include "chk.h"
+
+const char s1[] = "123";
+char p[32] = "";
+volatile char *s2 = "defg"; /* prevent constant propagation to happen when whole program assumptions are made. */
+volatile char *s3 = "FGH"; /* prevent constant propagation to happen when whole program assumptions are made. */
+volatile size_t l1 = 1; /* prevent constant propagation to happen when whole program assumptions are made. */
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ int i;
+
+#if defined __i386__ || defined __x86_64__
+ /* The functions below might not be optimized into direct stores on all
+ arches. It depends on how many instructions would be generated and
+ what limits the architecture chooses in STORE_BY_PIECES_P. */
+ memmove_disallowed = 1;
+ memcpy_disallowed = 1;
+#endif
+
+ /* All the memmove calls in this routine except last have fixed length, so
+ object size checking should be done at compile time if optimizing. */
+ chk_calls = 0;
+
+ if (memmove (p, "ABCDE", 6) != p || memcmp (p, "ABCDE", 6))
+ abort ();
+ if (memmove (p + 16, "VWX" + 1, 2) != p + 16
+ || memcmp (p + 16, "WX\0\0", 5))
+ abort ();
+ if (memmove (p + 1, "", 1) != p + 1 || memcmp (p, "A\0CDE", 6))
+ abort ();
+ if (memmove (p + 3, "FGHI", 4) != p + 3 || memcmp (p, "A\0CFGHI", 8))
+ abort ();
+
+ i = 8;
+ memmove (p + 20, "qrstu", 6);
+ memmove (p + 25, "QRSTU", 6);
+ if (memmove (p + 25 + 1, s1, 3) != p + 25 + 1
+ || memcmp (p + 25, "Q123U", 6))
+ abort ();
+
+ if (memmove (memmove (p, "abcdEFG", 4) + 4, "efg", 4) != p + 4
+ || memcmp (p, "abcdefg", 8))
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_memmove (p, "ABCDE", 6) != p || memcmp (p, "ABCDE", 6))
+ abort ();
+
+ memmove (p + 5, s3, 1);
+ if (memcmp (p, "ABCDEFg", 8))
+ abort ();
+
+ memmove_disallowed = 0;
+ memcpy_disallowed = 0;
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+
+ memmove (p + 6, s1 + 1, l1);
+ if (memcmp (p, "ABCDEF2", 8))
+ abort ();
+
+ /* The above memmove copies into an object with known size, but
+ unknown length, so it should be a __memmove_chk call. */
+ if (chk_calls != 1)
+ abort ();
+}
+
+long buf1[64];
+char *buf2 = (char *) (buf1 + 32);
+long buf5[20];
+char buf7[20];
+
+void
+__attribute__((noinline))
+test2_sub (long *buf3, char *buf4, char *buf6, int n)
+{
+ int i = 0;
+
+ /* All the memmove/__builtin_memmove/__builtin___memmove_chk
+ calls in this routine are either fixed length, or have
+ side-effects in __builtin_object_size arguments, or
+ dst doesn't point into a known object. */
+ chk_calls = 0;
+
+ /* These should probably be handled by store_by_pieces on most arches. */
+ if (memmove (buf1, "ABCDEFGHI", 9) != (char *) buf1
+ || memcmp (buf1, "ABCDEFGHI\0", 11))
+ abort ();
+
+ if (memmove (buf1, "abcdefghijklmnopq", 17) != (char *) buf1
+ || memcmp (buf1, "abcdefghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_memmove (buf3, "ABCDEF", 6) != (char *) buf1
+ || memcmp (buf1, "ABCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_memmove (buf3, "a", 1) != (char *) buf1
+ || memcmp (buf1, "aBCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (memmove ((char *) buf3 + 2, "bcd" + ++i, 2) != (char *) buf1 + 2
+ || memcmp (buf1, "aBcdEFghijklmnopq\0", 19)
+ || i != 1)
+ abort ();
+
+ /* These should probably be handled by move_by_pieces on most arches. */
+ if (memmove ((char *) buf3 + 4, buf5, 6) != (char *) buf1 + 4
+ || memcmp (buf1, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_memmove ((char *) buf1 + ++i + 8, (char *) buf5 + 1, 1)
+ != (char *) buf1 + 10
+ || memcmp (buf1, "aBcdRSTUVWSlmnopq\0", 19)
+ || i != 2)
+ abort ();
+
+ if (memmove ((char *) buf3 + 14, buf6, 2) != (char *) buf1 + 14
+ || memcmp (buf1, "aBcdRSTUVWSlmnrsq\0", 19))
+ abort ();
+
+ if (memmove (buf3, buf5, 8) != (char *) buf1
+ || memcmp (buf1, "RSTUVWXYVWSlmnrsq\0", 19))
+ abort ();
+
+ if (memmove (buf3, buf5, 17) != (char *) buf1
+ || memcmp (buf1, "RSTUVWXYZ01234567\0", 19))
+ abort ();
+
+ __builtin_memmove (buf3, "aBcdEFghijklmnopq\0", 19);
+
+ /* These should be handled either by movmemendM or memmove
+ call. */
+
+ /* buf3 points to an unknown object, so __memmove_chk should not be done. */
+ if (memmove ((char *) buf3 + 4, buf5, n + 6) != (char *) buf1 + 4
+ || memcmp (buf1, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ /* This call has side-effects in dst, therefore no checking. */
+ if (__builtin___memmove_chk ((char *) buf1 + ++i + 8, (char *) buf5 + 1,
+ n + 1, os ((char *) buf1 + ++i + 8))
+ != (char *) buf1 + 11
+ || memcmp (buf1, "aBcdRSTUVWkSmnopq\0", 19)
+ || i != 3)
+ abort ();
+
+ if (memmove ((char *) buf3 + 14, buf6, n + 2) != (char *) buf1 + 14
+ || memcmp (buf1, "aBcdRSTUVWkSmnrsq\0", 19))
+ abort ();
+
+ i = 1;
+
+ /* These might be handled by store_by_pieces. */
+ if (memmove (buf2, "ABCDEFGHI", 9) != buf2
+ || memcmp (buf2, "ABCDEFGHI\0", 11))
+ abort ();
+
+ if (memmove (buf2, "abcdefghijklmnopq", 17) != buf2
+ || memcmp (buf2, "abcdefghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_memmove (buf4, "ABCDEF", 6) != buf2
+ || memcmp (buf2, "ABCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_memmove (buf4, "a", 1) != buf2
+ || memcmp (buf2, "aBCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (memmove (buf4 + 2, "bcd" + i++, 2) != buf2 + 2
+ || memcmp (buf2, "aBcdEFghijklmnopq\0", 19)
+ || i != 2)
+ abort ();
+
+ /* These might be handled by move_by_pieces. */
+ if (memmove (buf4 + 4, buf7, 6) != buf2 + 4
+ || memcmp (buf2, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ /* Side effect. */
+ if (__builtin___memmove_chk (buf2 + i++ + 8, buf7 + 1, 1,
+ os (buf2 + i++ + 8))
+ != buf2 + 10
+ || memcmp (buf2, "aBcdRSTUVWSlmnopq\0", 19)
+ || i != 3)
+ abort ();
+
+ if (memmove (buf4 + 14, buf6, 2) != buf2 + 14
+ || memcmp (buf2, "aBcdRSTUVWSlmnrsq\0", 19))
+ abort ();
+
+ __builtin_memmove (buf4, "aBcdEFghijklmnopq\0", 19);
+
+ /* These should be handled either by movmemendM or memmove
+ call. */
+ if (memmove (buf4 + 4, buf7, n + 6) != buf2 + 4
+ || memcmp (buf2, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ /* Side effect. */
+ if (__builtin___memmove_chk (buf2 + i++ + 8, buf7 + 1, n + 1,
+ os (buf2 + i++ + 8))
+ != buf2 + 11
+ || memcmp (buf2, "aBcdRSTUVWkSmnopq\0", 19)
+ || i != 4)
+ abort ();
+
+ if (memmove (buf4 + 14, buf6, n + 2) != buf2 + 14
+ || memcmp (buf2, "aBcdRSTUVWkSmnrsq\0", 19))
+ abort ();
+
+ if (chk_calls)
+ abort ();
+}
+
+void
+__attribute__((noinline))
+test2 (void)
+{
+ long *x;
+ char *y;
+ int z;
+ __builtin_memmove (buf5, "RSTUVWXYZ0123456789", 20);
+ __builtin_memmove (buf7, "RSTUVWXYZ0123456789", 20);
+ __asm ("" : "=r" (x) : "0" (buf1));
+ __asm ("" : "=r" (y) : "0" (buf2));
+ __asm ("" : "=r" (z) : "0" (0));
+ test2_sub (x, y, "rstuvwxyz", z);
+}
+
+static const struct foo
+{
+ char *s;
+ double d;
+ long l;
+} foo[] =
+{
+ { "hello world1", 3.14159, 101L },
+ { "hello world2", 3.14159, 102L },
+ { "hello world3", 3.14159, 103L },
+ { "hello world4", 3.14159, 104L },
+ { "hello world5", 3.14159, 105L },
+ { "hello world6", 3.14159, 106L }
+};
+
+static const struct bar
+{
+ char *s;
+ const struct foo f[3];
+} bar[] =
+{
+ {
+ "hello world10",
+ {
+ { "hello1", 3.14159, 201L },
+ { "hello2", 3.14159, 202L },
+ { "hello3", 3.14159, 203L },
+ }
+ },
+ {
+ "hello world11",
+ {
+ { "hello4", 3.14159, 204L },
+ { "hello5", 3.14159, 205L },
+ { "hello6", 3.14159, 206L },
+ }
+ }
+};
+
+static const int baz[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
+
+void
+__attribute__((noinline))
+test3 (void)
+{
+ const char *s;
+ struct foo f1[sizeof foo/sizeof*foo];
+ struct bar b1[sizeof bar/sizeof*bar];
+ int bz[sizeof baz/sizeof*baz];
+
+ /* All the memmove/__builtin_memmove calls in this routine have fixed
+ length. */
+ chk_calls = 0;
+
+ /* All the *memmove calls below have src in read-only memory, so all
+ of them should be optimized into memcpy. */
+ memmove_disallowed = 1;
+ if (memmove (f1, foo, sizeof (foo)) != f1 || memcmp (f1, foo, sizeof (foo)))
+ abort ();
+ if (memmove (b1, bar, sizeof (bar)) != b1 || memcmp (b1, bar, sizeof (bar)))
+ abort ();
+ memmove (bz, baz, sizeof (baz));
+ if (memcmp (bz, baz, sizeof (baz)))
+ abort ();
+
+ if (memmove (p, "abcde", 6) != p || memcmp (p, "abcde", 6))
+ abort ();
+ s = s1;
+ if (memmove (p + 2, ++s, 0) != p + 2 || memcmp (p, "abcde", 6) || s != s1 + 1)
+ abort ();
+ if (__builtin_memmove (p + 3, "", 1) != p + 3 || memcmp (p, "abc\0e", 6))
+ abort ();
+ memmove (p + 2, "fghijk", 4);
+ if (memcmp (p, "abfghi", 7))
+ abort ();
+ s = s1 + 1;
+ memmove (p + 1, s++, 0);
+ if (memcmp (p, "abfghi", 7) || s != s1 + 2)
+ abort ();
+ __builtin_memmove (p + 4, "ABCDE", 1);
+ if (memcmp (p, "abfgAi", 7))
+ abort ();
+
+ /* memmove with length 1 can be optimized into memcpy if it can be
+ expanded inline. */
+ if (memmove (p + 2, p + 3, 1) != p + 2)
+ abort ();
+ if (memcmp (p, "abggAi", 7))
+ abort ();
+
+ if (chk_calls)
+ abort ();
+ memmove_disallowed = 0;
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test4 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+ size_t l;
+
+ /* The following calls should do runtime checking
+ - length is not known, but destination is. */
+ chk_calls = 0;
+ memmove (a.buf1 + 2, s3, l1);
+ memmove (r, s3, l1 + 1);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ memmove (r, s2, l1 + 2);
+ memmove (r + 2, s3, l1);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ memmove (r, s2, l1);
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ memmove (a.buf1 + 2, s3, 1);
+ memmove (r, s3, 2);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ memmove (r, s2, 3);
+ r = buf3;
+ l = 4;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1], l = 2;
+ else if (i == l1)
+ r = &a.buf2[7], l = 3;
+ else if (i == l1 + 1)
+ r = &buf3[5], l = 4;
+ else if (i == l1 + 2)
+ r = &a.buf1[9], l = 1;
+ }
+ memmove (r, s2, 1);
+ /* Here, l is known to be at most 4 and __builtin_object_size (&buf3[16], 0)
+ is 4, so this doesn't need runtime checking. */
+ memmove (&buf3[16], s2, l);
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test5 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ memmove (&a.buf2[9], s2, l1 + 1);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ memmove (&a.buf2[7], s3, strlen (s3) + 1);
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ memmove (&buf3[19], "ab", 2);
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+#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 + 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;
+
+void
+__attribute__((noinline))
+test6 (void)
+{
+ 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;
+ }
+
+ p = memmove (u1.buf + off1, u2.buf + off2, len);
+ 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 ();
+ }
+
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+ }
+}
+
+#define TESTSIZE 80
+
+char srcb[TESTSIZE] __attribute__ ((aligned));
+char dstb[TESTSIZE] __attribute__ ((aligned));
+
+void
+__attribute__((noinline))
+check (char *test, char *match, int n)
+{
+ if (memcmp (test, match, n))
+ abort ();
+}
+
+#define TN(n) \
+{ memset (dstb, 0, n); memmove (dstb, srcb, n); check (dstb, srcb, n); }
+#define T(n) \
+TN (n) \
+TN ((n) + 1) \
+TN ((n) + 2) \
+TN ((n) + 3)
+
+void
+__attribute__((noinline))
+test7 (void)
+{
+ int i;
+
+ chk_calls = 0;
+
+ for (i = 0; i < sizeof (srcb); ++i)
+ srcb[i] = 'a' + i % 26;
+
+ T (0);
+ T (4);
+ T (8);
+ T (12);
+ T (16);
+ T (20);
+ T (24);
+ T (28);
+ T (32);
+ T (36);
+ T (40);
+ T (44);
+ T (48);
+ T (52);
+ T (56);
+ T (60);
+ T (64);
+ T (68);
+ T (72);
+ T (76);
+
+ /* All memmove calls in this routine have constant arguments. */
+ if (chk_calls)
+ abort ();
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (l1) : "0" (l1));
+ test1 ();
+ test2 ();
+ __builtin_memset (p, '\0', sizeof (p));
+ test3 ();
+ test4 ();
+ test5 ();
+ test6 ();
+ test7 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test5 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,7 @@
+#include "lib/memmove.c"
+#ifdef __vxworks
+/* The RTP C library uses bzero and bfill, both of which are defined
+ in the same file as bcopy. */
+#include "lib/bzero.c"
+#include "lib/bfill.c"
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memmove.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,90 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation.
+
+ Ensure builtin memmove and bcopy perform correctly.
+
+ Written by Jakub Jelinek, 4/26/2003. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern void *memmove (void *, const void *, size_t);
+extern void bcopy (const void *, void *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+
+const char s1[] = "123";
+char p[32] = "";
+
+static const struct foo
+{
+ char *s;
+ double d;
+ long l;
+} foo[] =
+{
+ { "hello world1", 3.14159, 101L },
+ { "hello world2", 3.14159, 102L },
+ { "hello world3", 3.14159, 103L },
+ { "hello world4", 3.14159, 104L },
+ { "hello world5", 3.14159, 105L },
+ { "hello world6", 3.14159, 106L }
+};
+
+static const struct bar
+{
+ char *s;
+ const struct foo f[3];
+} bar[] =
+{
+ {
+ "hello world10",
+ {
+ { "hello1", 3.14159, 201L },
+ { "hello2", 3.14159, 202L },
+ { "hello3", 3.14159, 203L },
+ }
+ },
+ {
+ "hello world11",
+ {
+ { "hello4", 3.14159, 204L },
+ { "hello5", 3.14159, 205L },
+ { "hello6", 3.14159, 206L },
+ }
+ }
+};
+
+static const int baz[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
+
+void
+main_test (void)
+{
+ const char *s;
+ struct foo f1[sizeof foo/sizeof*foo];
+ struct bar b1[sizeof bar/sizeof*bar];
+ int bz[sizeof baz/sizeof*baz];
+
+ if (memmove (f1, foo, sizeof (foo)) != f1 || memcmp (f1, foo, sizeof (foo)))
+ abort ();
+ if (memmove (b1, bar, sizeof (bar)) != b1 || memcmp (b1, bar, sizeof (bar)))
+ abort ();
+ bcopy (baz, bz, sizeof (baz));
+ if (memcmp (bz, baz, sizeof (baz)))
+ abort ();
+
+ if (memmove (p, "abcde", 6) != p || memcmp (p, "abcde", 6))
+ abort ();
+ s = s1;
+ if (memmove (p + 2, ++s, 0) != p + 2 || memcmp (p, "abcde", 6) || s != s1 + 1)
+ abort ();
+ if (__builtin_memmove (p + 3, "", 1) != p + 3 || memcmp (p, "abc\0e", 6))
+ abort ();
+ bcopy ("fghijk", p + 2, 4);
+ if (memcmp (p, "abfghi", 7))
+ abort ();
+ s = s1 + 1;
+ bcopy (s++, p + 1, 0);
+ if (memcmp (p, "abfghi", 7) || s != s1 + 2)
+ abort ();
+ __builtin_bcopy ("ABCDE", p + 4, 1);
+ if (memcmp (p, "abfgAi", 7))
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,117 @@
+extern void abort (void);
+extern int inside_main;
+typedef __SIZE_TYPE__ size_t;
+
+#define TEST_ABORT if (inside_main) abort()
+
+/* LTO code is at the present to able to track that asm alias my_bcopy on builtin
+ actually refers to this function. See PR47181. */
+__attribute__ ((used))
+void *
+my_memcpy (void *d, const void *s, size_t n)
+{
+ char *dst = (char *) d;
+ const char *src = (const char *) s;
+ while (n--)
+ *dst++ = *src++;
+ return (char *) d;
+}
+
+/* LTO code is at the present to able to track that asm alias my_bcopy on builtin
+ actually refers to this function. See PR47181. */
+__attribute__ ((used))
+void
+my_bcopy (const void *s, void *d, size_t n)
+{
+ char *dst = (char *) d;
+ const char *src = (const char *) s;
+ if (src >= dst)
+ while (n--)
+ *dst++ = *src++;
+ else
+ {
+ dst += n;
+ src += n;
+ while (n--)
+ *--dst = *--src;
+ }
+}
+
+__attribute__ ((used))
+void *
+my_memmove (void *d, const void *s, size_t n)
+{
+ char *dst = (char *) d;
+ const char *src = (const char *) s;
+ if (src >= dst)
+ while (n--)
+ *dst++ = *src++;
+ else
+ {
+ dst += n;
+ src += n;
+ while (n--)
+ *--dst = *--src;
+ }
+
+ return d;
+}
+
+/* LTO code is at the present to able to track that asm alias my_bcopy on builtin
+ actually refers to this function. See PR47181. */
+__attribute__ ((used))
+void *
+my_memset (void *d, int c, size_t n)
+{
+ char *dst = (char *) d;
+ while (n--)
+ *dst++ = c;
+ return (char *) d;
+}
+
+/* LTO code is at the present to able to track that asm alias my_bcopy on builtin
+ actually refers to this function. See PR47181. */
+__attribute__ ((used))
+void
+my_bzero (void *d, size_t n)
+{
+ char *dst = (char *) d;
+ while (n--)
+ *dst++ = '\0';
+}
+
+void *
+memcpy (void *d, const void *s, size_t n)
+{
+ void *result = my_memcpy (d, s, n);
+ TEST_ABORT;
+ return result;
+}
+
+void
+bcopy (const void *s, void *d, size_t n)
+{
+ my_bcopy (s, d, n);
+ TEST_ABORT;
+}
+
+void *
+memset (void *d, int c, size_t n)
+{
+ void *result = my_memset (d, c, n);
+ TEST_ABORT;
+ return result;
+}
+
+void
+bzero (void *d, size_t n)
+{
+ my_bzero (d, n);
+ TEST_ABORT;
+}
+
+#ifdef __vxworks
+/* The RTP C library uses bfill, which is defined in the same file as
+ bzero and bcopy. */
+#include "lib/bfill.c"
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,53 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Test memcpy and memset in presence of redirect. */
+
+#define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+#define ASMNAME2(prefix, cname) STRING (prefix) cname
+#define STRING(x) #x
+
+typedef __SIZE_TYPE__ size_t;
+extern void abort (void);
+extern void *memcpy (void *, const void *, size_t)
+ __asm (ASMNAME ("my_memcpy"));
+extern void bcopy (const void *, void *, size_t)
+ __asm (ASMNAME ("my_bcopy"));
+extern void *memmove (void *, const void *, size_t)
+ __asm (ASMNAME ("my_memmove"));
+extern void *memset (void *, int, size_t)
+ __asm (ASMNAME ("my_memset"));
+extern void bzero (void *, size_t)
+ __asm (ASMNAME ("my_bzero"));
+extern int memcmp (const void *, const void *, size_t);
+
+struct A { char c[32]; } a = { "foobar" };
+char x[64] = "foobar", y[64];
+int i = 39, j = 6, k = 4;
+
+extern int inside_main;
+
+void
+main_test (void)
+{
+ struct A b = a;
+ struct A c = { { 'x' } };
+
+ inside_main = 1;
+
+ if (memcmp (b.c, x, 32) || c.c[0] != 'x' || memcmp (c.c + 1, x + 32, 31))
+ abort ();
+ if (__builtin_memcpy (y, x, i) != y || memcmp (x, y, 64))
+ abort ();
+ if (memcpy (y + 6, x, j) != y + 6
+ || memcmp (x, y, 6) || memcmp (x, y + 6, 58))
+ abort ();
+ if (__builtin_memset (y + 2, 'X', k) != y + 2
+ || memcmp (y, "foXXXXfoobar", 13))
+ abort ();
+ bcopy (y + 1, y + 2, 6);
+ if (memcmp (y, "fooXXXXfobar", 13))
+ abort ();
+ __builtin_bzero (y + 4, 2);
+ if (memcmp (y, "fooX\0\0Xfobar", 13))
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memops-asm.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,10 @@
+# Different translation units may have different user name overrides
+# and we do not preserve enough context to known which one we want.
+
+set torture_eval_before_compile {
+ if {[string match {*-flto*} "$option"]} {
+ continue
+ }
+}
+
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-2-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-2-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-2-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-2-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/mempcpy.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,153 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Ensure that builtin mempcpy and stpcpy perform correctly.
+
+ Written by Jakub Jelinek, 21/05/2003. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern void *mempcpy (void *, const void *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+extern int inside_main;
+
+long buf1[64];
+char *buf2 = (char *) (buf1 + 32);
+long buf5[20];
+char buf7[20];
+
+void
+__attribute__((noinline))
+test (long *buf3, char *buf4, char *buf6, int n)
+{
+ int i = 0;
+
+ /* These should probably be handled by store_by_pieces on most arches. */
+ if (mempcpy (buf1, "ABCDEFGHI", 9) != (char *) buf1 + 9
+ || memcmp (buf1, "ABCDEFGHI\0", 11))
+ abort ();
+
+ if (mempcpy (buf1, "abcdefghijklmnopq", 17) != (char *) buf1 + 17
+ || memcmp (buf1, "abcdefghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy (buf3, "ABCDEF", 6) != (char *) buf1 + 6
+ || memcmp (buf1, "ABCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy (buf3, "a", 1) != (char *) buf1 + 1
+ || memcmp (buf1, "aBCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (mempcpy ((char *) buf3 + 2, "bcd" + ++i, 2) != (char *) buf1 + 4
+ || memcmp (buf1, "aBcdEFghijklmnopq\0", 19)
+ || i != 1)
+ abort ();
+
+ /* These should probably be handled by move_by_pieces on most arches. */
+ if (mempcpy ((char *) buf3 + 4, buf5, 6) != (char *) buf1 + 10
+ || memcmp (buf1, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy ((char *) buf1 + ++i + 8, (char *) buf5 + 1, 1)
+ != (char *) buf1 + 11
+ || memcmp (buf1, "aBcdRSTUVWSlmnopq\0", 19)
+ || i != 2)
+ abort ();
+
+ if (mempcpy ((char *) buf3 + 14, buf6, 2) != (char *) buf1 + 16
+ || memcmp (buf1, "aBcdRSTUVWSlmnrsq\0", 19))
+ abort ();
+
+ if (mempcpy (buf3, buf5, 8) != (char *) buf1 + 8
+ || memcmp (buf1, "RSTUVWXYVWSlmnrsq\0", 19))
+ abort ();
+
+ if (mempcpy (buf3, buf5, 17) != (char *) buf1 + 17
+ || memcmp (buf1, "RSTUVWXYZ01234567\0", 19))
+ abort ();
+
+ __builtin_memcpy (buf3, "aBcdEFghijklmnopq\0", 19);
+
+ /* These should be handled either by movmemendM or mempcpy
+ call. */
+ if (mempcpy ((char *) buf3 + 4, buf5, n + 6) != (char *) buf1 + 10
+ || memcmp (buf1, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy ((char *) buf1 + ++i + 8, (char *) buf5 + 1, n + 1)
+ != (char *) buf1 + 12
+ || memcmp (buf1, "aBcdRSTUVWkSmnopq\0", 19)
+ || i != 3)
+ abort ();
+
+ if (mempcpy ((char *) buf3 + 14, buf6, n + 2) != (char *) buf1 + 16
+ || memcmp (buf1, "aBcdRSTUVWkSmnrsq\0", 19))
+ abort ();
+
+ i = 1;
+
+ /* These might be handled by store_by_pieces. */
+ if (mempcpy (buf2, "ABCDEFGHI", 9) != buf2 + 9
+ || memcmp (buf2, "ABCDEFGHI\0", 11))
+ abort ();
+
+ if (mempcpy (buf2, "abcdefghijklmnopq", 17) != buf2 + 17
+ || memcmp (buf2, "abcdefghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy (buf4, "ABCDEF", 6) != buf2 + 6
+ || memcmp (buf2, "ABCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy (buf4, "a", 1) != buf2 + 1
+ || memcmp (buf2, "aBCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (mempcpy (buf4 + 2, "bcd" + i++, 2) != buf2 + 4
+ || memcmp (buf2, "aBcdEFghijklmnopq\0", 19)
+ || i != 2)
+ abort ();
+
+ /* These might be handled by move_by_pieces. */
+ if (mempcpy (buf4 + 4, buf7, 6) != buf2 + 10
+ || memcmp (buf2, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy (buf2 + i++ + 8, buf7 + 1, 1)
+ != buf2 + 11
+ || memcmp (buf2, "aBcdRSTUVWSlmnopq\0", 19)
+ || i != 3)
+ abort ();
+
+ if (mempcpy (buf4 + 14, buf6, 2) != buf2 + 16
+ || memcmp (buf2, "aBcdRSTUVWSlmnrsq\0", 19))
+ abort ();
+
+ __builtin_memcpy (buf4, "aBcdEFghijklmnopq\0", 19);
+
+ /* These should be handled either by movmemendM or mempcpy
+ call. */
+ if (mempcpy (buf4 + 4, buf7, n + 6) != buf2 + 10
+ || memcmp (buf2, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy (buf2 + i++ + 8, buf7 + 1, n + 1)
+ != buf2 + 12
+ || memcmp (buf2, "aBcdRSTUVWkSmnopq\0", 19)
+ || i != 4)
+ abort ();
+
+ if (mempcpy (buf4 + 14, buf6, n + 2) != buf2 + 16
+ || memcmp (buf2, "aBcdRSTUVWkSmnrsq\0", 19))
+ abort ();
+}
+
+void
+main_test (void)
+{
+ /* All these tests are allowed to call mempcpy/stpcpy. */
+ inside_main = 0;
+ __builtin_memcpy (buf5, "RSTUVWXYZ0123456789", 20);
+ __builtin_memcpy (buf7, "RSTUVWXYZ0123456789", 20);
+ test (buf1, buf2, "rstuvwxyz", 0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,487 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __mempcpy_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern void *mempcpy (void *, const void *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+
+#include "chk.h"
+
+const char s1[] = "123";
+char p[32] = "";
+volatile char *s2 = "defg"; /* prevent constant propagation to happen when whole program assumptions are made. */
+volatile char *s3 = "FGH"; /* prevent constant propagation to happen when whole program assumptions are made. */
+volatile size_t l1 = 1; /* prevent constant propagation to happen when whole program assumptions are made. */
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ int i;
+
+#if defined __i386__ || defined __x86_64__
+ /* The functions below might not be optimized into direct stores on all
+ arches. It depends on how many instructions would be generated and
+ what limits the architecture chooses in STORE_BY_PIECES_P. */
+ mempcpy_disallowed = 1;
+#endif
+
+ /* All the mempcpy calls in this routine except last have fixed length, so
+ object size checking should be done at compile time if optimizing. */
+ chk_calls = 0;
+
+ if (mempcpy (p, "ABCDE", 6) != p + 6 || memcmp (p, "ABCDE", 6))
+ abort ();
+ if (mempcpy (p + 16, "VWX" + 1, 2) != p + 16 + 2
+ || memcmp (p + 16, "WX\0\0", 5))
+ abort ();
+ if (mempcpy (p + 1, "", 1) != p + 1 + 1 || memcmp (p, "A\0CDE", 6))
+ abort ();
+ if (mempcpy (p + 3, "FGHI", 4) != p + 3 + 4 || memcmp (p, "A\0CFGHI", 8))
+ abort ();
+
+ i = 8;
+ memcpy (p + 20, "qrstu", 6);
+ memcpy (p + 25, "QRSTU", 6);
+ if (mempcpy (p + 25 + 1, s1, 3) != (p + 25 + 1 + 3)
+ || memcmp (p + 25, "Q123U", 6))
+ abort ();
+
+ if (mempcpy (mempcpy (p, "abcdEFG", 4), "efg", 4) != p + 8
+ || memcmp (p, "abcdefg", 8))
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_mempcpy (p, "ABCDE", 6) != p + 6 || memcmp (p, "ABCDE", 6))
+ abort ();
+
+ /* If the result of mempcpy is ignored, gcc should use memcpy.
+ This should be optimized always, so disallow mempcpy calls. */
+ mempcpy_disallowed = 1;
+ mempcpy (p + 5, s3, 1);
+ if (memcmp (p, "ABCDEFg", 8))
+ abort ();
+
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+
+ mempcpy (p + 6, s1 + 1, l1);
+ if (memcmp (p, "ABCDEF2", 8))
+ abort ();
+
+ /* The above mempcpy copies into an object with known size, but
+ unknown length and with result ignored, so it should be a
+ __memcpy_chk call. */
+ if (chk_calls != 1)
+ abort ();
+
+ mempcpy_disallowed = 0;
+}
+
+long buf1[64];
+char *buf2 = (char *) (buf1 + 32);
+long buf5[20];
+char buf7[20];
+
+void
+__attribute__((noinline))
+test2_sub (long *buf3, char *buf4, char *buf6, int n)
+{
+ int i = 0;
+
+ /* All the mempcpy/__builtin_mempcpy/__builtin___mempcpy_chk
+ calls in this routine are either fixed length, or have
+ side-effects in __builtin_object_size arguments, or
+ dst doesn't point into a known object. */
+ chk_calls = 0;
+
+ /* These should probably be handled by store_by_pieces on most arches. */
+ if (mempcpy (buf1, "ABCDEFGHI", 9) != (char *) buf1 + 9
+ || memcmp (buf1, "ABCDEFGHI\0", 11))
+ abort ();
+
+ if (mempcpy (buf1, "abcdefghijklmnopq", 17) != (char *) buf1 + 17
+ || memcmp (buf1, "abcdefghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy (buf3, "ABCDEF", 6) != (char *) buf1 + 6
+ || memcmp (buf1, "ABCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy (buf3, "a", 1) != (char *) buf1 + 1
+ || memcmp (buf1, "aBCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (mempcpy ((char *) buf3 + 2, "bcd" + ++i, 2) != (char *) buf1 + 4
+ || memcmp (buf1, "aBcdEFghijklmnopq\0", 19)
+ || i != 1)
+ abort ();
+
+ /* These should probably be handled by move_by_pieces on most arches. */
+ if (mempcpy ((char *) buf3 + 4, buf5, 6) != (char *) buf1 + 10
+ || memcmp (buf1, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy ((char *) buf1 + ++i + 8, (char *) buf5 + 1, 1)
+ != (char *) buf1 + 11
+ || memcmp (buf1, "aBcdRSTUVWSlmnopq\0", 19)
+ || i != 2)
+ abort ();
+
+ if (mempcpy ((char *) buf3 + 14, buf6, 2) != (char *) buf1 + 16
+ || memcmp (buf1, "aBcdRSTUVWSlmnrsq\0", 19))
+ abort ();
+
+ if (mempcpy (buf3, buf5, 8) != (char *) buf1 + 8
+ || memcmp (buf1, "RSTUVWXYVWSlmnrsq\0", 19))
+ abort ();
+
+ if (mempcpy (buf3, buf5, 17) != (char *) buf1 + 17
+ || memcmp (buf1, "RSTUVWXYZ01234567\0", 19))
+ abort ();
+
+ __builtin_memcpy (buf3, "aBcdEFghijklmnopq\0", 19);
+
+ /* These should be handled either by movmemendM or mempcpy
+ call. */
+
+ /* buf3 points to an unknown object, so __mempcpy_chk should not be done. */
+ if (mempcpy ((char *) buf3 + 4, buf5, n + 6) != (char *) buf1 + 10
+ || memcmp (buf1, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ /* This call has side-effects in dst, therefore no checking. */
+ if (__builtin___mempcpy_chk ((char *) buf1 + ++i + 8, (char *) buf5 + 1,
+ n + 1, os ((char *) buf1 + ++i + 8))
+ != (char *) buf1 + 12
+ || memcmp (buf1, "aBcdRSTUVWkSmnopq\0", 19)
+ || i != 3)
+ abort ();
+
+ if (mempcpy ((char *) buf3 + 14, buf6, n + 2) != (char *) buf1 + 16
+ || memcmp (buf1, "aBcdRSTUVWkSmnrsq\0", 19))
+ abort ();
+
+ i = 1;
+
+ /* These might be handled by store_by_pieces. */
+ if (mempcpy (buf2, "ABCDEFGHI", 9) != buf2 + 9
+ || memcmp (buf2, "ABCDEFGHI\0", 11))
+ abort ();
+
+ if (mempcpy (buf2, "abcdefghijklmnopq", 17) != buf2 + 17
+ || memcmp (buf2, "abcdefghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy (buf4, "ABCDEF", 6) != buf2 + 6
+ || memcmp (buf2, "ABCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (__builtin_mempcpy (buf4, "a", 1) != buf2 + 1
+ || memcmp (buf2, "aBCDEFghijklmnopq\0", 19))
+ abort ();
+
+ if (mempcpy (buf4 + 2, "bcd" + i++, 2) != buf2 + 4
+ || memcmp (buf2, "aBcdEFghijklmnopq\0", 19)
+ || i != 2)
+ abort ();
+
+ /* These might be handled by move_by_pieces. */
+ if (mempcpy (buf4 + 4, buf7, 6) != buf2 + 10
+ || memcmp (buf2, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ /* Side effect. */
+ if (__builtin___mempcpy_chk (buf2 + i++ + 8, buf7 + 1, 1,
+ os (buf2 + i++ + 8))
+ != buf2 + 11
+ || memcmp (buf2, "aBcdRSTUVWSlmnopq\0", 19)
+ || i != 3)
+ abort ();
+
+ if (mempcpy (buf4 + 14, buf6, 2) != buf2 + 16
+ || memcmp (buf2, "aBcdRSTUVWSlmnrsq\0", 19))
+ abort ();
+
+ __builtin_memcpy (buf4, "aBcdEFghijklmnopq\0", 19);
+
+ /* These should be handled either by movmemendM or mempcpy
+ call. */
+ if (mempcpy (buf4 + 4, buf7, n + 6) != buf2 + 10
+ || memcmp (buf2, "aBcdRSTUVWklmnopq\0", 19))
+ abort ();
+
+ /* Side effect. */
+ if (__builtin___mempcpy_chk (buf2 + i++ + 8, buf7 + 1,
+ n + 1, os (buf2 + i++ + 8))
+ != buf2 + 12
+ || memcmp (buf2, "aBcdRSTUVWkSmnopq\0", 19)
+ || i != 4)
+ abort ();
+
+ if (mempcpy (buf4 + 14, buf6, n + 2) != buf2 + 16
+ || memcmp (buf2, "aBcdRSTUVWkSmnrsq\0", 19))
+ abort ();
+
+ if (chk_calls)
+ abort ();
+}
+
+void
+__attribute__((noinline))
+test2 (void)
+{
+ long *x;
+ char *y;
+ int z;
+ __builtin_memcpy (buf5, "RSTUVWXYZ0123456789", 20);
+ __builtin_memcpy (buf7, "RSTUVWXYZ0123456789", 20);
+ __asm ("" : "=r" (x) : "0" (buf1));
+ __asm ("" : "=r" (y) : "0" (buf2));
+ __asm ("" : "=r" (z) : "0" (0));
+ test2_sub (x, y, "rstuvwxyz", z);
+}
+
+volatile void *vx;
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+ size_t l;
+
+ /* The following calls should do runtime checking
+ - length is not known, but destination is. */
+ chk_calls = 0;
+ vx = mempcpy (a.buf1 + 2, s3, l1);
+ vx = mempcpy (r, s3, l1 + 1);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ vx = mempcpy (r, s2, l1 + 2);
+ vx = mempcpy (r + 2, s3, l1);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ vx = mempcpy (r, s2, l1);
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ vx = mempcpy (a.buf1 + 2, s3, 1);
+ vx = mempcpy (r, s3, 2);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ vx = mempcpy (r, s2, 3);
+ r = buf3;
+ l = 4;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1], l = 2;
+ else if (i == l1)
+ r = &a.buf2[7], l = 3;
+ else if (i == l1 + 1)
+ r = &buf3[5], l = 4;
+ else if (i == l1 + 2)
+ r = &a.buf1[9], l = 1;
+ }
+ vx = mempcpy (r, s2, 1);
+ /* Here, l is known to be at most 4 and __builtin_object_size (&buf3[16], 0)
+ is 4, so this doesn't need runtime checking. */
+ vx = mempcpy (&buf3[16], s2, l);
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test4 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ vx = mempcpy (&a.buf2[9], s2, l1 + 1);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ vx = mempcpy (&a.buf2[7], s3, strlen (s3) + 1);
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ vx = mempcpy (&buf3[19], "ab", 2);
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+#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 + 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;
+
+void
+__attribute__((noinline))
+test5 (void)
+{
+ 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;
+ }
+
+ p = mempcpy (u1.buf + off1, u2.buf + off2, len);
+ if (p != u1.buf + off1 + len)
+ 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 ();
+ }
+
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+ }
+}
+
+#define TESTSIZE 80
+
+char srcb[TESTSIZE] __attribute__ ((aligned));
+char dstb[TESTSIZE] __attribute__ ((aligned));
+
+void
+__attribute__((noinline))
+check (char *test, char *match, int n)
+{
+ if (memcmp (test, match, n))
+ abort ();
+}
+
+#define TN(n) \
+{ memset (dstb, 0, n); vx = mempcpy (dstb, srcb, n); check (dstb, srcb, n); }
+#define T(n) \
+TN (n) \
+TN ((n) + 1) \
+TN ((n) + 2) \
+TN ((n) + 3)
+
+void
+__attribute__((noinline))
+test6 (void)
+{
+ int i;
+
+ chk_calls = 0;
+
+ for (i = 0; i < sizeof (srcb); ++i)
+ srcb[i] = 'a' + i % 26;
+
+ T (0);
+ T (4);
+ T (8);
+ T (12);
+ T (16);
+ T (20);
+ T (24);
+ T (28);
+ T (32);
+ T (36);
+ T (40);
+ T (44);
+ T (48);
+ T (52);
+ T (56);
+ T (60);
+ T (64);
+ T (68);
+ T (72);
+ T (76);
+
+ /* All mempcpy calls in this routine have constant arguments. */
+ if (chk_calls)
+ abort ();
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (l1) : "0" (l1));
+ test1 ();
+ test2 ();
+ test3 ();
+ test4 ();
+ test5 ();
+ test6 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test4 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/mempcpy.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/mempcpy.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,68 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Ensure builtin mempcpy performs correctly.
+
+ Written by Kaveh Ghazi, 4/11/2003. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern void *mempcpy (void *, const void *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+extern int inside_main;
+
+const char s1[] = "123";
+char p[32] = "";
+char *s2 = "defg";
+char *s3 = "FGH";
+size_t l1 = 1;
+
+void
+main_test (void)
+{
+ int i;
+
+#if !defined __i386__ && !defined __x86_64__
+ /* The functions below might not be optimized into direct stores on all
+ arches. It depends on how many instructions would be generated and
+ what limits the architecture chooses in STORE_BY_PIECES_P. */
+ inside_main = 0;
+#endif
+
+ if (mempcpy (p, "ABCDE", 6) != p + 6 || memcmp (p, "ABCDE", 6))
+ abort ();
+ if (mempcpy (p + 16, "VWX" + 1, 2) != p + 16 + 2
+ || memcmp (p + 16, "WX\0\0", 5))
+ abort ();
+ if (mempcpy (p + 1, "", 1) != p + 1 + 1 || memcmp (p, "A\0CDE", 6))
+ abort ();
+ if (mempcpy (p + 3, "FGHI", 4) != p + 3 + 4 || memcmp (p, "A\0CFGHI", 8))
+ abort ();
+
+ i = 8;
+ memcpy (p + 20, "qrstu", 6);
+ memcpy (p + 25, "QRSTU", 6);
+ if (mempcpy (p + 25 + 1, s1, 3) != (p + 25 + 1 + 3)
+ || memcmp (p + 25, "Q123U", 6))
+ abort ();
+
+ if (mempcpy (mempcpy (p, "abcdEFG", 4), "efg", 4) != p + 8
+ || memcmp (p, "abcdefg", 8))
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_mempcpy (p, "ABCDE", 6) != p + 6 || memcmp (p, "ABCDE", 6))
+ abort ();
+
+ /* If the result of mempcpy is ignored, gcc should use memcpy.
+ This should be optimized always, so set inside_main again. */
+ inside_main = 1;
+ mempcpy (p + 5, s3, 1);
+ if (memcmp (p, "ABCDEFg", 8))
+ abort ();
+ mempcpy (p + 6, s1 + 1, l1);
+ if (memcmp (p, "ABCDEF2", 8))
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,721 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __memset_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern void *memset (void *, int, size_t);
+extern int memcmp (const void *, const void *, size_t);
+
+#include "chk.h"
+
+char buffer[32];
+int argc = 1;
+volatile size_t l1 = 1; /* prevent constant propagation to happen when whole program assumptions are made. */
+volatile char *s3 = "FGH"; /* prevent constant propagation to happen when whole program assumptions are made. */
+char *s4;
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ memset_disallowed = 1;
+ chk_calls = 0;
+ memset (buffer, argc, 0);
+ memset (buffer, argc, 1);
+ memset (buffer, argc, 2);
+ memset (buffer, argc, 3);
+ memset (buffer, argc, 4);
+ memset (buffer, argc, 5);
+ memset (buffer, argc, 6);
+ memset (buffer, argc, 7);
+ memset (buffer, argc, 8);
+ memset (buffer, argc, 9);
+ memset (buffer, argc, 10);
+ memset (buffer, argc, 11);
+ memset (buffer, argc, 12);
+ memset (buffer, argc, 13);
+ memset (buffer, argc, 14);
+ memset (buffer, argc, 15);
+ memset (buffer, argc, 16);
+ memset (buffer, argc, 17);
+ memset_disallowed = 0;
+ if (chk_calls)
+ abort ();
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test2 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+ size_t l;
+
+ /* The following calls should do runtime checking
+ - length is not known, but destination is. */
+ chk_calls = 0;
+ memset (a.buf1 + 2, 'a', l1);
+ memset (r, '\0', l1 + 1);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ memset (r, argc, l1 + 2);
+ memset (r + 2, 'Q', l1);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ memset (r, '\0', l1);
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ memset (a.buf1 + 2, '\0', 1);
+ memset (r, argc, 2);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ memset (r, 'N', 3);
+ r = buf3;
+ l = 4;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1], l = 2;
+ else if (i == l1)
+ r = &a.buf2[7], l = 3;
+ else if (i == l1 + 1)
+ r = &buf3[5], l = 4;
+ else if (i == l1 + 2)
+ r = &a.buf1[9], l = 1;
+ }
+ memset (r, 'H', 1);
+ /* Here, l is known to be at most 4 and __builtin_object_size (&buf3[16], 0)
+ is 4, so this doesn't need runtime checking. */
+ memset (&buf3[16], 'd', l);
+ /* Neither length nor destination known. Doesn't need runtime checking. */
+ memset (s4, 'a', l1);
+ memset (s4 + 2, '\0', l1 + 2);
+ /* Destination unknown. */
+ memset (s4 + 4, 'b', 2);
+ memset (s4 + 6, '\0', 4);
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ memset (&a.buf2[9], '\0', l1 + 1);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ memset (&a.buf2[7], 'T', strlen (s3) + 1);
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ memset (&buf3[19], 'b', 2);
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+#ifndef MAX_OFFSET
+#define MAX_OFFSET (sizeof (long long))
+#endif
+
+#ifndef MAX_COPY
+#define MAX_COPY (10 * sizeof (long long))
+#define MAX_COPY2 15
+#else
+#define MAX_COPY2 MAX_COPY
+#endif
+
+#ifndef MAX_EXTRA
+#define MAX_EXTRA (sizeof (long long))
+#endif
+
+#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)
+#define MAX_LENGTH2 (MAX_OFFSET + MAX_COPY2 + MAX_EXTRA)
+
+static union {
+ char buf[MAX_LENGTH];
+ long long align_int;
+ long double align_fp;
+} u;
+
+char A = 'A';
+
+void
+__attribute__((noinline))
+test4 (void)
+{
+ int off, len, i;
+ char *p, *q;
+
+ for (off = 0; off < MAX_OFFSET; off++)
+ for (len = 1; len < MAX_COPY; len++)
+ {
+ for (i = 0; i < MAX_LENGTH; i++)
+ u.buf[i] = 'a';
+
+ p = memset (u.buf + off, '\0', len);
+ if (p != u.buf + off)
+ abort ();
+
+ q = u.buf;
+ for (i = 0; i < off; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ for (i = 0; i < len; i++, q++)
+ if (*q != '\0')
+ abort ();
+
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ p = memset (u.buf + off, A, len);
+ if (p != u.buf + off)
+ abort ();
+
+ q = u.buf;
+ for (i = 0; i < off; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ for (i = 0; i < len; i++, q++)
+ if (*q != 'A')
+ abort ();
+
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ p = memset (u.buf + off, 'B', len);
+ if (p != u.buf + off)
+ abort ();
+
+ q = u.buf;
+ for (i = 0; i < off; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ for (i = 0; i < len; i++, q++)
+ if (*q != 'B')
+ abort ();
+
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+ }
+}
+
+static union {
+ char buf[MAX_LENGTH2];
+ long long align_int;
+ long double align_fp;
+} u2;
+
+void reset ()
+{
+ int i;
+
+ for (i = 0; i < MAX_LENGTH2; i++)
+ u2.buf[i] = 'a';
+}
+
+void check (int off, int len, int ch)
+{
+ char *q;
+ int i;
+
+ q = u2.buf;
+ for (i = 0; i < off; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ for (i = 0; i < len; i++, q++)
+ if (*q != ch)
+ abort ();
+
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+}
+
+void
+__attribute__((noinline))
+test5 (void)
+{
+ int off;
+ char *p;
+
+ /* len == 1 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 1);
+ if (p != u2.buf + off) abort ();
+ check (off, 1, '\0');
+
+ p = memset (u2.buf + off, A, 1);
+ if (p != u2.buf + off) abort ();
+ check (off, 1, 'A');
+
+ p = memset (u2.buf + off, 'B', 1);
+ if (p != u2.buf + off) abort ();
+ check (off, 1, 'B');
+ }
+
+ /* len == 2 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 2);
+ if (p != u2.buf + off) abort ();
+ check (off, 2, '\0');
+
+ p = memset (u2.buf + off, A, 2);
+ if (p != u2.buf + off) abort ();
+ check (off, 2, 'A');
+
+ p = memset (u2.buf + off, 'B', 2);
+ if (p != u2.buf + off) abort ();
+ check (off, 2, 'B');
+ }
+
+ /* len == 3 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 3);
+ if (p != u2.buf + off) abort ();
+ check (off, 3, '\0');
+
+ p = memset (u2.buf + off, A, 3);
+ if (p != u2.buf + off) abort ();
+ check (off, 3, 'A');
+
+ p = memset (u2.buf + off, 'B', 3);
+ if (p != u2.buf + off) abort ();
+ check (off, 3, 'B');
+ }
+
+ /* len == 4 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 4);
+ if (p != u2.buf + off) abort ();
+ check (off, 4, '\0');
+
+ p = memset (u2.buf + off, A, 4);
+ if (p != u2.buf + off) abort ();
+ check (off, 4, 'A');
+
+ p = memset (u2.buf + off, 'B', 4);
+ if (p != u2.buf + off) abort ();
+ check (off, 4, 'B');
+ }
+
+ /* len == 5 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 5);
+ if (p != u2.buf + off) abort ();
+ check (off, 5, '\0');
+
+ p = memset (u2.buf + off, A, 5);
+ if (p != u2.buf + off) abort ();
+ check (off, 5, 'A');
+
+ p = memset (u2.buf + off, 'B', 5);
+ if (p != u2.buf + off) abort ();
+ check (off, 5, 'B');
+ }
+
+ /* len == 6 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 6);
+ if (p != u2.buf + off) abort ();
+ check (off, 6, '\0');
+
+ p = memset (u2.buf + off, A, 6);
+ if (p != u2.buf + off) abort ();
+ check (off, 6, 'A');
+
+ p = memset (u2.buf + off, 'B', 6);
+ if (p != u2.buf + off) abort ();
+ check (off, 6, 'B');
+ }
+
+ /* len == 7 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 7);
+ if (p != u2.buf + off) abort ();
+ check (off, 7, '\0');
+
+ p = memset (u2.buf + off, A, 7);
+ if (p != u2.buf + off) abort ();
+ check (off, 7, 'A');
+
+ p = memset (u2.buf + off, 'B', 7);
+ if (p != u2.buf + off) abort ();
+ check (off, 7, 'B');
+ }
+
+ /* len == 8 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 8);
+ if (p != u2.buf + off) abort ();
+ check (off, 8, '\0');
+
+ p = memset (u2.buf + off, A, 8);
+ if (p != u2.buf + off) abort ();
+ check (off, 8, 'A');
+
+ p = memset (u2.buf + off, 'B', 8);
+ if (p != u2.buf + off) abort ();
+ check (off, 8, 'B');
+ }
+
+ /* len == 9 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 9);
+ if (p != u2.buf + off) abort ();
+ check (off, 9, '\0');
+
+ p = memset (u2.buf + off, A, 9);
+ if (p != u2.buf + off) abort ();
+ check (off, 9, 'A');
+
+ p = memset (u2.buf + off, 'B', 9);
+ if (p != u2.buf + off) abort ();
+ check (off, 9, 'B');
+ }
+
+ /* len == 10 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 10);
+ if (p != u2.buf + off) abort ();
+ check (off, 10, '\0');
+
+ p = memset (u2.buf + off, A, 10);
+ if (p != u2.buf + off) abort ();
+ check (off, 10, 'A');
+
+ p = memset (u2.buf + off, 'B', 10);
+ if (p != u2.buf + off) abort ();
+ check (off, 10, 'B');
+ }
+
+ /* len == 11 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 11);
+ if (p != u2.buf + off) abort ();
+ check (off, 11, '\0');
+
+ p = memset (u2.buf + off, A, 11);
+ if (p != u2.buf + off) abort ();
+ check (off, 11, 'A');
+
+ p = memset (u2.buf + off, 'B', 11);
+ if (p != u2.buf + off) abort ();
+ check (off, 11, 'B');
+ }
+
+ /* len == 12 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 12);
+ if (p != u2.buf + off) abort ();
+ check (off, 12, '\0');
+
+ p = memset (u2.buf + off, A, 12);
+ if (p != u2.buf + off) abort ();
+ check (off, 12, 'A');
+
+ p = memset (u2.buf + off, 'B', 12);
+ if (p != u2.buf + off) abort ();
+ check (off, 12, 'B');
+ }
+
+ /* len == 13 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 13);
+ if (p != u2.buf + off) abort ();
+ check (off, 13, '\0');
+
+ p = memset (u2.buf + off, A, 13);
+ if (p != u2.buf + off) abort ();
+ check (off, 13, 'A');
+
+ p = memset (u2.buf + off, 'B', 13);
+ if (p != u2.buf + off) abort ();
+ check (off, 13, 'B');
+ }
+
+ /* len == 14 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 14);
+ if (p != u2.buf + off) abort ();
+ check (off, 14, '\0');
+
+ p = memset (u2.buf + off, A, 14);
+ if (p != u2.buf + off) abort ();
+ check (off, 14, 'A');
+
+ p = memset (u2.buf + off, 'B', 14);
+ if (p != u2.buf + off) abort ();
+ check (off, 14, 'B');
+ }
+
+ /* len == 15 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u2.buf + off, '\0', 15);
+ if (p != u2.buf + off) abort ();
+ check (off, 15, '\0');
+
+ p = memset (u2.buf + off, A, 15);
+ if (p != u2.buf + off) abort ();
+ check (off, 15, 'A');
+
+ p = memset (u2.buf + off, 'B', 15);
+ if (p != u2.buf + off) abort ();
+ check (off, 15, 'B');
+ }
+}
+
+void
+__attribute__((noinline))
+test6 (void)
+{
+ int len;
+ char *p;
+
+ /* off == 0 */
+ for (len = 0; len < MAX_COPY2; len++)
+ {
+ reset ();
+
+ p = memset (u2.buf, '\0', len);
+ if (p != u2.buf) abort ();
+ check (0, len, '\0');
+
+ p = memset (u2.buf, A, len);
+ if (p != u2.buf) abort ();
+ check (0, len, 'A');
+
+ p = memset (u2.buf, 'B', len);
+ if (p != u2.buf) abort ();
+ check (0, len, 'B');
+ }
+
+ /* off == 1 */
+ for (len = 0; len < MAX_COPY2; len++)
+ {
+ reset ();
+
+ p = memset (u2.buf+1, '\0', len);
+ if (p != u2.buf+1) abort ();
+ check (1, len, '\0');
+
+ p = memset (u2.buf+1, A, len);
+ if (p != u2.buf+1) abort ();
+ check (1, len, 'A');
+
+ p = memset (u2.buf+1, 'B', len);
+ if (p != u2.buf+1) abort ();
+ check (1, len, 'B');
+ }
+
+ /* off == 2 */
+ for (len = 0; len < MAX_COPY2; len++)
+ {
+ reset ();
+
+ p = memset (u2.buf+2, '\0', len);
+ if (p != u2.buf+2) abort ();
+ check (2, len, '\0');
+
+ p = memset (u2.buf+2, A, len);
+ if (p != u2.buf+2) abort ();
+ check (2, len, 'A');
+
+ p = memset (u2.buf+2, 'B', len);
+ if (p != u2.buf+2) abort ();
+ check (2, len, 'B');
+ }
+
+ /* off == 3 */
+ for (len = 0; len < MAX_COPY2; len++)
+ {
+ reset ();
+
+ p = memset (u2.buf+3, '\0', len);
+ if (p != u2.buf+3) abort ();
+ check (3, len, '\0');
+
+ p = memset (u2.buf+3, A, len);
+ if (p != u2.buf+3) abort ();
+ check (3, len, 'A');
+
+ p = memset (u2.buf+3, 'B', len);
+ if (p != u2.buf+3) abort ();
+ check (3, len, 'B');
+ }
+
+ /* off == 4 */
+ for (len = 0; len < MAX_COPY2; len++)
+ {
+ reset ();
+
+ p = memset (u2.buf+4, '\0', len);
+ if (p != u2.buf+4) abort ();
+ check (4, len, '\0');
+
+ p = memset (u2.buf+4, A, len);
+ if (p != u2.buf+4) abort ();
+ check (4, len, 'A');
+
+ p = memset (u2.buf+4, 'B', len);
+ if (p != u2.buf+4) abort ();
+ check (4, len, 'B');
+ }
+
+ /* off == 5 */
+ for (len = 0; len < MAX_COPY2; len++)
+ {
+ reset ();
+
+ p = memset (u2.buf+5, '\0', len);
+ if (p != u2.buf+5) abort ();
+ check (5, len, '\0');
+
+ p = memset (u2.buf+5, A, len);
+ if (p != u2.buf+5) abort ();
+ check (5, len, 'A');
+
+ p = memset (u2.buf+5, 'B', len);
+ if (p != u2.buf+5) abort ();
+ check (5, len, 'B');
+ }
+
+ /* off == 6 */
+ for (len = 0; len < MAX_COPY2; len++)
+ {
+ reset ();
+
+ p = memset (u2.buf+6, '\0', len);
+ if (p != u2.buf+6) abort ();
+ check (6, len, '\0');
+
+ p = memset (u2.buf+6, A, len);
+ if (p != u2.buf+6) abort ();
+ check (6, len, 'A');
+
+ p = memset (u2.buf+6, 'B', len);
+ if (p != u2.buf+6) abort ();
+ check (6, len, 'B');
+ }
+
+ /* off == 7 */
+ for (len = 0; len < MAX_COPY2; len++)
+ {
+ reset ();
+
+ p = memset (u2.buf+7, '\0', len);
+ if (p != u2.buf+7) abort ();
+ check (7, len, '\0');
+
+ p = memset (u2.buf+7, A, len);
+ if (p != u2.buf+7) abort ();
+ check (7, len, 'A');
+
+ p = memset (u2.buf+7, 'B', len);
+ if (p != u2.buf+7) abort ();
+ check (7, len, 'B');
+ }
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (l1) : "0" (l1));
+ s4 = buffer;
+ test1 ();
+ test2 ();
+ test3 ();
+ test4 ();
+ test5 ();
+ test6 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test3 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/memset.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/memset.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation.
+
+ Ensure that builtin memset operations for constant length and
+ non-constant assigned value don't cause compiler problems.
+
+ Written by Roger Sayle, 21 April 2002. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern void *memset (void *, int, size_t);
+
+char buffer[32];
+int argc = 1;
+
+void
+main_test (void)
+{
+ memset (buffer, argc, 0);
+ memset (buffer, argc, 1);
+ memset (buffer, argc, 2);
+ memset (buffer, argc, 3);
+ memset (buffer, argc, 4);
+ memset (buffer, argc, 5);
+ memset (buffer, argc, 6);
+ memset (buffer, argc, 7);
+ memset (buffer, argc, 8);
+ memset (buffer, argc, 9);
+ memset (buffer, argc, 10);
+ memset (buffer, argc, 11);
+ memset (buffer, argc, 12);
+ memset (buffer, argc, 13);
+ memset (buffer, argc, 14);
+ memset (buffer, argc, 15);
+ memset (buffer, argc, 16);
+ memset (buffer, argc, 17);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr22237-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr22237-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr22237-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr22237-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+extern void abort (void);
+
+void *
+memcpy (void *dst, const void *src, __SIZE_TYPE__ n)
+{
+ const char *srcp;
+ char *dstp;
+
+ srcp = src;
+ dstp = dst;
+
+ if (dst < src)
+ {
+ if (dst + n > src)
+ abort ();
+ }
+ else
+ {
+ if (src + n > dst)
+ abort ();
+ }
+
+ while (n-- != 0)
+ *dstp++ = *srcp++;
+
+ return dst;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr22237.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr22237.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr22237.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr22237.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,44 @@
+extern void abort (void);
+extern void exit (int);
+struct s { unsigned char a[256]; };
+union u { struct { struct s b; int c; } d; struct { int c; struct s b; } e; };
+static union u v;
+static union u v0;
+static struct s *p = &v.d.b;
+static struct s *q = &v.e.b;
+
+static inline struct s rp (void) { return *p; }
+static inline struct s rq (void) { return *q; }
+static void pq (void) { *p = rq(); }
+static void qp (void) { *q = rp(); }
+
+static void
+init (struct s *sp)
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ sp->a[i] = i;
+}
+
+static void
+check (struct s *sp)
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (sp->a[i] != i)
+ abort ();
+}
+
+void
+main_test (void)
+{
+ v = v0;
+ init (p);
+ qp ();
+ check (q);
+ v = v0;
+ init (q);
+ pq ();
+ check (p);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,67 @@
+/* PR middle-end/23484 */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen (const char *);
+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 int snprintf (char *, size_t, const char *, ...);
+extern int memcmp (const void *, const void *, size_t);
+
+#include "chk.h"
+
+static char data[8] = "ABCDEFG";
+
+int l1;
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ char buf[8];
+
+ /* All the checking calls in this routine have a maximum length, so
+ object size checking should be done at compile time if optimizing. */
+ chk_calls = 0;
+
+ memset (buf, 'I', sizeof (buf));
+ if (memcpy (buf, data, l1 ? sizeof (buf) : 4) != buf
+ || memcmp (buf, "ABCDIIII", 8))
+ abort ();
+
+ memset (buf, 'J', sizeof (buf));
+ if (mempcpy (buf, data, l1 ? sizeof (buf) : 4) != buf + 4
+ || memcmp (buf, "ABCDJJJJ", 8))
+ abort ();
+
+ memset (buf, 'K', sizeof (buf));
+ if (memmove (buf, data, l1 ? sizeof (buf) : 4) != buf
+ || memcmp (buf, "ABCDKKKK", 8))
+ abort ();
+
+ memset (buf, 'L', sizeof (buf));
+#if(__SIZEOF_INT__ >= 4)
+ if (snprintf (buf, l1 ? sizeof (buf) : 4, "%d", l1 + 65536) != 5
+ || memcmp (buf, "655\0LLLL", 8))
+ abort ();
+#else
+ if (snprintf (buf, l1 ? sizeof (buf) : 4, "%d", l1 + 32700) != 5
+ || memcmp (buf, "327\0LLLL", 8))
+ abort ();
+#endif
+
+ if (chk_calls)
+ abort ();
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (l1) : "0" (l1));
+ test1 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/pr23484-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,7 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/printf-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/printf-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/printf-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/printf-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/printf.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/printf.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/printf.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/printf.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/printf.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,52 @@
+/* Copyright (C) 2000 Free Software Foundation.
+
+ Ensure all expected transformations of builtin printf occur and
+ that we honor side effects in the arguments.
+
+ Written by Kaveh R. Ghazi, 12/4/2000. */
+
+extern int printf (const char *, ...);
+extern int printf_unlocked (const char *, ...);
+extern void abort(void);
+
+void
+main_test (void)
+{
+ const char *const s1 = "hello world";
+ const char *const s2[] = { s1, 0 }, *const*s3;
+
+ printf ("%s\n", "hello");
+ printf ("%s\n", *s2);
+ s3 = s2;
+ printf ("%s\n", *s3++);
+ if (s3 != s2+1 || *s3 != 0)
+ abort();
+
+ printf ("%c", '\n');
+ printf ("%c", **s2);
+ s3 = s2;
+ printf ("%c", **s3++);
+ if (s3 != s2+1 || *s3 != 0)
+ abort();
+
+ printf ("");
+ printf ("%s", "");
+ printf ("\n");
+ printf ("%s", "\n");
+ printf ("hello world\n");
+ printf ("%s", "hello world\n");
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ __builtin_printf ("%s\n", "hello");
+ /* These builtin stubs are called by __builtin_printf, ensure their
+ prototypes are set correctly too. */
+ __builtin_putchar ('\n');
+ __builtin_puts ("hello");
+ /* Check the unlocked style, these evaluate to nothing to avoid
+ problems on systems without the unlocked functions. */
+ printf_unlocked ("");
+ __builtin_printf_unlocked ("");
+ printf_unlocked ("%s", "");
+ __builtin_printf_unlocked ("%s", "");
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,220 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __snprintf_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern char *strcpy (char *, const char *);
+extern int memcmp (const void *, const void *, size_t);
+extern void *memset (void *, int, size_t);
+extern int sprintf (char *, const char *, ...);
+extern int snprintf (char *, size_t, const char *, ...);
+
+#include "chk.h"
+
+const char s1[] = "123";
+char p[32] = "";
+char *s2 = "defg";
+char *s3 = "FGH";
+char *s4;
+size_t l1 = 1;
+static char buffer[32];
+char * volatile ptr = "barf"; /* prevent constant propagation to happen when whole program assumptions are made. */
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ chk_calls = 0;
+ /* snprintf_disallowed = 1; */
+
+ memset (buffer, 'A', 32);
+ snprintf (buffer, 4, "foo");
+ if (memcmp (buffer, "foo", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (snprintf (buffer, 4, "foo bar") != 7)
+ abort ();
+ if (memcmp (buffer, "foo", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ snprintf (buffer, 32, "%s", "bar");
+ if (memcmp (buffer, "bar", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (snprintf (buffer, 21, "%s", "bar") != 3)
+ abort ();
+ if (memcmp (buffer, "bar", 4) || buffer[4] != 'A')
+ abort ();
+
+ snprintf_disallowed = 0;
+
+ memset (buffer, 'A', 32);
+ if (snprintf (buffer, 4, "%d%d%d", (int) l1, (int) l1 + 1, (int) l1 + 12)
+ != 4)
+ abort ();
+ if (memcmp (buffer, "121", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (snprintf (buffer, 32, "%d%d%d", (int) l1, (int) l1 + 1, (int) l1 + 12)
+ != 4)
+ abort ();
+ if (memcmp (buffer, "1213", 5) || buffer[5] != 'A')
+ abort ();
+
+ if (chk_calls)
+ abort ();
+
+ memset (buffer, 'A', 32);
+ snprintf (buffer, strlen (ptr) + 1, "%s", ptr);
+ if (memcmp (buffer, "barf", 5) || buffer[5] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ snprintf (buffer, l1 + 31, "%d - %c", (int) l1 + 27, *ptr);
+ if (memcmp (buffer, "28 - b\0AAAAA", 12))
+ abort ();
+
+ if (chk_calls != 2)
+ abort ();
+ chk_calls = 0;
+
+ memset (s4, 'A', 32);
+ snprintf (s4, l1 + 6, "%d - %c", (int) l1 - 17, ptr[1]);
+ if (memcmp (s4, "-16 - \0AAA", 10))
+ abort ();
+ if (chk_calls)
+ abort ();
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test2 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+
+ /* The following calls should do runtime checking
+ - length is not known, but destination is. */
+ chk_calls = 0;
+ snprintf (a.buf1 + 2, l1, "%s", s3 + 3);
+ snprintf (r, l1 + 4, "%s%c", s3 + 3, s3[3]);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ snprintf (r, strlen (s2) - 2, "%c %s", s2[2], s2 + 4);
+ snprintf (r + 2, l1, s3 + 3);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ snprintf (r, l1, s2 + 4);
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known source length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ /* snprintf_disallowed = 1; */
+ snprintf (a.buf1 + 2, 4, "");
+ snprintf (r, 1, "a");
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ snprintf (r, 3, "%s", s1 + 1);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ snprintf (r, 1, "%s", "");
+ snprintf (r, 0, "%s", "");
+ snprintf_disallowed = 0;
+ /* Unknown destination and source, no checking. */
+ snprintf (s4, l1 + 31, "%s %d", s3, 0);
+ if (chk_calls)
+ abort ();
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ snprintf (&a.buf2[9], l1 + 1, "%c%s", s2[3], s2 + 4);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ snprintf (&a.buf2[7], l1 + 30, "%s%c", s3 + strlen (s3) - 2, *s3);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ snprintf (&a.buf2[7], l1 + 3, "%d", (int) l1 + 9999);
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ snprintf (&buf3[19], 2, "a");
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ snprintf (&buf3[17], 4, "a");
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ snprintf (&buf3[17], 4, "%s", "abc");
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (s2) : "0" (s2));
+ __asm ("" : "=r" (s3) : "0" (s3));
+ __asm ("" : "=r" (l1) : "0" (l1));
+ s4 = p;
+ test1 ();
+ test2 ();
+ test3 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/snprintf-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test3 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,197 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __sprintf_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern char *strcpy (char *, const char *);
+extern int memcmp (const void *, const void *, size_t);
+extern void *memset (void *, int, size_t);
+extern int sprintf (char *, const char *, ...);
+
+#include "chk.h"
+
+LOCAL const char s1[] = "123";
+char p[32] = "";
+char *s2 = "defg";
+char *s3 = "FGH";
+char *s4;
+size_t l1 = 1;
+static char buffer[32];
+char * volatile ptr = "barf"; /* prevent constant propagation to happen when whole program assumptions are made. */
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ chk_calls = 0;
+ sprintf_disallowed = 1;
+
+ memset (buffer, 'A', 32);
+ sprintf (buffer, "foo");
+ if (memcmp (buffer, "foo", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (sprintf (buffer, "foo") != 3)
+ abort ();
+ if (memcmp (buffer, "foo", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ sprintf (buffer, "%s", "bar");
+ if (memcmp (buffer, "bar", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (sprintf (buffer, "%s", "bar") != 3)
+ abort ();
+ if (memcmp (buffer, "bar", 4) || buffer[4] != 'A')
+ abort ();
+
+ if (chk_calls)
+ abort ();
+ sprintf_disallowed = 0;
+
+ memset (buffer, 'A', 32);
+ sprintf (buffer, "%s", ptr);
+ if (memcmp (buffer, "barf", 5) || buffer[5] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ sprintf (buffer, "%d - %c", (int) l1 + 27, *ptr);
+ if (memcmp (buffer, "28 - b\0AAAAA", 12))
+ abort ();
+
+ if (chk_calls != 2)
+ abort ();
+ chk_calls = 0;
+
+ sprintf (s4, "%d - %c", (int) l1 - 17, ptr[1]);
+ if (memcmp (s4, "-16 - a", 8))
+ abort ();
+ if (chk_calls)
+ abort ();
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test2 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+
+ /* The following calls should do runtime checking
+ - source length is not known, but destination is. */
+ chk_calls = 0;
+ sprintf (a.buf1 + 2, "%s", s3 + 3);
+ sprintf (r, "%s%c", s3 + 3, s3[3]);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ sprintf (r, "%c %s", s2[2], s2 + 4);
+ sprintf (r + 2, s3 + 3);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ sprintf (r, s2 + 4);
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known source length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ sprintf_disallowed = 1;
+ sprintf (a.buf1 + 2, "");
+ sprintf (r, "a");
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ sprintf (r, "%s", s1 + 1);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ sprintf (r, "%s", "");
+ sprintf_disallowed = 0;
+ /* Unknown destination and source, no checking. */
+ sprintf (s4, "%s %d", s3, 0);
+ if (chk_calls)
+ abort ();
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ sprintf (&a.buf2[9], "%c%s", s2[3], s2 + 4);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ sprintf (&a.buf2[7], "%s%c", s3 + strlen (s3) - 2, *s3);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ sprintf (&a.buf2[7], "%d", (int) l1 + 9999);
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ sprintf (&buf3[19], "a");
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ sprintf (&buf3[17], "%s", "abc");
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (s2) : "0" (s2));
+ __asm ("" : "=r" (s3) : "0" (s3));
+ __asm ("" : "=r" (l1) : "0" (l1));
+ s4 = p;
+ test1 ();
+ test2 ();
+ test3 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test3 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/sprintf.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/sprintf.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,71 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Test sprintf optimizations don't break anything and return the
+ correct results.
+
+ Written by Roger Sayle, June 22, 2003. */
+
+static char buffer[32];
+
+extern void abort ();
+typedef __SIZE_TYPE__ size_t;
+extern int sprintf(char*, const char*, ...);
+extern void *memset(void*, int, size_t);
+extern int memcmp(const void*, const void*, size_t);
+
+void test1()
+{
+ sprintf(buffer,"foo");
+}
+
+int test2()
+{
+ return sprintf(buffer,"foo");
+}
+
+void test3()
+{
+ sprintf(buffer,"%s","bar");
+}
+
+int test4()
+{
+ return sprintf(buffer,"%s","bar");
+}
+
+void test5(char *ptr)
+{
+ sprintf(buffer,"%s",ptr);
+}
+
+
+void
+main_test (void)
+{
+ memset (buffer, 'A', 32);
+ test1 ();
+ if (memcmp(buffer, "foo", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (test2 () != 3)
+ abort ();
+ if (memcmp(buffer, "foo", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ test3 ();
+ if (memcmp(buffer, "bar", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (test4 () != 3)
+ abort ();
+ if (memcmp(buffer, "bar", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ test5 ("barf");
+ if (memcmp(buffer, "barf", 5) || buffer[5] != 'A')
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,265 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __stpcpy_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern char *stpcpy (char *, const char *);
+extern int memcmp (const void *, const void *, size_t);
+
+#include "chk.h"
+
+LOCAL const char s1[] = "123";
+char p[32] = "";
+char *s2 = "defg";
+char *s3 = "FGH";
+char *s4;
+size_t l1 = 1;
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ int i = 8;
+
+#if defined __i386__ || defined __x86_64__
+ /* The functions below might not be optimized into direct stores on all
+ arches. It depends on how many instructions would be generated and
+ what limits the architecture chooses in STORE_BY_PIECES_P. */
+ stpcpy_disallowed = 1;
+#endif
+ if (stpcpy (p, "abcde") != p + 5 || memcmp (p, "abcde", 6))
+ abort ();
+ if (stpcpy (p + 16, "vwxyz" + 1) != p + 16 + 4 || memcmp (p + 16, "wxyz", 5))
+ abort ();
+ if (stpcpy (p + 1, "") != p + 1 + 0 || memcmp (p, "a\0cde", 6))
+ abort ();
+ if (stpcpy (p + 3, "fghij") != p + 3 + 5 || memcmp (p, "a\0cfghij", 9))
+ abort ();
+
+ if (stpcpy ((i++, p + 20 + 1), "23") != (p + 20 + 1 + 2)
+ || i != 9 || memcmp (p + 19, "z\0""23\0", 5))
+ abort ();
+
+ if (stpcpy (stpcpy (p, "ABCD"), "EFG") != p + 7 || memcmp (p, "ABCDEFG", 8))
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_stpcpy (p, "abcde") != p + 5 || memcmp (p, "abcde", 6))
+ abort ();
+
+ /* If return value of stpcpy is ignored, it should be optimized into
+ strcpy call. */
+ stpcpy_disallowed = 1;
+ stpcpy (p + 1, "abcd");
+ stpcpy_disallowed = 0;
+ if (memcmp (p, "aabcd", 6))
+ abort ();
+
+ if (chk_calls)
+ abort ();
+
+ chk_calls = 0;
+ strcpy_disallowed = 1;
+ if (stpcpy (p, s2) != p + 4 || memcmp (p, "defg\0", 6))
+ abort ();
+ strcpy_disallowed = 0;
+ stpcpy_disallowed = 1;
+ stpcpy (p + 2, s3);
+ stpcpy_disallowed = 0;
+ if (memcmp (p, "deFGH", 6))
+ abort ();
+ if (chk_calls != 2)
+ abort ();
+}
+
+#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;
+
+volatile char *vx;
+
+void
+__attribute__((noinline))
+test2 (void)
+{
+ 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 = stpcpy (u1.buf + off1, u2.buf + off2);
+ if (p != u1.buf + off1 + len)
+ 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 ();
+ }
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+ const char *l;
+
+ /* The following calls should do runtime checking
+ - source length is not known, but destination is. */
+ chk_calls = 0;
+ vx = stpcpy (a.buf1 + 2, s3 + 3);
+ vx = stpcpy (r, s3 + 2);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ vx = stpcpy (r, s2 + 2);
+ vx = stpcpy (r + 2, s3 + 3);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ vx = stpcpy (r, s2 + 4);
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known source length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ vx = stpcpy (a.buf1 + 2, "");
+ vx = stpcpy (r, "a");
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ vx = stpcpy (r, s1 + 1);
+ r = buf3;
+ l = "abc";
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1], l = "e";
+ else if (i == l1)
+ r = &a.buf2[7], l = "gh";
+ else if (i == l1 + 1)
+ r = &buf3[5], l = "jkl";
+ else if (i == l1 + 2)
+ r = &a.buf1[9], l = "";
+ }
+ vx = stpcpy (r, "");
+ /* Here, strlen (l) + 1 is known to be at most 4 and
+ __builtin_object_size (&buf3[16], 0) is 4, so this doesn't need
+ runtime checking. */
+ vx = stpcpy (&buf3[16], l);
+ /* Unknown destination and source, no checking. */
+ vx = stpcpy (s4, s3);
+ stpcpy (s4 + 4, s3);
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test4 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ vx = stpcpy (&a.buf2[9], s2 + 3);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ vx = stpcpy (&a.buf2[7], s3 + strlen (s3) - 3);
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ vx = stpcpy (&buf3[19], "a");
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (s2) : "0" (s2));
+ __asm ("" : "=r" (s3) : "0" (s3));
+ __asm ("" : "=r" (l1) : "0" (l1));
+ test1 ();
+ s4 = p;
+ test2 ();
+ test3 ();
+ test4 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpcpy-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test4 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,261 @@
+/* Copyright (C) 2004, 2005, 2011 Free Software Foundation.
+
+ Ensure builtin __stpncpy_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern char *stpncpy (char *, const char *, size_t);
+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);
+extern void *memset (void *, int, size_t);
+
+#include "chk.h"
+
+const char s1[] = "123";
+char p[32] = "";
+char * volatile s2 = "defg"; /* prevent constant propagation to happen when whole program assumptions are made. */
+char * volatile s3 = "FGH"; /* prevent constant propagation to happen when whole program assumptions are made. */
+char *s4;
+volatile size_t l1 = 1; /* prevent constant propagation to happen when whole program assumptions are made. */
+int i;
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ const char *const src = "hello world";
+ const char *src2;
+ char dst[64], *dst2;
+
+ chk_calls = 0;
+
+ memset (dst, 0, sizeof (dst));
+ if (stpncpy (dst, src, 4) != dst+4 || strncmp (dst, src, 4))
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ if (stpncpy (dst+16, src, 4) != dst+20 || strncmp (dst+16, src, 4))
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ if (stpncpy (dst+32, src+5, 4) != dst+36 || strncmp (dst+32, src+5, 4))
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ dst2 = dst;
+ if (stpncpy (++dst2, src+5, 4) != dst+5 || strncmp (dst2, src+5, 4)
+ || dst2 != dst+1)
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ if (stpncpy (dst, src, 0) != dst || strcmp (dst, ""))
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ dst2 = dst; src2 = src;
+ if (stpncpy (++dst2, ++src2, 0) != dst+1 || strcmp (dst2, "")
+ || dst2 != dst+1 || src2 != src+1)
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ dst2 = dst; src2 = src;
+ if (stpncpy (++dst2+5, ++src2+5, 0) != dst+6 || strcmp (dst2+5, "")
+ || dst2 != dst+1 || src2 != src+1)
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ if (stpncpy (dst, src, 12) != dst+11 || strcmp (dst, src))
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ memset (dst, 0, sizeof (dst));
+ if (__builtin_stpncpy (dst, src, 4) != dst+4 || strncmp (dst, src, 4))
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ if (stpncpy (dst, i++ ? "xfoo" + 1 : "bar", 4) != dst+3
+ || strcmp (dst, "bar")
+ || i != 1)
+ abort ();
+
+ /* If return value of stpncpy is ignored, it should be optimized into
+ stpncpy call. */
+ stpncpy_disallowed = 1;
+ stpncpy (dst + 1, src, 4);
+ stpncpy_disallowed = 0;
+ if (strncmp (dst + 1, src, 4))
+ abort ();
+
+ if (chk_calls)
+ abort ();
+}
+
+void
+__attribute__((noinline))
+test2 (void)
+{
+ chk_calls = 0;
+
+ /* No runtime checking should be done here, both destination
+ and length are unknown. */
+ size_t cpy_length = l1 < 4 ? l1 + 1 : 4;
+ if (stpncpy (s4, "abcd", l1 + 1) != s4 + cpy_length || strncmp (s4, "abcd", cpy_length))
+ abort ();
+
+ if (chk_calls)
+ abort ();
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+ const char *l;
+ size_t l2;
+
+ /* The following calls should do runtime checking
+ - source length is not known, but destination is.
+ The returned value is checked so that stpncpy calls
+ are not rewritten to strncpy calls. */
+ chk_calls = 0;
+ if (!stpncpy (a.buf1 + 2, s3 + 3, l1))
+ abort();
+ if (!stpncpy (r, s3 + 2, l1 + 2))
+ abort();
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ if (!stpncpy (r, s2 + 2, l1 + 2))
+ abort();
+ if (!stpncpy (r + 2, s3 + 3, l1))
+ abort();
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ if (!stpncpy (r, s2 + 4, l1))
+ abort();
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ if (!stpncpy (a.buf1 + 2, "", 3))
+ abort ();
+ if (!stpncpy (a.buf1 + 2, "", 0))
+ abort ();
+ if (!stpncpy (r, "a", 1))
+ abort ();
+ if (!stpncpy (r, "a", 3))
+ abort ();
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ if (!stpncpy (r, s1 + 1, 3))
+ abort ();
+ if (!stpncpy (r, s1 + 1, 2))
+ abort ();
+ r = buf3;
+ l = "abc";
+ l2 = 4;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1], l = "e", l2 = 2;
+ else if (i == l1)
+ r = &a.buf2[7], l = "gh", l2 = 3;
+ else if (i == l1 + 1)
+ r = &buf3[5], l = "jkl", l2 = 4;
+ else if (i == l1 + 2)
+ r = &a.buf1[9], l = "", l2 = 1;
+ }
+ if (!stpncpy (r, "", 1))
+ abort ();
+ /* Here, strlen (l) + 1 is known to be at most 4 and
+ __builtin_object_size (&buf3[16], 0) is 4, so this doesn't need
+ runtime checking. */
+ if (!stpncpy (&buf3[16], l, l2))
+ abort ();
+ if (!stpncpy (&buf3[15], "abc", l2))
+ abort ();
+ if (!stpncpy (&buf3[10], "fghij", l2))
+ abort ();
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test4 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ if (stpncpy (&a.buf2[9], s2 + 4, l1 + 1))
+ // returned value used to prevent stpncpy calls
+ // to be rewritten in strncpy calls
+ i++;
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ if (stpncpy (&a.buf2[7], s3, l1 + 4))
+ i++;
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ if (stpncpy (&buf3[19], "abc", 2))
+ i++;
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ if (stpncpy (&buf3[18], "", 3))
+ i++;
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (s2) : "0" (s2));
+ __asm ("" : "=r" (s3) : "0" (s3));
+ __asm ("" : "=r" (l1) : "0" (l1));
+ test1 ();
+
+ s4 = p;
+ test2 ();
+ test3 ();
+ test4 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/stpncpy-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test4 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,204 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __strcat_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern char *strcat (char *, const char *);
+extern int memcmp (const void *, const void *, size_t);
+extern char *strcpy (char *, const char *);
+extern int strcmp (const char *, const char *);
+extern void *memset (void *, int, size_t);
+#define RESET_DST_WITH(FILLER) \
+ do { memset (dst, 'X', sizeof (dst)); strcpy (dst, (FILLER)); } while (0)
+
+#include "chk.h"
+
+const char s1[] = "123";
+char p[32] = "";
+char *s2 = "defg";
+char *s3 = "FGH";
+char *s4;
+size_t l1 = 1;
+char *s5;
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ const char *const x1 = "hello world";
+ const char *const x2 = "";
+ char dst[64], *d2;
+
+ chk_calls = 0;
+ strcat_disallowed = 1;
+ /* Following strcat calls should be optimized out at compile time. */
+ RESET_DST_WITH (x1);
+ if (strcat (dst, "") != dst || strcmp (dst, x1))
+ abort ();
+ RESET_DST_WITH (x1);
+ if (strcat (dst, x2) != dst || strcmp (dst, x1))
+ abort ();
+ RESET_DST_WITH (x1); d2 = dst;
+ if (strcat (++d2, x2) != dst+1 || d2 != dst+1 || strcmp (dst, x1))
+ abort ();
+ RESET_DST_WITH (x1); d2 = dst;
+ if (strcat (++d2+5, x2) != dst+6 || d2 != dst+1 || strcmp (dst, x1))
+ abort ();
+ RESET_DST_WITH (x1); d2 = dst;
+ if (strcat (++d2+5, x1+11) != dst+6 || d2 != dst+1 || strcmp (dst, x1))
+ abort ();
+ if (chk_calls)
+ abort ();
+ strcat_disallowed = 0;
+
+ RESET_DST_WITH (x1);
+ if (strcat (dst, " 1111") != dst
+ || memcmp (dst, "hello world 1111\0XXX", 20))
+ abort ();
+
+ RESET_DST_WITH (x1);
+ if (strcat (dst+5, " 2222") != dst+5
+ || memcmp (dst, "hello world 2222\0XXX", 20))
+ abort ();
+
+ RESET_DST_WITH (x1); d2 = dst;
+ if (strcat (++d2+5, " 3333") != dst+6 || d2 != dst+1
+ || memcmp (dst, "hello world 3333\0XXX", 20))
+ abort ();
+
+ RESET_DST_WITH (x1);
+ strcat (strcat (strcat (strcat (strcat (strcat (dst, ": this "), ""),
+ "is "), "a "), "test"), ".");
+ if (memcmp (dst, "hello world: this is a test.\0X", 30))
+ abort ();
+
+ chk_calls = 0;
+ strcat_disallowed = 1;
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ RESET_DST_WITH (x1);
+ if (__builtin_strcat (dst, "") != dst || strcmp (dst, x1))
+ abort ();
+ if (chk_calls)
+ abort ();
+ strcat_disallowed = 0;
+}
+
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test2 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+
+ /* The following calls should do runtime checking
+ - source length is not known, but destination is. */
+ memset (&a, '\0', sizeof (a));
+ s5 = (char *) &a;
+ __asm __volatile ("" : : "r" (s5) : "memory");
+ chk_calls = 0;
+ strcat (a.buf1 + 2, s3 + 3);
+ strcat (r, s3 + 2);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ memset (r, '\0', 3);
+ __asm __volatile ("" : : "r" (r) : "memory");
+ strcat (r, s2 + 2);
+ strcat (r + 2, s3 + 3);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ strcat (r, s2 + 4);
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known source length,
+ but we don't know the length of dest string, so runtime checking
+ is needed too. */
+ memset (&a, '\0', sizeof (a));
+ chk_calls = 0;
+ s5 = (char *) &a;
+ __asm __volatile ("" : : "r" (s5) : "memory");
+ strcat (a.buf1 + 2, "a");
+ strcat (r, "");
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ memset (r, '\0', 3);
+ __asm __volatile ("" : : "r" (r) : "memory");
+ strcat (r, s1 + 1);
+ if (chk_calls != 2)
+ abort ();
+ chk_calls = 0;
+ /* Unknown destination and source, no checking. */
+ strcat (s4, s3);
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ memset (&a, '\0', sizeof (a));
+ memset (buf3, '\0', sizeof (buf3));
+ s5 = (char *) &a;
+ __asm __volatile ("" : : "r" (s5) : "memory");
+ s5 = buf3;
+ __asm __volatile ("" : : "r" (s5) : "memory");
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strcat (&a.buf2[9], s2 + 3);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strcat (&a.buf2[7], s3 + strlen (s3) - 3);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strcat (&buf3[19], "a");
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (s2) : "0" (s2));
+ __asm ("" : "=r" (s3) : "0" (s3));
+ __asm ("" : "=r" (l1) : "0" (l1));
+ s4 = p;
+ test1 ();
+ memset (p, '\0', sizeof (p));
+ test2 ();
+ test3 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test3 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strcat.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcat.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,81 @@
+/* Copyright (C) 2000, 2003 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strcat occur and
+ perform correctly.
+
+ Written by Kaveh R. Ghazi, 11/27/2000. */
+
+extern int inside_main;
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern char *strcat (char *, const char *);
+extern char *strcpy (char *, const char *);
+extern void *memset (void *, int, size_t);
+extern int memcmp (const void *, const void *, size_t);
+#define RESET_DST_WITH(FILLER) \
+ do { memset (dst, 'X', sizeof (dst)); strcpy (dst, (FILLER)); } while (0)
+
+void main_test (void)
+{
+ const char *const s1 = "hello world";
+ const char *const s2 = "";
+ char dst[64], *d2;
+
+ RESET_DST_WITH (s1);
+ if (strcat (dst, "") != dst || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+ RESET_DST_WITH (s1);
+ if (strcat (dst, s2) != dst || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strcat (++d2, s2) != dst+1 || d2 != dst+1
+ || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strcat (++d2+5, s2) != dst+6 || d2 != dst+1
+ || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strcat (++d2+5, s1+11) != dst+6 || d2 != dst+1
+ || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+
+#ifndef __OPTIMIZE_SIZE__
+# if !defined __i386__ && !defined __x86_64__
+ /* The functions below might not be optimized into direct stores on all
+ arches. It depends on how many instructions would be generated and
+ what limits the architecture chooses in STORE_BY_PIECES_P. */
+ inside_main = 0;
+# endif
+
+ RESET_DST_WITH (s1);
+ if (strcat (dst, " 1111") != dst
+ || memcmp (dst, "hello world 1111\0XXX", 20))
+ abort();
+
+ RESET_DST_WITH (s1);
+ if (strcat (dst+5, " 2222") != dst+5
+ || memcmp (dst, "hello world 2222\0XXX", 20))
+ abort();
+
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strcat (++d2+5, " 3333") != dst+6 || d2 != dst+1
+ || memcmp (dst, "hello world 3333\0XXX", 20))
+ abort();
+
+ RESET_DST_WITH (s1);
+ strcat (strcat (strcat (strcat (strcat (strcat (dst, ": this "), ""),
+ "is "), "a "), "test"), ".");
+ if (memcmp (dst, "hello world: this is a test.\0X", 30))
+ abort();
+
+ /* Set inside_main again. */
+ inside_main = 1;
+#endif
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ RESET_DST_WITH (s1);
+ if (__builtin_strcat (dst, "") != dst || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strchr-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strchr-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strchr-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strchr-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,8 @@
+#include "lib/strchr.c"
+#ifdef __vxworks
+/* The RTP C library uses bzero, bfill and bcopy, all of which are defined
+ in the same file as index. */
+#include "lib/bzero.c"
+#include "lib/bfill.c"
+#include "lib/memmove.c"
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strchr.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strchr.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strchr.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strchr.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+/* Copyright (C) 2000, 2003 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strchr and index
+ occur and perform correctly.
+
+ Written by Jakub Jelinek, 11/7/2000. */
+
+extern void abort (void);
+extern char *strchr (const char *, int);
+extern char *index (const char *, int);
+
+void
+main_test (void)
+{
+ const char *const foo = "hello world";
+
+ if (strchr (foo, 'x'))
+ abort ();
+ if (strchr (foo, 'o') != foo + 4)
+ abort ();
+ if (strchr (foo + 5, 'o') != foo + 7)
+ abort ();
+ if (strchr (foo, '\0') != foo + 11)
+ abort ();
+ /* Test only one instance of index since the code path is the same
+ as that of strchr. */
+ if (index ("hello", 'z') != 0)
+ abort ();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strchr (foo, 'o') != foo + 4)
+ abort ();
+ if (__builtin_index (foo, 'o') != foo + 4)
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcmp-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcmp-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcmp-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcmp-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strcmp.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcmp.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcmp.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcmp.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcmp.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,48 @@
+/* Copyright (C) 2000, 2003, 2004 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strcmp
+ occur and perform correctly.
+
+ Written by Jakub Jelinek, 11/7/2000. */
+
+extern void abort (void);
+extern int strcmp (const char *, const char *);
+
+int x = 7;
+char *bar = "hi world";
+
+void
+main_test (void)
+{
+ const char *const foo = "hello world";
+
+ if (strcmp (foo, "hello") <= 0)
+ abort ();
+ if (strcmp (foo + 2, "llo") <= 0)
+ abort ();
+ if (strcmp (foo, foo) != 0)
+ abort ();
+ if (strcmp (foo, "hello world ") >= 0)
+ abort ();
+ if (strcmp (foo + 10, "dx") >= 0)
+ abort ();
+ if (strcmp (10 + foo, "dx") >= 0)
+ abort ();
+ if (strcmp (bar, "") <= 0)
+ abort ();
+ if (strcmp ("", bar) >= 0)
+ abort ();
+ if (strcmp (bar+8, "") != 0)
+ abort ();
+ if (strcmp ("", bar+8) != 0)
+ abort ();
+ if (strcmp (bar+(--x), "") <= 0 || x != 6)
+ abort ();
+ if (strcmp ("", bar+(++x)) >= 0 || x != 7)
+ abort ();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strcmp (foo, "hello") <= 0)
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-2-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-2-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-2-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-2-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strcpy.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,47 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Ensure builtin strcpy is optimized into memcpy
+ even when there is more than one possible string literal
+ passed to it, but all string literals passed to it
+ have equal length.
+
+ Written by Jakub Jelinek, 9/15/2004. */
+
+extern void abort (void);
+extern char *strcpy (char *, const char *);
+typedef __SIZE_TYPE__ size_t;
+extern void *memcpy (void *, const void *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+
+char buf[32], *p;
+int i;
+
+char *
+__attribute__((noinline))
+test (void)
+{
+ int j;
+ const char *q = "abcdefg";
+ for (j = 0; j < 3; ++j)
+ {
+ if (j == i)
+ q = "bcdefgh";
+ else if (j == i + 1)
+ q = "cdefghi";
+ else if (j == i + 2)
+ q = "defghij";
+ }
+ p = strcpy (buf, q);
+ return strcpy (buf + 16, q);
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE_SIZE__
+ /* For -Os, strcpy above is not replaced with
+ memcpy (buf, q, 8);, as that is larger. */
+ if (test () != buf + 16 || p != buf)
+ abort ();
+#endif
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,234 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __strcpy_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern char *strcpy (char *, const char *);
+extern int memcmp (const void *, const void *, size_t);
+
+#include "chk.h"
+
+LOCAL const char s1[] = "123";
+char p[32] = "";
+char *s2 = "defg";
+char *s3 = "FGH";
+char *s4;
+size_t l1 = 1;
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ chk_calls = 0;
+#ifndef __OPTIMIZE_SIZE__
+ strcpy_disallowed = 1;
+#else
+ strcpy_disallowed = 0;
+#endif
+
+ if (strcpy (p, "abcde") != p || memcmp (p, "abcde", 6))
+ abort ();
+ if (strcpy (p + 16, "vwxyz" + 1) != p + 16 || memcmp (p + 16, "wxyz", 5))
+ abort ();
+ if (strcpy (p + 1, "") != p + 1 || memcmp (p, "a\0cde", 6))
+ abort ();
+ if (strcpy (p + 3, "fghij") != p + 3 || memcmp (p, "a\0cfghij", 9))
+ abort ();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strcpy (p, "abcde") != p || memcmp (p, "abcde", 6))
+ abort ();
+
+ strcpy_disallowed = 0;
+ if (chk_calls)
+ abort ();
+}
+
+#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;
+
+void
+__attribute__((noinline))
+test2 (void)
+{
+ 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 ();
+ }
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+ const char *l;
+
+ /* The following calls should do runtime checking
+ - source length is not known, but destination is. */
+ chk_calls = 0;
+ strcpy (a.buf1 + 2, s3 + 3);
+ strcpy (r, s3 + 2);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ strcpy (r, s2 + 2);
+ strcpy (r + 2, s3 + 3);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ strcpy (r, s2 + 4);
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known source length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ strcpy (a.buf1 + 2, "");
+ strcpy (r, "a");
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ strcpy (r, s1 + 1);
+ r = buf3;
+ l = "abc";
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1], l = "e";
+ else if (i == l1)
+ r = &a.buf2[7], l = "gh";
+ else if (i == l1 + 1)
+ r = &buf3[5], l = "jkl";
+ else if (i == l1 + 2)
+ r = &a.buf1[9], l = "";
+ }
+ strcpy (r, "");
+ /* Here, strlen (l) + 1 is known to be at most 4 and
+ __builtin_object_size (&buf3[16], 0) is 4, so this doesn't need
+ runtime checking. */
+ strcpy (&buf3[16], l);
+ /* Unknown destination and source, no checking. */
+ strcpy (s4, s3);
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test4 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strcpy (&a.buf2[9], s2 + 3);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strcpy (&a.buf2[7], s3 + strlen (s3) - 3);
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strcpy (&buf3[19], "a");
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (s2) : "0" (s2));
+ __asm ("" : "=r" (s3) : "0" (s3));
+ __asm ("" : "=r" (l1) : "0" (l1));
+ test1 ();
+ test2 ();
+ s4 = p;
+ test3 ();
+ test4 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test4 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strcpy.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcpy.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+/* Copyright (C) 2000 Free Software Foundation.
+
+ Ensure builtin memcpy and strcpy perform correctly.
+
+ Written by Jakub Jelinek, 11/24/2000. */
+
+extern void abort (void);
+extern char *strcpy (char *, const char *);
+typedef __SIZE_TYPE__ size_t;
+extern void *memcpy (void *, const void *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+
+char p[32] = "";
+
+void
+main_test (void)
+{
+ if (strcpy (p, "abcde") != p || memcmp (p, "abcde", 6))
+ abort ();
+ if (strcpy (p + 16, "vwxyz" + 1) != p + 16 || memcmp (p + 16, "wxyz", 5))
+ abort ();
+ if (strcpy (p + 1, "") != p + 1 || memcmp (p, "a\0cde", 6))
+ abort ();
+ if (strcpy (p + 3, "fghij") != p + 3 || memcmp (p, "a\0cfghij", 9))
+ abort ();
+ if (memcpy (p, "ABCDE", 6) != p || memcmp (p, "ABCDE", 6))
+ abort ();
+ if (memcpy (p + 16, "VWX" + 1, 2) != p + 16 || memcmp (p + 16, "WXyz", 5))
+ abort ();
+ if (memcpy (p + 1, "", 1) != p + 1 || memcmp (p, "A\0CDE", 6))
+ abort ();
+ if (memcpy (p + 3, "FGHI", 4) != p + 3 || memcmp (p, "A\0CFGHIj", 9))
+ abort ();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strcpy (p, "abcde") != p || memcmp (p, "abcde", 6))
+ abort ();
+ if (__builtin_memcpy (p, "ABCDE", 6) != p || memcmp (p, "ABCDE", 6))
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcspn-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcspn-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcspn-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcspn-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strcspn.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcspn.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcspn.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcspn.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strcspn.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,54 @@
+/* Copyright (C) 2000, 2004 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strcspn occur and
+ perform correctly.
+
+ Written by Kaveh R. Ghazi, 11/27/2000. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strcspn (const char *, const char *);
+extern char *strcpy (char *, const char *);
+
+void
+main_test (void)
+{
+ const char *const s1 = "hello world";
+ char dst[64], *d2;
+
+ if (strcspn (s1, "hello") != 0)
+ abort();
+ if (strcspn (s1, "z") != 11)
+ abort();
+ if (strcspn (s1+4, "z") != 7)
+ abort();
+ if (strcspn (s1, "hello world") != 0)
+ abort();
+ if (strcspn (s1, "") != 11)
+ abort();
+ strcpy (dst, s1);
+ if (strcspn (dst, "") != 11)
+ abort();
+ strcpy (dst, s1); d2 = dst;
+ if (strcspn (++d2, "") != 10 || d2 != dst+1)
+ abort();
+ strcpy (dst, s1); d2 = dst;
+ if (strcspn (++d2+5, "") != 5 || d2 != dst+1)
+ abort();
+ if (strcspn ("", s1) != 0)
+ abort();
+ strcpy (dst, s1);
+ if (strcspn ("", dst) != 0)
+ abort();
+ strcpy (dst, s1); d2 = dst;
+ if (strcspn ("", ++d2) != 0 || d2 != dst+1)
+ abort();
+ strcpy (dst, s1); d2 = dst;
+ if (strcspn ("", ++d2+5) != 0 || d2 != dst+1)
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strcspn (s1, "z") != 11)
+ abort();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-2-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-2-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-2-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-2-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strlen.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Test strlen optimizations on conditional expressions.
+
+ Written by Jakub Jelinek, June 23, 2003. */
+
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen (const char *);
+extern char *strcpy (char *, const char *);
+extern int memcmp (const void *, const void *, size_t);
+extern void abort (void);
+extern int inside_main;
+
+size_t g, h, i, j, k, l;
+
+size_t
+foo (void)
+{
+ if (l)
+ abort ();
+ return ++l;
+}
+
+void
+main_test (void)
+{
+ if (strlen (i ? "foo" + 1 : j ? "bar" + 1 : "baz" + 1) != 2)
+ abort ();
+ if (strlen (g++ ? "foo" : "bar") != 3 || g != 1)
+ abort ();
+ if (strlen (h++ ? "xfoo" + 1 : "bar") != 3 || h != 1)
+ abort ();
+ if (strlen ((i++, "baz")) != 3 || i != 1)
+ abort ();
+ /* The following calls might not optimize strlen call away. */
+ inside_main = 0;
+ if (strlen (j ? "foo" + k++ : "bar" + k++) != 3 || k != 1)
+ abort ();
+ if (strlen (foo () ? "foo" : "bar") != 3 || l != 1)
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-3-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-3-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-3-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-3-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strlen.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,76 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Test strlen on const variables initialized to string literals.
+
+ Written by Jakub Jelinek, 9/14/2004. */
+
+extern void abort (void);
+extern __SIZE_TYPE__ strlen (const char *);
+extern char *strcpy (char *, const char *);
+static const char bar[] = "Hello, World!";
+static const char baz[] = "hello, world?";
+static const char larger[20] = "short string";
+extern int inside_main;
+
+int l1 = 1;
+int x = 6;
+
+void
+main_test(void)
+{
+ inside_main = 1;
+
+#ifdef __OPTIMIZE__
+ const char *foo;
+ int i;
+#endif
+
+ if (strlen (bar) != 13)
+ abort ();
+
+ if (strlen (bar + 3) != 10)
+ abort ();
+
+ if (strlen (&bar[6]) != 7)
+ abort ();
+
+ if (strlen (bar + (x++ & 7)) != 7)
+ abort ();
+ if (x != 7)
+ abort ();
+
+#ifdef __OPTIMIZE__
+ foo = bar;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ foo = "HELLO, WORLD!";
+ else if (i == l1)
+ foo = bar;
+ else if (i == l1 + 1)
+ foo = "hello, world!";
+ else
+ foo = baz;
+ }
+ if (strlen (foo) != 13)
+ abort ();
+#endif
+
+ if (strlen (larger) != 12)
+ abort ();
+ if (strlen (&larger[10]) != 2)
+ abort ();
+
+ inside_main = 0;
+ /* The following call may or may not be folded depending on
+ the optimization level, and when it isn't folded (such
+ as may be the case with -Og) it may or may not result in
+ a library call, depending on whether or not it's expanded
+ inline (e.g., powerpc64 makes a call while x86_64 expands
+ it inline). */
+ if (strlen (larger + (x++ & 7)) != 5)
+ abort ();
+ if (x != 8)
+ abort ();
+ inside_main = 1;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strlen.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strlen.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,71 @@
+/* Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strlen
+ occur and perform correctly.
+
+ Written by Jakub Jelinek, 11/7/2000.
+
+ Additional tests written by Roger Sayle, 11/02/2001:
+ Ensure all builtin strlen comparisons against zero are optimized
+ and perform correctly. The multiple calls to strcpy are to prevent
+ the potentially "pure" strlen calls from being removed by CSE.
+
+ Modified by Ben Elliston, 2006-10-25:
+ The multiple calls to strcpy that Roger mentions above are
+ problematic on systems where strcpy is implemented using strlen
+ (which this test overrides to call abort). So, rather than use
+ strcpy, we perform the identical operations using array indexing
+ and char assignments. */
+
+extern void abort (void);
+extern __SIZE_TYPE__ strlen (const char *);
+extern char *strcpy (char *, const char *);
+
+int x = 6;
+
+void
+main_test(void)
+{
+ const char *const foo = "hello world";
+ char str[8];
+ char *ptr;
+
+ if (strlen (foo) != 11)
+ abort ();
+ if (strlen (foo + 4) != 7)
+ abort ();
+ if (strlen (foo + (x++ & 7)) != 5)
+ abort ();
+ if (x != 7)
+ abort ();
+
+ ptr = str;
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
+ if (strlen (ptr) == 0)
+ abort ();
+
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
+ if (strlen (ptr) < 1)
+ abort ();
+
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
+ if (strlen (ptr) <= 0)
+ abort ();
+
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
+ if (strlen (ptr+3) != 0)
+ abort ();
+
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
+ if (strlen (ptr+3) > 0)
+ abort ();
+
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
+ if (strlen (str+3) >= 1)
+ abort ();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strlen (foo) != 11)
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,229 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __strncat_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen (const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern char *strcat (char *, const char *);
+extern char *strncat (char *, const char *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+extern char *strcpy (char *, const char *);
+extern int strcmp (const char *, const char *);
+extern void *memset (void *, int, size_t);
+
+#include "chk.h"
+
+const char s1[] = "123";
+char p[32] = "";
+char *s2 = "defg";
+char *s3 = "FGH";
+char *s4;
+size_t l1 = 1;
+char *s5;
+int x = 123;
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ const char *const s1 = "hello world";
+ const char *const s2 = "";
+ const char *s3;
+ char dst[64], *d2;
+
+ /* Following strncat calls should be all optimized out. */
+ chk_calls = 0;
+ strncat_disallowed = 1;
+ strcat_disallowed = 1;
+ strcpy (dst, s1);
+ if (strncat (dst, "", 100) != dst || strcmp (dst, s1))
+ abort ();
+ strcpy (dst, s1);
+ if (strncat (dst, s2, 100) != dst || strcmp (dst, s1))
+ abort ();
+ strcpy (dst, s1); d2 = dst;
+ if (strncat (++d2, s2, 100) != dst+1 || d2 != dst+1 || strcmp (dst, s1))
+ abort ();
+ strcpy (dst, s1); d2 = dst;
+ if (strncat (++d2+5, s2, 100) != dst+6 || d2 != dst+1 || strcmp (dst, s1))
+ abort ();
+ strcpy (dst, s1); d2 = dst;
+ if (strncat (++d2+5, s1+11, 100) != dst+6 || d2 != dst+1 || strcmp (dst, s1))
+ abort ();
+ strcpy (dst, s1); d2 = dst;
+ if (strncat (++d2+5, s1, 0) != dst+6 || d2 != dst+1 || strcmp (dst, s1))
+ abort ();
+ strcpy (dst, s1); d2 = dst; s3 = s1;
+ if (strncat (++d2+5, ++s3, 0) != dst+6 || d2 != dst+1 || strcmp (dst, s1)
+ || s3 != s1 + 1)
+ abort ();
+ strcpy (dst, s1); d2 = dst;
+ if (strncat (++d2+5, "", ++x) != dst+6 || d2 != dst+1 || x != 124
+ || strcmp (dst, s1))
+ abort ();
+ if (chk_calls)
+ abort ();
+ strcat_disallowed = 0;
+
+ /* These __strncat_chk calls should be optimized into __strcat_chk,
+ as strlen (src) <= len. */
+ strcpy (dst, s1);
+ if (strncat (dst, "foo", 3) != dst || strcmp (dst, "hello worldfoo"))
+ abort ();
+ strcpy (dst, s1);
+ if (strncat (dst, "foo", 100) != dst || strcmp (dst, "hello worldfoo"))
+ abort ();
+ strcpy (dst, s1);
+ if (strncat (dst, s1, 100) != dst || strcmp (dst, "hello worldhello world"))
+ abort ();
+ if (chk_calls != 3)
+ abort ();
+
+ chk_calls = 0;
+ /* The following calls have side-effects in dest, so are not checked. */
+ strcpy (dst, s1); d2 = dst;
+ if (__builtin___strncat_chk (++d2, s1, 100, os (++d2)) != dst+1
+ || d2 != dst+1 || strcmp (dst, "hello worldhello world"))
+ abort ();
+ strcpy (dst, s1); d2 = dst;
+ if (__builtin___strncat_chk (++d2+5, s1, 100, os (++d2+5)) != dst+6
+ || d2 != dst+1 || strcmp (dst, "hello worldhello world"))
+ abort ();
+ strcpy (dst, s1); d2 = dst;
+ if (__builtin___strncat_chk (++d2+5, s1+5, 100, os (++d2+5)) != dst+6
+ || d2 != dst+1 || strcmp (dst, "hello world world"))
+ abort ();
+ if (chk_calls)
+ abort ();
+
+ chk_calls = 0;
+ strcat_disallowed = 1;
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ strcpy (dst, s1);
+ if (__builtin_strncat (dst, "", 100) != dst || strcmp (dst, s1))
+ abort ();
+
+ if (chk_calls)
+ abort ();
+ strncat_disallowed = 0;
+ strcat_disallowed = 0;
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test2 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+
+ /* The following calls should do runtime checking. */
+ memset (&a, '\0', sizeof (a));
+ s5 = (char *) &a;
+ __asm __volatile ("" : : "r" (s5) : "memory");
+ chk_calls = 0;
+ strncat (a.buf1 + 2, s3 + 3, l1 - 1);
+ strncat (r, s3 + 2, l1);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ memset (r, '\0', 3);
+ __asm __volatile ("" : : "r" (r) : "memory");
+ strncat (r, s2 + 2, l1 + 1);
+ strncat (r + 2, s3 + 3, l1 - 1);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ strncat (r, s2 + 4, l1);
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known source length,
+ but we don't know the length of dest string, so runtime checking
+ is needed too. */
+ memset (&a, '\0', sizeof (a));
+ chk_calls = 0;
+ s5 = (char *) &a;
+ __asm __volatile ("" : : "r" (s5) : "memory");
+ strncat (a.buf1 + 2, "a", 5);
+ strncat (r, "def", 0);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ memset (r, '\0', 3);
+ __asm __volatile ("" : : "r" (r) : "memory");
+ strncat (r, s1 + 1, 2);
+ if (chk_calls != 2)
+ abort ();
+ chk_calls = 0;
+ strcat_disallowed = 1;
+ /* Unknown destination and source, no checking. */
+ strncat (s4, s3, l1 + 1);
+ strcat_disallowed = 0;
+ if (chk_calls)
+ abort ();
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ memset (&a, '\0', sizeof (a));
+ memset (buf3, '\0', sizeof (buf3));
+ s5 = (char *) &a;
+ __asm __volatile ("" : : "r" (s5) : "memory");
+ s5 = buf3;
+ __asm __volatile ("" : : "r" (s5) : "memory");
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strncat (&a.buf2[9], s2 + 3, 4);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strncat (&a.buf2[7], s3 + strlen (s3) - 3, 3);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strncat (&buf3[19], "abcde", 1);
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (s2) : "0" (s2));
+ __asm ("" : "=r" (s3) : "0" (s3));
+ __asm ("" : "=r" (l1) : "0" (l1));
+ s4 = p;
+ test1 ();
+ memset (p, '\0', sizeof (p));
+ test2 ();
+ test3 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test3 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strncat.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncat.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,82 @@
+/* Copyright (C) 2000, 2003 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strncat occur and
+ perform correctly.
+
+ Written by Kaveh R. Ghazi, 11/27/2000. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern char *strncat (char *, const char *, size_t);
+extern char *strcpy (char *, const char *);
+extern void *memset (void *, int, size_t);
+extern int memcmp (const void *, const void *, size_t);
+int x = 123;
+
+/* Reset the destination buffer to a known state. */
+#define RESET_DST_WITH(FILLER) \
+ do { memset (dst, 'X', sizeof (dst)); strcpy (dst, (FILLER)); } while (0)
+
+void
+main_test (void)
+{
+ const char *const s1 = "hello world";
+ const char *const s2 = "";
+ char dst[64], *d2;
+
+ RESET_DST_WITH (s1);
+ if (strncat (dst, "", 100) != dst || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+ RESET_DST_WITH (s1);
+ if (strncat (dst, s2, 100) != dst || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strncat (++d2, s2, 100) != dst+1 || d2 != dst+1
+ || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strncat (++d2+5, s2, 100) != dst+6 || d2 != dst+1
+ || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strncat (++d2+5, s1+11, 100) != dst+6 || d2 != dst+1
+ || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strncat (++d2+5, s1, 0) != dst+6 || d2 != dst+1
+ || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strncat (++d2+5, "", ++x) != dst+6 || d2 != dst+1 || x != 124
+ || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+
+ RESET_DST_WITH (s1);
+ if (strncat (dst, "foo", 3) != dst || memcmp (dst, "hello worldfoo\0XXX", 18))
+ abort();
+ RESET_DST_WITH (s1);
+ if (strncat (dst, "foo", 100) != dst || memcmp (dst, "hello worldfoo\0XXX", 18))
+ abort();
+ RESET_DST_WITH (s1);
+ if (strncat (dst, s1, 100) != dst || memcmp (dst, "hello worldhello world\0XXX", 26))
+ abort();
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strncat (++d2, s1, 100) != dst+1 || d2 != dst+1
+ || memcmp (dst, "hello worldhello world\0XXX", 26))
+ abort();
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strncat (++d2+5, s1, 100) != dst+6 || d2 != dst+1
+ || memcmp (dst, "hello worldhello world\0XXX", 26))
+ abort();
+ RESET_DST_WITH (s1); d2 = dst;
+ if (strncat (++d2+5, s1+5, 100) != dst+6 || d2 != dst+1
+ || memcmp (dst, "hello world world\0XXX", 21))
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ RESET_DST_WITH (s1);
+ if (__builtin_strncat (dst, "", 100) != dst
+ || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-2-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-2-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-2-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-2-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strncmp.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,173 @@
+/* Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strncmp occur and
+ perform correctly.
+
+ Written by Kaveh R. Ghazi, 11/26/2000. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern int strncmp (const char *, const char *, size_t);
+
+void
+main_test (void)
+{
+#if !defined(__OPTIMIZE__) || ((defined(__sh__) || defined(__i386__) || defined (__x86_64__)) && !defined(__OPTIMIZE_SIZE__))
+ /* These tests work on platforms which support cmpstrsi. We test it
+ at -O0 on all platforms to ensure the strncmp logic is correct. */
+ const char *const s1 = "hello world";
+ const char *s2;
+ int n = 6, x;
+
+ s2 = s1;
+ if (strncmp (++s2, "ello", 3) != 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("ello", ++s2, 3) != 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp (++s2, "ello", 4) != 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("ello", ++s2, 4) != 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp (++s2, "ello", 5) <= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("ello", ++s2, 5) >= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp (++s2, "ello", 6) <= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("ello", ++s2, 6) >= 0 || s2 != s1+1)
+ abort();
+
+ s2 = s1;
+ if (strncmp (++s2, "zllo", 3) >= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("zllo", ++s2, 3) <= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp (++s2, "zllo", 4) >= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("zllo", ++s2, 4) <= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp (++s2, "zllo", 5) >= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("zllo", ++s2, 5) <= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp (++s2, "zllo", 6) >= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("zllo", ++s2, 6) <= 0 || s2 != s1+1)
+ abort();
+
+ s2 = s1;
+ if (strncmp (++s2, "allo", 3) <= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("allo", ++s2, 3) >= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp (++s2, "allo", 4) <= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("allo", ++s2, 4) >= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp (++s2, "allo", 5) <= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("allo", ++s2, 5) >= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp (++s2, "allo", 6) <= 0 || s2 != s1+1)
+ abort();
+ s2 = s1;
+ if (strncmp ("allo", ++s2, 6) >= 0 || s2 != s1+1)
+ abort();
+
+ s2 = s1; n = 2; x = 1;
+ if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 3)
+ abort();
+ s2 = s1; n = 2; x = 1;
+ if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 3)
+ abort();
+ s2 = s1; n = 3; x = 1;
+ if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 4)
+ abort();
+ s2 = s1; n = 3; x = 1;
+ if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 4)
+ abort();
+ s2 = s1; n = 4; x = 1;
+ if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 5)
+ abort();
+ s2 = s1; n = 4; x = 1;
+ if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 5)
+ abort();
+ s2 = s1; n = 5; x = 1;
+ if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 6)
+ abort();
+ s2 = s1; n = 5; x = 1;
+ if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 6)
+ abort();
+
+ s2 = s1; n = 2;
+ if (strncmp (++s2, "zllo", ++n) >= 0 || s2 != s1+1 || n != 3)
+ abort();
+ s2 = s1; n = 2; x = 1;
+ if (strncmp ("zllo", ++s2, ++n) <= 0 || s2 != s1+1 || n != 3)
+ abort();
+ s2 = s1; n = 3; x = 1;
+ if (strncmp (++s2, "zllo", ++n) >= 0 || s2 != s1+1 || n != 4)
+ abort();
+ s2 = s1; n = 3; x = 1;
+ if (strncmp ("zllo", ++s2, ++n) <= 0 || s2 != s1+1 || n != 4)
+ abort();
+ s2 = s1; n = 4; x = 1;
+ if (strncmp (++s2, "zllo", ++n) >= 0 || s2 != s1+1 || n != 5)
+ abort();
+ s2 = s1; n = 4; x = 1;
+ if (strncmp ("zllo", ++s2, ++n) <= 0 || s2 != s1+1 || n != 5)
+ abort();
+ s2 = s1; n = 5; x = 1;
+ if (strncmp (++s2, "zllo", ++n) >= 0 || s2 != s1+1 || n != 6)
+ abort();
+ s2 = s1; n = 5; x = 1;
+ if (strncmp ("zllo", ++s2, ++n) <= 0 || s2 != s1+1 || n != 6)
+ abort();
+
+ s2 = s1; n = 2;
+ if (strncmp (++s2, "allo", ++n) <= 0 || s2 != s1+1 || n != 3)
+ abort();
+ s2 = s1; n = 2; x = 1;
+ if (strncmp ("allo", ++s2, ++n) >= 0 || s2 != s1+1 || n != 3)
+ abort();
+ s2 = s1; n = 3; x = 1;
+ if (strncmp (++s2, "allo", ++n) <= 0 || s2 != s1+1 || n != 4)
+ abort();
+ s2 = s1; n = 3; x = 1;
+ if (strncmp ("allo", ++s2, ++n) >= 0 || s2 != s1+1 || n != 4)
+ abort();
+ s2 = s1; n = 4; x = 1;
+ if (strncmp (++s2, "allo", ++n) <= 0 || s2 != s1+1 || n != 5)
+ abort();
+ s2 = s1; n = 4; x = 1;
+ if (strncmp ("allo", ++s2, ++n) >= 0 || s2 != s1+1 || n != 5)
+ abort();
+ s2 = s1; n = 5; x = 1;
+ if (strncmp (++s2, "allo", ++n) <= 0 || s2 != s1+1 || n != 6)
+ abort();
+ s2 = s1; n = 5; x = 1;
+ if (strncmp ("allo", ++s2, ++n) >= 0 || s2 != s1+1 || n != 6)
+ abort();
+
+#endif
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strncmp.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncmp.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,73 @@
+/* Copyright (C) 2000, 2001, 2003 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strncmp occur and
+ perform correctly.
+
+ Written by Kaveh R. Ghazi, 11/26/2000. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern int strncmp (const char *, const char *, size_t);
+
+void
+main_test (void)
+{
+ const char *const s1 = "hello world";
+ const char *s2, *s3;
+
+ if (strncmp (s1, "hello world", 12) != 0)
+ abort();
+ if (strncmp ("hello world", s1, 12) != 0)
+ abort();
+ if (strncmp ("hello", "hello", 6) != 0)
+ abort();
+ if (strncmp ("hello", "hello", 2) != 0)
+ abort();
+ if (strncmp ("hello", "hello", 100) != 0)
+ abort();
+ if (strncmp (s1+10, "d", 100) != 0)
+ abort();
+ if (strncmp (10+s1, "d", 100) != 0)
+ abort();
+ if (strncmp ("d", s1+10, 1) != 0)
+ abort();
+ if (strncmp ("d", 10+s1, 1) != 0)
+ abort();
+ if (strncmp ("hello", "aaaaa", 100) <= 0)
+ abort();
+ if (strncmp ("aaaaa", "hello", 100) >= 0)
+ abort();
+ if (strncmp ("hello", "aaaaa", 1) <= 0)
+ abort();
+ if (strncmp ("aaaaa", "hello", 1) >= 0)
+ abort();
+
+ s2 = s1; s3 = s1+4;
+ if (strncmp (++s2, ++s3, 0) != 0 || s2 != s1+1 || s3 != s1+5)
+ abort();
+ s2 = s1;
+ if (strncmp (++s2, "", 1) <= 0 || s2 != s1+1)
+ abort();
+ if (strncmp ("", ++s2, 1) >= 0 || s2 != s1+2)
+ abort();
+ if (strncmp (++s2, "", 100) <= 0 || s2 != s1+3)
+ abort();
+ if (strncmp ("", ++s2, 100) >= 0 || s2 != s1+4)
+ abort();
+ if (strncmp (++s2+6, "", 100) != 0 || s2 != s1+5)
+ abort();
+ if (strncmp ("", ++s2+5, 100) != 0 || s2 != s1+6)
+ abort();
+ if (strncmp ("ozz", ++s2, 1) != 0 || s2 != s1+7)
+ abort();
+ if (strncmp (++s2, "rzz", 1) != 0 || s2 != s1+8)
+ abort();
+ s2 = s1; s3 = s1+4;
+ if (strncmp (++s2, ++s3+2, 1) >= 0 || s2 != s1+1 || s3 != s1+5)
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strncmp ("hello", "a", 100) <= 0)
+ abort();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,227 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __strncpy_chk performs correctly. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern char *strncpy (char *, const char *, size_t);
+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);
+extern void *memset (void *, int, size_t);
+
+#include "chk.h"
+
+const char s1[] = "123";
+char p[32] = "";
+char * volatile s2 = "defg"; /* prevent constant propagation to happen when whole program assumptions are made. */
+char * volatile s3 = "FGH"; /* prevent constant propagation to happen when whole program assumptions are made. */
+char *s4;
+volatile size_t l1 = 1; /* prevent constant propagation to happen when whole program assumptions are made. */
+int i;
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ const char *const src = "hello world";
+ const char *src2;
+ char dst[64], *dst2;
+
+ strncpy_disallowed = 1;
+ chk_calls = 0;
+
+ memset (dst, 0, sizeof (dst));
+ if (strncpy (dst, src, 4) != dst || strncmp (dst, src, 4))
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ if (strncpy (dst+16, src, 4) != dst+16 || strncmp (dst+16, src, 4))
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ if (strncpy (dst+32, src+5, 4) != dst+32 || strncmp (dst+32, src+5, 4))
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ dst2 = dst;
+ if (strncpy (++dst2, src+5, 4) != dst+1 || strncmp (dst2, src+5, 4)
+ || dst2 != dst+1)
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ if (strncpy (dst, src, 0) != dst || strcmp (dst, ""))
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ dst2 = dst; src2 = src;
+ if (strncpy (++dst2, ++src2, 0) != dst+1 || strcmp (dst2, "")
+ || dst2 != dst+1 || src2 != src+1)
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ dst2 = dst; src2 = src;
+ if (strncpy (++dst2+5, ++src2+5, 0) != dst+6 || strcmp (dst2+5, "")
+ || dst2 != dst+1 || src2 != src+1)
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ if (strncpy (dst, src, 12) != dst || strcmp (dst, src))
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ memset (dst, 0, sizeof (dst));
+ if (__builtin_strncpy (dst, src, 4) != dst || strncmp (dst, src, 4))
+ abort();
+
+ memset (dst, 0, sizeof (dst));
+ if (strncpy (dst, i++ ? "xfoo" + 1 : "bar", 4) != dst
+ || strcmp (dst, "bar")
+ || i != 1)
+ abort ();
+
+ if (chk_calls)
+ abort ();
+ strncpy_disallowed = 0;
+}
+
+void
+__attribute__((noinline))
+test2 (void)
+{
+ chk_calls = 0;
+ /* No runtime checking should be done here, both destination
+ and length are unknown. */
+ strncpy (s4, "abcd", l1 + 1);
+ if (chk_calls)
+ abort ();
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int i;
+ const char *l;
+ size_t l2;
+
+ /* The following calls should do runtime checking
+ - source length is not known, but destination is. */
+ chk_calls = 0;
+ strncpy (a.buf1 + 2, s3 + 3, l1);
+ strncpy (r, s3 + 2, l1 + 2);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ strncpy (r, s2 + 2, l1 + 2);
+ strncpy (r + 2, s3 + 3, l1);
+ r = buf3;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1];
+ else if (i == l1)
+ r = &a.buf2[7];
+ else if (i == l1 + 1)
+ r = &buf3[5];
+ else if (i == l1 + 2)
+ r = &a.buf1[9];
+ }
+ strncpy (r, s2 + 4, l1);
+ if (chk_calls != 5)
+ abort ();
+
+ /* Following have known destination and known length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ strncpy (a.buf1 + 2, "", 3);
+ strncpy (a.buf1 + 2, "", 0);
+ strncpy (r, "a", 1);
+ strncpy (r, "a", 3);
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ strncpy (r, s1 + 1, 3);
+ strncpy (r, s1 + 1, 2);
+ r = buf3;
+ l = "abc";
+ l2 = 4;
+ for (i = 0; i < 4; ++i)
+ {
+ if (i == l1 - 1)
+ r = &a.buf1[1], l = "e", l2 = 2;
+ else if (i == l1)
+ r = &a.buf2[7], l = "gh", l2 = 3;
+ else if (i == l1 + 1)
+ r = &buf3[5], l = "jkl", l2 = 4;
+ else if (i == l1 + 2)
+ r = &a.buf1[9], l = "", l2 = 1;
+ }
+ strncpy (r, "", 1);
+ /* Here, strlen (l) + 1 is known to be at most 4 and
+ __builtin_object_size (&buf3[16], 0) is 4, so this doesn't need
+ runtime checking. */
+ strncpy (&buf3[16], l, l2);
+ strncpy (&buf3[15], "abc", l2);
+ strncpy (&buf3[10], "fghij", l2);
+ if (chk_calls)
+ abort ();
+ chk_calls = 0;
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test4 (void)
+{
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strncpy (&a.buf2[9], s2 + 4, l1 + 1);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strncpy (&a.buf2[7], s3, l1 + 4);
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strncpy (&buf3[19], "abc", 2);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ strncpy (&buf3[18], "", 3);
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (s2) : "0" (s2));
+ __asm ("" : "=r" (s3) : "0" (s3));
+ __asm ("" : "=r" (l1) : "0" (l1));
+ test1 ();
+ s4 = p;
+ test2 ();
+ test3 ();
+ test4 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test4 struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strncpy.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strncpy.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,75 @@
+/* Copyright (C) 2000, 2005 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strncpy occur and
+ perform correctly.
+
+ Written by Kaveh R. Ghazi, 11/25/2000. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern char *strncpy (char *, const char *, size_t);
+extern int memcmp (const void *, const void *, size_t);
+extern void *memset (void *, int, size_t);
+
+/* Reset the destination buffer to a known state. */
+#define RESET_DST memset(dst, 'X', sizeof(dst))
+
+int i;
+
+void
+main_test (void)
+{
+ const char *const src = "hello world";
+ const char *src2;
+ char dst[64], *dst2;
+
+ RESET_DST;
+ if (strncpy (dst, src, 4) != dst || memcmp (dst, "hellXXX", 7))
+ abort();
+
+ RESET_DST;
+ if (strncpy (dst+16, src, 4) != dst+16 || memcmp (dst+16, "hellXXX", 7))
+ abort();
+
+ RESET_DST;
+ if (strncpy (dst+32, src+5, 4) != dst+32 || memcmp (dst+32, " worXXX", 7))
+ abort();
+
+ RESET_DST;
+ dst2 = dst;
+ if (strncpy (++dst2, src+5, 4) != dst+1 || memcmp (dst2, " worXXX", 7)
+ || dst2 != dst+1)
+ abort();
+
+ RESET_DST;
+ if (strncpy (dst, src, 0) != dst || memcmp (dst, "XXX", 3))
+ abort();
+
+ RESET_DST;
+ dst2 = dst; src2 = src;
+ if (strncpy (++dst2, ++src2, 0) != dst+1 || memcmp (dst2, "XXX", 3)
+ || dst2 != dst+1 || src2 != src+1)
+ abort();
+
+ RESET_DST;
+ dst2 = dst; src2 = src;
+ if (strncpy (++dst2+5, ++src2+5, 0) != dst+6 || memcmp (dst2+5, "XXX", 3)
+ || dst2 != dst+1 || src2 != src+1)
+ abort();
+
+ RESET_DST;
+ if (strncpy (dst, src, 12) != dst || memcmp (dst, "hello world\0XXX", 15))
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ RESET_DST;
+ if (__builtin_strncpy (dst, src, 4) != dst || memcmp (dst, "hellXXX", 7))
+ abort();
+
+ RESET_DST;
+ if (strncpy (dst, i++ ? "xfoo" + 1 : "bar", 4) != dst
+ || memcmp (dst, "bar\0XXX", 7)
+ || i != 1)
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strnlen.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,92 @@
+/* PR tree-optimization/81384 - built-in form of strnlen missing
+ Test to verify that strnlen built-in expansion works correctly. */
+
+#define PTRDIFF_MAX __PTRDIFF_MAX__
+#define SIZE_MAX __SIZE_MAX__
+#define NOIPA __attribute__ ((noipa))
+
+typedef __SIZE_TYPE__ size_t;
+
+extern void abort (void);
+extern size_t strnlen (const char *, size_t);
+
+#define A(expr) \
+ ((expr) ? (void)0 \
+ : (__builtin_printf ("assertion on line %i failed: %s\n", \
+ __LINE__, #expr), \
+ abort ()))
+
+NOIPA void test_strnlen_str_cst (void)
+{
+ A (strnlen ("", 0) == 0);
+ A (strnlen ("", 1) == 0);
+ A (strnlen ("", 9) == 0);
+ A (strnlen ("", PTRDIFF_MAX) == 0);
+ A (strnlen ("", SIZE_MAX) == 0);
+ A (strnlen ("", -1) == 0);
+
+ A (strnlen ("1", 0) == 0);
+ A (strnlen ("1", 1) == 1);
+ A (strnlen ("1", 9) == 1);
+ A (strnlen ("1", PTRDIFF_MAX) == 1);
+ A (strnlen ("1", SIZE_MAX) == 1);
+ A (strnlen ("1", -2) == 1);
+
+ A (strnlen ("123", 0) == 0);
+ A (strnlen ("123", 1) == 1);
+ A (strnlen ("123", 2) == 2);
+ A (strnlen ("123", 3) == 3);
+ A (strnlen ("123", 9) == 3);
+ A (strnlen ("123", PTRDIFF_MAX) == 3);
+ A (strnlen ("123", SIZE_MAX) == 3);
+ A (strnlen ("123", -2) == 3);
+}
+
+NOIPA void test_strnlen_str_range (size_t x)
+{
+ size_t r_0_3 = x & 3;
+ size_t r_1_3 = r_0_3 | 1;
+ size_t r_2_3 = r_0_3 | 2;
+
+ A (strnlen ("", r_0_3) == 0);
+ A (strnlen ("1", r_0_3) <= 1);
+ A (strnlen ("12", r_0_3) <= 2);
+ A (strnlen ("123", r_0_3) <= 3);
+ A (strnlen ("1234", r_0_3) <= 3);
+
+ A (strnlen ("", r_1_3) == 0);
+ A (strnlen ("1", r_1_3) == 1);
+ A (strnlen ("12", r_1_3) <= 2);
+ A (strnlen ("123", r_1_3) <= 3);
+ A (strnlen ("1234", r_1_3) <= 3);
+
+ A (strnlen ("", r_2_3) == 0);
+ A (strnlen ("1", r_2_3) == 1);
+ A (strnlen ("12", r_2_3) == 2);
+ A (strnlen ("123", r_2_3) <= 3);
+ A (strnlen ("1234", r_2_3) <= 3);
+}
+
+NOIPA void test_strnlen_str_range_side_effect (size_t x)
+{
+ size_t r_0_3 = x & 3;
+ size_t r_1_3 = r_0_3 | 1;
+ size_t r_2_3 = r_0_3 | 2;
+ size_t n = r_2_3;
+
+ int i = 0;
+
+ A (strnlen ("1234" + i++, n) <= 3);
+ A (i == 1);
+
+ A (strnlen ("1234", n++) <= 3);
+ A (n == r_2_3 + 1);
+}
+
+void
+main_test (void)
+{
+ test_strnlen_str_cst ();
+ test_strnlen_str_range ((size_t)"");
+ test_strnlen_str_range_side_effect ((size_t)"");
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strnlen.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+# At -Og no pass records the global range information
+# necessary to optimize the strnlen calls down to
+# a constant. The framework assumes that the test
+# will never call strnlen when the optimizer is
+# enabled. So we filter out the -Og run here.
+
+set torture_eval_before_compile {
+ if {[string match {*-Og*} "$option"]} {
+ continue
+ }
+}
+
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpbrk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpbrk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpbrk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpbrk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strpbrk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpbrk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpbrk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpbrk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpbrk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,42 @@
+/* Copyright (C) 2000 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strpbrk occur and
+ perform correctly.
+
+ Written by Kaveh R. Ghazi, 11/6/2000. */
+
+extern void abort(void);
+extern char *strpbrk (const char *, const char *);
+extern int strcmp (const char *, const char *);
+
+void fn (const char *foo, const char *const *bar)
+{
+ if (strcmp(strpbrk ("hello world", "lrooo"), "llo world") != 0)
+ abort();
+ if (strpbrk (foo, "") != 0)
+ abort();
+ if (strpbrk (foo + 4, "") != 0)
+ abort();
+ if (strpbrk (*bar--, "") != 0)
+ abort();
+ if (strpbrk (*bar, "h") != foo)
+ abort();
+ if (strpbrk (foo, "h") != foo)
+ abort();
+ if (strpbrk (foo, "w") != foo + 6)
+ abort();
+ if (strpbrk (foo + 6, "o") != foo + 7)
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strpbrk (foo + 6, "o") != foo + 7)
+ abort();
+}
+
+void
+main_test (void)
+{
+ const char *const foo[] = { "hello world", "bye bye world" };
+ fn (foo[0], foo + 1);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-2-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-2-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-2-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-2-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/stpcpy.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,45 @@
+/* Copyright (C) 2003 Free Software Foundation.
+
+ Ensure that builtin stpcpy performs correctly.
+
+ Written by Jakub Jelinek, 21/05/2003. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern int memcmp (const void *, const void *, size_t);
+extern char *stpcpy (char *, const char *);
+extern int inside_main;
+
+long buf1[64];
+char *buf2 = (char *) (buf1 + 32);
+long buf5[20];
+char buf7[20];
+
+void
+__attribute__((noinline))
+test (long *buf3, char *buf4, char *buf6, int n)
+{
+ int i = 4;
+
+ if (stpcpy ((char *) buf3, "abcdefghijklmnop") != (char *) buf1 + 16
+ || memcmp (buf1, "abcdefghijklmnop", 17))
+ abort ();
+
+ if (__builtin_stpcpy ((char *) buf3, "ABCDEFG") != (char *) buf1 + 7
+ || memcmp (buf1, "ABCDEFG\0ijklmnop", 17))
+ abort ();
+
+ if (stpcpy ((char *) buf3 + i++, "x") != (char *) buf1 + 5
+ || memcmp (buf1, "ABCDx\0G\0ijklmnop", 17))
+ abort ();
+}
+
+void
+main_test (void)
+{
+ /* All these tests are allowed to call mempcpy/stpcpy. */
+ inside_main = 0;
+ __builtin_memcpy (buf5, "RSTUVWXYZ0123456789", 20);
+ __builtin_memcpy (buf7, "RSTUVWXYZ0123456789", 20);
+ test (buf1, buf2, "rstuvwxyz", 0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/stpcpy.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strpcpy.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,60 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation.
+
+ Ensure builtin stpcpy performs correctly.
+
+ Written by Kaveh Ghazi, 4/11/2003. */
+
+typedef __SIZE_TYPE__ size_t;
+
+extern void abort (void);
+extern char *strcpy (char *, const char *);
+extern char *stpcpy (char *, const char *);
+extern int memcmp (const void *, const void *, size_t);
+
+extern int inside_main;
+
+const char s1[] = "123";
+char p[32] = "";
+char *s2 = "defg";
+char *s3 = "FGH";
+size_t l1 = 1;
+
+void
+main_test (void)
+{
+ int i = 8;
+
+#if !defined __i386__ && !defined __x86_64__
+ /* The functions below might not be optimized into direct stores on all
+ arches. It depends on how many instructions would be generated and
+ what limits the architecture chooses in STORE_BY_PIECES_P. */
+ inside_main = 0;
+#endif
+ if (stpcpy (p, "abcde") != p + 5 || memcmp (p, "abcde", 6))
+ abort ();
+ if (stpcpy (p + 16, "vwxyz" + 1) != p + 16 + 4 || memcmp (p + 16, "wxyz", 5))
+ abort ();
+ if (stpcpy (p + 1, "") != p + 1 + 0 || memcmp (p, "a\0cde", 6))
+ abort ();
+ if (stpcpy (p + 3, "fghij") != p + 3 + 5 || memcmp (p, "a\0cfghij", 9))
+ abort ();
+
+ if (stpcpy ((i++, p + 20 + 1), "23") != (p + 20 + 1 + 2)
+ || i != 9 || memcmp (p + 19, "z\0""23\0", 5))
+ abort ();
+
+ if (stpcpy (stpcpy (p, "ABCD"), "EFG") != p + 7 || memcmp (p, "ABCDEFG", 8))
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_stpcpy (p, "abcde") != p + 5 || memcmp (p, "abcde", 6))
+ abort ();
+
+ /* If the result of stpcpy is ignored, gcc should use strcpy.
+ This should be optimized always, so set inside_main again. */
+ inside_main = 1;
+ stpcpy (p + 3, s3);
+ if (memcmp (p, "abcFGH", 6))
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strrchr-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strrchr-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strrchr-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strrchr-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,8 @@
+#include "lib/strrchr.c"
+#ifdef __vxworks
+/* The RTP C library uses bzero, bfill and bcopy, all of which are defined
+ in the same file as rindex. */
+#include "lib/bzero.c"
+#include "lib/bfill.c"
+#include "lib/memmove.c"
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strrchr.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strrchr.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strrchr.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strrchr.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,49 @@
+/* Copyright (C) 2000, 2003, 2004 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strrchr and rindex
+ occur and perform correctly.
+
+ Written by Jakub Jelinek, 11/7/2000. */
+
+extern void abort (void);
+extern char *strrchr (const char *, int);
+extern char *rindex (const char *, int);
+
+char *bar = "hi world";
+int x = 7;
+
+void
+main_test (void)
+{
+ const char *const foo = "hello world";
+
+ if (strrchr (foo, 'x'))
+ abort ();
+ if (strrchr (foo, 'o') != foo + 7)
+ abort ();
+ if (strrchr (foo, 'e') != foo + 1)
+ abort ();
+ if (strrchr (foo + 3, 'e'))
+ abort ();
+ if (strrchr (foo, '\0') != foo + 11)
+ abort ();
+ if (strrchr (bar, '\0') != bar + 8)
+ abort ();
+ if (strrchr (bar + 4, '\0') != bar + 8)
+ abort ();
+ if (strrchr (bar + (x++ & 3), '\0') != bar + 8)
+ abort ();
+ if (x != 8)
+ abort ();
+ /* Test only one instance of rindex since the code path is the same
+ as that of strrchr. */
+ if (rindex ("hello", 'z') != 0)
+ abort ();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strrchr (foo, 'o') != foo + 7)
+ abort ();
+ if (__builtin_rindex (foo, 'o') != foo + 7)
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strspn-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strspn-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strspn-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strspn-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strspn.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strspn.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strspn.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strspn.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strspn.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,54 @@
+/* Copyright (C) 2000 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strspn occur and
+ perform correctly.
+
+ Written by Kaveh R. Ghazi, 11/27/2000. */
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strspn (const char *, const char *);
+extern char *strcpy (char *, const char *);
+
+void
+main_test (void)
+{
+ const char *const s1 = "hello world";
+ char dst[64], *d2;
+
+ if (strspn (s1, "hello") != 5)
+ abort();
+ if (strspn (s1+4, "hello") != 1)
+ abort();
+ if (strspn (s1, "z") != 0)
+ abort();
+ if (strspn (s1, "hello world") != 11)
+ abort();
+ if (strspn (s1, "") != 0)
+ abort();
+ strcpy (dst, s1);
+ if (strspn (dst, "") != 0)
+ abort();
+ strcpy (dst, s1); d2 = dst;
+ if (strspn (++d2, "") != 0 || d2 != dst+1)
+ abort();
+ strcpy (dst, s1); d2 = dst;
+ if (strspn (++d2+5, "") != 0 || d2 != dst+1)
+ abort();
+ if (strspn ("", s1) != 0)
+ abort();
+ strcpy (dst, s1);
+ if (strspn ("", dst) != 0)
+ abort();
+ strcpy (dst, s1); d2 = dst;
+ if (strspn ("", ++d2) != 0 || d2 != dst+1)
+ abort();
+ strcpy (dst, s1); d2 = dst;
+ if (strspn ("", ++d2+5) != 0 || d2 != dst+1)
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strspn (s1, "hello") != 5)
+ abort();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern char *strchr(const char *, int);
+extern int strcmp(const char *, const char *);
+extern int strncmp(const char *, const char *, size_t);
+extern int inside_main;
+extern const char *p;
+
+__attribute__ ((used))
+char *
+my_strstr (const char *s1, const char *s2)
+{
+ const size_t len = strlen (s2);
+
+#ifdef __OPTIMIZE__
+ /* If optimizing, we should be called only in the strstr (foo + 2, p)
+ case. All other cases should be optimized. */
+ if (inside_main)
+ if (s2 != p || strcmp (s1, "hello world" + 2) != 0)
+ abort ();
+#endif
+ if (len == 0)
+ return (char *) s1;
+ for (s1 = strchr (s1, *s2); s1; s1 = strchr (s1 + 1, *s2))
+ if (strncmp (s1, s2, len) == 0)
+ return (char *) s1;
+ return (char *) 0;
+}
+
+char *
+strstr (const char *s1, const char *s2)
+{
+ if (inside_main)
+ abort ();
+
+ return my_strstr (s1, s2);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,45 @@
+/* Copyright (C) 2000, 2003 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strstr occur and
+ perform correctly in presence of redirect. */
+
+#define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+#define ASMNAME2(prefix, cname) STRING (prefix) cname
+#define STRING(x) #x
+
+typedef __SIZE_TYPE__ size_t;
+extern void abort (void);
+extern char *strstr (const char *, const char *)
+ __asm (ASMNAME ("my_strstr"));
+
+const char *p = "rld", *q = "hello world";
+
+void
+main_test (void)
+{
+ const char *const foo = "hello world";
+
+ if (strstr (foo, "") != foo)
+ abort ();
+ if (strstr (foo + 4, "") != foo + 4)
+ abort ();
+ if (strstr (foo, "h") != foo)
+ abort ();
+ if (strstr (foo, "w") != foo + 6)
+ abort ();
+ if (strstr (foo + 6, "o") != foo + 7)
+ abort ();
+ if (strstr (foo + 1, "world") != foo + 6)
+ abort ();
+ if (strstr (foo + 2, p) != foo + 8)
+ abort ();
+ if (strstr (q, "") != q)
+ abort ();
+ if (strstr (q + 1, "o") != q + 4)
+ abort ();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strstr (foo + 1, "world") != foo + 6)
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-asm.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,10 @@
+# Different translation units may have different user name overrides
+# and we do not preserve enough context to known which one we want.
+
+set torture_eval_before_compile {
+ if {[string match {*-flto*} "$option"]} {
+ continue
+ }
+}
+
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/strstr.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/strstr.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+/* Copyright (C) 2000 Free Software Foundation.
+
+ Ensure all expected transformations of builtin strstr occur and
+ perform correctly.
+
+ Written by Kaveh R. Ghazi, 11/6/2000. */
+
+extern void abort(void);
+extern char *strstr (const char *, const char *);
+
+void
+main_test (void)
+{
+ const char *const foo = "hello world";
+
+ if (strstr (foo, "") != foo)
+ abort();
+ if (strstr (foo + 4, "") != foo + 4)
+ abort();
+ if (strstr (foo, "h") != foo)
+ abort();
+ if (strstr (foo, "w") != foo + 6)
+ abort();
+ if (strstr (foo + 6, "o") != foo + 7)
+ abort();
+ if (strstr (foo + 1, "world") != foo + 6)
+ abort();
+
+ /* Test at least one instance of the __builtin_ style. We do this
+ to ensure that it works and that the prototype is correct. */
+ if (__builtin_strstr (foo + 1, "world") != foo + 6)
+ abort();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,321 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __vsnprintf_chk performs correctly. */
+
+#include <stdarg.h>
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern char *strcpy (char *, const char *);
+extern int memcmp (const void *, const void *, size_t);
+extern void *memset (void *, int, size_t);
+extern int vsnprintf (char *, size_t, const char *, va_list);
+
+#include "chk.h"
+
+const char s1[] = "123";
+char p[32] = "";
+char *s2 = "defg";
+char *s3 = "FGH";
+char *s4;
+size_t l1 = 1;
+static char buffer[32];
+char * volatile ptr = "barf"; /* prevent constant propagation to happen when whole program assumptions are made. */
+
+int
+__attribute__((noinline))
+test1_sub (int i, ...)
+{
+ int ret = 0;
+ va_list ap;
+ va_start (ap, i);
+ switch (i)
+ {
+ case 0:
+ vsnprintf (buffer, 4, "foo", ap);
+ break;
+ case 1:
+ ret = vsnprintf (buffer, 4, "foo bar", ap);
+ break;
+ case 2:
+ vsnprintf (buffer, 32, "%s", ap);
+ break;
+ case 3:
+ ret = vsnprintf (buffer, 21, "%s", ap);
+ break;
+ case 4:
+ ret = vsnprintf (buffer, 4, "%d%d%d", ap);
+ break;
+ case 5:
+ ret = vsnprintf (buffer, 32, "%d%d%d", ap);
+ break;
+ case 6:
+ ret = vsnprintf (buffer, strlen (ptr) + 1, "%s", ap);
+ break;
+ case 7:
+ vsnprintf (buffer, l1 + 31, "%d - %c", ap);
+ break;
+ case 8:
+ vsnprintf (s4, l1 + 6, "%d - %c", ap);
+ break;
+ }
+ va_end (ap);
+ return ret;
+}
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ chk_calls = 0;
+ /* vsnprintf_disallowed = 1; */
+
+ memset (buffer, 'A', 32);
+ test1_sub (0);
+ if (memcmp (buffer, "foo", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (test1_sub (1) != 7)
+ abort ();
+ if (memcmp (buffer, "foo", 4) || buffer[4] != 'A')
+ abort ();
+
+ vsnprintf_disallowed = 0;
+
+ memset (buffer, 'A', 32);
+ test1_sub (2, "bar");
+ if (memcmp (buffer, "bar", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (test1_sub (3, "bar") != 3)
+ abort ();
+ if (memcmp (buffer, "bar", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (test1_sub (4, (int) l1, (int) l1 + 1, (int) l1 + 12) != 4)
+ abort ();
+ if (memcmp (buffer, "121", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (test1_sub (5, (int) l1, (int) l1 + 1, (int) l1 + 12) != 4)
+ abort ();
+ if (memcmp (buffer, "1213", 5) || buffer[5] != 'A')
+ abort ();
+
+ if (chk_calls)
+ abort ();
+
+ memset (buffer, 'A', 32);
+ test1_sub (6, ptr);
+ if (memcmp (buffer, "barf", 5) || buffer[5] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ test1_sub (7, (int) l1 + 27, *ptr);
+ if (memcmp (buffer, "28 - b\0AAAAA", 12))
+ abort ();
+
+ if (chk_calls != 2)
+ abort ();
+ chk_calls = 0;
+
+ memset (s4, 'A', 32);
+ test1_sub (8, (int) l1 - 17, ptr[1]);
+ if (memcmp (s4, "-16 - \0AAA", 10))
+ abort ();
+ if (chk_calls)
+ abort ();
+}
+
+void
+__attribute__((noinline))
+test2_sub (int i, ...)
+{
+ va_list ap;
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int j;
+
+ va_start (ap, i);
+ /* The following calls should do runtime checking
+ - length is not known, but destination is. */
+ switch (i)
+ {
+ case 0:
+ vsnprintf (a.buf1 + 2, l1, "%s", ap);
+ break;
+ case 1:
+ vsnprintf (r, l1 + 4, "%s%c", ap);
+ break;
+ case 2:
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ vsnprintf (r, strlen (s2) - 2, "%c %s", ap);
+ break;
+ case 3:
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ vsnprintf (r + 2, l1, s3 + 3, ap);
+ break;
+ case 4:
+ case 7:
+ r = buf3;
+ for (j = 0; j < 4; ++j)
+ {
+ if (j == l1 - 1)
+ r = &a.buf1[1];
+ else if (j == l1)
+ r = &a.buf2[7];
+ else if (j == l1 + 1)
+ r = &buf3[5];
+ else if (j == l1 + 2)
+ r = &a.buf1[9];
+ }
+ if (i == 4)
+ vsnprintf (r, l1, s2 + 4, ap);
+ else
+ vsnprintf (r, 1, "a", ap);
+ break;
+ case 5:
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ vsnprintf (r, l1 + 3, "%s", ap);
+ break;
+ case 6:
+ vsnprintf (a.buf1 + 2, 4, "", ap);
+ break;
+ case 8:
+ vsnprintf (s4, 3, "%s %d", ap);
+ break;
+ }
+ va_end (ap);
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test2 (void)
+{
+ /* The following calls should do runtime checking
+ - length is not known, but destination is. */
+ chk_calls = 0;
+ test2_sub (0, s3 + 3);
+ test2_sub (1, s3 + 3, s3[3]);
+ test2_sub (2, s2[2], s2 + 4);
+ test2_sub (3);
+ test2_sub (4);
+ test2_sub (5, s1 + 1);
+ if (chk_calls != 6)
+ abort ();
+
+ /* Following have known destination and known source length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ /* vsnprintf_disallowed = 1; */
+ test2_sub (6);
+ test2_sub (7);
+ vsnprintf_disallowed = 0;
+ /* Unknown destination and source, no checking. */
+ test2_sub (8, s3, 0);
+ if (chk_calls)
+ abort ();
+}
+
+void
+__attribute__((noinline))
+test3_sub (int i, ...)
+{
+ va_list ap;
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ va_start (ap, i);
+ /* The following calls should do runtime checking
+ - source length is not known, but destination is. */
+ switch (i)
+ {
+ case 0:
+ vsnprintf (&a.buf2[9], l1 + 1, "%c%s", ap);
+ break;
+ case 1:
+ vsnprintf (&a.buf2[7], l1 + 30, "%s%c", ap);
+ break;
+ case 2:
+ vsnprintf (&a.buf2[7], l1 + 3, "%d", ap);
+ break;
+ case 3:
+ vsnprintf (&buf3[17], l1 + 3, "%s", ap);
+ break;
+ case 4:
+ vsnprintf (&buf3[19], 2, "a", ap);
+ break;
+ case 5:
+ vsnprintf (&buf3[16], 5, "a", ap);
+ break;
+ }
+ va_end (ap);
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ test3_sub (0, s2[3], s2 + 4);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ test3_sub (1, s3 + strlen (s3) - 2, *s3);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ test3_sub (2, (int) l1 + 9999);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ test3_sub (3, "abc");
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ test3_sub (4);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ test3_sub (5);
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (s2) : "0" (s2));
+ __asm ("" : "=r" (s3) : "0" (s3));
+ __asm ("" : "=r" (l1) : "0" (l1));
+ s4 = p;
+ test1 ();
+ test2 ();
+ test3 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsnprintf-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test3_sub struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk-lib.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk-lib.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk-lib.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk-lib.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "lib/chk.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,290 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation.
+
+ Ensure builtin __vsprintf_chk performs correctly. */
+
+#include <stdarg.h>
+
+extern void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern size_t strlen(const char *);
+extern void *memcpy (void *, const void *, size_t);
+extern char *strcpy (char *, const char *);
+extern int memcmp (const void *, const void *, size_t);
+extern void *memset (void *, int, size_t);
+extern int vsprintf (char *, const char *, va_list);
+
+#include "chk.h"
+
+const char s1[] = "123";
+char p[32] = "";
+char *s2 = "defg";
+char *s3 = "FGH";
+char *s4;
+size_t l1 = 1;
+static char buffer[32];
+char * volatile ptr = "barf"; /* prevent constant propagation to happen when whole program assumptions are made. */
+
+int
+__attribute__((noinline))
+test1_sub (int i, ...)
+{
+ int ret = 0;
+ va_list ap;
+ va_start (ap, i);
+ switch (i)
+ {
+ case 0:
+ vsprintf (buffer, "foo", ap);
+ break;
+ case 1:
+ ret = vsprintf (buffer, "foo", ap);
+ break;
+ case 2:
+ vsprintf (buffer, "%s", ap);
+ break;
+ case 3:
+ ret = vsprintf (buffer, "%s", ap);
+ break;
+ case 4:
+ vsprintf (buffer, "%d - %c", ap);
+ break;
+ case 5:
+ vsprintf (s4, "%d - %c", ap);
+ break;
+ }
+ va_end (ap);
+ return ret;
+}
+
+void
+__attribute__((noinline))
+test1 (void)
+{
+ chk_calls = 0;
+ vsprintf_disallowed = 1;
+
+ memset (buffer, 'A', 32);
+ test1_sub (0);
+ if (memcmp (buffer, "foo", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (test1_sub (1) != 3)
+ abort ();
+ if (memcmp (buffer, "foo", 4) || buffer[4] != 'A')
+ abort ();
+
+ if (chk_calls)
+ abort ();
+ vsprintf_disallowed = 0;
+
+ memset (buffer, 'A', 32);
+ test1_sub (2, "bar");
+ if (memcmp (buffer, "bar", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ if (test1_sub (3, "bar") != 3)
+ abort ();
+ if (memcmp (buffer, "bar", 4) || buffer[4] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ test1_sub (2, ptr);
+ if (memcmp (buffer, "barf", 5) || buffer[5] != 'A')
+ abort ();
+
+ memset (buffer, 'A', 32);
+ test1_sub (4, (int) l1 + 27, *ptr);
+ if (memcmp (buffer, "28 - b\0AAAAA", 12))
+ abort ();
+
+ if (chk_calls != 4)
+ abort ();
+ chk_calls = 0;
+
+ test1_sub (5, (int) l1 - 17, ptr[1]);
+ if (memcmp (s4, "-16 - a", 8))
+ abort ();
+ if (chk_calls)
+ abort ();
+}
+
+void
+__attribute__((noinline))
+test2_sub (int i, ...)
+{
+ va_list ap;
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];
+ char buf3[20];
+ int j;
+
+ va_start (ap, i);
+ /* The following calls should do runtime checking
+ - source length is not known, but destination is. */
+ switch (i)
+ {
+ case 0:
+ vsprintf (a.buf1 + 2, "%s", ap);
+ break;
+ case 1:
+ vsprintf (r, "%s%c", ap);
+ break;
+ case 2:
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ vsprintf (r, "%c %s", ap);
+ break;
+ case 3:
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ vsprintf (r + 2, s3 + 3, ap);
+ break;
+ case 4:
+ case 7:
+ r = buf3;
+ for (j = 0; j < 4; ++j)
+ {
+ if (j == l1 - 1)
+ r = &a.buf1[1];
+ else if (j == l1)
+ r = &a.buf2[7];
+ else if (j == l1 + 1)
+ r = &buf3[5];
+ else if (j == l1 + 2)
+ r = &a.buf1[9];
+ }
+ if (i == 4)
+ vsprintf (r, s2 + 4, ap);
+ else
+ vsprintf (r, "a", ap);
+ break;
+ case 5:
+ r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];
+ vsprintf (r, "%s", ap);
+ break;
+ case 6:
+ vsprintf (a.buf1 + 2, "", ap);
+ break;
+ case 8:
+ vsprintf (s4, "%s %d", ap);
+ break;
+ }
+ va_end (ap);
+}
+
+/* Test whether compile time checking is done where it should
+ and so is runtime object size checking. */
+void
+__attribute__((noinline))
+test2 (void)
+{
+ /* The following calls should do runtime checking
+ - source length is not known, but destination is. */
+ chk_calls = 0;
+ test2_sub (0, s3 + 3);
+ test2_sub (1, s3 + 3, s3[3]);
+ test2_sub (2, s2[2], s2 + 4);
+ test2_sub (3);
+ test2_sub (4);
+ test2_sub (5, s1 + 1);
+ if (chk_calls != 6)
+ abort ();
+
+ /* Following have known destination and known source length,
+ so if optimizing certainly shouldn't result in the checking
+ variants. */
+ chk_calls = 0;
+ vsprintf_disallowed = 1;
+ test2_sub (6);
+ test2_sub (7);
+ vsprintf_disallowed = 0;
+ /* Unknown destination and source, no checking. */
+ test2_sub (8, s3, 0);
+ if (chk_calls)
+ abort ();
+}
+
+void
+__attribute__((noinline))
+test3_sub (int i, ...)
+{
+ va_list ap;
+ struct A { char buf1[10]; char buf2[10]; } a;
+ char buf3[20];
+
+ va_start (ap, i);
+ /* The following calls should do runtime checking
+ - source length is not known, but destination is. */
+ switch (i)
+ {
+ case 0:
+ vsprintf (&a.buf2[9], "%c%s", ap);
+ break;
+ case 1:
+ vsprintf (&a.buf2[7], "%s%c", ap);
+ break;
+ case 2:
+ vsprintf (&a.buf2[7], "%d", ap);
+ break;
+ case 3:
+ vsprintf (&buf3[17], "%s", ap);
+ break;
+ case 4:
+ vsprintf (&buf3[19], "a", ap);
+ break;
+ }
+ va_end (ap);
+}
+
+/* Test whether runtime and/or compile time checking catches
+ buffer overflows. */
+void
+__attribute__((noinline))
+test3 (void)
+{
+ chk_fail_allowed = 1;
+ /* Runtime checks. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ test3_sub (0, s2[3], s2 + 4);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ test3_sub (1, s3 + strlen (s3) - 2, *s3);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ test3_sub (2, (int) l1 + 9999);
+ abort ();
+ }
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ test3_sub (3, "abc");
+ abort ();
+ }
+ /* This should be detectable at compile time already. */
+ if (__builtin_setjmp (chk_fail_buf) == 0)
+ {
+ test3_sub (4);
+ abort ();
+ }
+ chk_fail_allowed = 0;
+}
+
+void
+main_test (void)
+{
+#ifndef __OPTIMIZE__
+ /* Object size checking is only intended for -O[s123]. */
+ return;
+#endif
+ __asm ("" : "=r" (s2) : "0" (s2));
+ __asm ("" : "=r" (s3) : "0" (s3));
+ __asm ("" : "=r" (l1) : "0" (l1));
+ s4 = p;
+ test1 ();
+ test2 ();
+ test3 ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/builtins/vsprintf-chk.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+load_lib target-supports.exp
+
+if { ! [check_effective_target_nonlocal_goto] } {
+ return 1
+}
+
+if [istarget "epiphany-*-*"] {
+ # This test assumes the absence of struct padding.
+ # to make this true for test3_sub struct A on epiphany would require
+ # __attribute__((packed)) .
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/call-trap-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/call-trap-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/call-trap-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/call-trap-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+/* Undefined behavior from a call to a function cast to a different
+ type does not appear until after the function designator and
+ arguments have been evaluated. PR 38483. */
+/* Origin: Joseph Myers <joseph at codesourcery.com> */
+/* { dg-require-effective-target untyped_assembly } */
+
+extern void exit (int);
+extern void abort (void);
+
+int
+foo (void)
+{
+ exit (0);
+ return 0;
+}
+
+void
+bar (void)
+{
+}
+
+int
+main (void)
+{
+ ((long (*)(int))bar) (foo ());
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cbrt.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cbrt.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cbrt.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cbrt.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,92 @@
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+*/
+
+#ifndef __vax__
+static const unsigned long
+ B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */
+ B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */
+
+static const double
+ C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */
+ D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */
+ E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */
+ F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */
+ G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */
+
+double
+cbrtl (double x)
+{
+ long hx;
+ double r,s,w;
+ double lt;
+ unsigned sign;
+ typedef unsigned unsigned32 __attribute__((mode(SI)));
+ union {
+ double t;
+ unsigned32 pt[2];
+ } ut, ux;
+ int n0;
+
+ ut.t = 1.0;
+ n0 = (ut.pt[0] == 0);
+
+ ut.t = 0.0;
+ ux.t = x;
+
+ hx = ux.pt[n0]; /* high word of x */
+ sign=hx&0x80000000; /* sign= sign(x) */
+ hx ^=sign;
+ if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */
+ if((hx| ux.pt[1-n0])==0)
+ return(ux.t); /* cbrt(0) is itself */
+
+ ux.pt[n0] = hx;
+ /* rough cbrt to 5 bits */
+ if(hx<0x00100000) /* subnormal number */
+ {ut.pt[n0]=0x43500000; /* set t= 2**54 */
+ ut.t*=x; ut.pt[n0]=ut.pt[n0]/3+B2;
+ }
+ else
+ ut.pt[n0]=hx/3+B1;
+
+ /* new cbrt to 23 bits, may be implemented in single precision */
+ r=ut.t*ut.t/ux.t;
+ s=C+r*ut.t;
+ ut.t*=G+F/(s+E+D/s);
+
+ /* chopped to 20 bits and make it larger than cbrt(x) */
+ ut.pt[1-n0]=0; ut.pt[n0]+=0x00000001;
+
+ /* one step newton iteration to 53 bits with error less than 0.667 ulps */
+ s=ut.t*ut.t; /* t*t is exact */
+ r=ux.t/s;
+ w=ut.t+ut.t;
+ r=(r-ut.t)/(w+r); /* r-s is exact */
+ ut.t=ut.t+ut.t*r;
+
+ /* restore the sign bit */
+ ut.pt[n0] |= sign;
+
+ lt = ut.t;
+ lt -= (lt - (x/(lt*lt))) * 0.333333333333333333333;
+ return lt;
+}
+
+main ()
+{
+ if ((int) (cbrtl (27.0) + 0.5) != 3)
+ abort ();
+
+ exit (0);
+}
+#else
+main () { exit (0); }
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpdi-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpdi-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpdi-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpdi-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,218 @@
+#define F 140
+#define T 13
+
+feq (x, y)
+ long long int x;
+ long long int y;
+{
+ if (x == y)
+ return T;
+ else
+ return F;
+}
+
+fne (x, y)
+ long long int x;
+ long long int y;
+{
+ if (x != y)
+ return T;
+ else
+ return F;
+}
+
+flt (x, y)
+ long long int x;
+ long long int y;
+{
+ if (x < y)
+ return T;
+ else
+ return F;
+}
+
+fge (x, y)
+ long long int x;
+ long long int y;
+{
+ if (x >= y)
+ return T;
+ else
+ return F;
+}
+
+fgt (x, y)
+ long long int x;
+ long long int y;
+{
+ if (x > y)
+ return T;
+ else
+ return F;
+}
+
+fle (x, y)
+ long long int x;
+ long long int y;
+{
+ if (x <= y)
+ return T;
+ else
+ return F;
+}
+
+fltu (x, y)
+ unsigned long long int x;
+ unsigned long long int y;
+{
+ if (x < y)
+ return T;
+ else
+ return F;
+}
+
+fgeu (x, y)
+ unsigned long long int x;
+ unsigned long long int y;
+{
+ if (x >= y)
+ return T;
+ else
+ return F;
+}
+
+fgtu (x, y)
+ unsigned long long int x;
+ unsigned long long int y;
+{
+ if (x > y)
+ return T;
+ else
+ return F;
+}
+
+fleu (x, y)
+ unsigned long long int x;
+ unsigned long long int y;
+{
+ if (x <= y)
+ return T;
+ else
+ return F;
+}
+
+long long args[] =
+{
+ 0LL,
+ 1LL,
+ -1LL,
+ 0x7fffffffffffffffLL,
+ 0x8000000000000000LL,
+ 0x8000000000000001LL,
+ 0x1A3F237394D36C58LL,
+ 0x93850E92CAAC1B04LL
+};
+
+int correct_results[] =
+{
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, F, T, T, F,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, T, F, F, T,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ T, F, F, T, F, T, F, T, F, T
+};
+
+main ()
+{
+ int i, j, *res = correct_results;
+
+ for (i = 0; i < 8; i++)
+ {
+ long long arg0 = args[i];
+ for (j = 0; j < 8; j++)
+ {
+ long long arg1 = args[j];
+
+ if (feq (arg0, arg1) != *res++)
+ abort ();
+ if (fne (arg0, arg1) != *res++)
+ abort ();
+ if (flt (arg0, arg1) != *res++)
+ abort ();
+ if (fge (arg0, arg1) != *res++)
+ abort ();
+ if (fgt (arg0, arg1) != *res++)
+ abort ();
+ if (fle (arg0, arg1) != *res++)
+ abort ();
+ if (fltu (arg0, arg1) != *res++)
+ abort ();
+ if (fgeu (arg0, arg1) != *res++)
+ abort ();
+ if (fgtu (arg0, arg1) != *res++)
+ abort ();
+ if (fleu (arg0, arg1) != *res++)
+ abort ();
+ }
+ }
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsf-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsf-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsf-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsf-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,161 @@
+#include <limits.h>
+
+#define F 140
+#define T 13
+
+feq (float x, float y)
+{
+ if (x == y)
+ return T;
+ else
+ return F;
+}
+
+fne (float x, float y)
+{
+ if (x != y)
+ return T;
+ else
+ return F;
+}
+
+flt (float x, float y)
+{
+ if (x < y)
+ return T;
+ else
+ return F;
+}
+
+fge (float x, float y)
+{
+ if (x >= y)
+ return T;
+ else
+ return F;
+}
+
+fgt (float x, float y)
+{
+ if (x > y)
+ return T;
+ else
+ return F;
+}
+
+fle (float x, float y)
+{
+ if (x <= y)
+ return T;
+ else
+ return F;
+}
+
+float args[] =
+{
+ 0.0F,
+ 1.0F,
+ -1.0F,
+ __FLT_MAX__,
+ __FLT_MIN__,
+ 0.0000000000001F,
+ 123456789.0F,
+ -987654321.0F
+};
+
+int correct_results[] =
+{
+ T, F, F, T, F, T,
+ F, T, T, F, F, T,
+ F, T, F, T, T, F,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ T, F, F, T, F, T,
+ F, T, F, T, T, F,
+ F, T, T, F, F, T,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ F, T, T, F, F, T,
+ F, T, F, T, T, F,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ T, F, F, T, F, T,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ T, F, F, T, F, T,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ F, T, T, F, F, T,
+ F, T, F, T, T, F,
+ F, T, T, F, F, T,
+ T, F, F, T, F, T,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ F, T, T, F, F, T,
+ F, T, F, T, T, F,
+ F, T, T, F, F, T,
+ F, T, F, T, T, F,
+ T, F, F, T, F, T,
+ F, T, T, F, F, T,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ F, T, T, F, F, T,
+ F, T, F, T, T, F,
+ F, T, F, T, T, F,
+ T, F, F, T, F, T,
+ F, T, F, T, T, F,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ F, T, T, F, F, T,
+ T, F, F, T, F, T,
+};
+
+int
+main (void)
+{
+ int i, j, *res = correct_results;
+
+ for (i = 0; i < 8; i++)
+ {
+ float arg0 = args[i];
+ for (j = 0; j < 8; j++)
+ {
+ float arg1 = args[j];
+
+ if (feq (arg0, arg1) != *res++)
+ abort ();
+ if (fne (arg0, arg1) != *res++)
+ abort ();
+ if (flt (arg0, arg1) != *res++)
+ abort ();
+ if (fge (arg0, arg1) != *res++)
+ abort ();
+ if (fgt (arg0, arg1) != *res++)
+ abort ();
+ if (fle (arg0, arg1) != *res++)
+ abort ();
+ }
+ }
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsi-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsi-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsi-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsi-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+f1 (unsigned int x, unsigned int y)
+{
+ if (x == 0)
+ dummy ();
+ x -= y;
+ /* 0xfffffff2 < 0x80000000? */
+ if (x < ~(~(unsigned int) 0 >> 1))
+ abort ();
+ return x;
+}
+
+f2 (unsigned long int x, unsigned long int y)
+{
+ if (x == 0)
+ dummy ();
+ x -= y;
+ /* 0xfffffff2 < 0x80000000? */
+ if (x < ~(~(unsigned long int) 0 >> 1))
+ abort ();
+ return x;
+}
+
+
+dummy () {}
+
+main ()
+{
+ /* 0x7ffffff3 0x80000001 */
+ f1 ((~(unsigned int) 0 >> 1) - 12, ~(~(unsigned int) 0 >> 1) + 1);
+ f2 ((~(unsigned long int) 0 >> 1) - 12, ~(~(unsigned long int) 0 >> 1) + 1);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsi-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsi-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsi-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cmpsi-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,200 @@
+/* { dg-require-effective-target int32plus } */
+#define F 140
+#define T 13
+
+feq (int x, int y)
+{
+ if (x == y)
+ return T;
+ else
+ return F;
+}
+
+fne (int x, int y)
+{
+ if (x != y)
+ return T;
+ else
+ return F;
+}
+
+flt (int x, int y)
+{
+ if (x < y)
+ return T;
+ else
+ return F;
+}
+
+fge (int x, int y)
+{
+ if (x >= y)
+ return T;
+ else
+ return F;
+}
+
+fgt (int x, int y)
+{
+ if (x > y)
+ return T;
+ else
+ return F;
+}
+
+fle (int x, int y)
+{
+ if (x <= y)
+ return T;
+ else
+ return F;
+}
+
+fltu (unsigned int x, unsigned int y)
+{
+ if (x < y)
+ return T;
+ else
+ return F;
+}
+
+fgeu (unsigned int x, unsigned int y)
+{
+ if (x >= y)
+ return T;
+ else
+ return F;
+}
+
+fgtu (unsigned int x, unsigned int y)
+{
+ if (x > y)
+ return T;
+ else
+ return F;
+}
+
+fleu (unsigned int x, unsigned int y)
+{
+ if (x <= y)
+ return T;
+ else
+ return F;
+}
+
+unsigned int args[] =
+{
+ 0L,
+ 1L,
+ -1L,
+ 0x7fffffffL,
+ 0x80000000L,
+ 0x80000001L,
+ 0x1A3F2373L,
+ 0x93850E92L
+};
+
+int correct_results[] =
+{
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, F, T, T, F,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, T, F, F, T,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ T, F, F, T, F, T, F, T, F, T,
+ F, T, F, T, T, F, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, T, F, F, T, T, F, F, T,
+ F, T, T, F, F, T, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, F, T, T, F, F, T, T, F,
+ F, T, T, F, F, T, F, T, T, F,
+ T, F, F, T, F, T, F, T, F, T
+};
+
+int
+main (void)
+{
+ int i, j, *res = correct_results;
+
+ for (i = 0; i < 8; i++)
+ {
+ unsigned int arg0 = args[i];
+ for (j = 0; j < 8; j++)
+ {
+ unsigned int arg1 = args[j];
+
+ if (feq (arg0, arg1) != *res++)
+ abort ();
+ if (fne (arg0, arg1) != *res++)
+ abort ();
+ if (flt (arg0, arg1) != *res++)
+ abort ();
+ if (fge (arg0, arg1) != *res++)
+ abort ();
+ if (fgt (arg0, arg1) != *res++)
+ abort ();
+ if (fle (arg0, arg1) != *res++)
+ abort ();
+ if (fltu (arg0, arg1) != *res++)
+ abort ();
+ if (fgeu (arg0, arg1) != *res++)
+ abort ();
+ if (fgtu (arg0, arg1) != *res++)
+ abort ();
+ if (fleu (arg0, arg1) != *res++)
+ abort ();
+ }
+ }
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/comp-goto-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/comp-goto-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/comp-goto-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/comp-goto-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,167 @@
+/* { dg-require-effective-target label_values } */
+/* { dg-require-stack-size "4000" } */
+
+#include <stdlib.h>
+
+#if __INT_MAX__ >= 2147483647
+typedef unsigned int uint32;
+typedef signed int sint32;
+
+typedef uint32 reg_t;
+
+typedef unsigned long int host_addr_t;
+typedef uint32 target_addr_t;
+typedef sint32 target_saddr_t;
+
+typedef union
+{
+ struct
+ {
+ signed int offset:18;
+ unsigned int ignore:4;
+ unsigned int s1:8;
+ int :2;
+ signed int simm:14;
+ unsigned int s3:8;
+ unsigned int s2:8;
+ int pad2:2;
+ } f1;
+ long long ll;
+ double d;
+} insn_t;
+
+typedef struct
+{
+ target_addr_t vaddr_tag;
+ unsigned long int rigged_paddr;
+} tlb_entry_t;
+
+typedef struct
+{
+ insn_t *pc;
+ reg_t registers[256];
+ insn_t *program;
+ tlb_entry_t tlb_tab[0x100];
+} environment_t;
+
+enum operations
+{
+ LOAD32_RR,
+ METAOP_DONE
+};
+
+host_addr_t
+f ()
+{
+ abort ();
+}
+
+reg_t
+simulator_kernel (int what, environment_t *env)
+{
+ register insn_t *pc = env->pc;
+ register reg_t *regs = env->registers;
+ register insn_t insn;
+ register int s1;
+ register reg_t r2;
+ register void *base_addr = &&sim_base_addr;
+ register tlb_entry_t *tlb = env->tlb_tab;
+
+ if (what != 0)
+ {
+ int i;
+ static void *op_map[] =
+ {
+ &&L_LOAD32_RR,
+ &&L_METAOP_DONE,
+ };
+ insn_t *program = env->program;
+ for (i = 0; i < what; i++)
+ program[i].f1.offset = op_map[program[i].f1.offset] - base_addr;
+ }
+
+ sim_base_addr:;
+
+ insn = *pc++;
+ r2 = (*(reg_t *) (((char *) regs) + (insn.f1.s2 << 2)));
+ s1 = (insn.f1.s1 << 2);
+ goto *(base_addr + insn.f1.offset);
+
+ L_LOAD32_RR:
+ {
+ target_addr_t vaddr_page = r2 / 4096;
+ unsigned int x = vaddr_page % 0x100;
+ insn = *pc++;
+
+ for (;;)
+ {
+ target_addr_t tag = tlb[x].vaddr_tag;
+ host_addr_t rigged_paddr = tlb[x].rigged_paddr;
+
+ if (tag == vaddr_page)
+ {
+ *(reg_t *) (((char *) regs) + s1) = *(uint32 *) (rigged_paddr + r2);
+ r2 = *(reg_t *) (((char *) regs) + (insn.f1.s2 << 2));
+ s1 = insn.f1.s1 << 2;
+ goto *(base_addr + insn.f1.offset);
+ }
+
+ if (((target_saddr_t) tag < 0))
+ {
+ *(reg_t *) (((char *) regs) + s1) = *(uint32 *) f ();
+ r2 = *(reg_t *) (((char *) regs) + (insn.f1.s2 << 2));
+ s1 = insn.f1.s1 << 2;
+ goto *(base_addr + insn.f1.offset);
+ }
+
+ x = (x - 1) % 0x100;
+ }
+
+ L_METAOP_DONE:
+ return (*(reg_t *) (((char *) regs) + s1));
+ }
+}
+
+insn_t program[2 + 1];
+
+void *malloc ();
+
+int
+main ()
+{
+ environment_t env;
+ insn_t insn;
+ int i, res;
+ host_addr_t a_page = (host_addr_t) malloc (2 * 4096);
+ target_addr_t a_vaddr = 0x123450;
+ target_addr_t vaddr_page = a_vaddr / 4096;
+ a_page = (a_page + 4096 - 1) & -4096;
+
+ env.tlb_tab[((vaddr_page) % 0x100)].vaddr_tag = vaddr_page;
+ env.tlb_tab[((vaddr_page) % 0x100)].rigged_paddr = a_page - vaddr_page * 4096;
+ insn.f1.offset = LOAD32_RR;
+ env.registers[0] = 0;
+ env.registers[2] = a_vaddr;
+ *(sint32 *) (a_page + a_vaddr % 4096) = 88;
+ insn.f1.s1 = 0;
+ insn.f1.s2 = 2;
+
+ for (i = 0; i < 2; i++)
+ program[i] = insn;
+
+ insn.f1.offset = METAOP_DONE;
+ insn.f1.s1 = 0;
+ program[2] = insn;
+
+ env.pc = program;
+ env.program = program;
+
+ res = simulator_kernel (2 + 1, &env);
+
+ if (res != 88)
+ abort ();
+ exit (0);
+}
+#else
+main(){ exit (0); }
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/comp-goto-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/comp-goto-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/comp-goto-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/comp-goto-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+/* { dg-require-effective-target label_values } */
+/* { dg-require-effective-target trampolines } */
+/* { dg-add-options stack_size } */
+
+/* A slight variation of 920501-7.c. */
+
+#ifdef STACK_SIZE
+#define DEPTH ((STACK_SIZE) / 512 + 1)
+#else
+#define DEPTH 1000
+#endif
+
+x(a)
+{
+ __label__ xlab;
+ void y(a)
+ {
+ void *x = &&llab;
+ if (a==-1)
+ goto *x;
+ if (a==0)
+ goto xlab;
+ llab:
+ y (a-1);
+ }
+ y (a);
+ xlab:;
+ return a;
+}
+
+main ()
+{
+
+ if (x (DEPTH) != DEPTH)
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,118 @@
+/* Copyright (C) 2002 Free Software Foundation.
+
+ Test for correctness of composite comparisons.
+
+ Written by Roger Sayle, 3rd June 2002. */
+
+extern void abort (void);
+
+int ieq (int x, int y, int ok)
+{
+ if ((x<=y) && (x>=y))
+ {
+ if (!ok) abort ();
+ }
+ else
+ if (ok) abort ();
+
+ if ((x<=y) && (x==y))
+ {
+ if (!ok) abort ();
+ }
+ else
+ if (ok) abort ();
+
+ if ((x<=y) && (y<=x))
+ {
+ if (!ok) abort ();
+ }
+ else
+ if (ok) abort ();
+
+ if ((y==x) && (x<=y))
+ {
+ if (!ok) abort ();
+ }
+ else
+ if (ok) abort ();
+}
+
+int ine (int x, int y, int ok)
+{
+ if ((x<y) || (x>y))
+ {
+ if (!ok) abort ();
+ }
+ else
+ if (ok) abort ();
+}
+
+int ilt (int x, int y, int ok)
+{
+ if ((x<y) && (x!=y))
+ {
+ if (!ok) abort ();
+ }
+ else
+ if (ok) abort ();
+}
+
+int ile (int x, int y, int ok)
+{
+ if ((x<y) || (x==y))
+ {
+ if (!ok) abort ();
+ }
+ else
+ if (ok) abort ();
+}
+
+int igt (int x, int y, int ok)
+{
+ if ((x>y) && (x!=y))
+ {
+ if (!ok) abort ();
+ }
+ else
+ if (ok) abort ();
+}
+
+int ige (int x, int y, int ok)
+{
+ if ((x>y) || (x==y))
+ {
+ if (!ok) abort ();
+ }
+ else
+ if (ok) abort ();
+}
+
+int
+main ()
+{
+ ieq (1, 4, 0);
+ ieq (3, 3, 1);
+ ieq (5, 2, 0);
+
+ ine (1, 4, 1);
+ ine (3, 3, 0);
+ ine (5, 2, 1);
+
+ ilt (1, 4, 1);
+ ilt (3, 3, 0);
+ ilt (5, 2, 0);
+
+ ile (1, 4, 1);
+ ile (3, 3, 1);
+ ile (5, 2, 0);
+
+ igt (1, 4, 0);
+ igt (3, 3, 0);
+ igt (5, 2, 1);
+
+ ige (1, 4, 0);
+ ige (3, 3, 1);
+ ige (5, 2, 1);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* Copyright (C) 2002 Free Software Foundation.
+
+ Ensure that the composite comparison optimization doesn't misfire
+ and attempt to combine a signed comparison with an unsigned one.
+
+ Written by Roger Sayle, 3rd June 2002. */
+
+extern void abort (void);
+
+int
+foo (int x, int y)
+{
+ /* If miscompiled the following may become "x == y". */
+ return (x<=y) && ((unsigned int)x >= (unsigned int)y);
+}
+
+int
+main ()
+{
+ if (! foo (-1,0))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compare-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,85 @@
+/* Copyright (C) 2002 Free Software Foundation.
+
+ Test for composite comparison always true/false optimization.
+
+ Written by Roger Sayle, 7th June 2002. */
+
+extern void link_error0 ();
+extern void link_error1 ();
+
+void
+test1 (int x, int y)
+{
+ if ((x==y) && (x!=y))
+ link_error0();
+}
+
+void
+test2 (int x, int y)
+{
+ if ((x<y) && (x>y))
+ link_error0();
+}
+
+void
+test3 (int x, int y)
+{
+ if ((x<y) && (y<x))
+ link_error0();
+}
+
+void
+test4 (int x, int y)
+{
+ if ((x==y) || (x!=y))
+ {
+ }
+ else
+ link_error1 ();
+}
+
+void
+test5 (int x, int y)
+{
+ if ((x>=y) || (x<y))
+ {
+ }
+ else
+ link_error1 ();
+}
+
+void
+test6 (int x, int y)
+{
+ if ((x<=y) || (y<x))
+ {
+ }
+ else
+ link_error1 ();
+}
+
+void
+all_tests (int x, int y)
+{
+ test1 (x, y);
+ test2 (x, y);
+ test3 (x, y);
+ test4 (x, y);
+ test5 (x, y);
+ test6 (x, y);
+}
+
+int
+main ()
+{
+ all_tests (0, 0);
+ all_tests (1, 2);
+ all_tests (4, 3);
+
+ return 0;
+}
+
+#ifndef __OPTIMIZE__
+void link_error0() {}
+void link_error1() {}
+#endif /* ! __OPTIMIZE__ */
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,40 @@
+double
+g0 (double x)
+{
+ return 1.0;
+}
+
+double
+g1 (double x)
+{
+ return -1.0;
+}
+
+double
+g2 (double x)
+{
+ return 0.0;
+}
+
+__complex__ double
+xcexp (__complex__ double x)
+{
+ double r;
+
+ r = g0 (__real__ x);
+ __real__ x = r * g1 (__imag__ x);
+ __imag__ x = r * g2 (__imag__ x);
+ return x;
+}
+
+main ()
+{
+ __complex__ double x;
+
+ x = xcexp (1.0i);
+ if (__real__ x != -1.0)
+ abort ();
+ if (__imag__ x != 0.0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+__complex__ double
+f (__complex__ double x, __complex__ double y)
+{
+ x += y;
+ return x;
+}
+
+__complex__ double ag = 1.0 + 1.0i;
+__complex__ double bg = -2.0 + 2.0i;
+
+main ()
+{
+ __complex__ double a, b, c;
+
+ a = ag;
+ b = -2.0 + 2.0i;
+ c = f (a, b);
+
+ if (a != 1.0 + 1.0i)
+ abort ();
+ if (b != -2.0 + 2.0i)
+ abort ();
+ if (c != -1.0 + 3.0i)
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+struct complex
+{
+ float r;
+ float i;
+};
+
+struct complex cmplx (float, float);
+
+struct complex
+f (float a, float b)
+{
+ struct complex c;
+ c.r = a;
+ c.i = b;
+ return c;
+}
+
+main ()
+{
+ struct complex z = f (1.0, 0.0);
+
+ if (z.r != 1.0 || z.i != 0.0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,9 @@
+main ()
+{
+ if ((__complex__ double) 0.0 != (__complex__ double) (-0.0))
+ abort ();
+
+ if (0.0 != -0.0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+float __complex__
+p (float __complex__ a, float __complex__ b)
+{
+ return a + b;
+}
+
+float __complex__ x = 1.0 + 14.0 * (1.0fi);
+float __complex__ y = 7.0 + 5.0 * (1.0fi);
+float __complex__ w = 8.0 + 19.0 * (1.0fi);
+float __complex__ z;
+
+main ()
+{
+
+ z = p (x,y);
+ y = p (x, 1.0f / z);
+ if (z != w)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-6.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-6.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-6.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-6.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,61 @@
+/* { dg-skip-if "requires io" { freestanding } } */
+
+/* This test tests complex conjugate and passing/returning of
+ complex parameter. */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int err;
+
+#define TEST(TYPE, FUNC) \
+__complex__ TYPE \
+ctest_ ## FUNC (__complex__ TYPE x) \
+{ \
+ __complex__ TYPE res; \
+ \
+ res = ~x; \
+ \
+ return res; \
+} \
+ \
+void \
+test_ ## FUNC (void) \
+{ \
+ __complex__ TYPE res, x; \
+ \
+ x = 1.0 + 2.0i; \
+ \
+ res = ctest_ ## FUNC (x); \
+ \
+ if (res != 1.0 - 2.0i) \
+ { \
+ printf ("test_" #FUNC " failed\n"); \
+ ++err; \
+ } \
+}
+
+
+TEST(float, float)
+TEST(double, double)
+TEST(long double, long_double)
+TEST(int, int)
+TEST(long int, long_int)
+
+int
+main (void)
+{
+
+ err = 0;
+
+ test_float ();
+ test_double ();
+ test_long_double ();
+ test_int ();
+ test_long_int ();
+
+ if (err != 0)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-7.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-7.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-7.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/complex-7.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,56 @@
+/* Test argument passing of complex values. The MIPS64 compiler had a
+ bug when they were split between registers and the stack. */
+/* Origin: Joseph Myers <joseph at codesourcery.com> */
+
+volatile _Complex float f1 = 1.1f + 2.2if;
+volatile _Complex float f2 = 3.3f + 4.4if;
+volatile _Complex float f3 = 5.5f + 6.6if;
+volatile _Complex float f4 = 7.7f + 8.8if;
+volatile _Complex float f5 = 9.9f + 10.1if;
+volatile _Complex double d1 = 1.1 + 2.2i;
+volatile _Complex double d2 = 3.3 + 4.4i;
+volatile _Complex double d3 = 5.5 + 6.6i;
+volatile _Complex double d4 = 7.7 + 8.8i;
+volatile _Complex double d5 = 9.9 + 10.1i;
+volatile _Complex long double ld1 = 1.1L + 2.2iL;
+volatile _Complex long double ld2 = 3.3L + 4.4iL;
+volatile _Complex long double ld3 = 5.5L + 6.6iL;
+volatile _Complex long double ld4 = 7.7L + 8.8iL;
+volatile _Complex long double ld5 = 9.9L + 10.1iL;
+
+extern void abort (void);
+extern void exit (int);
+
+__attribute__((noinline)) void
+check_float (int a, _Complex float a1, _Complex float a2,
+ _Complex float a3, _Complex float a4, _Complex float a5)
+{
+ if (a1 != f1 || a2 != f2 || a3 != f3 || a4 != f4 || a5 != f5)
+ abort ();
+}
+
+__attribute__((noinline)) void
+check_double (int a, _Complex double a1, _Complex double a2,
+ _Complex double a3, _Complex double a4, _Complex double a5)
+{
+ if (a1 != d1 || a2 != d2 || a3 != d3 || a4 != d4 || a5 != d5)
+ abort ();
+}
+
+__attribute__((noinline)) void
+check_long_double (int a, _Complex long double a1, _Complex long double a2,
+ _Complex long double a3, _Complex long double a4,
+ _Complex long double a5)
+{
+ if (a1 != ld1 || a2 != ld2 || a3 != ld3 || a4 != ld4 || a5 != ld5)
+ abort ();
+}
+
+int
+main (void)
+{
+ check_float (0, f1, f2, f3, f4, f5);
+ check_double (0, d1, d2, d3, d4, d5);
+ check_long_double (0, ld1, ld2, ld3, ld4, ld5);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compndlit-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compndlit-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compndlit-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/compndlit-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* The bit-field below would have a problem if __INT_MAX__ is too
+ small. */
+#if __INT_MAX__ < 2147483647
+int
+main (void)
+{
+ exit (0);
+}
+#else
+struct S
+{
+ int a:3;
+ unsigned b:1, c:28;
+};
+
+struct S x = {1, 1, 1};
+
+main ()
+{
+ x = (struct S) {b:0, a:0, c:({ struct S o = x; o.a == 1 ? 10 : 20;})};
+ if (x.c != 10)
+ abort ();
+ exit (0);
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/const-addr-expr-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/const-addr-expr-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/const-addr-expr-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/const-addr-expr-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <stdlib.h>
+extern void abort();
+
+typedef struct foo
+{
+ int uaattrid;
+ char *name;
+} FOO;
+
+FOO Upgrade_items[] =
+{
+ {1, "1"},
+ {2, "2"},
+ {0, NULL}
+};
+
+int *Upgd_minor_ID =
+ (int *) &((Upgrade_items + 1)->uaattrid);
+
+int *Upgd_minor_ID1 =
+ (int *) &((Upgrade_items)->uaattrid);
+
+int
+main(int argc, char **argv)
+{
+ if (*Upgd_minor_ID != 2)
+ abort();
+
+ if (*Upgd_minor_ID1 != 1)
+ abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/conversion.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/conversion.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/conversion.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/conversion.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,551 @@
+/* Test front-end conversions, optimizer conversions, and run-time
+ conversions between different arithmetic types.
+
+ Constants are specified in a non-obvious way to make them work for
+ any word size. Their value on a 32-bit machine is indicated in the
+ comments.
+
+ Note that this code is NOT intended for testing of accuracy of fp
+ conversions. */
+
+float
+u2f(u)
+ unsigned int u;
+{
+ return u;
+}
+
+double
+u2d(u)
+ unsigned int u;
+{
+ return u;
+}
+
+long double
+u2ld(u)
+ unsigned int u;
+{
+ return u;
+}
+
+float
+s2f(s)
+ int s;
+{
+ return s;
+}
+
+double
+s2d(s)
+ int s;
+{
+ return s;
+}
+
+long double
+s2ld(s)
+ int s;
+{
+ return s;
+}
+
+int
+fnear (float x, float y)
+{
+ float t = x - y;
+ return t == 0 || x / t > 1000000.0;
+}
+
+int
+dnear (double x, double y)
+{
+ double t = x - y;
+ return t == 0 || x / t > 100000000000000.0;
+}
+
+int
+ldnear (long double x, long double y)
+{
+ long double t = x - y;
+ return t == 0 || x / t > 100000000000000000000000000000000.0;
+}
+
+test_integer_to_float()
+{
+ if (u2f(0U) != (float) 0U) /* 0 */
+ abort();
+ if (!fnear (u2f(~0U), (float) ~0U)) /* 0xffffffff */
+ abort();
+ if (!fnear (u2f((~0U) >> 1), (float) ((~0U) >> 1))) /* 0x7fffffff */
+ abort();
+ if (u2f(~((~0U) >> 1)) != (float) ~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (u2d(0U) != (double) 0U) /* 0 */
+ abort();
+ if (!dnear (u2d(~0U), (double) ~0U)) /* 0xffffffff */
+ abort();
+ if (!dnear (u2d((~0U) >> 1),(double) ((~0U) >> 1))) /* 0x7fffffff */
+ abort();
+ if (u2d(~((~0U) >> 1)) != (double) ~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (u2ld(0U) != (long double) 0U) /* 0 */
+ abort();
+ if (!ldnear (u2ld(~0U), (long double) ~0U)) /* 0xffffffff */
+ abort();
+ if (!ldnear (u2ld((~0U) >> 1),(long double) ((~0U) >> 1))) /* 0x7fffffff */
+ abort();
+ if (u2ld(~((~0U) >> 1)) != (long double) ~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (s2f(0) != (float) 0) /* 0 */
+ abort();
+ if (!fnear (s2f(~0), (float) ~0)) /* 0xffffffff */
+ abort();
+ if (!fnear (s2f((int)((~0U) >> 1)), (float)(int)((~0U) >> 1))) /* 0x7fffffff */
+ abort();
+ if (s2f((int)(~((~0U) >> 1))) != (float)(int)~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (s2d(0) != (double) 0) /* 0 */
+ abort();
+ if (!dnear (s2d(~0), (double) ~0)) /* 0xffffffff */
+ abort();
+ if (!dnear (s2d((int)((~0U) >> 1)), (double)(int)((~0U) >> 1))) /* 0x7fffffff */
+ abort();
+ if (s2d((int)~((~0U) >> 1)) != (double)(int)~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (s2ld(0) != (long double) 0) /* 0 */
+ abort();
+ if (!ldnear (s2ld(~0), (long double) ~0)) /* 0xffffffff */
+ abort();
+ if (!ldnear (s2ld((int)((~0U) >> 1)), (long double)(int)((~0U) >> 1))) /* 0x7fffffff */
+ abort();
+ if (s2ld((int)~((~0U) >> 1)) != (long double)(int)~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+}
+
+#if __GNUC__
+float
+ull2f(u)
+ unsigned long long int u;
+{
+ return u;
+}
+
+double
+ull2d(u)
+ unsigned long long int u;
+{
+ return u;
+}
+
+long double
+ull2ld(u)
+ unsigned long long int u;
+{
+ return u;
+}
+
+float
+sll2f(s)
+ long long int s;
+{
+ return s;
+}
+
+double
+sll2d(s)
+ long long int s;
+{
+ return s;
+}
+
+long double
+sll2ld(s)
+ long long int s;
+{
+ return s;
+}
+
+test_longlong_integer_to_float()
+{
+ if (ull2f(0ULL) != (float) 0ULL) /* 0 */
+ abort();
+ if (ull2f(~0ULL) != (float) ~0ULL) /* 0xffffffff */
+ abort();
+ if (ull2f((~0ULL) >> 1) != (float) ((~0ULL) >> 1)) /* 0x7fffffff */
+ abort();
+ if (ull2f(~((~0ULL) >> 1)) != (float) ~((~0ULL) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (ull2d(0ULL) != (double) 0ULL) /* 0 */
+ abort();
+#if __HAVE_68881__
+ /* Some 68881 targets return values in fp0, with excess precision.
+ But the compile-time conversion to double works correctly. */
+ if (! dnear (ull2d(~0ULL), (double) ~0ULL)) /* 0xffffffff */
+ abort();
+ if (! dnear (ull2d((~0ULL) >> 1), (double) ((~0ULL) >> 1))) /* 0x7fffffff */
+ abort();
+#else
+ if (ull2d(~0ULL) != (double) ~0ULL) /* 0xffffffff */
+ abort();
+ if (ull2d((~0ULL) >> 1) != (double) ((~0ULL) >> 1)) /* 0x7fffffff */
+ abort();
+#endif
+ if (ull2d(~((~0ULL) >> 1)) != (double) ~((~0ULL) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (ull2ld(0ULL) != (long double) 0ULL) /* 0 */
+ abort();
+ if (ull2ld(~0ULL) != (long double) ~0ULL) /* 0xffffffff */
+ abort();
+ if (ull2ld((~0ULL) >> 1) != (long double) ((~0ULL) >> 1)) /* 0x7fffffff */
+ abort();
+ if (ull2ld(~((~0ULL) >> 1)) != (long double) ~((~0ULL) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (sll2f(0LL) != (float) 0LL) /* 0 */
+ abort();
+ if (sll2f(~0LL) != (float) ~0LL) /* 0xffffffff */
+ abort();
+ if (! fnear (sll2f((long long int)((~0ULL) >> 1)), (float)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */
+ abort();
+ if (sll2f((long long int)(~((~0ULL) >> 1))) != (float)(long long int)~((~0ULL) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (sll2d(0LL) != (double) 0LL) /* 0 */
+ abort();
+ if (sll2d(~0LL) != (double) ~0LL) /* 0xffffffff */
+ abort();
+ if (!dnear (sll2d((long long int)((~0ULL) >> 1)), (double)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */
+ abort();
+ if (! dnear (sll2d((long long int)~((~0ULL) >> 1)), (double)(long long int)~((~0ULL) >> 1))) /* 0x80000000 */
+ abort();
+
+ if (sll2ld(0LL) != (long double) 0LL) /* 0 */
+ abort();
+ if (sll2ld(~0LL) != (long double) ~0LL) /* 0xffffffff */
+ abort();
+ if (!ldnear (sll2ld((long long int)((~0ULL) >> 1)), (long double)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */
+ abort();
+ if (! ldnear (sll2ld((long long int)~((~0ULL) >> 1)), (long double)(long long int)~((~0ULL) >> 1))) /* 0x80000000 */
+ abort();
+}
+#endif
+
+unsigned int
+f2u(float f)
+{
+ return (unsigned) f;
+}
+
+unsigned int
+d2u(double d)
+{
+ return (unsigned) d;
+}
+
+unsigned int
+ld2u(long double d)
+{
+ return (unsigned) d;
+}
+
+int
+f2s(float f)
+{
+ return (int) f;
+}
+
+int
+d2s(double d)
+{
+ return (int) d;
+}
+
+int
+ld2s(long double d)
+{
+ return (int) d;
+}
+
+test_float_to_integer()
+{
+ if (f2u(0.0) != 0)
+ abort();
+ if (f2u(0.999) != 0)
+ abort();
+ if (f2u(1.0) != 1)
+ abort();
+ if (f2u(1.99) != 1)
+ abort();
+#ifdef __SPU__
+ /* SPU float rounds towards zero. */
+ if (f2u((float) ((~0U) >> 1)) != 0x7fffff80)
+ abort();
+#else
+ if (f2u((float) ((~0U) >> 1)) != (~0U) >> 1 && /* 0x7fffffff */
+ f2u((float) ((~0U) >> 1)) != ((~0U) >> 1) + 1)
+ abort();
+#endif
+ if (f2u((float) ~((~0U) >> 1)) != ~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+
+ /* These tests require double precision, so for hosts that don't offer
+ that much precision, just ignore these test. */
+ if (sizeof (double) >= 8) {
+ if (d2u(0.0) != 0)
+ abort();
+ if (d2u(0.999) != 0)
+ abort();
+ if (d2u(1.0) != 1)
+ abort();
+ if (d2u(1.99) != 1)
+ abort();
+ if (d2u((double) (~0U)) != ~0U) /* 0xffffffff */
+ abort();
+ if (d2u((double) ((~0U) >> 1)) != (~0U) >> 1) /* 0x7fffffff */
+ abort();
+ if (d2u((double) ~((~0U) >> 1)) != ~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+ }
+
+ /* These tests require long double precision, so for hosts that don't offer
+ that much precision, just ignore these test. */
+ if (sizeof (long double) >= 8) {
+ if (ld2u(0.0) != 0)
+ abort();
+ if (ld2u(0.999) != 0)
+ abort();
+ if (ld2u(1.0) != 1)
+ abort();
+ if (ld2u(1.99) != 1)
+ abort();
+ if (ld2u((long double) (~0U)) != ~0U) /* 0xffffffff */
+ abort();
+ if (ld2u((long double) ((~0U) >> 1)) != (~0U) >> 1) /* 0x7fffffff */
+ abort();
+ if (ld2u((long double) ~((~0U) >> 1)) != ~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+ }
+
+ if (f2s(0.0) != 0)
+ abort();
+ if (f2s(0.999) != 0)
+ abort();
+ if (f2s(1.0) != 1)
+ abort();
+ if (f2s(1.99) != 1)
+ abort();
+ if (f2s(-0.999) != 0)
+ abort();
+ if (f2s(-1.0) != -1)
+ abort();
+ if (f2s(-1.99) != -1)
+ abort();
+ if (f2s((float)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+
+ /* These tests require double precision, so for hosts that don't offer
+ that much precision, just ignore these test. */
+ if (sizeof (double) >= 8) {
+ if (d2s(0.0) != 0)
+ abort();
+ if (d2s(0.999) != 0)
+ abort();
+ if (d2s(1.0) != 1)
+ abort();
+ if (d2s(1.99) != 1)
+ abort();
+ if (d2s(-0.999) != 0)
+ abort();
+ if (d2s(-1.0) != -1)
+ abort();
+ if (d2s(-1.99) != -1)
+ abort();
+ if (d2s((double) ((~0U) >> 1)) != (~0U) >> 1) /* 0x7fffffff */
+ abort();
+ if (d2s((double)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+ }
+
+ /* These tests require long double precision, so for hosts that don't offer
+ that much precision, just ignore these test. */
+ if (sizeof (long double) >= 8) {
+ if (ld2s(0.0) != 0)
+ abort();
+ if (ld2s(0.999) != 0)
+ abort();
+ if (ld2s(1.0) != 1)
+ abort();
+ if (ld2s(1.99) != 1)
+ abort();
+ if (ld2s(-0.999) != 0)
+ abort();
+ if (ld2s(-1.0) != -1)
+ abort();
+ if (ld2s(-1.99) != -1)
+ abort();
+ if (ld2s((long double) ((~0U) >> 1)) != (~0U) >> 1) /* 0x7fffffff */
+ abort();
+ if (ld2s((long double)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */
+ abort();
+ }
+}
+
+#if __GNUC__
+unsigned long long int
+f2ull(float f)
+{
+ return (unsigned long long int) f;
+}
+
+unsigned long long int
+d2ull(double d)
+{
+ return (unsigned long long int) d;
+}
+
+unsigned long long int
+ld2ull(long double d)
+{
+ return (unsigned long long int) d;
+}
+
+long long int
+f2sll(float f)
+{
+ return (long long int) f;
+}
+
+long long int
+d2sll(double d)
+{
+ return (long long int) d;
+}
+
+long long int
+ld2sll(long double d)
+{
+ return (long long int) d;
+}
+
+test_float_to_longlong_integer()
+{
+ if (f2ull(0.0) != 0LL)
+ abort();
+ if (f2ull(0.999) != 0LL)
+ abort();
+ if (f2ull(1.0) != 1LL)
+ abort();
+ if (f2ull(1.99) != 1LL)
+ abort();
+#ifdef __SPU__
+ /* SPU float rounds towards zero. */
+ if (f2ull((float) ((~0ULL) >> 1)) != 0x7fffff8000000000ULL)
+ abort();
+#else
+ if (f2ull((float) ((~0ULL) >> 1)) != (~0ULL) >> 1 && /* 0x7fffffff */
+ f2ull((float) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1)
+ abort();
+#endif
+ if (f2ull((float) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (d2ull(0.0) != 0LL)
+ abort();
+ if (d2ull(0.999) != 0LL)
+ abort();
+ if (d2ull(1.0) != 1LL)
+ abort();
+ if (d2ull(1.99) != 1LL)
+ abort();
+ if (d2ull((double) ((~0ULL) >> 1)) != (~0ULL) >> 1 && /* 0x7fffffff */
+ d2ull((double) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1)
+ abort();
+ if (d2ull((double) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (ld2ull(0.0) != 0LL)
+ abort();
+ if (ld2ull(0.999) != 0LL)
+ abort();
+ if (ld2ull(1.0) != 1LL)
+ abort();
+ if (ld2ull(1.99) != 1LL)
+ abort();
+ if (ld2ull((long double) ((~0ULL) >> 1)) != (~0ULL) >> 1 && /* 0x7fffffff */
+ ld2ull((long double) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1)
+ abort();
+ if (ld2ull((long double) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */
+ abort();
+
+
+ if (f2sll(0.0) != 0LL)
+ abort();
+ if (f2sll(0.999) != 0LL)
+ abort();
+ if (f2sll(1.0) != 1LL)
+ abort();
+ if (f2sll(1.99) != 1LL)
+ abort();
+ if (f2sll(-0.999) != 0LL)
+ abort();
+ if (f2sll(-1.0) != -1LL)
+ abort();
+ if (f2sll(-1.99) != -1LL)
+ abort();
+ if (f2sll((float)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (d2sll(0.0) != 0LL)
+ abort();
+ if (d2sll(0.999) != 0LL)
+ abort();
+ if (d2sll(1.0) != 1LL)
+ abort();
+ if (d2sll(1.99) != 1LL)
+ abort();
+ if (d2sll(-0.999) != 0LL)
+ abort();
+ if (d2sll(-1.0) != -1LL)
+ abort();
+ if (d2sll(-1.99) != -1LL)
+ abort();
+ if (d2sll((double)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */
+ abort();
+
+ if (ld2sll(0.0) != 0LL)
+ abort();
+ if (ld2sll(0.999) != 0LL)
+ abort();
+ if (ld2sll(1.0) != 1LL)
+ abort();
+ if (ld2sll(1.99) != 1LL)
+ abort();
+ if (ld2sll(-0.999) != 0LL)
+ abort();
+ if (ld2sll(-1.0) != -1LL)
+ abort();
+ if (ld2sll(-1.99) != -1LL)
+ abort();
+ if (ld2sll((long double)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */
+ abort();
+}
+#endif
+
+main()
+{
+ test_integer_to_float();
+ test_float_to_integer();
+#if __GNUC__
+ test_longlong_integer_to_float();
+ test_float_to_longlong_integer();
+#endif
+ exit(0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cvt-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cvt-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cvt-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/cvt-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+static inline long
+g1 (double x)
+{
+ return (double) (long) x;
+}
+
+long
+g2 (double f)
+{
+ return f;
+}
+
+double
+f (long i)
+{
+ if (g1 (i) != g2 (i))
+ abort ();
+ return g2 (i);
+}
+
+main ()
+{
+ if (f (123456789L) != 123456789L)
+ abort ();
+ if (f (123456789L) != g2 (123456789L))
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/dbra-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/dbra-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/dbra-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/dbra-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,95 @@
+f1 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (--a == -1)
+ return i;
+ }
+ return -1;
+}
+
+f2 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (--a != -1)
+ return i;
+ }
+ return -1;
+}
+
+f3 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (--a == 0)
+ return i;
+ }
+ return -1;
+}
+
+f4 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (--a != 0)
+ return i;
+ }
+ return -1;
+}
+
+f5 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (++a == 0)
+ return i;
+ }
+ return -1;
+}
+
+f6 (a)
+ long a;
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (++a != 0)
+ return i;
+ }
+ return -1;
+}
+
+
+main()
+{
+ if (f1 (5L) != 5)
+ abort ();
+ if (f2 (1L) != 0)
+ abort ();
+ if (f2 (0L) != 1)
+ abort ();
+ if (f3 (5L) != 4)
+ abort ();
+ if (f4 (1L) != 1)
+ abort ();
+ if (f4 (0L) != 0)
+ abort ();
+ if (f5 (-5L) != 4)
+ abort ();
+ if (f6 (-1L) != 1)
+ abort ();
+ if (f6 (0L) != 0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,355 @@
+extern void abort(void);
+
+int test1(int x)
+{
+ return x/10 == 2;
+}
+
+int test1u(unsigned int x)
+{
+ return x/10U == 2;
+}
+
+int test2(int x)
+{
+ return x/10 == 0;
+}
+
+int test2u(unsigned int x)
+{
+ return x/10U == 0;
+}
+
+int test3(int x)
+{
+ return x/10 != 2;
+}
+
+int test3u(unsigned int x)
+{
+ return x/10U != 2;
+}
+
+int test4(int x)
+{
+ return x/10 != 0;
+}
+
+int test4u(unsigned int x)
+{
+ return x/10U != 0;
+}
+
+int test5(int x)
+{
+ return x/10 < 2;
+}
+
+int test5u(unsigned int x)
+{
+ return x/10U < 2;
+}
+
+int test6(int x)
+{
+ return x/10 < 0;
+}
+
+int test7(int x)
+{
+ return x/10 <= 2;
+}
+
+int test7u(unsigned int x)
+{
+ return x/10U <= 2;
+}
+
+int test8(int x)
+{
+ return x/10 <= 0;
+}
+
+int test8u(unsigned int x)
+{
+ return x/10U <= 0;
+}
+
+int test9(int x)
+{
+ return x/10 > 2;
+}
+
+int test9u(unsigned int x)
+{
+ return x/10U > 2;
+}
+
+int test10(int x)
+{
+ return x/10 > 0;
+}
+
+int test10u(unsigned int x)
+{
+ return x/10U > 0;
+}
+
+int test11(int x)
+{
+ return x/10 >= 2;
+}
+
+int test11u(unsigned int x)
+{
+ return x/10U >= 2;
+}
+
+int test12(int x)
+{
+ return x/10 >= 0;
+}
+
+
+int main()
+{
+ if (test1(19) != 0)
+ abort ();
+ if (test1(20) != 1)
+ abort ();
+ if (test1(29) != 1)
+ abort ();
+ if (test1(30) != 0)
+ abort ();
+
+ if (test1u(19) != 0)
+ abort ();
+ if (test1u(20) != 1)
+ abort ();
+ if (test1u(29) != 1)
+ abort ();
+ if (test1u(30) != 0)
+ abort ();
+
+ if (test2(0) != 1)
+ abort ();
+ if (test2(9) != 1)
+ abort ();
+ if (test2(10) != 0)
+ abort ();
+ if (test2(-1) != 1)
+ abort ();
+ if (test2(-9) != 1)
+ abort ();
+ if (test2(-10) != 0)
+ abort ();
+
+ if (test2u(0) != 1)
+ abort ();
+ if (test2u(9) != 1)
+ abort ();
+ if (test2u(10) != 0)
+ abort ();
+ if (test2u(-1) != 0)
+ abort ();
+ if (test2u(-9) != 0)
+ abort ();
+ if (test2u(-10) != 0)
+ abort ();
+
+ if (test3(19) != 1)
+ abort ();
+ if (test3(20) != 0)
+ abort ();
+ if (test3(29) != 0)
+ abort ();
+ if (test3(30) != 1)
+ abort ();
+
+ if (test3u(19) != 1)
+ abort ();
+ if (test3u(20) != 0)
+ abort ();
+ if (test3u(29) != 0)
+ abort ();
+ if (test3u(30) != 1)
+ abort ();
+
+ if (test4(0) != 0)
+ abort ();
+ if (test4(9) != 0)
+ abort ();
+ if (test4(10) != 1)
+ abort ();
+ if (test4(-1) != 0)
+ abort ();
+ if (test4(-9) != 0)
+ abort ();
+ if (test4(-10) != 1)
+ abort ();
+
+ if (test4u(0) != 0)
+ abort ();
+ if (test4u(9) != 0)
+ abort ();
+ if (test4u(10) != 1)
+ abort ();
+ if (test4u(-1) != 1)
+ abort ();
+ if (test4u(-9) != 1)
+ abort ();
+ if (test4u(-10) != 1)
+ abort ();
+
+ if (test5(19) != 1)
+ abort ();
+ if (test5(20) != 0)
+ abort ();
+ if (test5(29) != 0)
+ abort ();
+ if (test5(30) != 0)
+ abort ();
+
+ if (test5u(19) != 1)
+ abort ();
+ if (test5u(20) != 0)
+ abort ();
+ if (test5u(29) != 0)
+ abort ();
+ if (test5u(30) != 0)
+ abort ();
+
+ if (test6(0) != 0)
+ abort ();
+ if (test6(9) != 0)
+ abort ();
+ if (test6(10) != 0)
+ abort ();
+ if (test6(-1) != 0)
+ abort ();
+ if (test6(-9) != 0)
+ abort ();
+ if (test6(-10) != 1)
+ abort ();
+
+ if (test7(19) != 1)
+ abort ();
+ if (test7(20) != 1)
+ abort ();
+ if (test7(29) != 1)
+ abort ();
+ if (test7(30) != 0)
+ abort ();
+
+ if (test7u(19) != 1)
+ abort ();
+ if (test7u(20) != 1)
+ abort ();
+ if (test7u(29) != 1)
+ abort ();
+ if (test7u(30) != 0)
+ abort ();
+
+ if (test8(0) != 1)
+ abort ();
+ if (test8(9) != 1)
+ abort ();
+ if (test8(10) != 0)
+ abort ();
+ if (test8(-1) != 1)
+ abort ();
+ if (test8(-9) != 1)
+ abort ();
+ if (test8(-10) != 1)
+ abort ();
+
+ if (test8u(0) != 1)
+ abort ();
+ if (test8u(9) != 1)
+ abort ();
+ if (test8u(10) != 0)
+ abort ();
+ if (test8u(-1) != 0)
+ abort ();
+ if (test8u(-9) != 0)
+ abort ();
+ if (test8u(-10) != 0)
+ abort ();
+
+ if (test9(19) != 0)
+ abort ();
+ if (test9(20) != 0)
+ abort ();
+ if (test9(29) != 0)
+ abort ();
+ if (test9(30) != 1)
+ abort ();
+
+ if (test9u(19) != 0)
+ abort ();
+ if (test9u(20) != 0)
+ abort ();
+ if (test9u(29) != 0)
+ abort ();
+ if (test9u(30) != 1)
+ abort ();
+
+ if (test10(0) != 0)
+ abort ();
+ if (test10(9) != 0)
+ abort ();
+ if (test10(10) != 1)
+ abort ();
+ if (test10(-1) != 0)
+ abort ();
+ if (test10(-9) != 0)
+ abort ();
+ if (test10(-10) != 0)
+ abort ();
+
+ if (test10u(0) != 0)
+ abort ();
+ if (test10u(9) != 0)
+ abort ();
+ if (test10u(10) != 1)
+ abort ();
+ if (test10u(-1) != 1)
+ abort ();
+ if (test10u(-9) != 1)
+ abort ();
+ if (test10u(-10) != 1)
+ abort ();
+
+ if (test11(19) != 0)
+ abort ();
+ if (test11(20) != 1)
+ abort ();
+ if (test11(29) != 1)
+ abort ();
+ if (test11(30) != 1)
+ abort ();
+
+ if (test11u(19) != 0)
+ abort ();
+ if (test11u(20) != 1)
+ abort ();
+ if (test11u(29) != 1)
+ abort ();
+ if (test11u(30) != 1)
+ abort ();
+
+ if (test12(0) != 1)
+ abort ();
+ if (test12(9) != 1)
+ abort ();
+ if (test12(10) != 1)
+ abort ();
+ if (test12(-1) != 1)
+ abort ();
+ if (test12(-9) != 1)
+ abort ();
+ if (test12(-10) != 0)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,91 @@
+extern void abort (void);
+
+int test1(int x)
+{
+ return x/10 == 2;
+}
+
+int test2(int x)
+{
+ return x/10 == 0;
+}
+
+int test3(int x)
+{
+ return x/10 == -2;
+}
+
+int test4(int x)
+{
+ return x/-10 == 2;
+}
+
+int test5(int x)
+{
+ return x/-10 == 0;
+}
+
+int test6(int x)
+{
+ return x/-10 == -2;
+}
+
+
+int main()
+{
+ if (test1(19) != 0)
+ abort ();
+ if (test1(20) != 1)
+ abort ();
+ if (test1(29) != 1)
+ abort ();
+ if (test1(30) != 0)
+ abort ();
+
+ if (test2(-10) != 0)
+ abort ();
+ if (test2(-9) != 1)
+ abort ();
+ if (test2(9) != 1)
+ abort ();
+ if (test2(10) != 0)
+ abort ();
+
+ if (test3(-30) != 0)
+ abort ();
+ if (test3(-29) != 1)
+ abort ();
+ if (test3(-20) != 1)
+ abort ();
+ if (test3(-19) != 0)
+ abort ();
+
+ if (test4(-30) != 0)
+ abort ();
+ if (test4(-29) != 1)
+ abort ();
+ if (test4(-20) != 1)
+ abort ();
+ if (test4(-19) != 0)
+ abort ();
+
+ if (test5(-10) != 0)
+ abort ();
+ if (test5(-9) != 1)
+ abort ();
+ if (test5(9) != 1)
+ abort ();
+ if (test5(10) != 0)
+ abort ();
+
+ if (test6(19) != 0)
+ abort ();
+ if (test6(20) != 1)
+ abort ();
+ if (test6(29) != 1)
+ abort ();
+ if (test6(30) != 0)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,96 @@
+extern void abort(void);
+
+int test1(char x)
+{
+ return x/100 == 3;
+}
+
+int test1u(unsigned char x)
+{
+ return x/100 == 3;
+}
+
+int test2(char x)
+{
+ return x/100 != 3;
+}
+
+int test2u(unsigned char x)
+{
+ return x/100 != 3;
+}
+
+int test3(char x)
+{
+ return x/100 < 3;
+}
+
+int test3u(unsigned char x)
+{
+ return x/100 < 3;
+}
+
+int test4(char x)
+{
+ return x/100 <= 3;
+}
+
+int test4u(unsigned char x)
+{
+ return x/100 <= 3;
+}
+
+int test5(char x)
+{
+ return x/100 > 3;
+}
+
+int test5u(unsigned char x)
+{
+ return x/100 > 3;
+}
+
+int test6(char x)
+{
+ return x/100 >= 3;
+}
+
+int test6u(unsigned char x)
+{
+ return x/100 >= 3;
+}
+
+
+int main()
+{
+ int c;
+
+ for (c=-128; c<256; c++)
+ {
+ if (test1(c) != 0)
+ abort ();
+ if (test1u(c) != 0)
+ abort ();
+ if (test2(c) != 1)
+ abort ();
+ if (test2u(c) != 1)
+ abort ();
+ if (test3(c) != 1)
+ abort ();
+ if (test3u(c) != 1)
+ abort ();
+ if (test4(c) != 1)
+ abort ();
+ if (test4u(c) != 1)
+ abort ();
+ if (test5(c) != 0)
+ abort ();
+ if (test5u(c) != 0)
+ abort ();
+ if (test6(c) != 0)
+ abort ();
+ if (test6u(c) != 0)
+ abort ();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,201 @@
+/* PR middle-end/17894 */
+
+extern void abort(void);
+
+int test1(int x)
+{
+ return x/-10 == 2;
+}
+
+int test2(int x)
+{
+ return x/-10 == 0;
+}
+
+int test3(int x)
+{
+ return x/-10 != 2;
+}
+
+int test4(int x)
+{
+ return x/-10 != 0;
+}
+
+int test5(int x)
+{
+ return x/-10 < 2;
+}
+
+int test6(int x)
+{
+ return x/-10 < 0;
+}
+
+int test7(int x)
+{
+ return x/-10 <= 2;
+}
+
+int test8(int x)
+{
+ return x/-10 <= 0;
+}
+
+int test9(int x)
+{
+ return x/-10 > 2;
+}
+
+int test10(int x)
+{
+ return x/-10 > 0;
+}
+
+int test11(int x)
+{
+ return x/-10 >= 2;
+}
+
+int test12(int x)
+{
+ return x/-10 >= 0;
+}
+
+
+int main()
+{
+ if (test1(-30) != 0)
+ abort ();
+ if (test1(-29) != 1)
+ abort ();
+ if (test1(-20) != 1)
+ abort ();
+ if (test1(-19) != 0)
+ abort ();
+
+ if (test2(0) != 1)
+ abort ();
+ if (test2(9) != 1)
+ abort ();
+ if (test2(10) != 0)
+ abort ();
+ if (test2(-1) != 1)
+ abort ();
+ if (test2(-9) != 1)
+ abort ();
+ if (test2(-10) != 0)
+ abort ();
+
+ if (test3(-30) != 1)
+ abort ();
+ if (test3(-29) != 0)
+ abort ();
+ if (test3(-20) != 0)
+ abort ();
+ if (test3(-19) != 1)
+ abort ();
+
+ if (test4(0) != 0)
+ abort ();
+ if (test4(9) != 0)
+ abort ();
+ if (test4(10) != 1)
+ abort ();
+ if (test4(-1) != 0)
+ abort ();
+ if (test4(-9) != 0)
+ abort ();
+ if (test4(-10) != 1)
+ abort ();
+
+ if (test5(-30) != 0)
+ abort ();
+ if (test5(-29) != 0)
+ abort ();
+ if (test5(-20) != 0)
+ abort ();
+ if (test5(-19) != 1)
+ abort ();
+
+ if (test6(0) != 0)
+ abort ();
+ if (test6(9) != 0)
+ abort ();
+ if (test6(10) != 1)
+ abort ();
+ if (test6(-1) != 0)
+ abort ();
+ if (test6(-9) != 0)
+ abort ();
+ if (test6(-10) != 0)
+ abort ();
+
+ if (test7(-30) != 0)
+ abort ();
+ if (test7(-29) != 1)
+ abort ();
+ if (test7(-20) != 1)
+ abort ();
+ if (test7(-19) != 1)
+ abort ();
+
+ if (test8(0) != 1)
+ abort ();
+ if (test8(9) != 1)
+ abort ();
+ if (test8(10) != 1)
+ abort ();
+ if (test8(-1) != 1)
+ abort ();
+ if (test8(-9) != 1)
+ abort ();
+ if (test8(-10) != 0)
+ abort ();
+
+ if (test9(-30) != 1)
+ abort ();
+ if (test9(-29) != 0)
+ abort ();
+ if (test9(-20) != 0)
+ abort ();
+ if (test9(-19) != 0)
+ abort ();
+
+ if (test10(0) != 0)
+ abort ();
+ if (test10(9) != 0)
+ abort ();
+ if (test10(10) != 0)
+ abort ();
+ if (test10(-1) != 0)
+ abort ();
+ if (test10(-9) != 0)
+ abort ();
+ if (test10(-10) != 1)
+ abort ();
+
+ if (test11(-30) != 1)
+ abort ();
+ if (test11(-29) != 1)
+ abort ();
+ if (test11(-20) != 1)
+ abort ();
+ if (test11(-19) != 0)
+ abort ();
+
+ if (test12(0) != 1)
+ abort ();
+ if (test12(9) != 1)
+ abort ();
+ if (test12(10) != 0)
+ abort ();
+ if (test12(-1) != 1)
+ abort ();
+ if (test12(-9) != 1)
+ abort ();
+ if (test12(-10) != 1)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divcmp-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* PR middle-end/26561 */
+
+extern void abort(void);
+
+int always_one_1 (int a)
+{
+ if (a/100 >= -999999999)
+ return 1;
+ else
+ return 0;
+}
+
+int always_one_2 (int a)
+{
+ if (a/100 < -999999999)
+ return 0;
+ else
+ return 1;
+}
+
+int main(void)
+{
+ if (always_one_1 (0) != 1)
+ abort ();
+
+ if (always_one_2 (0) != 1)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+typedef struct
+{
+ unsigned a, b, c, d;
+} t1;
+
+f (t1 *ps)
+{
+ ps->a = 10000;
+ ps->b = ps->a / 3;
+ ps->c = 10000;
+ ps->d = ps->c / 3;
+}
+
+main ()
+{
+ t1 s;
+ f (&s);
+ if (s.a != 10000 || s.b != 3333 || s.c != 10000 || s.d != 3333)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,39 @@
+long
+f (long x)
+{
+ return x / (-0x7fffffffL - 1L);
+}
+
+long
+r (long x)
+{
+ return x % (-0x7fffffffL - 1L);
+}
+
+/* Since we have a negative divisor, this equation must hold for the
+ results of / and %; no specific results are guaranteed. */
+long
+std_eqn (long num, long denom, long quot, long rem)
+{
+ /* For completeness, a check for "ABS (rem) < ABS (denom)" belongs here,
+ but causes trouble on 32-bit machines and isn't worthwhile. */
+ return quot * (-0x7fffffffL - 1L) + rem == num;
+}
+
+long nums[] =
+{
+ -1L, 0x7fffffffL, -0x7fffffffL - 1L
+};
+
+main ()
+{
+ int i;
+
+ for (i = 0;
+ i < sizeof (nums) / sizeof (nums[0]);
+ i++)
+ if (std_eqn (nums[i], -0x7fffffffL - 1L, f (nums[i]), r (nums[i])) == 0)
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divconst-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,12 @@
+long long
+f (long long x)
+{
+ return x / 10000000000LL;
+}
+
+main ()
+{
+ if (f (10000000000LL) != 1 || f (100000000000LL) != 10)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divmod-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divmod-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divmod-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/divmod-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,77 @@
+div1 (signed char x)
+{
+ return x / -1;
+}
+
+div2 (signed short x)
+{
+ return x / -1;
+}
+
+div3 (signed char x, signed char y)
+{
+ return x / y;
+}
+
+div4 (signed short x, signed short y)
+{
+ return x / y;
+}
+
+mod1 (signed char x)
+{
+ return x % -1;
+}
+
+mod2 (signed short x)
+{
+ return x % -1;
+}
+
+mod3 (signed char x, signed char y)
+{
+ return x % y;
+}
+
+mod4 (signed short x, signed short y)
+{
+ return x % y;
+}
+
+signed long
+mod5 (signed long x, signed long y)
+{
+ return x % y;
+}
+
+unsigned long
+mod6 (unsigned long x, unsigned long y)
+{
+ return x % y;
+}
+
+main ()
+{
+ if (div1 (-(1 << 7)) != 1 << 7)
+ abort ();
+ if (div2 (-(1 << 15)) != 1 << 15)
+ abort ();
+ if (div3 (-(1 << 7), -1) != 1 << 7)
+ abort ();
+ if (div4 (-(1 << 15), -1) != 1 << 15)
+ abort ();
+ if (mod1 (-(1 << 7)) != 0)
+ abort ();
+ if (mod2 (-(1 << 15)) != 0)
+ abort ();
+ if (mod3 (-(1 << 7), -1) != 0)
+ abort ();
+ if (mod4 (-(1 << 15), -1) != 0)
+ abort ();
+ if (mod5 (0x50000000, 2) != 0)
+ abort ();
+ if (mod6 (0x50000000, 2) != 0)
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/doloop-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/doloop-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/doloop-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/doloop-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+#include <limits.h>
+
+extern void exit (int);
+extern void abort (void);
+
+volatile unsigned int i;
+
+int
+main (void)
+{
+ unsigned char z = 0;
+
+ do ++i;
+ while (--z > 0);
+ if (i != UCHAR_MAX + 1U)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/doloop-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/doloop-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/doloop-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/doloop-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+#include <limits.h>
+
+extern void exit (int);
+extern void abort (void);
+
+volatile unsigned int i;
+
+int
+main (void)
+{
+ unsigned short z = 0;
+
+ do ++i;
+ while (--z > 0);
+ if (i != USHRT_MAX + 1U)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/eeprof-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/eeprof-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/eeprof-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/eeprof-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,79 @@
+/* { dg-require-effective-target return_address } */
+/* { dg-options "-finstrument-functions" } */
+/* { dg-xfail-run-if "" { powerpc-ibm-aix* } } */
+
+extern void abort (void);
+
+#define ASSERT(X) if (!(X)) abort ();
+#define NOCHK __attribute__ ((no_instrument_function))
+
+int entry_calls, exit_calls;
+void (*last_fn_entered)();
+void (*last_fn_exited)();
+
+__attribute__ ((noinline))
+int main () NOCHK;
+
+__attribute__ ((noinline))
+void foo ()
+{
+ ASSERT (last_fn_entered == foo);
+}
+
+__attribute__ ((noinline))
+static void foo2 ()
+{
+ ASSERT (entry_calls == 1 && exit_calls == 0);
+ ASSERT (last_fn_entered == foo2);
+ foo ();
+ ASSERT (entry_calls == 2 && exit_calls == 1);
+ ASSERT (last_fn_entered == foo);
+ ASSERT (last_fn_exited == foo);
+}
+
+__attribute__ ((noinline))
+void nfoo (void) NOCHK;
+void nfoo ()
+{
+ ASSERT (entry_calls == 2 && exit_calls == 2);
+ ASSERT (last_fn_entered == foo);
+ ASSERT (last_fn_exited == foo2);
+ foo ();
+ ASSERT (entry_calls == 3 && exit_calls == 3);
+ ASSERT (last_fn_entered == foo);
+ ASSERT (last_fn_exited == foo);
+}
+
+int main ()
+{
+ ASSERT (entry_calls == 0 && exit_calls == 0);
+
+ foo2 ();
+
+ ASSERT (entry_calls == 2 && exit_calls == 2);
+ ASSERT (last_fn_entered == foo);
+ ASSERT (last_fn_exited == foo2);
+
+ nfoo ();
+
+ ASSERT (entry_calls == 3 && exit_calls == 3);
+ ASSERT (last_fn_entered == foo);
+
+ return 0;
+}
+
+void __cyg_profile_func_enter (void*, void*) NOCHK;
+void __cyg_profile_func_exit (void*, void*) NOCHK;
+
+__attribute__ ((noinline))
+void __cyg_profile_func_enter (void *fn, void *parent)
+{
+ entry_calls++;
+ last_fn_entered = (void (*)())fn;
+}
+__attribute__ ((noinline))
+void __cyg_profile_func_exit (void *fn, void *parent)
+{
+ exit_calls++;
+ last_fn_exited = (void (*)())fn;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,43 @@
+typedef enum
+{
+ END = -1,
+ EMPTY = (1 << 8 ) ,
+ BACKREF,
+ BEGLINE,
+ ENDLINE,
+ BEGWORD,
+ ENDWORD,
+ LIMWORD,
+ NOTLIMWORD,
+ QMARK,
+ STAR,
+ PLUS,
+ REPMN,
+ CAT,
+ OR,
+ ORTOP,
+ LPAREN,
+ RPAREN,
+ CSET
+} token;
+
+static token tok;
+
+static int
+atom ()
+{
+ if ((tok >= 0 && tok < (1 << 8 ) ) || tok >= CSET || tok == BACKREF
+ || tok == BEGLINE || tok == ENDLINE || tok == BEGWORD
+ || tok == ENDWORD || tok == LIMWORD || tok == NOTLIMWORD)
+ return 1;
+ else
+ return 0;
+}
+
+main ()
+{
+ tok = 0;
+ if (atom () != 1)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* Copyright (C) 2000 Free Software Foundation */
+/* by Alexandre Oliva <aoliva at redhat.com> */
+
+enum foo { FOO, BAR };
+
+/* Even though the underlying type of an enum is unspecified, the type
+ of enumeration constants is explicitly defined as int (6.4.4.3/2 in
+ the C99 Standard). Therefore, `i' must not be promoted to
+ `unsigned' in the comparison below; we must exit the loop when it
+ becomes negative. */
+
+int
+main ()
+{
+ int i;
+ for (i = BAR; i >= FOO; --i)
+ if (i == -1)
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/enum-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* The composite type of int and an enum compatible with int might be
+ either of the two types, but it isn't an unsigned type. */
+/* Origin: Joseph Myers <jsm at polyomino.org.uk> */
+
+#include <limits.h>
+
+#include <stdio.h>
+
+extern void abort (void);
+extern void exit (int);
+
+enum e { a = INT_MIN };
+
+int *p;
+enum e *q;
+int
+main (void)
+{
+ enum e x = a;
+ q = &x;
+ if (*(1 ? q : p) > 0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/execute.exp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/execute.exp?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/execute.exp (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/execute.exp Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+# Copyright (C) 1991-2019 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file was written by Rob Savoye. (rob at cygnus.com)
+# Modified and maintained by Jeffrey Wheat (cassidy at cygnus.com)
+
+#
+# These tests come from Torbjorn Granlund (tege at cygnus.com)
+# C torture test suite.
+#
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+set saved-dg-do-what-default ${dg-do-what-default}
+set dg-do-what-default "run"
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" "-w"
+set dg-do-what-default ${saved-dg-do-what-default}
+
+# All done.
+dg-finish
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/extzvsi.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/extzvsi.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/extzvsi.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/extzvsi.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+/* The bit-field below would have a problem if __INT_MAX__ is too
+ small. */
+#if __INT_MAX__ < 2147483647
+int
+main (void)
+{
+ exit (0);
+}
+#else
+/* Failed on powerpc due to bad extzvsi pattern. */
+
+struct ieee
+{
+ unsigned int negative:1;
+ unsigned int exponent:11;
+ unsigned int mantissa0:20;
+ unsigned int mantissa1:32;
+} x;
+
+unsigned int
+foo (void)
+{
+ unsigned int exponent;
+
+ exponent = x.exponent;
+ if (exponent == 0)
+ return 1;
+ else if (exponent > 1)
+ return 2;
+ return 0;
+}
+
+int
+main (void)
+{
+ x.exponent = 1;
+ if (foo () != 0)
+ abort ();
+ return 0;
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ffs-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ffs-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ffs-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ffs-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,12 @@
+__volatile int a = 0;
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ if (__builtin_ffs (a) != 0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ffs-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ffs-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ffs-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ffs-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,44 @@
+struct
+ {
+ int input;
+ int output;
+ }
+ffstesttab[] =
+ {
+#if __INT_MAX__ >= 2147483647
+ /* at least 32-bit integers */
+ { 0x80000000, 32 },
+ { 0xa5a5a5a5, 1 },
+ { 0x5a5a5a5a, 2 },
+ { 0xcafe0000, 18 },
+#endif
+#if __INT_MAX__ >= 32767
+ /* at least 16-bit integers */
+ { 0x8000, 16 },
+ { 0xa5a5, 1 },
+ { 0x5a5a, 2 },
+ { 0x0ca0, 6 },
+#endif
+#if __INT_MAX__ < 32767
+#error integers are too small
+#endif
+ };
+
+#define NFFSTESTS (sizeof (ffstesttab) / sizeof (ffstesttab[0]))
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ int i;
+
+ for (i = 0; i < NFFSTESTS; i++)
+ {
+ if (__builtin_ffs (ffstesttab[i].input) != ffstesttab[i].output)
+ abort ();
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/float-floor.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/float-floor.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/float-floor.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/float-floor.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+
+#if(__SIZEOF_DOUBLE__==8)
+double d = 1024.0 - 1.0 / 32768.0;
+#else
+double d = 1024.0 - 1.0 / 16384.0;
+#endif
+
+extern double floor(double);
+extern float floorf(float);
+extern void abort();
+
+int main() {
+
+ double df = floor(d);
+ float f1 = (float)floor(d);
+
+ if ((int)df != 1023 || (int)f1 != 1023)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/floatunsisf-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/floatunsisf-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/floatunsisf-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/floatunsisf-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* The fp-bit.c function __floatunsisf had a latent bug where guard bits
+ could be lost leading to incorrect rounding. */
+/* Origin: Joseph Myers <joseph at codesourcery.com> */
+
+extern void abort (void);
+extern void exit (int);
+#if __INT_MAX__ >= 0x7fffffff
+volatile unsigned u = 0x80000081;
+#else
+volatile unsigned long u = 0x80000081;
+#endif
+volatile float f1, f2;
+int
+main (void)
+{
+ f1 = (float) u;
+ f2 = (float) 0x80000081;
+ if (f1 != f2)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/fprintf-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/fprintf-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/fprintf-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/fprintf-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...) \
+ fprintf (stdout, args); \
+ if (fprintf (stdout, 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/fprintf-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/fprintf-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/fprintf-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/fprintf-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,53 @@
+/* Verify that calls to fprintf 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-skip-if "requires io" { freestanding } } */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main (void)
+{
+ char *tmpfname = tmpnam (0);
+ FILE *f = fopen (tmpfname, "w");
+ if (!f)
+ {
+ perror ("fopen for writing");
+ return 1;
+ }
+
+ fprintf (f, "1");
+ fprintf (f, "%c", '2');
+ fprintf (f, "%c%c", '3', '4');
+ fprintf (f, "%s", "5");
+ fprintf (f, "%s%s", "6", "7");
+ fprintf (f, "%i", 8);
+ fprintf (f, "%.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/fprintf-chk-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/fprintf-chk-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/fprintf-chk-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/fprintf-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))
+__fprintf_chk (FILE *f, 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 = vfprintf (f, fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+int
+main (void)
+{
+#define test(ret, opt, args...) \
+ should_optimize = opt; \
+ __fprintf_chk (stdout, 1, args); \
+ if (!should_optimize) \
+ abort (); \
+ should_optimize = 0; \
+ if (__fprintf_chk (stdout, 1, args) != ret) \
+ abort (); \
+ if (!should_optimize) \
+ abort ();
+ test (5, 1, "hello");
+ test (6, 1, "hello\n");
+ test (1, 1, "a");
+ test (0, 1, "");
+ test (5, 1, "%s", "hello");
+ test (6, 1, "%s", "hello\n");
+ test (1, 1, "%s", "a");
+ test (0, 1, "%s", "");
+ test (1, 1, "%c", 'x');
+ test (7, 0, "%s\n", "hello\n");
+ test (2, 0, "%d\n", 0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/frame-address.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/frame-address.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/frame-address.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/frame-address.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,45 @@
+/* { dg-require-effective-target return_address } */
+int check_fa_work (const char *, const char *) __attribute__((noinline));
+int check_fa_mid (const char *) __attribute__((noinline));
+int check_fa (char *) __attribute__((noinline));
+int how_much (void) __attribute__((noinline));
+
+int check_fa_work (const char *c, const char *f)
+{
+ const char d = 0;
+
+ if (c >= &d)
+ return c >= f && f >= &d;
+ else
+ return c <= f && f <= &d;
+}
+
+int check_fa_mid (const char *c)
+{
+ const char *f = __builtin_frame_address (0);
+
+ /* Prevent a tail call to check_fa_work, eliding the current stack frame. */
+ return check_fa_work (c, f) != 0;
+}
+
+int check_fa (char *unused)
+{
+ const char c = 0;
+
+ /* Prevent a tail call to check_fa_mid, eliding the current stack frame. */
+ return check_fa_mid (&c) != 0;
+}
+
+int how_much (void)
+{
+ return 8;
+}
+
+int main (void)
+{
+ char *unused = __builtin_alloca (how_much ());
+
+ if (!check_fa(unused))
+ abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/func-ptr-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/func-ptr-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/func-ptr-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/func-ptr-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+static double f (float a);
+static double (*fp) (float a);
+
+main ()
+{
+ fp = f;
+ if (fp ((float) 1) != 1.0)
+ abort ();
+ exit (0);
+}
+
+static double
+f (float a)
+{
+ return a;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/gofast.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/gofast.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/gofast.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/gofast.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,101 @@
+/* { dg-skip-if "requires io" { freestanding } } */
+
+/* Program to test gcc's usage of the gofast library. */
+
+/* The main guiding themes are to make it trivial to add test cases over time
+ and to make it easy for a program to parse the output to see if the right
+ libcalls are being made. */
+
+#include <stdio.h>
+
+float fp_add (float a, float b) { return a + b; }
+float fp_sub (float a, float b) { return a - b; }
+float fp_mul (float a, float b) { return a * b; }
+float fp_div (float a, float b) { return a / b; }
+float fp_neg (float a) { return -a; }
+
+double dp_add (double a, double b) { return a + b; }
+double dp_sub (double a, double b) { return a - b; }
+double dp_mul (double a, double b) { return a * b; }
+double dp_div (double a, double b) { return a / b; }
+double dp_neg (double a) { return -a; }
+
+double fp_to_dp (float f) { return f; }
+float dp_to_fp (double d) { return d; }
+
+int eqsf2 (float a, float b) { return a == b; }
+int nesf2 (float a, float b) { return a != b; }
+int gtsf2 (float a, float b) { return a > b; }
+int gesf2 (float a, float b) { return a >= b; }
+int ltsf2 (float a, float b) { return a < b; }
+int lesf2 (float a, float b) { return a <= b; }
+
+int eqdf2 (double a, double b) { return a == b; }
+int nedf2 (double a, double b) { return a != b; }
+int gtdf2 (double a, double b) { return a > b; }
+int gedf2 (double a, double b) { return a >= b; }
+int ltdf2 (double a, double b) { return a < b; }
+int ledf2 (double a, double b) { return a <= b; }
+
+float floatsisf (int i) { return i; }
+double floatsidf (int i) { return i; }
+int fixsfsi (float f) { return f; }
+int fixdfsi (double d) { return d; }
+unsigned int fixunssfsi (float f) { return f; }
+unsigned int fixunsdfsi (double d) { return d; }
+
+int fail_count = 0;
+
+int
+fail (char *msg)
+{
+ fail_count++;
+ fprintf (stderr, "Test failed: %s\n", msg);
+}
+
+int
+main()
+{
+ if (fp_add (1, 1) != 2) fail ("fp_add 1+1");
+ if (fp_sub (3, 2) != 1) fail ("fp_sub 3-2");
+ if (fp_mul (2, 3) != 6) fail ("fp_mul 2*3");
+ if (fp_div (3, 2) != 1.5) fail ("fp_div 3/2");
+ if (fp_neg (1) != -1) fail ("fp_neg 1");
+
+ if (dp_add (1, 1) != 2) fail ("dp_add 1+1");
+ if (dp_sub (3, 2) != 1) fail ("dp_sub 3-2");
+ if (dp_mul (2, 3) != 6) fail ("dp_mul 2*3");
+ if (dp_div (3, 2) != 1.5) fail ("dp_div 3/2");
+ if (dp_neg (1) != -1) fail ("dp_neg 1");
+
+ if (fp_to_dp (1.5) != 1.5) fail ("fp_to_dp 1.5");
+ if (dp_to_fp (1.5) != 1.5) fail ("dp_to_fp 1.5");
+
+ if (floatsisf (1) != 1) fail ("floatsisf 1");
+ if (floatsidf (1) != 1) fail ("floatsidf 1");
+ if (fixsfsi (1.42) != 1) fail ("fixsfsi 1.42");
+ if (fixunssfsi (1.42) != 1) fail ("fixunssfsi 1.42");
+ if (fixdfsi (1.42) != 1) fail ("fixdfsi 1.42");
+ if (fixunsdfsi (1.42) != 1) fail ("fixunsdfsi 1.42");
+
+ if (eqsf2 (1, 1) == 0) fail ("eqsf2 1==1");
+ if (eqsf2 (1, 2) != 0) fail ("eqsf2 1==2");
+ if (nesf2 (1, 2) == 0) fail ("nesf2 1!=1");
+ if (nesf2 (1, 1) != 0) fail ("nesf2 1!=1");
+ if (gtsf2 (2, 1) == 0) fail ("gtsf2 2>1");
+ if (gtsf2 (1, 1) != 0) fail ("gtsf2 1>1");
+ if (gtsf2 (0, 1) != 0) fail ("gtsf2 0>1");
+ if (gesf2 (2, 1) == 0) fail ("gesf2 2>=1");
+ if (gesf2 (1, 1) == 0) fail ("gesf2 1>=1");
+ if (gesf2 (0, 1) != 0) fail ("gesf2 0>=1");
+ if (ltsf2 (1, 2) == 0) fail ("ltsf2 1<2");
+ if (ltsf2 (1, 1) != 0) fail ("ltsf2 1<1");
+ if (ltsf2 (1, 0) != 0) fail ("ltsf2 1<0");
+ if (lesf2 (1, 2) == 0) fail ("lesf2 1<=2");
+ if (lesf2 (1, 1) == 0) fail ("lesf2 1<=1");
+ if (lesf2 (1, 0) != 0) fail ("lesf2 1<=0");
+
+ if (fail_count != 0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20000320-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20000320-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20000320-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20000320-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,93 @@
+#if __INT_MAX__ != 2147483647 || (__LONG_LONG_MAX__ != 9223372036854775807ll && __LONG_MAX__ != 9223372036854775807ll)
+int main(void) { exit (0); }
+#else
+#if __LONG_MAX__ != 9223372036854775807ll
+typedef unsigned long long ull;
+#else
+typedef unsigned long ull;
+#endif
+typedef unsigned ul;
+
+union fl {
+ float f;
+ ul l;
+} uf;
+union dl {
+ double d;
+ ull ll;
+} ud;
+
+int failed = 0;
+
+void c(ull d, ul f)
+{
+ ud.ll = d;
+ uf.f = (float) ud.d;
+ if (uf.l != f)
+ {
+ failed++;
+ }
+}
+
+int main()
+{
+ if (sizeof (float) != sizeof (ul)
+ || sizeof (double) != sizeof (ull))
+ exit (0);
+
+#if (defined __arm__ || defined __thumb__) && ! (defined __ARMEB__ || defined __VFP_FP__)
+ /* The ARM always stores FP numbers in big-wordian format,
+ even when running in little-byteian mode. */
+ c(0x0000000036900000ULL, 0x00000000U);
+ c(0x0000000136900000ULL, 0x00000001U);
+ c(0xffffffff369fffffULL, 0x00000001U);
+ c(0x0000000036A00000ULL, 0x00000001U);
+ c(0xffffffff36A7ffffULL, 0x00000001U);
+ c(0x0000000036A80000ULL, 0x00000002U);
+ c(0xffffffff36AfffffULL, 0x00000002U);
+ c(0x0000000036b00000ULL, 0x00000002U);
+ c(0x0000000136b00000ULL, 0x00000002U);
+
+ c(0xdfffffff380fffffULL, 0x007fffffU);
+ c(0xe0000000380fffffULL, 0x00800000U);
+ c(0xe0000001380fffffULL, 0x00800000U);
+ c(0xffffffff380fffffULL, 0x00800000U);
+ c(0x0000000038100000ULL, 0x00800000U);
+ c(0x0000000138100000ULL, 0x00800000U);
+ c(0x1000000038100000ULL, 0x00800000U);
+ c(0x1000000138100000ULL, 0x00800001U);
+ c(0x2fffffff38100000ULL, 0x00800001U);
+ c(0x3000000038100000ULL, 0x00800002U);
+ c(0x5000000038100000ULL, 0x00800002U);
+ c(0x5000000138100000ULL, 0x00800003U);
+#else
+ c(0x3690000000000000ULL, 0x00000000U);
+ c(0x3690000000000001ULL, 0x00000001U);
+ c(0x369fffffffffffffULL, 0x00000001U);
+ c(0x36A0000000000000ULL, 0x00000001U);
+ c(0x36A7ffffffffffffULL, 0x00000001U);
+ c(0x36A8000000000000ULL, 0x00000002U);
+ c(0x36AfffffffffffffULL, 0x00000002U);
+ c(0x36b0000000000000ULL, 0x00000002U);
+ c(0x36b0000000000001ULL, 0x00000002U);
+
+ c(0x380fffffdfffffffULL, 0x007fffffU);
+ c(0x380fffffe0000000ULL, 0x00800000U);
+ c(0x380fffffe0000001ULL, 0x00800000U);
+ c(0x380fffffffffffffULL, 0x00800000U);
+ c(0x3810000000000000ULL, 0x00800000U);
+ c(0x3810000000000001ULL, 0x00800000U);
+ c(0x3810000010000000ULL, 0x00800000U);
+ c(0x3810000010000001ULL, 0x00800001U);
+ c(0x381000002fffffffULL, 0x00800001U);
+ c(0x3810000030000000ULL, 0x00800002U);
+ c(0x3810000050000000ULL, 0x00800002U);
+ c(0x3810000050000001ULL, 0x00800003U);
+#endif
+
+ if (failed)
+ abort ();
+ else
+ exit (0);
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20000320-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20000320-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20000320-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20000320-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+if {[istarget "m68k-*-*"] && [check_effective_target_coldfire_fpu]} {
+ # ColdFire FPUs require software handling of subnormals. We are
+ # not aware of any system that has this.
+ set torture_execute_xfail "m68k-*-*"
+}
+if [istarget "avr-*-*"] {
+ # AVR doubles are floats
+ return 1
+}
+if { [istarget "tic6x-*-*"] && [check_effective_target_ti_c67x] } {
+ # C6X floating point hardware turns denormals to zero in FP conversions.
+ set torture_execute_xfail "tic6x-*-*"
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20001122-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20001122-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20001122-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20001122-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+volatile double a, *p;
+
+int main ()
+{
+ double c, d;
+ volatile double b;
+
+ d = 1.0;
+ p = &b;
+ do
+ {
+ c = d;
+ d = c * 0.5;
+ b = 1 + d;
+ } while (b != 1.0);
+
+ a = 1.0 + c;
+ if (a == 1.0)
+ abort();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010114-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010114-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010114-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010114-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+extern void exit (int);
+extern void abort (void);
+
+float
+rintf (float x)
+{
+ static const float TWO23 = 8388608.0;
+
+ if (__builtin_fabs (x) < TWO23)
+ {
+ if (x > 0.0)
+ {
+ x += TWO23;
+ x -= TWO23;
+ }
+ else if (x < 0.0)
+ {
+ x = TWO23 - x;
+ x = -(x - TWO23);
+ }
+ }
+
+ return x;
+}
+
+int main (void)
+{
+ if (rintf (-1.5) != -2.0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010114-2.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010114-2.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010114-2.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010114-2.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,6 @@
+if [istarget "spu-*-*"] {
+ # This doesn't work on the SPU because single precision floats are
+ # always rounded toward 0.
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010226-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010226-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010226-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20010226-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+#include <float.h>
+
+long double dfrom = 1.1L;
+long double m1;
+long double m2;
+unsigned long mant_long;
+
+int main()
+{
+ /* Some targets don't support a conforming long double type. This is
+ common with very small parts which set long double == float. Look
+ to see if the type has at least 32 bits of precision. */
+ if (LDBL_EPSILON > 0x1p-31L)
+ return 0;
+
+ m1 = dfrom / 2.0L;
+ m2 = m1 * 4294967296.0L;
+ mant_long = ((unsigned long) m2) & 0xffffffff;
+
+ if (mant_long == 0x8ccccccc)
+ return 0;
+ else
+ abort();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20011123-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20011123-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20011123-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20011123-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,12 @@
+main()
+{
+ double db1 = 1.7976931348623157e+308;
+ long double ldb1 = db1;
+
+ if (sizeof (double) != 8 || sizeof (long double) != 16)
+ exit (0);
+
+ if (ldb1 != 1.7976931348623157e+308)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20030331-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20030331-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20030331-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20030331-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+extern void exit (int);
+extern void abort (void);
+float x = -1.5f;
+
+float
+rintf ()
+{
+ static const float TWO23 = 8388608.0;
+
+ if (__builtin_fabs (x) < TWO23)
+ {
+ if (x > 0.0)
+ {
+ x += TWO23;
+ x -= TWO23;
+ }
+ else if (x < 0.0)
+ {
+ x = TWO23 - x;
+ x = -(x - TWO23);
+ }
+ }
+
+ return x;
+}
+
+int main (void)
+{
+ if (rintf () != -2.0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20030331-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20030331-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20030331-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20030331-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,6 @@
+if [istarget "spu-*-*"] {
+ # This doesn't work on the SPU because single precision floats are
+ # always rounded toward 0.
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20041213-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20041213-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20041213-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/20041213-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+extern double sqrt (double);
+extern void abort (void);
+int once;
+
+double foo (void)
+{
+ if (once++)
+ abort ();
+ return 0.0 / 0.0;
+}
+
+double x;
+int main (void)
+{
+ x = sqrt (foo ());
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920518-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920518-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920518-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920518-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,8 @@
+unsigned u=2147483839;float f0=2147483648e0,f1=2147483904e0;
+main()
+{
+ float f=u;
+ if(f==f0)
+ abort();
+ exit(0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920518-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920518-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920518-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920518-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,6 @@
+if [istarget "spu-*-*"] {
+ # This doesn't work on the SPU because single precision floats are
+ # always rounded toward 0.
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920810-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920810-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920810-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920810-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,3 @@
+#include <stdio.h>
+double normalize(x)double x;{if(x==0)x=0;return x;}
+main(){char b[9];sprintf(b,"%g",normalize(-0.0));if(strcmp(b,"0"))abort();exit(0);}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920810-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920810-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920810-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/920810-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,4 @@
+if { [check_effective_target_newlib_nano_io] } {
+ lappend additional_flags "-Wl,-u,_printf_float"
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/930529-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/930529-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/930529-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/930529-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+main ()
+{
+ union {
+ double d;
+ unsigned char c[8];
+ } d;
+
+ d.d = 1.0/7.0;
+
+ if (sizeof (char) * 8 == sizeof (double))
+ {
+ if (d.c[0] == 0x92 && d.c[1] == 0x24 && d.c[2] == 0x49 && d.c[3] == 0x92
+ && d.c[4] == 0x24 && d.c[5] == 0x49 && d.c[6] == 0xc2 && d.c[7] == 0x3f)
+ exit (0);
+ if (d.c[7] == 0x92 && d.c[6] == 0x24 && d.c[5] == 0x49 && d.c[4] == 0x92
+ && d.c[3] == 0x24 && d.c[2] == 0x49 && d.c[1] == 0xc2 && d.c[0] == 0x3f)
+ exit (0);
+#if defined __arm__ || defined __thumb__
+ if (d.c[4] == 0x92 && d.c[5] == 0x24 && d.c[6] == 0x49 && d.c[7] == 0x92
+ && d.c[0] == 0x24 && d.c[1] == 0x49 && d.c[2] == 0xc2 && d.c[3] == 0x3f)
+ exit (0);
+#endif
+ abort ();
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/980619-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/980619-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/980619-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/980619-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+ int main(void)
+ {
+ float reale = 1.0f;
+ float oneplus;
+ int i;
+
+ if (sizeof (float) != 4)
+ exit (0);
+
+ for (i = 0; ; i++)
+ {
+ oneplus = 1.0f + reale;
+ if (oneplus == 1.0f)
+ break;
+ reale=reale/2.0f;
+ }
+ /* Assumes ieee754 accurate arithmetic above. */
+ if (i != 24)
+ abort ();
+ else
+ exit (0);
+ }
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/980619-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/980619-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/980619-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/980619-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+# This used to fail on ia32, with or without -ffloat-store.
+# It works now, but some people think that's a fluke, so I'm
+# keeping this around just in case.
+
+#set torture_eval_before_execute {
+#
+# set compiler_conditional_xfail_data {
+# "ia32 fp rounding isn't pedantic" \
+# "i?86-*-*" \
+# { "-O3" "-O2" "-O1" "-Os"} \
+# { "" }
+# }
+#}
+
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/acc1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/acc1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/acc1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/acc1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+/* Tail call optimizations would reverse the order of additions in func(). */
+
+double func (const double *array)
+{
+ double d = *array;
+ if (d == 0.0)
+ return d;
+ else
+ return d + func (array + 1);
+}
+
+int main ()
+{
+ double values[] = { 0.1e-100, 1.0, -1.0, 0.0 };
+ if (func (values) != 0.1e-100)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/acc2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/acc2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/acc2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/acc2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* Tail call optimizations would reverse the order of multiplications
+ in func(). */
+
+double func (const double *array)
+{
+ double d = *array;
+ if (d == 1.0)
+ return d;
+ else
+ return d * func (array + 1);
+}
+
+int main ()
+{
+ double values[] = { __DBL_MAX__, 2.0, 0.5, 1.0 };
+ if (func (values) != __DBL_MAX__)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/builtin-nan-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/builtin-nan-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/builtin-nan-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/builtin-nan-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+/* PR middle-end/19983 */
+
+typedef __SIZE_TYPE__ size_t;
+
+extern void abort(void);
+extern int memcmp(const void *, const void *, size_t);
+
+double n1 = __builtin_nan("0x1");
+double n2 = __builtin_nan("0X1");
+
+int main()
+{
+ if (memcmp (&n1, &n2, sizeof(double)))
+ abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,189 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Test for correctness of composite floating-point comparisons.
+
+ Written by Paolo Bonzini, 26th May 2004. */
+
+extern void abort (void);
+
+#define TEST(c) if ((c) != ok) abort ();
+#define ORD(a, b) (!__builtin_isunordered ((a), (b)))
+#define UNORD(a, b) (__builtin_isunordered ((a), (b)))
+#define UNEQ(a, b) (__builtin_isunordered ((a), (b)) || ((a) == (b)))
+#define UNLT(a, b) (__builtin_isunordered ((a), (b)) || ((a) < (b)))
+#define UNLE(a, b) (__builtin_isunordered ((a), (b)) || ((a) <= (b)))
+#define UNGT(a, b) (__builtin_isunordered ((a), (b)) || ((a) > (b)))
+#define UNGE(a, b) (__builtin_isunordered ((a), (b)) || ((a) >= (b)))
+#define LTGT(a, b) (__builtin_islessgreater ((a), (b)))
+
+float pinf;
+float ninf;
+float NaN;
+
+int iuneq (float x, float y, int ok)
+{
+ TEST (UNEQ (x, y));
+ TEST (!LTGT (x, y));
+ TEST (UNLE (x, y) && UNGE (x,y));
+}
+
+int ieq (float x, float y, int ok)
+{
+ TEST (ORD (x, y) && UNEQ (x, y));
+}
+
+int iltgt (float x, float y, int ok)
+{
+ TEST (!UNEQ (x, y)); /* Not optimizable. */
+ TEST (LTGT (x, y)); /* Same, __builtin_islessgreater does not trap. */
+ TEST (ORD (x, y) && (UNLT (x, y) || UNGT (x,y)));
+}
+
+int ine (float x, float y, int ok)
+{
+ TEST (UNLT (x, y) || UNGT (x, y));
+}
+
+int iunlt (float x, float y, int ok)
+{
+ TEST (UNLT (x, y));
+ TEST (UNORD (x, y) || (x < y));
+}
+
+int ilt (float x, float y, int ok)
+{
+ TEST (ORD (x, y) && UNLT (x, y)); /* Not optimized */
+ TEST ((x <= y) && (x != y));
+ TEST ((x <= y) && (y != x));
+ TEST ((x != y) && (x <= y)); /* Not optimized */
+ TEST ((y != x) && (x <= y)); /* Not optimized */
+}
+
+int iunle (float x, float y, int ok)
+{
+ TEST (UNLE (x, y));
+ TEST (UNORD (x, y) || (x <= y));
+}
+
+int ile (float x, float y, int ok)
+{
+ TEST (ORD (x, y) && UNLE (x, y)); /* Not optimized */
+ TEST ((x < y) || (x == y));
+ TEST ((y > x) || (x == y));
+ TEST ((x == y) || (x < y)); /* Not optimized */
+ TEST ((y == x) || (x < y)); /* Not optimized */
+}
+
+int iungt (float x, float y, int ok)
+{
+ TEST (UNGT (x, y));
+ TEST (UNORD (x, y) || (x > y));
+}
+
+int igt (float x, float y, int ok)
+{
+ TEST (ORD (x, y) && UNGT (x, y)); /* Not optimized */
+ TEST ((x >= y) && (x != y));
+ TEST ((x >= y) && (y != x));
+ TEST ((x != y) && (x >= y)); /* Not optimized */
+ TEST ((y != x) && (x >= y)); /* Not optimized */
+}
+
+int iunge (float x, float y, int ok)
+{
+ TEST (UNGE (x, y));
+ TEST (UNORD (x, y) || (x >= y));
+}
+
+int ige (float x, float y, int ok)
+{
+ TEST (ORD (x, y) && UNGE (x, y)); /* Not optimized */
+ TEST ((x > y) || (x == y));
+ TEST ((y < x) || (x == y));
+ TEST ((x == y) || (x > y)); /* Not optimized */
+ TEST ((y == x) || (x > y)); /* Not optimized */
+}
+
+int
+main ()
+{
+ pinf = __builtin_inf ();
+ ninf = -__builtin_inf ();
+ NaN = __builtin_nan ("");
+
+ iuneq (ninf, pinf, 0);
+ iuneq (NaN, NaN, 1);
+ iuneq (pinf, ninf, 0);
+ iuneq (1, 4, 0);
+ iuneq (3, 3, 1);
+ iuneq (5, 2, 0);
+
+ ieq (1, 4, 0);
+ ieq (3, 3, 1);
+ ieq (5, 2, 0);
+
+ iltgt (ninf, pinf, 1);
+ iltgt (NaN, NaN, 0);
+ iltgt (pinf, ninf, 1);
+ iltgt (1, 4, 1);
+ iltgt (3, 3, 0);
+ iltgt (5, 2, 1);
+
+ ine (1, 4, 1);
+ ine (3, 3, 0);
+ ine (5, 2, 1);
+
+ iunlt (NaN, ninf, 1);
+ iunlt (pinf, NaN, 1);
+ iunlt (pinf, ninf, 0);
+ iunlt (pinf, pinf, 0);
+ iunlt (ninf, ninf, 0);
+ iunlt (1, 4, 1);
+ iunlt (3, 3, 0);
+ iunlt (5, 2, 0);
+
+ ilt (1, 4, 1);
+ ilt (3, 3, 0);
+ ilt (5, 2, 0);
+
+ iunle (NaN, ninf, 1);
+ iunle (pinf, NaN, 1);
+ iunle (pinf, ninf, 0);
+ iunle (pinf, pinf, 1);
+ iunle (ninf, ninf, 1);
+ iunle (1, 4, 1);
+ iunle (3, 3, 1);
+ iunle (5, 2, 0);
+
+ ile (1, 4, 1);
+ ile (3, 3, 1);
+ ile (5, 2, 0);
+
+ iungt (NaN, ninf, 1);
+ iungt (pinf, NaN, 1);
+ iungt (pinf, ninf, 1);
+ iungt (pinf, pinf, 0);
+ iungt (ninf, ninf, 0);
+ iungt (1, 4, 0);
+ iungt (3, 3, 0);
+ iungt (5, 2, 1);
+
+ igt (1, 4, 0);
+ igt (3, 3, 0);
+ igt (5, 2, 1);
+
+ iunge (NaN, ninf, 1);
+ iunge (pinf, NaN, 1);
+ iunge (ninf, pinf, 0);
+ iunge (pinf, pinf, 1);
+ iunge (ninf, ninf, 1);
+ iunge (1, 4, 0);
+ iunge (3, 3, 1);
+ iunge (5, 2, 1);
+
+ ige (1, 4, 0);
+ ige (3, 3, 1);
+ ige (5, 2, 1);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,6 @@
+if [istarget "spu-*-*"] {
+ # The SPU single-precision floating point format does not
+ # support Nan & Inf.
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Ensure that the composite comparison optimization doesn't misfire
+ and attempt to combine an integer comparison with a floating-point one.
+
+ Written by Paolo Bonzini, 26th May 2004. */
+
+extern void abort (void);
+
+int
+foo (double x, double y)
+{
+ /* If miscompiled the following may become false. */
+ return (x > y) && ((int)x == (int)y);
+}
+
+int
+main ()
+{
+ if (! foo (1.3,1.0))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,96 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Test for composite comparison always true/false optimization.
+
+ Written by Paolo Bonzini, 26th May 2004. */
+
+extern void link_error0 ();
+extern void link_error1 ();
+
+void
+test1 (float x, float y)
+{
+ if ((x==y) && (x!=y))
+ link_error0();
+}
+
+void
+test2 (float x, float y)
+{
+ if ((x<y) && (x>y))
+ link_error0();
+}
+
+void
+test3 (float x, float y)
+{
+ if ((x<y) && (y<x))
+ link_error0();
+}
+
+void
+test4 (float x, float y)
+{
+ if ((x==y) || (x!=y))
+ {
+ }
+ else
+ link_error1 ();
+}
+
+void
+test5 (float x, float y)
+{
+ if (__builtin_isunordered (x, y) || (x>=y) || (x<y))
+ {
+ }
+ else
+ link_error1 ();
+}
+
+void
+test6 (float x, float y)
+{
+ if (__builtin_isunordered (y, x) || (x<=y) || (y<x))
+ {
+ }
+ else
+ link_error1 ();
+}
+
+void
+test7 (float x, float y)
+{
+ if (__builtin_isunordered (x, y) || !__builtin_isunordered (x, y))
+ {
+ }
+ else
+ link_error1 ();
+}
+
+void
+all_tests (float x, float y)
+{
+ test1 (x, y);
+ test2 (x, y);
+ test3 (x, y);
+ test4 (x, y);
+ test5 (x, y);
+ test6 (x, y);
+ test7 (x, y);
+}
+
+int
+main ()
+{
+ all_tests (0, 0);
+ all_tests (1, 2);
+ all_tests (4, 3);
+
+ return 0;
+}
+
+#ifndef __OPTIMIZE__
+void link_error0() {}
+void link_error1() {}
+#endif /* ! __OPTIMIZE__ */
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-3.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-3.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-3.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-3.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,2 @@
+lappend additional_flags "-fno-trapping-math"
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,190 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ Test for correctness of composite floating-point comparisons.
+
+ Written by Paolo Bonzini, 26th May 2004. */
+
+extern void abort (void);
+
+#define TEST(c) if ((c) != ok) abort ();
+#define ORD(a, b) (((a) < (b)) || (a) >= (b))
+#define UNORD(a, b) (!ORD ((a), (b)))
+#define UNEQ(a, b) (!LTGT ((a), (b)))
+#define UNLT(a, b) (((a) < (b)) || __builtin_isunordered ((a), (b)))
+#define UNLE(a, b) (((a) <= (b)) || __builtin_isunordered ((a), (b)))
+#define UNGT(a, b) (((a) > (b)) || __builtin_isunordered ((a), (b)))
+#define UNGE(a, b) (((a) >= (b)) || __builtin_isunordered ((a), (b)))
+#define LTGT(a, b) (((a) < (b)) || (a) > (b))
+
+float pinf;
+float ninf;
+float NaN;
+
+int iuneq (float x, float y, int ok)
+{
+ TEST (UNEQ (x, y));
+ TEST (!LTGT (x, y));
+ TEST (UNLE (x, y) && UNGE (x,y));
+}
+
+int ieq (float x, float y, int ok)
+{
+ TEST (ORD (x, y) && UNEQ (x, y));
+}
+
+int iltgt (float x, float y, int ok)
+{
+ TEST (!UNEQ (x, y));
+ TEST (LTGT (x, y));
+ TEST (ORD (x, y) && (UNLT (x, y) || UNGT (x,y)));
+}
+
+int ine (float x, float y, int ok)
+{
+ TEST (UNLT (x, y) || UNGT (x, y));
+ TEST ((x < y) || (x > y) || UNORD (x, y));
+}
+
+int iunlt (float x, float y, int ok)
+{
+ TEST (UNLT (x, y));
+ TEST (UNORD (x, y) || (x < y));
+}
+
+int ilt (float x, float y, int ok)
+{
+ TEST (ORD (x, y) && UNLT (x, y));
+ TEST ((x <= y) && (x != y));
+ TEST ((x <= y) && (y != x));
+ TEST ((x != y) && (x <= y));
+ TEST ((y != x) && (x <= y));
+}
+
+int iunle (float x, float y, int ok)
+{
+ TEST (UNLE (x, y));
+ TEST (UNORD (x, y) || (x <= y));
+}
+
+int ile (float x, float y, int ok)
+{
+ TEST (ORD (x, y) && UNLE (x, y));
+ TEST ((x < y) || (x == y));
+ TEST ((y > x) || (x == y));
+ TEST ((x == y) || (x < y));
+ TEST ((y == x) || (x < y));
+}
+
+int iungt (float x, float y, int ok)
+{
+ TEST (UNGT (x, y));
+ TEST (UNORD (x, y) || (x > y));
+}
+
+int igt (float x, float y, int ok)
+{
+ TEST (ORD (x, y) && UNGT (x, y));
+ TEST ((x >= y) && (x != y));
+ TEST ((x >= y) && (y != x));
+ TEST ((x != y) && (x >= y));
+ TEST ((y != x) && (x >= y));
+}
+
+int iunge (float x, float y, int ok)
+{
+ TEST (UNGE (x, y));
+ TEST (UNORD (x, y) || (x >= y));
+}
+
+int ige (float x, float y, int ok)
+{
+ TEST (ORD (x, y) && UNGE (x, y));
+ TEST ((x > y) || (x == y));
+ TEST ((y < x) || (x == y));
+ TEST ((x == y) || (x > y));
+ TEST ((y == x) || (x > y));
+}
+
+int
+main ()
+{
+ pinf = __builtin_inf ();
+ ninf = -__builtin_inf ();
+ NaN = __builtin_nan ("");
+
+ iuneq (ninf, pinf, 0);
+ iuneq (NaN, NaN, 1);
+ iuneq (pinf, ninf, 0);
+ iuneq (1, 4, 0);
+ iuneq (3, 3, 1);
+ iuneq (5, 2, 0);
+
+ ieq (1, 4, 0);
+ ieq (3, 3, 1);
+ ieq (5, 2, 0);
+
+ iltgt (ninf, pinf, 1);
+ iltgt (NaN, NaN, 0);
+ iltgt (pinf, ninf, 1);
+ iltgt (1, 4, 1);
+ iltgt (3, 3, 0);
+ iltgt (5, 2, 1);
+
+ ine (1, 4, 1);
+ ine (3, 3, 0);
+ ine (5, 2, 1);
+
+ iunlt (NaN, ninf, 1);
+ iunlt (pinf, NaN, 1);
+ iunlt (pinf, ninf, 0);
+ iunlt (pinf, pinf, 0);
+ iunlt (ninf, ninf, 0);
+ iunlt (1, 4, 1);
+ iunlt (3, 3, 0);
+ iunlt (5, 2, 0);
+
+ ilt (1, 4, 1);
+ ilt (3, 3, 0);
+ ilt (5, 2, 0);
+
+ iunle (NaN, ninf, 1);
+ iunle (pinf, NaN, 1);
+ iunle (pinf, ninf, 0);
+ iunle (pinf, pinf, 1);
+ iunle (ninf, ninf, 1);
+ iunle (1, 4, 1);
+ iunle (3, 3, 1);
+ iunle (5, 2, 0);
+
+ ile (1, 4, 1);
+ ile (3, 3, 1);
+ ile (5, 2, 0);
+
+ iungt (NaN, ninf, 1);
+ iungt (pinf, NaN, 1);
+ iungt (pinf, ninf, 1);
+ iungt (pinf, pinf, 0);
+ iungt (ninf, ninf, 0);
+ iungt (1, 4, 0);
+ iungt (3, 3, 0);
+ iungt (5, 2, 1);
+
+ igt (1, 4, 0);
+ igt (3, 3, 0);
+ igt (5, 2, 1);
+
+ iunge (NaN, ninf, 1);
+ iunge (pinf, NaN, 1);
+ iunge (ninf, pinf, 0);
+ iunge (pinf, pinf, 1);
+ iunge (ninf, ninf, 1);
+ iunge (1, 4, 0);
+ iunge (3, 3, 1);
+ iunge (5, 2, 1);
+
+ ige (1, 4, 0);
+ ige (3, 3, 1);
+ ige (5, 2, 1);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-4.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-4.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-4.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/compare-fp-4.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+# The ARM VxWorks kernel uses an external floating-point library in
+# which routines like __ledf2 are just aliases for __cmpdf2. These
+# routines therefore don't handle NaNs correctly.
+if [istarget "arm*-*-vxworks*"] {
+ set torture_eval_before_execute {
+ global compiler_conditional_xfail_data
+ set compiler_conditional_xfail_data {
+ "The ARM kernel uses a flawed floating-point library."
+ { "*-*-*" }
+ {}
+ { "-mrtp" }
+ }
+ }
+}
+
+if [istarget "spu-*-*"] {
+ # The SPU single-precision floating point format does not
+ # support Nan & Inf.
+ return 1
+}
+
+lappend additional_flags "-fno-trapping-math"
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/copysign1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/copysign1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/copysign1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/copysign1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,76 @@
+#include <string.h>
+#include <stdlib.h>
+#include <float.h>
+
+#define fpsizeoff sizeof(float)
+#define fpsizeof sizeof(double)
+#define fpsizeofl sizeof(long double)
+
+/* Work around the fact that with the Intel double-extended precision,
+ we've got a 10 byte type stuffed into some amount of padding. And
+ the fact that -ffloat-store is going to stuff this value temporarily
+ into some bit of stack frame that we've no control over and can't zero. */
+#if LDBL_MANT_DIG == 64
+# if defined(__i386__) || defined(__x86_64__) || defined (__ia64__)
+# undef fpsizeofl
+# define fpsizeofl 10
+# endif
+#endif
+
+/* Work around the fact that the sign of the second double in the IBM
+ double-double format is not strictly specified when it contains a zero.
+ For instance, -0.0L can be represented with either (-0.0, +0.0) or
+ (-0.0, -0.0). The former is what we'll get from the compiler when it
+ builds constants; the later is what we'll get from the negation operator
+ at runtime. */
+/* ??? This hack only works for big-endian, which is fortunately true for
+ AIX and, Darwin. */
+#if LDBL_MANT_DIG == 106
+# undef fpsizeofl
+# define fpsizeofl sizeof(double)
+#endif
+
+
+#define TEST(TYPE, EXT) \
+TYPE c##EXT (TYPE x, TYPE y) \
+{ \
+ return __builtin_copysign##EXT (x, y); \
+} \
+ \
+struct D##EXT { TYPE x, y, z; }; \
+ \
+static const struct D##EXT T##EXT[] = { \
+ { 1.0, 2.0, 1.0 }, \
+ { 1.0, -2.0, -1.0 }, \
+ { -1.0, -2.0, -1.0 }, \
+ { 0.0, -2.0, -0.0 }, \
+ { -0.0, -2.0, -0.0 }, \
+ { -0.0, 2.0, 0.0 }, \
+ { __builtin_inf##EXT (), -0.0, -__builtin_inf##EXT () }, \
+ { -__builtin_nan##EXT (""), __builtin_inf##EXT (), \
+ __builtin_nan##EXT ("") } \
+}; \
+ \
+void test##EXT (void) \
+{ \
+ int i, n = sizeof (T##EXT) / sizeof (T##EXT[0]); \
+ TYPE r; \
+ for (i = 0; i < n; ++i) \
+ { \
+ r = c##EXT (T##EXT[i].x, T##EXT[i].y); \
+ if (memcmp (&r, &T##EXT[i].z, fpsizeof##EXT) != 0) \
+ abort (); \
+ } \
+}
+
+TEST(float, f)
+TEST(double, )
+TEST(long double, l)
+
+int main()
+{
+ testf();
+ test();
+ testl();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/copysign2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/copysign2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/copysign2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/copysign2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,70 @@
+#include <string.h>
+#include <stdlib.h>
+#include <float.h>
+
+#define fpsizeoff sizeof(float)
+#define fpsizeof sizeof(double)
+#define fpsizeofl sizeof(long double)
+
+/* Work around the fact that with the Intel double-extended precision,
+ we've got a 10 byte type stuffed into some amount of padding. And
+ the fact that -ffloat-store is going to stuff this value temporarily
+ into some bit of stack frame that we've no control over and can't zero. */
+#if LDBL_MANT_DIG == 64
+# if defined(__i386__) || defined(__x86_64__) || defined (__ia64__)
+# undef fpsizeofl
+# define fpsizeofl 10
+# endif
+#endif
+
+/* Work around the fact that the sign of the second double in the IBM
+ double-double format is not strictly specified when it contains a zero.
+ For instance, -0.0L can be represented with either (-0.0, +0.0) or
+ (-0.0, -0.0). The former is what we'll get from the compiler when it
+ builds constants; the later is what we'll get from the negation operator
+ at runtime. */
+/* ??? This hack only works for big-endian, which is fortunately true for
+ AIX and Darwin. */
+#if LDBL_MANT_DIG == 106
+# undef fpsizeofl
+# define fpsizeofl sizeof(double)
+#endif
+
+
+#define TEST(TYPE, EXT) \
+static TYPE Y##EXT[] = { \
+ 2.0, -2.0, -2.0, -2.0, -2.0, 2.0, -0.0, __builtin_inf##EXT () \
+}; \
+static const TYPE Z##EXT[] = { \
+ 1.0, -1.0, -1.0, -0.0, -0.0, 0.0, -__builtin_inf##EXT (), \
+ __builtin_nan##EXT ("") \
+}; \
+ \
+void test##EXT (void) \
+{ \
+ TYPE r[8]; \
+ int i; \
+ r[0] = __builtin_copysign##EXT (1.0, Y##EXT[0]); \
+ r[1] = __builtin_copysign##EXT (1.0, Y##EXT[1]); \
+ r[2] = __builtin_copysign##EXT (-1.0, Y##EXT[2]); \
+ r[3] = __builtin_copysign##EXT (0.0, Y##EXT[3]); \
+ r[4] = __builtin_copysign##EXT (-0.0, Y##EXT[4]); \
+ r[5] = __builtin_copysign##EXT (-0.0, Y##EXT[5]); \
+ r[6] = __builtin_copysign##EXT (__builtin_inf##EXT (), Y##EXT[6]); \
+ r[7] = __builtin_copysign##EXT (-__builtin_nan##EXT (""), Y##EXT[7]); \
+ for (i = 0; i < 8; ++i) \
+ if (memcmp (r+i, Z##EXT+i, fpsizeof##EXT) != 0) \
+ abort (); \
+}
+
+TEST(float, f)
+TEST(double, )
+TEST(long double, l)
+
+int main()
+{
+ testf();
+ test();
+ testl();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,43 @@
+#ifndef SIGNAL_SUPPRESS
+#include <signal.h>
+#endif
+
+double dnan = 1.0/0.0 - 1.0/0.0;
+double x = 1.0;
+
+void leave ()
+{
+ exit (0);
+}
+
+main ()
+{
+#if ! defined (__vax__) && ! defined (_CRAY)
+ /* Move this line earlier, for architectures (like alpha) that issue
+ SIGFPE on the first comparisons. */
+#ifndef SIGNAL_SUPPRESS
+ /* Some machines catches a SIGFPE when a NaN is compared.
+ Let this test succeed o such machines. */
+ signal (SIGFPE, leave);
+#endif
+ /* NaN is an IEEE unordered operand. All these test should be false. */
+ if (dnan == dnan)
+ abort ();
+ if (dnan != x)
+ x = 1.0;
+ else
+ abort ();
+
+ if (dnan < x)
+ abort ();
+ if (dnan > x)
+ abort ();
+ if (dnan <= x)
+ abort ();
+ if (dnan >= x)
+ abort ();
+ if (dnan == x)
+ abort ();
+#endif
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+# The ARM VxWorks kernel uses an external floating-point library in
+# which routines like __ledf2 are just aliases for __cmpdf2. These
+# routines therefore don't handle NaNs correctly.
+if [istarget "arm*-*-vxworks*"] {
+ set torture_eval_before_execute {
+ global compiler_conditional_xfail_data
+ set compiler_conditional_xfail_data {
+ "The ARM kernel uses a flawed floating-point library."
+ { "*-*-*" }
+ {}
+ { "-mrtp" }
+ }
+ }
+}
+
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,43 @@
+#ifndef SIGNAL_SUPPRESS
+#include <signal.h>
+#endif
+
+float fnan = 1.0f/0.0f - 1.0f/0.0f;
+float x = 1.0f;
+
+void leave ()
+{
+ exit (0);
+}
+
+main ()
+{
+#if ! defined (__vax__) && ! defined (_CRAY)
+ /* Move this line earlier, for architectures (like alpha) that issue
+ SIGFPE on the first comparisons. */
+#ifndef SIGNAL_SUPPRESS
+ /* Some machines catches a SIGFPE when a NaN is compared.
+ Let this test succeed o such machines. */
+ signal (SIGFPE, leave);
+#endif
+ /* NaN is an IEEE unordered operand. All these test should be false. */
+ if (fnan == fnan)
+ abort ();
+ if (fnan != x)
+ x = 1.0;
+ else
+ abort ();
+
+ if (fnan < x)
+ abort ();
+ if (fnan > x)
+ abort ();
+ if (fnan <= x)
+ abort ();
+ if (fnan >= x)
+ abort ();
+ if (fnan == x)
+ abort ();
+#endif
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-2.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-2.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-2.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-2.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+# The ARM VxWorks kernel uses an external floating-point library in
+# which routines like __ledf2 are just aliases for __cmpdf2. These
+# routines therefore don't handle NaNs correctly.
+if [istarget "arm*-*-vxworks*"] {
+ set torture_eval_before_execute {
+ global compiler_conditional_xfail_data
+ set compiler_conditional_xfail_data {
+ "The ARM kernel uses a flawed floating-point library."
+ { "*-*-*" }
+ {}
+ { "-mrtp" }
+ }
+ }
+}
+
+if [istarget "spu-*-*"] {
+ # The SPU single-precision floating point format does not
+ # support Nan & Inf.
+ return 1
+}
+
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,43 @@
+#ifndef SIGNAL_SUPPRESS
+#include <signal.h>
+#endif
+
+long double dnan = 1.0l/0.0l - 1.0l/0.0l;
+long double x = 1.0l;
+
+void leave ()
+{
+ exit (0);
+}
+
+main ()
+{
+#if ! defined (__vax__) && ! defined (_CRAY)
+ /* Move this line earlier, for architectures (like alpha) that issue
+ SIGFPE on the first comparisons. */
+#ifndef SIGNAL_SUPPRESS
+ /* Some machines catches a SIGFPE when a NaN is compared.
+ Let this test succeed o such machines. */
+ signal (SIGFPE, leave);
+#endif
+ /* NaN is an IEEE unordered operand. All these test should be false. */
+ if (dnan == dnan)
+ abort ();
+ if (dnan != x)
+ x = 1.0;
+ else
+ abort ();
+
+ if (dnan < x)
+ abort ();
+ if (dnan > x)
+ abort ();
+ if (dnan <= x)
+ abort ();
+ if (dnan >= x)
+ abort ();
+ if (dnan == x)
+ abort ();
+#endif
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-3.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-3.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-3.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-3.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+# The ARM VxWorks kernel uses an external floating-point library in
+# which routines like __ledf2 are just aliases for __cmpdf2. These
+# routines therefore don't handle NaNs correctly.
+if [istarget "arm*-*-vxworks*"] {
+ set torture_eval_before_execute {
+ global compiler_conditional_xfail_data
+ set compiler_conditional_xfail_data {
+ "The ARM kernel uses a flawed floating-point library."
+ { "*-*-*" }
+ {}
+ { "-mrtp" }
+ }
+ }
+}
+
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,135 @@
+#ifndef FLOAT
+#define FLOAT double
+#endif
+
+void
+test_isunordered(FLOAT x, FLOAT y, int true)
+{
+ if (__builtin_isunordered(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+void
+test_isless(FLOAT x, FLOAT y, int true)
+{
+ if (__builtin_isless(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+void
+test_islessequal(FLOAT x, FLOAT y, int true)
+{
+ if (__builtin_islessequal(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+void
+test_isgreater(FLOAT x, FLOAT y, int true)
+{
+ if (__builtin_isgreater(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+void
+test_isgreaterequal(FLOAT x, FLOAT y, int true)
+{
+ if (__builtin_isgreaterequal(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+void
+test_islessgreater(FLOAT x, FLOAT y, int true)
+{
+ if (__builtin_islessgreater(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+#define NAN (0.0 / 0.0)
+
+int
+main()
+{
+ struct try
+ {
+ FLOAT x, y;
+ unsigned unord : 1;
+ unsigned lt : 1;
+ unsigned le : 1;
+ unsigned gt : 1;
+ unsigned ge : 1;
+ unsigned lg : 1;
+ };
+
+ static struct try const data[] =
+ {
+ { NAN, NAN, 1, 0, 0, 0, 0, 0 },
+ { 0.0, NAN, 1, 0, 0, 0, 0, 0 },
+ { NAN, 0.0, 1, 0, 0, 0, 0, 0 },
+ { 0.0, 0.0, 0, 0, 1, 0, 1, 0 },
+ { 1.0, 2.0, 0, 1, 1, 0, 0, 1 },
+ { 2.0, 1.0, 0, 0, 0, 1, 1, 1 },
+ };
+
+ const int n = sizeof(data) / sizeof(data[0]);
+ int i;
+
+ for (i = 0; i < n; ++i)
+ {
+ test_isunordered (data[i].x, data[i].y, data[i].unord);
+ test_isless (data[i].x, data[i].y, data[i].lt);
+ test_islessequal (data[i].x, data[i].y, data[i].le);
+ test_isgreater (data[i].x, data[i].y, data[i].gt);
+ test_isgreaterequal (data[i].x, data[i].y, data[i].ge);
+ test_islessgreater (data[i].x, data[i].y, data[i].lg);
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4e.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4e.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4e.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4e.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,10 @@
+#if defined (__ia64__) && defined (__hpux__)
+#define FLOAT __float80
+#include "fp-cmp-4.c"
+#else
+int
+main ()
+{
+ return 0;
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4f.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4f.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4f.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4f.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,2 @@
+#define FLOAT float
+#include "fp-cmp-4.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4f.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4f.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4f.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4f.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,6 @@
+if [istarget "spu-*-*"] {
+ # The SPU single-precision floating point format does not
+ # support Nan & Inf.
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4l.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4l.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4l.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-4l.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,2 @@
+#define FLOAT long double
+#include "fp-cmp-4.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,131 @@
+/* Like fp-cmp-4.c, but test that the setcc patterns are correct. */
+
+static int
+test_isunordered(double x, double y)
+{
+ return __builtin_isunordered(x, y);
+}
+
+static int
+test_not_isunordered(double x, double y)
+{
+ return !__builtin_isunordered(x, y);
+}
+
+static int
+test_isless(double x, double y)
+{
+ return __builtin_isless(x, y);
+}
+
+static int
+test_not_isless(double x, double y)
+{
+ return !__builtin_isless(x, y);
+}
+
+static int
+test_islessequal(double x, double y)
+{
+ return __builtin_islessequal(x, y);
+}
+
+static int
+test_not_islessequal(double x, double y)
+{
+ return !__builtin_islessequal(x, y);
+}
+
+static int
+test_isgreater(double x, double y)
+{
+ return __builtin_isgreater(x, y);
+}
+
+static int
+test_not_isgreater(double x, double y)
+{
+ return !__builtin_isgreater(x, y);
+}
+
+static int
+test_isgreaterequal(double x, double y)
+{
+ return __builtin_isgreaterequal(x, y);
+}
+
+static int
+test_not_isgreaterequal(double x, double y)
+{
+ return !__builtin_isgreaterequal(x, y);
+}
+
+static int
+test_islessgreater(double x, double y)
+{
+ return __builtin_islessgreater(x, y);
+}
+
+static int
+test_not_islessgreater(double x, double y)
+{
+ return !__builtin_islessgreater(x, y);
+}
+
+static void
+one_test(double x, double y, int expected,
+ int (*pos) (double, double), int (*neg) (double, double))
+{
+ if ((*pos)(x, y) != expected)
+ abort ();
+ if ((*neg)(x, y) != !expected)
+ abort ();
+}
+
+#define NAN (0.0 / 0.0)
+
+int
+main()
+{
+ struct try
+ {
+ double x, y;
+ int result[6];
+ };
+
+ static struct try const data[] =
+ {
+ { NAN, NAN, { 1, 0, 0, 0, 0, 0 } },
+ { 0.0, NAN, { 1, 0, 0, 0, 0, 0 } },
+ { NAN, 0.0, { 1, 0, 0, 0, 0, 0 } },
+ { 0.0, 0.0, { 0, 0, 1, 0, 1, 0 } },
+ { 1.0, 2.0, { 0, 1, 1, 0, 0, 1 } },
+ { 2.0, 1.0, { 0, 0, 0, 1, 1, 1 } },
+ };
+
+ struct test
+ {
+ int (*pos)(double, double);
+ int (*neg)(double, double);
+ };
+
+ static struct test const tests[] =
+ {
+ { test_isunordered, test_not_isunordered },
+ { test_isless, test_not_isless },
+ { test_islessequal, test_not_islessequal },
+ { test_isgreater, test_not_isgreater },
+ { test_isgreaterequal, test_not_isgreaterequal },
+ { test_islessgreater, test_not_islessgreater }
+ };
+
+ const int n = sizeof(data) / sizeof(data[0]);
+ int i, j;
+
+ for (i = 0; i < n; ++i)
+ for (j = 0; j < 6; ++j)
+ one_test (data[i].x, data[i].y, data[i].result[j],
+ tests[j].pos, tests[j].neg);
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-6.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-6.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-6.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-6.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+
+const double dnan = 1.0/0.0 - 1.0/0.0;
+double x = 1.0;
+
+extern void link_error (void);
+extern void abort (void);
+
+main ()
+{
+#if ! defined (__vax__) && ! defined (_CRAY)
+ /* NaN is an IEEE unordered operand. All these test should be false. */
+ if (dnan == dnan)
+ link_error ();
+ if (dnan != x)
+ x = 1.0;
+ else
+ link_error ();
+
+ if (dnan < x)
+ link_error ();
+ if (dnan > x)
+ link_error ();
+ if (dnan <= x)
+ link_error ();
+ if (dnan >= x)
+ link_error ();
+ if (dnan == x)
+ link_error ();
+#endif
+ exit (0);
+}
+
+#ifndef __OPTIMIZE__
+void link_error (void)
+{
+ abort ();
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-6.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-6.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-6.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-6.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+# The ARM VxWorks kernel uses an external floating-point library in
+# which routines like __ledf2 are just aliases for __cmpdf2. These
+# routines therefore don't handle NaNs correctly.
+if [istarget "arm*-*-vxworks*"] {
+ set torture_eval_before_execute {
+ global compiler_conditional_xfail_data
+ set compiler_conditional_xfail_data {
+ "The ARM kernel uses a flawed floating-point library."
+ { "*-*-*" }
+ { "-O0" }
+ { "-mrtp" }
+ }
+ }
+}
+
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-7.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-7.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-7.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-7.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+extern void link_error ();
+
+void foo(double x)
+{
+ if (x > __builtin_inf())
+ link_error ();
+}
+
+int main ()
+{
+ foo (1.0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-7.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-7.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-7.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-7.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,2 @@
+lappend additional_flags "-fno-trapping-math"
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,145 @@
+#ifndef FLOAT
+#define FLOAT double
+#endif
+
+/* Like fp-cmp-4.c, but test that the cmove patterns are correct. */
+
+static FLOAT
+test_isunordered(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return __builtin_isunordered(x, y) ? a : b;
+}
+
+static FLOAT
+test_not_isunordered(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return !__builtin_isunordered(x, y) ? a : b;
+}
+
+static FLOAT
+test_isless(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return __builtin_isless(x, y) ? a : b;
+}
+
+static FLOAT
+test_not_isless(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return !__builtin_isless(x, y) ? a : b;
+}
+
+static FLOAT
+test_islessequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return __builtin_islessequal(x, y) ? a : b;
+}
+
+static FLOAT
+test_not_islessequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return !__builtin_islessequal(x, y) ? a : b;
+}
+
+static FLOAT
+test_isgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return __builtin_isgreater(x, y) ? a : b;
+}
+
+static FLOAT
+test_not_isgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return !__builtin_isgreater(x, y) ? a : b;
+}
+
+static FLOAT
+test_isgreaterequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return __builtin_isgreaterequal(x, y) ? a : b;
+}
+
+static FLOAT
+test_not_isgreaterequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return !__builtin_isgreaterequal(x, y) ? a : b;
+}
+
+static FLOAT
+test_islessgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return __builtin_islessgreater(x, y) ? a : b;
+}
+
+static FLOAT
+test_not_islessgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
+{
+ return !__builtin_islessgreater(x, y) ? a : b;
+}
+
+static void
+one_test(FLOAT x, FLOAT y, int expected,
+ FLOAT (*pos) (FLOAT, FLOAT, FLOAT, FLOAT),
+ FLOAT (*neg) (FLOAT, FLOAT, FLOAT, FLOAT))
+{
+ if (((*pos)(x, y, 1.0, 2.0) == 1.0) != expected)
+ abort ();
+ if (((*neg)(x, y, 3.0, 4.0) == 4.0) != expected)
+ abort ();
+}
+
+#define NAN (0.0 / 0.0)
+#define INF (1.0 / 0.0)
+
+int
+main()
+{
+ struct try
+ {
+ FLOAT x, y;
+ int result[6];
+ };
+
+ static struct try const data[] =
+ {
+ { NAN, NAN, { 1, 0, 0, 0, 0, 0 } },
+ { 0.0, NAN, { 1, 0, 0, 0, 0, 0 } },
+ { NAN, 0.0, { 1, 0, 0, 0, 0, 0 } },
+ { 0.0, 0.0, { 0, 0, 1, 0, 1, 0 } },
+ { 1.0, 2.0, { 0, 1, 1, 0, 0, 1 } },
+ { 2.0, 1.0, { 0, 0, 0, 1, 1, 1 } },
+ { INF, 0.0, { 0, 0, 0, 1, 1, 1 } },
+ { 1.0, INF, { 0, 1, 1, 0, 0, 1 } },
+ { INF, INF, { 0, 0, 1, 0, 1, 0 } },
+ { 0.0, -INF, { 0, 0, 0, 1, 1, 1 } },
+ { -INF, 1.0, { 0, 1, 1, 0, 0, 1 } },
+ { -INF, -INF, { 0, 0, 1, 0, 1, 0 } },
+ { INF, -INF, { 0, 0, 0, 1, 1, 1 } },
+ { -INF, INF, { 0, 1, 1, 0, 0, 1 } },
+ };
+
+ struct test
+ {
+ FLOAT (*pos)(FLOAT, FLOAT, FLOAT, FLOAT);
+ FLOAT (*neg)(FLOAT, FLOAT, FLOAT, FLOAT);
+ };
+
+ static struct test const tests[] =
+ {
+ { test_isunordered, test_not_isunordered },
+ { test_isless, test_not_isless },
+ { test_islessequal, test_not_islessequal },
+ { test_isgreater, test_not_isgreater },
+ { test_isgreaterequal, test_not_isgreaterequal },
+ { test_islessgreater, test_not_islessgreater }
+ };
+
+ const int n = sizeof(data) / sizeof(data[0]);
+ int i, j;
+
+ for (i = 0; i < n; ++i)
+ for (j = 0; j < 6; ++j)
+ one_test (data[i].x, data[i].y, data[i].result[j],
+ tests[j].pos, tests[j].neg);
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8e.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8e.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8e.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8e.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,10 @@
+#if defined (__ia64__) && defined (__hpux__)
+#define FLOAT __float80
+#include "fp-cmp-8.c"
+#else
+int
+main ()
+{
+ return 0;
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8f.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8f.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8f.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8f.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,2 @@
+#define FLOAT float
+#include "fp-cmp-8.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8f.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8f.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8f.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8f.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,6 @@
+if [istarget "spu-*-*"] {
+ # The SPU single-precision floating point format does not
+ # support Nan & Inf.
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8l.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8l.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8l.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/fp-cmp-8l.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,2 @@
+#define FLOAT long double
+#include "fp-cmp-8.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/hugeval.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/hugeval.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/hugeval.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/hugeval.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+#include <math.h>
+
+static const double zero = 0.0;
+static const double pone = 1.0;
+static const double none = -1.0;
+static const double pinf = 1.0 / 0.0;
+static const double ninf = -1.0 / 0.0;
+
+int
+main ()
+{
+ if (pinf != pone/zero)
+ abort ();
+
+ if (ninf != none/zero)
+ abort ();
+
+#ifdef HUGE_VAL
+ if (HUGE_VAL != pinf)
+ abort ();
+
+ if (-HUGE_VAL != ninf)
+ abort ();
+#endif
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/hugeval.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/hugeval.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/hugeval.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/hugeval.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+# This test fails under hpux 9.X and 10.X because HUGE_VAL is DBL_MAX
+# instead of +Infinity.
+
+global target_triplet
+if { [istarget "hppa*-*-hpux9*"] || [istarget "hppa*-*-hpux10*"] } {
+ set torture_execute_xfail "$target_triplet"
+}
+
+# VxWorks kernel mode has the same problem.
+if {[istarget "*-*-vxworks*"]} {
+ set torture_eval_before_execute {
+ global compiler_conditional_xfail_data
+ set compiler_conditional_xfail_data {
+ "The kernel HUGE_VAL is defined to DBL_MAX instead of +Inf."
+ { "*-*-*" }
+ {}
+ { "-mrtp" }
+ }
+ }
+}
+
+if { [istarget "tic6x-*-*"] && [check_effective_target_ti_c67x] } {
+ # C6X uses -freciprocal-math by default.
+ set torture_execute_xfail "$target_triplet"
+ return 1
+}
+
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/ieee.exp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/ieee.exp?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/ieee.exp (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/ieee.exp Wed Oct 9 04:01:46 2019
@@ -0,0 +1,81 @@
+#
+# Expect driver script for GCC Regression Tests
+# Copyright (C) 1993-2019 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+#
+# Written by Jeffrey Wheat (cassidy at cygnus.com)
+#
+
+# Load support procs.
+load_lib gcc-dg.exp
+load_lib torture-options.exp
+load_lib c-torture.exp
+
+# These tests come from Torbjorn Granlund's (tege at cygnus.com)
+# C torture test suite, and other contributors.
+
+# Disable tests on machines with no hardware support for IEEE arithmetic.
+if { [istarget "vax-*-*"] || [ istarget "powerpc-*-*spe"] || [istarget "pdp11-*-*"] } { return }
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+torture-init
+set-torture-options $C_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS
+
+set additional_flags "-fno-inline"
+
+# We must use -ffloat-store/-mieee to ensure that excess precision on some
+# machines does not cause problems
+if { ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"])
+ && [check_effective_target_ia32] } then {
+ lappend additional_flags "-ffloat-store"
+}
+if [istarget "m68k-*-*"] then {
+ lappend additional_flags "-ffloat-store"
+}
+if { [istarget "alpha*-*-*"]
+ || [istarget "sh*-*-*"] } then {
+ lappend additional_flags "-mieee"
+}
+
+if { ![check_effective_target_signal] } {
+ lappend additional_flags "-DSIGNAL_SUPPRESS"
+}
+
+# load support procs
+load_lib c-torture.exp
+
+# initialize harness
+gcc_init
+
+#
+# main test loop
+#
+
+foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
+ # If we're only testing specific files and this isn't one of them, skip it.
+ if ![runtest_file_p $runtests $src] then {
+ continue
+ }
+
+ c-torture-execute $src $additional_flags
+}
+
+# All done.
+torture-finish
+gcc_finish
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,44 @@
+extern void abort (void);
+
+int main()
+{
+#ifndef __SPU__
+ /* The SPU single-precision floating point format does not support Inf. */
+ float fi = __builtin_inff();
+#endif
+ double di = __builtin_inf();
+ long double li = __builtin_infl();
+
+ float fh = __builtin_huge_valf();
+ double dh = __builtin_huge_val();
+ long double lh = __builtin_huge_vall();
+
+#ifndef __SPU__
+ if (fi + fi != fi)
+ abort ();
+#endif
+ if (di + di != di)
+ abort ();
+ if (li + li != li)
+ abort ();
+
+#ifndef __SPU__
+ if (fi != fh)
+ abort ();
+#endif
+ if (di != dh)
+ abort ();
+ if (li != lh)
+ abort ();
+
+#ifndef __SPU__
+ if (fi <= 0)
+ abort ();
+#endif
+ if (di <= 0)
+ abort ();
+ if (li <= 0)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,82 @@
+extern void abort (void);
+
+void test(double f, double i)
+{
+ if (f == __builtin_inf())
+ abort ();
+ if (f == -__builtin_inf())
+ abort ();
+ if (i == -__builtin_inf())
+ abort ();
+ if (i != __builtin_inf())
+ abort ();
+
+ if (f >= __builtin_inf())
+ abort ();
+ if (f > __builtin_inf())
+ abort ();
+ if (i > __builtin_inf())
+ abort ();
+ if (f <= -__builtin_inf())
+ abort ();
+ if (f < -__builtin_inf())
+ abort ();
+}
+
+void testf(float f, float i)
+{
+#ifndef __SPU__
+ /* The SPU single-precision floating point format does not support Inf. */
+
+ if (f == __builtin_inff())
+ abort ();
+ if (f == -__builtin_inff())
+ abort ();
+ if (i == -__builtin_inff())
+ abort ();
+ if (i != __builtin_inff())
+ abort ();
+
+ if (f >= __builtin_inff())
+ abort ();
+ if (f > __builtin_inff())
+ abort ();
+ if (i > __builtin_inff())
+ abort ();
+ if (f <= -__builtin_inff())
+ abort ();
+ if (f < -__builtin_inff())
+ abort ();
+#endif
+}
+
+void testl(long double f, long double i)
+{
+ if (f == __builtin_infl())
+ abort ();
+ if (f == -__builtin_infl())
+ abort ();
+ if (i == -__builtin_infl())
+ abort ();
+ if (i != __builtin_infl())
+ abort ();
+
+ if (f >= __builtin_infl())
+ abort ();
+ if (f > __builtin_infl())
+ abort ();
+ if (i > __builtin_infl())
+ abort ();
+ if (f <= -__builtin_infl())
+ abort ();
+ if (f < -__builtin_infl())
+ abort ();
+}
+
+int main()
+{
+ test (34.0, __builtin_inf());
+ testf (34.0f, __builtin_inff());
+ testl (34.0l, __builtin_infl());
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/inf-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,78 @@
+extern void abort (void);
+
+void test(double f, double i)
+{
+ if (f == __builtin_huge_val())
+ abort ();
+ if (f == -__builtin_huge_val())
+ abort ();
+ if (i == -__builtin_huge_val())
+ abort ();
+ if (i != __builtin_huge_val())
+ abort ();
+
+ if (f >= __builtin_huge_val())
+ abort ();
+ if (f > __builtin_huge_val())
+ abort ();
+ if (i > __builtin_huge_val())
+ abort ();
+ if (f <= -__builtin_huge_val())
+ abort ();
+ if (f < -__builtin_huge_val())
+ abort ();
+}
+
+void testf(float f, float i)
+{
+ if (f == __builtin_huge_valf())
+ abort ();
+ if (f == -__builtin_huge_valf())
+ abort ();
+ if (i == -__builtin_huge_valf())
+ abort ();
+ if (i != __builtin_huge_valf())
+ abort ();
+
+ if (f >= __builtin_huge_valf())
+ abort ();
+ if (f > __builtin_huge_valf())
+ abort ();
+ if (i > __builtin_huge_valf())
+ abort ();
+ if (f <= -__builtin_huge_valf())
+ abort ();
+ if (f < -__builtin_huge_valf())
+ abort ();
+}
+
+void testl(long double f, long double i)
+{
+ if (f == __builtin_huge_vall())
+ abort ();
+ if (f == -__builtin_huge_vall())
+ abort ();
+ if (i == -__builtin_huge_vall())
+ abort ();
+ if (i != __builtin_huge_vall())
+ abort ();
+
+ if (f >= __builtin_huge_vall())
+ abort ();
+ if (f > __builtin_huge_vall())
+ abort ();
+ if (i > __builtin_huge_vall())
+ abort ();
+ if (f <= -__builtin_huge_vall())
+ abort ();
+ if (f < -__builtin_huge_vall())
+ abort ();
+}
+
+int main()
+{
+ test (34.0, __builtin_huge_val());
+ testf (34.0f, __builtin_huge_valf());
+ testl (34.0l, __builtin_huge_vall());
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/minuszero.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/minuszero.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/minuszero.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/minuszero.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+main ()
+{
+ union
+ {
+ double d;
+ unsigned short i[sizeof (double) / sizeof (short)];
+ } u;
+ int a = 0;
+ int b = -5;
+ int j;
+
+ u.d = (double) a / b;
+
+ /* Look for the right pattern, but be sloppy since
+ we don't know the byte order. */
+ for (j = 0; j < sizeof (double) / sizeof (short); j++)
+ {
+ if (u.i[j] == 0x8000)
+ exit (0);
+ }
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mul-subnormal-single-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mul-subnormal-single-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mul-subnormal-single-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mul-subnormal-single-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,75 @@
+/* Check that certain subnormal numbers (formerly known as denormalized
+ numbers) are rounded to within 0.5 ulp. PR other/14354. */
+
+/* This test requires that float and unsigned int are the same size and
+ that the sign-bit of the float is at MSB of the unsigned int. */
+
+#if __INT_MAX__ != 2147483647L
+int main () { exit (0); }
+#else
+
+union uf
+{
+ unsigned int u;
+ float f;
+};
+
+static float
+u2f (unsigned int v)
+{
+ union uf u;
+ u.u = v;
+ return u.f;
+}
+
+static unsigned int
+f2u (float v)
+{
+ union uf u;
+ u.f = v;
+ return u.u;
+}
+
+int ok = 1;
+
+static void
+tstmul (unsigned int ux, unsigned int uy, unsigned int ur)
+{
+ float x = u2f (ux);
+ float y = u2f (uy);
+
+ if (f2u (x * y) != ur)
+ /* Set a variable rather than aborting here, to simplify tracing when
+ several computations are wrong. */
+ ok = 0;
+}
+
+/* We don't want to make this const and static, or else we risk inlining
+ causing the test to fold as constants at compile-time. */
+struct
+{
+ unsigned int p1, p2, res;
+} expected[] =
+ {
+ {0xfff, 0x3f800400, 0xfff},
+ {0xf, 0x3fc88888, 0x17},
+ {0xf, 0x3f844444, 0xf}
+ };
+
+int
+main ()
+{
+ unsigned int i;
+
+ for (i = 0; i < sizeof (expected) / sizeof (expected[0]); i++)
+ {
+ tstmul (expected[i].p1, expected[i].p2, expected[i].res);
+ tstmul (expected[i].p2, expected[i].p1, expected[i].res);
+ }
+
+ if (!ok)
+ abort ();
+
+ exit (0);
+}
+#endif
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mul-subnormal-single-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mul-subnormal-single-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mul-subnormal-single-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mul-subnormal-single-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+if {[istarget "csky-*-*"] && [check_effective_target_hard_float]} {
+ # The C-SKY hardware FPU only supports flush-to-zero mode.
+ set torture_execute_xfail "csky-*-*"
+ return 1
+}
+if [istarget "epiphany-*-*"] {
+ # The Epiphany single-precision floating point format does not
+ # support subnormals.
+ return 1
+}
+if {[istarget "m68k-*-*"] && [check_effective_target_coldfire_fpu]} {
+ # ColdFire FPUs require software handling of subnormals. We are
+ # not aware of any system that has this.
+ set torture_execute_xfail "m68k-*-*"
+}
+if [istarget "spu-*-*"] {
+ # The SPU single-precision floating point format does not
+ # support subnormals.
+ return 1
+}
+if { [istarget "tic6x-*-*"] && [check_effective_target_ti_c67x] } {
+ # C6X floating point hardware turns denormals to zero in multiplications.
+ set torture_execute_xfail "tic6x-*-*"
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,61 @@
+/* Test IEEE +0/-0 rules */
+
+static double pzero = +0.0;
+static double nzero = -0.0;
+static double pinf = +1.0 / 0.0;
+static double ninf = -1.0 / 0.0;
+static double nan = 0.0 / 0.0;
+
+void
+expect (double value, double expected)
+{
+ if (expected != expected) /* expected value is Not a number */
+ {
+ if (value == value) /* actual value is a number */
+ abort ();
+ }
+
+ else if (value != value)
+ abort (); /* actual value is a NaN */
+
+ else if (memcmp ((void *)&value, (void *)&expected, sizeof (double)) != 0)
+ abort (); /* values don't match */
+}
+
+main ()
+{
+ expect (pzero + pzero, pzero);
+ expect (pzero + nzero, pzero);
+ expect (nzero + pzero, pzero);
+ expect (nzero + nzero, nzero);
+
+ expect (pzero - pzero, pzero);
+ expect (pzero - nzero, pzero);
+ expect (nzero - pzero, nzero);
+ expect (nzero - nzero, pzero);
+
+ expect (pzero * pzero, pzero);
+ expect (pzero * nzero, nzero);
+ expect (nzero * pzero, nzero);
+ expect (nzero * nzero, pzero);
+
+ expect (+1.00 * pzero, pzero);
+ expect (-1.00 * pzero, nzero);
+ expect (+1.00 * nzero, nzero);
+ expect (-1.00 * nzero, pzero);
+
+#ifndef _TMS320C6700
+ /* C6X floating point division is implemented using reciprocals. */
+ expect (pzero / pzero, nan);
+ expect (pzero / nzero, nan);
+ expect (nzero / pzero, nan);
+ expect (nzero / nzero, nan);
+
+ expect (+1.00 / pzero, pinf);
+ expect (-1.00 / pzero, ninf);
+ expect (+1.00 / nzero, ninf);
+ expect (-1.00 / nzero, pinf);
+#endif
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero2.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero2.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero2.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero2.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,6 @@
+# freebsd sets up the fpu with a different precision control which causes
+# this test to "fail".
+if { [istarget "i?86-*-freebsd*\[123\]\.*"] } {
+ set torture_execute_xfail "i?86-*-freebsd*"
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,51 @@
+/* Copyright (C) 2002 Free Software Foundation.
+ by Hans-Peter Nilsson <hp at bitrange.com>, derived from mzero2.c
+
+ In the MMIX port, negdf2 was bogusly expanding -x into 0 - x. */
+
+double nzerod = -0.0;
+float nzerof = -0.0;
+double zerod = 0.0;
+float zerof = 0.0;
+
+void expectd (double, double);
+void expectf (float, float);
+double negd (double);
+float negf (float);
+
+main ()
+{
+ expectd (negd (zerod), nzerod);
+ expectf (negf (zerof), nzerof);
+ expectd (negd (nzerod), zerod);
+ expectf (negf (nzerof), zerof);
+ exit (0);
+}
+
+void
+expectd (double value, double expected)
+{
+ if (value != expected
+ || memcmp ((void *)&value, (void *) &expected, sizeof (double)) != 0)
+ abort ();
+}
+
+void
+expectf (float value, float expected)
+{
+ if (value != expected
+ || memcmp ((void *)&value, (void *) &expected, sizeof (float)) != 0)
+ abort ();
+}
+
+double
+negd (double v)
+{
+ return -v;
+}
+
+float
+negf (float v)
+{
+ return -v;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,57 @@
+/* Copyright (C) 2003 Free Software Foundation.
+ by Roger Sayle <roger at eyesopen.com>, derived from mzero3.c
+
+ Constant folding of sin(-0.0), tan(-0.0) and atan(-0.0) should
+ all return -0.0, for both double and float forms. */
+
+void abort (void);
+typedef __SIZE_TYPE__ size_t;
+extern int memcmp (const void *, const void *, size_t);
+
+double sin (double);
+double tan (double);
+double atan (double);
+
+float sinf (float);
+float tanf (float);
+float atanf (float);
+
+void expectd (double, double);
+void expectf (float, float);
+
+void
+expectd (double value, double expected)
+{
+ if (value != expected
+ || memcmp ((void *)&value, (void *) &expected, sizeof (double)) != 0)
+ abort ();
+}
+
+void
+expectf (float value, float expected)
+{
+ if (value != expected
+ || memcmp ((void *)&value, (void *) &expected, sizeof (float)) != 0)
+ abort ();
+}
+
+int main ()
+{
+ expectd (sin (0.0), 0.0);
+ expectd (tan (0.0), 0.0);
+ expectd (atan (0.0), 0.0);
+
+ expectd (sin (-0.0), -0.0);
+ expectd (tan (-0.0), -0.0);
+ expectd (atan (-0.0), -0.0);
+
+ expectf (sinf (0.0f), 0.0f);
+ expectf (tanf (0.0f), 0.0f);
+ expectf (atanf (0.0f), 0.0f);
+
+ expectf (sinf (-0.0f), -0.0f);
+ expectf (tanf (-0.0f), -0.0f);
+ expectf (atanf (-0.0f), -0.0f);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+/* Test gcse handling of IEEE 0/-0 rules. */
+static double zero = 0.0;
+
+int
+negzero_check (double d)
+{
+ if (d == 0)
+ return !!memcmp ((void *)&zero, (void *)&d, sizeof (double));
+ return 0;
+}
+
+int
+sub (double d, double e)
+{
+ if (d == 0.0 && e == 0.0
+ && negzero_check (d) == 0 && negzero_check (e) == 0)
+ return 1;
+ else
+ return 0;
+}
+
+int
+main (void)
+{
+ double minus_zero = -0.0;
+ if (sub (minus_zero, 0))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero6.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero6.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero6.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/mzero6.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* Tail call optimizations would convert func() into the moral equivalent of:
+
+ double acc = 0.0;
+ for (int i = 0; i <= n; i++)
+ acc += d;
+ return acc;
+
+ which mishandles the case where 'd' is -0. They also initialised 'acc'
+ to a zero int rather than a zero double. */
+
+double func (double d, int n)
+{
+ if (n == 0)
+ return d;
+ else
+ return d + func (d, n - 1);
+}
+
+int main ()
+{
+ if (__builtin_copysign (1.0, func (0.0 / -5.0, 10)) != -1.0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr28634.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr28634.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr28634.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr28634.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+/* PR rtl-optimization/28634. On targets with delayed branches,
+ dbr_schedule could do the next iteration's addition in the
+ branch delay slot, then subtract the value again if the branch
+ wasn't taken. This can lead to rounding errors. */
+double x = -0x1.0p53;
+double y = 1;
+int
+main (void)
+{
+ while (y > 0)
+ y += x;
+ if (y != x + 1)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr29302-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr29302-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr29302-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr29302-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+extern void abort (void);
+
+int main (void)
+{
+ int n;
+ long double x;
+
+ x = 1/0.0;
+
+ n = (x == 1/0.0);
+
+ if (n == 1)
+ return 0;
+ else
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr29302-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr29302-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr29302-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr29302-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,12 @@
+if { [istarget "tic6x-*-*"] && [check_effective_target_ti_c67x] } {
+ # C6X uses -freciprocal-math by default.
+ set torture_execute_xfail "tic6x-*-*"
+ return 1
+}
+return 0
+if { [istarget "tic6x-*-*"] && [check_effective_target_ti_c67x] } {
+ # C6X uses -freciprocal-math by default.
+ set torture_execute_xfail "tic6x-*-*"
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr30704.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr30704.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr30704.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr30704.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,55 @@
+/* PR middle-end/30704 */
+
+typedef __SIZE_TYPE__ size_t;
+extern void abort (void);
+extern int memcmp (const void *, const void *, size_t);
+extern void *memcpy (void *, const void *, size_t);
+
+long long
+f1 (void)
+{
+ long long t;
+ double d = 0x0.fffffffffffff000p-1022;
+ memcpy (&t, &d, sizeof (long long));
+ return t;
+}
+
+double
+f2 (void)
+{
+ long long t = 0x000fedcba9876543LL;
+ double d;
+ memcpy (&d, &t, sizeof (long long));
+ return d;
+}
+
+int
+main ()
+{
+ union
+ {
+ long long ll;
+ double d;
+ } u;
+
+ if (sizeof (long long) != sizeof (double) || __DBL_MIN_EXP__ != -1021)
+ return 0;
+
+ u.ll = f1 ();
+ if (u.d != 0x0.fffffffffffff000p-1022)
+ abort ();
+
+ u.d = f2 ();
+ if (u.ll != 0x000fedcba9876543LL)
+ abort ();
+
+ double b = 234.0;
+ long long c;
+ double d = b;
+ memcpy (&c, &b, sizeof (double));
+ long long e = c;
+ if (memcmp (&e, &d, sizeof (double)) != 0)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr30704.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr30704.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr30704.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr30704.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,5 @@
+if [istarget "avr-*-*"] {
+ # AVR doubles are floats
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr36332.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr36332.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr36332.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr36332.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+/* PR target/36332 */
+
+int
+foo (long double ld)
+{
+ return ld == __builtin_infl ();
+}
+
+int
+main ()
+{
+ if (foo (__LDBL_MAX__))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr38016.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr38016.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr38016.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr38016.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1 @@
+#include "fp-cmp-8.c"
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr38016.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr38016.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr38016.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr38016.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,2 @@
+lappend additional_flags "-fno-ivopts" "-fno-gcse"
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr50310.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr50310.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr50310.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr50310.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,73 @@
+/* PR target/50310 */
+
+extern void abort (void);
+double s1[4], s2[4], s3[64];
+
+void
+foo (void)
+{
+ int i;
+ for (i = 0; i < 4; i++)
+ s3[0 * 4 + i] = __builtin_isgreater (s1[i], s2[i]) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[1 * 4 + i] = (!__builtin_isgreater (s1[i], s2[i])) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[2 * 4 + i] = __builtin_isgreaterequal (s1[i], s2[i]) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[3 * 4 + i] = (!__builtin_isgreaterequal (s1[i], s2[i])) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[4 * 4 + i] = __builtin_isless (s1[i], s2[i]) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[5 * 4 + i] = (!__builtin_isless (s1[i], s2[i])) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[6 * 4 + i] = __builtin_islessequal (s1[i], s2[i]) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[7 * 4 + i] = (!__builtin_islessequal (s1[i], s2[i])) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[8 * 4 + i] = __builtin_islessgreater (s1[i], s2[i]) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[9 * 4 + i] = (!__builtin_islessgreater (s1[i], s2[i])) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[10 * 4 + i] = __builtin_isunordered (s1[i], s2[i]) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[11 * 4 + i] = (!__builtin_isunordered (s1[i], s2[i])) ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[12 * 4 + i] = s1[i] > s2[i] ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[13 * 4 + i] = s1[i] <= s2[i] ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[14 * 4 + i] = s1[i] < s2[i] ? -1.0 : 0.0;
+ for (i = 0; i < 4; i++)
+ s3[15 * 4 + i] = s1[i] >= s2[i] ? -1.0 : 0.0;
+}
+
+int
+main ()
+{
+ int i;
+ s1[0] = 5.0;
+ s1[1] = 6.0;
+ s1[2] = 5.0;
+ s1[3] = __builtin_nan ("");
+ s2[0] = 6.0;
+ s2[1] = 5.0;
+ s2[2] = 5.0;
+ s2[3] = 5.0;
+ asm volatile ("" : : : "memory");
+ foo ();
+ asm volatile ("" : : : "memory");
+ for (i = 0; i < 16 * 4; i++)
+ if (i >= 12 * 4 && (i & 3) == 3)
+ {
+ if (s3[i] != 0.0) abort ();
+ }
+ else
+ {
+ static int masks[] = { 2, 2|4, 1, 1|4, 1|2, 8, 2, 1 };
+ if (s3[i]
+ != (((1 << (i & 3)) & ((i & 4) ? ~masks[i / 8] : masks[i / 8]))
+ ? -1.0 : 0.0))
+ abort ();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr67218.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr67218.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr67218.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr67218.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+extern void abort (void) __attribute__ ((noreturn));
+
+double __attribute__ ((noinline, noclone))
+foo (unsigned int x)
+{
+ return (double) (float) (x | 0xffff0000);
+}
+
+int
+main ()
+{
+ if (foo (1) != 0x1.fffep31)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr72824-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr72824-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr72824-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr72824-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR tree-optimization/72824 */
+
+typedef float V __attribute__((vector_size (4 * sizeof (float))));
+
+static inline void
+foo (V *x, V value)
+{
+ int i;
+ for (i = 0; i < 32; ++i)
+ x[i] = value;
+}
+
+int
+main ()
+{
+ V x[32];
+ foo (x, (V) { 0.f, -0.f, 0.f, -0.f });
+ if (__builtin_copysignf (1.0, x[3][1]) != -1.0f)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr72824.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr72824.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr72824.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr72824.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* PR tree-optimization/72824 */
+
+static inline void
+foo (float *x, float value)
+{
+ int i;
+ for (i = 0; i < 32; ++i)
+ x[i] = value;
+}
+
+int
+main ()
+{
+ float x[32];
+ foo (x, -0.f);
+ if (__builtin_copysignf (1.0, x[3]) != -1.0f)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr84235.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr84235.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr84235.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/pr84235.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,11 @@
+/* PR tree-optimization/84235 */
+
+int
+main ()
+{
+ double d = 1.0 / 0.0;
+ _Bool b = d == d && (d - d) != (d - d);
+ if (!b)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/rbug.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/rbug.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/rbug.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/rbug.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,54 @@
+#if defined(__i386__) && defined(__FreeBSD__)
+#include <ieeefp.h>
+#endif
+
+double d (unsigned long long k)
+{
+ double x;
+
+ x = (double) k;
+ return x;
+}
+
+float s (unsigned long long k)
+{
+ float x;
+
+ x = (float) k;
+ return x;
+}
+
+main ()
+{
+ unsigned long long int k;
+ double x;
+
+#if defined(__i386__) && defined(__FreeBSD__)
+ /* This test case assumes extended-precision, but FreeBSD defaults to
+ double-precision. Make it so. */
+ fpsetprec (FP_PE);
+#endif
+
+ if (sizeof (double) >= 8)
+ {
+ k = 0x8693ba6d7d220401ULL;
+ x = d (k);
+ k = (unsigned long long) x;
+ if (k != 0x8693ba6d7d220800ULL)
+ abort ();
+ }
+
+ k = 0x8234508000000001ULL;
+ x = s (k);
+ k = (unsigned long long) x;
+#ifdef __SPU__
+ /* SPU float rounds towards zero. */
+ if (k != 0x8234500000000000ULL)
+ abort ();
+#else
+ if (k != 0x8234510000000000ULL)
+ abort ();
+#endif
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/rbug.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/rbug.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/rbug.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/rbug.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,10 @@
+# This doesn't work on d10v if doubles are not 64 bits
+
+if { [istarget "d10v-*-*"] && ! [string-match "*-mdouble64*" $CFLAGS] } {
+ set torture_execute_xfail "d10v-*-*"
+}
+if [istarget "avr-*-*"] {
+ # AVR doubles are floats
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,39 @@
+extern void abort();
+
+typedef union {
+ struct {
+ unsigned int hi;
+ unsigned int lo;
+ } i;
+ double d;
+} hexdouble;
+
+static const double twoTo52 = 0x1.0p+52;
+
+void func ( double x )
+{
+ hexdouble argument;
+ register double y, z;
+ unsigned int xHead;
+ argument.d = x;
+ xHead = argument.i.hi & 0x7fffffff;
+ if (__builtin_expect(!!(xHead < 0x43300000u), 1))
+ {
+ y = ( x - twoTo52 ) + twoTo52;
+ if ( y != x )
+ abort();
+ z = x - 0.5;
+ y = ( z - twoTo52 ) + twoTo52;
+ if ( y == (( x - twoTo52 ) + twoTo52) )
+ abort();
+ }
+ return;
+}
+
+int main()
+{
+ if (sizeof (double) == 4)
+ return 0;
+ func((double)1.00);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc-1.x
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc-1.x?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc-1.x (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc-1.x Wed Oct 9 04:01:46 2019
@@ -0,0 +1,5 @@
+if [istarget "avr-*-*"] {
+ # AVR doubles are floats
+ return 1
+}
+return 0
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ieee/unsafe-fp-assoc.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+#include <float.h>
+
+extern void abort(void);
+
+static const double C = DBL_MAX;
+
+double foo(double x)
+{
+ return ( ( (x * C) * C ) * C);
+}
+
+int main ()
+{
+ double d = foo (0.0);
+ if (d != 0.0)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ifcvt-onecmpl-abs-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ifcvt-onecmpl-abs-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ifcvt-onecmpl-abs-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ifcvt-onecmpl-abs-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+
+extern void abort(void);
+
+__attribute__ ((noinline))
+int foo(int n)
+{
+ if (n < 0)
+ n = ~n;
+
+ return n;
+}
+
+int main(void)
+{
+ if (foo (-1) != 0)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/index-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/index-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/index-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/index-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+int a[] =
+{
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
+};
+
+int
+f (long n)
+{
+ return a[n - 100000];
+}
+
+main ()
+{
+ if (f (100030L) != 30)
+ abort();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/inst-check.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/inst-check.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/inst-check.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/inst-check.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+#include <stdarg.h>
+
+f(m)
+{
+ int i,s=0;
+ for(i=0;i<m;i++)
+ s+=i;
+ return s;
+}
+
+main()
+{
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/int-compare.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/int-compare.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/int-compare.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/int-compare.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,108 @@
+#include <limits.h>
+
+gt (a, b)
+{
+ return a > b;
+}
+
+ge (a, b)
+{
+ return a >= b;
+}
+
+lt (a, b)
+{
+ return a < b;
+}
+
+le (a, b)
+{
+ return a <= b;
+}
+
+void
+true (c)
+{
+ if (!c)
+ abort();
+}
+
+void
+false (c)
+{
+ if (c)
+ abort();
+}
+
+f ()
+{
+ true (gt (2, 1));
+ false (gt (1, 2));
+
+ true (gt (INT_MAX, 0));
+ false (gt (0, INT_MAX));
+ true (gt (INT_MAX, 1));
+ false (gt (1, INT_MAX));
+
+ false (gt (INT_MIN, 0));
+ true (gt (0, INT_MIN));
+ false (gt (INT_MIN, 1));
+ true (gt (1, INT_MIN));
+
+ true (gt (INT_MAX, INT_MIN));
+ false (gt (INT_MIN, INT_MAX));
+
+ true (ge (2, 1));
+ false (ge (1, 2));
+
+ true (ge (INT_MAX, 0));
+ false (ge (0, INT_MAX));
+ true (ge (INT_MAX, 1));
+ false (ge (1, INT_MAX));
+
+ false (ge (INT_MIN, 0));
+ true (ge (0, INT_MIN));
+ false (ge (INT_MIN, 1));
+ true (ge (1, INT_MIN));
+
+ true (ge (INT_MAX, INT_MIN));
+ false (ge (INT_MIN, INT_MAX));
+
+ false (lt (2, 1));
+ true (lt (1, 2));
+
+ false (lt (INT_MAX, 0));
+ true (lt (0, INT_MAX));
+ false (lt (INT_MAX, 1));
+ true (lt (1, INT_MAX));
+
+ true (lt (INT_MIN, 0));
+ false (lt (0, INT_MIN));
+ true (lt (INT_MIN, 1));
+ false (lt (1, INT_MIN));
+
+ false (lt (INT_MAX, INT_MIN));
+ true (lt (INT_MIN, INT_MAX));
+
+ false (le (2, 1));
+ true (le (1, 2));
+
+ false (le (INT_MAX, 0));
+ true (le (0, INT_MAX));
+ false (le (INT_MAX, 1));
+ true (le (1, INT_MAX));
+
+ true (le (INT_MIN, 0));
+ false (le (0, INT_MIN));
+ true (le (INT_MIN, 1));
+ false (le (1, INT_MIN));
+
+ false (le (INT_MAX, INT_MIN));
+ true (le (INT_MIN, INT_MAX));
+}
+
+main ()
+{
+ f ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ipa-sra-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ipa-sra-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ipa-sra-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ipa-sra-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+/* Trivially making sure IPA-SRA does not introduce segfaults where they should
+ not be. */
+
+struct bovid
+{
+ float red;
+ int green;
+ void *blue;
+};
+
+static int
+__attribute__((noinline))
+ox (int fail, struct bovid *cow)
+{
+ int r;
+ if (fail)
+ r = cow->red;
+ else
+ r = 0;
+ return r;
+}
+
+int main (int argc, char *argv[])
+{
+ int r;
+
+ r = ox ((argc > 2000), (void *) 0);
+ return r;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ipa-sra-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ipa-sra-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ipa-sra-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/ipa-sra-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+/* { dg-require-effective-target int32plus } */
+struct big
+{
+ int data[1000000];
+};
+
+struct small
+{
+ int data[10];
+};
+
+union both
+{
+ struct big big;
+ struct small small;
+};
+
+extern void *calloc (__SIZE_TYPE__, __SIZE_TYPE__);
+extern void free (void *);
+
+static int __attribute__((noinline))
+foo (int fail, union both *agg)
+{
+ int r;
+ if (fail)
+ r = agg->big.data[999999];
+ else
+ r = agg->small.data[0];
+ return r;
+}
+
+int main (int argc, char *argv[])
+{
+ union both *agg = calloc (1, sizeof (struct small));
+ int r;
+
+ r = foo ((argc > 2000), agg);
+
+ free (agg);
+ return r;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/longlong.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/longlong.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/longlong.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/longlong.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,39 @@
+/* Source: PR 321 modified for test suite by Neil Booth 14 Jan 2001. */
+
+typedef unsigned long long uint64;
+unsigned long pars;
+
+uint64 b[32];
+uint64 *r = b;
+
+void alpha_ep_extbl_i_eq_0()
+{
+ unsigned int rb, ra, rc;
+
+ rb = (((unsigned long)(pars) >> 27)) & 0x1fUL;
+ ra = (((unsigned int)(pars) >> 5)) & 0x1fUL;
+ rc = (((unsigned int)(pars) >> 0)) & 0x1fUL;
+ {
+ uint64 temp = ((r[ra] >> ((r[rb] & 0x7) << 3)) & 0x00000000000000FFLL);
+ if (rc != 31)
+ r[rc] = temp;
+ }
+}
+
+int
+main(void)
+{
+ if (sizeof (uint64) == 8)
+ {
+ b[17] = 0x0000000000303882ULL; /* rb */
+ b[2] = 0x534f4f4c494d000aULL; /* ra & rc */
+
+ pars = 0x88000042; /* 17, 2, 2 coded */
+ alpha_ep_extbl_i_eq_0();
+
+ if (b[2] != 0x4d)
+ abort ();
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+main ()
+{
+ int i, j, k[3];
+
+ j = 0;
+ for (i=0; i < 3; i++)
+ {
+ k[i] = j++;
+ }
+
+ for (i=2; i >= 0; i--)
+ {
+ if (k[i] != i)
+ abort ();
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-10.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-10.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-10.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-10.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+/* Reduced from PR optimization/5076, PR optimization/2847 */
+
+static int count = 0;
+
+static void
+inc (void)
+{
+ count++;
+}
+
+int
+main (void)
+{
+ int iNbr = 1;
+ int test = 0;
+ while (test == 0)
+ {
+ inc ();
+ if (iNbr == 0)
+ break;
+ else
+ {
+ inc ();
+ iNbr--;
+ }
+ test = 1;
+ }
+ if (count != 2)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-11.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-11.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-11.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-11.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+static int a[199];
+
+static void
+foo ()
+{
+ int i;
+ for (i = 198; i >= 0; i--)
+ a[i] = i;
+}
+
+int
+main ()
+{
+ int i;
+ foo ();
+ for (i = 0; i < 199; i++)
+ if (a[i] != i)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-12.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-12.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-12.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-12.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* Checks that pure functions are not treated as const. */
+
+char *p;
+
+static int __attribute__ ((pure))
+is_end_of_statement (void)
+{
+ return *p == '\n' || *p == ';' || *p == '!';
+}
+
+void foo (void)
+{
+ /* The is_end_of_statement call was moved out of the loop at one stage,
+ resulting in an endless loop. */
+ while (!is_end_of_statement ())
+ p++;
+}
+
+int
+main (void)
+{
+ p = "abc\n";
+ foo ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-13.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-13.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-13.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-13.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+/* PR opt/7130 */
+#define TYPE long
+
+void
+scale (TYPE *alpha, TYPE *x, int n)
+{
+ int i, ix;
+
+ if (*alpha != 1)
+ for (i = 0, ix = 0; i < n; i++, ix += 2)
+ {
+ TYPE tmpr, tmpi;
+ tmpr = *alpha * x[ix];
+ tmpi = *alpha * x[ix + 1];
+ x[ix] = tmpr;
+ x[ix + 1] = tmpi;
+ }
+}
+
+int
+main (void)
+{
+ int i;
+ TYPE x[10];
+ TYPE alpha = 2;
+
+ for (i = 0; i < 10; i++)
+ x[i] = i;
+
+ scale (&alpha, x, 5);
+
+ if (x[9] != 18)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-14.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-14.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-14.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-14.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+int a3[3];
+
+void f(int *a)
+{
+ int i;
+
+ for (i=3; --i;)
+ a[i] = 42 / i;
+}
+
+int
+main ()
+{
+ f(a3);
+
+ if (a3[1] != 42 || a3[2] != 21)
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-15.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-15.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-15.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-15.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,40 @@
+/* Bombed with a segfault on powerpc-linux. doloop.c generated wrong
+ loop count. */
+void
+foo (unsigned long *start, unsigned long *end)
+{
+ unsigned long *temp = end - 1;
+
+ while (end > start)
+ *end-- = *temp--;
+}
+
+int
+main (void)
+{
+ unsigned long a[5];
+ int start, end, k;
+
+ for (start = 0; start < 5; start++)
+ for (end = 0; end < 5; end++)
+ {
+ for (k = 0; k < 5; k++)
+ a[k] = k;
+
+ foo (a + start, a + end);
+
+ for (k = 0; k <= start; k++)
+ if (a[k] != k)
+ abort ();
+
+ for (k = start + 1; k <= end; k++)
+ if (a[k] != k - 1)
+ abort ();
+
+ for (k = end + 1; k < 5; k++)
+ if (a[k] != k)
+ abort ();
+ }
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+int a[2];
+
+f (b)
+{
+ unsigned int i;
+ for (i = 0; i < b; i++)
+ a[i] = i - 2;
+}
+
+main ()
+{
+ a[0] = a[1] = 0;
+ f (2);
+ if (a[0] != -2 || a[1] != -1)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2b.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2b.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2b.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2b.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+#include <limits.h>
+
+int a[2];
+
+f (int i)
+{
+ for (; i < INT_MAX; i++)
+ {
+ a[i] = -2;
+ if (&a[i] == &a[1])
+ break;
+ }
+}
+
+main ()
+{
+ a[0] = a[1] = 0;
+ f (0);
+ if (a[0] != -2 || a[1] != -2)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2c.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2c.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2c.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2c.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* { dg-options "-fgnu89-inline -Wno-pointer-to-int-cast" } */
+
+extern void abort (void);
+extern void exit (int);
+
+int a[2];
+
+__inline__ void f (int b, int o)
+{
+ unsigned int i;
+ int *p;
+ for (p = &a[b], i = b; --i < ~0; )
+ *--p = i * 3 + o;
+}
+
+void
+g(int b)
+{
+ f (b, (int)a);
+}
+
+int
+main ()
+{
+ a[0] = a[1] = 0;
+ g (2);
+ if (a[0] != (int)a || a[1] != (int)a + 3)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2d.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2d.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2d.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2d.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+int a[2];
+
+f (b)
+{
+ unsigned int i;
+ int *p;
+ for (p = &a[b], i = b; --i < ~0; )
+ *--p = i * 3 + (int)a;
+}
+
+main ()
+{
+ a[0] = a[1] = 0;
+ f (2);
+ if (a[0] != (int)a || a[1] != (int)a + 3)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2e.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2e.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2e.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2e.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,39 @@
+void f (int *p, int **q)
+{
+ int i;
+ for (i = 0; i < 40; i++)
+ {
+ *q++ = &p[i];
+ }
+}
+
+int main ()
+{
+ void *p;
+ int *q[40];
+ __SIZE_TYPE__ start;
+
+ /* Find the signed middle of the address space. */
+ if (sizeof(start) == sizeof(int))
+ start = (__SIZE_TYPE__) __INT_MAX__;
+ else if (sizeof(start) == sizeof(long))
+ start = (__SIZE_TYPE__) __LONG_MAX__;
+ else if (sizeof(start) == sizeof(long long))
+ start = (__SIZE_TYPE__) __LONG_LONG_MAX__;
+ else
+ return 0;
+
+ /* Arbitrarily align the pointer. */
+ start &= -32;
+
+ /* Pretend that's good enough to start address arithmetic. */
+ p = (void *)start;
+
+ /* Verify that GIV replacement computes the correct results. */
+ q[39] = 0;
+ f (p, q);
+ if (q[39] != (int *)p + 39)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2f.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2f.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2f.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2f.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,64 @@
+/* { dg-require-effective-target mmap } */
+/* { dg-skip-if "the executable is at the same position the test tries to remap" { m68k-*-linux* } } */
+
+#include <limits.h>
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#ifndef MAP_ANON
+#ifdef MAP_ANONYMOUS
+#define MAP_ANON MAP_ANONYMOUS
+#else
+#define MAP_ANON MAP_FILE
+#endif
+#endif
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+#ifndef MAP_FIXED
+#define MAP_FIXED 0
+#endif
+
+#define MAP_START (void *)0x7fff8000
+#define MAP_LEN 0x10000
+
+#define OFFSET (MAP_LEN/2 - 2 * sizeof (char));
+
+f (int s, char *p)
+{
+ int i;
+ for (i = s; i >= 0 && &p[i] < &p[40]; i++)
+ {
+ p[i] = -2;
+ }
+}
+
+main ()
+{
+#ifdef MAP_ANON
+ char *p;
+ int dev_zero;
+
+ dev_zero = open ("/dev/zero", O_RDONLY);
+ /* -1 is OK when we have MAP_ANON; else mmap will flag an error. */
+ if (INT_MAX != 0x7fffffffL || sizeof (char *) != sizeof (int))
+ exit (0);
+ p = mmap (MAP_START, MAP_LEN, PROT_READ|PROT_WRITE,
+ MAP_ANON|MAP_FIXED|MAP_PRIVATE, dev_zero, 0);
+ if (p != (char *)-1)
+ {
+ p += OFFSET;
+ p[39] = 0;
+ f (0, p);
+ if (p[39] != (char)-2)
+ abort ();
+ p[39] = 0;
+ f (-1, p);
+ if (p[39] != 0)
+ abort ();
+ }
+#endif
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2g.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2g.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2g.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-2g.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,64 @@
+/* { dg-require-effective-target mmap } */
+/* { dg-skip-if "the executable is at the same position the test tries to remap" { m68k-*-linux* } } */
+
+#include <limits.h>
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#ifndef MAP_ANON
+#ifdef MAP_ANONYMOUS
+#define MAP_ANON MAP_ANONYMOUS
+#else
+#define MAP_ANON MAP_FILE
+#endif
+#endif
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+#ifndef MAP_FIXED
+#define MAP_FIXED 0
+#endif
+
+#define MAP_START (void *)0x7fff8000
+#define MAP_LEN 0x10000
+
+#define OFFSET (MAP_LEN/2 - 2 * sizeof (char));
+
+f (int s, char *p)
+{
+ int i;
+ for (i = s; &p[i] < &p[40] && i >= 0; i++)
+ {
+ p[i] = -2;
+ }
+}
+
+main ()
+{
+#ifdef MAP_ANON
+ char *p;
+ int dev_zero;
+
+ dev_zero = open ("/dev/zero", O_RDONLY);
+ /* -1 is OK when we have MAP_ANON; else mmap will flag an error. */
+ if (INT_MAX != 0x7fffffffL || sizeof (char *) != sizeof (int))
+ exit (0);
+ p = mmap (MAP_START, MAP_LEN, PROT_READ|PROT_WRITE,
+ MAP_ANON|MAP_FIXED|MAP_PRIVATE, dev_zero, 0);
+ if (p != (char *)-1)
+ {
+ p += OFFSET;
+ p[39] = 0;
+ f (0, p);
+ if (p[39] != (char)-2)
+ abort ();
+ p[39] = 0;
+ f (-1, p);
+ if (p[39] != 0)
+ abort ();
+ }
+#endif
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+#include <limits.h>
+
+int n = 0;
+
+g (i)
+{
+ n++;
+}
+
+f (m)
+{
+ int i;
+ i = m;
+ do
+ {
+ g (i * INT_MAX / 2);
+ }
+ while (--i > 0);
+}
+
+main ()
+{
+ f (4);
+ if (n != 4)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3b.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3b.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3b.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3b.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+#include <limits.h>
+
+int n = 0;
+
+g (i)
+{
+ n++;
+}
+
+f (m)
+{
+ int i;
+ i = m;
+ do
+ {
+ g (i * 4);
+ i -= INT_MAX / 8;
+ }
+ while (i > 0);
+}
+
+main ()
+{
+ f (INT_MAX/8*4);
+ if (n != 4)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3c.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3c.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3c.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-3c.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+#include <limits.h>
+
+void * a[255];
+
+f (m)
+{
+ int i;
+ int sh = 0x100;
+ i = m;
+ do
+ {
+ a[sh >>= 1] = ((unsigned)i << 3) + (char*)a;
+ i += 4;
+ }
+ while (i < INT_MAX/2 + 1 + 4 * 4);
+}
+
+main ()
+{
+ a[0x10] = 0;
+ a[0x08] = 0;
+ f (INT_MAX/2 + INT_MAX/4 + 2);
+ if (a[0x10] || a[0x08])
+ abort ();
+ a[0x10] = 0;
+ a[0x08] = 0;
+ f (INT_MAX/2 + 1);
+ if (! a[0x10] || a[0x08])
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+int
+f()
+{
+ int j = 1;
+ long i;
+ for (i = -0x70000000L; i < 0x60000000L; i += 0x10000000L) j <<= 1;
+ return j;
+}
+
+int
+main ()
+{
+ if (f () != 8192)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-4b.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-4b.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-4b.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-4b.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+int
+f()
+{
+ int j = 1;
+ long i;
+ i = 0x60000000L;
+ do
+ {
+ j <<= 1;
+ i += 0x10000000L;
+ } while (i < -0x60000000L);
+ return j;
+}
+
+int
+main ()
+{
+ if (f () != 2)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+static int ap(int i);
+static void testit(void){
+ int ir[4] = {0,1,2,3};
+ int ix,n,m;
+ n=1; m=3;
+ for (ix=1;ix<=4;ix++) {
+ if (n == 1) m = 4;
+ else m = n-1;
+ ap(ir[n-1]);
+ n = m;
+ }
+}
+
+static int t = 0;
+static int a[4];
+
+static int ap(int i){
+ if (t > 3)
+ abort();
+ a[t++] = i;
+ return 1;
+}
+
+int main(void)
+{
+ testit();
+ if (a[0] != 0)
+ abort();
+ if (a[1] != 3)
+ abort();
+ if (a[2] != 2)
+ abort();
+ if (a[3] != 1)
+ abort();
+ exit(0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-6.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-6.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-6.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-6.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+main()
+{
+ char c;
+ char d;
+ int nbits;
+ c = -1;
+ for (nbits = 1 ; nbits < 100; nbits++) {
+ d = (1 << nbits) - 1;
+ if (d == c)
+ break;
+ }
+ if (nbits == 100)
+ abort();
+ exit(0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-7.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-7.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-7.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-7.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+void foo (unsigned int n)
+{
+ int i, j = -1;
+
+ for (i = 0; i < 10 && j < 0; i++)
+ {
+ if ((1UL << i) == n)
+ j = i;
+ }
+
+ if (j < 0)
+ abort ();
+}
+
+main()
+{
+ foo (64);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-8.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-8.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-8.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-8.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+double a[3] = { 0.0, 1.0, 2.0 };
+
+void bar (int x, double *y)
+{
+ if (x || *y != 1.0)
+ abort ();
+}
+
+int main ()
+{
+ double c;
+ int d;
+ for (d = 0; d < 3; d++)
+ {
+ c = a[d];
+ if (c > 0.0) goto e;
+ }
+ bar(1, &c);
+ exit (1);
+e:
+ bar(0, &c);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-9.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-9.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-9.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-9.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* Source: Neil Booth, from PR # 115. */
+
+int false()
+{
+ return 0;
+}
+
+extern void abort (void);
+
+int main (int argc,char *argv[])
+{
+ int count = 0;
+
+ while (false() || count < -123)
+ ++count;
+
+ if (count)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-ivopts-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-ivopts-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-ivopts-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-ivopts-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* From PR 18977. */
+void foo(float * x);
+
+int main()
+{
+ float x[4];
+ foo (x);
+ return 0;
+}
+
+void foo (float *x)
+{
+ int i,j,k;
+ float temp;
+ static float t16[16]={1.,2.,3.,4.,5.,6.,7.,8.,9.,
+ 10.,11.,12.,13.,14.,15.,16.};
+ static float tmp[4]={0.,0.,0.,0.};
+
+ for (i=0; i<4; i++) {
+ k = 3 - i;
+ temp = t16[5*k];
+ for(j=k+1; j<4; j++) {
+ tmp[k] = t16[k+ j*4] * temp;
+ }
+ }
+ x[0] = tmp[0];
+ x[1] = tmp[1];
+ x[2] = tmp[2];
+ x[3] = tmp[3];
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-ivopts-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-ivopts-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-ivopts-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/loop-ivopts-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,49 @@
+/* PR rtl-optimization/20290 */
+
+/* We used to mis-optimize the second loop in main on at least ppc and
+ arm, because tree loop would change the loop to something like:
+
+ ivtmp.65 = &l[i];
+ ivtmp.16 = 113;
+ goto <bb 4> (<L4>);
+
+<L3>:;
+ *(ivtmp.65 + 4294967292B) = 9;
+ i = i + 1;
+
+<L4>:;
+ ivtmp.16 = ivtmp.16 - 1;
+ ivtmp.65 = ivtmp.65 + 4B;
+ if (ivtmp.16 != 0) goto <L3>;
+
+ We used to consider the increment of i as executed in every
+ iteration, so we'd miscompute the final value. */
+
+extern void abort (void);
+
+void
+check (unsigned int *l)
+{
+ int i;
+ for (i = 0; i < 288; i++)
+ if (l[i] != 7 + (i < 256 || i >= 280) + (i >= 144 && i < 256))
+ abort ();
+}
+
+int
+main (void)
+{
+ int i;
+ unsigned int l[288];
+
+ for (i = 0; i < 144; i++)
+ l[i] = 8;
+ for (; i < 256; i++)
+ l[i] = 9;
+ for (; i < 280; i++)
+ l[i] = 7;
+ for (; i < 288; i++)
+ l[i] = 8;
+ check (l);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/lshrdi-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/lshrdi-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/lshrdi-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/lshrdi-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,221 @@
+#include <limits.h>
+
+extern void abort(void);
+extern void exit(int);
+
+#if __LONG_LONG_MAX__ == 9223372036854775807LL
+#define BITS 64
+
+static unsigned long long const zext[64] = {
+ 0x87654321fedcba90ULL,
+ 0x43b2a190ff6e5d48ULL,
+ 0x21d950c87fb72ea4ULL,
+ 0x10eca8643fdb9752ULL,
+ 0x87654321fedcba9ULL,
+ 0x43b2a190ff6e5d4ULL,
+ 0x21d950c87fb72eaULL,
+ 0x10eca8643fdb975ULL,
+ 0x87654321fedcbaULL,
+ 0x43b2a190ff6e5dULL,
+ 0x21d950c87fb72eULL,
+ 0x10eca8643fdb97ULL,
+ 0x87654321fedcbULL,
+ 0x43b2a190ff6e5ULL,
+ 0x21d950c87fb72ULL,
+ 0x10eca8643fdb9ULL,
+ 0x87654321fedcULL,
+ 0x43b2a190ff6eULL,
+ 0x21d950c87fb7ULL,
+ 0x10eca8643fdbULL,
+ 0x87654321fedULL,
+ 0x43b2a190ff6ULL,
+ 0x21d950c87fbULL,
+ 0x10eca8643fdULL,
+ 0x87654321feULL,
+ 0x43b2a190ffULL,
+ 0x21d950c87fULL,
+ 0x10eca8643fULL,
+ 0x87654321fULL,
+ 0x43b2a190fULL,
+ 0x21d950c87ULL,
+ 0x10eca8643ULL,
+ 0x87654321ULL,
+ 0x43b2a190ULL,
+ 0x21d950c8ULL,
+ 0x10eca864ULL,
+ 0x8765432ULL,
+ 0x43b2a19ULL,
+ 0x21d950cULL,
+ 0x10eca86ULL,
+ 0x876543ULL,
+ 0x43b2a1ULL,
+ 0x21d950ULL,
+ 0x10eca8ULL,
+ 0x87654ULL,
+ 0x43b2aULL,
+ 0x21d95ULL,
+ 0x10ecaULL,
+ 0x8765ULL,
+ 0x43b2ULL,
+ 0x21d9ULL,
+ 0x10ecULL,
+ 0x876ULL,
+ 0x43bULL,
+ 0x21dULL,
+ 0x10eULL,
+ 0x87ULL,
+ 0x43ULL,
+ 0x21ULL,
+ 0x10ULL,
+ 0x8ULL,
+ 0x4ULL,
+ 0x2ULL,
+ 0x1ULL
+};
+
+#elif __LONG_LONG_MAX__ == 2147483647LL
+#define BITS 32
+
+static unsigned long long const zext[32] = {
+ 0x87654321ULL,
+ 0x43b2a190ULL,
+ 0x21d950c8ULL,
+ 0x10eca864ULL,
+ 0x8765432ULL,
+ 0x43b2a19ULL,
+ 0x21d950cULL,
+ 0x10eca86ULL,
+ 0x876543ULL,
+ 0x43b2a1ULL,
+ 0x21d950ULL,
+ 0x10eca8ULL,
+ 0x87654ULL,
+ 0x43b2aULL,
+ 0x21d95ULL,
+ 0x10ecaULL,
+ 0x8765ULL,
+ 0x43b2ULL,
+ 0x21d9ULL,
+ 0x10ecULL,
+ 0x876ULL,
+ 0x43bULL,
+ 0x21dULL,
+ 0x10eULL,
+ 0x87ULL,
+ 0x43ULL,
+ 0x21ULL,
+ 0x10ULL,
+ 0x8ULL,
+ 0x4ULL,
+ 0x2ULL,
+ 0x1ULL,
+};
+
+#else
+#error "Update the test case."
+#endif
+
+static unsigned long long
+variable_shift(unsigned long long x, int i)
+{
+ return x >> i;
+}
+
+static unsigned long long
+constant_shift(unsigned long long x, int i)
+{
+ switch (i)
+ {
+ case 0: x = x >> 0; break;
+ case 1: x = x >> 1; break;
+ case 2: x = x >> 2; break;
+ case 3: x = x >> 3; break;
+ case 4: x = x >> 4; break;
+ case 5: x = x >> 5; break;
+ case 6: x = x >> 6; break;
+ case 7: x = x >> 7; break;
+ case 8: x = x >> 8; break;
+ case 9: x = x >> 9; break;
+ case 10: x = x >> 10; break;
+ case 11: x = x >> 11; break;
+ case 12: x = x >> 12; break;
+ case 13: x = x >> 13; break;
+ case 14: x = x >> 14; break;
+ case 15: x = x >> 15; break;
+ case 16: x = x >> 16; break;
+ case 17: x = x >> 17; break;
+ case 18: x = x >> 18; break;
+ case 19: x = x >> 19; break;
+ case 20: x = x >> 20; break;
+ case 21: x = x >> 21; break;
+ case 22: x = x >> 22; break;
+ case 23: x = x >> 23; break;
+ case 24: x = x >> 24; break;
+ case 25: x = x >> 25; break;
+ case 26: x = x >> 26; break;
+ case 27: x = x >> 27; break;
+ case 28: x = x >> 28; break;
+ case 29: x = x >> 29; break;
+ case 30: x = x >> 30; break;
+ case 31: x = x >> 31; break;
+#if BITS > 32
+ case 32: x = x >> 32; break;
+ case 33: x = x >> 33; break;
+ case 34: x = x >> 34; break;
+ case 35: x = x >> 35; break;
+ case 36: x = x >> 36; break;
+ case 37: x = x >> 37; break;
+ case 38: x = x >> 38; break;
+ case 39: x = x >> 39; break;
+ case 40: x = x >> 40; break;
+ case 41: x = x >> 41; break;
+ case 42: x = x >> 42; break;
+ case 43: x = x >> 43; break;
+ case 44: x = x >> 44; break;
+ case 45: x = x >> 45; break;
+ case 46: x = x >> 46; break;
+ case 47: x = x >> 47; break;
+ case 48: x = x >> 48; break;
+ case 49: x = x >> 49; break;
+ case 50: x = x >> 50; break;
+ case 51: x = x >> 51; break;
+ case 52: x = x >> 52; break;
+ case 53: x = x >> 53; break;
+ case 54: x = x >> 54; break;
+ case 55: x = x >> 55; break;
+ case 56: x = x >> 56; break;
+ case 57: x = x >> 57; break;
+ case 58: x = x >> 58; break;
+ case 59: x = x >> 59; break;
+ case 60: x = x >> 60; break;
+ case 61: x = x >> 61; break;
+ case 62: x = x >> 62; break;
+ case 63: x = x >> 63; break;
+#endif
+
+ default:
+ abort ();
+ }
+ return x;
+}
+
+int
+main()
+{
+ int i;
+
+ for (i = 0; i < BITS; ++i)
+ {
+ unsigned long long y = variable_shift (zext[0], i);
+ if (y != zext[i])
+ abort ();
+ }
+ for (i = 0; i < BITS; ++i)
+ {
+ unsigned long long y = constant_shift (zext[0], i);
+ if (y != zext[i])
+ abort ();
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/lto-tbaa-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/lto-tbaa-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/lto-tbaa-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/lto-tbaa-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,42 @@
+/* { dg-additional-options "-fno-early-inlining -fno-ipa-cp" } */
+struct a {
+ float *b;
+} *a;
+struct b {
+ int *b;
+} b;
+struct c {
+ float *b;
+} *c;
+int d;
+use_a (struct a *a)
+{
+}
+set_b (int **a)
+{
+ *a=&d;
+}
+use_c (struct c *a)
+{
+}
+__attribute__ ((noinline)) int **retme(int **val)
+{
+ return val;
+}
+int e;
+struct b b= {&e};
+struct b b2;
+struct b b3;
+int **ptr = &b2.b;
+main ()
+{
+ a= (void *)0;
+ b.b=&e;
+ ptr =retme ( &b.b);
+ set_b (ptr);
+ b3=b;
+ if (b3.b != &d)
+ __builtin_abort ();
+ c= (void *)0;
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* Tests that the may_alias attribute works as expected.
+ Author: Osku Salerma <osku at iki.fi> Apr 2002. */
+
+extern void abort(void);
+extern void exit(int);
+
+typedef short __attribute__((__may_alias__)) short_a;
+
+int
+main (void)
+{
+ int a = 0x12345678;
+ short_a *b = (short_a*) &a;
+
+ b[1] = 0;
+
+ if (a == 0x12345678)
+ abort();
+
+ exit(0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+typedef struct __attribute__((__may_alias__)) { short x; } test;
+
+int f() {
+ int a=10;
+ test *p=(test *)&a;
+ p->x = 1;
+ return a;
+}
+
+int main() {
+ if (f() == 10)
+ __builtin_abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mayalias-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+typedef struct __attribute__((__may_alias__)) { short x; } test;
+
+test *p;
+
+int g(int *a)
+{
+ p = (test*)a;
+}
+
+int f()
+{
+ int a;
+ g(&a);
+ a = 10;
+ test s={1};
+ *p=s;
+ return a;
+}
+
+int main() {
+ if (f() == 10)
+ __builtin_abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/medce-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/medce-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/medce-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/medce-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+
+extern void abort (void);
+extern void link_error (void);
+
+static int ok = 0;
+
+void bar (void)
+{
+ ok = 1;
+}
+
+void foo(int x)
+{
+ switch (x)
+ {
+ case 0:
+ if (0)
+ {
+ link_error();
+ case 1:
+ bar();
+ }
+ }
+}
+
+int main()
+{
+ foo (1);
+ if (!ok)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memchr-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memchr-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memchr-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memchr-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,207 @@
+/* PR tree-optimization/86711 - wrong folding of memchr
+
+ Verify that memchr() of arrays initialized with string literals
+ where the nul doesn't fit in the array doesn't find the nul. */
+typedef __SIZE_TYPE__ size_t;
+typedef __WCHAR_TYPE__ wchar_t;
+
+extern void* memchr (const void*, int, size_t);
+
+#define A(expr) \
+ ((expr) \
+ ? (void)0 \
+ : (__builtin_printf ("assertion failed on line %i: %s\n", \
+ __LINE__, #expr), \
+ __builtin_abort ()))
+
+static const char c = '1';
+static const char s1[1] = "1";
+static const char s4[4] = "1234";
+
+static const char s4_2[2][4] = { "1234", "5678" };
+static const char s5_3[3][5] = { "12345", "6789", "01234" };
+
+volatile int v0 = 0;
+volatile int v1 = 1;
+volatile int v2 = 2;
+volatile int v3 = 3;
+volatile int v4 = 3;
+
+void test_narrow (void)
+{
+ int i0 = 0;
+ int i1 = i0 + 1;
+ int i2 = i1 + 1;
+ int i3 = i2 + 1;
+ int i4 = i3 + 1;
+
+ A (memchr ("" + 1, 0, 0) == 0);
+
+ A (memchr (&c, 0, sizeof c) == 0);
+ A (memchr (&c + 1, 0, sizeof c - 1) == 0);
+ A (memchr (&c + i1, 0, sizeof c - i1) == 0);
+ A (memchr (&c + v1, 0, sizeof c - v1) == 0);
+
+ A (memchr (s1, 0, sizeof s1) == 0);
+ A (memchr (s1 + 1, 0, sizeof s1 - 1) == 0);
+ A (memchr (s1 + i1, 0, sizeof s1 - i1) == 0);
+ A (memchr (s1 + v1, 0, sizeof s1 - v1) == 0);
+
+ A (memchr (&s1, 0, sizeof s1) == 0);
+ A (memchr (&s1 + 1, 0, sizeof s1 - 1) == 0);
+ A (memchr (&s1 + i1, 0, sizeof s1 - i1) == 0);
+ A (memchr (&s1 + v1, 0, sizeof s1 - v1) == 0);
+
+ A (memchr (&s1[0], 0, sizeof s1) == 0);
+ A (memchr (&s1[0] + 1, 0, sizeof s1 - 1) == 0);
+ A (memchr (&s1[0] + i1, 0, sizeof s1 - i1) == 0);
+ A (memchr (&s1[0] + v1, 0, sizeof s1 - v1) == 0);
+
+ A (memchr (&s1[i0], 0, sizeof s1) == 0);
+ A (memchr (&s1[i0] + 1, 0, sizeof s1 - 1) == 0);
+ A (memchr (&s1[i0] + i1, 0, sizeof s1 - i1) == 0);
+ A (memchr (&s1[i0] + v1, 0, sizeof s1 - v1) == 0);
+
+ A (memchr (&s1[v0], 0, sizeof s1) == 0);
+ A (memchr (&s1[v0] + 1, 0, sizeof s1 - 1) == 0);
+ A (memchr (&s1[v0] + i1, 0, sizeof s1 - i1) == 0);
+ A (memchr (&s1[v0] + v1, 0, sizeof s1 - v1) == 0);
+
+
+ A (memchr (s4 + i0, 0, sizeof s4 - i0) == 0);
+ A (memchr (s4 + i1, 0, sizeof s4 - i1) == 0);
+ A (memchr (s4 + i2, 0, sizeof s4 - i2) == 0);
+ A (memchr (s4 + i3, 0, sizeof s4 - i3) == 0);
+ A (memchr (s4 + i4, 0, sizeof s4 - i4) == 0);
+
+ A (memchr (s4 + v0, 0, sizeof s4 - v0) == 0);
+ A (memchr (s4 + v1, 0, sizeof s4 - v1) == 0);
+ A (memchr (s4 + v2, 0, sizeof s4 - v2) == 0);
+ A (memchr (s4 + v3, 0, sizeof s4 - v3) == 0);
+ A (memchr (s4 + v4, 0, sizeof s4 - v4) == 0);
+
+
+ A (memchr (s4_2, 0, sizeof s4_2) == 0);
+
+ A (memchr (s4_2[0], 0, sizeof s4_2[0]) == 0);
+ A (memchr (s4_2[1], 0, sizeof s4_2[1]) == 0);
+
+ A (memchr (s4_2[0] + 1, 0, sizeof s4_2[0] - 1) == 0);
+ A (memchr (s4_2[1] + 2, 0, sizeof s4_2[1] - 2) == 0);
+ A (memchr (s4_2[1] + 3, 0, sizeof s4_2[1] - 3) == 0);
+
+ A (memchr (s4_2[v0], 0, sizeof s4_2[v0]) == 0);
+ A (memchr (s4_2[v0] + 1, 0, sizeof s4_2[v0] - 1) == 0);
+
+
+ /* The following calls must find the nul. */
+ A (memchr ("", 0, 1) != 0);
+ A (memchr (s5_3, 0, sizeof s5_3) == &s5_3[1][4]);
+
+ A (memchr (&s5_3[0][0] + i0, 0, sizeof s5_3 - i0) == &s5_3[1][4]);
+ A (memchr (&s5_3[0][0] + i1, 0, sizeof s5_3 - i1) == &s5_3[1][4]);
+ A (memchr (&s5_3[0][0] + i2, 0, sizeof s5_3 - i2) == &s5_3[1][4]);
+ A (memchr (&s5_3[0][0] + i4, 0, sizeof s5_3 - i4) == &s5_3[1][4]);
+
+ A (memchr (&s5_3[1][i0], 0, sizeof s5_3[1] - i0) == &s5_3[1][4]);
+}
+
+#if 4 == __WCHAR_WIDTH__
+
+static const wchar_t wc = L'1';
+static const wchar_t ws1[] = L"1";
+static const wchar_t ws4[] = L"\x00123456\x12005678\x12340078\x12345600";
+
+void test_wide (void)
+{
+ int i0 = 0;
+ int i1 = i0 + 1;
+ int i2 = i1 + 1;
+ int i3 = i2 + 1;
+ int i4 = i3 + 1;
+
+ A (memchr (L"" + 1, 0, 0) == 0);
+ A (memchr (&wc + 1, 0, 0) == 0);
+ A (memchr (L"\x12345678", 0, sizeof (wchar_t)) == 0);
+
+ const size_t nb = sizeof ws4;
+ const size_t nwb = sizeof (wchar_t);
+
+ const char *pws1 = (const char*)ws1;
+ const char *pws4 = (const char*)ws4;
+
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ A (memchr (ws1, 0, sizeof ws1) == pws1 + 1);
+
+ A (memchr (&ws4[0], 0, nb) == pws4 + 3);
+ A (memchr (&ws4[1], 0, nb - 1 * nwb) == pws4 + 1 * nwb + 2);
+ A (memchr (&ws4[2], 0, nb - 2 * nwb) == pws4 + 2 * nwb + 1);
+ A (memchr (&ws4[3], 0, nb - 3 * nwb) == pws4 + 3 * nwb + 0);
+#else
+ A (memchr (ws1, 0, sizeof ws1) == pws1 + 0);
+
+ A (memchr (&ws4[0], 0, nb) == pws4 + 0);
+ A (memchr (&ws4[1], 0, nb - 1 * nwb) == pws4 + 1 * nwb + 1);
+ A (memchr (&ws4[2], 0, nb - 2 * nwb) == pws4 + 2 * nwb + 2);
+ A (memchr (&ws4[3], 0, nb - 3 * nwb) == pws4 + 3 * nwb + 3);
+#endif
+}
+
+#elif 2 == __WCHAR_WIDTH__
+
+static const wchar_t wc = L'1';
+static const wchar_t ws1[] = L"1";
+static const wchar_t ws2[2] = L"\x1234\x5678"; /* no terminating nul */
+static const wchar_t ws4[] = L"\x0012\x1200\x1234";
+
+void test_wide (void)
+{
+ int i0 = 0;
+ int i1 = i0 + 1;
+ int i2 = i1 + 1;
+
+ A (sizeof (wchar_t) == 2);
+
+ A (memchr (L"" + 1, 0, 0) == 0);
+ A (memchr (&wc + 1, 0, 0) == 0);
+ A (memchr (L"\x1234", 0, sizeof (wchar_t)) == 0);
+
+ A (memchr (L"" + i1, i0, i0) == 0);
+ A (memchr (&wc + i1, i0, i0) == 0);
+ A (memchr (L"\x1234", i0, sizeof (wchar_t)) == 0);
+
+ A (memchr (ws2, 0, sizeof ws2) == 0);
+ A (memchr (ws2, i0, sizeof ws2) == 0);
+
+ const size_t nb = sizeof ws4;
+ const size_t nwb = sizeof (wchar_t);
+
+ const char *pws1 = (const char*)ws1;
+ const char *pws4 = (const char*)ws4;
+
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ A (memchr (ws1, i0, sizeof ws1) == pws1 + 1);
+
+ A (memchr (&ws4[0], i0, nb) == pws4 + i1);
+ A (memchr (&ws4[1], i0, nb - i1 * nwb) == pws4 + i1 * nwb);
+ A (memchr (&ws4[2], i0, nb - i2 * nwb) == pws4 + i2 * nwb + i2);
+#else
+ A (memchr (ws1, i0, sizeof ws1) == pws1 + 0);
+
+ A (memchr (&ws4[0], i0, nb) == pws4 + 0);
+ A (memchr (&ws4[1], i0, nb - i1 * nwb) == pws4 + i1 * nwb + i1);
+ A (memchr (&ws4[2], i0, nb - i2 * nwb) == pws4 + i2 * nwb + i2);
+#endif
+}
+
+#else
+
+void test_wide (void) { }
+
+#endif
+
+int main ()
+{
+ test_narrow ();
+ test_wide ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memcpy-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memcpy-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memcpy-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memcpy-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,65 @@
+/* { dg-add-options stack_size } */
+
+#include <string.h>
+
+#if defined (STACK_SIZE)
+#define MEMCPY_SIZE (STACK_SIZE / 3)
+#else
+#define MEMCPY_SIZE (1 << 17)
+#endif
+
+
+void *copy (void *o, const void *i, unsigned l)
+{
+ return memcpy (o, i, l);
+}
+
+main ()
+{
+ unsigned i;
+ unsigned char src[MEMCPY_SIZE];
+ unsigned char dst[MEMCPY_SIZE];
+
+ for (i = 0; i < MEMCPY_SIZE; i++)
+ src[i] = (unsigned char) i, dst[i] = 0;
+
+ (void) memcpy (dst, src, MEMCPY_SIZE / 128);
+
+ for (i = 0; i < MEMCPY_SIZE / 128; i++)
+ if (dst[i] != (unsigned char) i)
+ abort ();
+
+ (void) memset (dst, 1, MEMCPY_SIZE / 128);
+
+ for (i = 0; i < MEMCPY_SIZE / 128; i++)
+ if (dst[i] != 1)
+ abort ();
+
+ (void) memcpy (dst, src, MEMCPY_SIZE);
+
+ for (i = 0; i < MEMCPY_SIZE; i++)
+ if (dst[i] != (unsigned char) i)
+ abort ();
+
+ (void) memset (dst, 0, MEMCPY_SIZE);
+
+ for (i = 0; i < MEMCPY_SIZE; i++)
+ if (dst[i] != 0)
+ abort ();
+
+ (void) copy (dst, src, MEMCPY_SIZE / 128);
+
+ for (i = 0; i < MEMCPY_SIZE / 128; i++)
+ if (dst[i] != (unsigned char) i)
+ abort ();
+
+ (void) memset (dst, 0, MEMCPY_SIZE);
+
+ (void) copy (dst, src, MEMCPY_SIZE);
+
+ for (i = 0; i < MEMCPY_SIZE; i++)
+ if (dst[i] != (unsigned char) i)
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memcpy-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memcpy-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memcpy-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memcpy-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,75 @@
+/* Copyright (C) 2002 Free Software Foundation.
+
+ Test memcpy 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>
+
+#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 + 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;
+ }
+
+ p = memcpy (u1.buf + off1, u2.buf + off2, len);
+ 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 ();
+ }
+
+ 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/memcpy-bi.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memcpy-bi.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memcpy-bi.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memcpy-bi.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,53 @@
+/* Test builtin-memcpy (which may emit different code for different N). */
+#include <string.h>
+
+#define TESTSIZE 80
+
+char src[TESTSIZE] __attribute__ ((aligned));
+char dst[TESTSIZE] __attribute__ ((aligned));
+
+void
+check (char *test, char *match, int n)
+{
+ if (memcmp (test, match, n))
+ abort ();
+}
+
+#define TN(n) \
+{ memset (dst, 0, n); memcpy (dst, src, n); check (dst, src, n); }
+#define T(n) \
+TN (n) \
+TN ((n) + 1) \
+TN ((n) + 2) \
+TN ((n) + 3)
+
+main ()
+{
+ int i,j;
+
+ for (i = 0; i < sizeof (src); ++i)
+ src[i] = 'a' + i % 26;
+
+ T (0);
+ T (4);
+ T (8);
+ T (12);
+ T (16);
+ T (20);
+ T (24);
+ T (28);
+ T (32);
+ T (36);
+ T (40);
+ T (44);
+ T (48);
+ T (52);
+ T (56);
+ T (60);
+ T (64);
+ T (68);
+ T (72);
+ T (76);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,96 @@
+/* Copyright (C) 2002 Free Software Foundation.
+
+ Test memset 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>
+
+#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 + MAX_EXTRA)
+
+static union {
+ char buf[MAX_LENGTH];
+ long long align_int;
+ long double align_fp;
+} u;
+
+char A = 'A';
+
+main ()
+{
+ int off, len, i;
+ char *p, *q;
+
+ for (off = 0; off < MAX_OFFSET; off++)
+ for (len = 1; len < MAX_COPY; len++)
+ {
+ for (i = 0; i < MAX_LENGTH; i++)
+ u.buf[i] = 'a';
+
+ p = memset (u.buf + off, '\0', len);
+ if (p != u.buf + off)
+ abort ();
+
+ q = u.buf;
+ for (i = 0; i < off; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ for (i = 0; i < len; i++, q++)
+ if (*q != '\0')
+ abort ();
+
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ p = memset (u.buf + off, A, len);
+ if (p != u.buf + off)
+ abort ();
+
+ q = u.buf;
+ for (i = 0; i < off; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ for (i = 0; i < len; i++, q++)
+ if (*q != 'A')
+ abort ();
+
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ p = memset (u.buf + off, 'B', len);
+ if (p != u.buf + off)
+ abort ();
+
+ q = u.buf;
+ for (i = 0; i < off; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ for (i = 0; i < len; i++, q++)
+ if (*q != 'B')
+ 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/memset-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,333 @@
+/* Copyright (C) 2002 Free Software Foundation.
+
+ Test memset with various combinations of pointer alignments and constant
+ lengths to make sure any optimizations in the compiler are correct.
+
+ Written by Roger Sayle, April 22, 2002. */
+
+#ifndef MAX_OFFSET
+#define MAX_OFFSET (sizeof (long long))
+#endif
+
+#ifndef MAX_COPY
+#define MAX_COPY 15
+#endif
+
+#ifndef MAX_EXTRA
+#define MAX_EXTRA (sizeof (long long))
+#endif
+
+#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)
+
+static union {
+ char buf[MAX_LENGTH];
+ long long align_int;
+ long double align_fp;
+} u;
+
+char A = 'A';
+
+void reset ()
+{
+ int i;
+
+ for (i = 0; i < MAX_LENGTH; i++)
+ u.buf[i] = 'a';
+}
+
+void check (int off, int len, int ch)
+{
+ char *q;
+ int i;
+
+ q = u.buf;
+ for (i = 0; i < off; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ for (i = 0; i < len; i++, q++)
+ if (*q != ch)
+ abort ();
+
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+}
+
+int main ()
+{
+ int off;
+ char *p;
+
+ /* len == 1 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 1);
+ if (p != u.buf + off) abort ();
+ check (off, 1, '\0');
+
+ p = memset (u.buf + off, A, 1);
+ if (p != u.buf + off) abort ();
+ check (off, 1, 'A');
+
+ p = memset (u.buf + off, 'B', 1);
+ if (p != u.buf + off) abort ();
+ check (off, 1, 'B');
+ }
+
+ /* len == 2 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 2);
+ if (p != u.buf + off) abort ();
+ check (off, 2, '\0');
+
+ p = memset (u.buf + off, A, 2);
+ if (p != u.buf + off) abort ();
+ check (off, 2, 'A');
+
+ p = memset (u.buf + off, 'B', 2);
+ if (p != u.buf + off) abort ();
+ check (off, 2, 'B');
+ }
+
+ /* len == 3 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 3);
+ if (p != u.buf + off) abort ();
+ check (off, 3, '\0');
+
+ p = memset (u.buf + off, A, 3);
+ if (p != u.buf + off) abort ();
+ check (off, 3, 'A');
+
+ p = memset (u.buf + off, 'B', 3);
+ if (p != u.buf + off) abort ();
+ check (off, 3, 'B');
+ }
+
+ /* len == 4 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 4);
+ if (p != u.buf + off) abort ();
+ check (off, 4, '\0');
+
+ p = memset (u.buf + off, A, 4);
+ if (p != u.buf + off) abort ();
+ check (off, 4, 'A');
+
+ p = memset (u.buf + off, 'B', 4);
+ if (p != u.buf + off) abort ();
+ check (off, 4, 'B');
+ }
+
+ /* len == 5 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 5);
+ if (p != u.buf + off) abort ();
+ check (off, 5, '\0');
+
+ p = memset (u.buf + off, A, 5);
+ if (p != u.buf + off) abort ();
+ check (off, 5, 'A');
+
+ p = memset (u.buf + off, 'B', 5);
+ if (p != u.buf + off) abort ();
+ check (off, 5, 'B');
+ }
+
+ /* len == 6 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 6);
+ if (p != u.buf + off) abort ();
+ check (off, 6, '\0');
+
+ p = memset (u.buf + off, A, 6);
+ if (p != u.buf + off) abort ();
+ check (off, 6, 'A');
+
+ p = memset (u.buf + off, 'B', 6);
+ if (p != u.buf + off) abort ();
+ check (off, 6, 'B');
+ }
+
+ /* len == 7 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 7);
+ if (p != u.buf + off) abort ();
+ check (off, 7, '\0');
+
+ p = memset (u.buf + off, A, 7);
+ if (p != u.buf + off) abort ();
+ check (off, 7, 'A');
+
+ p = memset (u.buf + off, 'B', 7);
+ if (p != u.buf + off) abort ();
+ check (off, 7, 'B');
+ }
+
+ /* len == 8 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 8);
+ if (p != u.buf + off) abort ();
+ check (off, 8, '\0');
+
+ p = memset (u.buf + off, A, 8);
+ if (p != u.buf + off) abort ();
+ check (off, 8, 'A');
+
+ p = memset (u.buf + off, 'B', 8);
+ if (p != u.buf + off) abort ();
+ check (off, 8, 'B');
+ }
+
+ /* len == 9 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 9);
+ if (p != u.buf + off) abort ();
+ check (off, 9, '\0');
+
+ p = memset (u.buf + off, A, 9);
+ if (p != u.buf + off) abort ();
+ check (off, 9, 'A');
+
+ p = memset (u.buf + off, 'B', 9);
+ if (p != u.buf + off) abort ();
+ check (off, 9, 'B');
+ }
+
+ /* len == 10 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 10);
+ if (p != u.buf + off) abort ();
+ check (off, 10, '\0');
+
+ p = memset (u.buf + off, A, 10);
+ if (p != u.buf + off) abort ();
+ check (off, 10, 'A');
+
+ p = memset (u.buf + off, 'B', 10);
+ if (p != u.buf + off) abort ();
+ check (off, 10, 'B');
+ }
+
+ /* len == 11 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 11);
+ if (p != u.buf + off) abort ();
+ check (off, 11, '\0');
+
+ p = memset (u.buf + off, A, 11);
+ if (p != u.buf + off) abort ();
+ check (off, 11, 'A');
+
+ p = memset (u.buf + off, 'B', 11);
+ if (p != u.buf + off) abort ();
+ check (off, 11, 'B');
+ }
+
+ /* len == 12 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 12);
+ if (p != u.buf + off) abort ();
+ check (off, 12, '\0');
+
+ p = memset (u.buf + off, A, 12);
+ if (p != u.buf + off) abort ();
+ check (off, 12, 'A');
+
+ p = memset (u.buf + off, 'B', 12);
+ if (p != u.buf + off) abort ();
+ check (off, 12, 'B');
+ }
+
+ /* len == 13 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 13);
+ if (p != u.buf + off) abort ();
+ check (off, 13, '\0');
+
+ p = memset (u.buf + off, A, 13);
+ if (p != u.buf + off) abort ();
+ check (off, 13, 'A');
+
+ p = memset (u.buf + off, 'B', 13);
+ if (p != u.buf + off) abort ();
+ check (off, 13, 'B');
+ }
+
+ /* len == 14 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 14);
+ if (p != u.buf + off) abort ();
+ check (off, 14, '\0');
+
+ p = memset (u.buf + off, A, 14);
+ if (p != u.buf + off) abort ();
+ check (off, 14, 'A');
+
+ p = memset (u.buf + off, 'B', 14);
+ if (p != u.buf + off) abort ();
+ check (off, 14, 'B');
+ }
+
+ /* len == 15 */
+ for (off = 0; off < MAX_OFFSET; off++)
+ {
+ reset ();
+
+ p = memset (u.buf + off, '\0', 15);
+ if (p != u.buf + off) abort ();
+ check (off, 15, '\0');
+
+ p = memset (u.buf + off, A, 15);
+ if (p != u.buf + off) abort ();
+ check (off, 15, 'A');
+
+ p = memset (u.buf + off, 'B', 15);
+ if (p != u.buf + off) abort ();
+ check (off, 15, 'B');
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,207 @@
+/* Copyright (C) 2002 Free Software Foundation.
+
+ Test memset with various combinations of constant pointer alignments and
+ lengths to make sure any optimizations in the compiler are correct.
+
+ Written by Roger Sayle, July 22, 2002. */
+
+#ifndef MAX_OFFSET
+#define MAX_OFFSET (sizeof (long long))
+#endif
+
+#ifndef MAX_COPY
+#define MAX_COPY 15
+#endif
+
+#ifndef MAX_EXTRA
+#define MAX_EXTRA (sizeof (long long))
+#endif
+
+#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)
+
+static union {
+ char buf[MAX_LENGTH];
+ long long align_int;
+ long double align_fp;
+} u;
+
+char A = 'A';
+
+void reset ()
+{
+ int i;
+
+ for (i = 0; i < MAX_LENGTH; i++)
+ u.buf[i] = 'a';
+}
+
+void check (int off, int len, int ch)
+{
+ char *q;
+ int i;
+
+ q = u.buf;
+ for (i = 0; i < off; i++, q++)
+ if (*q != 'a')
+ abort ();
+
+ for (i = 0; i < len; i++, q++)
+ if (*q != ch)
+ abort ();
+
+ for (i = 0; i < MAX_EXTRA; i++, q++)
+ if (*q != 'a')
+ abort ();
+}
+
+int main ()
+{
+ int len;
+ char *p;
+
+ /* off == 0 */
+ for (len = 0; len < MAX_COPY; len++)
+ {
+ reset ();
+
+ p = memset (u.buf, '\0', len);
+ if (p != u.buf) abort ();
+ check (0, len, '\0');
+
+ p = memset (u.buf, A, len);
+ if (p != u.buf) abort ();
+ check (0, len, 'A');
+
+ p = memset (u.buf, 'B', len);
+ if (p != u.buf) abort ();
+ check (0, len, 'B');
+ }
+
+ /* off == 1 */
+ for (len = 0; len < MAX_COPY; len++)
+ {
+ reset ();
+
+ p = memset (u.buf+1, '\0', len);
+ if (p != u.buf+1) abort ();
+ check (1, len, '\0');
+
+ p = memset (u.buf+1, A, len);
+ if (p != u.buf+1) abort ();
+ check (1, len, 'A');
+
+ p = memset (u.buf+1, 'B', len);
+ if (p != u.buf+1) abort ();
+ check (1, len, 'B');
+ }
+
+ /* off == 2 */
+ for (len = 0; len < MAX_COPY; len++)
+ {
+ reset ();
+
+ p = memset (u.buf+2, '\0', len);
+ if (p != u.buf+2) abort ();
+ check (2, len, '\0');
+
+ p = memset (u.buf+2, A, len);
+ if (p != u.buf+2) abort ();
+ check (2, len, 'A');
+
+ p = memset (u.buf+2, 'B', len);
+ if (p != u.buf+2) abort ();
+ check (2, len, 'B');
+ }
+
+ /* off == 3 */
+ for (len = 0; len < MAX_COPY; len++)
+ {
+ reset ();
+
+ p = memset (u.buf+3, '\0', len);
+ if (p != u.buf+3) abort ();
+ check (3, len, '\0');
+
+ p = memset (u.buf+3, A, len);
+ if (p != u.buf+3) abort ();
+ check (3, len, 'A');
+
+ p = memset (u.buf+3, 'B', len);
+ if (p != u.buf+3) abort ();
+ check (3, len, 'B');
+ }
+
+ /* off == 4 */
+ for (len = 0; len < MAX_COPY; len++)
+ {
+ reset ();
+
+ p = memset (u.buf+4, '\0', len);
+ if (p != u.buf+4) abort ();
+ check (4, len, '\0');
+
+ p = memset (u.buf+4, A, len);
+ if (p != u.buf+4) abort ();
+ check (4, len, 'A');
+
+ p = memset (u.buf+4, 'B', len);
+ if (p != u.buf+4) abort ();
+ check (4, len, 'B');
+ }
+
+ /* off == 5 */
+ for (len = 0; len < MAX_COPY; len++)
+ {
+ reset ();
+
+ p = memset (u.buf+5, '\0', len);
+ if (p != u.buf+5) abort ();
+ check (5, len, '\0');
+
+ p = memset (u.buf+5, A, len);
+ if (p != u.buf+5) abort ();
+ check (5, len, 'A');
+
+ p = memset (u.buf+5, 'B', len);
+ if (p != u.buf+5) abort ();
+ check (5, len, 'B');
+ }
+
+ /* off == 6 */
+ for (len = 0; len < MAX_COPY; len++)
+ {
+ reset ();
+
+ p = memset (u.buf+6, '\0', len);
+ if (p != u.buf+6) abort ();
+ check (6, len, '\0');
+
+ p = memset (u.buf+6, A, len);
+ if (p != u.buf+6) abort ();
+ check (6, len, 'A');
+
+ p = memset (u.buf+6, 'B', len);
+ if (p != u.buf+6) abort ();
+ check (6, len, 'B');
+ }
+
+ /* off == 7 */
+ for (len = 0; len < MAX_COPY; len++)
+ {
+ reset ();
+
+ p = memset (u.buf+7, '\0', len);
+ if (p != u.buf+7) abort ();
+ check (7, len, '\0');
+
+ p = memset (u.buf+7, A, len);
+ if (p != u.buf+7) abort ();
+ check (7, len, 'A');
+
+ p = memset (u.buf+7, 'B', len);
+ if (p != u.buf+7) abort ();
+ check (7, len, 'B');
+ }
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/memset-4.c Wed Oct 9 04:01:46 2019
@@ -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;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mod-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mod-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mod-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mod-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,11 @@
+f (x, y)
+{
+ if (x % y != 0)
+ abort ();
+}
+
+main ()
+{
+ f (-5, 5);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mode-dependent-address.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mode-dependent-address.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mode-dependent-address.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/mode-dependent-address.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,51 @@
+/* { dg-require-effective-target stdint_types } */
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+void f883b (int8_t * result,
+ int16_t * __restrict arg1,
+ uint32_t * __restrict arg2,
+ uint64_t * __restrict arg3,
+ uint8_t * __restrict arg4)
+{
+ int idx;
+ for (idx=0;idx<96;idx += 1) {
+ result[idx] = (((((((((((-27 + 2+1)>>1) || arg4[idx]) < arg1[idx])
+ ? (((-27 + 2+1)>>1) || arg4[idx])
+ : arg1[idx])
+ >> (arg2[idx] & 31)) ^ 1) - -32)>>7) | -5) & arg3[idx]);
+ }
+}
+
+int8_t result[96];
+int16_t arg1[96];
+uint32_t arg2[96];
+uint64_t arg3[96];
+uint8_t arg4[96];
+
+int main (void)
+{
+ int i;
+ int correct[] = {0x0,0x1,0x2,0x3,0x0,0x1,0x2,0x3,0x8,0x9,0xa,0xb,0x8,0x9,
+ 0xa,0xb,0x10,0x11,0x12,0x13,0x10,0x11,0x12,0x13,
+ 0x18,0x19,0x1a,0x1b,0x18,0x19,0x1a,0x1b,0x20,0x21,0x22,
+ 0x23,0x20,0x21,0x22,0x23,0x28,0x29,0x2a,
+ 0x2b,0x28,0x29,0x2a,0x2b,0x30,0x31,0x32,0x33,
+ 0x30,0x31,0x32,0x33,0x38,0x39,0x3a,0x3b,0x38,0x39,0x3a,
+ 0x3b,0x40,0x41,0x42,0x43,0x40,0x41,0x42,0x43,0x48,0x49,
+ 0x4a,0x4b,0x48,0x49,0x4a,0x4b,0x50,0x51,
+ 0x52,0x53,0x50,0x51,0x52,0x53,0x58,0x59,0x5a,0x5b,
+ 0x58,0x59,0x5a,0x5b};
+
+ for (i=0; i < 96; i++)
+ arg3[i] = arg2[i] = arg1[i] = arg4[i] = i;
+
+ f883b(result, arg1, arg2, arg3, arg4);
+
+ for (i=0; i < 96; i++)
+ if (result[i] != correct[i]) abort();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/multdi-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/multdi-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/multdi-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/multdi-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* PR target/9348 */
+
+#define u_l_l unsigned long long
+#define l_l long long
+
+l_l mpy_res;
+
+u_l_l mpy (long a, long b)
+{
+ return (u_l_l) a * (u_l_l) b;
+}
+
+int main(void)
+{
+ mpy_res = mpy(1,-1);
+ if (mpy_res != -1LL)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/multi-ix.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/multi-ix.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/multi-ix.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/multi-ix.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,205 @@
+/* { dg-add-options stack_size } */
+
+/* Test for a reload bug:
+ if you have a memory reference using the indexed addressing
+ mode, and the base address is a pseudo containing an address in the frame
+ and this pseudo fails to get a hard register, we end up with a double PLUS,
+ so the frame address gets reloaded. Now, when the index got a hard register,
+ and it dies in this insn, push_reload will consider that hard register as
+ a reload register, and disregrad overlaps with rld[n_reloads].in . That is
+ fine as long as the add can be done with a single insn, but when the
+ constant is so large that it has to be reloaded into a register first,
+ that clobbers the index. */
+
+#include <stdarg.h>
+
+#ifdef STACK_SIZE
+/* We need to be careful that we don't blow our stack. Function f, in the
+ worst case, needs to fit on the stack:
+
+ * 40 int[CHUNK] arrays;
+ * ~40 ints;
+ * ~40 pointers for stdarg passing.
+
+ Subtract the last two off STACK_SIZE and figure out what the maximum
+ chunk size can be. We make the last bit conservative to account for
+ register saves and other processor-dependent saving. Limit the
+ chunk size to some sane values. */
+
+#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
+#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
+
+#define CHUNK \
+ MIN (500, (MAX (1, (signed)(STACK_SIZE-40*sizeof(int)-256*sizeof(void *)) \
+ / (signed)(40*sizeof(int)))))
+#else
+#define CHUNK 500
+#endif
+
+void s(int, ...);
+void z(int, ...);
+void c(int, ...);
+
+typedef int l[CHUNK];
+
+void
+f (int n)
+{
+ int i;
+ l a0, a1, a2, a3, a4, a5, a6, a7, a8, a9;
+ l a10, a11, a12, a13, a14, a15, a16, a17, a18, a19;
+ l a20, a21, a22, a23, a24, a25, a26, a27, a28, a29;
+ l a30, a31, a32, a33, a34, a35, a36, a37, a38, a39;
+ int i0, i1, i2, i3, i4, i5, i6, i7, i8, i9;
+ int i10, i11, i12, i13, i14, i15, i16, i17, i18, i19;
+ int i20, i21, i22, i23, i24, i25, i26, i27, i28, i29;
+ int i30, i31, i32, i33, i34, i35, i36, i37, i38, i39;
+
+ for (i = 0; i < n; i++)
+ {
+ s (40, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
+ a20, a21, a22, a23, a24, a25, a26, a27, a28, a29,
+ a30, a31, a32, a33, a34, a35, a36, a37, a38, a39);
+ i0 = a0[0];
+ i1 = a1[0];
+ i2 = a2[0];
+ i3 = a3[0];
+ i4 = a4[0];
+ i5 = a5[0];
+ i6 = a6[0];
+ i7 = a7[0];
+ i8 = a8[0];
+ i9 = a9[0];
+ i10 = a10[0];
+ i11 = a11[0];
+ i12 = a12[0];
+ i13 = a13[0];
+ i14 = a14[0];
+ i15 = a15[0];
+ i16 = a16[0];
+ i17 = a17[0];
+ i18 = a18[0];
+ i19 = a19[0];
+ i20 = a20[0];
+ i21 = a21[0];
+ i22 = a22[0];
+ i23 = a23[0];
+ i24 = a24[0];
+ i25 = a25[0];
+ i26 = a26[0];
+ i27 = a27[0];
+ i28 = a28[0];
+ i29 = a29[0];
+ i30 = a30[0];
+ i31 = a31[0];
+ i32 = a32[0];
+ i33 = a33[0];
+ i34 = a34[0];
+ i35 = a35[0];
+ i36 = a36[0];
+ i37 = a37[0];
+ i38 = a38[0];
+ i39 = a39[0];
+ z (40, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
+ a20, a21, a22, a23, a24, a25, a26, a27, a28, a29,
+ a30, a31, a32, a33, a34, a35, a36, a37, a38, a39);
+ a0[i0] = i0;
+ a1[i1] = i1;
+ a2[i2] = i2;
+ a3[i3] = i3;
+ a4[i4] = i4;
+ a5[i5] = i5;
+ a6[i6] = i6;
+ a7[i7] = i7;
+ a8[i8] = i8;
+ a9[i9] = i9;
+ a10[i10] = i10;
+ a11[i11] = i11;
+ a12[i12] = i12;
+ a13[i13] = i13;
+ a14[i14] = i14;
+ a15[i15] = i15;
+ a16[i16] = i16;
+ a17[i17] = i17;
+ a18[i18] = i18;
+ a19[i19] = i19;
+ a20[i20] = i20;
+ a21[i21] = i21;
+ a22[i22] = i22;
+ a23[i23] = i23;
+ a24[i24] = i24;
+ a25[i25] = i25;
+ a26[i26] = i26;
+ a27[i27] = i27;
+ a28[i28] = i28;
+ a29[i29] = i29;
+ a30[i30] = i30;
+ a31[i31] = i31;
+ a32[i32] = i32;
+ a33[i33] = i33;
+ a34[i34] = i34;
+ a35[i35] = i35;
+ a36[i36] = i36;
+ a37[i37] = i37;
+ a38[i38] = i38;
+ a39[i39] = i39;
+ c (40, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
+ a20, a21, a22, a23, a24, a25, a26, a27, a28, a29,
+ a30, a31, a32, a33, a34, a35, a36, a37, a38, a39);
+ }
+}
+
+int
+main ()
+{
+ /* CHUNK needs to be at least 40 to avoid stack corruption,
+ since index variable i0 in "a[i0] = i0" equals 39. */
+ if (CHUNK < 40)
+ exit (0);
+
+ f (1);
+ exit (0);
+}
+
+void s(int n, ...)
+{
+ va_list list;
+
+ va_start (list, n);
+ while (n--)
+ {
+ int *a = va_arg (list, int *);
+ a[0] = n;
+ }
+ va_end (list);
+}
+
+void z(int n, ...)
+{
+ va_list list;
+
+ va_start (list, n);
+ while (n--)
+ {
+ int *a = va_arg (list, int *);
+ __builtin_memset (a, 0, sizeof (l));
+ }
+ va_end (list);
+}
+
+void c(int n, ...)
+{
+ va_list list;
+
+ va_start (list, n);
+ while (n--)
+ {
+ int *a = va_arg (list, int *);
+ if (a[n] != n)
+ abort ();
+ }
+ va_end (list);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nest-align-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nest-align-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nest-align-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nest-align-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,43 @@
+/* Test for alignment handling when a variable is accessed by nested
+ function. */
+/* Origin: Joey Ye <joey.ye at intel.com> */
+
+/* Force bigger stack alignment for PowerPC EABI targets. */
+/* { dg-options "-mno-eabi" { target powerpc-*-eabi* } } */
+
+#include <stddef.h>
+
+typedef int aligned __attribute__((aligned));
+extern void abort (void);
+
+void
+check (int *i)
+{
+ *i = 20;
+ if ((((ptrdiff_t) i) & (__alignof__(aligned) - 1)) != 0)
+ abort ();
+}
+
+void
+foo (void)
+{
+ aligned jj;
+ void bar ()
+ {
+ jj = -20;
+ }
+ jj = 0;
+ bar ();
+ if (jj != -20)
+ abort ();
+ check (&jj);
+ if (jj != 20)
+ abort ();
+}
+
+int
+main()
+{
+ foo ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nest-stdar-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nest-stdar-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nest-stdar-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nest-stdar-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+#include <stdarg.h>
+
+main ()
+{
+ double f (int x, ...)
+ {
+ va_list args;
+ double a;
+
+ va_start (args, x);
+ a = va_arg (args, double);
+ va_end (args);
+ return a;
+ }
+
+ if (f (1, (double)1) != 1.0)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* { dg-require-effective-target trampolines } */
+
+int
+g (int a, int b, int (*gi) (int, int))
+{
+ if ((*gi) (a, b))
+ return a;
+ else
+ return b;
+}
+
+f ()
+{
+ int i, j;
+ int f2 (int a, int b)
+ {
+ return a > b;
+ }
+
+ if (g (1, 2, f2) != 2)
+ abort ();
+}
+
+main ()
+{
+ f ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,49 @@
+/* { dg-require-effective-target trampolines } */
+
+extern int foo (int, int, int (*) (int, int, int, int, int, int, int));
+
+int z;
+
+int
+main (void)
+{
+ int sum = 0;
+ int i;
+
+ int nested (int a, int b, int c, int d, int e, int f, int g)
+ {
+ z = c + d + e + f + g;
+
+ if (a > 2 * b)
+ return a - b;
+ else
+ return b - a;
+ }
+
+ for (i = 0; i < 10; ++i)
+ {
+ int j;
+
+ for (j = 0; j < 10; ++j)
+ {
+ int k;
+
+ for (k = 0; k < 10; ++k)
+ sum += foo (i, j > k ? j - k : k - j, nested);
+ }
+ }
+
+ if (sum != 2300)
+ abort ();
+
+ if (z != 0x1b)
+ abort ();
+
+ exit (0);
+}
+
+int
+foo (int a, int b, int (* fp) (int, int, int, int, int, int, int))
+{
+ return fp (a, b, a, b, a, b, a);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,59 @@
+/* { dg-require-effective-target trampolines } */
+
+extern long foo (long, long, long (*) (long, long));
+extern long use (long (*) (long, long), long, long);
+
+int
+main (void)
+{
+ long sum = 0;
+ long i;
+
+ long nested_0 (long a, long b)
+ {
+ if (a > 2 * b)
+ return a - b;
+ else
+ return b - a;
+ }
+
+ long nested_1 (long a, long b)
+ {
+ return use (nested_0, b, a) + sum;
+ }
+
+ long nested_2 (long a, long b)
+ {
+ return nested_1 (b, a);
+ }
+
+ for (i = 0; i < 10; ++i)
+ {
+ long j;
+
+ for (j = 0; j < 10; ++j)
+ {
+ long k;
+
+ for (k = 0; k < 10; ++k)
+ sum += foo (i, j > k ? j - k : k - j, nested_2);
+ }
+ }
+
+ if ((sum & 0xffffffff) != 0xbecfcbf5)
+ abort ();
+
+ exit (0);
+}
+
+long
+use (long (* func)(long, long), long a, long b)
+{
+ return func (b, a);
+}
+
+long
+foo (long a, long b, long (* func) (long, long))
+{
+ return func (a, b);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,39 @@
+/* { dg-add-options stack_size } */
+
+/* Origin: hp at bitrange.com
+ Test that return values come out right from a 1000-level call chain to
+ functions without parameters that each need at least one "long"
+ preserved. Exposed problems related to the MMIX port. */
+
+long level = 0;
+extern long foo (void);
+extern long bar (void);
+
+#ifdef STACK_SIZE
+#define DEPTH ((STACK_SIZE) / 512 + 1)
+#else
+#define DEPTH 500
+#endif
+
+int
+main (void)
+{
+ if (foo () == -42)
+ exit (0);
+
+ abort ();
+}
+
+long
+foo (void)
+{
+ long tmp = ++level;
+ return bar () + tmp;
+}
+
+long
+bar (void)
+{
+ long tmp = level;
+ return tmp > DEPTH - 1 ? -42 - tmp : foo () - tmp;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-5.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-5.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-5.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-5.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,34 @@
+/* { dg-require-effective-target trampolines } */
+
+extern void abort (void);
+extern void exit (int);
+
+static void recursive (int n, void (*proc) (void))
+{
+ __label__ l1;
+
+ void do_goto (void)
+ {
+ goto l1;
+ }
+
+ if (n == 3)
+ recursive (n - 1, do_goto);
+ else if (n > 0)
+ recursive (n - 1, proc);
+ else
+ (*proc) ();
+ return;
+
+l1:
+ if (n == 3)
+ exit (0);
+ else
+ abort ();
+}
+
+int main ()
+{
+ recursive (10, abort);
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-6.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-6.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-6.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-6.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* { dg-require-effective-target trampolines } */
+
+/* Test that the GP gets properly restored, either by the nonlocal
+ receiver or the nested function. */
+
+typedef __SIZE_TYPE__ size_t;
+extern void abort (void);
+extern void exit (int);
+extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
+
+int main ()
+{
+ __label__ nonlocal;
+ int compare (const void *a, const void *b)
+ {
+ goto nonlocal;
+ }
+
+ char array[3];
+ qsort (array, 3, 1, compare);
+ abort ();
+
+ nonlocal:
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-7.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-7.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-7.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/nestfunc-7.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,43 @@
+struct A
+{
+ int one;
+ int two;
+ int three;
+ int four;
+ int five;
+ int six;
+};
+
+static int test (void)
+{
+ int base;
+
+ struct A Foo (void)
+ {
+ struct A a;
+
+ a.one = base + 1;
+ a.two = base + 2;
+ a.three = base + 3;
+ a.four = base + 4;
+ a.five = base + 5;
+ a.six = base + 6;
+
+ return a;
+ }
+
+ base = 10;
+ struct A a = Foo ();
+
+ return (a.one == 11
+ && a.two == 12
+ && a.three == 13
+ && a.four == 14
+ && a.five == 15
+ && a.six == 16);
+}
+
+int main (void)
+{
+ return !test ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/noinit-attribute.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/noinit-attribute.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/noinit-attribute.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/noinit-attribute.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,59 @@
+/* { dg-do run } */
+/* { dg-require-effective-target noinit } */
+/* { dg-options "-O2" } */
+
+/* This test checks that noinit data is handled correctly. */
+
+extern void _start (void) __attribute__ ((noreturn));
+extern void abort (void) __attribute__ ((noreturn));
+extern void exit (int) __attribute__ ((noreturn));
+
+int var_common;
+int var_zero = 0;
+int var_one = 1;
+int __attribute__((noinit)) var_noinit;
+int var_init = 2;
+
+int __attribute__((noinit)) func(); /* { dg-warning "attribute only applies to variables" } */
+int __attribute__((section ("mysection"), noinit)) var_section1; /* { dg-warning "because it conflicts with attribute" } */
+int __attribute__((noinit, section ("mysection"))) var_section2; /* { dg-warning "because it conflicts with attribute" } */
+
+
+int
+main (void)
+{
+ /* Make sure that the C startup code has correctly initialized the ordinary variables. */
+ if (var_common != 0)
+ abort ();
+
+ /* Initialized variables are not re-initialized during startup, so
+ check their original values only during the first run of this
+ test. */
+ if (var_init == 2)
+ if (var_zero != 0 || var_one != 1)
+ abort ();
+
+ switch (var_init)
+ {
+ case 2:
+ /* First time through - change all the values. */
+ var_common = var_zero = var_one = var_noinit = var_init = 3;
+ break;
+
+ case 3:
+ /* Second time through - make sure that d has not been reset. */
+ if (var_noinit != 3)
+ abort ();
+ exit (0);
+
+ default:
+ /* Any other value for var_init is an error. */
+ abort ();
+ }
+
+ /* Simulate a processor reset by calling the C startup code. */
+ _start ();
+
+ /* Should never reach here. */
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/p18298.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/p18298.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/p18298.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/p18298.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* { dg-options "-fgnu89-inline" } */
+
+#include <stdbool.h>
+#include <stdlib.h>
+extern void abort (void);
+int strcmp (const char*, const char*);
+char s[2048] = "a";
+inline bool foo(const char *str) {
+ return !strcmp(s,str);
+}
+int main() {
+int i = 0;
+ while(!(foo(""))) {
+ i ++;
+ s[0] = '\0';
+ if (i>2)
+ abort ();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/packed-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/packed-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/packed-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/packed-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+short x1 = 17;
+
+struct
+{
+ short i __attribute__ ((packed));
+} t;
+
+f ()
+{
+ t.i = x1;
+ if (t.i != 17)
+ abort ();
+}
+
+main ()
+{
+ f ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/packed-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/packed-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/packed-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/packed-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,12 @@
+typedef struct s {
+ unsigned short a;
+ unsigned long b __attribute__ ((packed));
+} s;
+
+s t;
+
+int main()
+{
+ t.b = 0;
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pending-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pending-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pending-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pending-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+
+void dummy (x, y)
+ int *x;
+ int y;
+{}
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int number_columns=9;
+ int cnt0 = 0;
+ int cnt1 = 0;
+ int i,A1;
+
+ for (i = number_columns-1; i != 0; i--)
+ {
+ if (i == 1)
+ {
+ dummy(&A1, i);
+ cnt0++;
+ }
+ else
+ {
+ dummy(&A1, i-1);
+ cnt1++;
+ }
+ }
+ if (cnt0 != 1 || cnt1 != 7)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/postmod-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/postmod-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/postmod-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/postmod-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,62 @@
+#define DECLARE_ARRAY(A) array##A[0x10]
+#define DECLARE_COUNTER(A) counter##A = 0
+#define DECLARE_POINTER(A) *pointer##A = array##A + x
+/* Create a loop that allows post-modification of pointerA, followed by
+ a use of the post-modified address. */
+#define BEFORE(A) counter##A += *pointer##A, pointer##A += 3
+#define AFTER(A) counter##A += pointer##A[x]
+
+/* Set up the arrays so that one iteration of the loop sets the counter
+ to 3.0f. */
+#define INIT_ARRAY(A) array##A[1] = 1.0f, array##A[5] = 2.0f
+
+/* Check that the loop worked correctly for all values. */
+#define CHECK_ARRAY(A) exit_code |= (counter##A != 3.0f)
+
+/* Having 6 copies triggered the bug for ARM and Thumb. */
+#define MANY(A) A (0), A (1), A (2), A (3), A (4), A (5)
+
+/* Each addendA should be allocated a register. */
+#define INIT_VOLATILE(A) addend##A = vol
+#define ADD_VOLATILE(A) vol += addend##A
+
+/* Having 5 copies triggered the bug for ARM and Thumb. */
+#define MANY2(A) A (0), A (1), A (2), A (3), A (4)
+
+float MANY (DECLARE_ARRAY);
+float MANY (DECLARE_COUNTER);
+
+volatile int stop = 1;
+volatile int vol;
+
+void __attribute__((noinline))
+foo (int x)
+{
+ float MANY (DECLARE_POINTER);
+ int i;
+
+ do
+ {
+ MANY (BEFORE);
+ MANY (AFTER);
+ /* Create an inner loop that should ensure the code above
+ has registers free for reload inheritance. */
+ {
+ int MANY2 (INIT_VOLATILE);
+ for (i = 0; i < 10; i++)
+ MANY2 (ADD_VOLATILE);
+ }
+ }
+ while (!stop);
+}
+
+int
+main (void)
+{
+ int exit_code = 0;
+
+ MANY (INIT_ARRAY);
+ foo (1);
+ MANY (CHECK_ARRAY);
+ return exit_code;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,47 @@
+/* PR 15262.
+ The alias analyzer only considers relations between pointers and
+ symbols. If two pointers P and Q point to the same symbol S, then
+ their respective memory tags will either be the same or they will
+ have S in their alias set.
+
+ However, if there are no common symbols between P and Q, TBAA will
+ currently miss their alias relationship altogether. */
+struct A
+{
+ int t;
+ int i;
+};
+
+int foo () { return 3; }
+
+main ()
+{
+ struct A loc, *locp;
+ float f, g, *p;
+ int T355, *T356;
+
+ /* Avoid the partial hack in TBAA that would consider memory tags if
+ the program had no addressable symbols. */
+ f = 3;
+ g = 2;
+ p = foo () ? &g : &f;
+ if (*p > 0.0)
+ g = 1;
+
+ /* Store into *locp and cache its current value. */
+ locp = malloc (sizeof (*locp));
+ locp->i = 10;
+ T355 = locp->i;
+
+ /* Take the address of one of locp's fields and write to it. */
+ T356 = &locp->i;
+ *T356 = 1;
+
+ /* Read the recently stored value. If TBAA fails, this will appear
+ as a redundant load that will be replaced with '10'. */
+ T355 = locp->i;
+ if (T355 != 1)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,37 @@
+/* PR 15262. Similar to pr15262-1.c but with no obvious addresses
+ being taken in function foo(). Without IPA, by only looking inside
+ foo() we cannot tell for certain whether 'q' and 'b' alias each
+ other. */
+struct A
+{
+ int t;
+ int i;
+};
+
+struct B
+{
+ int *p;
+ float b;
+};
+
+float X;
+
+foo (struct B b, struct A *q, float *h)
+{
+ X += *h;
+ *(b.p) = 3;
+ q->t = 2;
+ return *(b.p);
+}
+
+main()
+{
+ struct A a;
+ struct B b;
+
+ b.p = &a.t;
+ if (foo (b, &a, &X) == 3)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15262.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,47 @@
+/* We used to mis-compile this testcase as we did not know that
+ &a+offsetof(b,a) was the same as &a.b */
+struct A
+{
+ int t;
+ int i;
+};
+
+void
+bar (float *p)
+{
+ *p = 5.2;
+}
+
+int
+foo(struct A *locp, int i, int str)
+{
+ float f, g, *p;
+ int T355;
+ int *T356;
+ /* Currently, the alias analyzer has limited support for handling
+ aliases of structure fields when no other variables are aliased.
+ Introduce additional aliases to confuse it. */
+ p = i ? &g : &f;
+ bar (p);
+ if (*p > 0.0)
+ str = 1;
+
+ T355 = locp->i;
+ T356 = &locp->i;
+ *T356 = str;
+ T355 = locp->i;
+
+ return T355;
+}
+
+main ()
+{
+ struct A loc;
+ int str;
+
+ loc.i = 2;
+ str = foo (&loc, 10, 3);
+ if (str!=1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15296.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15296.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15296.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr15296.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,73 @@
+/* PR optimization/15296. The delayed-branch scheduler caused code that
+ SEGV:d for CRIS; a register was set to -1 in a delay-slot for the
+ fall-through code, while that register held a pointer used in code at
+ the branch target. */
+
+typedef __INTPTR_TYPE__ intptr_t;
+typedef intptr_t W;
+union u0
+{
+ union u0 *r;
+ W i;
+};
+struct s1
+{
+ union u0 **m0;
+ union u0 m1[4];
+};
+
+void f (void *, struct s1 *, const union u0 *, W, W, W)
+ __attribute__ ((__noinline__));
+void g (void *, char *) __attribute__ ((__noinline__));
+
+void
+f (void *a, struct s1 *b, const union u0 *h, W v0, W v1, W v4)
+{
+ union u0 *e = 0;
+ union u0 *k = 0;
+ union u0 **v5 = b->m0;
+ union u0 *c = b->m1;
+ union u0 **d = &v5[0];
+l0:;
+ if (v0 < v1)
+ goto l0;
+ if (v0 == 0)
+ goto l3;
+ v0 = v4;
+ if (v0 != 0)
+ goto l3;
+ c[0].r = *d;
+ v1 = -1;
+ e = c[0].r;
+ if (e != 0)
+ g (a, "");
+ k = e + 3;
+ k->i = v1;
+ goto l4;
+l3:;
+ c[0].i = v0;
+ e = c[1].r;
+ if (e != 0)
+ g (a, "");
+ e = c[0].r;
+ if (e == 0)
+ g (a, "");
+ k = e + 2;
+ k->r = c[1].r;
+l4:;
+}
+
+void g (void *a, char *b) { abort (); }
+
+int
+main ()
+{
+ union u0 uv[] = {{ .i = 111 }, { .i = 222 }, { .i = 333 }, { .i = 444 }};
+ struct s1 s = { 0, {{ .i = 555 }, { .i = 0 }, { .i = 999 }, { .i = 777 }}};
+ f (0, &s, 0, 20000, 10000, (W) uv);
+ if (s.m1[0].i != (W) uv || s.m1[1].i != 0 || s.m1[2].i != 999
+ || s.m1[3].i != 777 || uv[0].i != 111 || uv[1].i != 222
+ || uv[2].i != 0 || uv[3].i != 444)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr16790-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr16790-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr16790-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr16790-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,40 @@
+/* PR middle-end/16790. */
+
+extern void abort ();
+
+static void test1(unsigned int u1)
+{
+ unsigned int y_final_1;
+ signed short y_middle;
+ unsigned int y_final_2;
+
+ y_final_1 = (unsigned int)( (signed short)(u1 * 2) * 3 );
+ y_middle = (signed short)(u1 * 2);
+ y_final_2 = (unsigned int)( y_middle * 3 );
+
+ if (y_final_1 != y_final_2)
+ abort ();
+}
+
+
+static void test2(unsigned int u1)
+{
+ unsigned int y_final_1;
+ signed short y_middle;
+ unsigned int y_final_2;
+
+ y_final_1 = (unsigned int)( (signed short)(u1 << 1) * 3 );
+ y_middle = (signed short)(u1 << 1);
+ y_final_2 = (unsigned int)( y_middle * 3 );
+
+ if (y_final_1 != y_final_2)
+ abort ();
+}
+
+
+int main()
+{
+ test1(0x4000U);
+ test2(0x4000U);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17078-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17078-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17078-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17078-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+extern void abort(void);
+
+void test(int *ptr)
+{
+ int i = 1;
+ goto useless;
+ if (0)
+ {
+ useless:
+ i = 0;
+ }
+ else
+ i = 1;
+ *ptr = i;
+}
+
+int main()
+{
+ int i = 1;
+ test(&i);
+ if (i)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17133.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17133.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17133.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17133.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+extern void abort (void);
+
+int foo = 0;
+void *bar = 0;
+unsigned int baz = 100;
+
+void *pure_alloc ()
+{
+ void *res;
+
+ while (1)
+ {
+ res = (void *) ((((unsigned int) (foo + bar))) & ~1);
+ foo += 2;
+ if (foo < baz)
+ return res;
+ foo = 0;
+ }
+}
+
+int main ()
+{
+ pure_alloc ();
+ if (!foo)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17252.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17252.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17252.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17252.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR 17252. When a char * pointer P takes its own address, storing
+ into *P changes P itself. */
+
+char *a;
+
+main ()
+{
+ /* Make 'a' point to itself. */
+ a = (char *)&a;
+
+ /* Change what 'a' is pointing to. */
+ a[0]++;
+
+ /* If a's memory tag does not contain 'a' in its alias set, we will
+ think that this predicate is superfluous and change it to
+ 'if (1)'. */
+ if (a == (char *)&a)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17377.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17377.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17377.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr17377.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,60 @@
+/* PR target/17377
+ Bug in code emitted by "return" pattern on CRIS: missing pop of
+ forced return address on stack. */
+/* { dg-require-effective-target return_address } */
+int calls = 0;
+
+void *f (int) __attribute__ ((__noinline__));
+void *
+f (int i)
+{
+ /* The code does a little brittle song and dance to trig the "return"
+ pattern instead of the function epilogue. This must still be a
+ leaf function for the bug to be exposed. */
+
+ if (calls++ == 0)
+ return __builtin_return_address (0);
+
+ switch (i)
+ {
+ case 1:
+ return f;
+ case 0:
+ return __builtin_return_address (0);
+ }
+ return 0;
+}
+
+int x;
+
+void *y (int i) __attribute__ ((__noinline__,__noclone__));
+void *
+y (int i)
+{
+ x = 0;
+
+ /* This must not be a sibling call: the return address must appear
+ constant for different calls to this function. Postincrementing x
+ catches otherwise unidentified multiple returns (e.g. through the
+ return-address register and then this epilogue popping the address
+ stored on stack in "f"). */
+ return (char *) f (i) + x++;
+}
+
+int
+main (void)
+{
+ void *v = y (4);
+ if (y (1) != f
+ /* Can't reasonably check the validity of the return address
+ above, but it's not that important: the test-case will probably
+ crash on the first call to f with the bug present, or it will
+ run wild including returning early (in y or here), so we also
+ try and check the number of calls. */
+ || y (0) != v
+ || y (3) != 0
+ || y (-1) != 0
+ || calls != 5)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19005.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19005.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19005.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19005.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+/* PR target/19005 */
+extern void abort (void);
+
+int v, s;
+
+void
+bar (int a, int b)
+{
+ unsigned char x = v;
+
+ if (!s)
+ {
+ if (a != x || b != (unsigned char) (x + 1))
+ abort ();
+ }
+ else if (a != (unsigned char) (x + 1) || b != x)
+ abort ();
+ s ^= 1;
+}
+
+int
+foo (int x)
+{
+ unsigned char a = x, b = x + 1;
+
+ bar (a, b);
+ a ^= b; b ^= a; a ^= b;
+ bar (a, b);
+ return 0;
+}
+
+int
+main (void)
+{
+ for (v = -10; v < 266; v++)
+ foo (v);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19449.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19449.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19449.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19449.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* PR c/19449 */
+
+extern void abort (void);
+
+int y;
+int z = __builtin_choose_expr (!__builtin_constant_p (y), 3, 4);
+
+int
+foo (int x)
+{
+ return __builtin_choose_expr (!__builtin_constant_p (x), 3, y++);
+}
+
+int
+main ()
+{
+ if (y || z != 3 || foo (4) != 3)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19515.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19515.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19515.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19515.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+/* PR 19515 */
+
+typedef union {
+ char a2[8];
+}aun;
+
+void abort (void);
+
+int main(void)
+{
+ aun a = {{0}};
+
+ if (a.a2[2] != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19606.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19606.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19606.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19606.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,34 @@
+/* PR c/19606
+ The C front end used to shorten the type of a division to a type
+ that does not preserve the semantics of the original computation.
+ Make sure that won't happen. */
+
+signed char a = -4;
+
+int
+foo (void)
+{
+ return ((unsigned int) (signed int) a) / 2LL;
+}
+
+int
+bar (void)
+{
+ return ((unsigned int) (signed int) a) % 5LL;
+}
+
+int
+main (void)
+{
+ int r;
+
+ r = foo ();
+ if (r != ((unsigned int) (signed int) (signed char) -4) / 2LL)
+ abort ();
+
+ r = bar ();
+ if (r != ((unsigned int) (signed int) (signed char) -4) % 5LL)
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19687.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19687.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19687.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19687.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+extern void abort (void);
+
+union U
+{
+ int i, j[4];
+};
+
+int main ()
+{
+ union U t = {};
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ if (t.j[i] != 0)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19689.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19689.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19689.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr19689.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* { dg-require-effective-target int32plus } */
+extern void abort (void);
+
+struct
+{
+ int b : 29;
+} f;
+
+void foo (short j)
+{
+ f.b = j;
+}
+
+int main()
+{
+ foo (-55);
+ if (f.b != -55)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20100-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20100-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20100-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20100-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,76 @@
+/* PR tree-optimization/20100
+ Pure function being treated as const.
+ Author: Hans-Peter Nilsson. */
+
+static unsigned short g = 0;
+static unsigned short p = 0;
+unsigned char e;
+
+static unsigned short
+next_g (void)
+{
+ return g == e - 1 ? 0 : g + 1;
+}
+
+static unsigned short
+curr_p (void)
+{
+ return p;
+}
+
+static unsigned short
+inc_g (void)
+{
+ return g = next_g ();
+}
+
+static unsigned short
+curr_g (void)
+{
+ return g;
+}
+
+static char
+ring_empty (void)
+{
+ if (curr_p () == curr_g ())
+ return 1;
+ else
+ return 0;
+}
+
+char
+frob (unsigned short a, unsigned short b)
+{
+ g = a;
+ p = b;
+ inc_g ();
+ return ring_empty ();
+}
+
+unsigned short
+get_n (void)
+{
+ unsigned short n = 0;
+ unsigned short org_g;
+ org_g = curr_g ();
+ while (!ring_empty () && n < 5)
+ {
+ inc_g ();
+ n++;
+ }
+
+ return n;
+}
+
+void abort (void);
+void exit (int);
+int main (void)
+{
+ e = 3;
+ if (frob (0, 2) != 0 || g != 1 || p != 2 || e != 3
+ || get_n () != 1
+ || g != 2 || p != 2)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20187-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20187-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20187-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20187-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+int a = 0x101;
+int b = 0x100;
+
+int
+test (void)
+{
+ return (((unsigned char) (unsigned long long) ((a ? a : 1) & (a * b)))
+ ? 0 : 1);
+}
+
+int
+main (void)
+{
+ return 1 - test ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20466-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20466-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20466-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20466-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+int f (int **, int *, int *, int **, int **) __attribute__ ((__noinline__));
+int
+f (int **ipp, int *i1p, int *i2p, int **i3, int **i4)
+{
+ **ipp = *i1p;
+ *ipp = i2p;
+ *i3 = *i4;
+ **ipp = 99;
+ return 3;
+}
+
+extern void exit (int);
+extern void abort (void);
+
+int main (void)
+{
+ int i = 42, i1 = 66, i2 = 1, i3 = -1, i4 = 55;
+ int *ip = &i;
+ int *i3p = &i3;
+ int *i4p = &i4;
+
+ f (&ip, &i1, &i2, &i3p, &i4p);
+ if (i != 66 || ip != &i2 || i2 != 99 || i3 != -1 || i3p != i4p || i4 != 55)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20527-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20527-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20527-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20527-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,81 @@
+/* PR rtl-optimization/20527
+ Mishandled postincrement. This test-case is derived from the
+ function BZ2_hbCreateDecodeTables in the file huffman.c from
+ bzip2-1.0.2, hence requiring the following disclaimer copied here: */
+
+/*--
+ This file is a part of bzip2 and/or libbzip2, a program and
+ library for lossless, block-sorting data compression.
+
+ Copyright (C) 1996-2002 Julian R Seward. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
+ documentation would be appreciated but is not required.
+
+ 3. Altered source versions must be plainly marked as such, and must
+ not be misrepresented as being the original software.
+
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ Julian Seward, Cambridge, UK.
+ jseward at acm.org
+ bzip2/libbzip2 version 1.0 of 21 March 2000
+
+ This program is based on (at least) the work of:
+ Mike Burrows
+ David Wheeler
+ Peter Fenwick
+ Alistair Moffat
+ Radford Neal
+ Ian H. Witten
+ Robert Sedgewick
+ Jon L. Bentley
+
+ For more information on these sources, see the manual.
+--*/
+
+void f (long *limit, long *base, long minLen, long maxLen) __attribute__ ((__noinline__));
+void f (long *limit, long *base, long minLen, long maxLen)
+{
+ long i;
+ long vec;
+ vec = 0;
+ for (i = minLen; i <= maxLen; i++) {
+ vec += (base[i+1] - base[i]);
+ limit[i] = vec-1;
+ }
+}
+extern void abort (void);
+extern void exit (int);
+long b[] = {1, 5, 11, 23};
+int main (void)
+{
+ long l[3];
+ f (l, b, 0, 2);
+ if (l[0] != 3 || l[1] != 9 || l[2] != 21)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20601-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20601-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20601-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20601-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,123 @@
+/* PR tree-optimization/20601 */
+/* { dg-xfail-if "ptxas crashes" { nvptx-*-* } { "-O1" } { "" } } */
+extern void abort (void);
+extern void exit (int);
+
+struct T
+{
+ char *t1;
+ char t2[4096];
+ char **t3;
+};
+
+int a[5];
+int b;
+char **c;
+int d;
+char **e;
+struct T t;
+char *f[16];
+char *g[] = { "a", "-u", "b", "c" };
+
+__attribute__ ((__noreturn__)) void
+foo (void)
+{
+ while (1);
+}
+
+__attribute__ ((noinline)) char *
+bar (char *x, unsigned int y)
+{
+ return 0;
+}
+
+static inline char *
+baz (char *x, unsigned int y)
+{
+ if (sizeof (t.t2) != (unsigned int) -1 && y > sizeof (t.t2))
+ foo ();
+ return bar (x, y);
+}
+
+static inline int
+setup1 (int x)
+{
+ char *p;
+ int rval;
+
+ if (!baz (t.t2, sizeof (t.t2)))
+ baz (t.t2, sizeof (t.t2));
+
+ if (x & 0x200)
+ {
+ char **h, **i = e;
+
+ ++d;
+ e = f;
+ if (t.t1 && *t.t1)
+ e[0] = t.t1;
+ else
+ abort ();
+
+ for (h = e + 1; (*h = *i); ++i, ++h)
+ ;
+ }
+ return 1;
+}
+
+static inline int
+setup2 (void)
+{
+ int j = 1;
+
+ e = c + 1;
+ d = b - 1;
+ while (d > 0 && e[0][0] == '-')
+ {
+ if (e[0][1] != '\0' && e[0][2] != '\0')
+ abort ();
+
+ switch (e[0][1])
+ {
+ case 'u':
+ if (!e[1])
+ abort ();
+
+ t.t3 = &e[1];
+ d--;
+ e++;
+ break;
+ case 'P':
+ j |= 0x1000;
+ break;
+ case '-':
+ d--;
+ e++;
+ if (j == 1)
+ j |= 0x600;
+ return j;
+ }
+ d--;
+ e++;
+ }
+
+ if (d > 0 && !(j & 1))
+ abort ();
+
+ return j;
+}
+
+int
+main (void)
+{
+ int x;
+ c = g;
+ b = 4;
+ x = setup2 ();
+ t.t1 = "/bin/sh";
+ setup1 (x);
+ /* PRE shouldn't transform x into the constant 0x601 here, it's not legal. */
+ if ((x & 0x400) && !a[4])
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20621-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20621-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20621-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr20621-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,8 @@
+/* { dg-require-stack-size "0x10000" } */
+
+/* When generating o32 MIPS PIC, main's $gp save slot was out of range
+ of a single load instruction. */
+struct big { int i[sizeof (int) >= 4 && sizeof (void *) >= 4 ? 0x4000 : 4]; };
+struct big gb;
+int foo (struct big b, int x) { return b.i[x]; }
+int main (void) { return foo (gb, 0) + foo (gb, 1); }
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21173.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21173.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21173.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21173.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+void abort (void);
+
+char q;
+void *a[2];
+
+void foo (char *p)
+{
+ int i;
+ for (i = 0; i < 2; i++)
+ a[i] += p - &q;
+}
+
+int main (void)
+{
+ int i;
+ foo (&q);
+ for (i = 0; i < 2; i ++)
+ if (a[i])
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21331.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21331.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21331.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21331.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+void abort (void);
+
+int bar (void) { return -1; }
+
+unsigned long
+foo ()
+{ unsigned long retval;
+ retval = bar ();
+ if (retval == -1) return 0;
+ return 3; }
+
+main ()
+{ if (foo () != 0) abort ();
+ return 0; }
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21964-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21964-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21964-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr21964-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+void
+foo (int n, int m)
+{
+ if (m == 0)
+ exit (0);
+ else if (n != 0)
+ abort ();
+ else
+ foo (n++, m - 1);
+}
+
+int
+main (void)
+{
+ foo (0, 4);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+/* { dg-require-effective-target alloca } */
+int N = 1;
+void foo() {} /* Necessary to trigger the original ICE. */
+void bar (char a[2][N]) { a[1][0] = N; }
+int
+main (void)
+{
+ void *x;
+
+ N = 4;
+ x = alloca (2 * N);
+ memset (x, 0, 2 * N);
+ bar (x);
+ if (N[(char *) x] != N)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,7 @@
+int *x;
+static void bar (char a[2][(*x)++]) {}
+int
+main (void)
+{
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+void
+bar (int N)
+{
+ int foo (char a[2][++N]) { N += 4; return sizeof (a[0]); }
+ if (foo (0) != 2)
+ abort ();
+ if (foo (0) != 7)
+ abort ();
+ if (N != 11)
+ abort ();
+}
+
+int
+main()
+{
+ bar (1);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22061-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* { dg-skip-if "requires alloca" { ! alloca } { "-O0" } { "" } } */
+void
+bar (int N)
+{
+ void foo (int a[2][N++]) {}
+ int a[2][N];
+ foo (a);
+ int b[2][N];
+ foo (b);
+ if (sizeof (a) != sizeof (int) * 2 * 1)
+ abort ();
+ if (sizeof (b) != sizeof (int) * 2 * 2)
+ abort ();
+ if (N != 3)
+ abort ();
+}
+
+int
+main (void)
+{
+ bar (1);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+extern void abort (void);
+extern void exit (int);
+typedef __UINTPTR_TYPE__ uintptr_t;
+int
+main (void)
+{
+ int a = 0;
+ int *p;
+ uintptr_t b;
+ b = (uintptr_t)(p = &(int []){0, 1, 2}[++a]);
+ if (a != 1 || *p != 1 || *(int *)b != 1)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+extern void abort (void);
+extern void exit (int);
+typedef __UINTPTR_TYPE__ uintptr_t;
+int
+main (void)
+{
+ int a = 0;
+ int *p;
+ uintptr_t b;
+ b = (uintptr_t)(p = &(int []){0, 1, 2}[1]);
+ if (*p != 1 || *(int *)b != 1)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22098-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+extern void abort (void);
+extern void exit (int);
+typedef __UINTPTR_TYPE__ uintptr_t;
+int n = 0;
+int f (void) { return ++n; }
+int
+main (void)
+{
+ int a = 0;
+ int *p;
+ uintptr_t b;
+ b = (uintptr_t)(p = &(int []){0, f(), 2}[1]);
+ if (*p != 1 || *(int *)b != 1 || n != 1)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22141-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22141-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22141-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22141-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,122 @@
+/* PR middle-end/22141 */
+
+extern void abort (void);
+
+struct S
+{
+ struct T
+ {
+ char a;
+ char b;
+ char c;
+ char d;
+ } t;
+} u;
+
+struct U
+{
+ struct S s[4];
+};
+
+void __attribute__((noinline))
+c1 (struct T *p)
+{
+ if (p->a != 1 || p->b != 2 || p->c != 3 || p->d != 4)
+ abort ();
+ __builtin_memset (p, 0xaa, sizeof (*p));
+}
+
+void __attribute__((noinline))
+c2 (struct S *p)
+{
+ c1 (&p->t);
+}
+
+void __attribute__((noinline))
+c3 (struct U *p)
+{
+ c2 (&p->s[2]);
+}
+
+void __attribute__((noinline))
+f1 (void)
+{
+ u = (struct S) { { 1, 2, 3, 4 } };
+}
+
+void __attribute__((noinline))
+f2 (void)
+{
+ u.t.a = 1;
+ u.t.b = 2;
+ u.t.c = 3;
+ u.t.d = 4;
+}
+
+void __attribute__((noinline))
+f3 (void)
+{
+ u.t.d = 4;
+ u.t.b = 2;
+ u.t.a = 1;
+ u.t.c = 3;
+}
+
+void __attribute__((noinline))
+f4 (void)
+{
+ struct S v;
+ v.t.a = 1;
+ v.t.b = 2;
+ v.t.c = 3;
+ v.t.d = 4;
+ c2 (&v);
+}
+
+void __attribute__((noinline))
+f5 (struct S *p)
+{
+ p->t.a = 1;
+ p->t.c = 3;
+ p->t.d = 4;
+ p->t.b = 2;
+}
+
+void __attribute__((noinline))
+f6 (void)
+{
+ struct U v;
+ v.s[2].t.a = 1;
+ v.s[2].t.b = 2;
+ v.s[2].t.c = 3;
+ v.s[2].t.d = 4;
+ c3 (&v);
+}
+
+void __attribute__((noinline))
+f7 (struct U *p)
+{
+ p->s[2].t.a = 1;
+ p->s[2].t.c = 3;
+ p->s[2].t.d = 4;
+ p->s[2].t.b = 2;
+}
+
+int
+main (void)
+{
+ struct U w;
+ f1 ();
+ c2 (&u);
+ f2 ();
+ c1 (&u.t);
+ f3 ();
+ c2 (&u);
+ f4 ();
+ f5 (&u);
+ c2 (&u);
+ f6 ();
+ f7 (&w);
+ c3 (&w);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22141-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22141-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22141-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22141-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,122 @@
+/* PR middle-end/22141 */
+
+extern void abort (void);
+
+struct S
+{
+ struct T
+ {
+ char a;
+ char b;
+ char c;
+ char d;
+ } t;
+} u __attribute__((aligned));
+
+struct U
+{
+ struct S s[4];
+};
+
+void __attribute__((noinline))
+c1 (struct T *p)
+{
+ if (p->a != 1 || p->b != 2 || p->c != 3 || p->d != 4)
+ abort ();
+ __builtin_memset (p, 0xaa, sizeof (*p));
+}
+
+void __attribute__((noinline))
+c2 (struct S *p)
+{
+ c1 (&p->t);
+}
+
+void __attribute__((noinline))
+c3 (struct U *p)
+{
+ c2 (&p->s[2]);
+}
+
+void __attribute__((noinline))
+f1 (void)
+{
+ u = (struct S) { { 1, 2, 3, 4 } };
+}
+
+void __attribute__((noinline))
+f2 (void)
+{
+ u.t.a = 1;
+ u.t.b = 2;
+ u.t.c = 3;
+ u.t.d = 4;
+}
+
+void __attribute__((noinline))
+f3 (void)
+{
+ u.t.d = 4;
+ u.t.b = 2;
+ u.t.a = 1;
+ u.t.c = 3;
+}
+
+void __attribute__((noinline))
+f4 (void)
+{
+ struct S v __attribute__((aligned));
+ v.t.a = 1;
+ v.t.b = 2;
+ v.t.c = 3;
+ v.t.d = 4;
+ c2 (&v);
+}
+
+void __attribute__((noinline))
+f5 (struct S *p)
+{
+ p->t.a = 1;
+ p->t.c = 3;
+ p->t.d = 4;
+ p->t.b = 2;
+}
+
+void __attribute__((noinline))
+f6 (void)
+{
+ struct U v __attribute__((aligned));
+ v.s[2].t.a = 1;
+ v.s[2].t.b = 2;
+ v.s[2].t.c = 3;
+ v.s[2].t.d = 4;
+ c3 (&v);
+}
+
+void __attribute__((noinline))
+f7 (struct U *p)
+{
+ p->s[2].t.a = 1;
+ p->s[2].t.c = 3;
+ p->s[2].t.d = 4;
+ p->s[2].t.b = 2;
+}
+
+int
+main (void)
+{
+ struct U w __attribute__((aligned));
+ f1 ();
+ c2 (&u);
+ f2 ();
+ c1 (&u.t);
+ f3 ();
+ c2 (&u);
+ f4 ();
+ f5 (&u);
+ c2 (&u);
+ f6 ();
+ f7 (&w);
+ c3 (&w);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22348.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22348.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22348.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22348.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+void abort (void);
+void f(int i)
+{
+ if (i>4 + 3 * 16)
+ abort();
+}
+
+int main()
+{
+ unsigned int buflen, i;
+ buflen = 4 + 3 * 16;
+ for (i = 4; i < buflen; i+= 3)
+ f(i);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22429.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22429.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22429.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22429.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+extern void abort (void);
+
+#define N (1 << (sizeof(int) * __CHAR_BIT__ - 2))
+
+int f(int n)
+{
+ if (-N <= n && n <= N-1)
+ return 1;
+ return 0;
+}
+
+int main ()
+{
+ if (f (N))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22493-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22493-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22493-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22493-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* { dg-options "-fwrapv" } */
+
+#include <limits.h>
+extern void abort ();
+extern void exit (int);
+void f(int i)
+{
+ if (i>0)
+ abort();
+ i = -i;
+ if (i<0)
+ return;
+ abort ();
+}
+
+int main(int argc, char *argv[])
+{
+ f(INT_MIN);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22630.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22630.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22630.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr22630.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+void abort (void);
+
+int j;
+
+void bla (int *r)
+{
+ int *p, *q;
+
+ p = q = r;
+ if (!p)
+ p = &j;
+
+ if (p != q)
+ j = 1;
+}
+
+int main (void)
+{
+ bla (0);
+ if (!j)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23047.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23047.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23047.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23047.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+/* { dg-options "-fwrapv" } */
+#include <limits.h>
+extern void abort ();
+extern void exit (int);
+void f(int i)
+{
+ i = i > 0 ? i : -i;
+ if (i<0)
+ return;
+ abort ();
+}
+
+int main(int argc, char *argv[])
+{
+ f(INT_MIN);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23135.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23135.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23135.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23135.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,140 @@
+/* Based on execute/simd-1.c, modified by joern.rennecke at st.com to
+ trigger a reload bug. Verified for gcc mainline from 20050722 13:00 UTC
+ for sh-elf -m4 -O2. */
+/* { dg-options "-Wno-psabi" } */
+/* { dg-add-options stack_size } */
+
+#ifndef STACK_SIZE
+#define STACK_SIZE (256*1024)
+#endif
+
+extern void abort (void);
+extern void exit (int);
+
+typedef struct { char c[STACK_SIZE/2]; } big_t;
+
+typedef int __attribute__((mode(SI))) __attribute__((vector_size (8))) vecint;
+typedef int __attribute__((mode(SI))) siint;
+
+vecint i = { 150, 100 };
+vecint j = { 10, 13 };
+vecint k;
+
+union {
+ vecint v;
+ siint i[2];
+} res;
+
+void
+verify (siint a1, siint a2, siint b1, siint b2, big_t big)
+{
+ if (a1 != b1
+ || a2 != b2)
+ abort ();
+}
+
+int
+main ()
+{
+ big_t big;
+ vecint k0, k1, k2, k3, k4, k5, k6, k7;
+
+ k0 = i + j;
+ res.v = k0;
+
+ verify (res.i[0], res.i[1], 160, 113, big);
+
+ k1 = i * j;
+ res.v = k1;
+
+ verify (res.i[0], res.i[1], 1500, 1300, big);
+
+ k2 = i / j;
+/* This is the observed failure - reload 0 has the wrong type and thus the
+ conflict with reload 1 is missed:
+
+(insn:HI 94 92 96 1 pr23135.c:46 (parallel [
+ (set (subreg:SI (reg:DI 253) 0)
+ (div:SI (reg:SI 4 r4)
+ (reg:SI 5 r5)))
+ (clobber (reg:SI 146 pr))
+ (clobber (reg:DF 64 fr0))
+ (clobber (reg:DF 66 fr2))
+ (use (reg:PSI 151 ))
+ (use (reg/f:SI 256))
+ ]) 60 {divsi3_i4} (insn_list:REG_DEP_TRUE 90 (insn_list:REG_DEP_TRUE 89
+(insn_list:REG_DEP_TRUE 42 (insn_list:REG_DEP_TRUE 83 (insn_list:REG_DEP_TRUE 92
+ (insn_list:REG_DEP_TRUE 91 (nil)))))))
+ (expr_list:REG_DEAD (reg:SI 4 r4)
+ (expr_list:REG_DEAD (reg:SI 5 r5)
+ (expr_list:REG_UNUSED (reg:DF 66 fr2)
+ (expr_list:REG_UNUSED (reg:DF 64 fr0)
+ (expr_list:REG_UNUSED (reg:SI 146 pr)
+ (insn_list:REG_RETVAL 91 (nil))))))))
+
+Reloads for insn # 94
+Reload 0: reload_in (SI) = (plus:SI (reg/f:SI 14 r14)
+ (const_int 64 [0x40]))
+ GENERAL_REGS, RELOAD_FOR_OUTADDR_ADDRESS (opnum = 0)
+ reload_in_reg: (plus:SI (reg/f:SI 14 r14)
+ (const_int 64 [0x40]))
+ reload_reg_rtx: (reg:SI 3 r3)
+Reload 1: GENERAL_REGS, RELOAD_FOR_OUTPUT_ADDRESS (opnum = 0), can't combine, se
+condary_reload_p
+ reload_reg_rtx: (reg:SI 3 r3)
+Reload 2: reload_out (SI) = (mem:SI (plus:SI (plus:SI (reg/f:SI 14 r14)
+ (const_int 64 [0x40]))
+ (const_int 28 [0x1c])) [ 16 S8 A32])
+ FPUL_REGS, RELOAD_FOR_OUTPUT (opnum = 0)
+ reload_out_reg: (subreg:SI (reg:DI 253) 0)
+ reload_reg_rtx: (reg:SI 150 fpul)
+ secondary_out_reload = 1
+
+Reload 3: reload_in (SI) = (symbol_ref:SI ("__sdivsi3_i4") [flags 0x1])
+ GENERAL_REGS, RELOAD_FOR_INPUT (opnum = 1), can't combine
+ reload_in_reg: (reg/f:SI 256)
+ reload_reg_rtx: (reg:SI 3 r3)
+ */
+
+
+ res.v = k2;
+
+ verify (res.i[0], res.i[1], 15, 7, big);
+
+ k3 = i & j;
+ res.v = k3;
+
+ verify (res.i[0], res.i[1], 2, 4, big);
+
+ k4 = i | j;
+ res.v = k4;
+
+ verify (res.i[0], res.i[1], 158, 109, big);
+
+ k5 = i ^ j;
+ res.v = k5;
+
+ verify (res.i[0], res.i[1], 156, 105, big);
+
+ k6 = -i;
+ res.v = k6;
+ verify (res.i[0], res.i[1], -150, -100, big);
+
+ k7 = ~i;
+ res.v = k7;
+ verify (res.i[0], res.i[1], -151, -101, big);
+
+ k = k0 + k1 + k3 + k4 + k5 + k6 + k7;
+ res.v = k;
+ verify (res.i[0], res.i[1], 1675, 1430, big);
+
+ k = k0 * k1 * k3 * k4 * k5 * k6 * k7;
+ res.v = k;
+ verify (res.i[0], res.i[1], 1456467968, -1579586240, big);
+
+ k = k0 / k1 / k2 / k3 / k4 / k5 / k6 / k7;
+ res.v = k;
+ verify (res.i[0], res.i[1], 0, 0, big);
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23324.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23324.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23324.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23324.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,133 @@
+extern void abort (void);
+#define A(x) if (!(x)) abort ()
+
+static union at6 {} vv6 = {};
+static struct et6
+{
+ struct bt6
+ {
+ signed av6:6;
+ signed bv6:7;
+ signed cv6:6;
+ signed dv6:5;
+ unsigned char ev6;
+ unsigned int fv6;
+ long int gv6;
+ } mv6;
+ unsigned long int nv6;
+ signed ov6:12;
+ signed pv6:3;
+ signed qv6:2;
+ signed rv6:10;
+ union ct6 { long int hv6; float iv6; float jv6; } sv6;
+ int *tv6;
+ union dt6 { double kv6; float lv6; } uv6;
+} wv6 = {
+ { 8, 9, 2, 4, '\x10', 67426805U, 1047191860L },
+ 1366022414UL, 858, 1, 1, 305,
+ { 1069379046L }, (int *) 358273621U,
+ { 3318.041978 }
+};
+static double xv6 = 19239.101269;
+static long long int yv6 = 1207859169L;
+static int zv6 = 660195606;
+
+static union at6
+callee_af6 (struct et6 ap6, double bp6, long long int cp6, int dp6)
+{
+ A (wv6.mv6.av6 == ap6.mv6.av6);
+ A (wv6.mv6.bv6 == ap6.mv6.bv6);
+ A (wv6.mv6.cv6 == ap6.mv6.cv6);
+ A (wv6.mv6.dv6 == ap6.mv6.dv6);
+ A (wv6.mv6.ev6 == ap6.mv6.ev6);
+ A (wv6.mv6.fv6 == ap6.mv6.fv6);
+ A (wv6.mv6.gv6 == ap6.mv6.gv6);
+ A (wv6.nv6 == ap6.nv6);
+ A (wv6.ov6 == ap6.ov6);
+ A (wv6.pv6 == ap6.pv6);
+ A (wv6.qv6 == ap6.qv6);
+ A (wv6.rv6 == ap6.rv6);
+ A (wv6.sv6.hv6 == ap6.sv6.hv6);
+ A (wv6.tv6 == ap6.tv6);
+ A (wv6.uv6.kv6 == ap6.uv6.kv6);
+ A (xv6 == bp6);
+ A (yv6 == cp6);
+ A (zv6 == dp6);
+ return vv6;
+}
+
+static void
+caller_bf6 (void)
+{
+ union at6 bav6;
+ bav6 = callee_af6 (wv6, xv6, yv6, zv6);
+}
+
+static unsigned char uv7 = '\x46';
+static float vv7 = 96636.982442;
+static double wv7 = 28450.711801;
+static union ct7 {} xv7 = {};
+static struct et7
+{
+ struct dt7
+ {
+ float iv7;
+ unsigned short int jv7;
+ } kv7;
+ float lv7[0];
+ signed mv7:9;
+ short int nv7;
+ double ov7;
+ float pv7;
+} yv7 = {
+ { 30135.996213, 42435 },
+ {}, 170, 22116, 26479.628148, 4082.960685
+};
+static union ft7
+{
+ float qv7;
+ float *rv7;
+ unsigned int *sv7;
+} zv7 = { 5042.227886 };
+static int bav7 = 1345451862;
+static struct gt7 { double tv7; } bbv7 = { 47875.491954 };
+static long int bcv7[1] = { 1732133482L };
+static long long int bdv7 = 381678602L;
+
+static unsigned char
+callee_af7 (float ap7, double bp7, union ct7 cp7, struct et7 dp7,
+ union ft7 ep7, int fp7, struct gt7 gp7, long int hp7[1],
+ long long int ip7)
+{
+ A (vv7 == ap7);
+ A (wv7 == bp7);
+ A (yv7.kv7.iv7 == dp7.kv7.iv7);
+ A (yv7.kv7.jv7 == dp7.kv7.jv7);
+ A (yv7.mv7 == dp7.mv7);
+ A (yv7.nv7 == dp7.nv7);
+ A (yv7.ov7 == dp7.ov7);
+ A (yv7.pv7 == dp7.pv7);
+ A (zv7.qv7 == ep7.qv7);
+ A (bav7 == fp7);
+ A (bbv7.tv7 == gp7.tv7);
+ A (bcv7[0] == hp7[0]);
+ A (bdv7 == ip7);
+ return uv7;
+}
+
+static void
+caller_bf7 (void)
+{
+ unsigned char bev7;
+
+ bev7 = callee_af7 (vv7, wv7, xv7, yv7, zv7, bav7, bbv7, bcv7, bdv7);
+ A (uv7 == bev7);
+}
+
+int
+main ()
+{
+ caller_bf6 ();
+ caller_bf7 ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23467.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23467.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23467.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23467.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* { dg-skip-if "small alignment" { pdp11-*-* } } */
+
+struct s1
+{
+ int __attribute__ ((aligned (8))) a;
+};
+
+struct
+{
+ char c;
+ struct s1 m;
+} v;
+
+int
+main (void)
+{
+ if ((int)&v.m & 7)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23604.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23604.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23604.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23604.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+extern void abort (void);
+
+int g(int i, int j)
+{
+ if (i>-1)
+ if (i<2)
+ {
+ if (i != j)
+ {
+ if (j != 0)
+ return 0;
+ }
+ }
+ return 1;
+}
+
+int main(void)
+{
+ if (!g(1, 0))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23941.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23941.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23941.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr23941.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,9 @@
+extern void abort (void);
+double d = __FLT_MIN__ / 2.0;
+int main()
+{
+ double x = __FLT_MIN__ / 2.0;
+ if (x != d)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24135.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24135.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24135.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24135.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,44 @@
+/* { dg-require-effective-target trampolines } */
+
+extern void abort (void);
+
+int x(int a, int b)
+{
+ __label__ xlab;
+ __label__ xlab2;
+
+ void y(int b)
+ {
+ switch (b)
+ {
+ case 1: goto xlab;
+ case 2: goto xlab;
+ }
+ }
+
+ a = a + 2;
+ y (b);
+
+ xlab:
+ return a;
+
+ xlab2:
+ a++;
+ return a;
+
+}
+
+int main ()
+{
+ int i, j;
+
+ for (j = 1; j <= 2; ++j)
+ for (i = 1; i <= 2; ++i)
+ {
+ int a = x (j, i);
+ if (a != 2 + j)
+ abort ();
+ }
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24141.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24141.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24141.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24141.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+// reduced testcase, compile with -O2. Also, with --disable-checking
+// gcc produces wrong code.
+
+void abort (void);
+int i;
+
+void g (void)
+{
+ i = 1;
+}
+
+void f (int a, int b)
+{
+ int c = 0;
+ if (a == 0)
+ c = 1;
+ if (c)
+ return;
+ if (c == 1)
+ c = 0;
+ if (b == 0)
+ c = 1;
+ if (c)
+ g ();
+}
+
+int main (void)
+{
+ f (1, 0);
+ if (i != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24142.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24142.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24142.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24142.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+void abort (void);
+
+int f (int a, int b)
+{
+ if (a == 1)
+ a = 0;
+ if (b == 0)
+ a = 1;
+ if (a != 0)
+ return 0;
+ return 1;
+}
+
+int main (void)
+{
+ if (f (1, 1) != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24716.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24716.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24716.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24716.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,58 @@
+/* PR24716, scalar evolution returning the wrong result
+ for pdest. */
+
+int Link[] = { -1 };
+int W[] = { 2 };
+
+extern void abort (void);
+
+int f (int k, int p)
+{
+ int pdest, j, D1361;
+ j = 0;
+ pdest = 0;
+ for (;;) {
+ if (pdest > 2)
+ do
+ j--, pdest++;
+ while (j > 2);
+
+ if (j == 1)
+ break;
+
+ while (pdest > p)
+ if (j == p)
+ pdest++;
+
+ do
+ {
+ D1361 = W[k];
+ do
+ if (D1361 != 0)
+ pdest = 1, W[k] = D1361 = 0;
+ while (p < 1);
+ } while (k > 0);
+
+ do
+ {
+ p = 0;
+ k = Link[k];
+ while (p < j)
+ if (k != -1)
+ pdest++, p++;
+ }
+ while (k != -1);
+ j = 1;
+ }
+
+ /* The correct return value should be pdest (1 in the call from main).
+ DOM3 is mistaken and propagates a 0 here. */
+ return pdest;
+}
+
+int main ()
+{
+ if (!f (0, 2))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24851.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24851.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24851.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr24851.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+/* We used to handle pointer addition wrongly
+ at the time of recombining to an ARRAY_REF
+ in the case of
+ p + -4B
+ where -4B is represented as unsigned. */
+
+void abort(void);
+int main()
+{
+ int a[10], *p, *q;
+ q = &a[1];
+ p = &q[-1];
+ if (p >= &a[9])
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr25125.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr25125.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr25125.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr25125.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+extern void exit (int);
+extern void abort (void);
+extern unsigned short f (short a) __attribute__((__noinline__));
+
+unsigned short
+f (short a)
+{
+ short b;
+
+ if (a > 0)
+ return 0;
+ b = ((int) a) + - (int) 32768;
+ return b;
+}
+
+int
+main (void)
+{
+ if (sizeof (short) < 2
+ || sizeof (short) >= sizeof (int))
+ exit (0);
+
+ if (f (-32767) != 1)
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr25737.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr25737.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr25737.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr25737.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+extern void abort (void);
+
+struct delay_block {
+ struct delay_block *succ;
+};
+
+static struct delay_block Timer_Queue;
+
+struct delay_block* time_enqueue (struct delay_block *d)
+{
+ struct delay_block *q = Timer_Queue.succ;
+ d->succ = (void *)0;
+ return Timer_Queue.succ;
+}
+
+int main(void)
+{
+ Timer_Queue.succ = &Timer_Queue;
+ if (time_enqueue (&Timer_Queue) != (void*)0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27073.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27073.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27073.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27073.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+void __attribute__((noinline))
+foo (int *p, int d1, int d2, int d3,
+ short count, int s1, int s2, int s3, int s4, int s5)
+{
+ int n = count;
+ while (n--)
+ {
+ *p++ = s1;
+ *p++ = s2;
+ *p++ = s3;
+ *p++ = s4;
+ *p++ = s5;
+ }
+}
+
+int main()
+{
+ int x[10], i;
+
+ foo (x, 0, 0, 0, 2, 100, 200, 300, 400, 500);
+ for (i = 0; i < 10; i++)
+ if (x[i] != (i % 5 + 1) * 100)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27260.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27260.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27260.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27260.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+/* PR middle-end/27260 */
+
+extern void abort (void);
+extern void *memset (void *, int, __SIZE_TYPE__);
+
+char buf[65];
+
+void
+foo (int x)
+{
+ memset (buf, x != 2 ? 1 : 0, 64);
+}
+
+int
+main (void)
+{
+ int i;
+ buf[64] = 2;
+ for (i = 0; i < 64; i++)
+ if (buf[i] != 0)
+ abort ();
+ foo (0);
+ for (i = 0; i < 64; i++)
+ if (buf[i] != 1)
+ abort ();
+ foo (2);
+ for (i = 0; i < 64; i++)
+ if (buf[i] != 0)
+ abort ();
+ if (buf[64] != 2)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27285.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27285.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27285.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27285.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,46 @@
+/* PR tree-optimization/27285 */
+
+extern void abort (void);
+
+struct S { unsigned char a, b, c, d[16]; };
+
+void __attribute__ ((noinline))
+foo (struct S *x, struct S *y)
+{
+ int a, b;
+ unsigned char c, *d, *e;
+
+ b = x->b;
+ d = x->d;
+ e = y->d;
+ a = 0;
+ while (b)
+ {
+ if (b >= 8)
+ {
+ c = 0xff;
+ b -= 8;
+ }
+ else
+ {
+ c = 0xff << (8 - b);
+ b = 0;
+ }
+
+ e[a] = d[a] & c;
+ a++;
+ }
+}
+
+int
+main (void)
+{
+ struct S x = { 0, 25, 0, { 0xaa, 0xbb, 0xcc, 0xdd }};
+ struct S y = { 0, 0, 0, { 0 }};
+
+ foo (&x, &y);
+ if (x.d[0] != y.d[0] || x.d[1] != y.d[1]
+ || x.d[2] != y.d[2] || (x.d[3] & 0x80) != y.d[3])
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27364.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27364.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27364.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27364.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+int f(unsigned number_of_digits_to_use)
+{
+ if (number_of_digits_to_use >1294)
+ return 0;
+ return (number_of_digits_to_use * 3321928 / 1000000 + 1) /16;
+}
+
+int main(void)
+{
+ if (f(11) != 2)
+ __builtin_abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27671-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27671-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27671-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr27671-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR rtl-optimization/27671.
+ The combiner used to simplify "a ^ b == a" to "a" via
+ simplify_relational_operation_1 in simplify-rtx.c. */
+
+extern void abort (void) __attribute__ ((noreturn));
+extern void exit (int) __attribute__ ((noreturn));
+
+static int __attribute__((noinline))
+foo (int a, int b)
+{
+ int c = a ^ b;
+ if (c == a)
+ abort ();
+}
+
+int
+main (void)
+{
+ foo (0, 1);
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28289.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28289.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28289.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28289.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+extern int ok (int);
+extern void exit ();
+static int gen_x86_64_shrd (int);
+static int
+gen_x86_64_shrd(int a __attribute__ ((__unused__)))
+{
+ return 0;
+}
+
+extern int gen_x86_shrd_1 (int);
+extern void ix86_split_ashr (int);
+
+void
+ix86_split_ashr (int mode)
+{
+ (mode != 0
+ ? ok
+ : gen_x86_64_shrd) (0);
+}
+
+volatile int one = 1;
+int
+main (void)
+{
+ ix86_split_ashr (one);
+ return 1;
+}
+
+int
+ok (int i)
+{
+ exit (i);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28403.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28403.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28403.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28403.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+typedef unsigned long long ull;
+int global;
+
+int __attribute__((noinline))
+foo (int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8)
+{
+ global = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8;
+}
+
+ull __attribute__((noinline))
+bar (ull x)
+{
+ foo (1, 2, 1, 3, 1, 4, 1, 5);
+ return x >> global;
+}
+
+int
+main (void)
+{
+ if (bar (0x123456789abcdefULL) != (0x123456789abcdefULL >> 18))
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28651.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28651.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28651.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28651.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+#include <limits.h>
+
+extern void abort (void);
+int __attribute__((noinline))
+foo (unsigned int u)
+{
+ return (int)(u + 4) < (int)u;
+}
+
+int
+main (int argc, char *argv[])
+{
+ unsigned int u = INT_MAX;
+
+ if (foo (u) == 0)
+ abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28778.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28778.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28778.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28778.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+extern void abort(void);
+typedef long GLint;
+void aglChoosePixelFormat (const GLint *);
+
+void
+find (const int *alistp)
+{
+ const int *blist;
+ int list[32];
+ if (alistp)
+ blist = alistp;
+ else
+ {
+ list[3] = 42;
+ blist = list;
+ }
+ aglChoosePixelFormat ((GLint *) blist);
+}
+
+void
+aglChoosePixelFormat (const GLint * a)
+{
+ int *b = (int *) a;
+ if (b[3] != 42)
+ abort ();
+}
+
+int
+main (void)
+{
+ find (0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28865.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28865.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28865.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28865.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+struct A { int a; char b[]; };
+union B { struct A a; char b[sizeof (struct A) + 31]; };
+union B b = { { 1, "123456789012345678901234567890" } };
+union B c = { { 2, "123456789012345678901234567890" } };
+
+__attribute__((noinline, noclone)) void
+foo (int *x[2])
+{
+ x[0] = &b.a.a;
+ x[1] = &c.a.a;
+}
+
+int
+main ()
+{
+ int *x[2];
+ foo (x);
+ if (*x[0] != 1 || *x[1] != 2)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28982a.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28982a.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28982a.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28982a.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,65 @@
+/* PR rtl-optimization/28982. Function foo() does the equivalent of:
+
+ float tmp_results[NVARS];
+ for (int i = 0; i < NVARS; i++)
+ {
+ int inc = incs[i];
+ float *ptr = ptrs[i], result = 0;
+ for (int j = 0; j < n; j++)
+ result += *ptr, ptr += inc;
+ tmp_results[i] = result;
+ }
+ memcpy (results, tmp_results, sizeof (results));
+
+ but without the outermost loop. The idea is to create high register
+ pressure and ensure that some INC and PTR variables are spilled.
+
+ On ARM targets, sequences like "result += *ptr, ptr += inc" can
+ usually be implemented using (mem (post_modify ...)), and we do
+ indeed create such MEMs before reload for this testcase. However,
+ (post_modify ...) is not a valid address for coprocessor loads, so
+ for -mfloat-abi=softfp, reload reloads the POST_MODIFY into a base
+ register. GCC did not deal correctly with cases where the base and
+ index of the POST_MODIFY are themselves reloaded. */
+#define NITER 4
+#define NVARS 20
+#define MULTI(X) \
+ X( 0), X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), \
+ X(10), X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19)
+
+#define DECLAREI(INDEX) inc##INDEX = incs[INDEX]
+#define DECLAREF(INDEX) *ptr##INDEX = ptrs[INDEX], result##INDEX = 0
+#define LOOP(INDEX) result##INDEX += *ptr##INDEX, ptr##INDEX += inc##INDEX
+#define COPYOUT(INDEX) results[INDEX] = result##INDEX
+
+float *ptrs[NVARS];
+float results[NVARS];
+int incs[NVARS];
+
+void __attribute__((noinline))
+foo (int n)
+{
+ int MULTI (DECLAREI);
+ float MULTI (DECLAREF);
+ while (n--)
+ MULTI (LOOP);
+ MULTI (COPYOUT);
+}
+
+float input[NITER * NVARS];
+
+int
+main (void)
+{
+ int i;
+
+ for (i = 0; i < NVARS; i++)
+ ptrs[i] = input + i, incs[i] = i;
+ for (i = 0; i < NITER * NVARS; i++)
+ input[i] = i;
+ foo (NITER);
+ for (i = 0; i < NVARS; i++)
+ if (results[i] != i * NITER * (NITER + 1) / 2)
+ return 1;
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28982b.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28982b.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28982b.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr28982b.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,56 @@
+/* { dg-require-stack-size "0x80100" } */
+
+/* Like pr28982a.c, but with the spill slots outside the range of
+ a single sp-based load on ARM. This test tests for cases where
+ the addresses in the base and index reloads require further reloads. */
+#define NITER 4
+#define NVARS 20
+#define MULTI(X) \
+ X( 0), X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), \
+ X(10), X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19)
+
+#define DECLAREI(INDEX) inc##INDEX = incs[INDEX]
+#define DECLAREF(INDEX) *ptr##INDEX = ptrs[INDEX], result##INDEX = 0
+#define LOOP(INDEX) result##INDEX += *ptr##INDEX, ptr##INDEX += inc##INDEX
+#define COPYOUT(INDEX) results[INDEX] = result##INDEX
+
+float *ptrs[NVARS];
+float results[NVARS];
+int incs[NVARS];
+
+struct big { int i[0x10000]; };
+void __attribute__((noinline))
+bar (struct big b)
+{
+ incs[0] += b.i[0];
+}
+
+void __attribute__((noinline))
+foo (int n)
+{
+ struct big b = {};
+ int MULTI (DECLAREI);
+ float MULTI (DECLAREF);
+ while (n--)
+ MULTI (LOOP);
+ MULTI (COPYOUT);
+ bar (b);
+}
+
+float input[NITER * NVARS];
+
+int
+main (void)
+{
+ int i;
+
+ for (i = 0; i < NVARS; i++)
+ ptrs[i] = input + i, incs[i] = i;
+ for (i = 0; i < NITER * NVARS; i++)
+ input[i] = i;
+ foo (NITER);
+ for (i = 0; i < NVARS; i++)
+ if (results[i] != i * NITER * (NITER + 1) / 2)
+ return 1;
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29006.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29006.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29006.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29006.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,3 @@
+struct __attribute__((__packed__)) s { char c; unsigned long long x; };
+void __attribute__((__noinline__)) foo (struct s *s) { s->x = 0; }
+int main (void) { struct s s = { 1, ~0ULL }; foo (&s); return s.x != 0; }
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29156.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29156.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29156.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29156.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+extern void abort(void);
+struct test1
+{
+ int a;
+ int b;
+};
+struct test2
+{
+ float d;
+ struct test1 sub;
+};
+
+int global;
+
+int bla(struct test1 *xa, struct test2 *xb)
+{
+ global = 1;
+ xb->sub.a = 1;
+ xa->a = 8;
+ return xb->sub.a;
+}
+
+int main(void)
+{
+ struct test2 pom;
+
+ if (bla (&pom.sub, &pom) != 8)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29695-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29695-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29695-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29695-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,83 @@
+/* PR middle-end/29695 */
+
+extern void abort (void);
+
+int
+f1 (void)
+{
+ int a = 128;
+ return (a & 0x80) ? 0x80 : 0;
+}
+
+int
+f2 (void)
+{
+ unsigned char a = 128;
+ return (a & 0x80) ? 0x80 : 0;
+}
+
+int
+f3 (void)
+{
+ unsigned char a = 128;
+ return (a & 0x80) ? 0x380 : 0;
+}
+
+int
+f4 (void)
+{
+ unsigned char a = 128;
+ return (a & 0x80) ? -128 : 0;
+}
+
+long long
+f5 (void)
+{
+ long long a = 0x80000000LL;
+ return (a & 0x80000000) ? 0x80000000LL : 0LL;
+}
+
+long long
+f6 (void)
+{
+ unsigned int a = 0x80000000;
+ return (a & 0x80000000) ? 0x80000000LL : 0LL;
+}
+
+long long
+f7 (void)
+{
+ unsigned int a = 0x80000000;
+ return (a & 0x80000000) ? 0x380000000LL : 0LL;
+}
+
+long long
+f8 (void)
+{
+ unsigned int a = 0x80000000;
+ return (a & 0x80000000) ? -2147483648LL : 0LL;
+}
+
+int
+main (void)
+{
+ if ((char) 128 != -128 || (int) 0x80000000 != -2147483648)
+ return 0;
+ if (f1 () != 128)
+ abort ();
+ if (f2 () != 128)
+ abort ();
+ if (f3 () != 896)
+ abort ();
+ if (f4 () != -128)
+ abort ();
+ if (f5 () != 0x80000000LL)
+ abort ();
+ if (f6 () != 0x80000000LL)
+ abort ();
+ if (f7 () != 0x380000000LL)
+ abort ();
+ if (f8 () != -2147483648LL)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29695-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29695-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29695-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29695-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,80 @@
+/* PR middle-end/29695 */
+
+extern void abort (void);
+
+int a = 128;
+unsigned char b = 128;
+long long c = 0x80000000LL;
+unsigned int d = 0x80000000;
+
+int
+f1 (void)
+{
+ return (a & 0x80) ? 0x80 : 0;
+}
+
+int
+f2 (void)
+{
+ return (b & 0x80) ? 0x80 : 0;
+}
+
+int
+f3 (void)
+{
+ return (b & 0x80) ? 0x380 : 0;
+}
+
+int
+f4 (void)
+{
+ return (b & 0x80) ? -128 : 0;
+}
+
+long long
+f5 (void)
+{
+ return (c & 0x80000000) ? 0x80000000LL : 0LL;
+}
+
+long long
+f6 (void)
+{
+ return (d & 0x80000000) ? 0x80000000LL : 0LL;
+}
+
+long long
+f7 (void)
+{
+ return (d & 0x80000000) ? 0x380000000LL : 0LL;
+}
+
+long long
+f8 (void)
+{
+ return (d & 0x80000000) ? -2147483648LL : 0LL;
+}
+
+int
+main (void)
+{
+ if ((char) 128 != -128 || (int) 0x80000000 != -2147483648)
+ return 0;
+ if (f1 () != 128)
+ abort ();
+ if (f2 () != 128)
+ abort ();
+ if (f3 () != 896)
+ abort ();
+ if (f4 () != -128)
+ abort ();
+ if (f5 () != 0x80000000LL)
+ abort ();
+ if (f6 () != 0x80000000LL)
+ abort ();
+ if (f7 () != 0x380000000LL)
+ abort ();
+ if (f8 () != -2147483648LL)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29797-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29797-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29797-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29797-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+/* { dg-require-effective-target int32plus } */
+extern void abort(void);
+
+unsigned int bar(void) { return 32768; }
+
+int main()
+{
+ unsigned int nStyle = bar ();
+ if (nStyle & 32768)
+ nStyle |= 65536;
+ if (nStyle != (32768 | 65536))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29797-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29797-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29797-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29797-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+extern void abort(void);
+
+unsigned long bar(void) { return 32768; }
+
+int main()
+{
+ unsigned long nStyle = bar ();
+ if (nStyle & 32768)
+ nStyle |= 65536;
+ if (nStyle != (32768 | 65536))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29798.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29798.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29798.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr29798.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+extern void abort ();
+
+int
+main ()
+{
+ int i;
+ double oldrho;
+ double beta = 0.0;
+ double work = 1.0;
+ for (i = 1; i <= 2; i++)
+ {
+ double rho = work * work;
+ if (i != 1)
+ beta = rho / oldrho;
+ if (beta == 1.0)
+ abort ();
+
+ /* All targets even remotely likely to ever get supported
+ use at least an even base, so there will never be any
+ floating-point rounding. All computation in this test
+ case is exact for even bases. */
+ work /= 2.0;
+ oldrho = rho;
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr30185.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr30185.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr30185.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr30185.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* PR target/30185 */
+
+extern void abort (void);
+
+typedef struct S { char a; long long b; } S;
+
+S
+foo (S x, S y)
+{
+ S z;
+ z.b = x.b / y.b;
+ return z;
+}
+
+int
+main (void)
+{
+ S a, b;
+ a.b = 32LL;
+ b.b = 4LL;
+ if (foo (a, b).b != 8LL)
+ abort ();
+ a.b = -8LL;
+ b.b = -2LL;
+ if (foo (a, b).b != 4LL)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr30778.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr30778.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr30778.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr30778.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,34 @@
+extern void *memset (void *, int, __SIZE_TYPE__);
+extern void abort (void);
+
+struct reg_stat {
+ void *last_death;
+ void *last_set;
+ void *last_set_value;
+ int last_set_label;
+ char last_set_sign_bit_copies;
+ int last_set_mode : 8;
+ char last_set_invalid;
+ char sign_bit_copies;
+ long nonzero_bits;
+};
+
+static struct reg_stat *reg_stat;
+
+void __attribute__((noinline))
+init_reg_last (void)
+{
+ memset (reg_stat, 0, __builtin_offsetof (struct reg_stat, sign_bit_copies));
+}
+
+int main (void)
+{
+ struct reg_stat r;
+
+ reg_stat = &r;
+ r.nonzero_bits = -1;
+ init_reg_last ();
+ if (r.nonzero_bits != -1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31072.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31072.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31072.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31072.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,10 @@
+extern volatile int ReadyFlag_NotProperlyInitialized;
+
+volatile int ReadyFlag_NotProperlyInitialized=1;
+
+int main(void)
+{
+ if (ReadyFlag_NotProperlyInitialized != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31136.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31136.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31136.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31136.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+extern void abort (void);
+
+struct S {
+ unsigned b4:4;
+ unsigned b6:6;
+} s;
+
+int main()
+{
+ s.b6 = 31;
+ s.b4 = s.b6;
+ s.b6 = s.b4;
+ if (s.b6 != 15)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31169.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31169.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31169.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31169.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,51 @@
+extern void abort();
+
+#define HOST_WIDE_INT long
+#define HOST_BITS_PER_WIDE_INT (sizeof(long)*8)
+
+struct tree_type
+{
+ unsigned int precision : 9;
+};
+
+int
+sign_bit_p (struct tree_type *t, HOST_WIDE_INT val_hi, unsigned HOST_WIDE_INT val_lo)
+{
+ unsigned HOST_WIDE_INT mask_lo, lo;
+ HOST_WIDE_INT mask_hi, hi;
+ int width = t->precision;
+
+ if (width > HOST_BITS_PER_WIDE_INT)
+ {
+ hi = (unsigned HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT - 1);
+ lo = 0;
+
+ mask_hi = ((unsigned HOST_WIDE_INT) -1
+ >> (2 * HOST_BITS_PER_WIDE_INT - width));
+ mask_lo = -1;
+ }
+ else
+ {
+ hi = 0;
+ lo = (unsigned HOST_WIDE_INT) 1 << (width - 1);
+
+ mask_hi = 0;
+ mask_lo = ((unsigned HOST_WIDE_INT) -1
+ >> (HOST_BITS_PER_WIDE_INT - width));
+ }
+
+ if ((val_hi & mask_hi) == hi
+ && (val_lo & mask_lo) == lo)
+ return 1;
+
+ return 0;
+}
+
+int main()
+{
+ struct tree_type t;
+ t.precision = 1;
+ if (!sign_bit_p (&t, 0, -1))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31448-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31448-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31448-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31448-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+/* PR middle-end/31448, this used to ICE during expand because
+ reduce_to_bit_field_precision was not ready to handle constants. */
+
+typedef struct _st {
+ long int iIndex : 24;
+ long int iIndex1 : 24;
+} st;
+st *next;
+void g(void)
+{
+ st *next = 0;
+ int nIndx;
+ const static int constreg[] = { 0,};
+ nIndx = 0;
+ next->iIndex = constreg[nIndx];
+}
+void f(void)
+{
+ int nIndx;
+ const static long int constreg[] = { 0xFEFEFEFE,};
+ nIndx = 0;
+ next->iIndex = constreg[nIndx];
+ next->iIndex1 = constreg[nIndx];
+}
+int main(void)
+{
+ st a;
+ next = &a;
+ f();
+ if (next->iIndex != 0xFFFEFEFE)
+ __builtin_abort ();
+ if (next->iIndex1 != 0xFFFEFEFE)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31448.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31448.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31448.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31448.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+/* PR middle-end/31448, this used to ICE during expand because
+ reduce_to_bit_field_precision was not ready to handle constants. */
+/* { dg-require-effective-target int32plus } */
+
+typedef struct _st {
+ int iIndex : 24;
+ int iIndex1 : 24;
+} st;
+st *next;
+void g(void)
+{
+ st *next = 0;
+ int nIndx;
+ const static int constreg[] = { 0,};
+ nIndx = 0;
+ next->iIndex = constreg[nIndx];
+}
+void f(void)
+{
+ int nIndx;
+ const static int constreg[] = { 0xFEFEFEFE,};
+ nIndx = 0;
+ next->iIndex = constreg[nIndx];
+ next->iIndex1 = constreg[nIndx];
+}
+int main(void)
+{
+ st a;
+ next = &a;
+ f();
+ if (next->iIndex != 0xFFFEFEFE)
+ __builtin_abort ();
+ if (next->iIndex1 != 0xFFFEFEFE)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31605.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31605.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31605.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr31605.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+void put_field (unsigned int start, unsigned int len)
+{
+ int cur_bitshift = ((start + len) % 8) - 8;
+ if (cur_bitshift > -8)
+ exit (0);
+}
+
+int
+main ()
+{
+ put_field (0, 1);
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr32244-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr32244-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr32244-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr32244-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+struct foo
+{
+ unsigned long long b:40;
+} x;
+
+extern void abort (void);
+
+void test1(unsigned long long res)
+{
+ /* The shift is carried out in 40 bit precision. */
+ if (x.b<<32 != res)
+ abort ();
+}
+
+int main()
+{
+ x.b = 0x0100;
+ test1(0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr32500.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr32500.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr32500.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr32500.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+extern void abort(void);
+extern void exit(int);
+void foo(int) __attribute__((noinline));
+void bar(void) __attribute__((noinline));
+
+/* Make sure foo is not inlined or considered pure/const. */
+int x;
+void foo(int i) { x = i; }
+void bar(void) { exit(0); }
+
+int
+main(int argc, char *argv[])
+{
+ int i;
+ int numbers[4] = { 0xdead, 0xbeef, 0x1337, 0x4242 };
+
+ for (i = 1; i <= 12; i++) {
+ if (i <= 4)
+ foo(numbers[i-1]);
+ else if (i >= 7 && i <= 9)
+ bar();
+ }
+
+ abort();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33142.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33142.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33142.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33142.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+int abs(int j);
+extern void abort(void);
+
+__attribute__((noinline)) int lisp_atan2(long dy, long dx) {
+ if (dx <= 0)
+ if (dy > 0)
+ return abs(dx) <= abs(dy);
+ return 0;
+}
+
+int main() {
+ volatile long dy = 63, dx = -77;
+ if (lisp_atan2(dy, dx))
+ abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33382.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33382.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33382.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33382.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+struct Foo {
+ int i;
+ int j[];
+};
+
+struct Foo x = { 1, { 2, 0, 2, 3 } };
+
+int foo(void)
+{
+ x.j[0] = 1;
+ return x.j[1];
+}
+
+extern void abort(void);
+
+int main()
+{
+ if (foo() != 0)
+ abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33631.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33631.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33631.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33631.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+typedef union
+{
+ int __lock;
+} pthread_mutex_t;
+
+extern void abort (void);
+
+int main()
+{
+ struct { int c; pthread_mutex_t m; } r = { .m = 0 };
+ if (r.c != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33669.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33669.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33669.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33669.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,40 @@
+extern void abort (void);
+
+typedef struct foo_t
+{
+ unsigned int blksz;
+ unsigned int bf_cnt;
+} foo_t;
+
+#define _RNDUP(x, unit) ((((x) + (unit) - 1) / (unit)) * (unit))
+#define _RNDDOWN(x, unit) ((x) - ((x)%(unit)))
+
+long long
+foo (foo_t *const pxp, long long offset, unsigned int extent)
+{
+ long long blkoffset = _RNDDOWN(offset, (long long )pxp->blksz);
+ unsigned int diff = (unsigned int)(offset - blkoffset);
+ unsigned int blkextent = _RNDUP(diff + extent, pxp->blksz);
+
+ if (pxp->blksz < blkextent)
+ return -1LL;
+
+ if (pxp->bf_cnt > pxp->blksz)
+ pxp->bf_cnt = pxp->blksz;
+
+ return blkoffset;
+}
+
+int
+main ()
+{
+ foo_t x;
+ long long xx;
+
+ x.blksz = 8192;
+ x.bf_cnt = 0;
+ xx = foo (&x, 0, 4096);
+ if (xx != 0LL)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33779-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33779-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33779-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33779-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+int foo(int i)
+{
+ if (((unsigned)(i + 1)) * 4 == 0)
+ return 1;
+ return 0;
+}
+
+extern void abort(void);
+int main()
+{
+ if (foo(0x3fffffff) == 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33779-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33779-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33779-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33779-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,12 @@
+int foo(int i)
+{
+ return ((int)((unsigned)(i + 1) * 4)) / 4;
+}
+
+extern void abort(void);
+int main()
+{
+ if (foo(0x3fffffff) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33870-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33870-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33870-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33870-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,94 @@
+extern void abort (void);
+
+typedef struct PgHdr PgHdr;
+typedef unsigned char u8;
+struct PgHdr {
+int y;
+struct {
+ unsigned int pgno;
+ PgHdr *pNextHash, *pPrevHash;
+ PgHdr *pNextFree, *pPrevFree;
+ PgHdr *pNextAll;
+ u8 inJournal;
+ short int nRef;
+ PgHdr *pDirty, *pPrevDirty;
+ unsigned int notUsed;
+} x;
+};
+PgHdr **xx;
+volatile int vx;
+static inline PgHdr *merge_pagelist(PgHdr *pA, PgHdr *pB)
+{
+ PgHdr result;
+ PgHdr *pTail;
+ xx = &result.x.pDirty;
+ pTail = &result;
+ while( pA && pB ){
+ if( pA->x.pgno<pB->x.pgno ){
+ pTail->x.pDirty = pA;
+ pTail = pA;
+ pA = pA->x.pDirty;
+ }else{
+ pTail->x.pDirty = pB;
+ pTail = pB;
+ pB = pB->x.pDirty;
+ }
+ vx = (*xx)->y;
+ }
+ if( pA ){
+ pTail->x.pDirty = pA;
+ }else if( pB ){
+ pTail->x.pDirty = pB;
+ }else{
+ pTail->x.pDirty = 0;
+ }
+ return result.x.pDirty;
+}
+
+PgHdr * __attribute__((noinline)) sort_pagelist(PgHdr *pIn)
+{
+ PgHdr *a[25], *p;
+ int i;
+ __builtin_memset (a, 0, sizeof (a));
+ while( pIn ){
+ p = pIn;
+ pIn = p->x.pDirty;
+ p->x.pDirty = 0;
+ for(i=0; i<25 -1; i++){
+ if( a[i]==0 ){
+ a[i] = p;
+ break;
+ }else{
+ p = merge_pagelist(a[i], p);
+ a[i] = 0;
+ a[i] = 0;
+ }
+ }
+ if( i==25 -1 ){
+ a[i] = merge_pagelist(a[i], p);
+ }
+ }
+ p = a[0];
+ for(i=1; i<25; i++){
+ p = merge_pagelist (p, a[i]);
+ }
+ return p;
+}
+
+int main()
+{
+ PgHdr a[5];
+ PgHdr *p;
+ a[0].x.pgno = 5;
+ a[0].x.pDirty = &a[1];
+ a[1].x.pgno = 4;
+ a[1].x.pDirty = &a[2];
+ a[2].x.pgno = 1;
+ a[2].x.pDirty = &a[3];
+ a[3].x.pgno = 3;
+ a[3].x.pDirty = 0;
+ p = sort_pagelist (&a[0]);
+ if (p->x.pDirty == p)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33870.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33870.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33870.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33870.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,87 @@
+extern void abort (void);
+
+typedef struct PgHdr PgHdr;
+typedef unsigned char u8;
+struct PgHdr {
+ unsigned int pgno;
+ PgHdr *pNextHash, *pPrevHash;
+ PgHdr *pNextFree, *pPrevFree;
+ PgHdr *pNextAll;
+ u8 inJournal;
+ short int nRef;
+ PgHdr *pDirty, *pPrevDirty;
+ unsigned int notUsed;
+};
+
+static inline PgHdr *merge_pagelist(PgHdr *pA, PgHdr *pB)
+{
+ PgHdr result;
+ PgHdr *pTail;
+ pTail = &result;
+ while( pA && pB ){
+ if( pA->pgno<pB->pgno ){
+ pTail->pDirty = pA;
+ pTail = pA;
+ pA = pA->pDirty;
+ }else{
+ pTail->pDirty = pB;
+ pTail = pB;
+ pB = pB->pDirty;
+ }
+ }
+ if( pA ){
+ pTail->pDirty = pA;
+ }else if( pB ){
+ pTail->pDirty = pB;
+ }else{
+ pTail->pDirty = 0;
+ }
+ return result.pDirty;
+}
+
+PgHdr * __attribute__((noinline)) sort_pagelist(PgHdr *pIn)
+{
+ PgHdr *a[25], *p;
+ int i;
+ __builtin_memset (a, 0, sizeof (a));
+ while( pIn ){
+ p = pIn;
+ pIn = p->pDirty;
+ p->pDirty = 0;
+ for(i=0; i<25 -1; i++){
+ if( a[i]==0 ){
+ a[i] = p;
+ break;
+ }else{
+ p = merge_pagelist(a[i], p);
+ a[i] = 0;
+ }
+ }
+ if( i==25 -1 ){
+ a[i] = merge_pagelist(a[i], p);
+ }
+ }
+ p = a[0];
+ for(i=1; i<25; i++){
+ p = merge_pagelist (p, a[i]);
+ }
+ return p;
+}
+
+int main()
+{
+ PgHdr a[5];
+ PgHdr *p;
+ a[0].pgno = 5;
+ a[0].pDirty = &a[1];
+ a[1].pgno = 4;
+ a[1].pDirty = &a[2];
+ a[2].pgno = 1;
+ a[2].pDirty = &a[3];
+ a[3].pgno = 3;
+ a[3].pDirty = 0;
+ p = sort_pagelist (&a[0]);
+ if (p->pDirty == p)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33992.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33992.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33992.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr33992.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,37 @@
+extern void abort ();
+
+void __attribute__((noinline))
+bar (unsigned long long i)
+{
+ if (i)
+ abort ();
+}
+
+static void __attribute__((always_inline))
+foo (unsigned long long *r)
+{
+ int i;
+
+ for (i = 0; ; i++)
+ if (*r & ((unsigned long long)1 << (63 - i)))
+ break;
+
+ bar (i);
+}
+
+void __attribute__((noinline))
+do_test (unsigned long long *r)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i)
+ foo (r);
+}
+
+int main()
+{
+ unsigned long long r = 0x8000000000000001ull;
+
+ do_test (&r);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34070-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34070-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34070-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34070-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+extern void abort (void);
+
+int f(unsigned int x)
+{
+ return ((int)x) % 4;
+}
+
+int main()
+{
+ if (f(-1) != -1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34070-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34070-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34070-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34070-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+extern void abort (void);
+
+int f(unsigned int x, int n)
+{
+ return ((int)x) / (1 << n);
+}
+
+int main()
+{
+ if (f(-1, 1) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34099-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34099-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34099-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34099-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,46 @@
+int test1 (int b, int c)
+{
+ char x;
+ if (b)
+ return x / c;
+ else
+ return 1;
+}
+int test2 (int b, int c)
+{
+ int x;
+ if (b)
+ return x * c;
+ else
+ return 1;
+}
+int test3 (int b, int c)
+{
+ int x;
+ if (b)
+ return x % c;
+ else
+ return 1;
+}
+int test4 (int b, int c)
+{
+ char x;
+ if (b)
+ return x == c;
+ else
+ return 1;
+}
+
+extern void abort (void);
+int main()
+{
+ if (test1(1, 1000) != 0)
+ abort ();
+ if (test2(1, 0) != 0)
+ abort ();
+ if (test3(1, 1) != 0)
+ abort ();
+ if (test4(1, 1000) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34099.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34099.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34099.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34099.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+int foo (int b, int c)
+{
+ int x;
+ if (b)
+ return x & c;
+ else
+ return 1;
+}
+extern void abort (void);
+int main()
+{
+ if (foo(1, 0) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34130.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34130.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34130.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34130.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,12 @@
+extern void abort (void);
+int foo (int i)
+{
+ return -2 * __builtin_abs(i - 2);
+}
+int main()
+{
+ if (foo(1) != -2
+ || foo(3) != -2)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34154.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34154.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34154.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34154.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+int foo( unsigned long long aLL )
+{
+ switch( aLL )
+ {
+ case 1000000000000000000ULL ... 9999999999999999999ULL : return 19 ;
+ default : return 20 ;
+ };
+};
+extern void abort (void);
+int main()
+{
+ unsigned long long aLL = 1000000000000000000ULL;
+ if (foo (aLL) != 19)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34176.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34176.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34176.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34176.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,68 @@
+
+typedef __SIZE_TYPE__ size_t;
+typedef unsigned int index_ty;
+typedef index_ty *index_list_ty;
+
+struct mult_index
+{
+ index_ty index;
+ unsigned int count;
+};
+
+struct mult_index_list
+{
+ struct mult_index *item;
+ size_t nitems;
+ size_t nitems_max;
+
+ struct mult_index *item2;
+ size_t nitems2_max;
+};
+
+int __attribute__((noinline))
+hash_find_entry (size_t *result)
+{
+ *result = 2;
+ return 0;
+}
+
+extern void abort (void);
+struct mult_index * __attribute__((noinline))
+foo (size_t n)
+{
+ static count = 0;
+ if (count++ > 0)
+ abort ();
+ return 0;
+}
+
+int
+main (void)
+{
+ size_t nitems = 0;
+
+ for (;;)
+ {
+ size_t list;
+
+ hash_find_entry (&list);
+ {
+ size_t len2 = list;
+ struct mult_index *destptr;
+ struct mult_index *dest;
+ size_t new_max = nitems + len2;
+
+ if (new_max != len2)
+ break;
+ dest = foo (new_max);
+
+ destptr = dest;
+ while (len2--)
+ destptr++;
+
+ nitems = destptr - dest;
+ }
+ }
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34415.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34415.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34415.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34415.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,34 @@
+const char *__attribute__((noinline))
+foo (const char *p)
+{
+ const char *end;
+ int len = 1;
+ for (;;)
+ {
+ int c = *p;
+ c = (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c);
+ if (c == 'B')
+ end = p;
+ else if (c == 'A')
+ {
+ end = p;
+ do
+ p++;
+ while (*p == '+');
+ }
+ else
+ break;
+ p++;
+ len++;
+ }
+ if (len > 2 && *p == ':')
+ p = end;
+ return p;
+}
+
+int
+main (void)
+{
+ const char *input = "Bbb:";
+ return foo (input) != input + 2;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34456.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34456.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34456.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34456.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+/* { dg-skip-if "requires qsort" { freestanding } } */
+
+#include <stdlib.h>
+
+int __attribute__ ((noinline)) debug (void) { return 1; }
+int errors;
+
+struct s { int elt; int (*compare) (int); };
+
+static int
+compare (const void *x, const void *y)
+{
+ const struct s *s1 = x, *s2 = y;
+ int (*compare1) (int);
+ int elt2;
+
+ compare1 = s1->compare;
+ elt2 = s2->elt;
+ if (elt2 != 0 && debug () && compare1 (s1->elt) != 0)
+ errors++;
+ return compare1 (elt2);
+}
+
+int bad_compare (int x) { return -x; }
+struct s array[2] = { { 1, bad_compare }, { -1, bad_compare } };
+
+int
+main (void)
+{
+ qsort (array, 2, sizeof (struct s), compare);
+ return errors == 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34768-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34768-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34768-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34768-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+int x;
+
+void __attribute__((noinline)) foo (void)
+{
+ x = -x;
+}
+void __attribute__((const,noinline)) bar (void)
+{
+}
+
+int __attribute__((noinline))
+test (int c)
+{
+ int tmp = x;
+ (c ? foo : bar) ();
+ return tmp + x;
+}
+
+extern void abort (void);
+int main()
+{
+ x = 1;
+ if (test (1) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34768-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34768-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34768-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34768-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+int x;
+
+int __attribute__((noinline)) foo (void)
+{
+ x = -x;
+ return 0;
+}
+int __attribute__((const,noinline)) bar (void)
+{
+ return 0;
+}
+
+int __attribute__((noinline))
+test (int c)
+{
+ int tmp = x;
+ int res = (c ? foo : bar) ();
+ return tmp + x + res;
+}
+
+extern void abort (void);
+int main()
+{
+ x = 1;
+ if (test (1) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34971.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34971.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34971.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34971.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+struct foo
+{
+ unsigned long long b:40;
+} x;
+
+extern void abort (void);
+
+void test1(unsigned long long res)
+{
+ /* Build a rotate expression on a 40 bit argument. */
+ if ((x.b<<8) + (x.b>>32) != res)
+ abort ();
+}
+
+int main()
+{
+ x.b = 0x0100000001;
+ test1(0x0000000101);
+ x.b = 0x0100000000;
+ test1(0x0000000001);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34982.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34982.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34982.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr34982.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+extern void abort (void);
+
+static void something();
+
+int main()
+{
+ something(-1);
+ return 0;
+}
+
+static void something(int i)
+{
+ if (i != -1)
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35163.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35163.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35163.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35163.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+extern void abort(void);
+
+int main()
+{
+ signed char a = -30;
+ signed char b = -31;
+ #if(__SIZEOF_INT__ >= 4)
+ if (a > (unsigned short)b)
+#else
+ if ((long) a > (unsigned short)b)
+#endif
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35231.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35231.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35231.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35231.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+extern void abort(void);
+
+int __attribute__((noinline))
+foo(int bits_per_pixel, int depth)
+{
+ if ((bits_per_pixel | depth) == 1)
+ abort ();
+ return bits_per_pixel;
+}
+
+int main()
+{
+ if (foo(2, 0) != 2)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35390.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35390.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35390.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35390.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+extern void abort (void);
+
+unsigned int foo (int n)
+{
+ return ~((unsigned int)~n);
+}
+
+int main()
+{
+ if (foo(0) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35456.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35456.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35456.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35456.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* { dg-skip-if "signed zero not supported" { "vax-*-*" } } */
+extern void abort (void);
+
+double
+__attribute__ ((noinline))
+not_fabs (double x)
+{
+ return x >= 0.0 ? x : -x;
+}
+
+int main()
+{
+ double x = -0.0;
+ double y;
+
+ y = not_fabs (x);
+
+ if (!__builtin_signbit (y))
+ abort();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35472.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35472.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35472.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35472.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+extern void abort (void);
+extern void *memset (void *s, int c, __SIZE_TYPE__ n);
+struct S { int i[16]; };
+struct S *p;
+void __attribute__((noinline,noclone))
+foo(struct S *a, struct S *b) { a->i[0] = -1; p = b; }
+void test (void)
+{
+ struct S a, b;
+ memset (&a.i[0], '\0', sizeof (a.i));
+ memset (&b.i[0], '\0', sizeof (b.i));
+ foo (&a, &b);
+ *p = a;
+ *p = b;
+ if (b.i[0] != -1)
+ abort ();
+}
+int main()
+{
+ test();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35800.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35800.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35800.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr35800.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,103 @@
+extern void abort (void);
+
+int stab_xcoff_builtin_type (int typenum)
+{
+ const char *name;
+ if (typenum >= 0 || typenum < -34)
+ {
+ return 0;
+ }
+ switch (-typenum)
+ {
+ case 1:
+ name = "int";
+ break;
+ case 2:
+ name = "char";
+ case 3:
+ name = "short";
+ break;
+ case 4:
+ name = "long";
+ case 5:
+ name = "unsigned char";
+ case 6:
+ name = "signed char";
+ case 7:
+ name = "unsigned short";
+ case 8:
+ name = "unsigned int";
+ case 9:
+ name = "unsigned";
+ case 10:
+ name = "unsigned long";
+ case 11:
+ name = "void";
+ case 12:
+ name = "float";
+ case 13:
+ name = "double";
+ case 14:
+ name = "long double";
+ case 15:
+ name = "integer";
+ case 16:
+ name = "boolean";
+ case 17:
+ name = "short real";
+ case 18:
+ name = "real";
+ case 19:
+ name = "stringptr";
+ case 20:
+ name = "character";
+ case 21:
+ name = "logical*1";
+ case 22:
+ name = "logical*2";
+ case 23:
+ name = "logical*4";
+ case 24:
+ name = "logical";
+ case 25:
+ name = "complex";
+ case 26:
+ name = "double complex";
+ case 27:
+ name = "integer*1";
+ case 28:
+ name = "integer*2";
+ case 29:
+ name = "integer*4";
+ case 30:
+ name = "wchar";
+ case 31:
+ name = "long long";
+ case 32:
+ name = "unsigned long long";
+ case 33:
+ name = "logical*8";
+ case 34:
+ name = "integer*8";
+ }
+ return name[0];
+}
+
+int main()
+{
+ int i;
+ if (stab_xcoff_builtin_type(0) != 0)
+ abort ();
+ if (stab_xcoff_builtin_type(-1) != 'i')
+ abort ();
+ if (stab_xcoff_builtin_type(-2) != 's')
+ abort ();
+ if (stab_xcoff_builtin_type(-3) != 's')
+ abort ();
+ for (i = -4; i >= -34; --i)
+ if (stab_xcoff_builtin_type(i) != 'i')
+ abort ();
+ if (stab_xcoff_builtin_type(-35) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36034-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36034-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36034-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36034-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+double x[5][10] = { { 10, 11, 12, 13, 14, 15, -1, -1, -1, -1 },
+ { 21, 22, 23, 24, 25, 26, -1, -1, -1, -1 },
+ { 32, 33, 34, 35, 36, 37, -1, -1, -1, -1 },
+ { 43, 44, 45, 46, 47, 48, -1, -1, -1, -1 },
+ { 54, 55, 56, 57, 58, 59, -1, -1, -1, -1 } };
+double tmp[5][6];
+
+void __attribute__((noinline))
+test (void)
+{
+ int i, j;
+ for (i = 0; i < 5; ++i)
+ {
+ tmp[i][0] = x[i][0];
+ tmp[i][1] = x[i][1];
+ tmp[i][2] = x[i][2];
+ tmp[i][3] = x[i][3];
+ tmp[i][4] = x[i][4];
+ tmp[i][5] = x[i][5];
+ }
+}
+extern void abort (void);
+int main()
+{
+ int i, j;
+ test();
+ for (i = 0; i < 5; ++i)
+ for (j = 0; j < 6; ++j)
+ if (tmp[i][j] == -1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36034-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36034-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36034-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36034-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+double x[50] = { 10, 11, 12, 13, 14, 15, -1, -1, -1, -1,
+ 21, 22, 23, 24, 25, 26, -1, -1, -1, -1,
+ 32, 33, 34, 35, 36, 37, -1, -1, -1, -1,
+ 43, 44, 45, 46, 47, 48, -1, -1, -1, -1,
+ 54, 55, 56, 57, 58, 59, -1, -1, -1, -1 };
+double tmp[30];
+
+void __attribute__((noinline))
+test (void)
+{
+ int i, j;
+ for (i = 0; i < 5; ++i)
+ {
+ tmp[i*6] = x[i*10];
+ tmp[i*6+1] = x[i*10+1];
+ tmp[i*6+2] = x[i*10+2];
+ tmp[i*6+3] = x[i*10+3];
+ tmp[i*6+4] = x[i*10+4];
+ tmp[i*6+5] = x[i*10+5];
+ }
+}
+extern void abort (void);
+int main()
+{
+ int i, j;
+ test();
+ for (i = 0; i < 5; ++i)
+ for (j = 0; j < 6; ++j)
+ if (tmp[i*6+j] == -1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36038.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36038.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36038.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36038.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,43 @@
+/* PR tree-optimization/36038 */
+
+long long list[10];
+long long expect[10] = { 0, 1, 2, 3, 4, 4, 5, 6, 7, 9 };
+long long *stack_base;
+int indices[10];
+int *markstack_ptr;
+
+void
+doit (void)
+{
+ long long *src;
+ long long *dst;
+ long long *sp = stack_base + 5;
+ int diff = 2;
+ int shift;
+ int count;
+
+ shift = diff - (markstack_ptr[-1] - markstack_ptr[-2]);
+ count = (sp - stack_base) - markstack_ptr[-1] + 2;
+ src = sp;
+ dst = (sp += shift);
+ while (--count)
+ *dst-- = *src--;
+}
+
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ list[i] = i;
+
+ markstack_ptr = indices + 9;
+ markstack_ptr[-1] = 2;
+ markstack_ptr[-2] = 1;
+
+ stack_base = list + 2;
+ doit ();
+ if (__builtin_memcmp (expect, list, sizeof (list)))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36077.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36077.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36077.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36077.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+extern void abort (void);
+
+unsigned int test (unsigned int x)
+{
+ return x / 0x80000001U / 0x00000002U;
+}
+
+int main()
+{
+ if (test(2) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36093.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36093.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36093.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36093.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* { dg-skip-if "small alignment" { pdp11-*-* } } */
+
+extern void abort (void);
+
+typedef struct Bar {
+ char c[129];
+} Bar __attribute__((__aligned__(128)));
+
+typedef struct Foo {
+ Bar bar[4];
+} Foo;
+
+Foo foo[4];
+
+int main()
+{
+ int i, j;
+ Foo *foop = &foo[0];
+
+ for (i=0; i < 4; i++) {
+ Bar *bar = &foop->bar[i];
+ for (j=0; j < 129; j++) {
+ bar->c[j] = 'a' + i;
+ }
+ }
+
+ if (foo[0].bar[3].c[128] != 'd')
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36321.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36321.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36321.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36321.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* { dg-skip-if "requires alloca" { ! alloca } { "-O0" } { "" } } */
+extern void abort (void);
+
+extern __SIZE_TYPE__ strlen (const char *);
+void foo(char *str)
+{
+ int len2 = strlen (str);
+ char *a = (char *) __builtin_alloca (0);
+ char *b = (char *) __builtin_alloca (len2*3);
+
+ if ((int) (a-b) < (len2*3))
+ {
+#ifdef _WIN32
+ abort ();
+#endif
+ return;
+ }
+}
+
+static char * volatile argp = "pr36321.x";
+
+int main(int argc, char **argv)
+{
+ foo (argp);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36339.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36339.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36339.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36339.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+extern void abort (void);
+
+typedef unsigned long my_uintptr_t;
+
+int check_a(my_uintptr_t tagged_ptr);
+
+int __attribute__((noinline)) try_a(my_uintptr_t x)
+{
+ my_uintptr_t heap[2];
+ my_uintptr_t *hp = heap;
+
+ hp[0] = x;
+ hp[1] = 0;
+ return check_a((my_uintptr_t)(void*)((char*)hp + 1));
+}
+
+int __attribute__((noinline)) check_a(my_uintptr_t tagged_ptr)
+{
+ my_uintptr_t *hp = (my_uintptr_t*)(void*)((char*)tagged_ptr - 1);
+
+ if (hp[0] == 42 && hp[1] == 0)
+ return 0;
+ return -1;
+}
+
+int main(void)
+{
+ if (try_a(42) < 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36343.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36343.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36343.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36343.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+extern void abort (void);
+
+void __attribute__((noinline))
+bar (int **p)
+{
+ float *q = (float *)p;
+ *q = 0.0;
+}
+
+float __attribute__((noinline))
+foo (int b)
+{
+ int *i = 0;
+ float f = 1.0;
+ int **p;
+ if (b)
+ p = &i;
+ else
+ p = (int **)&f;
+ bar (p);
+ if (b)
+ return **p;
+ return f;
+}
+
+int main()
+{
+ if (foo(0) != 0.0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36691.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36691.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36691.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36691.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+unsigned char g_5;
+
+void func_1 (void)
+{
+ for (g_5 = 9; g_5 >= 4; g_5 -= 5)
+ ;
+}
+
+extern void abort (void);
+int main (void)
+{
+ func_1 ();
+ if (g_5 != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36765.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36765.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36765.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr36765.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+int __attribute__((noinline))
+foo(int i)
+{
+ int *p = __builtin_malloc (4 * sizeof(int));
+ *p = 0;
+ p[i] = 1;
+ return *p;
+}
+extern void abort (void);
+int main()
+{
+ if (foo(0) != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37102.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37102.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37102.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37102.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+extern void abort (void);
+
+unsigned int a, b = 1, c;
+
+void __attribute__ ((noinline))
+foo (int x)
+{
+ if (x != 5)
+ abort ();
+}
+
+int
+main ()
+{
+ unsigned int d, e;
+ for (d = 1; d < 5; d++)
+ if (c)
+ a = b;
+ a = b;
+ e = a << 1;
+ if (e)
+ e = (e << 1) ^ 1;
+ foo (e);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37125.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37125.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37125.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37125.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+extern void abort (void);
+
+static inline unsigned int
+mod_rhs(int rhs)
+{
+ if (rhs == 0) return 1;
+ return rhs;
+}
+
+void func_44 (unsigned int p_45);
+void func_44 (unsigned int p_45)
+{
+ if (!((p_45 * -9) % mod_rhs (-9))) {
+ abort();
+ }
+}
+
+int main (void)
+{
+ func_44 (2);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37573.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37573.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37573.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37573.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,65 @@
+/* PR tree-optimization/37573 */
+/* { dg-require-effective-target int32plus } */
+
+struct S
+{
+ unsigned int *a;
+ unsigned int b;
+ unsigned int c[624];
+};
+
+static unsigned char __attribute__((noinline))
+foo (struct S *s)
+{
+ unsigned int r;
+ if (!--s->b)
+ {
+ unsigned int *c = s->c;
+ unsigned int i;
+ s->a = c;
+ for (i = 0; i < 227; i++)
+ c[i] = ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1)
+ ^ ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i + 397];
+ }
+ r = *(s->a++);
+ r ^= (r >> 11);
+ r ^= ((r & 0xff3a58ad) << 7);
+ r ^= ((r & 0xffffdf8c) << 15);
+ r ^= (r >> 18);
+ return (unsigned char) (r >> 1);
+}
+
+static void __attribute__((noinline))
+bar (unsigned char *p, unsigned int q, unsigned int r)
+{
+ struct S s;
+ unsigned int i;
+ unsigned int *c = s.c;
+ *c = r;
+ for (i = 1; i < 624; i++)
+ c[i] = i + 0x6c078965 * ((c[i - 1] >> 30) ^ c[i - 1]);
+ s.b = 1;
+ while (q--)
+ *p++ ^= foo (&s);
+};
+
+static unsigned char p[23] = {
+ 0xc0, 0x49, 0x17, 0x32, 0x62, 0x1e, 0x2e, 0xd5, 0x4c, 0x19, 0x28, 0x49,
+ 0x91, 0xe4, 0x72, 0x83, 0x91, 0x3d, 0x93, 0x83, 0xb3, 0x61, 0x38
+};
+
+static unsigned char q[23] = {
+ 0x3e, 0x41, 0x55, 0x54, 0x4f, 0x49, 0x54, 0x20, 0x55, 0x4e, 0x49, 0x43,
+ 0x4f, 0x44, 0x45, 0x20, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x3c
+};
+
+int
+main (void)
+{
+ unsigned int s;
+ s = 23;
+ bar (p, s, s + 0xa25e);
+ if (__builtin_memcmp (p, q, s) != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37780.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37780.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37780.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37780.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,49 @@
+/* PR middle-end/37780. */
+
+#define VAL (8 * sizeof (int))
+
+int __attribute__ ((noinline, noclone))
+fooctz (int i)
+{
+ return (i == 0) ? VAL : __builtin_ctz (i);
+}
+
+int __attribute__ ((noinline, noclone))
+fooctz2 (int i)
+{
+ return (i != 0) ? __builtin_ctz (i) : VAL;
+}
+
+unsigned int __attribute__ ((noinline, noclone))
+fooctz3 (unsigned int i)
+{
+ return (i > 0) ? __builtin_ctz (i) : VAL;
+}
+
+int __attribute__ ((noinline, noclone))
+fooclz (int i)
+{
+ return (i == 0) ? VAL : __builtin_clz (i);
+}
+
+int __attribute__ ((noinline, noclone))
+fooclz2 (int i)
+{
+ return (i != 0) ? __builtin_clz (i) : VAL;
+}
+
+unsigned int __attribute__ ((noinline, noclone))
+fooclz3 (unsigned int i)
+{
+ return (i > 0) ? __builtin_clz (i) : VAL;
+}
+
+int
+main (void)
+{
+ if (fooctz (0) != VAL || fooctz2 (0) != VAL || fooctz3 (0) != VAL
+ || fooclz (0) != VAL || fooclz2 (0) != VAL || fooclz3 (0) != VAL)
+ __builtin_abort ();
+
+ return 0;
+}
\ No newline at end of file
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37882.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37882.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37882.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37882.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+/* PR middle-end/37882 */
+
+struct S
+{
+ unsigned char b : 3;
+} s;
+
+int
+main ()
+{
+ s.b = 4;
+ if (s.b > 0 && s.b < 4)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37924.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37924.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37924.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37924.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,50 @@
+/* PR c/37924 */
+
+extern void abort (void);
+
+signed char a;
+unsigned char b;
+
+int
+test1 (void)
+{
+ int c = -1;
+ return ((unsigned int) (a ^ c)) >> 9;
+}
+
+int
+test2 (void)
+{
+ int c = -1;
+ return ((unsigned int) (b ^ c)) >> 9;
+}
+
+int
+main (void)
+{
+ a = 0;
+ if (test1 () != (-1U >> 9))
+ abort ();
+ a = 0x40;
+ if (test1 () != (-1U >> 9))
+ abort ();
+ a = 0x80;
+ if (test1 () != (a < 0) ? 0 : (-1U >> 9))
+ abort ();
+ a = 0xff;
+ if (test1 () != (a < 0) ? 0 : (-1U >> 9))
+ abort ();
+ b = 0;
+ if (test2 () != (-1U >> 9))
+ abort ();
+ b = 0x40;
+ if (test2 () != (-1U >> 9))
+ abort ();
+ b = 0x80;
+ if (test2 () != (-1U >> 9))
+ abort ();
+ b = 0xff;
+ if (test2 () != (-1U >> 9))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37931.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37931.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37931.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr37931.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* PR middle-end/37931 */
+
+extern void abort (void);
+
+int
+foo (int a, unsigned int b)
+{
+ return (a | 1) & (b | 1);
+}
+
+int
+main (void)
+{
+ if (foo (6, 0xc6) != 7)
+ abort ();
+ if (foo (0x80, 0xc1) != 0x81)
+ abort ();
+ if (foo (4, 4) != 5)
+ abort ();
+ if (foo (5, 4) != 5)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38048-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38048-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38048-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38048-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+extern void abort(void);
+
+int foo ()
+{
+ int mat[2][1];
+ int (*a)[1] = mat;
+ int det = 0;
+ int i;
+ mat[0][0] = 1;
+ mat[1][0] = 2;
+ for (i = 0; i < 2; ++i)
+ det += a[i][0];
+ return det;
+}
+
+int main()
+{
+ if (foo () != 3)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38048-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38048-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38048-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38048-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+extern void abort (void);
+
+static int inv_J(int a[][2])
+{
+ int i, j;
+ int det = 0.0;
+ for (j=0; j<2; ++j)
+ det += a[j][0] + a[j][1];
+ return det;
+}
+
+int foo()
+{
+ int mat[2][2];
+ mat[0][0] = 1;
+ mat[0][1] = 2;
+ mat[1][0] = 4;
+ mat[1][1] = 8;
+ return inv_J(mat);
+}
+
+int main()
+{
+ if (foo () != 15)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38051.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38051.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38051.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38051.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,215 @@
+typedef __SIZE_TYPE__ size_t;
+static int mymemcmp1 (unsigned long int, unsigned long int)
+ __attribute__ ((__nothrow__));
+
+__inline static int
+mymemcmp1 (unsigned long int a, unsigned long int b)
+{
+ long int srcp1 = (long int) &a;
+ long int srcp2 = (long int) &b;
+ unsigned long int a0, b0;
+ do
+ {
+ a0 = ((unsigned char *) srcp1)[0];
+ b0 = ((unsigned char *) srcp2)[0];
+ srcp1 += 1;
+ srcp2 += 1;
+ }
+ while (a0 == b0);
+ return a0 - b0;
+}
+
+static int mymemcmp2 (long, long, size_t) __attribute__ ((__nothrow__));
+
+static int
+mymemcmp2 (long int srcp1, long int srcp2, size_t len)
+{
+ unsigned long int a0, a1;
+ unsigned long int b0, b1;
+ switch (len % 4)
+ {
+ default:
+ case 2:
+ a0 = ((unsigned long int *) srcp1)[0];
+ b0 = ((unsigned long int *) srcp2)[0];
+ srcp1 -= 2 * (sizeof (unsigned long int));
+ srcp2 -= 2 * (sizeof (unsigned long int));
+ len += 2;
+ goto do1;
+ case 3:
+ a1 = ((unsigned long int *) srcp1)[0];
+ b1 = ((unsigned long int *) srcp2)[0];
+ srcp1 -= (sizeof (unsigned long int));
+ srcp2 -= (sizeof (unsigned long int));
+ len += 1;
+ goto do2;
+ case 0:
+ if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)
+ return 0;
+ a0 = ((unsigned long int *) srcp1)[0];
+ b0 = ((unsigned long int *) srcp2)[0];
+ goto do3;
+ case 1:
+ a1 = ((unsigned long int *) srcp1)[0];
+ b1 = ((unsigned long int *) srcp2)[0];
+ srcp1 += (sizeof (unsigned long int));
+ srcp2 += (sizeof (unsigned long int));
+ len -= 1;
+ if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)
+ goto do0;
+ }
+ do
+ {
+ a0 = ((unsigned long int *) srcp1)[0];
+ b0 = ((unsigned long int *) srcp2)[0];
+ if (a1 != b1)
+ return mymemcmp1 ((a1), (b1));
+ do3:
+ a1 = ((unsigned long int *) srcp1)[1];
+ b1 = ((unsigned long int *) srcp2)[1];
+ if (a0 != b0)
+ return mymemcmp1 ((a0), (b0));
+ do2:
+ a0 = ((unsigned long int *) srcp1)[2];
+ b0 = ((unsigned long int *) srcp2)[2];
+ if (a1 != b1)
+ return mymemcmp1 ((a1), (b1));
+ do1:
+ a1 = ((unsigned long int *) srcp1)[3];
+ b1 = ((unsigned long int *) srcp2)[3];
+ if (a0 != b0)
+ return mymemcmp1 ((a0), (b0));
+ srcp1 += 4 * (sizeof (unsigned long int));
+ srcp2 += 4 * (sizeof (unsigned long int));
+ len -= 4;
+ }
+ while (len != 0);
+do0:
+ if (a1 != b1)
+ return mymemcmp1 ((a1), (b1));
+ return 0;
+}
+
+static int mymemcmp3 (long, long, size_t) __attribute__ ((__nothrow__));
+
+static int
+mymemcmp3 (long int srcp1, long int srcp2, size_t len)
+{
+ unsigned long int a0, a1, a2, a3;
+ unsigned long int b0, b1, b2, b3;
+ unsigned long int x;
+ int shl, shr;
+ shl = 8 * (srcp1 % (sizeof (unsigned long int)));
+ shr = 8 * (sizeof (unsigned long int)) - shl;
+ srcp1 &= -(sizeof (unsigned long int));
+ switch (len % 4)
+ {
+ default:
+ case 2:
+ a1 = ((unsigned long int *) srcp1)[0];
+ a2 = ((unsigned long int *) srcp1)[1];
+ b2 = ((unsigned long int *) srcp2)[0];
+ srcp1 -= 1 * (sizeof (unsigned long int));
+ srcp2 -= 2 * (sizeof (unsigned long int));
+ len += 2;
+ goto do1;
+ case 3:
+ a0 = ((unsigned long int *) srcp1)[0];
+ a1 = ((unsigned long int *) srcp1)[1];
+ b1 = ((unsigned long int *) srcp2)[0];
+ srcp2 -= 1 * (sizeof (unsigned long int));
+ len += 1;
+ goto do2;
+ case 0:
+ if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)
+ return 0;
+ a3 = ((unsigned long int *) srcp1)[0];
+ a0 = ((unsigned long int *) srcp1)[1];
+ b0 = ((unsigned long int *) srcp2)[0];
+ srcp1 += 1 * (sizeof (unsigned long int));
+ goto do3;
+ case 1:
+ a2 = ((unsigned long int *) srcp1)[0];
+ a3 = ((unsigned long int *) srcp1)[1];
+ b3 = ((unsigned long int *) srcp2)[0];
+ srcp1 += 2 * (sizeof (unsigned long int));
+ srcp2 += 1 * (sizeof (unsigned long int));
+ len -= 1;
+ if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)
+ goto do0;
+ }
+ do
+ {
+ a0 = ((unsigned long int *) srcp1)[0];
+ b0 = ((unsigned long int *) srcp2)[0];
+ x = (((a2) >> (shl)) | ((a3) << (shr)));
+ if (x != b3)
+ return mymemcmp1 ((x), (b3));
+ do3:
+ a1 = ((unsigned long int *) srcp1)[1];
+ b1 = ((unsigned long int *) srcp2)[1];
+ x = (((a3) >> (shl)) | ((a0) << (shr)));
+ if (x != b0)
+ return mymemcmp1 ((x), (b0));
+ do2:
+ a2 = ((unsigned long int *) srcp1)[2];
+ b2 = ((unsigned long int *) srcp2)[2];
+ x = (((a0) >> (shl)) | ((a1) << (shr)));
+ if (x != b1)
+ return mymemcmp1 ((x), (b1));
+ do1:
+ a3 = ((unsigned long int *) srcp1)[3];
+ b3 = ((unsigned long int *) srcp2)[3];
+ x = (((a1) >> (shl)) | ((a2) << (shr)));
+ if (x != b2)
+ return mymemcmp1 ((x), (b2));
+ srcp1 += 4 * (sizeof (unsigned long int));
+ srcp2 += 4 * (sizeof (unsigned long int));
+ len -= 4;
+ }
+ while (len != 0);
+do0:
+ x = (((a2) >> (shl)) | ((a3) << (shr)));
+ if (x != b3)
+ return mymemcmp1 ((x), (b3));
+ return 0;
+}
+
+__attribute__ ((noinline))
+int mymemcmp (const void *s1, const void *s2, size_t len)
+{
+ unsigned long int a0;
+ unsigned long int b0;
+ long int srcp1 = (long int) s1;
+ long int srcp2 = (long int) s2;
+ if (srcp1 % (sizeof (unsigned long int)) == 0)
+ return mymemcmp2 (srcp1, srcp2, len / (sizeof (unsigned long int)));
+ else
+ return mymemcmp3 (srcp1, srcp2, len / (sizeof (unsigned long int)));
+}
+
+char buf[256];
+
+int
+main (void)
+{
+ char *p;
+ union { long int l; char c[sizeof (long int)]; } u;
+
+ /* The test above assumes little endian and long being the same size
+ as pointer. */
+ if (sizeof (long int) != sizeof (void *) || sizeof (long int) < 4)
+ return 0;
+ u.l = 0x12345678L;
+ if (u.c[0] != 0x78 || u.c[1] != 0x56 || u.c[2] != 0x34 || u.c[3] != 0x12)
+ return 0;
+
+ p = buf + 16 - (((long int) buf) & 15);
+ __builtin_memcpy (p + 9,
+"\x1\x37\x82\xa7\x55\x49\x9d\xbf\xf8\x44\xb6\x55\x17\x8e\xf9", 15);
+ __builtin_memcpy (p + 128 + 24,
+"\x1\x37\x82\xa7\x55\x49\xd0\xf3\xb7\x2a\x6d\x23\x71\x49\x6a", 15);
+ if (mymemcmp (p + 9, p + 128 + 24, 33) != -51)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38151.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38151.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38151.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38151.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,47 @@
+/* { dg-options "-Wno-psabi" } */
+/* { dg-require-effective-target int32plus } */
+void abort (void);
+
+struct S2848
+{
+ unsigned int a;
+ _Complex int b;
+ struct
+ {
+ } __attribute__ ((aligned)) c;
+};
+
+struct S2848 s2848;
+
+int fails;
+
+void __attribute__((noinline))
+check2848va (int z, ...)
+{
+ struct S2848 arg;
+ __builtin_va_list ap;
+
+ __builtin_va_start (ap, z);
+
+ arg = __builtin_va_arg (ap, struct S2848);
+
+ if (s2848.a != arg.a)
+ ++fails;
+ if (s2848.b != arg.b)
+ ++fails;
+
+ __builtin_va_end (ap);
+}
+
+int main (void)
+{
+ s2848.a = 4027477739U;
+ s2848.b = (723419448 + -218144346 * __extension__ 1i);
+
+ check2848va (1, s2848);
+
+ if (fails)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38212.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38212.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38212.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38212.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+int __attribute__((noinline))
+foo (int *__restrict p, int i)
+{
+ int *__restrict q;
+ int *__restrict r;
+ int v, w;
+ q = p + 1;
+ r = q - i;
+ v = *r;
+ *p = 1;
+ w = *r;
+ return v + w;
+}
+extern void abort (void);
+int main()
+{
+ int i = 0;
+ if (foo (&i, 1) != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38236.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38236.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38236.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38236.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+struct X { int i; };
+
+int __attribute__((noinline))
+foo (struct X *p, int *q, int a, int b)
+{
+ struct X x, y;
+ if (a)
+ p = &x;
+ if (b)
+ q = &x.i;
+ else
+ q = &y.i;
+ *q = 1;
+ return p->i;
+}
+extern void abort (void);
+int main()
+{
+ if (foo((void *)0, (void *)0, 1, 1) != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38422.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38422.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38422.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38422.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* PR middle-end/38422 */
+
+extern void abort (void);
+
+struct S
+{
+ int s : (sizeof (int) * __CHAR_BIT__ - 2);
+} s;
+
+void
+foo (void)
+{
+ s.s *= 2;
+}
+
+int
+main ()
+{
+ s.s = 24;
+ foo ();
+ if (s.s != 48)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38533.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38533.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38533.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38533.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR middle-end/38533 */
+
+#define A asm volatile ("" : "=r" (f) : "0" (0)); e |= f;
+#define B A A A A A A A A A A A
+#define C B B B B B B B B B B B
+
+int
+foo (void)
+{
+ int e = 0, f;
+ C C B B B B B A A A A A A
+ return e;
+}
+
+int
+main (void)
+{
+ if (foo ())
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38819.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38819.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38819.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38819.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+extern void exit (int);
+extern void abort (void);
+
+volatile int a = 1;
+volatile int b = 0;
+volatile int x = 2;
+volatile signed int r = 8;
+
+void __attribute__((noinline))
+foo (void)
+{
+ exit (0);
+}
+
+int
+main (void)
+{
+ int si1 = a;
+ int si2 = b;
+ int i;
+
+ for (i = 0; i < 100; ++i) {
+ foo ();
+ if (x == 8)
+ i++;
+ r += i + si1 % si2;
+ }
+ abort ();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38969.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38969.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38969.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr38969.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+__complex__ float
+__attribute__ ((noinline)) foo (__complex__ float x)
+{
+ return x;
+}
+
+__complex__ float
+__attribute__ ((noinline)) bar (__complex__ float x)
+{
+ return foo (x);
+}
+
+int main()
+{
+ __complex__ float a, b;
+ __real__ a = 9;
+ __imag__ a = 42;
+
+ b = bar (a);
+
+ if (a != b)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39100.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39100.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39100.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39100.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,63 @@
+/* Bad PTA results (incorrect store handling) was causing us to delete
+ *na = 0 store. */
+
+typedef struct E
+{
+ int p;
+ struct E *n;
+} *EP;
+
+typedef struct C
+{
+ EP x;
+ short cn, cp;
+} *CP;
+
+__attribute__((noinline)) CP
+foo (CP h, EP x)
+{
+ EP pl = 0, *pa = &pl;
+ EP nl = 0, *na = &nl;
+ EP n;
+
+ while (x)
+ {
+ n = x->n;
+ if ((x->p & 1) == 1)
+ {
+ h->cp++;
+ *pa = x;
+ pa = &((*pa)->n);
+ }
+ else
+ {
+ h->cn++;
+ *na = x;
+ na = &((*na)->n);
+ }
+ x = n;
+ }
+ *pa = nl;
+ *na = 0;
+ h->x = pl;
+ return h;
+}
+
+int
+main (void)
+{
+ struct C c = { 0, 0, 0 };
+ struct E e[2] = { { 0, &e[1] }, { 1, 0 } };
+ EP p;
+
+ foo (&c, &e[0]);
+ if (c.cn != 1 || c.cp != 1)
+ __builtin_abort ();
+ if (c.x != &e[1])
+ __builtin_abort ();
+ if (e[1].n != &e[0])
+ __builtin_abort ();
+ if (e[0].n)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39120.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39120.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39120.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39120.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+struct X { int *p; } x;
+
+struct X __attribute__((noinline))
+foo(int *p) { struct X x; x.p = p; return x; }
+
+void __attribute((noinline))
+bar() { *x.p = 1; }
+
+extern void abort (void);
+int main()
+{
+ int i = 0;
+ x = foo(&i);
+ bar();
+ if (i != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39228.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39228.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39228.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39228.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,39 @@
+/* { dg-add-options ieee } */
+/* { dg-skip-if "No Inf/NaN support" { spu-*-* } } */
+
+extern void abort (void);
+
+static inline int __attribute__((always_inline)) testf (float b)
+{
+ float c = 1.01f * b;
+
+ return __builtin_isinff (c);
+}
+
+static inline int __attribute__((always_inline)) test (double b)
+{
+ double c = 1.01 * b;
+
+ return __builtin_isinf (c);
+}
+
+static inline int __attribute__((always_inline)) testl (long double b)
+{
+ long double c = 1.01L * b;
+
+ return __builtin_isinfl (c);
+}
+
+int main()
+{
+ if (testf (__FLT_MAX__) < 1)
+ abort ();
+
+ if (test (__DBL_MAX__) < 1)
+ abort ();
+
+ if (testl (__LDBL_MAX__) < 1)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39233.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39233.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39233.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39233.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+extern void abort (void);
+
+__attribute__((noinline)) void
+foo (void *p)
+{
+ long l = (long) p;
+ if (l < 0 || l > 6)
+ abort ();
+}
+
+int
+main ()
+{
+ short i;
+ for (i = 6; i >= 0; i--)
+ foo ((void *) (long) i);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39240.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39240.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39240.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39240.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,105 @@
+/* PR target/39240 */
+
+extern void abort (void);
+
+__attribute__ ((noinline))
+static int foo1 (int x)
+{
+ return x;
+}
+
+__attribute__ ((noinline))
+unsigned int bar1 (int x)
+{
+ return foo1 (x + 6);
+}
+
+volatile unsigned long l1 = (unsigned int) -4;
+
+__attribute__ ((noinline))
+static short int foo2 (int x)
+{
+ return x;
+}
+
+__attribute__ ((noinline))
+unsigned short int bar2 (int x)
+{
+ return foo2 (x + 6);
+}
+
+volatile unsigned long l2 = (unsigned short int) -4;
+
+__attribute__ ((noinline))
+static signed char foo3 (int x)
+{
+ return x;
+}
+
+__attribute__ ((noinline))
+unsigned char bar3 (int x)
+{
+ return foo3 (x + 6);
+}
+
+volatile unsigned long l3 = (unsigned char) -4;
+
+__attribute__ ((noinline))
+static unsigned int foo4 (int x)
+{
+ return x;
+}
+
+__attribute__ ((noinline))
+int bar4 (int x)
+{
+ return foo4 (x + 6);
+}
+
+volatile unsigned long l4 = (int) -4;
+
+__attribute__ ((noinline))
+static unsigned short int foo5 (int x)
+{
+ return x;
+}
+
+__attribute__ ((noinline))
+short int bar5 (int x)
+{
+ return foo5 (x + 6);
+}
+
+volatile unsigned long l5 = (short int) -4;
+
+__attribute__ ((noinline))
+static unsigned char foo6 (int x)
+{
+ return x;
+}
+
+__attribute__ ((noinline))
+signed char bar6 (int x)
+{
+ return foo6 (x + 6);
+}
+
+volatile unsigned long l6 = (signed char) -4;
+
+int
+main (void)
+{
+ if (bar1 (-10) != l1)
+ abort ();
+ if (bar2 (-10) != l2)
+ abort ();
+ if (bar3 (-10) != l3)
+ abort ();
+ if (bar4 (-10) != l4)
+ abort ();
+ if (bar5 (-10) != l5)
+ abort ();
+ if (bar6 (-10) != l6)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39339.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39339.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39339.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39339.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,80 @@
+struct C
+{
+ unsigned int c;
+ struct D
+ {
+ unsigned int columns : 4;
+ unsigned int fore : 12;
+ unsigned int back : 6;
+ unsigned int fragment : 1;
+ unsigned int standout : 1;
+ unsigned int underline : 1;
+ unsigned int strikethrough : 1;
+ unsigned int reverse : 1;
+ unsigned int blink : 1;
+ unsigned int half : 1;
+ unsigned int bold : 1;
+ unsigned int invisible : 1;
+ unsigned int pad : 1;
+ } attr;
+};
+
+struct A
+{
+ struct C *data;
+ unsigned int len;
+};
+
+struct B
+{
+ struct A *cells;
+ unsigned char soft_wrapped : 1;
+};
+
+struct E
+{
+ long row, col;
+ struct C defaults;
+};
+
+__attribute__ ((noinline))
+void foo (struct E *screen, unsigned int c, int columns, struct B *row)
+{
+ struct D attr;
+ long col;
+ int i;
+ col = screen->col;
+ attr = screen->defaults.attr;
+ attr.columns = columns;
+ row->cells->data[col].c = c;
+ row->cells->data[col].attr = attr;
+ col++;
+ attr.fragment = 1;
+ for (i = 1; i < columns; i++)
+ {
+ row->cells->data[col].c = c;
+ row->cells->data[col].attr = attr;
+ col++;
+ }
+}
+
+int
+main (void)
+{
+ struct E e = {.row = 5,.col = 0,.defaults =
+ {6, {-1, -1, -1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}} };
+ struct C c[4];
+ struct A a = { c, 4 };
+ struct B b = { &a, 1 };
+ struct D d;
+ __builtin_memset (&c, 0, sizeof c);
+ foo (&e, 65, 2, &b);
+ d = e.defaults.attr;
+ d.columns = 2;
+ if (__builtin_memcmp (&d, &c[0].attr, sizeof d))
+ __builtin_abort ();
+ d.fragment = 1;
+ if (__builtin_memcmp (&d, &c[1].attr, sizeof d))
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39501.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39501.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39501.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr39501.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,87 @@
+/* { dg-options "-ffast-math" } */
+
+extern void abort (void);
+extern void exit (int);
+
+#define min1(a,b) ((a) < (b) ? (a) : (b))
+#define max1(a,b) ((a) > (b) ? (a) : (b))
+
+#define min2(a,b) ((a) <= (b) ? (a) : (b))
+#define max2(a,b) ((a) >= (b) ? (a) : (b))
+
+#define F(type,n) \
+ type __attribute__((noinline)) type##_##n(type a, type b) \
+ { \
+ return n(a, b); \
+ }
+
+F(float,min1)
+F(float,min2)
+F(float,max1)
+F(float,max2)
+
+F(double,min1)
+F(double,min2)
+F(double,max1)
+F(double,max2)
+
+int main()
+{
+ if (float_min1(0.f, -1.f) != -1.f) abort();
+ if (float_min1(-1.f, 0.f) != -1.f) abort();
+ if (float_min1(0.f, 1.f) != 0.f) abort();
+ if (float_min1(1.f, 0.f) != 0.f) abort();
+ if (float_min1(-1.f, 1.f) != -1.f) abort();
+ if (float_min1(1.f, -1.f) != -1.f) abort();
+
+ if (float_max1(0.f, -1.f) != 0.f) abort();
+ if (float_max1(-1.f, 0.f) != 0.f) abort();
+ if (float_max1(0.f, 1.f) != 1.f) abort();
+ if (float_max1(1.f, 0.f) != 1.f) abort();
+ if (float_max1(-1.f, 1.f) != 1.f) abort();
+ if (float_max1(1.f, -1.f) != 1.f) abort();
+
+ if (float_min2(0.f, -1.f) != -1.f) abort();
+ if (float_min2(-1.f, 0.f) != -1.f) abort();
+ if (float_min2(0.f, 1.f) != 0.f) abort();
+ if (float_min2(1.f, 0.f) != 0.f) abort();
+ if (float_min2(-1.f, 1.f) != -1.f) abort();
+ if (float_min2(1.f, -1.f) != -1.f) abort();
+
+ if (float_max2(0.f, -1.f) != 0.f) abort();
+ if (float_max2(-1.f, 0.f) != 0.f) abort();
+ if (float_max2(0.f, 1.f) != 1.f) abort();
+ if (float_max2(1.f, 0.f) != 1.f) abort();
+ if (float_max2(-1.f, 1.f) != 1.f) abort();
+ if (float_max2(1.f, -1.f) != 1.f) abort();
+
+ if (double_min1(0., -1.) != -1.) abort();
+ if (double_min1(-1., 0.) != -1.) abort();
+ if (double_min1(0., 1.) != 0.) abort();
+ if (double_min1(1., 0.) != 0.) abort();
+ if (double_min1(-1., 1.) != -1.) abort();
+ if (double_min1(1., -1.) != -1.) abort();
+
+ if (double_max1(0., -1.) != 0.) abort();
+ if (double_max1(-1., 0.) != 0.) abort();
+ if (double_max1(0., 1.) != 1.) abort();
+ if (double_max1(1., 0.) != 1.) abort();
+ if (double_max1(-1., 1.) != 1.) abort();
+ if (double_max1(1., -1.) != 1.) abort();
+
+ if (double_min2(0., -1.) != -1.) abort();
+ if (double_min2(-1., 0.) != -1.) abort();
+ if (double_min2(0., 1.) != 0.) abort();
+ if (double_min2(1., 0.) != 0.) abort();
+ if (double_min2(-1., 1.) != -1.) abort();
+ if (double_min2(1., -1.) != -1.) abort();
+
+ if (double_max2(0., -1.) != 0.) abort();
+ if (double_max2(-1., 0.) != 0.) abort();
+ if (double_max2(0., 1.) != 1.) abort();
+ if (double_max2(1., 0.) != 1.) abort();
+ if (double_max2(-1., 1.) != 1.) abort();
+ if (double_max2(1., -1.) != 1.) abort();
+
+ exit(0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40022.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40022.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40022.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40022.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,50 @@
+extern void abort (void);
+
+struct A
+{
+ struct A *a;
+};
+
+struct B
+{
+ struct A *b;
+};
+
+__attribute__((noinline))
+struct A *
+foo (struct A *x)
+{
+ asm volatile ("" : : "g" (x) : "memory");
+ return x;
+}
+
+__attribute__((noinline))
+void
+bar (struct B *w, struct A *x, struct A *y, struct A *z)
+{
+ struct A **c;
+ c = &w->b;
+ *c = foo (x);
+ while (*c)
+ c = &(*c)->a;
+ *c = foo (y);
+ while (*c)
+ c = &(*c)->a;
+ *c = foo (z);
+}
+
+struct B d;
+struct A e, f, g;
+
+int
+main (void)
+{
+ f.a = &g;
+ bar (&d, &e, &f, 0);
+ if (d.b == 0
+ || d.b->a == 0
+ || d.b->a->a == 0
+ || d.b->a->a->a != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40057.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40057.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40057.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40057.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,37 @@
+/* PR middle-end/40057 */
+
+extern void abort (void);
+
+__attribute__((noinline)) int
+foo (unsigned long long x)
+{
+ unsigned long long y = (x >> 31ULL) & 1ULL;
+ if (y == 0ULL)
+ return 0;
+ return -1;
+}
+
+__attribute__((noinline)) int
+bar (long long x)
+{
+ long long y = (x >> 31LL) & 1LL;
+ if (y == 0LL)
+ return 0;
+ return -1;
+}
+
+int
+main (void)
+{
+ if (sizeof (long long) != 8)
+ return 0;
+ if (foo (0x1682a9aaaULL))
+ abort ();
+ if (!foo (0x1882a9aaaULL))
+ abort ();
+ if (bar (0x1682a9aaaLL))
+ abort ();
+ if (!bar (0x1882a9aaaLL))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40386.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40386.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40386.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40386.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,104 @@
+/* { dg-options "-fno-ira-share-spill-slots -Wno-shift-overflow" } */
+
+extern void abort (void);
+extern void exit (int);
+
+#define CHAR_BIT 8
+
+#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))
+#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))
+
+#define CHAR_VALUE ((char)0xf234)
+#define SHORT_VALUE ((short)0xf234)
+#define INT_VALUE ((int)0xf234)
+#define LONG_VALUE ((long)0xf2345678L)
+#define LL_VALUE ((long long)0xf2345678abcdef0LL)
+
+#define SHIFT1 4
+#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)
+
+char c = CHAR_VALUE;
+short s = SHORT_VALUE;
+int i = INT_VALUE;
+long l = LONG_VALUE;
+long long ll = LL_VALUE;
+int shift1 = SHIFT1;
+int shift2 = SHIFT2;
+
+int
+main ()
+{
+ if (ROR (c, shift1) != ROR (CHAR_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (c, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (s, shift1) != ROR (SHORT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (s, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (i, shift1) != ROR (INT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (i, SHIFT1) != ROR (INT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (l, shift1) != ROR (LONG_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (l, SHIFT1) != ROR (LONG_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (ll, shift1) != ROR (LL_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (ll, SHIFT1) != ROR (LL_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (ll, shift2) != ROR (LL_VALUE, SHIFT2))
+ abort ();
+
+ if (ROR (ll, SHIFT2) != ROR (LL_VALUE, SHIFT2))
+ abort ();
+
+ if (ROL (c, shift1) != ROL (CHAR_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (c, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (s, shift1) != ROL (SHORT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (s, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (i, shift1) != ROL (INT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (i, SHIFT1) != ROL (INT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (l, shift1) != ROL (LONG_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (l, SHIFT1) != ROL (LONG_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (ll, shift1) != ROL (LL_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (ll, SHIFT1) != ROL (LL_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (ll, shift2) != ROL (LL_VALUE, SHIFT2))
+ abort ();
+
+ if (ROL (ll, SHIFT2) != ROL (LL_VALUE, SHIFT2))
+ abort ();
+
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40404.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40404.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40404.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40404.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+extern void abort (void);
+
+#if (__SIZEOF_INT__ <= 2)
+struct S {
+ unsigned long ui17 : 17;
+} s;
+#else
+struct S {
+ unsigned int ui17 : 17;
+} s;
+#endif
+int main()
+{
+ s.ui17 = 0x1ffff;
+ if (s.ui17 >= 0xfffffffeu)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40493.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40493.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40493.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40493.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,82 @@
+extern void abort (void);
+
+typedef union i386_operand_type
+{
+ struct
+ {
+ unsigned int reg8:1;
+ unsigned int reg16:1;
+ unsigned int reg32:1;
+ unsigned int reg64:1;
+ unsigned int floatreg:1;
+ unsigned int regmmx:1;
+ unsigned int regxmm:1;
+ unsigned int regymm:1;
+ unsigned int control:1;
+ unsigned int debug:1;
+ unsigned int test:1;
+ unsigned int sreg2:1;
+ unsigned int sreg3:1;
+ unsigned int imm1:1;
+ unsigned int imm8:1;
+ unsigned int imm8s:1;
+ unsigned int imm16:1;
+ unsigned int imm32:1;
+ unsigned int imm32s:1;
+ unsigned int imm64:1;
+ unsigned int disp8:1;
+ unsigned int disp16:1;
+ unsigned int disp32:1;
+ unsigned int disp32s:1;
+ unsigned int disp64:1;
+ unsigned int acc:1;
+ unsigned int floatacc:1;
+ unsigned int baseindex:1;
+ unsigned int inoutportreg:1;
+ unsigned int shiftcount:1;
+ unsigned int jumpabsolute:1;
+ unsigned int esseg:1;
+ unsigned int regmem:1;
+ unsigned int mem:1;
+ unsigned int byte:1;
+ unsigned int word:1;
+ unsigned int dword:1;
+ unsigned int fword:1;
+ unsigned int qword:1;
+ unsigned int tbyte:1;
+ unsigned int xmmword:1;
+ unsigned int ymmword:1;
+ unsigned int unspecified:1;
+ unsigned int anysize:1;
+ } bitfield;
+ unsigned int array[2];
+} i386_operand_type;
+
+unsigned int x00, x01, y00, y01;
+
+int main (int argc, char *argv[])
+{
+ i386_operand_type a,b,c,d;
+
+ a.bitfield.reg16 = 1;
+ a.bitfield.imm16 = 0;
+ a.array[1] = 22;
+
+ b = a;
+ x00 = b.array[0];
+ x01 = b.array[1];
+
+ c = b;
+ y00 = c.array[0];
+ y01 = c.array[1];
+
+ d = c;
+ if (d.bitfield.reg16 != 1)
+ abort();
+ if (d.bitfield.imm16 != 0)
+ abort();
+ if (d.array[1] != 22)
+ abort();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40579.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40579.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40579.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40579.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+extern void abort (void);
+static char * __attribute__((noinline))
+itos(int num)
+{
+ return (char *)0;
+}
+static void __attribute__((noinline))
+foo(int i, const char *x)
+{
+ if (i >= 4)
+ abort ();
+}
+int main()
+{
+ int x = -__INT_MAX__ + 3;
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ {
+ char *p;
+ --x;
+ p = itos(x);
+ foo(i, p);
+ }
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40657.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40657.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40657.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40657.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* Verify that that Thumb-1 epilogue size optimization does not clobber the
+ return value. */
+
+long long v = 0x123456789abc;
+
+__attribute__((noinline)) void bar (int *x)
+{
+ asm volatile ("" : "=m" (x) ::);
+}
+
+__attribute__((noinline)) long long foo()
+{
+ int x;
+ bar(&x);
+ return v;
+}
+
+int main ()
+{
+ if (foo () != v)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40668.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40668.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40668.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40668.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,40 @@
+#if (__SIZEOF_INT__ == 2)
+#define TESTVALUE 0x1234
+#else
+#define TESTVALUE 0x12345678
+#endif
+static void
+foo (unsigned int x, void *p)
+{
+ __builtin_memcpy (p, &x, sizeof x);
+}
+
+void
+bar (int type, void *number)
+{
+ switch (type)
+ {
+ case 1:
+ foo (TESTVALUE, number);
+ break;
+ case 7:
+ foo (0, number);
+ break;
+ case 8:
+ foo (0, number);
+ break;
+ case 9:
+ foo (0, number);
+ break;
+ }
+}
+
+int
+main (void)
+{
+ unsigned int x;
+ bar (1, &x);
+ if (x != TESTVALUE)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40747.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40747.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40747.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr40747.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* PR middle-end/40747 */
+
+extern void abort (void);
+
+int
+foo (int i)
+{
+ return (i < 4 && i >= 0) ? i : 4;
+}
+
+int
+main ()
+{
+ if (foo (-1) != 4) abort ();
+ if (foo (0) != 0) abort ();
+ if (foo (1) != 1) abort ();
+ if (foo (2) != 2) abort ();
+ if (foo (3) != 3) abort ();
+ if (foo (4) != 4) abort ();
+ if (foo (5) != 4) abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41239.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41239.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41239.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41239.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,67 @@
+/* PR rtl-optimization/41239 */
+
+struct S
+{
+ short nargs;
+ unsigned long arg[2];
+};
+
+extern void abort (void);
+extern void exit (int);
+extern char fn1 (int, const char *, int, const char *, const char *);
+extern void fn2 (int, ...);
+extern int fn3 (int);
+extern int fn4 (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+
+unsigned long
+test (struct S *x)
+{
+ signed int arg1 = x->arg[0];
+ long int arg2 = x->arg[1];
+
+ if (arg2 == 0)
+ (fn1 (20, "foo", 924, __func__, ((void *) 0))
+ ? (fn2 (fn3 (0x2040082), fn4 ("division by zero")))
+ : (void) 0);
+
+ return (long int) arg1 / arg2;
+}
+
+int
+main (void)
+{
+ struct S s = { 2, { 5, 0 } };
+ test (&s);
+ abort ();
+}
+
+__attribute__((noinline)) char
+fn1 (int x, const char *y, int z, const char *w, const char *v)
+{
+ asm volatile ("" : : "r" (w), "r" (v) : "memory");
+ asm volatile ("" : "+r" (x) : "r" (y), "r" (z) : "memory");
+ return x;
+}
+
+__attribute__((noinline)) int
+fn3 (int x)
+{
+ asm volatile ("" : "+r" (x) : : "memory");
+ return x;
+}
+
+__attribute__((noinline)) int
+fn4 (const char *x, ...)
+{
+ asm volatile ("" : "+r" (x) : : "memory");
+ return *x;
+}
+
+__attribute__((noinline)) void
+fn2 (int x, ...)
+{
+ asm volatile ("" : "+r" (x) : : "memory");
+ if (x)
+ /* Could be a longjmp or throw too. */
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41317.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41317.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41317.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41317.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+extern void abort (void);
+
+struct A
+{
+ int i;
+};
+struct B
+{
+ struct A a;
+ int j;
+};
+
+static void
+foo (struct B *p)
+{
+ ((struct A *)p)->i = 1;
+}
+
+int main()
+{
+ struct A a;
+ a.i = 0;
+ foo ((struct B *)&a);
+ if (a.i != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41395-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41395-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41395-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41395-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+struct VEC_char_base
+{
+ unsigned num;
+ unsigned alloc;
+ short vec[1];
+};
+
+short __attribute__((noinline))
+foo (struct VEC_char_base *p, int i)
+{
+ short *q;
+ p->vec[i] = 0;
+ q = &p->vec[8];
+ *q = 1;
+ return p->vec[i];
+}
+
+extern void abort (void);
+extern void *malloc (__SIZE_TYPE__);
+
+int
+main()
+{
+ struct VEC_char_base *p = malloc (sizeof (struct VEC_char_base) + 256);
+ if (foo (p, 8) != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41395-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41395-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41395-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41395-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+struct VEC_char_base
+{
+ unsigned num;
+ unsigned alloc;
+ union {
+ short vec[1];
+ struct {
+ int i;
+ int j;
+ int k;
+ } a;
+ } u;
+};
+
+short __attribute__((noinline))
+foo (struct VEC_char_base *p, int i)
+{
+ short *q;
+ p->u.vec[i] = 0;
+ q = &p->u.vec[16];
+ *q = 1;
+ return p->u.vec[i];
+}
+
+extern void abort (void);
+extern void *malloc (__SIZE_TYPE__);
+
+int
+main()
+{
+ struct VEC_char_base *p = malloc (sizeof (struct VEC_char_base) + 256);
+ if (foo (p, 16) != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41463.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41463.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41463.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41463.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,55 @@
+#include <stdlib.h>
+
+union tree_node;
+
+struct tree_common
+{
+ int a;
+ long b;
+ long c;
+ void *p;
+ int d;
+};
+
+struct other_tree
+{
+ struct tree_common common;
+ int arr[14];
+};
+
+struct tree_vec
+{
+ struct tree_common common;
+ int length;
+ union tree_node *a[1];
+};
+
+union tree_node
+{
+ struct other_tree othr;
+ struct tree_vec vec;
+};
+
+union tree_node global;
+
+union tree_node * __attribute__((noinline))
+foo (union tree_node *p, int i)
+{
+ union tree_node **q;
+ p->vec.a[i] = (union tree_node *) 0;
+ q = &p->vec.a[1];
+ *q = &global;
+ return p->vec.a[i];
+}
+
+extern void abort (void);
+extern void *malloc (__SIZE_TYPE__);
+
+int
+main()
+{
+ union tree_node *p = malloc (sizeof (union tree_node));
+ if (foo (p, 1) != &global)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41750.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41750.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41750.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41750.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,67 @@
+/* PR 41750 - IPA-SRA used to pass hash->sgot by value rather than by
+ reference. */
+
+struct bfd_link_hash_table
+{
+ int hash;
+};
+
+struct foo_link_hash_table
+{
+ struct bfd_link_hash_table root;
+ int *dynobj;
+ int *sgot;
+};
+
+struct foo_link_info
+{
+ struct foo_link_hash_table *hash;
+};
+
+extern void abort (void);
+
+int __attribute__((noinline))
+foo_create_got_section (int *abfd, struct foo_link_info *info)
+{
+ info->hash->sgot = abfd;
+ return 1;
+}
+
+static int *
+get_got (int *abfd, struct foo_link_info *info,
+ struct foo_link_hash_table *hash)
+{
+ int *got;
+ int *dynobj;
+
+ got = hash->sgot;
+ if (!got)
+ {
+ dynobj = hash->dynobj;
+ if (!dynobj)
+ hash->dynobj = dynobj = abfd;
+ if (!foo_create_got_section (dynobj, info))
+ return 0;
+ got = hash->sgot;
+ }
+ return got;
+}
+
+int * __attribute__((noinline,noclone))
+elf64_ia64_check_relocs (int *abfd, struct foo_link_info *info)
+{
+ return get_got (abfd, info, info->hash);
+}
+
+struct foo_link_info link_info;
+struct foo_link_hash_table hash;
+int abfd;
+
+int
+main ()
+{
+ link_info.hash = &hash;
+ if (elf64_ia64_check_relocs (&abfd, &link_info) != &abfd)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41917.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41917.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41917.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41917.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR rtl-optimization/41917 */
+
+extern void abort (void);
+unsigned int a = 1;
+
+int
+main (void)
+{
+ unsigned int b, c, d;
+
+ if (sizeof (int) != 4 || (int) 0xc7d24b5e > 0)
+ return 0;
+
+ c = 0xc7d24b5e;
+ d = a | -2;
+ b = (d == 0) ? c : (c % d);
+ if (b != c)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41919.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41919.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41919.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41919.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+extern void abort (void);
+
+#define assert(x) if(!(x)) abort()
+
+struct S1
+{
+ signed char f0;
+};
+
+int g_23 = 0;
+
+static struct S1
+foo (void)
+{
+ int *l_100 = &g_23;
+ int **l_110 = &l_100;
+ struct S1 l_128 = { 1 };
+ assert (l_100 == &g_23);
+ assert (l_100 == &g_23);
+ assert (l_100 == &g_23);
+ assert (l_100 == &g_23);
+ assert (l_100 == &g_23);
+ assert (l_100 == &g_23);
+ assert (l_100 == &g_23);
+ return l_128;
+}
+
+static signed char bar(signed char si1, signed char si2)
+{
+ return (si1 <= 0) ? si1 : (si2 * 2);
+}
+int main (void)
+{
+ struct S1 s = foo();
+ if (bar(0x99 ^ (s.f0 && 1), 1) != -104)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41935.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41935.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41935.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr41935.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR middle-end/41935 */
+
+extern void abort (void);
+
+long int
+foo (int n, int i, int j)
+{
+ typedef int T[n];
+ struct S { int a; T b[n]; };
+ return __builtin_offsetof (struct S, b[i][j]);
+}
+
+int
+main (void)
+{
+ typedef int T[5];
+ struct S { int a; T b[5]; };
+ if (foo (5, 2, 3)
+ != __builtin_offsetof (struct S, b) + (5 * 2 + 3) * sizeof (int))
+ abort ();
+ if (foo (5, 5, 5)
+ != __builtin_offsetof (struct S, b) + (5 * 5 + 5) * sizeof (int))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42006.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42006.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42006.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42006.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+extern void abort (void);
+
+static unsigned int
+my_add(unsigned int si1, unsigned int si2)
+{
+ return (si1 > (50-si2)) ? si1 : (si1 + si2);
+}
+
+static unsigned int
+my_shift(unsigned int left, unsigned int right)
+{
+ return (right > 100) ? left : (left >> right);
+}
+
+static int func_4(unsigned int p_6)
+{
+ int count = 0;
+ for (p_6 = 1; p_6 < 3; p_6 = my_add(p_6, 1))
+ {
+ if (count++ > 1)
+ abort ();
+
+ if (my_shift(p_6, p_6))
+ return 0;
+ }
+ return 0;
+}
+
+int main(void)
+{
+ func_4(0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42142.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42142.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42142.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42142.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+int __attribute__((noinline,noclone))
+sort(int L)
+{
+ int end[2] = { 10, 10, }, i=0, R;
+ while (i<2)
+ {
+ R = end[i];
+ if (L<R)
+ {
+ end[i+1] = 1;
+ end[i] = 10;
+ ++i;
+ }
+ else
+ break;
+ }
+ return i;
+}
+extern void abort (void);
+int main()
+{
+ if (sort (5) != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42154.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42154.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42154.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42154.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+struct A { char x[1]; };
+extern void abort (void);
+void __attribute__((noinline,noclone))
+foo (struct A a)
+{
+ if (a.x[0] != 'a')
+ abort ();
+}
+int main ()
+{
+ struct A a;
+ int i;
+ for (i = 0; i < 1; ++i)
+ a.x[i] = 'a';
+ foo (a);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42231.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42231.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42231.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42231.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+extern void abort (void);
+
+static max;
+
+static void __attribute__((noinline)) storemax (int i)
+{
+ if (i > max)
+ max = i;
+}
+
+static int CallFunctionRec(int (*fun)(int depth), int depth) {
+ if (!fun(depth)) {
+ return 0;
+ }
+ if (depth < 10) {
+ CallFunctionRec(fun, depth + 1);
+ }
+ return 1;
+}
+
+static int CallFunction(int (*fun)(int depth)) {
+ return CallFunctionRec(fun, 1) && !fun(0);
+}
+
+static int callback(int depth) {
+ storemax (depth);
+ return depth != 0;
+}
+
+int main() {
+ CallFunction(callback);
+ if (max != 10)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42248.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42248.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42248.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42248.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+typedef struct {
+ _Complex double a;
+ _Complex double b;
+} Scf10;
+
+Scf10 g1s;
+
+void
+check (Scf10 x, _Complex double y)
+{
+ if (x.a != y) __builtin_abort ();
+}
+
+void
+init (Scf10 *p, _Complex double y)
+{
+ p->a = y;
+}
+
+int
+main ()
+{
+ init (&g1s, (_Complex double)1);
+ check (g1s, (_Complex double)1);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42269-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42269-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42269-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42269-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+/* Make sure that language + abi extensions in passing S interoperate. */
+
+static long long __attribute__((noinline))
+foo (unsigned short s)
+{
+ return (short) s;
+}
+
+unsigned short s = 0xFFFF;
+
+int
+main (void)
+{
+ return foo (s) + 1 != 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42512.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42512.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42512.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42512.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+extern void abort (void);
+
+short g_3;
+
+int main (void)
+{
+ int l_2;
+ for (l_2 = -1; l_2 != 0; l_2 = (unsigned char)(l_2 - 1))
+ g_3 |= l_2;
+ if (g_3 != -1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42544.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42544.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42544.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42544.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+/* PR c/42544 */
+
+extern void abort (void);
+
+int
+main ()
+{
+ signed short s = -1;
+ if (sizeof (long long) == sizeof (unsigned int))
+ return 0;
+ if ((unsigned int) s >= 0x100000000ULL)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42570.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42570.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42570.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42570.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,9 @@
+typedef unsigned char uint8_t;
+uint8_t foo[1][0];
+extern void abort (void);
+int main()
+{
+ if (sizeof (foo) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42614.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42614.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42614.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42614.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,67 @@
+extern void *malloc(__SIZE_TYPE__);
+extern void abort(void);
+extern void free(void *);
+
+typedef struct SEntry
+{
+ unsigned char num;
+} TEntry;
+
+typedef struct STable
+{
+ TEntry data[2];
+} TTable;
+
+TTable *init ()
+{
+ return malloc(sizeof(TTable));
+}
+
+void
+expect_func (int a, unsigned char *b) __attribute__ ((noinline));
+
+static inline void
+inlined_wrong (TEntry *entry_p, int flag);
+
+void
+inlined_wrong (TEntry *entry_p, int flag)
+{
+ unsigned char index;
+ entry_p->num = 0;
+
+ if (flag == 0)
+ abort();
+
+ for (index = 0; index < 1; index++)
+ entry_p->num++;
+
+ if (!entry_p->num)
+ {
+ abort();
+ }
+}
+
+void
+expect_func (int a, unsigned char *b)
+{
+ if (abs ((a == 0)))
+ abort ();
+ if (abs ((b == 0)))
+ abort ();
+}
+
+int
+main ()
+{
+ unsigned char index = 0;
+ TTable *table_p = init();
+ TEntry work;
+
+ inlined_wrong (&(table_p->data[1]), 1);
+ expect_func (1, &index);
+ inlined_wrong (&work, 1);
+
+ free (table_p);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42691.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42691.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42691.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42691.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+extern void abort (void);
+
+union _D_rep
+{
+ unsigned short rep[4];
+ double val;
+};
+
+int add(double* key, double* table)
+{
+ unsigned i = 0;
+ double* deletedEntry = 0;
+ while (1) {
+ double* entry = table + i;
+
+ if (*entry == *key)
+ break;
+
+ union _D_rep _D_inf = {{ 0, 0, 0, 0x7ff0 }};
+ if (*entry != _D_inf.val)
+ abort ();
+
+ union _D_rep _D_inf2 = {{ 0, 0, 0, 0x7ff0 }};
+ if (!_D_inf2.val)
+ deletedEntry = entry;
+
+ i++;
+ }
+ if (deletedEntry)
+ *deletedEntry = 0.0;
+ return 0;
+}
+
+int main ()
+{
+ union _D_rep infinit = {{ 0, 0, 0, 0x7ff0 }};
+ double table[2] = { infinit.val, 23 };
+ double key = 23;
+ int ret = add (&key, table);
+ return ret;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42721.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42721.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42721.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42721.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR c/42721 */
+
+extern void abort (void);
+
+static unsigned long long
+foo (unsigned long long x, unsigned long long y)
+{
+ return x / y;
+}
+
+static int a, b;
+
+int
+main (void)
+{
+ unsigned long long c = 1;
+ b ^= c && (foo (a, -1ULL) != 1L);
+ if (b != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42833.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42833.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42833.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr42833.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,171 @@
+typedef __INT_LEAST8_TYPE__ int8_t;
+typedef __UINT_LEAST32_TYPE__ uint32_t;
+typedef int ssize_t;
+typedef struct { int8_t v1; int8_t v2; int8_t v3; int8_t v4; } neon_s8;
+
+uint32_t helper_neon_rshl_s8 (uint32_t arg1, uint32_t arg2);
+
+uint32_t
+helper_neon_rshl_s8 (uint32_t arg1, uint32_t arg2)
+{
+ uint32_t res;
+ neon_s8 vsrc1;
+ neon_s8 vsrc2;
+ neon_s8 vdest;
+ do
+ {
+ union
+ {
+ neon_s8 v;
+ uint32_t i;
+ } conv_u;
+ conv_u.i = (arg1);
+ vsrc1 = conv_u.v;
+ }
+ while (0);
+ do
+ {
+ union
+ {
+ neon_s8 v;
+ uint32_t i;
+ } conv_u;
+ conv_u.i = (arg2);
+ vsrc2 = conv_u.v;
+ }
+ while (0);
+ do
+ {
+ int8_t tmp;
+ tmp = (int8_t) vsrc2.v1;
+ if (tmp >= (ssize_t) sizeof (vsrc1.v1) * 8)
+ {
+ vdest.v1 = 0;
+ }
+ else if (tmp < -(ssize_t) sizeof (vsrc1.v1) * 8)
+ {
+ vdest.v1 = vsrc1.v1 >> (sizeof (vsrc1.v1) * 8 - 1);
+ }
+ else if (tmp == -(ssize_t) sizeof (vsrc1.v1) * 8)
+ {
+ vdest.v1 = vsrc1.v1 >> (tmp - 1);
+ vdest.v1++;
+ vdest.v1 >>= 1;
+ }
+ else if (tmp < 0)
+ {
+ vdest.v1 = (vsrc1.v1 + (1 << (-1 - tmp))) >> -tmp;
+ }
+ else
+ {
+ vdest.v1 = vsrc1.v1 << tmp;
+ }
+ }
+ while (0);
+ do
+ {
+ int8_t tmp;
+ tmp = (int8_t) vsrc2.v2;
+ if (tmp >= (ssize_t) sizeof (vsrc1.v2) * 8)
+ {
+ vdest.v2 = 0;
+ }
+ else if (tmp < -(ssize_t) sizeof (vsrc1.v2) * 8)
+ {
+ vdest.v2 = vsrc1.v2 >> (sizeof (vsrc1.v2) * 8 - 1);
+ }
+ else if (tmp == -(ssize_t) sizeof (vsrc1.v2) * 8)
+ {
+ vdest.v2 = vsrc1.v2 >> (tmp - 1);
+ vdest.v2++;
+ vdest.v2 >>= 1;
+ }
+ else if (tmp < 0)
+ {
+ vdest.v2 = (vsrc1.v2 + (1 << (-1 - tmp))) >> -tmp;
+ }
+ else
+ {
+ vdest.v2 = vsrc1.v2 << tmp;
+ }
+ }
+ while (0);
+ do
+ {
+ int8_t tmp;
+ tmp = (int8_t) vsrc2.v3;
+ if (tmp >= (ssize_t) sizeof (vsrc1.v3) * 8)
+ {
+ vdest.v3 = 0;
+ }
+ else if (tmp < -(ssize_t) sizeof (vsrc1.v3) * 8)
+ {
+ vdest.v3 = vsrc1.v3 >> (sizeof (vsrc1.v3) * 8 - 1);
+ }
+ else if (tmp == -(ssize_t) sizeof (vsrc1.v3) * 8)
+ {
+ vdest.v3 = vsrc1.v3 >> (tmp - 1);
+ vdest.v3++;
+ vdest.v3 >>= 1;
+ }
+ else if (tmp < 0)
+ {
+ vdest.v3 = (vsrc1.v3 + (1 << (-1 - tmp))) >> -tmp;
+ }
+ else
+ {
+ vdest.v3 = vsrc1.v3 << tmp;
+ }
+ }
+ while (0);
+ do
+ {
+ int8_t tmp;
+ tmp = (int8_t) vsrc2.v4;
+ if (tmp >= (ssize_t) sizeof (vsrc1.v4) * 8)
+ {
+ vdest.v4 = 0;
+ }
+ else if (tmp < -(ssize_t) sizeof (vsrc1.v4) * 8)
+ {
+ vdest.v4 = vsrc1.v4 >> (sizeof (vsrc1.v4) * 8 - 1);
+ }
+ else if (tmp == -(ssize_t) sizeof (vsrc1.v4) * 8)
+ {
+ vdest.v4 = vsrc1.v4 >> (tmp - 1);
+ vdest.v4++;
+ vdest.v4 >>= 1;
+ }
+ else if (tmp < 0)
+ {
+ vdest.v4 = (vsrc1.v4 + (1 << (-1 - tmp))) >> -tmp;
+ }
+ else
+ {
+ vdest.v4 = vsrc1.v4 << tmp;
+ }
+ }
+ while (0);;
+ do
+ {
+ union
+ {
+ neon_s8 v;
+ uint32_t i;
+ } conv_u;
+ conv_u.v = (vdest);
+ res = conv_u.i;
+ }
+ while (0);
+ return res;
+}
+
+extern void abort(void);
+
+int main()
+{
+ uint32_t r = helper_neon_rshl_s8 (0x05050505, 0x01010101);
+ if (r != 0x0a0a0a0a)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43008.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43008.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43008.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43008.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+int i;
+struct X {
+ int *p;
+};
+struct X * __attribute__((malloc))
+my_alloc (void)
+{
+ struct X *p = __builtin_malloc (sizeof (struct X));
+ p->p = &i;
+ return p;
+}
+extern void abort (void);
+int main()
+{
+ struct X *p, *q;
+ p = my_alloc ();
+ q = my_alloc ();
+ *(p->p) = 1;
+ *(q->p) = 0;
+ if (*(p->p) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43220.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43220.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43220.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43220.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+/* { dg-require-effective-target int32plus } */
+/* { dg-require-effective-target alloca } */
+
+void *volatile p;
+
+int
+main (void)
+{
+ int n = 0;
+lab:;
+ {
+ int x[n % 1000 + 1];
+ x[0] = 1;
+ x[n % 1000] = 2;
+ p = x;
+ n++;
+ }
+
+ {
+ int x[n % 1000 + 1];
+ x[0] = 1;
+ x[n % 1000] = 2;
+ p = x;
+ n++;
+ }
+
+ if (n < 1000000)
+ goto lab;
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43236.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43236.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43236.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43236.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+/* { dg-options "-ftree-loop-distribution" } */
+extern void abort(void);
+extern void *memset(void *s, int c, __SIZE_TYPE__ n);
+extern int memcmp(const void *s1, const void *s2, __SIZE_TYPE__ n);
+/*extern int printf(const char *format, ...);*/
+
+int main()
+{
+ char A[30], B[30], C[30];
+ int i;
+
+ /* prepare arrays */
+ memset(A, 1, 30);
+ memset(B, 1, 30);
+
+ for (i = 20; i-- > 10;) {
+ A[i] = 0;
+ B[i] = 0;
+ }
+
+ /* expected result */
+ memset(C, 1, 30);
+ memset(C + 10, 0, 10);
+
+ /* show result */
+/* for (i = 0; i < 30; i++)
+ printf("%d %d %d\n", A[i], B[i], C[i]); */
+
+ /* compare results */
+ if (memcmp(A, C, 30) || memcmp(B, C, 30)) abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43269.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43269.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43269.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43269.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+int g_21;
+int g_211;
+int g_261;
+
+static void __attribute__((noinline,noclone))
+func_32 (int b)
+{
+ if (b) {
+lbl_370:
+ g_21 = 1;
+ }
+
+ for (g_261 = -1; g_261 > -2; g_261--) {
+ if (g_211 + 1) {
+ return;
+ } else {
+ g_21 = 1;
+ goto lbl_370;
+ }
+ }
+}
+
+extern void abort (void);
+
+int main(void)
+{
+ func_32(0);
+ if (g_261 != -1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43385.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43385.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43385.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43385.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,59 @@
+/* PR c/43385 */
+
+extern void abort (void);
+
+int e;
+
+__attribute__((noinline)) void
+foo (int x, int y)
+{
+ if (__builtin_expect (x, 0) && y != 0)
+ e++;
+}
+
+__attribute__((noinline)) int
+bar (int x, int y)
+{
+ if (__builtin_expect (x, 0) && y != 0)
+ return 1;
+ else
+ return 0;
+}
+
+int
+main (void)
+{
+ int z = 0;
+ asm ("" : "+r" (z));
+ foo (z + 2, z + 1);
+ if (e != 1)
+ abort ();
+ foo (z + 2, z);
+ if (e != 1)
+ abort ();
+ foo (z + 1, z + 1);
+ if (e != 2)
+ abort ();
+ foo (z + 1, z);
+ if (e != 2)
+ abort ();
+ foo (z, z + 1);
+ if (e != 2)
+ abort ();
+ foo (z, z);
+ if (e != 2)
+ abort ();
+ if (bar (z + 2, z + 1) != 1)
+ abort ();
+ if (bar (z + 2, z) != 0)
+ abort ();
+ if (bar (z + 1, z + 1) != 1)
+ abort ();
+ if (bar (z + 1, z) != 0)
+ abort ();
+ if (bar (z, z + 1) != 0)
+ abort ();
+ if (bar (z, z) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43438.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43438.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43438.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43438.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+extern void abort (void);
+
+static unsigned char g_2 = 1;
+static int g_9;
+static int *l_8 = &g_9;
+
+static void func_12(int p_13)
+{
+ int * l_17 = &g_9;
+ *l_17 &= 0 < p_13;
+}
+
+int main(void)
+{
+ unsigned char l_11 = 254;
+ *l_8 |= g_2;
+ l_11 |= *l_8;
+ func_12(l_11);
+ if (g_9 != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43560.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43560.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43560.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43560.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* PR tree-optimization/43560 */
+
+struct S
+{
+ int a, b;
+ char c[10];
+};
+
+__attribute__ ((noinline)) void
+test (struct S *x)
+{
+ while (x->b > 1 && x->c[x->b - 1] == '/')
+ {
+ x->b--;
+ x->c[x->b] = '\0';
+ }
+}
+
+const struct S s = { 0, 0, "" };
+
+int
+main ()
+{
+ struct S *p;
+ asm ("" : "=r" (p) : "0" (&s));
+ test (p);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43629.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43629.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43629.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43629.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+int flag;
+extern void abort (void);
+int main()
+{
+ int x;
+ if (flag)
+ x = -1;
+ else
+ x &= 0xff;
+ if (x & ~0xff)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43783.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43783.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43783.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43783.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,23 @@
+/* { dg-skip-if "small alignment" { pdp11-*-* } } */
+
+typedef __attribute__((aligned(16)))
+struct {
+ unsigned long long w[3];
+} UINT192;
+
+UINT192 bid_Kx192[32];
+
+extern void abort (void);
+
+int main()
+{
+ int i = 0;
+ unsigned long x = 0;
+ for (i = 0; i < 32; ++i)
+ bid_Kx192[i].w[1] = i == 1;
+ for (i = 0; i < 32; ++i)
+ x += bid_Kx192[1].w[1];
+ if (x != 32)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43784.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43784.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43784.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43784.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+struct s {
+ unsigned char a[256];
+};
+union u {
+ struct { struct s b; int c; } d;
+ struct { int c; struct s b; } e;
+};
+
+static union u v;
+static struct s *p = &v.d.b;
+static struct s *q = &v.e.b;
+
+static struct s __attribute__((noinline)) rp(void)
+{
+ return *p;
+}
+
+static void qp(void)
+{
+ *q = rp();
+}
+
+int main()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ p->a[i] = i;
+ qp();
+ for (i = 0; i < 256; i++)
+ if (q->a[i] != i)
+ __builtin_abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43835.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43835.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43835.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43835.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,51 @@
+struct PMC {
+ unsigned flags;
+};
+
+typedef struct Pcc_cell
+{
+ struct PMC *p;
+ long bla;
+ long type;
+} Pcc_cell;
+
+extern void abort ();
+extern void Parrot_gc_mark_PMC_alive_fun(int * interp, struct PMC *pmc)
+ __attribute__((noinline));
+
+void Parrot_gc_mark_PMC_alive_fun (int * interp, struct PMC *pmc)
+{
+ abort ();
+}
+
+static void mark_cell(int * interp, Pcc_cell *c)
+ __attribute__((__nonnull__(1)))
+ __attribute__((__nonnull__(2)))
+ __attribute__((noinline));
+
+static void
+mark_cell(int * interp, Pcc_cell *c)
+{
+ if (c->type == 4 && c->p
+ && !(c->p->flags & (1<<18)))
+ Parrot_gc_mark_PMC_alive_fun(interp, c->p);
+}
+
+void foo(int * interp, Pcc_cell *c);
+
+void
+foo(int * interp, Pcc_cell *c)
+{
+ mark_cell(interp, c);
+}
+
+int main()
+{
+ int i;
+ Pcc_cell c;
+ c.p = 0;
+ c.bla = 42;
+ c.type = 4;
+ foo (&i, &c);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43987.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43987.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43987.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr43987.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+char B[256 * sizeof(void *)];
+typedef void *FILE;
+typedef struct globals {
+ int c;
+ FILE *l;
+} __attribute__((may_alias)) T;
+void add_input_file(FILE *file)
+{
+ (*(T*)&B).l[0] = file;
+}
+extern void abort (void);
+int main()
+{
+ FILE x;
+ (*(T*)&B).l = &x;
+ add_input_file ((void *)-1);
+ if ((*(T*)&B).l[0] != (void *)-1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44164.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44164.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44164.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44164.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+struct X {
+ struct Y {
+ struct YY {
+ struct Z {
+ int i;
+ } c;
+ } bb;
+ } b;
+} a;
+int __attribute__((noinline, noclone))
+foo (struct Z *p)
+{
+ int i = p->i;
+ a.b = (struct Y){};
+ return p->i + i;
+}
+extern void abort (void);
+int main()
+{
+ a.b.bb.c.i = 1;
+ if (foo (&a.b.bb.c) != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44202-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44202-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44202-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44202-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+extern __attribute__ ((__noreturn__)) void exit(int);
+extern __attribute__ ((__noreturn__)) void abort(void);
+__attribute__ ((__noinline__))
+int
+add512(int a, int *b)
+{
+ int c = a + 512;
+ if (c != 0)
+ *b = a;
+ return c;
+}
+
+__attribute__ ((__noinline__))
+int
+add513(int a, int *b)
+{
+ int c = a + 513;
+ if (c == 0)
+ *b = a;
+ return c;
+}
+
+int main(void)
+{
+ int b0 = -1;
+ int b1 = -1;
+ if (add512(-512, &b0) != 0 || b0 != -1 || add513(-513, &b1) != 0 || b1 != -513)
+ abort ();
+ exit (0);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44468.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44468.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44468.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44468.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,60 @@
+#include <stddef.h>
+
+struct S {
+ int i;
+ int j;
+};
+struct R {
+ int k;
+ struct S a;
+};
+struct Q {
+ float k;
+ struct S a;
+};
+struct Q s;
+int __attribute__((noinline,noclone))
+test1 (void *q)
+{
+ struct S *b = (struct S *)((char *)q + sizeof (int));
+ s.a.i = 0;
+ b->i = 3;
+ return s.a.i;
+}
+int __attribute__((noinline,noclone))
+test2 (void *q)
+{
+ struct S *b = &((struct R *)q)->a;
+ s.a.i = 0;
+ b->i = 3;
+ return s.a.i;
+}
+int __attribute__((noinline,noclone))
+test3 (void *q)
+{
+ s.a.i = 0;
+ ((struct S *)((char *)q + sizeof (int)))->i = 3;
+ return s.a.i;
+}
+extern void abort (void);
+int
+main()
+{
+ if (sizeof (float) != sizeof (int)
+ || offsetof (struct R, a) != sizeof (int)
+ || offsetof (struct Q, a) != sizeof (int))
+ return 0;
+ s.a.i = 1;
+ s.a.j = 2;
+ if (test1 ((void *)&s) != 3)
+ abort ();
+ s.a.i = 1;
+ s.a.j = 2;
+ if (test2 ((void *)&s) != 3)
+ abort ();
+ s.a.i = 1;
+ s.a.j = 2;
+ if (test3 ((void *)&s) != 3)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44555.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44555.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44555.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44555.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+struct a {
+ char b[100];
+};
+int foo(struct a *a)
+{
+ if (&a->b)
+ return 1;
+ return 0;
+}
+extern void abort (void);
+int main()
+{
+ if (foo((struct a *)0) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44575.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44575.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44575.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44575.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,49 @@
+/* PR target/44575 */
+
+#include <stdarg.h>
+
+int fails = 0;
+struct S { float a[3]; };
+struct S a[5];
+
+void
+check (int z, ...)
+{
+ struct S arg, *p;
+ va_list ap;
+ int j = 0, k = 0;
+ int i;
+ va_start (ap, z);
+ for (i = 2; i < 4; ++i)
+ {
+ p = 0;
+ j++;
+ k += 2;
+ switch ((z << 4) | i)
+ {
+ case 0x12:
+ case 0x13:
+ p = &a[2];
+ arg = va_arg (ap, struct S);
+ break;
+ default:
+ ++fails;
+ break;
+ }
+ if (p && p->a[2] != arg.a[2])
+ ++fails;
+ if (fails)
+ break;
+ }
+ va_end (ap);
+}
+
+int
+main ()
+{
+ a[2].a[2] = -49026;
+ check (1, a[2], a[2]);
+ if (fails)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44683.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44683.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44683.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44683.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+int __attribute__((noinline,noclone))
+copysign_bug (double x)
+{
+ if (x != 0.0 && (x * 0.5 == x))
+ return 1;
+ if (__builtin_copysign(1.0, x) < 0.0)
+ return 2;
+ else
+ return 3;
+}
+int main(void)
+{
+ double x = -0.0;
+ if (copysign_bug (x) != 2)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44828.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44828.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44828.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44828.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+extern void abort (void);
+
+static signed char
+foo (signed char si1, signed char si2)
+{
+ return si1 * si2;
+}
+
+int a = 0x105F61CA;
+
+int
+main (void)
+{
+ int b = 0x0332F5C8;
+ if (foo (b, a) > 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44852.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44852.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44852.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44852.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+__attribute__ ((__noinline__))
+char *sf(char *s, char *s0)
+{
+ asm ("");
+ while (*--s == '9')
+ if (s == s0)
+ {
+ *s = '0';
+ break;
+ }
+ ++*s++;
+ return s;
+}
+
+int main()
+{
+ char s[] = "999999";
+ char *x = sf (s+2, s);
+ if (x != s+1 || __builtin_strcmp (s, "199999") != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44858.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44858.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44858.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44858.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* PR rtl-optimization/44858 */
+
+extern void abort (void);
+int a = 3;
+int b = 1;
+
+__attribute__((noinline)) long long
+foo (int x, int y)
+{
+ return x / y;
+}
+
+__attribute__((noinline)) int
+bar (void)
+{
+ int c = 2;
+ c &= foo (1, b) > b;
+ b = (a != 0) | c;
+ return c;
+}
+
+int
+main (void)
+{
+ if (bar () != 0 || b != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44942.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44942.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44942.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr44942.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,70 @@
+/* PR target/44942 */
+
+#include <stdarg.h>
+
+void
+test1 (int a, int b, int c, int d, int e, int f, int g, long double h, ...)
+{
+ int i;
+ va_list ap;
+
+ va_start (ap, h);
+ i = va_arg (ap, int);
+ if (i != 1234)
+ __builtin_abort ();
+ va_end (ap);
+}
+
+void
+test2 (int a, int b, int c, int d, int e, int f, int g, long double h, int i,
+ long double j, int k, long double l, int m, long double n, ...)
+{
+ int o;
+ va_list ap;
+
+ va_start (ap, n);
+ o = va_arg (ap, int);
+ if (o != 1234)
+ __builtin_abort ();
+ va_end (ap);
+}
+
+void
+test3 (double a, double b, double c, double d, double e, double f,
+ double g, long double h, ...)
+{
+ double i;
+ va_list ap;
+
+ va_start (ap, h);
+ i = va_arg (ap, double);
+ if (i != 1234.0)
+ __builtin_abort ();
+ va_end (ap);
+}
+
+void
+test4 (double a, double b, double c, double d, double e, double f, double g,
+ long double h, double i, long double j, double k, long double l,
+ double m, long double n, ...)
+{
+ double o;
+ va_list ap;
+
+ va_start (ap, n);
+ o = va_arg (ap, double);
+ if (o != 1234.0)
+ __builtin_abort ();
+ va_end (ap);
+}
+
+int
+main ()
+{
+ test1 (0, 0, 0, 0, 0, 0, 0, 0.0L, 1234);
+ test2 (0, 0, 0, 0, 0, 0, 0, 0.0L, 0, 0.0L, 0, 0.0L, 0, 0.0L, 1234);
+ test3 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0L, 1234.0);
+ test4 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0L, 0.0, 0.0L,
+ 0.0, 0.0L, 0.0, 0.0L, 1234.0);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45034.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45034.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45034.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45034.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,44 @@
+extern void abort (void);
+static void fixnum_neg(signed char x, signed char *py, int *pv)
+{
+ unsigned char ux, uy;
+
+ ux = (unsigned char)x;
+ uy = -ux;
+ *py = (uy <= 127) ? (signed char)uy : (-(signed char)(255 - uy) - 1);
+ *pv = (x == -128) ? 1 : 0;
+}
+
+void __attribute__((noinline)) foo(int x, int y, int v)
+{
+ if (y < -128 || y > 127)
+ abort();
+}
+
+int test_neg(void)
+{
+ signed char x, y;
+ int v, err;
+
+ err = 0;
+ x = -128;
+ for (;;) {
+ fixnum_neg(x, &y, &v);
+ foo((int)x, (int)y, v);
+ if ((v && x != -128) || (!v && x == -128))
+ ++err;
+ if (x == 127)
+ break;
+ ++x;
+ }
+ return err;
+}
+
+int main(void)
+{
+ if (sizeof (char) != 1)
+ return 0;
+ if (test_neg() != 0)
+ abort();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45070.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45070.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45070.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45070.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,52 @@
+/* PR45070 */
+extern void abort(void);
+
+struct packed_ushort {
+ unsigned short ucs;
+} __attribute__((packed));
+
+struct source {
+ int pos, length;
+ int flag;
+};
+
+static void __attribute__((noinline)) fetch(struct source *p)
+{
+ p->length = 128;
+}
+
+static struct packed_ushort __attribute__((noinline)) next(struct source *p)
+{
+ struct packed_ushort rv;
+
+ if (p->pos >= p->length) {
+ if (p->flag) {
+ p->flag = 0;
+ fetch(p);
+ return next(p);
+ }
+ p->flag = 1;
+ rv.ucs = 0xffff;
+ return rv;
+ }
+ rv.ucs = 0;
+ return rv;
+}
+
+int main(void)
+{
+ struct source s;
+ int i;
+
+ s.pos = 0;
+ s.length = 0;
+ s.flag = 0;
+
+ for (i = 0; i < 16; i++) {
+ struct packed_ushort rv = next(&s);
+ if ((i == 0 && rv.ucs != 0xffff)
+ || (i > 0 && rv.ucs != 0))
+ abort();
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45262.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45262.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45262.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45262.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+/* PR middle-end/45262 */
+
+/* { dg-require-effective-target int32plus } */
+
+extern void abort (void);
+
+int
+foo (unsigned int x)
+{
+ return ((int) x < 0) || ((int) (-x) < 0);
+}
+
+int
+bar (unsigned int x)
+{
+ return x >> 31 || (-x) >> 31;
+}
+
+int
+main (void)
+{
+ if (foo (1) != 1)
+ abort ();
+ if (foo (0) != 0)
+ abort ();
+ if (foo (-1) != 1)
+ abort ();
+ if (bar (1) != 1)
+ abort ();
+ if (bar (0) != 0)
+ abort ();
+ if (bar (-1) != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45695.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45695.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45695.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr45695.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+/* PR rtl-optimization/45695 */
+
+extern void abort (void);
+
+__attribute__((noinline)) void
+g (int x)
+{
+ asm volatile ("" : "+r" (x));
+}
+
+__attribute__((noinline)) int
+f (int a, int b, int d)
+{
+ int r = -1;
+ b += d;
+ if (d == a)
+ r = b - d;
+ g (b);
+ return r;
+}
+
+int
+main (void)
+{
+ int l;
+ asm ("" : "=r" (l) : "0" (0));
+ if (f (l + 0, l + 1, l + 4) != -1)
+ abort ();
+ if (f (l + 4, l + 1, l + 4) != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46019.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46019.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46019.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46019.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+/* PR middle-end/46019 */
+
+extern void abort (void);
+
+int
+main (void)
+{
+ unsigned long long l = 0x40000000000ULL;
+ int n;
+ for (n = 0; n < 8; n++)
+ if (l / (0x200000000ULL << n) != (0x200 >> n))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46309.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46309.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46309.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46309.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+/* PR tree-optimization/46309 */
+
+extern void abort (void);
+
+unsigned int *q;
+
+__attribute__((noinline, noclone)) void
+bar (unsigned int *p)
+{
+ if (*p != 2 && *p != 3)
+ (!(!(*q & 263) || *p != 1)) ? abort () : 0;
+}
+
+int
+main ()
+{
+ unsigned int x, y;
+ asm volatile ("" : : : "memory");
+ x = 2;
+ bar (&x);
+ x = 3;
+ bar (&x);
+ y = 1;
+ x = 0;
+ q = &y;
+ bar (&x);
+ y = 0;
+ x = 1;
+ bar (&x);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46316.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46316.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46316.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46316.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+extern void abort (void);
+
+long long __attribute__((noinline,noclone))
+foo (long long t)
+{
+ while (t > -4)
+ t -= 2;
+
+ return t;
+}
+
+int main(void)
+{
+ if (foo (0) != -4)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46909-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46909-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46909-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46909-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* PR tree-optimization/46909 */
+
+extern void abort ();
+
+int
+__attribute__ ((__noinline__))
+foo (unsigned int x)
+{
+ if (! (x == 4 || x == 6) || (x == 2 || x == 6))
+ return 1;
+ return -1;
+}
+
+int
+main ()
+{
+ int i;
+ for (i = -10; i < 10; i++)
+ if (foo (i) != 1 - 2 * (i == 4))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46909-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46909-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46909-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr46909-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+/* PR tree-optimization/46909 */
+
+extern void abort (void);
+
+int
+__attribute__((noinline))
+foo (int x)
+{
+ if ((x != 0 && x != 13) || x == 5 || x == 20)
+ return 1;
+ return -1;
+}
+
+int
+main (void)
+{
+ int i;
+ for (i = -10; i < 30; i++)
+ if (foo (i) != 1 - 2 * (i == 0) - 2 * (i == 13))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47148.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47148.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47148.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47148.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+/* PR tree-optimization/47148 */
+
+static inline unsigned
+bar (unsigned x, unsigned y)
+{
+ if (y >= 32)
+ return x;
+ else
+ return x >> y;
+}
+
+static unsigned a = 1, b = 1;
+
+static inline void
+foo (unsigned char x, unsigned y)
+{
+ if (!y)
+ return;
+ unsigned c = (0x7000U / (x - 2)) ^ a;
+ unsigned d = bar (a, a);
+ b &= ((a - d) && (a - 1)) + c;
+}
+
+int
+main (void)
+{
+ foo (1, 1);
+ foo (-1, 1);
+ if (b && ((unsigned char) -1) == 255)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47155.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47155.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47155.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47155.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+/* PR tree-optimization/47155 */
+
+unsigned int a;
+static signed char b = -127;
+int c = 1;
+
+int
+main (void)
+{
+ a = b <= (unsigned char) (-6 * c);
+ if (!a)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47237.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47237.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47237.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47237.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* { dg-xfail-if "can cause stack underflow" { nios2-*-* } } */
+/* { dg-require-effective-target untyped_assembly } */
+#define INTEGER_ARG 5
+
+extern void abort(void);
+
+static void foo(int arg)
+{
+ if (arg != INTEGER_ARG)
+ abort();
+}
+
+static void bar(int arg)
+{
+ foo(arg);
+ __builtin_apply(foo, __builtin_apply_args(), 16);
+}
+
+int main(void)
+{
+ bar(INTEGER_ARG);
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47299.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47299.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47299.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47299.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+/* PR rtl-optimization/47299 */
+
+extern void abort (void);
+
+__attribute__ ((noinline, noclone)) unsigned short
+foo (unsigned char x)
+{
+ return x * 255;
+}
+
+int
+main ()
+{
+ if (foo (0x40) != 0x3fc0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47337.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47337.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47337.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47337.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,86 @@
+/* PR rtl-optimization/47337 */
+
+static unsigned int a[256], b = 0;
+static char c = 0;
+static int d = 0, *f = &d;
+static long long e = 0;
+
+static short
+foo (long long x, long long y)
+{
+ return x / y;
+}
+
+static char
+bar (char x, char y)
+{
+ return x - y;
+}
+
+static int
+baz (int x, int y)
+{
+ *f = (y != (short) (y * 3));
+ for (c = 0; c < 2; c++)
+ {
+ lab:
+ if (d)
+ {
+ if (e)
+ e = 1;
+ else
+ return x;
+ }
+ else
+ {
+ d = 1;
+ goto lab;
+ }
+ f = &d;
+ }
+ return x;
+}
+
+static void
+fnx (unsigned long long x, int y)
+{
+ if (!y)
+ {
+ b = a[b & 1];
+ b = a[b & 1];
+ b = a[(b ^ (x & 1)) & 1];
+ b = a[(b ^ (x & 1)) & 1];
+ }
+}
+
+char *volatile w = "2";
+
+int
+main ()
+{
+ int h = 0;
+ unsigned int k = 0;
+ int l[8];
+ int i, j;
+
+ if (__builtin_strcmp (w, "1") == 0)
+ h = 1;
+
+ for (i = 0; i < 256; i++)
+ {
+ for (j = 8; j > 0; j--)
+ k = 1;
+ a[i] = k;
+ }
+ for (i = 0; i < 8; i++)
+ l[i] = 0;
+
+ d = bar (c, c);
+ d = baz (c, 1 | foo (l[0], 10));
+ fnx (d, h);
+ fnx (e, h);
+
+ if (d != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47538.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47538.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47538.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47538.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,73 @@
+/* PR tree-optimization/47538 */
+
+struct S
+{
+ double a, b, *c;
+ unsigned long d;
+};
+
+__attribute__((noinline, noclone)) void
+foo (struct S *x, const struct S *y)
+{
+ const unsigned long n = y->d + 1;
+ const double m = 0.25 * (y->b - y->a);
+ x->a = y->a;
+ x->b = y->b;
+ if (n == 1)
+ {
+ x->c[0] = 0.;
+ }
+ else if (n == 2)
+ {
+ x->c[1] = m * y->c[0];
+ x->c[0] = 2.0 * x->c[1];
+ }
+ else
+ {
+ double o = 0.0, p = 1.0;
+ unsigned long i;
+
+ for (i = 1; i <= n - 2; i++)
+ {
+ x->c[i] = m * (y->c[i - 1] - y->c[i + 1]) / (double) i;
+ o += p * x->c[i];
+ p = -p;
+ }
+ x->c[n - 1] = m * y->c[n - 2] / (n - 1.0);
+ o += p * x->c[n - 1];
+ x->c[0] = 2.0 * o;
+ }
+}
+
+int
+main (void)
+{
+ struct S x, y;
+ double c[4] = { 10, 20, 30, 40 }, d[4], e[4] = { 118, 118, 118, 118 };
+
+ y.a = 10;
+ y.b = 6;
+ y.c = c;
+ x.c = d;
+ y.d = 3;
+ __builtin_memcpy (d, e, sizeof d);
+ foo (&x, &y);
+ if (d[0] != 0 || d[1] != 20 || d[2] != 10 || d[3] != -10)
+ __builtin_abort ();
+ y.d = 2;
+ __builtin_memcpy (d, e, sizeof d);
+ foo (&x, &y);
+ if (d[0] != 60 || d[1] != 20 || d[2] != -10 || d[3] != 118)
+ __builtin_abort ();
+ y.d = 1;
+ __builtin_memcpy (d, e, sizeof d);
+ foo (&x, &y);
+ if (d[0] != -20 || d[1] != -10 || d[2] != 118 || d[3] != 118)
+ __builtin_abort ();
+ y.d = 0;
+ __builtin_memcpy (d, e, sizeof d);
+ foo (&x, &y);
+ if (d[0] != 0 || d[1] != 118 || d[2] != 118 || d[3] != 118)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47925.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47925.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47925.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr47925.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+struct s { volatile struct s *next; };
+
+void __attribute__((noinline))
+bar (int ignored, int n)
+{
+ asm volatile ("");
+}
+
+int __attribute__((noinline))
+foo (volatile struct s *ptr, int n)
+{
+ int i;
+
+ bar (0, n);
+ for (i = 0; i < n; i++)
+ ptr = ptr->next;
+}
+
+int main (void)
+{
+ volatile struct s rec = { &rec };
+ foo (&rec, 10);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48197.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48197.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48197.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48197.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR c/48197 */
+
+extern void abort (void);
+static int y = 0x8000;
+
+int
+main ()
+{
+ unsigned int x = (short)y;
+ if (sizeof (0LL) == sizeof (0U))
+ return 0;
+ if (0LL > (0U ^ (short)-0x8000))
+ abort ();
+ if (0LL > (0U ^ x))
+ abort ();
+ if (0LL > (0U ^ (short)y))
+ abort ();
+ if ((0U ^ (short)-0x8000) < 0LL)
+ abort ();
+ if ((0U ^ x) < 0LL)
+ abort ();
+ if ((0U ^ (short)y) < 0LL)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48571-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48571-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48571-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48571-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+#define S (sizeof (int))
+
+unsigned int c[624];
+void __attribute__((noinline))
+bar (void)
+{
+ unsigned int i;
+ /* Obfuscated c[i] = c[i-1] * 2. */
+ for (i = 1; i < 624; ++i)
+ *(unsigned int *)((void *)c + (__SIZE_TYPE__)i * S)
+ = 2 * *(unsigned int *)((void *)c + ((__SIZE_TYPE__)i +
+ ((__SIZE_TYPE__)-S)/S) * S);
+}
+extern void abort (void);
+int
+main()
+{
+ unsigned int i, j;
+ for (i = 0; i < 624; ++i)
+ c[i] = 1;
+ bar();
+ j = 1;
+ for (i = 0; i < 624; ++i)
+ {
+ if (c[i] != j)
+ abort ();
+ j = j * 2;
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48717.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48717.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48717.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48717.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* PR tree-optimization/48717 */
+
+extern void abort (void);
+
+int v = 1, w;
+
+unsigned short
+foo (unsigned short x, unsigned short y)
+{
+ return x + y;
+}
+
+void
+bar (void)
+{
+ v = foo (~w, w);
+}
+
+int
+main ()
+{
+ bar ();
+ if (v != (unsigned short) -1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48809.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48809.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48809.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48809.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,60 @@
+/* PR tree-optimization/48809 */
+
+extern void abort (void);
+
+int
+foo (signed char x)
+{
+ int y = 0;
+ switch (x)
+ {
+ case 0: y = 1; break;
+ case 1: y = 7; break;
+ case 2: y = 2; break;
+ case 3: y = 19; break;
+ case 4: y = 5; break;
+ case 5: y = 17; break;
+ case 6: y = 31; break;
+ case 7: y = 8; break;
+ case 8: y = 28; break;
+ case 9: y = 16; break;
+ case 10: y = 31; break;
+ case 11: y = 12; break;
+ case 12: y = 15; break;
+ case 13: y = 111; break;
+ case 14: y = 17; break;
+ case 15: y = 10; break;
+ case 16: y = 31; break;
+ case 17: y = 7; break;
+ case 18: y = 2; break;
+ case 19: y = 19; break;
+ case 20: y = 5; break;
+ case 21: y = 107; break;
+ case 22: y = 31; break;
+ case 23: y = 8; break;
+ case 24: y = 28; break;
+ case 25: y = 106; break;
+ case 26: y = 31; break;
+ case 27: y = 102; break;
+ case 28: y = 105; break;
+ case 29: y = 111; break;
+ case 30: y = 17; break;
+ case 31: y = 10; break;
+ case 32: y = 31; break;
+ case 98: y = 18; break;
+ case -62: y = 19; break;
+ }
+ return y;
+}
+
+int
+main ()
+{
+ if (foo (98) != 18 || foo (97) != 0 || foo (99) != 0)
+ abort ();
+ if (foo (-62) != 19 || foo (-63) != 0 || foo (-61) != 0)
+ abort ();
+ if (foo (28) != 105 || foo (27) != 102 || foo (29) != 111)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48814-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48814-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48814-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48814-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+extern void abort (void);
+
+int arr[] = {1,2,3,4};
+int count = 0;
+
+int __attribute__((noinline))
+incr (void)
+{
+ return ++count;
+}
+
+int main()
+{
+ arr[count++] = incr ();
+ if (count != 2 || arr[count] != 3)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48814-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48814-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48814-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48814-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+extern void abort (void);
+
+int arr[] = {1,2,3,4};
+int count = 0;
+
+int
+incr (void)
+{
+ return ++count;
+}
+
+int main()
+{
+ arr[count++] = incr ();
+ if (count != 2 || arr[count] != 3)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48973-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48973-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48973-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48973-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* PR middle-end/48973 */
+
+extern void abort (void);
+struct S { int f : 1; } s;
+int v = -1;
+
+void
+foo (unsigned int x)
+{
+ if (x != -1U)
+ abort ();
+}
+
+int
+main ()
+{
+ s.f = (v & 1) > 0;
+ foo (s.f);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48973-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48973-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48973-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr48973-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+/* PR middle-end/48973 */
+
+extern void abort (void);
+struct S { int f : 1; } s;
+int v = -1;
+
+int
+main ()
+{
+ s.f = v < 0;
+ if ((unsigned int) s.f != -1U)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49039.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49039.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49039.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49039.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* PR tree-optimization/49039 */
+extern void abort (void);
+int cnt;
+
+__attribute__((noinline, noclone)) void
+foo (unsigned int x, unsigned int y)
+{
+ unsigned int minv, maxv;
+ if (x == 1 || y == -2U)
+ return;
+ minv = x < y ? x : y;
+ maxv = x > y ? x : y;
+ if (minv == 1)
+ ++cnt;
+ if (maxv == -2U)
+ ++cnt;
+}
+
+int
+main ()
+{
+ foo (-2U, 1);
+ if (cnt != 2)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49073.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49073.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49073.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49073.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,26 @@
+/* PR tree-optimization/49073 */
+
+extern void abort (void);
+int a[] = { 1, 2, 3, 4, 5, 6, 7 }, c;
+
+int
+main ()
+{
+ int d = 1, i = 1;
+ _Bool f = 0;
+ do
+ {
+ d = a[i];
+ if (f && d == 4)
+ {
+ ++c;
+ break;
+ }
+ i++;
+ f = (d == 3);
+ }
+ while (d < 7);
+ if (c != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49123.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49123.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49123.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49123.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+/* PR lto/49123 */
+
+extern void abort (void);
+static struct S { int f : 1; } s;
+static int v = -1;
+
+int
+main ()
+{
+ s.f = v < 0;
+ if ((unsigned int) s.f != -1U)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49161.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49161.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49161.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49161.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,46 @@
+/* PR tree-optimization/49161 */
+
+extern void abort (void);
+
+int c;
+
+__attribute__((noinline, noclone)) void
+bar (int x)
+{
+ if (x != c++)
+ abort ();
+}
+
+__attribute__((noinline, noclone)) void
+foo (int x)
+{
+ switch (x)
+ {
+ case 3: goto l1;
+ case 4: goto l2;
+ case 6: goto l3;
+ default: return;
+ }
+l1:
+ goto l4;
+l2:
+ goto l4;
+l3:
+ bar (-1);
+l4:
+ bar (0);
+ if (x != 4)
+ bar (1);
+ if (x != 3)
+ bar (-1);
+ bar (2);
+}
+
+int
+main ()
+{
+ foo (3);
+ if (c != 3)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49186.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49186.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49186.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49186.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,15 @@
+/* PR target/49186 */
+extern void abort (void);
+
+int
+main ()
+{
+ int x;
+ unsigned long long uv = 0x1000000001ULL;
+
+ x = (uv < 0x80) ? 1 : ((uv < 0x800) ? 2 : 3);
+ if (x != 3)
+ abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49218.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49218.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49218.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49218.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+#ifdef __SIZEOF_INT128__
+typedef __int128 L;
+#else
+typedef long long L;
+#endif
+float f;
+
+int
+main ()
+{
+ L i = f;
+ if (i <= 10)
+ do
+ {
+ ++i;
+ asm ("");
+ }
+ while (i != 11);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49279.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49279.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49279.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49279.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+/* PR tree-optimization/49279 */
+extern void abort (void);
+
+struct S { int a; int *__restrict p; };
+
+__attribute__((noinline, noclone))
+struct S *bar (struct S *p)
+{
+ struct S *r;
+ asm volatile ("" : "=r" (r) : "0" (p) : "memory");
+ return r;
+}
+
+__attribute__((noinline, noclone))
+int
+foo (int *p, int *q)
+{
+ struct S s, *t;
+ s.a = 1;
+ s.p = p;
+ t = bar (&s);
+ t->p = q;
+ s.p[0] = 0;
+ t->p[0] = 1;
+ return s.p[0];
+}
+
+int
+main ()
+{
+ int a, b;
+ if (foo (&a, &b) != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49281.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49281.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49281.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49281.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR target/49281 */
+
+extern void abort (void);
+
+__attribute__((noinline, noclone)) int
+foo (int x)
+{
+ return (x << 2) | 4;
+}
+
+__attribute__((noinline, noclone)) int
+bar (int x)
+{
+ return (x << 2) | 3;
+}
+
+int
+main ()
+{
+ if (foo (43) != 172 || foo (1) != 4 || foo (2) != 12)
+ abort ();
+ if (bar (43) != 175 || bar (1) != 7 || bar (2) != 11)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49390.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49390.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49390.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49390.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,88 @@
+/* PR rtl-optimization/49390 */
+
+struct S { unsigned int s1; unsigned int s2; };
+struct T { unsigned int t1; struct S t2; };
+struct U { unsigned short u1; unsigned short u2; };
+struct V { struct U v1; struct T v2; };
+struct S a;
+char *b;
+union { char b[64]; struct V v; } u;
+volatile int v;
+extern void abort (void);
+
+__attribute__((noinline, noclone)) void
+foo (int x, void *y, unsigned int z, unsigned int w)
+{
+ if (x != 4 || y != (void *) &u.v.v2)
+ abort ();
+ v = z + w;
+ v = 16384;
+}
+
+__attribute__((noinline, noclone)) void
+bar (struct S x)
+{
+ v = x.s1;
+ v = x.s2;
+}
+
+__attribute__((noinline, noclone)) int
+baz (struct S *x)
+{
+ v = x->s1;
+ v = x->s2;
+ v = 0;
+ return v + 1;
+}
+
+__attribute__((noinline, noclone)) void
+test (struct S *c)
+{
+ struct T *d;
+ struct S e = a;
+ unsigned int f, g;
+ if (c == 0)
+ c = &e;
+ else
+ {
+ if (c->s2 % 8192 <= 15 || (8192 - c->s2 % 8192) <= 31)
+ foo (1, 0, c->s1, c->s2);
+ }
+ if (!baz (c))
+ return;
+ g = (((struct U *) b)->u2 & 2) ? 32 : __builtin_offsetof (struct V, v2);
+ f = c->s2 % 8192;
+ if (f == 0)
+ {
+ e.s2 += g;
+ f = g;
+ }
+ else if (f < g)
+ {
+ foo (2, 0, c->s1, c->s2);
+ return;
+ }
+ if ((((struct U *) b)->u2 & 1) && f == g)
+ {
+ bar (*c);
+ foo (3, 0, c->s1, c->s2);
+ return;
+ }
+ d = (struct T *) (b + c->s2 % 8192);
+ if (d->t2.s1 >= c->s1 && (d->t2.s1 != c->s1 || d->t2.s2 >= c->s2))
+ foo (4, d, c->s1, c->s2);
+ return;
+}
+
+int
+main ()
+{
+ struct S *c = 0;
+ asm ("" : "+r" (c) : "r" (&a));
+ u.v.v2.t2.s1 = 8192;
+ b = u.b;
+ test (c);
+ if (v != 16384)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49419.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49419.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49419.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49419.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,38 @@
+/* PR tree-optimization/49419 */
+
+extern void abort (void);
+
+struct S { int w, x, y; } *t;
+
+int
+foo (int n, int f, int *s, int m)
+{
+ int x, i, a;
+ if (n == -1)
+ return 0;
+ for (x = n, i = 0; t[x].w == f && i < m; i++)
+ x = t[x].x;
+ if (i == m)
+ abort ();
+ a = i + 1;
+ for (x = n; i > 0; i--)
+ {
+ s[i] = t[x].y;
+ x = t[x].x;
+ }
+ s[0] = x;
+ return a;
+}
+
+int
+main (void)
+{
+ int s[3], i;
+ struct S buf[3] = { { 1, 1, 2 }, { 0, 0, 0 }, { 0, 0, 0 } };
+ t = buf;
+ if (foo (0, 1, s, 3) != 2)
+ abort ();
+ if (s[0] != 1 || s[1] != 2)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49644.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49644.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49644.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49644.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,16 @@
+/* PR c/49644 */
+
+extern void abort (void);
+
+int
+main ()
+{
+ _Complex double a[12], *c = a, s = 3.0 + 1.0i;
+ double b[12] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }, *d = b;
+ int i;
+ for (i = 0; i < 6; i++)
+ *c++ = *d++ * s;
+ if (c != a + 6 || d != b + 6)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49712.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49712.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49712.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49712.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* PR tree-optimization/49712 */
+
+int a[2], b, c, d, e;
+
+void
+foo (int x, int y)
+{
+}
+
+int
+bar (void)
+{
+ int i;
+ for (; d <= 0; d = 1)
+ for (i = 0; i < 4; i++)
+ for (e = 0; e; e = 1)
+ ;
+ return 0;
+}
+
+int
+main ()
+{
+ for (b = 0; b < 2; b++)
+ while (c)
+ foo (a[b] = 0, bar ());
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49768.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49768.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49768.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49768.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,12 @@
+/* PR tree-optimization/49768 */
+
+extern void abort (void);
+
+int
+main ()
+{
+ static struct { unsigned int : 1; unsigned int s : 1; } s = { .s = 1 };
+ if (s.s != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49886.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49886.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49886.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr49886.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,99 @@
+struct PMC {
+ unsigned flags;
+};
+
+typedef struct Pcc_cell
+{
+ struct PMC *p;
+ long bla;
+ long type;
+} Pcc_cell;
+
+int gi;
+int cond;
+
+extern void abort ();
+extern void never_ever(int interp, struct PMC *pmc)
+ __attribute__((noinline,noclone));
+
+void never_ever (int interp, struct PMC *pmc)
+{
+ abort ();
+}
+
+static void mark_cell(int * interp, Pcc_cell *c)
+ __attribute__((__nonnull__(1)));
+
+static void
+mark_cell(int * interp, Pcc_cell *c)
+{
+ if (!cond)
+ return;
+
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<18)))
+ never_ever(gi + 1, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<17)))
+ never_ever(gi + 2, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<16)))
+ never_ever(gi + 3, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<15)))
+ never_ever(gi + 4, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<14)))
+ never_ever(gi + 5, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<13)))
+ never_ever(gi + 6, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<12)))
+ never_ever(gi + 7, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<11)))
+ never_ever(gi + 8, c->p);
+ if (c && c->type == 4 && c->p
+ && !(c->p->flags & (1<<10)))
+ never_ever(gi + 9, c->p);
+}
+
+static void
+foo(int * interp, Pcc_cell *c)
+{
+ mark_cell(interp, c);
+}
+
+static struct Pcc_cell *
+__attribute__((noinline,noclone))
+getnull(void)
+{
+ return (struct Pcc_cell *) 0;
+}
+
+
+int main()
+{
+ int i;
+
+ cond = 1;
+ for (i = 0; i < 100; i++)
+ foo (&gi, getnull ());
+ return 0;
+}
+
+
+void
+bar_1 (int * interp, Pcc_cell *c)
+{
+ c->bla += 1;
+ mark_cell(interp, c);
+}
+
+void
+bar_2 (int * interp, Pcc_cell *c)
+{
+ c->bla += 2;
+ mark_cell(interp, c);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr50865.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr50865.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr50865.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr50865.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+/* PR middle-end/50865 */
+
+#define INT64_MIN (-__LONG_LONG_MAX__ - 1)
+
+int
+main ()
+{
+ volatile long long l1 = 1;
+ volatile long long l2 = -1;
+ volatile long long l3 = -1;
+
+ if ((INT64_MIN % 1LL) != 0)
+ __builtin_abort ();
+ if ((INT64_MIN % l1) != 0)
+ __builtin_abort ();
+ if (l2 == -1)
+ {
+ if ((INT64_MIN % 1LL) != 0)
+ __builtin_abort ();
+ }
+ else if ((INT64_MIN % -l2) != 0)
+ __builtin_abort ();
+ if ((INT64_MIN % -l3) != 0)
+ __builtin_abort ();
+
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51023.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51023.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51023.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51023.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+/* PR rtl-optimization/51023 */
+
+extern void abort (void);
+
+short int
+foo (long int x)
+{
+ return x;
+}
+
+int
+main ()
+{
+ long int a = 0x4272AL;
+ if (foo (a) == a)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51323.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51323.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51323.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51323.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+/* PR middle-end/51323 */
+
+extern void abort (void);
+struct S { int a, b, c; };
+int v;
+
+__attribute__((noinline, noclone)) void
+foo (int x, int y, int z)
+{
+ if (x != v || y != 0 || z != 9)
+ abort ();
+}
+
+static inline int
+baz (const struct S *p)
+{
+ return p->b;
+}
+
+__attribute__((noinline, noclone)) void
+bar (int x, struct S y)
+{
+ foo (baz (&y), 0, x);
+}
+
+int
+main ()
+{
+ struct S s;
+ v = 3; s.a = v - 1; s.b = v; s.c = v + 1;
+ bar (9, s);
+ v = 17; s.a = v - 1; s.b = v; s.c = v + 1;
+ bar (9, s);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51447.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51447.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51447.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51447.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+/* PR rtl-optimization/51447 */
+/* { dg-require-effective-target label_values } */
+/* { dg-require-effective-target indirect_jumps } */
+
+extern void abort (void);
+
+#ifdef __x86_64__
+register void *ptr asm ("rbx");
+#else
+void *ptr;
+#endif
+
+int
+main (void)
+{
+ __label__ nonlocal_lab;
+ __attribute__((noinline, noclone)) void
+ bar (void *func)
+ {
+ ptr = func;
+ goto nonlocal_lab;
+ }
+ bar (&&nonlocal_lab);
+ return 1;
+nonlocal_lab:
+ if (ptr != &&nonlocal_lab)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51466.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51466.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51466.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51466.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,43 @@
+/* PR tree-optimization/51466 */
+
+extern void abort (void);
+
+__attribute__((noinline, noclone)) int
+foo (int i)
+{
+ volatile int v[4];
+ int *p;
+ v[i] = 6;
+ p = (int *) &v[i];
+ return *p;
+}
+
+__attribute__((noinline, noclone)) int
+bar (int i)
+{
+ volatile int v[4];
+ int *p;
+ v[i] = 6;
+ p = (int *) &v[i];
+ *p = 8;
+ return v[i];
+}
+
+__attribute__((noinline, noclone)) int
+baz (int i)
+{
+ volatile int v[4];
+ int *p;
+ v[i] = 6;
+ p = (int *) &v[0];
+ *p = 8;
+ return v[i];
+}
+
+int
+main ()
+{
+ if (foo (3) != 6 || bar (2) != 8 || baz (0) != 8 || baz (1) != 6)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51581-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51581-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51581-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51581-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,159 @@
+/* PR tree-optimization/51581 */
+
+/* { dg-require-effective-target int32plus } */
+
+extern void abort (void);
+
+#define N 4096
+int a[N], c[N];
+unsigned int b[N], d[N];
+
+__attribute__((noinline, noclone)) void
+f1 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ c[i] = a[i] / 3;
+}
+
+__attribute__((noinline, noclone)) void
+f2 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ d[i] = b[i] / 3;
+}
+
+__attribute__((noinline, noclone)) void
+f3 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ c[i] = a[i] / 18;
+}
+
+__attribute__((noinline, noclone)) void
+f4 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ d[i] = b[i] / 18;
+}
+
+__attribute__((noinline, noclone)) void
+f5 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ c[i] = a[i] / 19;
+}
+
+__attribute__((noinline, noclone)) void
+f6 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ d[i] = b[i] / 19;
+}
+
+#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
+__attribute__((noinline, noclone)) void
+f7 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ c[i] = (int) ((unsigned long long) (a[i] * 0x55555556LL) >> 32) - (a[i] >> 31);
+}
+
+__attribute__((noinline, noclone)) void
+f8 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ d[i] = ((unsigned int) ((b[i] * 0xaaaaaaabULL) >> 32) >> 1);
+}
+
+__attribute__((noinline, noclone)) void
+f9 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ c[i] = (((int) ((unsigned long long) (a[i] * 0x38e38e39LL) >> 32)) >> 2) - (a[i] >> 31);
+}
+
+__attribute__((noinline, noclone)) void
+f10 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ d[i] = (unsigned int) ((b[i] * 0x38e38e39ULL) >> 32) >> 2;
+}
+
+__attribute__((noinline, noclone)) void
+f11 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ c[i] = (((int) ((unsigned long long) (a[i] * 0x6bca1af3LL) >> 32)) >> 3) - (a[i] >> 31);
+}
+
+__attribute__((noinline, noclone)) void
+f12 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ {
+ unsigned int tmp = (b[i] * 0xaf286bcbULL) >> 32;
+ d[i] = (((b[i] - tmp) >> 1) + tmp) >> 4;
+ }
+}
+#endif
+
+int
+main ()
+{
+ int i;
+ for (i = 0; i < N; i++)
+ {
+ asm ("");
+ a[i] = i - N / 2;
+ b[i] = i;
+ }
+ a[0] = -__INT_MAX__ - 1;
+ a[1] = -__INT_MAX__;
+ a[N - 1] = __INT_MAX__;
+ b[N - 1] = ~0;
+ f1 ();
+ f2 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] / 3 || d[i] != b[i] / 3)
+ abort ();
+ f3 ();
+ f4 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] / 18 || d[i] != b[i] / 18)
+ abort ();
+ f5 ();
+ f6 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] / 19 || d[i] != b[i] / 19)
+ abort ();
+#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
+ f7 ();
+ f8 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] / 3 || d[i] != b[i] / 3)
+ abort ();
+ f9 ();
+ f10 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] / 18 || d[i] != b[i] / 18)
+ abort ();
+ f11 ();
+ f12 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] / 19 || d[i] != b[i] / 19)
+ abort ();
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51581-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51581-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51581-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51581-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,174 @@
+/* PR tree-optimization/51581 */
+/* { dg-require-effective-target int32plus } */
+
+extern void abort (void);
+
+#define N 4096
+int a[N], c[N];
+unsigned int b[N], d[N];
+
+__attribute__((noinline, noclone)) void
+f1 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ c[i] = a[i] % 3;
+}
+
+__attribute__((noinline, noclone)) void
+f2 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ d[i] = b[i] % 3;
+}
+
+__attribute__((noinline, noclone)) void
+f3 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ c[i] = a[i] % 18;
+}
+
+__attribute__((noinline, noclone)) void
+f4 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ d[i] = b[i] % 18;
+}
+
+__attribute__((noinline, noclone)) void
+f5 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ c[i] = a[i] % 19;
+}
+
+__attribute__((noinline, noclone)) void
+f6 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ d[i] = b[i] % 19;
+}
+
+#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
+__attribute__((noinline, noclone)) void
+f7 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ {
+ int x = (int) ((unsigned long long) (a[i] * 0x55555556LL) >> 32) - (a[i] >> 31);
+ c[i] = a[i] - x * 3;
+ }
+}
+
+__attribute__((noinline, noclone)) void
+f8 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ {
+ unsigned int x = ((unsigned int) ((b[i] * 0xaaaaaaabULL) >> 32) >> 1);
+ d[i] = b[i] - x * 3;
+ }
+}
+
+__attribute__((noinline, noclone)) void
+f9 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ {
+ int x = (((int) ((unsigned long long) (a[i] * 0x38e38e39LL) >> 32)) >> 2) - (a[i] >> 31);
+ c[i] = a[i] - x * 18;
+ }
+}
+
+__attribute__((noinline, noclone)) void
+f10 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ {
+ unsigned int x = (unsigned int) ((b[i] * 0x38e38e39ULL) >> 32) >> 2;
+ d[i] = b[i] - x * 18;
+ }
+}
+
+__attribute__((noinline, noclone)) void
+f11 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ {
+ int x = (((int) ((unsigned long long) (a[i] * 0x6bca1af3LL) >> 32)) >> 3) - (a[i] >> 31);
+ c[i] = a[i] - x * 19;
+ }
+}
+
+__attribute__((noinline, noclone)) void
+f12 (void)
+{
+ int i;
+ for (i = 0; i < N; i++)
+ {
+ unsigned int tmp = (b[i] * 0xaf286bcbULL) >> 32;
+ unsigned int x = (((b[i] - tmp) >> 1) + tmp) >> 4;
+ d[i] = b[i] - x * 19;
+ }
+}
+#endif
+
+int
+main ()
+{
+ int i;
+ for (i = 0; i < N; i++)
+ {
+ asm ("");
+ a[i] = i - N / 2;
+ b[i] = i;
+ }
+ a[0] = -__INT_MAX__ - 1;
+ a[1] = -__INT_MAX__;
+ a[N - 1] = __INT_MAX__;
+ b[N - 1] = ~0;
+ f1 ();
+ f2 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] % 3 || d[i] != b[i] % 3)
+ abort ();
+ f3 ();
+ f4 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] % 18 || d[i] != b[i] % 18)
+ abort ();
+ f5 ();
+ f6 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] % 19 || d[i] != b[i] % 19)
+ abort ();
+#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
+ f7 ();
+ f8 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] % 3 || d[i] != b[i] % 3)
+ abort ();
+ f9 ();
+ f10 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] % 18 || d[i] != b[i] % 18)
+ abort ();
+ f11 ();
+ f12 ();
+ for (i = 0; i < N; i++)
+ if (c[i] != a[i] % 19 || d[i] != b[i] % 19)
+ abort ();
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51877.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51877.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51877.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51877.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,50 @@
+/* PR tree-optimization/51877 */
+
+extern void abort (void);
+struct A { int a; char b[32]; } a, b;
+
+__attribute__((noinline, noclone))
+struct A
+bar (int x)
+{
+ struct A r;
+ static int n;
+ r.a = ++n;
+ __builtin_memset (r.b, 0, sizeof (r.b));
+ r.b[0] = x;
+ return r;
+}
+
+__attribute__((noinline, noclone))
+void
+baz (void)
+{
+ asm volatile ("" : : : "memory");
+}
+
+__attribute__((noinline, noclone))
+void
+foo (struct A *x, int y)
+{
+ if (y == 6)
+ a = bar (7);
+ else
+ *x = bar (7);
+ baz ();
+}
+
+int
+main ()
+{
+ a = bar (3);
+ b = bar (4);
+ if (a.a != 1 || a.b[0] != 3 || b.a != 2 || b.b[0] != 4)
+ abort ();
+ foo (&b, 0);
+ if (a.a != 1 || a.b[0] != 3 || b.a != 3 || b.b[0] != 7)
+ abort ();
+ foo (&b, 6);
+ if (a.a != 4 || a.b[0] != 7 || b.a != 3 || b.b[0] != 7)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51933.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51933.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51933.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr51933.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,59 @@
+/* PR rtl-optimization/51933 */
+
+static signed char v1;
+static unsigned char v2[256], v3[256];
+
+__attribute__((noclone, noinline)) void
+foo (void)
+{
+#if defined(__s390__) && !defined(__zarch__)
+ /* S/390 31 bit cannot deal with more than one literal pool
+ reference per insn. */
+ asm volatile ("" : : "g" (&v1) : "memory");
+ asm volatile ("" : : "g" (&v2[0]));
+ asm volatile ("" : : "g" (&v3[0]));
+#else
+ asm volatile ("" : : "g" (&v1), "g" (&v2[0]), "g" (&v3[0]) : "memory");
+#endif
+}
+
+__attribute__((noclone, noinline)) int
+bar (const int x, const unsigned short *y, char *z)
+{
+ int i;
+ unsigned short u;
+ if (!v1)
+ foo ();
+ for (i = 0; i < x; i++)
+ {
+ u = y[i];
+ z[i] = u < 0x0100 ? v2[u] : v3[u & 0xff];
+ }
+ z[x] = '\0';
+ return x;
+}
+
+int
+main (void)
+{
+ char buf[18];
+ unsigned short s[18];
+ unsigned char c[18] = "abcdefghijklmnopq";
+ int i;
+ for (i = 0; i < 256; i++)
+ {
+ v2[i] = i;
+ v3[i] = i + 1;
+ }
+ for (i = 0; i < 18; i++)
+ s[i] = c[i];
+ s[5] |= 0x600;
+ s[6] |= 0x500;
+ s[11] |= 0x2000;
+ s[15] |= 0x500;
+ foo ();
+ if (bar (17, s, buf) != 17
+ || __builtin_memcmp (buf, "abcdeghhijkmmnoqq", 18) != 0)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52129.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52129.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52129.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52129.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+/* PR target/52129 */
+/* { dg-xfail-if "ptxas crashes" { nvptx-*-* } { "-O1" } { "" } } */
+
+extern void abort (void);
+struct S { void *p; unsigned int q; };
+struct T { char a[64]; char b[64]; } t;
+
+__attribute__((noinline, noclone)) int
+foo (void *x, struct S s, void *y, void *z)
+{
+ if (x != &t.a[2] || s.p != &t.b[5] || s.q != 27 || y != &t.a[17] || z != &t.b[17])
+ abort ();
+ return 29;
+}
+
+__attribute__((noinline, noclone)) int
+bar (void *x, void *y, void *z, struct S s, int t, struct T *u)
+{
+ return foo (x, s, &u->a[t], &u->b[t]);
+}
+
+int
+main ()
+{
+ struct S s = { &t.b[5], 27 };
+ if (bar (&t.a[2], (void *) 0, (void *) 0, s, 17, &t) != 29)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52209.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52209.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52209.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52209.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,14 @@
+/* PR middle-end/52209 */
+
+extern void abort (void);
+struct S0 { int f2 : 1; } c;
+int b;
+
+int
+main ()
+{
+ b = -1 ^ c.f2;
+ if (b != -1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52286.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52286.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52286.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52286.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,20 @@
+/* PR tree-optimization/52286 */
+
+extern void abort (void);
+
+int
+main ()
+{
+#if __SIZEOF_INT__ > 2
+ int a, b;
+ asm ("" : "=r" (a) : "0" (0));
+ b = (~a | 1) & -2038094497;
+#else
+ long a, b;
+ asm ("" : "=r" (a) : "0" (0));
+ b = (~a | 1) & -2038094497L;
+#endif
+ if (b >= 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52760.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52760.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52760.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52760.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+/* PR tree-optimization/52760 */
+
+struct T { unsigned short a, b, c, d; };
+
+__attribute__((noinline, noclone)) void
+foo (int x, struct T *y)
+{
+ int i;
+
+ for (i = 0; i < x; i++)
+ {
+ y[i].a = ((0x00ff & y[i].a >> 8) | (0xff00 & y[i].a << 8));
+ y[i].b = ((0x00ff & y[i].b >> 8) | (0xff00 & y[i].b << 8));
+ y[i].c = ((0x00ff & y[i].c >> 8) | (0xff00 & y[i].c << 8));
+ y[i].d = ((0x00ff & y[i].d >> 8) | (0xff00 & y[i].d << 8));
+ }
+}
+
+int
+main ()
+{
+ struct T t = { 0x0001, 0x0203, 0x0405, 0x0607 };
+ foo (1, &t);
+ if (t.a != 0x0100 || t.b != 0x0302 || t.c != 0x0504 || t.d != 0x0706)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52979-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52979-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52979-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52979-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,42 @@
+/* PR middle-end/52979 */
+
+/* { dg-require-effective-target int32plus } */
+
+extern void abort (void);
+int c, d, e;
+
+void
+foo (void)
+{
+}
+
+struct __attribute__((packed)) S { int g : 31; int h : 6; };
+struct S a = { 1 };
+static struct S b = { 1 };
+
+void
+bar (void)
+{
+ a.h = 1;
+ struct S f = { };
+ b = f;
+ e = 0;
+ if (d)
+ c = a.g;
+}
+
+void
+baz (void)
+{
+ bar ();
+ a = b;
+}
+
+int
+main ()
+{
+ baz ();
+ if (a.g)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52979-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52979-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52979-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr52979-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,41 @@
+/* PR middle-end/52979 */
+/* { dg-require-effective-target int32plus } */
+
+extern void abort (void);
+int c, d, e;
+
+void
+foo (void)
+{
+}
+
+struct __attribute__((packed)) S { int g : 31; int h : 6; };
+static struct S b = { 1 };
+struct S a = { 1 };
+
+void
+bar (void)
+{
+ a.h = 1;
+ struct S f = { };
+ b = f;
+ e = 0;
+ if (d)
+ c = a.g;
+}
+
+void
+baz (void)
+{
+ bar ();
+ a = b;
+}
+
+int
+main ()
+{
+ baz ();
+ if (a.g)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53084.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53084.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53084.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53084.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,18 @@
+/* PR middle-end/53084 */
+
+extern void abort (void);
+
+__attribute__((noinline, noclone)) void
+bar (const char *p)
+{
+ if (p[0] != 'o' || p[1] != 'o' || p[2])
+ abort ();
+}
+
+int
+main ()
+{
+ static const char *const foo[] = {"foo" + 1};
+ bar (foo[0]);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53160.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53160.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53160.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53160.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,35 @@
+/* PR rtl-optimization/53160 */
+
+extern void abort (void);
+
+int a, c = 1, d, e, g;
+volatile int b;
+volatile char f;
+long h;
+short i;
+
+void
+foo (void)
+{
+ for (e = 0; e; ++e)
+ ;
+}
+
+int
+main ()
+{
+ if (g)
+ (void) b;
+ foo ();
+ for (d = 0; d >= 0; d--)
+ {
+ short j = f;
+ int k = 0;
+ i = j ? j : j << k;
+ }
+ h = c == 0 ? 0 : i;
+ a = h;
+ if (a != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53465.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53465.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53465.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53465.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* PR tree-optimization/53465 */
+
+extern void abort ();
+
+static const int a[] = { 1, 2 };
+
+void
+foo (const int *x, int y)
+{
+ int i;
+ int b = 0;
+ int c;
+ for (i = 0; i < y; i++)
+ {
+ int d = x[i];
+ if (d == 0)
+ break;
+ if (b && d <= c)
+ abort ();
+ c = d;
+ b = 1;
+ }
+}
+
+int
+main ()
+{
+ foo (a, 2);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53645-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53645-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53645-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53645-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,121 @@
+/* PR tree-optimization/53645 */
+/* { dg-options "-std=gnu89" } */
+
+typedef unsigned short int UV __attribute__((vector_size (16)));
+typedef short int SV __attribute__((vector_size (16)));
+extern void abort (void);
+
+#define TEST(a, b, c, d, e, f, g, h) \
+__attribute__((noinline)) void \
+uq##a##b##c##d##e##f##g##h (UV *x, UV *y) \
+{ \
+ *x = *y / ((UV) { a, b, c, d, e, f, g, h }); \
+} \
+ \
+__attribute__((noinline)) void \
+ur##a##b##c##d##e##f##g##h (UV *x, UV *y) \
+{ \
+ *x = *y % ((UV) { a, b, c, d, e, f, g, h }); \
+} \
+ \
+__attribute__((noinline)) void \
+sq##a##b##c##d##e##f##g##h (SV *x, SV *y) \
+{ \
+ *x = *y / ((SV) { a, b, c, d, e, f, g, h }); \
+} \
+ \
+__attribute__((noinline)) void \
+sr##a##b##c##d##e##f##g##h (SV *x, SV *y) \
+{ \
+ *x = *y % ((SV) { a, b, c, d, e, f, g, h }); \
+}
+
+#define TESTS \
+TEST (4, 4, 4, 4, 4, 4, 4, 4) \
+TEST (1, 4, 2, 8, 16, 64, 32, 128) \
+TEST (3, 3, 3, 3, 3, 3, 3, 3) \
+TEST (6, 5, 6, 5, 6, 5, 6, 5) \
+TEST (14, 14, 14, 6, 14, 6, 14, 14) \
+TEST (7, 7, 7, 7, 7, 7, 7, 7) \
+
+TESTS
+
+UV u[] =
+ { ((UV) { 73U, 65531U, 0U, 174U, 921U, 65535U, 17U, 178U }),
+ ((UV) { 1U, 8173U, 65535U, 65472U, 12U, 29612U, 128U, 8912U }) };
+SV s[] =
+ { ((SV) { 73, -9123, 32761, 8191, 16371, 1201, 12701, 9999 }),
+ ((SV) { 9903, -1, -7323, 0, -7, -323, 9124, -9199 }) };
+
+int
+main ()
+{
+ UV ur, ur2;
+ SV sr, sr2;
+ int i;
+#undef TEST
+#define TEST(a, b, c, d, e, f, g, h) \
+ uq##a##b##c##d##e##f##g##h (&ur, u + i); \
+ if (ur[0] != u[i][0] / a || ur[3] != u[i][3] / d) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory"); \
+ if (ur[2] != u[i][2] / c || ur[1] != u[i][1] / b) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory"); \
+ if (ur[4] != u[i][4] / e || ur[7] != u[i][7] / h) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory"); \
+ if (ur[6] != u[i][6] / g || ur[5] != u[i][5] / f) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory"); \
+ ur##a##b##c##d##e##f##g##h (&ur, u + i); \
+ if (ur[0] != u[i][0] % a || ur[3] != u[i][3] % d) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory"); \
+ if (ur[2] != u[i][2] % c || ur[1] != u[i][1] % b) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory"); \
+ if (ur[4] != u[i][4] % e || ur[7] != u[i][7] % h) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory"); \
+ if (ur[6] != u[i][6] % g || ur[5] != u[i][5] % f) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory");
+ for (i = 0; i < sizeof (u) / sizeof (u[0]); i++)
+ {
+ TESTS
+ }
+#undef TEST
+#define TEST(a, b, c, d, e, f, g, h) \
+ sq##a##b##c##d##e##f##g##h (&sr, s + i); \
+ if (sr[0] != s[i][0] / a || sr[3] != s[i][3] / d) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory"); \
+ if (sr[2] != s[i][2] / c || sr[1] != s[i][1] / b) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory"); \
+ if (sr[4] != s[i][4] / e || sr[7] != s[i][7] / h) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory"); \
+ if (sr[6] != s[i][6] / g || sr[5] != s[i][5] / f) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory"); \
+ sr##a##b##c##d##e##f##g##h (&sr, s + i); \
+ if (sr[0] != s[i][0] % a || sr[3] != s[i][3] % d) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory"); \
+ if (sr[2] != s[i][2] % c || sr[1] != s[i][1] % b) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory"); \
+ if (sr[4] != s[i][4] % e || sr[7] != s[i][7] % h) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory"); \
+ if (sr[6] != s[i][6] % g || sr[5] != s[i][5] % f) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory");
+ for (i = 0; i < sizeof (s) / sizeof (s[0]); i++)
+ {
+ TESTS
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53645.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53645.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53645.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53645.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,97 @@
+/* PR tree-optimization/53645 */
+/* { dg-options "-std=gnu89" } */
+
+typedef unsigned int UV __attribute__((vector_size (16)));
+typedef int SV __attribute__((vector_size (16)));
+extern void abort (void);
+
+#define TEST(a, b, c, d) \
+__attribute__((noinline)) void \
+uq##a##b##c##d (UV *x, UV *y) \
+{ \
+ *x = *y / ((UV) { a, b, c, d }); \
+} \
+ \
+__attribute__((noinline)) void \
+ur##a##b##c##d (UV *x, UV *y) \
+{ \
+ *x = *y % ((UV) { a, b, c, d }); \
+} \
+ \
+__attribute__((noinline)) void \
+sq##a##b##c##d (SV *x, SV *y) \
+{ \
+ *x = *y / ((SV) { a, b, c, d }); \
+} \
+ \
+__attribute__((noinline)) void \
+sr##a##b##c##d (SV *x, SV *y) \
+{ \
+ *x = *y % ((SV) { a, b, c, d }); \
+}
+
+#define TESTS \
+TEST (4, 4, 4, 4) \
+TEST (1, 4, 2, 8) \
+TEST (3, 3, 3, 3) \
+TEST (6, 5, 6, 5) \
+TEST (14, 14, 14, 6) \
+TEST (7, 7, 7, 7) \
+
+TESTS
+
+UV u[] =
+ { ((UV) { 73U, 65531U, 0U, 174U }),
+ ((UV) { 1U, 8173U, ~0U, ~0U - 63 }) };
+SV s[] =
+ { ((SV) { 73, -9123, 32761, 8191 }),
+ ((SV) { 9903, -1, -7323, 0 }) };
+
+int
+main ()
+{
+ UV ur, ur2;
+ SV sr, sr2;
+ int i;
+#undef TEST
+#define TEST(a, b, c, d) \
+ uq##a##b##c##d (&ur, u + i); \
+ if (ur[0] != u[i][0] / a || ur[3] != u[i][3] / d) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory"); \
+ if (ur[2] != u[i][2] / c || ur[1] != u[i][1] / b) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory"); \
+ ur##a##b##c##d (&ur, u + i); \
+ if (ur[0] != u[i][0] % a || ur[3] != u[i][3] % d) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory"); \
+ if (ur[2] != u[i][2] % c || ur[1] != u[i][1] % b) \
+ abort (); \
+ asm volatile ("" : : "r" (&ur) : "memory");
+ for (i = 0; i < sizeof (u) / sizeof (u[0]); i++)
+ {
+ TESTS
+ }
+#undef TEST
+#define TEST(a, b, c, d) \
+ sq##a##b##c##d (&sr, s + i); \
+ if (sr[0] != s[i][0] / a || sr[3] != s[i][3] / d) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory"); \
+ if (sr[2] != s[i][2] / c || sr[1] != s[i][1] / b) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory"); \
+ sr##a##b##c##d (&sr, s + i); \
+ if (sr[0] != s[i][0] % a || sr[3] != s[i][3] % d) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory"); \
+ if (sr[2] != s[i][2] % c || sr[1] != s[i][1] % b) \
+ abort (); \
+ asm volatile ("" : : "r" (&sr) : "memory");
+ for (i = 0; i < sizeof (s) / sizeof (s[0]); i++)
+ {
+ TESTS
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53688.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53688.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53688.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr53688.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+char headline[256];
+struct hdr {
+ char part1[9];
+ char part2[8];
+} p;
+
+void __attribute__((noinline,noclone))
+init()
+{
+ __builtin_memcpy (p.part1, "FOOBARFOO", sizeof (p.part1));
+ __builtin_memcpy (p.part2, "SPEC CPU", sizeof (p.part2));
+}
+
+int main()
+{
+ char *x;
+ int c;
+ init();
+ __builtin_memcpy (&headline[0], p.part1, 9);
+ c = 9;
+ x = &headline[0];
+ x = x + c;
+ __builtin_memset (x, ' ', 245);
+ __builtin_memcpy (&headline[10], p.part2, 8);
+ c = 18;
+ x = &headline[0];
+ x = x + c;
+ __builtin_memset (x, ' ', 238);
+ if (headline[10] != 'S')
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54471.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54471.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54471.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54471.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+/* PR tree-optimization/54471 */
+
+#ifdef __SIZEOF_INT128__
+#define T __int128
+#else
+#define T long long
+#endif
+
+extern void abort (void);
+
+__attribute__ ((noinline))
+unsigned T
+foo (T ixi, unsigned ctr)
+{
+ unsigned T irslt = 1;
+ T ix = ixi;
+
+ for (; ctr; ctr--)
+ {
+ irslt *= ix;
+ ix *= ix;
+ }
+
+ if (irslt != 14348907)
+ abort ();
+ return irslt;
+}
+
+int
+main ()
+{
+ unsigned T res;
+
+ res = foo (3, 4);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54937.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54937.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54937.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54937.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,22 @@
+
+void exit (int);
+void abort (void);
+int a[1];
+void (*terminate_me)(int);
+
+__attribute__((noinline,noclone))
+t(int c)
+{ int i;
+ for (i=0;i<c;i++)
+ {
+ if (i)
+ terminate_me(0);
+ a[i]=0;
+ }
+}
+main()
+{
+ terminate_me = exit;
+ t(100);
+ abort();
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54985.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54985.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54985.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr54985.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,36 @@
+
+typedef struct st {
+ int a;
+} ST;
+
+int __attribute__((noinline,noclone))
+foo(ST *s, int c)
+{
+ int first = 1;
+ int count = c;
+ ST *item = s;
+ int a = s->a;
+ int x;
+
+ while (count--)
+ {
+ x = item->a;
+ if (first)
+ first = 0;
+ else if (x >= a)
+ return 1;
+ a = x;
+ item++;
+ }
+ return 0;
+}
+
+extern void abort (void);
+
+int main ()
+{
+ ST _1[2] = {{2}, {1}};
+ if (foo(_1, 2) != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55137.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55137.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55137.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55137.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* PR c++/55137 */
+
+extern void abort (void);
+
+int
+foo (unsigned int x)
+{
+ return ((int) (x + 1U) + 1) < (int) x;
+}
+
+int
+bar (unsigned int x)
+{
+ return (int) (x + 1U) + 1;
+}
+
+int
+baz (unsigned int x)
+{
+ return x + 1U;
+}
+
+int
+main ()
+{
+ if (foo (__INT_MAX__) != (bar (__INT_MAX__) < __INT_MAX__)
+ || foo (__INT_MAX__) != ((int) baz (__INT_MAX__) + 1 < __INT_MAX__))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55750.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55750.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55750.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55750.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,29 @@
+/* PR middle-end/55750 */
+
+extern void abort (void);
+
+struct S
+{
+ int m : 1;
+ int n : 7;
+} arr[2];
+
+__attribute__((noinline, noclone)) void
+foo (unsigned i)
+{
+ arr[i].n++;
+}
+
+int
+main ()
+{
+ arr[0].m = -1;
+ arr[0].n = (1 << 6) - 1;
+ arr[1].m = 0;
+ arr[1].n = -1;
+ foo (0);
+ foo (1);
+ if (arr[0].m != -1 || arr[0].n != -(1 << 6) || arr[1].m != 0 || arr[1].n != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55875.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55875.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55875.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr55875.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,17 @@
+int a[251];
+__attribute__ ((noinline))
+t(int i)
+{
+ if (i==0)
+ exit(0);
+ if (i>255)
+ abort ();
+}
+main()
+{
+ unsigned int i;
+ for (i=0;;i++)
+ {
+ a[i]=t((unsigned char)(i+5));
+ }
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56051.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56051.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56051.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56051.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+/* PR tree-optimization/56051 */
+
+extern void abort (void);
+
+int
+main ()
+{
+ unsigned char x1[1] = { 0 };
+ unsigned int s1 = __CHAR_BIT__;
+ int a1 = x1[0] < (unsigned char) (1 << s1);
+ unsigned char y1 = (unsigned char) (1 << s1);
+ int b1 = x1[0] < y1;
+ if (a1 != b1)
+ abort ();
+#if __SIZEOF_LONG_LONG__ > __SIZEOF_INT__
+ unsigned long long x2[1] = { 2ULL << (sizeof (int) * __CHAR_BIT__) };
+ unsigned int s2 = sizeof (int) * __CHAR_BIT__ - 1;
+ int a2 = x2[0] >= (unsigned long long) (1 << s2);
+ unsigned long long y2 = 1 << s2;
+ int b2 = x2[0] >= y2;
+ if (a2 != b2)
+ abort ();
+ unsigned long long x3[1] = { 2ULL << (sizeof (int) * __CHAR_BIT__) };
+ unsigned int s3 = sizeof (int) * __CHAR_BIT__ - 1;
+ int a3 = x3[0] >= (unsigned long long) (1U << s3);
+ unsigned long long y3 = 1U << s3;
+ int b3 = x3[0] >= y3;
+ if (a3 != b3)
+ abort ();
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56205.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56205.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56205.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56205.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,61 @@
+/* PR tree-optimization/56205 */
+
+#include <stdarg.h>
+
+int a, b;
+char c[128];
+
+__attribute__((noinline, noclone)) static void
+f1 (const char *fmt, ...)
+{
+ va_list ap;
+ asm volatile ("" : : : "memory");
+ if (__builtin_strcmp (fmt, "%s %d %s") != 0)
+ __builtin_abort ();
+ va_start (ap, fmt);
+ if (__builtin_strcmp (va_arg (ap, const char *), "foo") != 0
+ || va_arg (ap, int) != 1
+ || __builtin_strcmp (va_arg (ap, const char *), "bar") != 0)
+ __builtin_abort ();
+ va_end (ap);
+}
+
+__attribute__((noinline, noclone)) static void
+f2 (const char *fmt, va_list ap)
+{
+ asm volatile ("" : : : "memory");
+ if (__builtin_strcmp (fmt, "baz") != 0
+ || __builtin_strcmp (va_arg (ap, const char *), "foo") != 0
+ || va_arg (ap, double) != 12.0
+ || va_arg (ap, int) != 26)
+ __builtin_abort ();
+}
+
+static void
+f3 (int x, char const *y, va_list z)
+{
+ f1 ("%s %d %s", x ? "" : "foo", ++a, (y && *y) ? "bar" : "");
+ if (y && *y)
+ f2 (y, z);
+}
+
+__attribute__((noinline, noclone)) void
+f4 (int x, char const *y, ...)
+{
+ va_list z;
+ va_start (z, y);
+ if (!x && *c == '\0')
+ ++b;
+ f3 (x, y, z);
+ va_end (z);
+}
+
+int
+main ()
+{
+ asm volatile ("" : : : "memory");
+ f4 (0, "baz", "foo", 12.0, 26);
+ if (a != 1 || b != 1)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56250.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56250.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56250.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56250.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,13 @@
+/* PR tree-optimization/56250 */
+
+extern void abort (void);
+
+int
+main ()
+{
+ unsigned int x = 2;
+ unsigned int y = (0U - x / 2) / 2;
+ if (-1U / x != y)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56799.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56799.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56799.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56799.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,42 @@
+/* { dg-require-effective-target int32plus } */
+
+#include <stdio.h>
+typedef struct { int x; int y;} S;
+extern int foo(S*);
+int hi = 0, lo = 0;
+
+int main()
+{
+ S a;
+ int r;
+ a.x = (int) 0x00010000;
+ a.y = 1;
+ r = foo (&a);
+ if (r == 2 && lo==0 && hi==1)
+ {
+ exit (0);
+ }
+ abort ();
+}
+
+typedef unsigned short u16;
+
+__attribute__ ((noinline)) int foo (S* ptr)
+{
+ int a = ptr->x;
+ int c = 0;
+ u16 b = (u16) a;
+ if (b != 0)
+ {
+ lo = 1;
+ c += ptr->y;
+ }
+ b = a >> 16;
+ if (b != 0)
+ {
+ hi = 1;
+ c+= ptr->y;
+ }
+ c += ptr->y;
+ return c;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56837.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56837.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56837.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56837.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+extern void abort (void);
+_Complex int a[1024];
+
+__attribute__((noinline, noclone)) void
+foo (void)
+{
+ int i;
+ for (i = 0; i < 1024; i++)
+ a[i] = -1;
+}
+
+int
+main ()
+{
+ int i;
+ foo ();
+ for (i = 0; i < 1024; i++)
+ if (a[i] != -1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56866.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56866.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56866.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56866.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,45 @@
+/* PR target/56866 */
+
+int
+main ()
+{
+#if __CHAR_BIT__ == 8 && __SIZEOF_LONG_LONG__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_SHORT__ == 2
+ unsigned long long wq[256], rq[256];
+ unsigned int wi[256], ri[256];
+ unsigned short ws[256], rs[256];
+ unsigned char wc[256], rc[256];
+ int t;
+
+ __builtin_memset (wq, 0, sizeof wq);
+ __builtin_memset (wi, 0, sizeof wi);
+ __builtin_memset (ws, 0, sizeof ws);
+ __builtin_memset (wc, 0, sizeof wc);
+ wq[0] = 0x0123456789abcdefULL;
+ wi[0] = 0x01234567;
+ ws[0] = 0x4567;
+ wc[0] = 0x73;
+
+ asm volatile ("" : : "g" (wq), "g" (wi), "g" (ws), "g" (wc) : "memory");
+
+ for (t = 0; t < 256; ++t)
+ rq[t] = (wq[t] >> 8) | (wq[t] << (sizeof (wq[0]) * __CHAR_BIT__ - 8));
+ for (t = 0; t < 256; ++t)
+ ri[t] = (wi[t] >> 8) | (wi[t] << (sizeof (wi[0]) * __CHAR_BIT__ - 8));
+ for (t = 0; t < 256; ++t)
+ rs[t] = (ws[t] >> 9) | (ws[t] << (sizeof (ws[0]) * __CHAR_BIT__ - 9));
+ for (t = 0; t < 256; ++t)
+ rc[t] = (wc[t] >> 5) | (wc[t] << (sizeof (wc[0]) * __CHAR_BIT__ - 5));
+
+ asm volatile ("" : : "g" (rq), "g" (ri), "g" (rs), "g" (rc) : "memory");
+
+ if (rq[0] != 0xef0123456789abcdULL || rq[1])
+ __builtin_abort ();
+ if (ri[0] != 0x67012345 || ri[1])
+ __builtin_abort ();
+ if (rs[0] != 0xb3a2 || rs[1])
+ __builtin_abort ();
+ if (rc[0] != 0x9b || rc[1])
+ __builtin_abort ();
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56899.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56899.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56899.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56899.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,47 @@
+/* PR tree-optimization/56899 */
+
+#if __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8
+__attribute__((noinline, noclone)) void
+f1 (int v)
+{
+ int x = -214748365 * (v - 1);
+ if (x != -1932735285)
+ __builtin_abort ();
+}
+
+__attribute__((noinline, noclone)) void
+f2 (int v)
+{
+ int x = 214748365 * (v + 1);
+ if (x != -1932735285)
+ __builtin_abort ();
+}
+
+__attribute__((noinline, noclone)) void
+f3 (unsigned int v)
+{
+ unsigned int x = -214748365U * (v - 1);
+ if (x != -1932735285U)
+ __builtin_abort ();
+}
+
+__attribute__((noinline, noclone)) void
+f4 (unsigned int v)
+{
+ unsigned int x = 214748365U * (v + 1);
+ if (x != -1932735285U)
+ __builtin_abort ();
+}
+#endif
+
+int
+main ()
+{
+#if __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8
+ f1 (10);
+ f2 (-10);
+ f3 (10);
+ f4 (-10U);
+#endif
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56962.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56962.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56962.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56962.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,30 @@
+/* PR tree-optimization/56962 */
+
+extern void abort (void);
+long long v[144];
+
+__attribute__((noinline, noclone)) void
+bar (long long *x)
+{
+ if (x != &v[29])
+ abort ();
+}
+
+__attribute__((noinline, noclone)) void
+foo (long long *x, long y, long z)
+{
+ long long a, b, c;
+ a = x[z * 4 + y * 3];
+ b = x[z * 5 + y * 3];
+ c = x[z * 5 + y * 4];
+ x[y * 4] = a;
+ bar (&x[z * 5 + y]);
+ x[z * 5 + y * 5] = b + c;
+}
+
+int
+main ()
+{
+ foo (v, 24, 1);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56982.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56982.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56982.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr56982.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,46 @@
+/* { dg-require-effective-target indirect_jumps } */
+#include <setjmp.h>
+
+extern void abort (void);
+extern void exit (int);
+
+static jmp_buf env;
+
+void baz (void)
+{
+ __asm__ volatile ("" : : : "memory");
+}
+
+static inline int g(int x)
+{
+ if (x)
+ {
+ baz();
+ return 0;
+ }
+ else
+ {
+ baz();
+ return 1;
+ }
+}
+
+int f(int *e)
+{
+ if (*e)
+ return 1;
+
+ int x = setjmp(env);
+ int n = g(x);
+ if (n == 0)
+ exit(0);
+ if (x)
+ abort();
+ longjmp(env, 42);
+}
+
+int main(int argc, char** argv)
+{
+ int v = 0;
+ return f(&v);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57124.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57124.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57124.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57124.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+/* { dg-require-effective-target int32plus } */
+/* { dg-options "-fno-strict-overflow" } */
+
+extern void abort (void);
+extern void exit (int);
+
+__attribute__ ((noinline)) void
+foo(short unsigned int *p1, short unsigned int *p2)
+{
+ short unsigned int x1, x4;
+ int x2, x3, x5, x6;
+ unsigned int x7;
+
+ x1 = *p1;
+ x2 = (int) x1;
+ x3 = x2 * 65536;
+ x4 = *p2;
+ x5 = (int) x4;
+ x6 = x3 + x4;
+ x7 = (unsigned int) x6;
+ if (x7 <= 268435455U)
+ abort ();
+ exit (0);
+}
+
+int
+main()
+{
+ short unsigned int x, y;
+ x = -5;
+ y = -10;
+ foo (&x, &y);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57130.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57130.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57130.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57130.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR rtl-optimization/57130 */
+
+struct S { int a, b, c, d; } s[2] = { { 6, 8, -8, -5 }, { 0, 2, -1, 2 } };
+
+__attribute__((noinline, noclone)) void
+foo (struct S r)
+{
+ static int cnt;
+ if (__builtin_memcmp (&r, &s[cnt++], sizeof r) != 0)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ struct S r = { 6, 8, -8, -5 };
+ foo (r);
+ r = (struct S) { 0, 2, -1, 2 };
+ foo (r);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57131.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57131.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57131.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57131.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+/* PR rtl-optimization/57131 */
+
+extern void abort (void);
+
+int
+main ()
+{
+ volatile int x1 = 0;
+ volatile long long x2 = 0;
+ volatile int x3 = 0;
+ volatile int x4 = 1;
+ volatile int x5 = 1;
+ volatile long long x6 = 1;
+ long long t = ((x1 * (x2 << x3)) / (x4 * x5)) + x6;
+
+ if (t != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57144.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57144.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57144.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57144.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,19 @@
+extern void abort (void);
+extern void exit (int);
+
+void __attribute__ ((noinline))
+foo(int a)
+{
+ int z = a > 0 ? a : -a;
+ long long x = z;
+ if (x > 0x100000000LL)
+ abort ();
+ else
+ exit (0);
+}
+
+int
+main()
+{
+ foo (1);
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57281.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57281.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57281.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57281.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/57281 */
+
+int a = 1, b, d, *e = &d;
+long long c, *g = &c;
+volatile long long f;
+
+int
+foo (int h)
+{
+ int j = *g = b;
+ return h == 0 ? j : 0;
+}
+
+int
+main ()
+{
+ int h = a;
+ for (; b != -20; b--)
+ {
+ (int) f;
+ *e = 0;
+ *e = foo (h);
+ }
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57321.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57321.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57321.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57321.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,24 @@
+/* PR tree-optimization/57321 */
+
+int a = 1, *b, **c;
+
+static int
+foo (int *p)
+{
+ if (*p == a)
+ {
+ int *i[7][5] = { { 0 } };
+ int **j[1][1];
+ j[0][0] = &i[0][0];
+ *b = &p != c;
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ int i = 0;
+ foo (&i);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+/* PR middle-end/57344 */
+
+struct __attribute__((packed)) S
+{
+ int a : 11;
+#if __SIZEOF_INT__ * __CHAR_BIT__ >= 32
+ int b : 22;
+#else
+ int b : 13;
+#endif
+ char c;
+ int : 0;
+} s[2];
+int i;
+
+__attribute__((noinline, noclone)) void
+foo (int x)
+{
+ if (x != -3161)
+ __builtin_abort ();
+ asm volatile ("" : : : "memory");
+}
+
+int
+main ()
+{
+ struct S t = { 0, -3161L };
+ s[1] = t;
+ for (; i < 1; i++)
+ foo (s[1].b);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-2.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-2.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-2.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-2.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+/* PR middle-end/57344 */
+/* { dg-require-effective-target int32plus } */
+
+struct __attribute__((packed)) S
+{
+ int a : 27;
+#if __SIZEOF_INT__ * __CHAR_BIT__ >= 32
+ int b : 22;
+#else
+ int b : 13;
+#endif
+ char c;
+ int : 0;
+} s[2];
+int i;
+
+__attribute__((noinline, noclone)) void
+foo (int x)
+{
+ if (x != -3161)
+ __builtin_abort ();
+ asm volatile ("" : : : "memory");
+}
+
+int
+main ()
+{
+ struct S t = { 0, -3161L };
+ s[1] = t;
+ for (; i < 1; i++)
+ foo (s[1].b);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-3.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-3.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-3.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-3.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* PR middle-end/57344 */
+
+struct __attribute__((packed)) S
+{
+ long long int a : 43;
+ long long int b : 22;
+ char c;
+ long long int : 0;
+} s[2];
+int i;
+
+__attribute__((noinline, noclone)) void
+foo (long long int x)
+{
+ if (x != -3161LL)
+ __builtin_abort ();
+ asm volatile ("" : : : "memory");
+}
+
+int
+main ()
+{
+ struct S t = { 0, -3161LL };
+ s[1] = t;
+ for (; i < 1; i++)
+ foo (s[1].b);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-4.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-4.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-4.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57344-4.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* PR middle-end/57344 */
+
+struct __attribute__((packed)) S
+{
+ long long int a : 59;
+ long long int b : 54;
+ char c;
+ long long int : 0;
+} s[2];
+int i;
+
+__attribute__((noinline, noclone)) void
+foo (long long int x)
+{
+ if (x != -1220975898975746LL)
+ __builtin_abort ();
+ asm volatile ("" : : : "memory");
+}
+
+int
+main ()
+{
+ struct S t = { 0, -1220975898975746LL };
+ s[1] = t;
+ for (; i < 1; i++)
+ foo (s[1].b);
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57568.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57568.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57568.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57568.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,12 @@
+/* PR target/57568 */
+
+extern void abort (void);
+int a[6][9] = { }, b = 1, *c = &a[3][5];
+
+int
+main ()
+{
+ if (b && (*c = *c + *c))
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57829.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57829.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57829.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57829.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,31 @@
+/* PR rtl-optimization/57829 */
+
+__attribute__((noinline, noclone))
+int
+f1 (int k)
+{
+ return 2 | ((k - 1) >> ((int) sizeof (int) * __CHAR_BIT__ - 1));
+}
+
+__attribute__((noinline, noclone))
+long int
+f2 (long int k)
+{
+ return 2L | ((k - 1L) >> ((int) sizeof (long int) * __CHAR_BIT__ - 1));
+}
+
+__attribute__((noinline, noclone))
+int
+f3 (int k)
+{
+ k &= 63;
+ return 4 | ((k + 2) >> 5);
+}
+
+int
+main ()
+{
+ if (f1 (1) != 2 || f2 (1L) != 2L || f3 (63) != 6 || f3 (1) != 4)
+ __builtin_abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57860.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57860.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57860.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57860.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/57860 */
+
+extern void abort (void);
+int a, *b = &a, c, d, e, *f = &e, g, *h = &d, k[1] = { 1 };
+
+int
+foo (int p)
+{
+ for (;; g++)
+ {
+ for (; c; c--);
+ *f = *h = p > ((0x1FFFFFFFFLL ^ a) & *b);
+ if (k[g])
+ return 0;
+ }
+}
+
+int
+main ()
+{
+ foo (1);
+ if (d != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57861.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57861.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57861.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57861.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,33 @@
+/* PR rtl-optimization/57861 */
+
+extern void abort (void);
+short a = 1, f;
+int b, c, d, *g = &b, h, i, j;
+unsigned int e;
+
+static int
+foo (char p)
+{
+ int k;
+ for (c = 0; c < 2; c++)
+ {
+ i = (j = 0) || p;
+ k = i * p;
+ if (e < k)
+ {
+ short *l = &f;
+ a = d && h;
+ *l = 0;
+ }
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ *g = foo (a);
+ if (a != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57875.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57875.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57875.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57875.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,21 @@
+/* PR rtl-optimization/57875 */
+
+extern void abort (void);
+int a[1], b, c, d, f, i;
+char e[1];
+
+int
+main ()
+{
+ for (; i < 1; i++)
+ if (!d)
+ {
+ if (!c)
+ f = 2;
+ e[0] &= f ^= 0;
+ }
+ b = a[e[0] >> 1 & 1];
+ if (b != 0)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57876.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57876.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57876.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57876.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,27 @@
+/* PR rtl-optimization/57876 */
+
+extern void abort (void);
+int a, b = 1, c, *d = &c, f, *g, h, j;
+static int e;
+
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 2; i++)
+ {
+ long long k = b;
+ int l;
+ for (f = 0; f < 8; f++)
+ {
+ int *m = &e;
+ j = *d;
+ h = a * j - 1;
+ *m = (h == 0) < k;
+ g = &l;
+ }
+ }
+ if (e != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57877.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57877.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57877.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr57877.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,28 @@
+/* PR rtl-optimization/57877 */
+
+extern void abort (void);
+int a, b, *c = &b, e, f = 6, g, h;
+short d;
+
+static unsigned char
+foo (unsigned long long p1, int *p2)
+{
+ for (; g <= 0; g++)
+ {
+ short *i = &d;
+ int *j = &e;
+ h = *c;
+ *i = h;
+ *j = (*i == *p2) < p1;
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ foo (f, &a);
+ if (e != 1)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58209.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58209.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58209.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58209.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,32 @@
+/* PR tree-optimization/58209 */
+
+extern void abort (void);
+typedef __INTPTR_TYPE__ T;
+T buf[1024];
+
+T *
+foo (T n)
+{
+ if (n == 0)
+ return (T *) buf;
+ T s = (T) foo (n - 1);
+ return (T *) (s + sizeof (T));
+}
+
+T *
+bar (T n)
+{
+ if (n == 0)
+ return buf;
+ return foo (n - 1) + 1;
+}
+
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 27; i++)
+ if (foo (i) != buf + i || bar (i) != buf + i)
+ abort ();
+ return 0;
+}
Added: test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58277-1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58277-1.c?rev=374156&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58277-1.c (added)
+++ test-suite/trunk/SingleSource/Regression/C/gcc-c-torture/execute/pr58277-1.c Wed Oct 9 04:01:46 2019
@@ -0,0 +1,102 @@
+/* PR tree-optimization/58277 */
+
+extern void abort (void);
+static int a[2];
+int b, c, d, *e, f, g, h, **i = &e, k, l = 1, n, o, p;
+static int **volatile j = &e;
+const int m;
+char u;
+
+int
+bar ()
+{
+ u = 0;
+ return m;
+}
+
+__attribute__((noinline, noclone)) void
+baz ()
+{
+ asm ("");
+}
+
+static int
+foo ()
+{
+ int t1;
+ g = bar ();
+ if (l)
+ ;
+ else
+ for (;; h++)
+ {
+ *i = 0;
+ o = *e = 0;
+ if (p)
+ {
+ f = 0;
+ return 0;
+ }
+ for (;; k++)
+ {
+ int *t2 = 0;
+ int *const *t3[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, &t2, &t2, &t2,
+ &t2, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, &t2,
+ &t2, &t2, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, 0,
+ &t2, 0, 0, 0, &t2, 0, &t2, 0, 0, &t2, 0, 0, 0, 0,
+ 0, &t2, 0, 0, 0, 0, &t2, &t2, 0, 0, 0, 0, &t2, 0,
+ 0, 0, 0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, &t2, 0, 0, 0,
+ &t2, &t2
+ };
+ int *const **t4[] = {&t3[0]};
+ **i = 0;
+ if (**j)
+ break;
+ u = 0;
+ }
+ *i = *j;
+ t1 = 0;
+ for (; t1 < 5; t1++)
+ *i = *j;
+ }
+ *j = 0;
+ return 1;
+}
+
+int
+main ()
+{
+ int t5;
+ a[0] = 1;
+ {
+ int *t6[6] = {&d, &d};
+ for (n = 1; n; n--)
+ if (foo())
+ {
+ int *t7[] = {0};
+ d = 0;
+ for (; u < 1; u++)
+ *i = *j;
+ *i = 0;
+ *i = 0;
+ int t8[5] = {0};
+ *i = &t8[0];
+ int *const *t9 = &t6[0];
+ int *const **t10 = &t9;
+ *t10 = &t7[0];
+ }
+ }
+ u = 0;
+ for (; b; b++)
+ for (t5 = 0; t5 < 10; t5++)
+ c = a[a[a[a[a[a[a[a[c]]]]]]]];
+
+ baz ();
+
+ if (!a[a[a[a[a[a[a[a[a[a[a[a[a[a[a[u]]]]]]]]]]]]]]])
+ abort ();
+
+ return 0;
+}
More information about the llvm-commits
mailing list