diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-02-02 12:42:10 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-02-02 12:42:10 -0800 |
commit | 8910f1cd79445bbe2da01f8ccf7c37909349529e (patch) | |
tree | ba67a346969358fd7cc2b7c12384479de8364cab /gcc/testsuite/gcc.dg | |
parent | 45c32be1f96ace25b66c34a84818dc5e07e9d516 (diff) | |
parent | 8e4a738d2540ab6aff77506d368bf4e3fa6963bd (diff) | |
download | gcc-8910f1cd79445bbe2da01f8ccf7c37909349529e.zip gcc-8910f1cd79445bbe2da01f8ccf7c37909349529e.tar.gz gcc-8910f1cd79445bbe2da01f8ccf7c37909349529e.tar.bz2 |
Merge from trunk revision 8e4a738d2540ab6aff77506d368bf4e3fa6963bd.
Diffstat (limited to 'gcc/testsuite/gcc.dg')
280 files changed, 5980 insertions, 245 deletions
diff --git a/gcc/testsuite/gcc.dg/20021029-1.c b/gcc/testsuite/gcc.dg/20021029-1.c index 57c2b48..d13f669 100644 --- a/gcc/testsuite/gcc.dg/20021029-1.c +++ b/gcc/testsuite/gcc.dg/20021029-1.c @@ -3,7 +3,7 @@ /* { dg-do compile { target fpic } } */ /* { dg-options "-O2 -fpic" } */ /* { dg-final { scan-assembler-not ".data.rel.ro.local" } } */ -/* { dg-final { scan-assembler-symbol-section {ar} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?ar} {^\.(const|rodata)|\[RO\]} } } */ /* { dg-require-effective-target label_values } */ /* { dg-require-effective-target indirect_jumps } */ diff --git a/gcc/testsuite/gcc.dg/README b/gcc/testsuite/gcc.dg/README index 44e4b33..1c8c1c7 100644 --- a/gcc/testsuite/gcc.dg/README +++ b/gcc/testsuite/gcc.dg/README @@ -16,7 +16,7 @@ Notes for testsuite/gcc.dg. 4) Send bugs, comments, etc. to dje@cygnus.com. -Copyright (C) 1997-2020 Free Software Foundation, Inc. +Copyright (C) 1997-2021 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/gcc/testsuite/gcc.dg/Walloca-2.c b/gcc/testsuite/gcc.dg/Walloca-2.c index 1cf9165..c81813e 100644 --- a/gcc/testsuite/gcc.dg/Walloca-2.c +++ b/gcc/testsuite/gcc.dg/Walloca-2.c @@ -9,11 +9,7 @@ g1 (int n) { void *p; if (n > 0 && n < 2000) - // FIXME: This is a bogus warning, and is currently happening on - // 32-bit targets because VRP is not giving us any range info for - // the argument to __builtin_alloca. This should be fixed by the - // upcoming range work. - p = __builtin_alloca (n); // { dg-bogus "unbounded use of 'alloca'" "" { xfail { ! lp64 } } } + p = __builtin_alloca (n); // { dg-bogus "unbounded use of 'alloca'" "" } else p = __builtin_malloc (n); f (p); diff --git a/gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c new file mode 100644 index 0000000..a7d9212 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wfree-nonheap-object-4.c @@ -0,0 +1,107 @@ +/* PR middle-end/98664 - inconsistent --Wfree-nonheap-object for inlined + calls to system headers + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +# 7 "Wfree-nonheap-object-4.h" 1 3 + +struct A +{ + void *p; +}; + +void f0 (struct A *p, void *q) { p->p = q; } +void f1 (struct A *p, void *q) { f0 (p, q); } +void f2 (struct A *p, void *q) { f1 (p, q); } + +void g0 (struct A *p) +{ + __builtin_free (p->p); // { dg-warning "\\\[-Wfree-nonheap-object" } +} + +void g1 (struct A *p) { g0 (p); } +void g2 (struct A *p) { g1 (p); } + +# 26 "Wfree-nonheap-object-4.c" + +#define NOIPA __attribute__ ((noipa)) + +extern int array[]; + +/* Verify the warning is issued even for calls in a system header inlined + into a function outside the header. */ + +NOIPA void warn_g0 (struct A *p) +{ + int *q = array + 1; + + f0 (p, q); + g0 (p); +} + +// { dg-message "inlined from 'warn_g0'" "" { target *-*-* } 0 } + + +/* Also verify the warning can be suppressed. */ + +NOIPA void nowarn_g0 (struct A *p) +{ + int *q = array + 2; + + f0 (p, q); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" + g0 (p); +#pragma GCC diagnostic pop +} + + +NOIPA void warn_g1 (struct A *p) +{ + int *q = array + 3; + + f1 (p, q); + g1 (p); +} + +// { dg-message "inlined from 'g1'" "" { target *-*-* } 0 } +// { dg-message "inlined from 'warn_g1'" "" { target *-*-* } 0 } + + +NOIPA void nowarn_g1 (struct A *p) +{ + int *q = array + 4; + + f1 (p, q); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" + g1 (p); +#pragma GCC diagnostic pop +} + + +NOIPA void warn_g2 (struct A *p) +{ + int *q = array + 5; + + f2 (p, q); + g2 (p); +} + +// { dg-message "inlined from 'g2'" "" { target *-*-* } 0 } +// { dg-message "inlined from 'warn_g2'" "" { target *-*-* } 0 } + + +NOIPA void nowarn_g2 (struct A *p) +{ + int *q = array + 6; + + f2 (p, q); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" + g2 (p); +#pragma GCC diagnostic pop +} diff --git a/gcc/testsuite/gcc.dg/Wmismatched-dealloc-2.c b/gcc/testsuite/gcc.dg/Wmismatched-dealloc-2.c new file mode 100644 index 0000000..21a5ea7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wmismatched-dealloc-2.c @@ -0,0 +1,141 @@ +/* PR middle-end/94527 - Add an attribute that marks a function as freeing + an object + Verify that attribute malloc with one or two arguments has the expected + effect on diagnostics. + { dg-options "-Wall -ftrack-macro-expansion=0" } */ + +#define A(...) __attribute__ ((malloc (__VA_ARGS__), noipa)) + +typedef __SIZE_TYPE__ size_t; +typedef struct A A; +typedef struct B B; + +/* A pointer returned by any of the four functions must be deallocated + either by dealloc() or by realloc_{A,B}(). */ +A (__builtin_free) A* alloc_A (int); +A (__builtin_free) B* alloc_B (int); +A (__builtin_free) A* realloc_A (A *p, int n) { return p; } +A (__builtin_free) B* realloc_B (B *p, int n) { return p; } + +A (realloc_A) A* alloc_A (int); +A (realloc_B) B* alloc_B (int); +A (realloc_A) A* realloc_A (A*, int); +A (realloc_B) B* realloc_B (B*, int); + +void dealloc (void*); +A (dealloc) void* alloc (int); + +void sink (void*); + +void test_alloc_A (void) +{ + { + void *p = alloc_A (1); + p = realloc_A (p, 2); + __builtin_free (p); + } + + { + void *p = alloc_A (1); + /* Verify that calling realloc doesn't trigger a warning even though + alloc_A is not directly associated with it. */ + p = __builtin_realloc (p, 2); + sink (p); + } + + { + void *p = alloc_A (1); // { dg-message "returned from 'alloc_A'" } + dealloc (p); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } + + { + /* Because alloc_A() and realloc_B() share free() as a deallocator + they must also be valid as each other's deallocators. */ + void *p = alloc_A (1); + p = realloc_B ((B*)p, 2); + __builtin_free (p); + } + + { + void *p = alloc_A (1); + p = realloc_A (p, 2); + p = __builtin_realloc (p, 3); + __builtin_free (p); + } +} + + +void test_realloc_A (void *ptr) +{ + { + void *p = realloc_A (0, 1); + p = realloc_A (p, 2); + __builtin_free (p); + } + + { + void *p = realloc_A (ptr, 2); + p = realloc_A (p, 2); + __builtin_free (p); + } + + { + void *p = realloc_A (0, 3); + p = __builtin_realloc (p, 2); + sink (p); + } + + { + void *p = realloc_A (0, 4); // { dg-message "returned from 'realloc_A'" } + dealloc (p); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } + + { + /* Because realloc_A() and realloc_B() share free() as a deallocator + they must also be valid as each other's deallocators. */ + void *p = realloc_A (0, 5); + p = realloc_B ((B*)p, 2); + __builtin_free (p); + } + + { + void *p = realloc_A (0, 6); + p = realloc_A ((A*)p, 2); + p = __builtin_realloc (p, 3); + __builtin_free (p); + } +} + + +void test_realloc (void *ptr) +{ + extern void free (void*); + extern void* realloc (void*, size_t); + + { + void *p = realloc (ptr, 1); + p = realloc_A (p, 2); + __builtin_free (p); + } + + { + void *p = realloc (ptr, 2); + p = realloc_A (p, 2); + free (p); + } + + { + void *p = realloc (ptr, 3); + free (p); + } + + { + void *p = realloc (ptr, 4); + __builtin_free (p); + } + + { + void *p = realloc (ptr, 5); // { dg-message "returned from 'realloc'" } + dealloc (p); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } +} diff --git a/gcc/testsuite/gcc.dg/Wmismatched-dealloc-3.c b/gcc/testsuite/gcc.dg/Wmismatched-dealloc-3.c new file mode 100644 index 0000000..5afcea3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wmismatched-dealloc-3.c @@ -0,0 +1,265 @@ +/* Verify that Glibc <stdlib.h> declarations are handled correctly + { dg-do compile } + { dg-options "-Wall" } */ + +#define A(...) __attribute__ ((malloc (__VA_ARGS__), noipa)) + +typedef __SIZE_TYPE__ size_t; + +/* All functions with the same standard deallocator are associated + with each other. */ +void free (void*); +void* calloc (size_t, size_t); +void* malloc (size_t); +void* realloc (void*, size_t); + +A (__builtin_free) void* aligned_alloc (size_t, size_t); + +/* Like realloc(), reallocarray() is both an allocator and a deallocator. + It must be associated with both free() and with itself, but nothing + else. */ +A (__builtin_free) void* reallocarray (void*, size_t, size_t); +A (reallocarray) void* reallocarray (void*, size_t, size_t); + +A (__builtin_free) extern char *canonicalize_file_name (const char*); + + +void dealloc (void*); +A (dealloc) void* alloc (size_t); + + +void sink (void*); +void* source (void); + + +void test_builtin_aligned_alloc (void *p) +{ + { + void *q = __builtin_aligned_alloc (1, 2); + sink (q); + __builtin_free (q); + } + + { + void *q = __builtin_aligned_alloc (1, 2); + sink (q); + free (q); + } + + { + void *q = __builtin_aligned_alloc (1, 2); + q = __builtin_realloc (q, 3); + sink (q); + free (q); + } + + { + void *q = __builtin_aligned_alloc (1, 2); + q = realloc (q, 3); + sink (q); + free (q); + } + + { + void *q; + q = __builtin_aligned_alloc (1, 2); // { dg-message "returned from '__builtin_aligned_alloc'" } + sink (q); + dealloc (q); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } +} + + +void test_aligned_alloc (void *p) +{ + { + void *q = aligned_alloc (1, 2); + sink (q); + __builtin_free (q); + } + + { + void *q = aligned_alloc (1, 2); + sink (q); + free (q); + } + + { + void *q = aligned_alloc (1, 2); + q = __builtin_realloc (q, 3); + sink (q); + free (q); + } + + { + void *q = aligned_alloc (1, 2); + q = realloc (q, 3); + sink (q); + free (q); + } + + { + void *q = aligned_alloc (1, 2); // { dg-message "returned from 'aligned_alloc'" } + sink (q); + dealloc (q); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } +} + + +void test_reallocarray (void *p) +{ + { + void *q = __builtin_aligned_alloc (1, 2); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = aligned_alloc (1, 2); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = __builtin_calloc (1, 2); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = calloc (1, 2); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = __builtin_malloc (1); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = malloc (1); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = __builtin_realloc (p, 1); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = realloc (p, 1); + q = reallocarray (q, 2, 3); + sink (q); + free (q); + } + + { + void *q = __builtin_strdup ("abc"); + q = reallocarray (q, 3, 4); + sink (q); + free (q); + } + + { + void *q = __builtin_strndup ("abcd", 3); + q = reallocarray (q, 4, 5); + sink (q); + free (q); + } + + { + void *q = source (); + q = reallocarray (q, 5, 6); + sink (q); + free (q); + } + + { + void *q = alloc (1); // { dg-message "returned from 'alloc'" } + q = reallocarray (q, 6, 7); // { dg-warning "'reallocarray' called on pointer returned from a mismatched allocation function" } + sink (q); + free (q); + } + + { + void *q = reallocarray (p, 7, 8); + q = __builtin_realloc (q, 9); + sink (q); + free (q); + } + + { + void *q = reallocarray (p, 7, 8); + q = realloc (q, 9); + sink (q); + free (q); + } + + { + void *q = reallocarray (p, 8, 9); + q = reallocarray (q, 3, 4); + sink (q); + free (q); + } + + { + void *q = reallocarray (p, 9, 10); + q = reallocarray (q, 3, 4); + sink (q); + dealloc (q); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } +} + + +void test_canonicalize_filename (void *p) +{ + { + void *q = canonicalize_file_name ("a"); + sink (q); + __builtin_free (q); + } + + { + void *q = canonicalize_file_name ("b"); + sink (q); + free (q); + } + + { + void *q = canonicalize_file_name ("c"); + q = __builtin_realloc (q, 2); + sink (q); + free (q); + } + + { + void *q = canonicalize_file_name ("d"); + q = realloc (q, 3); + sink (q); + free (q); + } + + { + void *q = canonicalize_file_name ("e"); + q = reallocarray (q, 4, 5); + sink (q); + free (q); + } + + { + void *q; + q = canonicalize_file_name ("f"); // { dg-message "returned from 'canonicalize_file_name'" } + sink (q); + dealloc (q); // { dg-warning "'dealloc' called on pointer returned from a mismatched allocation function" } + } +} diff --git a/gcc/testsuite/gcc.dg/Wmismatched-dealloc.c b/gcc/testsuite/gcc.dg/Wmismatched-dealloc.c index 7c5d6ac..6336efa 100644 --- a/gcc/testsuite/gcc.dg/Wmismatched-dealloc.c +++ b/gcc/testsuite/gcc.dg/Wmismatched-dealloc.c @@ -13,28 +13,27 @@ void free (void*); void* malloc (size_t); void* realloc (void*, size_t); -int fclose (FILE*); -FILE* freopen (const char*, const char*, FILE*); -int pclose (FILE*); - -A (fclose) A (freopen, 3) - FILE* fdopen (int); -A (fclose) A (freopen, 3) - FILE* fopen (const char*, const char*); -A (fclose) A (freopen, 3) - FILE* fmemopen(void *, size_t, const char *); -A (fclose) A (freopen, 3) - FILE* freopen (const char*, const char*, FILE*); -A (pclose) A (freopen, 3) - FILE* popen (const char*, const char*); -A (fclose) A (freopen, 3) - FILE* tmpfile (void); +/* Declare functions with the minimum attributes malloc how they're + likely going to be declared in <stdio.h>. */ + int fclose (FILE*); +A (fclose) FILE* fdopen (int); +A (fclose) FILE* fopen (const char*, const char*); +A (fclose) FILE* fmemopen(void *, size_t, const char *); +A (fclose) FILE* freopen (const char*, const char*, FILE*); +A (freopen, 3) FILE* freopen (const char*, const char*, FILE*); +A (fclose) FILE* tmpfile (void); -void sink (FILE*); +A (fclose) FILE* open_memstream (char**, size_t*); +A (fclose) FILE* open_wmemstream (char**, size_t*); + + int pclose (FILE*); +A (pclose) FILE* popen (const char*, const char*); + void release (void*); +A (release) FILE* acquire (void); + +void sink (FILE*); - void release (void*); -A (release) FILE* acquire (void); void nowarn_fdopen (void) { @@ -68,18 +67,18 @@ void nowarn_fdopen (void) void warn_fdopen (void) { { - FILE *q = fdopen (0); // { dg-message "returned from a call to 'fdopen'" "note" } + FILE *q = fdopen (0); // { dg-message "returned from 'fdopen'" "note" } sink (q); release (q); // { dg-warning "'release' called on pointer returned from a mismatched allocation function" } } { - FILE *q = fdopen (0); // { dg-message "returned from a call to 'fdopen'" "note" } + FILE *q = fdopen (0); // { dg-message "returned from 'fdopen'" "note" } sink (q); free (q); // { dg-warning "'free' called on pointer returned from a mismatched allocation function" } } { - FILE *q = fdopen (0); // { dg-message "returned from a call to 'fdopen'" "note" } + FILE *q = fdopen (0); // { dg-message "returned from 'fdopen'" "note" } sink (q); q = realloc (q, 7); // { dg-warning "'realloc' called on pointer returned from a mismatched allocation function" } sink (q); @@ -132,43 +131,104 @@ void warn_fopen (void) } -void test_popen (void) +void test_freopen (FILE *p[]) { { - FILE *p = popen ("1", "r"); + FILE *q = freopen ("1", "r", p[0]); + sink (q); + fclose (q); + } + { + FILE *q = freopen ("2", "r", p[1]); + sink (q); + q = freopen ("3", "r", q); + sink (q); + fclose (q); + } + + { + FILE *q; + q = freopen ("3", "r", p[2]); // { dg-message "returned from 'freopen'" } + sink (q); + q = realloc (q, 7); // { dg-warning "'realloc' called on pointer returned from a mismatched allocation function" } + sink (q); + } +} + + +void test_tmpfile (void) +{ + { + FILE *p = tmpfile (); sink (p); - pclose (p); + fclose (p); } { - FILE *p; - p = popen ("2", "r"); // { dg-message "returned from a call to 'popen'" "note" } + FILE *p = tmpfile (); sink (p); - fclose (p); // { dg-warning "'fclose' called on pointer returned from a mismatched allocation function" } + p = freopen ("1", "r", p); + sink (p); + fclose (p); } { - /* freopen() can close a stream open by popen() but pclose() can't - close the stream returned from freopen(). */ - FILE *p = popen ("2", "r"); + FILE *p = tmpfile (); // { dg-message "returned from 'tmpfile'" "note" } sink (p); - p = freopen ("3", "r", p); // { dg-message "returned from a call to 'freopen'" "note" } + pclose (p); // { dg-warning "'pclose' called on pointer returned from a mismatched allocation function" } + } +} + + +void test_open_memstream (char **bufp, size_t *sizep) +{ + { + FILE *p = open_memstream (bufp, sizep); + sink (p); + fclose (p); + } + + { + FILE *p = open_memstream (bufp, sizep); + sink (p); + p = freopen ("1", "r", p); + sink (p); + fclose (p); + } + + { + FILE *p; + p = open_memstream (bufp, sizep); // { dg-message "returned from 'open_memstream'" "note" } sink (p); pclose (p); // { dg-warning "'pclose' called on pointer returned from a mismatched allocation function" } } + + { + FILE *p; + p = open_memstream (bufp, sizep); // { dg-message "returned from 'open_memstream'" "note" } + sink (p); + free (p); // { dg-warning "'free' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *p; + p = open_memstream (bufp, sizep); // { dg-message "returned from 'open_memstream'" "note" } + sink (p); + release (p); // { dg-warning "'release' called on pointer returned from a mismatched allocation function" } + } } -void test_tmpfile (void) +void test_open_wmemstream (char **bufp, size_t *sizep) { { - FILE *p = tmpfile (); + FILE *p = open_wmemstream (bufp, sizep); sink (p); fclose (p); } { - FILE *p = tmpfile (); + FILE *p = open_wmemstream (bufp, sizep); sink (p); p = freopen ("1", "r", p); sink (p); @@ -176,29 +236,44 @@ void test_tmpfile (void) } { - FILE *p = tmpfile (); // { dg-message "returned from a call to 'tmpfile'" "note" } + FILE *p; + p = open_wmemstream (bufp, sizep); // { dg-message "returned from 'open_wmemstream'" "note" } sink (p); pclose (p); // { dg-warning "'pclose' called on pointer returned from a mismatched allocation function" } } + + { + FILE *p; + p = open_wmemstream (bufp, sizep); // { dg-message "returned from 'open_wmemstream'" "note" } + sink (p); + free (p); // { dg-warning "'free' called on pointer returned from a mismatched allocation function" } + } + + { + FILE *p; + p = open_wmemstream (bufp, sizep); // { dg-message "returned from 'open_wmemstream'" "note" } + sink (p); + release (p); // { dg-warning "'release' called on pointer returned from a mismatched allocation function" } + } } void warn_malloc (void) { { - FILE *p = malloc (100); // { dg-message "returned from a call to 'malloc'" "note" } + FILE *p = malloc (100); // { dg-message "returned from 'malloc'" "note" } sink (p); fclose (p); // { dg-warning "'fclose' called on pointer returned from a mismatched allocation function" } } { - FILE *p = malloc (100); // { dg-message "returned from a call to 'malloc'" "note" } + FILE *p = malloc (100); // { dg-message "returned from 'malloc'" "note" } sink (p); p = freopen ("1", "r", p);// { dg-warning "'freopen' called on pointer returned from a mismatched allocation function" } } { - FILE *p = malloc (100); // { dg-message "returned from a call to 'malloc'" "note" } + FILE *p = malloc (100); // { dg-message "returned from 'malloc'" "note" } sink (p); pclose (p); // { dg-warning "'pclose' called on pointer returned from a mismatched allocation function" } } @@ -219,32 +294,32 @@ void test_acquire (void) } { - FILE *p = acquire (); // { dg-message "returned from a call to 'acquire'" "note" } + FILE *p = acquire (); // { dg-message "returned from 'acquire'" "note" } sink (p); fclose (p); // { dg-warning "'fclose' called on pointer returned from a mismatched allocation function" } } { - FILE *p = acquire (); // { dg-message "returned from a call to 'acquire'" "note" } + FILE *p = acquire (); // { dg-message "returned from 'acquire'" "note" } sink (p); pclose (p); // { dg-warning "'pclose' called on pointer returned from a mismatched allocation function" } } { - FILE *p = acquire (); // { dg-message "returned from a call to 'acquire'" "note" } + FILE *p = acquire (); // { dg-message "returned from 'acquire'" "note" } sink (p); p = freopen ("1", "r", p); // { dg-warning "'freopen' called on pointer returned from a mismatched allocation function" } sink (p); } { - FILE *p = acquire (); // { dg-message "returned from a call to 'acquire'" "note" } + FILE *p = acquire (); // { dg-message "returned from 'acquire'" "note" } sink (p); free (p); // { dg-warning "'free' called on pointer returned from a mismatched allocation function" } } { - FILE *p = acquire (); // { dg-message "returned from a call to 'acquire'" "note" } + FILE *p = acquire (); // { dg-message "returned from 'acquire'" "note" } sink (p); p = realloc (p, 123); // { dg-warning "'realloc' called on pointer returned from a mismatched allocation function" } sink (p); diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-25.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-25.c index 774474d..0091644 100644 --- a/gcc/testsuite/gcc.dg/Wstrict-overflow-25.c +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-25.c @@ -7,5 +7,5 @@ int foo (int x, int y) { - return x - y < 0; /* { dg-warning "assuming signed overflow does not occur" "correct warning" { xfail *-*-* } } */ + return x - y < 0; /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ } diff --git a/gcc/testsuite/gcc.dg/Wvla-larger-than-4.c b/gcc/testsuite/gcc.dg/Wvla-larger-than-4.c index de99afb..7d27829 100644 --- a/gcc/testsuite/gcc.dg/Wvla-larger-than-4.c +++ b/gcc/testsuite/gcc.dg/Wvla-larger-than-4.c @@ -17,14 +17,14 @@ static inline void inline_use_vla (unsigned n) static inline void use_inlined_vla (unsigned n) { inline_use_vla (n); // this call is okay - inline_use_vla (n + 1); // this one is not + inline_use_vla (n + 1); // this one is not (line 20) } void call_inline (void) { - use_inlined_vla (31); + use_inlined_vla (31); // line 25 } /* Verify that the inlining context is included and that it points to the correct line number in the inlined function: - { dg-message "function 'inline_use_vla'..*inlined from 'call_inline' .*:20:" "" { target *-*-* } 0 } */ + { dg-message "function 'inline_use_vla'.*inlined from 'use_inlined_vla'.*:20:.*inlined from 'call_inline' .*:25:" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c index 9331993..073f97e 100644 --- a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c +++ b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c @@ -1,10 +1,8 @@ /* { dg-require-effective-target alloca } */ -#include <alloca.h> - void *test (void) { - void *ptr = alloca (64); + void *ptr = __builtin_alloca (64); return ptr; } /* TODO: warn about escaping alloca. */ diff --git a/gcc/testsuite/gcc.dg/analyzer/analyzer.exp b/gcc/testsuite/gcc.dg/analyzer/analyzer.exp index d72fef3..e4b198b 100644 --- a/gcc/testsuite/gcc.dg/analyzer/analyzer.exp +++ b/gcc/testsuite/gcc.dg/analyzer/analyzer.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2019 Free Software Foundation, Inc. +# Copyright (C) 2019-2021 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 diff --git a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c new file mode 100644 index 0000000..3de32b1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-1.c @@ -0,0 +1,75 @@ +extern void free (void *); + +struct foo +{ + int m_int; +}; + +extern void foo_release (struct foo *); +extern struct foo *foo_acquire (void) + __attribute__ ((malloc (foo_release))); +extern void use_foo (const struct foo *) + __attribute__((nonnull)); + +void test_1 (void) +{ + struct foo *p = foo_acquire (); + foo_release (p); +} + +void test_2 (void) +{ + struct foo *p = foo_acquire (); /* { dg-message "this call could return NULL" } */ + p->m_int = 42; /* { dg-warning "dereference of possibly-NULL 'p'" } */ + foo_release (p); +} + +void test_2a (void) +{ + struct foo *p = foo_acquire (); /* { dg-message "this call could return NULL" } */ + use_foo (p); /* { dg-warning "use of possibly-NULL 'p' where non-null expected" } */ + foo_release (p); +} + +void test_3 (void) +{ + struct foo *p = foo_acquire (); /* { dg-message "allocated here" } */ +} /* { dg-warning "leak of 'p'" } */ + +void test_4 (struct foo *p) +{ + foo_release (p); + foo_release (p); /* { dg-warning "double-'foo_release' of 'p'" } */ +} + +void test_4a (void) +{ + struct foo *p = foo_acquire (); + foo_release (p); + foo_release (p); /* { dg-warning "double-'foo_release' of 'p'" } */ +} + +void test_5 (void) +{ + struct foo *p = foo_acquire (); /* { dg-message "allocated here \\(expects deallocation with 'foo_release'\\)" } */ + free (p); /* { dg-warning "'p' should have been deallocated with 'foo_release' but was deallocated with 'free'" } */ +} + +void test_6 (struct foo *p) +{ + foo_release (p); + free (p); // TODO: double-release warning! +} + +void test_7 () +{ + struct foo f; + foo_release (&f); /* { dg-warning "not on the heap" "analyzer" } */ + /* { dg-warning "'foo_release' called on unallocated object 'f'" "non-analyzer" { target *-*-* } .-1 } */ +} + +int test_8 (struct foo *p) +{ + foo_release (p); + return p->m_int; /* { dg-warning "use after 'foo_release' of 'p'" } */ +} diff --git a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-2.c b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-2.c new file mode 100644 index 0000000..09d941f --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-2.c @@ -0,0 +1,24 @@ +extern void free (void *); +char *xstrdup (const char *) + __attribute__((malloc (free), returns_nonnull)); + +void test_1 (const char *s) +{ + char *p = xstrdup (s); + free (p); +} + +/* Verify that we don't issue -Wanalyzer-possible-null-dereference + when the allocator has __attribute__((returns_nonnull)). */ + +char *test_2 (const char *s) +{ + char *p = xstrdup (s); + p[0] = 'a'; /* { dg-bogus "possibly-NULL" } */ + return p; +} + +void test_3 (const char *s) +{ + char *p = xstrdup (s); /* { dg-message "allocated here" } */ +} /* { dg-warning "leak of 'p'" } */ diff --git a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-4.c b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-4.c new file mode 100644 index 0000000..1517667 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-4.c @@ -0,0 +1,21 @@ +/* An example where the deallocator requires non-NULL. */ + +struct foo; +extern void foo_release (struct foo *) + __attribute__((nonnull)); +extern struct foo *foo_acquire (void) + __attribute__ ((malloc (foo_release))); + +void test_1 (void) +{ + struct foo *p = foo_acquire (); /* { dg-message "this call could return NULL" } */ + foo_release (p); /* { dg-warning "use of possibly-NULL 'p' where non-null" } */ +} + +void test_2 (void) +{ + struct foo *p = foo_acquire (); + if (!p) + return; + foo_release (p); +} diff --git a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-5.c b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-5.c new file mode 100644 index 0000000..7ff4e57 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-5.c @@ -0,0 +1,12 @@ +/* Example of extra argument to "malloc" attribute. */ + +struct foo; +extern void foo_release (int, struct foo *); +extern struct foo *foo_acquire (void) + __attribute__ ((malloc (foo_release, 2))); + +void test_1 (void) +{ + struct foo *p = foo_acquire (); + foo_release (0, p); +} diff --git a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-6.c b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-6.c new file mode 100644 index 0000000..bd28107 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-6.c @@ -0,0 +1,228 @@ +/* Adapted from gcc.dg/Wmismatched-dealloc.c. */ + +#define A(...) __attribute__ ((malloc (__VA_ARGS__))) + +typedef struct FILE FILE; +typedef __SIZE_TYPE__ size_t; + +void free (void*); +void* malloc (size_t); +void* realloc (void*, size_t); + +int fclose (FILE*); +FILE* freopen (const char*, const char*, FILE*); +int pclose (FILE*); + +A (fclose) A (freopen, 3) + FILE* fdopen (int); +A (fclose) A (freopen, 3) + FILE* fopen (const char*, const char*); +A (fclose) A (freopen, 3) + FILE* fmemopen(void *, size_t, const char *); +A (fclose) A (freopen, 3) + FILE* freopen (const char*, const char*, FILE*); +A (pclose) A (freopen, 3) + FILE* popen (const char*, const char*); +A (fclose) A (freopen, 3) + FILE* tmpfile (void); + +void sink (FILE*); + + + void release (void*); +A (release) FILE* acquire (void); + +void nowarn_fdopen (void) +{ + { + FILE *q = fdopen (0); + if (!q) + return; + + fclose (q); + } + + { + FILE *q = fdopen (0); + if (!q) + return; + + q = freopen ("1", "r", q); + fclose (q); + } + + { + FILE *q = fdopen (0); + if (!q) + return; + + sink (q); + } +} + + +void warn_fdopen (void) +{ + { + FILE *q = fdopen (0); // { dg-message "allocated here" } + release (q); // { dg-warning "'release' called on 'q' returned from a mismatched allocation function" } + } + { + FILE *q = fdopen (0); // { dg-message "allocated here" } + free (q); // { dg-warning "'free' called on 'q' returned from a mismatched allocation function" } + } + + { + FILE *q = fdopen (0); // { dg-message "allocated here" } + q = realloc (q, 7); // { dg-warning "'realloc' called on 'q' returned from a mismatched allocation function" } + sink (q); + } +} + + +void nowarn_fopen (void) +{ + { + FILE *q = fopen ("1", "r"); + sink (q); + fclose (q); + } + + { + FILE *q = fopen ("2", "r"); + sink (q); + q = freopen ("3", "r", q); + sink (q); + fclose (q); + } + + { + FILE *q = fopen ("4", "r"); + sink (q); + } +} + + +void warn_fopen (void) +{ + { + FILE *q = fopen ("1", "r"); + release (q); // { dg-warning "'release' called on 'q' returned from a mismatched allocation function" } + fclose (q); + } + { + FILE *q = fdopen (0); + free (q); // { dg-warning "'free' called on 'q' returned from a mismatched allocation function" } + } + + { + FILE *q = fdopen (0); + q = realloc (q, 7); // { dg-warning "'realloc' called on 'q' returned from a mismatched allocation function" } + sink (q); + } +} + + +void test_popen (void) +{ + { + FILE *p = popen ("1", "r"); + sink (p); + pclose (p); + } + + { + FILE *p; + p = popen ("2", "r"); // { dg-message "allocated here" } + fclose (p); // { dg-warning "'fclose' called on 'p' returned from a mismatched allocation function" } + } + + { + /* freopen() can close a stream open by popen() but pclose() can't + close the stream returned from freopen(). */ + FILE *p = popen ("2", "r"); + p = freopen ("3", "r", p); // { dg-message "allocated here" } + pclose (p); // { dg-warning "'pclose' called on 'p' returned from a mismatched allocation function" } + } +} + + +void test_tmpfile (void) +{ + { + FILE *p = tmpfile (); + fclose (p); + } + + { + FILE *p = tmpfile (); + p = freopen ("1", "r", p); + fclose (p); + } + + { + FILE *p = tmpfile (); // { dg-message "allocated here" } + pclose (p); // { dg-warning "'pclose' called on 'p' returned from a mismatched allocation function" } + } +} + + +void warn_malloc (void) +{ + { + FILE *p = malloc (100); // { dg-message "allocated here" } + fclose (p); // { dg-warning "'p' should have been deallocated with 'free' but was deallocated with 'fclose'" } + } + + { + FILE *p = malloc (100); // { dg-message "allocated here" } + p = freopen ("1", "r", p);// { dg-warning "'p' should have been deallocated with 'free' but was deallocated with 'freopen'" } + fclose (p); + } + + { + FILE *p = malloc (100); // { dg-message "allocated here" } + pclose (p); // { dg-warning "'p' should have been deallocated with 'free' but was deallocated with 'pclose'" } + } +} + + +void test_acquire (void) +{ + { + FILE *p = acquire (); + release (p); + } + + { + FILE *p = acquire (); + release (p); + } + + { + FILE *p = acquire (); // { dg-message "allocated here \\(expects deallocation with 'release'\\)" } + fclose (p); // { dg-warning "'p' should have been deallocated with 'release' but was deallocated with 'fclose'" } + } + + { + FILE *p = acquire (); // { dg-message "allocated here \\(expects deallocation with 'release'\\)" } + pclose (p); // { dg-warning "'p' should have been deallocated with 'release' but was deallocated with 'pclose'" } + } + + { + FILE *p = acquire (); // { dg-message "allocated here \\(expects deallocation with 'release'\\)" } + p = freopen ("1", "r", p); // { dg-warning "'p' should have been deallocated with 'release' but was deallocated with 'freopen'" } + sink (p); + } + + { + FILE *p = acquire (); // { dg-message "allocated here \\(expects deallocation with 'release'\\)" } + free (p); // { dg-warning "'p' should have been deallocated with 'release' but was deallocated with 'free'" } + } + + { + FILE *p = acquire (); // { dg-message "allocated here \\(expects deallocation with 'release'\\)" } + p = realloc (p, 123); // { dg-warning "'p' should have been deallocated with 'release' but was deallocated with 'realloc'" } + sink (p); + } +} diff --git a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c new file mode 100644 index 0000000..905d50e --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c @@ -0,0 +1,224 @@ +/* Adapted from linux 5.3.11: drivers/net/wireless/ath/ath10k/usb.c + Reduced reproducer for CVE-2019-19078 (leak of struct urb). */ + +typedef unsigned char u8; +typedef unsigned short u16; +typedef _Bool bool; + +#define ENOMEM 12 +#define EINVAL 22 + +/* The original file has this licence header. */ + +// SPDX-License-Identifier: ISC +/* + * Copyright (c) 2007-2011 Atheros Communications Inc. + * Copyright (c) 2011-2012,2017 Qualcomm Atheros, Inc. + * Copyright (c) 2016-2017 Erik Stromdahl <erik.stromdahl@gmail.com> + */ + +/* Adapted from include/linux/compiler_attributes.h. */ +#define __aligned(x) __attribute__((__aligned__(x))) +#define __printf(a, b) __attribute__((__format__(printf, a, b))) + +/* Possible macro for the new attribute. */ +#define __malloc(f) __attribute__((malloc(f))); + +/* From include/linux/types.h. */ + +typedef unsigned int gfp_t; + +/* Not the real value, which is in include/linux/gfp.h. */ +#define GFP_ATOMIC 32 + +/* From include/linux/usb.h. */ + +struct urb; +extern void usb_free_urb(struct urb *urb); +extern struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags) + __malloc(usb_free_urb); +/* attribute added as part of testcase */ + +extern int usb_submit_urb(/*struct urb *urb, */gfp_t mem_flags); +extern void usb_unanchor_urb(struct urb *urb); + +/* From drivers/net/wireless/ath/ath10k/core.h. */ + +struct ath10k; + +struct ath10k { + /* [...many other fields removed...] */ + + /* must be last */ + u8 drv_priv[0] __aligned(sizeof(void *)); +}; + +/* From drivers/net/wireless/ath/ath10k/debug.h. */ + +enum ath10k_debug_mask { + /* [...other values removed...] */ + ATH10K_DBG_USB_BULK = 0x00080000, +}; + +extern unsigned int ath10k_debug_mask; + +__printf(3, 4) void __ath10k_dbg(struct ath10k *ar, + enum ath10k_debug_mask mask, + const char *fmt, ...); + +/* Simplified for now, to avoid pulling in tracepoint code. */ +static inline +bool trace_ath10k_log_dbg_enabled(void) { return 0; } + +#define ath10k_dbg(ar, dbg_mask, fmt, ...) \ +do { \ + if ((ath10k_debug_mask & dbg_mask) || \ + trace_ath10k_log_dbg_enabled()) \ + __ath10k_dbg(ar, dbg_mask, fmt, ##__VA_ARGS__); \ +} while (0) + +/* From drivers/net/wireless/ath/ath10k/hif.h. */ + +struct ath10k_hif_sg_item { + /* [...other fields removed...] */ + void *transfer_context; /* NULL = tx completion callback not called */ +}; + +struct ath10k_hif_ops { + /* send a scatter-gather list to the target */ + int (*tx_sg)(struct ath10k *ar, u8 pipe_id, + struct ath10k_hif_sg_item *items, int n_items); + /* [...other fields removed...] */ +}; + +/* From drivers/net/wireless/ath/ath10k/usb.h. */ + +/* tx/rx pipes for usb */ +enum ath10k_usb_pipe_id { + /* [...other values removed...] */ + ATH10K_USB_PIPE_MAX = 8 +}; + +struct ath10k_usb_pipe { + /* [...all fields removed...] */ +}; + +/* usb device object */ +struct ath10k_usb { + /* [...other fields removed...] */ + struct ath10k_usb_pipe pipes[ATH10K_USB_PIPE_MAX]; +}; + +/* usb urb object */ +struct ath10k_urb_context { + /* [...other fields removed...] */ + struct ath10k_usb_pipe *pipe; + struct sk_buff *skb; +}; + +static inline struct ath10k_usb *ath10k_usb_priv(struct ath10k *ar) +{ + return (struct ath10k_usb *)ar->drv_priv; +} + +/* The source file. */ + +static void ath10k_usb_post_recv_transfers(struct ath10k *ar, + struct ath10k_usb_pipe *recv_pipe); + +struct ath10k_urb_context * +ath10k_usb_alloc_urb_from_pipe(struct ath10k_usb_pipe *pipe); + +void ath10k_usb_free_urb_to_pipe(struct ath10k_usb_pipe *pipe, + struct ath10k_urb_context *urb_context); + +static int ath10k_usb_hif_tx_sg(struct ath10k *ar, u8 pipe_id, + struct ath10k_hif_sg_item *items, int n_items) +{ + struct ath10k_usb *ar_usb = ath10k_usb_priv(ar); + struct ath10k_usb_pipe *pipe = &ar_usb->pipes[pipe_id]; + struct ath10k_urb_context *urb_context; + struct sk_buff *skb; + struct urb *urb; + int ret, i; + + for (i = 0; i < n_items; i++) { + urb_context = ath10k_usb_alloc_urb_from_pipe(pipe); + if (!urb_context) { + ret = -ENOMEM; + goto err; + } + + skb = items[i].transfer_context; + urb_context->skb = skb; + + urb = usb_alloc_urb(0, GFP_ATOMIC); /* { dg-message "allocated here" } */ + if (!urb) { + ret = -ENOMEM; + goto err_free_urb_to_pipe; + } + + /* TODO: these are disabled, otherwise we conservatively + assume that they could free urb. */ +#if 0 + usb_fill_bulk_urb(urb, + ar_usb->udev, + pipe->usb_pipe_handle, + skb->data, + skb->len, + ath10k_usb_transmit_complete, urb_context); + if (!(skb->len % pipe->max_packet_size)) { + /* hit a max packet boundary on this pipe */ + urb->transfer_flags |= URB_ZERO_PACKET; + } + + usb_anchor_urb(urb, &pipe->urb_submitted); +#endif + /* TODO: initial argument disabled, otherwise we conservatively + assume that it could free urb. */ + ret = usb_submit_urb(/*urb, */GFP_ATOMIC); + if (ret) { /* TODO: why doesn't it show this condition at default verbosity? */ + ath10k_dbg(ar, ATH10K_DBG_USB_BULK, + "usb bulk transmit failed: %d\n", ret); + + /* TODO: this is disabled, otherwise we conservatively + assume that it could free urb. */ +#if 0 + usb_unanchor_urb(urb); +#endif + + ret = -EINVAL; + /* Leak of urb happens here. */ + goto err_free_urb_to_pipe; + } + + /* TODO: the loop confuses the double-free checker (another + instance of PR analyzer/93695). */ + usb_free_urb(urb); /* { dg-bogus "double-'usb_free_urb' of 'urb'" "" { xfail *-*-* } } */ + } + + return 0; + +err_free_urb_to_pipe: + ath10k_usb_free_urb_to_pipe(urb_context->pipe, urb_context); +err: + return ret; /* { dg-warning "leak of 'urb'" } */ +} + +static const struct ath10k_hif_ops ath10k_usb_hif_ops = { + .tx_sg = ath10k_usb_hif_tx_sg, +}; + +/* Simulate code to register the callback. */ +extern void callback_registration (const void *); +int ath10k_usb_probe(void) +{ + callback_registration(&ath10k_usb_hif_ops); +} + + +/* The original source file ends with: +MODULE_AUTHOR("Atheros Communications, Inc."); +MODULE_DESCRIPTION("Driver support for Qualcomm Atheros 802.11ac WLAN USB devices"); +MODULE_LICENSE("Dual BSD/GPL"); +*/ diff --git a/gcc/testsuite/gcc.dg/analyzer/attr-malloc-misuses.c b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-misuses.c new file mode 100644 index 0000000..3c6c17b --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/attr-malloc-misuses.c @@ -0,0 +1,18 @@ +extern void free (void *); + +int not_a_fn __attribute__ ((malloc (free))); /* { dg-warning "'malloc' attribute ignored; valid only for functions" } */ + +void void_return (void) __attribute__ ((malloc(free))); /* { dg-warning "'malloc' attribute ignored on functions returning 'void'" } */ + +void test_void_return (void) +{ + void_return (); +} + +extern void void_args (void); /* { dg-message "declared here" } */ +void *has_malloc_with_void_args (void) + __attribute__ ((malloc(void_args))); /* { dg-error "'malloc' attribute argument 1 must take a pointer type as its first argument; have 'void'" } */ + +extern void no_args (); /* { dg-message "declared here" } */ +void *has_malloc_with_no_args (void) + __attribute__ ((malloc(no_args))); /* { dg-error "'malloc' attribute argument 1 must take a pointer type as its first argument" } */ diff --git a/gcc/testsuite/gcc.dg/analyzer/combined-conditionals-1.c b/gcc/testsuite/gcc.dg/analyzer/combined-conditionals-1.c new file mode 100644 index 0000000..caac267 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/combined-conditionals-1.c @@ -0,0 +1,55 @@ +/* Verify that we correctly consolidate conditionals in paths. */ + +#include "analyzer-decls.h" + +extern int foo (); +extern int bar (); +extern int baz (); + +void test_1 (int a, int b, int c) +{ + if (a && b && c) /* { dg-message "\\(1\\) following 'true' branch\\.\\.\\." } */ + __analyzer_dump_path (); /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ +} + +void test_2 (int a, int b, int c) +{ + if (a && b) /* { dg-message "\\(1\\) following 'true' branch\\.\\.\\." } */ + if (c) /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ + __analyzer_dump_path (); +} + +void test_3 (int a, int b, int c) +{ + if (a) /* { dg-message "\\(1\\) following 'true' branch" } */ + if (b && c) /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ + __analyzer_dump_path (); +} + +void test_4 (void) +{ + while (foo () && bar ()) /* { dg-message "\\(1\\) following 'true' branch\\.\\.\\." } */ + __analyzer_dump_path (); /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ +} + +void test_5 (int a, int b, int c) +{ + if (a || b || c) /* { dg-message "\\(1\\) following 'false' branch\\.\\.\\." } */ + { + } + else + __analyzer_dump_path (); /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ +} + +void test_6 (void) +{ + int i; + for (i = 0; i < 10 && foo (); i++) /* { dg-message "\\(1\\) following 'true' branch\\.\\.\\." } */ + __analyzer_dump_path (); /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ +} + +int test_7 (void) +{ + if (foo () ? bar () ? baz () : 0 : 0) /* { dg-message "\\(1\\) following 'true' branch\\.\\.\\." } */ + __analyzer_dump_path (); /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ +} diff --git a/gcc/testsuite/gcc.dg/analyzer/conditionals-3.c b/gcc/testsuite/gcc.dg/analyzer/conditionals-3.c index 5f29f21..f1c6c20 100644 --- a/gcc/testsuite/gcc.dg/analyzer/conditionals-3.c +++ b/gcc/testsuite/gcc.dg/analyzer/conditionals-3.c @@ -2,12 +2,12 @@ #include "analyzer-decls.h" -static void only_called_when_flag_a_true (int i) +static void __analyzer_only_called_when_flag_a_true (int i) { __analyzer_eval (i == 42); /* { dg-warning "TRUE" } */ } -static void only_called_when_flag_b_true (int i) +static void __analyzer_only_called_when_flag_b_true (int i) { __analyzer_eval (i == 17); /* { dg-warning "TRUE" } */ } @@ -34,7 +34,7 @@ int test_1 (int flag_a, int flag_b) __analyzer_eval (flag_b); /* { dg-warning "UNKNOWN" } */ __analyzer_eval (i == 42); /* { dg-warning "TRUE" } */ __analyzer_eval (i == 17); /* { dg-warning "FALSE" } */ - only_called_when_flag_a_true (i); + __analyzer_only_called_when_flag_a_true (i); } else { @@ -42,6 +42,6 @@ int test_1 (int flag_a, int flag_b) __analyzer_eval (flag_b); /* { dg-warning "UNKNOWN" } */ __analyzer_eval (i == 42); /* { dg-warning "FALSE" } */ __analyzer_eval (i == 17); /* { dg-warning "TRUE" } */ - only_called_when_flag_b_true (i); + __analyzer_only_called_when_flag_b_true (i); } } diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c index 3f16a38..afd1556 100644 --- a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c @@ -3,7 +3,6 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <alloca.h> #include "analyzer-decls.h" struct foo @@ -140,8 +139,8 @@ void test_11 (void) void test_12 (void) { - void *p = alloca (256); - void *q = alloca (256); + void *p = __builtin_alloca (256); + void *q = __builtin_alloca (256); /* alloca results should be unique. */ __analyzer_eval (p == q); /* { dg-warning "FALSE" } */ @@ -783,7 +782,7 @@ void test_33 (void) } static int __attribute__((noinline)) -only_called_by_test_34 (int parm) +__analyzer_only_called_by_test_34 (int parm) { __analyzer_eval (parm == 42); /* { dg-warning "TRUE" } */ @@ -792,7 +791,7 @@ only_called_by_test_34 (int parm) void test_34 (void) { - int result = only_called_by_test_34 (42); + int result = __analyzer_only_called_by_test_34 (42); __analyzer_eval (result == 84); /* { dg-warning "TRUE" } */ } diff --git a/gcc/testsuite/gcc.dg/analyzer/feasibility-1.c b/gcc/testsuite/gcc.dg/analyzer/feasibility-1.c index f2a8a4c..c968444 100644 --- a/gcc/testsuite/gcc.dg/analyzer/feasibility-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/feasibility-1.c @@ -60,3 +60,29 @@ int test_6 (int a, int b) } return problem; } + +/* As above, but call a static function. + Even if the path to the call of called_by_test_6a is falsely rejected + as infeasible, it still makes sense to complain about errors within + the called function. */ + +static void __attribute__((noinline)) +called_by_test_6a (void *ptr) +{ + __builtin_free (ptr); + __builtin_free (ptr); /* { dg-message "double-'free'" } */ +} + +int test_6a (int a, int b, void *ptr) +{ + int problem = 0; + if (a) + problem = 1; + if (b) + { + if (!problem) + problem = 2; + called_by_test_6a (ptr); + } + return problem; +} diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c index 26d8288..448b8558 100644 --- a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c @@ -1,6 +1,5 @@ /* { dg-require-effective-target alloca } */ -#include <alloca.h> #include <stdlib.h> extern int foo (void); @@ -273,7 +272,7 @@ int *test_23a (int n) int test_24 (void) { - void *ptr = alloca (sizeof (int)); /* { dg-message "memory is allocated on the stack here" } */ + void *ptr = __builtin_alloca (sizeof (int)); /* { dg-message "memory is allocated on the stack here" } */ free (ptr); /* { dg-warning "'free' of memory allocated on the stack by 'alloca' \\('ptr'\\) will corrupt the heap \\\[CWE-590\\\]" } */ } diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c index 35c9385..9a7c414 100644 --- a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c +++ b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c @@ -2,7 +2,6 @@ /* { dg-require-effective-target alloca } */ #include <stddef.h> -#include <alloca.h> #include <stdlib.h> extern void do_stuff (const void *); @@ -15,7 +14,7 @@ void test_1 (size_t sz) if (sz >= LIMIT) ptr = malloc (sz); else - ptr = alloca (sz); + ptr = __builtin_alloca (sz); do_stuff (ptr); @@ -27,7 +26,7 @@ void test_2 (size_t sz) { void *ptr; if (sz < LIMIT) - ptr = alloca (sz); + ptr = __builtin_alloca (sz); else ptr = malloc (sz); @@ -41,7 +40,7 @@ void test_3 (size_t sz) { void *ptr; if (sz <= LIMIT) - ptr = alloca (sz); /* { dg-message "memory is allocated on the stack here" } */ + ptr = __builtin_alloca (sz); /* { dg-message "memory is allocated on the stack here" } */ else ptr = malloc (sz); diff --git a/gcc/testsuite/gcc.dg/analyzer/params.c b/gcc/testsuite/gcc.dg/analyzer/params.c index f8331dd..12bba70 100644 --- a/gcc/testsuite/gcc.dg/analyzer/params.c +++ b/gcc/testsuite/gcc.dg/analyzer/params.c @@ -1,6 +1,6 @@ #include "analyzer-decls.h" -static int called_function(int j) +static int __analyzer_called_function(int j) { int k; @@ -23,7 +23,7 @@ void test(int i) __analyzer_eval (i > 4); /* { dg-warning "TRUE" } */ - i = called_function(i); + i = __analyzer_called_function(i); __analyzer_eval (i > 3); /* { dg-warning "TRUE" "desired" { xfail *-*-* } } */ /* { dg-warning "UNKNOWN" "status quo" { target *-*-* } .-1 } */ diff --git a/gcc/testsuite/gcc.dg/analyzer/pr93355-localealias-feasibility-2.c b/gcc/testsuite/gcc.dg/analyzer/pr93355-localealias-feasibility-2.c new file mode 100644 index 0000000..1afc6df --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr93355-localealias-feasibility-2.c @@ -0,0 +1,31 @@ +/* Simplified version of test to ensure we issue a FILE * leak diagnostic, + reproducing a feasibility issue. + Adapted from intl/localealias.c, with all #includes removed. */ + +/* { dg-do "compile" } */ + +#include "analyzer-decls.h" + +#define NULL ((void *) 0) +#define PATH_SEPARATOR ':' +#define LOCALE_ALIAS_PATH "value for LOCALE_ALIAS_PATH" + +const char * +_nl_expand_alias (void) +{ + static const char *locale_alias_path; + + if (locale_alias_path == NULL) + locale_alias_path = LOCALE_ALIAS_PATH; + + const char *start = locale_alias_path; + + while (locale_alias_path[0] != '\0' + && locale_alias_path[0] != PATH_SEPARATOR) + ++locale_alias_path; + + if (start < locale_alias_path) + __analyzer_dump_path (); /* { dg-message "path" "" { xfail *-*-* } } */ + /* XFAIL: PR analyzer/96374 + Use -fno-analyzer-feasibility to see the path. */ +} diff --git a/gcc/testsuite/gcc.dg/analyzer/pr93355-localealias-feasibility-3.c b/gcc/testsuite/gcc.dg/analyzer/pr93355-localealias-feasibility-3.c new file mode 100644 index 0000000..a864831 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr93355-localealias-feasibility-3.c @@ -0,0 +1,64 @@ +/* Simplified version of test to ensure we issue a FILE * leak diagnostic, + reproducing a feasibility issue. + Adapted from intl/localealias.c, with all #includes removed. */ + +/* { dg-do "compile" } */ + +/* Handle aliases for locale names. + Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, + USA. */ + +/* Minimal version of system headers. */ + +typedef __SIZE_TYPE__ size_t; +#define NULL ((void *)0) + +typedef struct _IO_FILE FILE; +extern FILE *fopen (const char *__restrict __filename, + const char *__restrict __modes); +extern int fclose (FILE *__stream); + +extern int isspace (int) __attribute__((__nothrow__, __leaf__)); + +/* Cleaned-up body of localealias.c follows. */ + +size_t +read_alias_file (const char *fname, char *cp) +{ + FILE *fp; + + fp = fopen (fname, "r"); /* { dg-message "opened here" "" { xfail *-*-* } } */ + /* XFAIL: PR analyzer/96374 + Use -fno-analyzer-feasibility to see the path. */ + if (fp == NULL) + return 0; + + if (cp[0] != '\0') + *cp++ = '\0'; + + while (isspace ((unsigned char)cp[0])) + ++cp; + + if (cp[0] != '\0') + return 42; /* { dg-warning "leak of FILE 'fp'" "" { xfail *-*-* } } */ + /* XFAIL: PR analyzer/96374 + Use -fno-analyzer-feasibility to see the path. */ + + fclose(fp); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/analyzer/pr94851-1.c b/gcc/testsuite/gcc.dg/analyzer/pr94851-1.c index da79652..34960e2 100644 --- a/gcc/testsuite/gcc.dg/analyzer/pr94851-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/pr94851-1.c @@ -40,8 +40,7 @@ int pamark(void) { last->m_next = p; } - p->m_name = (char)c; /* { dg-bogus "leak of 'p'" "bogus leak" { xfail *-*-* } } */ - // TODO(xfail): related to PR analyzer/97072 and PR analyzer/97074 + p->m_name = (char)c; /* { dg-bogus "leak of 'p'" "bogus leak" } */ return 1; } diff --git a/gcc/testsuite/gcc.dg/analyzer/pr96651-2.c b/gcc/testsuite/gcc.dg/analyzer/pr96651-2.c index 249a32b..25cda37 100644 --- a/gcc/testsuite/gcc.dg/analyzer/pr96651-2.c +++ b/gcc/testsuite/gcc.dg/analyzer/pr96651-2.c @@ -26,7 +26,7 @@ void test (void) } static void __attribute__((noinline)) -called_from_main (void) +__analyzer_called_from_main (void) { /* When accessed from main, the vars still have their initializer values. */ __analyzer_eval (a == 0); /* { dg-warning "TRUE" } */ @@ -53,7 +53,7 @@ int main (void) before "main"). */ __analyzer_eval (stderr == 0); /* { dg-warning "UNKNOWN" } */ - called_from_main (); + __analyzer_called_from_main (); unknown_fn (&a, &c); diff --git a/gcc/testsuite/gcc.dg/analyzer/pr97072.c b/gcc/testsuite/gcc.dg/analyzer/pr97072.c new file mode 100644 index 0000000..4024124 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr97072.c @@ -0,0 +1,9 @@ +void unknown_fn_1 (void *); + +void test_1 (int co, int y) +{ + void *p = __builtin_malloc (1024); + void **q; + unknown_fn_1 (&q); + *q = p; +} diff --git a/gcc/testsuite/gcc.dg/analyzer/pr97074.c b/gcc/testsuite/gcc.dg/analyzer/pr97074.c new file mode 100644 index 0000000..ccb3b61 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr97074.c @@ -0,0 +1,32 @@ +#include "analyzer-decls.h" +#define NULL ((void *)0) + +void *x, *y; + +void test_1 (int flag) +{ + void *p = __builtin_malloc (1024); + if (flag) + x = p; + else + y = p; +} /* { dg-bogus "leak" } */ + +struct s2 +{ + void *f1; + void *f2; +}; + +struct s2 test_2 (int flag) +{ + struct s2 r; + r.f1 = NULL; + r.f2 = NULL; + void *p = __builtin_malloc (1024); + if (flag) + r.f1 = p; + else + r.f2 = p; + return r; +} diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98073.c b/gcc/testsuite/gcc.dg/analyzer/pr98073.c new file mode 100644 index 0000000..abbda09 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr98073.c @@ -0,0 +1,13 @@ +struct ist { + char ptr; + long len; +} __trans_tmp_1, http_update_host_authority; +int http_update_host_sl_0_0_0; +void http_update_host(const struct ist uri) { + uri.len || uri.ptr; + if (http_update_host_sl_0_0_0) { + http_update_host_authority = __trans_tmp_1; + !http_update_host_authority.len; + } else + http_update_host_authority = uri; +} diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98293.c b/gcc/testsuite/gcc.dg/analyzer/pr98293.c new file mode 100644 index 0000000..f750c90 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr98293.c @@ -0,0 +1,2 @@ +/* { dg-additional-options "-fsanitize=undefined" } */ +#include "../pr93399.c" diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98564.c b/gcc/testsuite/gcc.dg/analyzer/pr98564.c new file mode 100644 index 0000000..74b1abe --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr98564.c @@ -0,0 +1,6 @@ +void *calloc (__SIZE_TYPE__, __SIZE_TYPE__); + +void test_1 (void) +{ + int *p = calloc (0, 1); /* { dg-message "allocated here" } */ +} /* { dg-warning "leak of 'p'" } */ diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98580-a.c b/gcc/testsuite/gcc.dg/analyzer/pr98580-a.c new file mode 100644 index 0000000..d2b10d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr98580-a.c @@ -0,0 +1,9 @@ +/* { dg-do link } */ +/* { dg-require-effective-target lto } */ +/* { dg-additional-options "-flto" } */ +/* { dg-additional-sources pr98580-b.c } */ + +int a; +int *p = &a; +int foo(); +int main() { return foo(); } diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98580-b.c b/gcc/testsuite/gcc.dg/analyzer/pr98580-b.c new file mode 100644 index 0000000..629ebce --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr98580-b.c @@ -0,0 +1,2 @@ +extern int *p; +int foo() { return *p; } diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98628.c b/gcc/testsuite/gcc.dg/analyzer/pr98628.c new file mode 100644 index 0000000..e2fa778 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr98628.c @@ -0,0 +1,19 @@ +/* { dg-additional-options "-O1" } */ + +void foo(void *); +struct chanset_t help_subst_chan; +struct chanset_t *help_subst_chan_0_0; +struct chanset_t { + struct chanset_t *next; + char dname[]; +}; +void help_subst() { + char *writeidx; + for (;; help_subst_chan = *help_subst_chan_0_0) { + foo(help_subst_chan.next->dname); + if (help_subst_chan_0_0) { + writeidx++; + *writeidx++ = ' '; + } + } +} diff --git a/gcc/testsuite/gcc.dg/analyzer/pr98918.c b/gcc/testsuite/gcc.dg/analyzer/pr98918.c new file mode 100644 index 0000000..ac626ba --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr98918.c @@ -0,0 +1,22 @@ +#include <stdlib.h> + +struct marker { + struct marker *next; + void *ref; +}; +struct data { + struct marker *marker; +}; + +void data_free(struct data d) +{ + struct marker *nm, *m; + + m = d.marker; + while (m) { + nm = m->next; + free(m->ref); + free(m); + m = nm; + } +} diff --git a/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c b/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c index 81144af..c66af92 100644 --- a/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c @@ -6,6 +6,11 @@ #include <string.h> +/* Declare getpass, in case unistd doesn't declare it. + Parenthesize it, in case it's a macro. + Don't use a prototype, to avoid const mismatches. */ +extern char *(getpass) (); + char test_1 (FILE *logfile) { char *password = getpass (">"); /* { dg-message "\\(1\\) sensitive value acquired here" } */ diff --git a/gcc/testsuite/gcc.dg/analyzer/signal-4b.c b/gcc/testsuite/gcc.dg/analyzer/signal-4b.c index cb1e7e4..5a2ccb1 100644 --- a/gcc/testsuite/gcc.dg/analyzer/signal-4b.c +++ b/gcc/testsuite/gcc.dg/analyzer/signal-4b.c @@ -20,14 +20,14 @@ static void int_handler(int signum) custom_logger("got signal"); } -static void register_handler () +static void __analyzer_register_handler () { signal(SIGINT, int_handler); } void test (void) { - register_handler (); + __analyzer_register_handler (); body_of_program(); } @@ -42,17 +42,17 @@ void test (void) | | | | | (1) entry to 'test' | NN | { - | NN | register_handler (); - | | ~~~~~~~~~~~~~~~~~~~ + | NN | __analyzer_register_handler (); + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | - | | (2) calling 'register_handler' from 'test' + | | (2) calling '__analyzer_register_handler' from 'test' | - +--> 'register_handler': events 3-4 + +--> '__analyzer_register_handler': events 3-4 | - | NN | static void register_handler () - | | ^~~~~~~~~~~~~~~~ + | NN | static void __analyzer_register_handler () + | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | - | | (3) entry to 'register_handler' + | | (3) entry to '__analyzer_register_handler' | NN | { | NN | signal(SIGINT, int_handler); | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/gcc/testsuite/gcc.dg/analyzer/sigsetjmp-5.c b/gcc/testsuite/gcc.dg/analyzer/sigsetjmp-5.c index d6a9910..494b813 100644 --- a/gcc/testsuite/gcc.dg/analyzer/sigsetjmp-5.c +++ b/gcc/testsuite/gcc.dg/analyzer/sigsetjmp-5.c @@ -4,7 +4,7 @@ #include <stddef.h> #include "analyzer-decls.h" -static jmp_buf env; +static sigjmp_buf env; static void inner (void) { diff --git a/gcc/testsuite/gcc.dg/analyzer/sigsetjmp-6.c b/gcc/testsuite/gcc.dg/analyzer/sigsetjmp-6.c index f89277e..f5507a3 100644 --- a/gcc/testsuite/gcc.dg/analyzer/sigsetjmp-6.c +++ b/gcc/testsuite/gcc.dg/analyzer/sigsetjmp-6.c @@ -6,7 +6,7 @@ extern int foo (int) __attribute__ ((__pure__)); -static jmp_buf env; +static sigjmp_buf env; static void inner (void) { diff --git a/gcc/testsuite/gcc.dg/analyzer/single-field.c b/gcc/testsuite/gcc.dg/analyzer/single-field.c index d54cfb0..31c6fee 100644 --- a/gcc/testsuite/gcc.dg/analyzer/single-field.c +++ b/gcc/testsuite/gcc.dg/analyzer/single-field.c @@ -11,14 +11,14 @@ void test_1 (struct foo f) __analyzer_describe (0, f.ptr); /* { dg-warning "svalue: 'INIT_VAL\\(f.ptr\\)'" } */ } -static void called_by_test_2 (struct foo f_inner) +static void __analyzer_called_by_test_2 (struct foo f_inner) { free (f_inner.ptr); free (f_inner.ptr); /* { dg-warning "double-'free' of 'f_outer.ptr'" } */ } void test_2 (struct foo f_outer) { - called_by_test_2 (f_outer); + __analyzer_called_by_test_2 (f_outer); } struct nested @@ -26,12 +26,12 @@ struct nested struct foo f; }; -static void called_by_test_3 (struct nested n_inner) +static void __analyzer_called_by_test_3 (struct nested n_inner) { free (n_inner.f.ptr); free (n_inner.f.ptr); /* { dg-warning "double-'free' of 'n_outer.f.ptr'" } */ } void test_3 (struct nested n_outer) { - called_by_test_3 (n_outer); + __analyzer_called_by_test_3 (n_outer); } diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/analyzer-torture.exp b/gcc/testsuite/gcc.dg/analyzer/torture/analyzer-torture.exp index a4d98bb..e16f447 100644 --- a/gcc/testsuite/gcc.dg/analyzer/torture/analyzer-torture.exp +++ b/gcc/testsuite/gcc.dg/analyzer/torture/analyzer-torture.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2020 Free Software Foundation, Inc. +# Copyright (C) 2020-2021 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 diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/conditionals-2.c b/gcc/testsuite/gcc.dg/analyzer/torture/conditionals-2.c index 35b0a05f..278a2a5 100644 --- a/gcc/testsuite/gcc.dg/analyzer/torture/conditionals-2.c +++ b/gcc/testsuite/gcc.dg/analyzer/torture/conditionals-2.c @@ -5,7 +5,7 @@ #define Z_NULL 0 static void __attribute__((noinline)) -test_1_callee (void *p, void *q) +__analyzer_test_1_callee (void *p, void *q) { __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */ @@ -21,11 +21,11 @@ void test_1 (void *p, void *q) if (p == Z_NULL || q == Z_NULL) return; - test_1_callee (p, q); + __analyzer_test_1_callee (p, q); } static void __attribute__((noinline)) -test_2_callee (void *p, void *q) +__analyzer_test_2_callee (void *p, void *q) { __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */ @@ -39,5 +39,5 @@ test_2_callee (void *p, void *q) void test_2 (void *p, void *q) { if (p != Z_NULL && q != Z_NULL) - test_2_callee (p, q); + __analyzer_test_2_callee (p, q); } diff --git a/gcc/testsuite/gcc.dg/array-quals-1.c b/gcc/testsuite/gcc.dg/array-quals-1.c index 31aa1d3..c8d3629 100644 --- a/gcc/testsuite/gcc.dg/array-quals-1.c +++ b/gcc/testsuite/gcc.dg/array-quals-1.c @@ -6,46 +6,46 @@ /* { dg-options "-Wno-discarded-array-qualifiers" } */ /* The MMIX port always switches to the .data section at the end of a file. */ /* { dg-final { scan-assembler-not "\\.data(?!\\.rel\\.ro)" { xfail powerpc*-*-aix* mmix-*-* x86_64-*-mingw* } } } */ -/* { dg-final { scan-assembler-symbol-section {^_?a$} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?a$} {^\.(const|rodata|srodata)|\[RO\]} } } */ static const int a[2] = { 1, 2 }; -/* { dg-final { scan-assembler-symbol-section {^_?a1$} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?a1$} {^\.(const|rodata|srodata)|\[RO\]} } } */ const int a1[2] = { 1, 2 }; typedef const int ci; -/* { dg-final { scan-assembler-symbol-section {^_?b$} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?b$} {^\.(const|rodata|srodata)|\[RO\]} } } */ static ci b[2] = { 3, 4 }; -/* { dg-final { scan-assembler-symbol-section {^_?b1$} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?b1$} {^\.(const|rodata|srodata)|\[RO\]} } } */ ci b1[2] = { 3, 4 }; typedef int ia[2]; -/* { dg-final { scan-assembler-symbol-section {^_?c$} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?c$} {^\.(const|rodata|srodata)|\[RO\]} } } */ static const ia c = { 5, 6 }; -/* { dg-final { scan-assembler-symbol-section {^_?c1$} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?c1$} {^\.(const|rodata|srodata)|\[RO\]} } } */ const ia c1 = { 5, 6 }; typedef const int cia[2]; -/* { dg-final { scan-assembler-symbol-section {^_?d$} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?d$} {^\.(const|rodata|srodata)|\[RO\]} } } */ static cia d = { 7, 8 }; -/* { dg-final { scan-assembler-symbol-section {^_?d1$} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?d1$} {^\.(const|rodata|srodata)|\[RO\]} } } */ cia d1 = { 7, 8 }; -/* { dg-final { scan-assembler-symbol-section {^_?e$} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?e$} {^\.(const|rodata|srodata)|\[RO\]} } } */ static cia e[2] = { { 1, 2 }, { 3, 4 } }; -/* { dg-final { scan-assembler-symbol-section {^_?e1$} {^\.(const|rodata)|\[RO\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?e1$} {^\.(const|rodata|srodata)|\[RO\]} } } */ cia e1[2] = { { 1, 2 }, { 3, 4 } }; -/* { dg-final { scan-assembler-symbol-section {^_?p$} {^\.(const|rodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?p$} {^\.(const|rodata|srodata)|\[RW\]} } } */ void *const p = &a; -/* { dg-final { scan-assembler-symbol-section {^_?q$} {^\.(const|rodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?q$} {^\.(const|rodata|srodata)|\[RW\]} } } */ void *const q = &b; -/* { dg-final { scan-assembler-symbol-section {^_?r$} {^\.(const|rodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?r$} {^\.(const|rodata|srodata)|\[RW\]} } } */ void *const r = &c; -/* { dg-final { scan-assembler-symbol-section {^_?s$} {^\.(const|rodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?s$} {^\.(const|rodata|srodata)|\[RW\]} } } */ void *const s = &d; -/* { dg-final { scan-assembler-symbol-section {^_?t$} {^\.(const|rodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?t$} {^\.(const|rodata|srodata)|\[RW\]} } } */ void *const t = &e; -/* { dg-final { scan-assembler-symbol-section {^_?p1$} {^\.(const|rodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?p1$} {^\.(const|rodata|srodata)|\[RW\]} } } */ void *const p1 = &a1; -/* { dg-final { scan-assembler-symbol-section {^_?q1$} {^\.(const|rodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?q1$} {^\.(const|rodata|srodata)|\[RW\]} } } */ void *const q1 = &b1; -/* { dg-final { scan-assembler-symbol-section {^_?r1$} {^\.(const|rodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?r1$} {^\.(const|rodata|srodata)|\[RW\]} } } */ void *const r1 = &c1; -/* { dg-final { scan-assembler-symbol-section {^_?s1$} {^\.(const|rodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?s1$} {^\.(const|rodata|srodata)|\[RW\]} } } */ void *const s1 = &d1; -/* { dg-final { scan-assembler-symbol-section {^_?t1$} {^\.(const|rodata)|\[RW\]} } } */ +/* { dg-final { scan-assembler-symbol-section {^_?t1$} {^\.(const|rodata|srodata)|\[RW\]} } } */ void *const t1 = &e1; diff --git a/gcc/testsuite/gcc.dg/asan/asan.exp b/gcc/testsuite/gcc.dg/asan/asan.exp index 19e7af9..a55003d 100644 --- a/gcc/testsuite/gcc.dg/asan/asan.exp +++ b/gcc/testsuite/gcc.dg/asan/asan.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2020 Free Software Foundation, Inc. +# Copyright (C) 2012-2021 Free Software Foundation, Inc. # # This file is part of GCC. # diff --git a/gcc/testsuite/gcc.dg/asan/nested-1.c b/gcc/testsuite/gcc.dg/asan/nested-1.c new file mode 100644 index 0000000..87e8420 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/nested-1.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=address" } */ + +int f(int i) { + auto int h() { + int r; + int *p; + + { + int x[3]; + + auto int g() { + return x[i]; + } + + p = &r; + *p = g(); + } + + return *p; + } + + return h(); +} diff --git a/gcc/testsuite/gcc.dg/atomic/atomic.exp b/gcc/testsuite/gcc.dg/atomic/atomic.exp index e6ded93..9cbcb53 100644 --- a/gcc/testsuite/gcc.dg/atomic/atomic.exp +++ b/gcc/testsuite/gcc.dg/atomic/atomic.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2020 Free Software Foundation, Inc. +# Copyright (C) 2012-2021 Free Software Foundation, Inc. # # This file is part of GCC. # diff --git a/gcc/testsuite/gcc.dg/autopar/autopar.exp b/gcc/testsuite/gcc.dg/autopar/autopar.exp index dffdebe..856808e 100644 --- a/gcc/testsuite/gcc.dg/autopar/autopar.exp +++ b/gcc/testsuite/gcc.dg/autopar/autopar.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2008-2020 Free Software Foundation, Inc. +# Copyright (C) 2008-2021 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 diff --git a/gcc/testsuite/gcc.dg/charset/charset.exp b/gcc/testsuite/gcc.dg/charset/charset.exp index d96ba47..a97e79d 100644 --- a/gcc/testsuite/gcc.dg/charset/charset.exp +++ b/gcc/testsuite/gcc.dg/charset/charset.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2020 Free Software Foundation, Inc. +# Copyright (C) 2004-2021 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 diff --git a/gcc/testsuite/gcc.dg/compat/compat.exp b/gcc/testsuite/gcc.dg/compat/compat.exp index 61f2863..d1c4902 100644 --- a/gcc/testsuite/gcc.dg/compat/compat.exp +++ b/gcc/testsuite/gcc.dg/compat/compat.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2020 Free Software Foundation, Inc. +# Copyright (C) 2002-2021 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 diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1.exp b/gcc/testsuite/gcc.dg/compat/struct-layout-1.exp index 66ee483..b685f04 100644 --- a/gcc/testsuite/gcc.dg/compat/struct-layout-1.exp +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2020 Free Software Foundation, Inc. +# Copyright (C) 2002-2021 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 diff --git a/gcc/testsuite/gcc.dg/cpp/assembl2.S b/gcc/testsuite/gcc.dg/cpp/assembl2.S index 7eb379b..00855d3 100644 --- a/gcc/testsuite/gcc.dg/cpp/assembl2.S +++ b/gcc/testsuite/gcc.dg/cpp/assembl2.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2020 Free Software Foundation, Inc. */ +/* Copyright (C) 2000-2021 Free Software Foundation, Inc. */ /* { dg-do preprocess } */ diff --git a/gcc/testsuite/gcc.dg/cpp/cpp.exp b/gcc/testsuite/gcc.dg/cpp/cpp.exp index 4a85fba..fd1101c 100644 --- a/gcc/testsuite/gcc.dg/cpp/cpp.exp +++ b/gcc/testsuite/gcc.dg/cpp/cpp.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/cpp/trad/trad.exp b/gcc/testsuite/gcc.dg/cpp/trad/trad.exp index 1fa07f1..4a6b882 100644 --- a/gcc/testsuite/gcc.dg/cpp/trad/trad.exp +++ b/gcc/testsuite/gcc.dg/cpp/trad/trad.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/cpp/ucs.c b/gcc/testsuite/gcc.dg/cpp/ucs.c index f52cd57..0fdd23b 100644 --- a/gcc/testsuite/gcc.dg/cpp/ucs.c +++ b/gcc/testsuite/gcc.dg/cpp/ucs.c @@ -43,7 +43,7 @@ #endif #if WCHAR_MAX >= 0x7ffffff -# if L'\U1234abcd' != 0x1234abcd /* { dg-warning "outside" "" } */ +# if L'\U1234abcd' != 0x1234abcd /* { dg-warning "outside" "" { xfail powerpc-ibm-aix* } } */ # error bad long ucs /* { dg-bogus "bad" "bad U1234abcd evaluation" } */ # endif #endif @@ -69,5 +69,5 @@ void foo () c = L"\uD800"[0]; /* { dg-error "not a valid" "D800 invalid UCN" } */ c = L'\U0000DFFF'; /* { dg-error "not a valid" "DFFF invalid UCN" } */ - c = L'\U00110000'; /* { dg-warning "outside" "110000 outside UCS" } */ + c = L'\U00110000'; /* { dg-warning "outside|Invalid" "110000 outside UCS" } */ } diff --git a/gcc/testsuite/gcc.dg/darwin-sections.c b/gcc/testsuite/gcc.dg/darwin-sections.c index 5fc2860..dbe3702 100644 --- a/gcc/testsuite/gcc.dg/darwin-sections.c +++ b/gcc/testsuite/gcc.dg/darwin-sections.c @@ -10,9 +10,7 @@ typedef struct _empty {} e_s; /* These should go in .comm */ char ub; e_s ea; -/* { dg-final { scan-assembler-symbol-section {^_a$} {\.data} } } */ /* { dg-final { scan-assembler ".comm\[\t \]_ub,1" } } */ -/* { dg-final { scan-assembler-symbol-section {^_b$} {\.data} } } */ /* { dg-final { scan-assembler ".comm\[\t \]_ea,1" } } */ /* These should go into __DATA,__common */ diff --git a/gcc/testsuite/gcc.dg/debug/debug.exp b/gcc/testsuite/gcc.dg/debug/debug.exp index 44d6b7f..bc5505e 100644 --- a/gcc/testsuite/gcc.dg/debug/debug.exp +++ b/gcc/testsuite/gcc.dg/debug/debug.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2020 Free Software Foundation, Inc. +# Copyright (C) 2002-2021 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 diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-float.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-float.c index f488384..51f5977 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-float.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-float.c @@ -1,11 +1,11 @@ /* Verify the DWARF encoding of C99 floating point types. */ /* { dg-do compile } */ -/* { dg-options "-O0 -gdwarf -dA" } */ -/* { dg-final { scan-assembler "0x4.*DW_AT_encoding" } } */ -/* { dg-final { scan-assembler "0x4.*DW_AT_byte_size" } } */ -/* { dg-final { scan-assembler "0x8.*DW_AT_byte_size" } } */ -/* { dg-final { scan-assembler "0x10.*DW_AT_byte_size" } } */ +/* { dg-options "-O0 -gdwarf-4 -dA" } */ +/* { dg-final { scan-assembler "0x4\[^\\r\\n]*DW_AT_encoding" } } */ +/* { dg-final { scan-assembler "0x4\[^\\r\\n]*DW_AT_byte_size" } } */ +/* { dg-final { scan-assembler "0x8\[^\\r\\n]*DW_AT_byte_size" { target double64 } } } */ +/* { dg-final { scan-assembler "0x10\[^\\r\\n]*DW_AT_byte_size" { target longdouble128 }} } */ void foo () { diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp index 1fd81d1..bb77397 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2020 Free Software Foundation, Inc. +# Copyright (C) 2002-2021 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 diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c b/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c index 03013f1..fde8c27 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c @@ -15,8 +15,8 @@ */ /* Explicitly use dwarf-5 which uses DW_FORM_implicit_const. */ -/* { dg-options "-O -g3 -gdwarf-5 -dA -fgnu89-inline" } */ /* { dg-do compile } */ +/* { dg-options "-O -g3 -gdwarf-5 -dA -fgnu89-inline" } */ /* There are 6 inlined subroutines: - One for each subroutine inlined into main, that's 3. diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-7.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-7.c index 0e0de82..1aa6005 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-7.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr41445-7.c @@ -1,6 +1,7 @@ /* PR preprocessor/41445 DWARF5 variant */ /* Test that token after multi-line function-like macro use - gets correct locus even when preprocessing separately. */ + gets correct locus even when preprocessing separately. + If lines are inserted, the expected line number must be updated. */ /* { dg-do compile } */ /* { dg-options "-save-temps -gdwarf-5 -O0 -dA -fno-merge-debug-strings" } */ @@ -12,5 +13,5 @@ int A(B) ; /* We want to check that both vari and varj have the same line number. */ -/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line \\((0xa|10)\\)" } } */ -/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"varj\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line \\((0xa|10)\\)" } } */ +/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"vari\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line \\((0xb|11)\\)" } } */ +/* { dg-final { scan-assembler "DW_TAG_variable\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"varj\[^\\r\\n\]*DW_AT_name(\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*DW_AT_)*\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\[^\\r\\n\]*DW_AT_decl_line \\((0xb|11)\\)" } } */ diff --git a/gcc/testsuite/gcc.dg/debug/pr97714.c b/gcc/testsuite/gcc.dg/debug/pr97714.c new file mode 100644 index 0000000..dba1783 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/pr97714.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -g" } */ + +void +function () +{ + if (0) + { +#line 0 "whatever" + } +} diff --git a/gcc/testsuite/gcc.dg/dfp/dfp.exp b/gcc/testsuite/gcc.dg/dfp/dfp.exp index ef3dea5..a21bef0 100644 --- a/gcc/testsuite/gcc.dg/dfp/dfp.exp +++ b/gcc/testsuite/gcc.dg/dfp/dfp.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2005-2020 Free Software Foundation, Inc. +# Copyright (C) 2005-2021 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 diff --git a/gcc/testsuite/gcc.dg/dg.exp b/gcc/testsuite/gcc.dg/dg.exp index 8cda6a3..9da2507 100644 --- a/gcc/testsuite/gcc.dg/dg.exp +++ b/gcc/testsuite/gcc.dg/dg.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/fixed-point/fixed-point.exp b/gcc/testsuite/gcc.dg/fixed-point/fixed-point.exp index 4e9f58a..7ac2347 100644 --- a/gcc/testsuite/gcc.dg/fixed-point/fixed-point.exp +++ b/gcc/testsuite/gcc.dg/fixed-point/fixed-point.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/format/format.exp b/gcc/testsuite/gcc.dg/format/format.exp index e16eb36..a451aa3 100644 --- a/gcc/testsuite/gcc.dg/format/format.exp +++ b/gcc/testsuite/gcc.dg/format/format.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/gimplefe-error-8.c b/gcc/testsuite/gcc.dg/gimplefe-error-8.c new file mode 100644 index 0000000..59e81eb --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-error-8.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE() f(int x, int y) +{ + int a; + a = (x < y) ? 1 : 2; /* { dg-error "expected" } */ + return a; +} diff --git a/gcc/testsuite/gcc.dg/goacc-gomp/goacc-gomp.exp b/gcc/testsuite/gcc.dg/goacc-gomp/goacc-gomp.exp index 88aeba9..79e1c2b 100644 --- a/gcc/testsuite/gcc.dg/goacc-gomp/goacc-gomp.exp +++ b/gcc/testsuite/gcc.dg/goacc-gomp/goacc-gomp.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2020 Free Software Foundation, Inc. +# Copyright (C) 2006-2021 Free Software Foundation, Inc. # # This file is part of GCC. # diff --git a/gcc/testsuite/gcc.dg/goacc/goacc.exp b/gcc/testsuite/gcc.dg/goacc/goacc.exp index c3e385b..3c5ecf8 100644 --- a/gcc/testsuite/gcc.dg/goacc/goacc.exp +++ b/gcc/testsuite/gcc.dg/goacc/goacc.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2020 Free Software Foundation, Inc. +# Copyright (C) 2006-2021 Free Software Foundation, Inc. # # This file is part of GCC. # diff --git a/gcc/testsuite/gcc.dg/goacc/pr98183.c b/gcc/testsuite/gcc.dg/goacc/pr98183.c new file mode 100644 index 0000000..b041011 --- /dev/null +++ b/gcc/testsuite/gcc.dg/goacc/pr98183.c @@ -0,0 +1,15 @@ +/* PR middle-end/98183 */ +/* { dg-additional-options "-fexceptions -O0" } */ + +void bar (void); +int x, y; + +void +foo (void) +{ +#pragma acc data copyout(x) + { +#pragma acc data copyout(y) + bar (); + } +} diff --git a/gcc/testsuite/gcc.dg/gomp/gomp.exp b/gcc/testsuite/gcc.dg/gomp/gomp.exp index 8a7f18e..a79f877 100644 --- a/gcc/testsuite/gcc.dg/gomp/gomp.exp +++ b/gcc/testsuite/gcc.dg/gomp/gomp.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2020 Free Software Foundation, Inc. +# Copyright (C) 2006-2021 Free Software Foundation, Inc. # # This file is part of GCC. # diff --git a/gcc/testsuite/gcc.dg/gomp/pr98183.c b/gcc/testsuite/gcc.dg/gomp/pr98183.c new file mode 100644 index 0000000..dd11499 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr98183.c @@ -0,0 +1,15 @@ +/* PR middle-end/98183 */ +/* { dg-additional-options "-fexceptions -O0" } */ + +void bar (void); +int x, y; + +void +foo (void) +{ +#pragma omp target data map(tofrom: x) + { +#pragma omp target data map(tofrom: y) + bar (); + } +} diff --git a/gcc/testsuite/gcc.dg/gomp/simd-2.c b/gcc/testsuite/gcc.dg/gomp/simd-2.c index 7ac3eb4..85acb98 100644 --- a/gcc/testsuite/gcc.dg/gomp/simd-2.c +++ b/gcc/testsuite/gcc.dg/gomp/simd-2.c @@ -1,7 +1,8 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fopenmp -fdump-tree-vect-details" } */ +/* { dg-additional-options "-msse2" { target { i?86-*-* x86_64-*-* } } } */ /* { dg-additional-options "-mavx" { target avx } } */ -/* { dg-final { scan-tree-dump-times "vectorized \[1-9]\[0-9]* loops in function" 5 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-9]\[0-9]* loops in function" 5 "vect" { target i?86-*-* x86_64-*-* aarch64-*-* } } } */ int a[10000][128]; diff --git a/gcc/testsuite/gcc.dg/gomp/simd-3.c b/gcc/testsuite/gcc.dg/gomp/simd-3.c index 13e1346..86fee85 100644 --- a/gcc/testsuite/gcc.dg/gomp/simd-3.c +++ b/gcc/testsuite/gcc.dg/gomp/simd-3.c @@ -1,7 +1,8 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fopenmp -fdump-tree-vect-details" } */ +/* { dg-additional-options "-msse2" { target { i?86-*-* x86_64-*-* } } } */ /* { dg-additional-options "-mavx" { target avx } } */ -/* { dg-final { scan-tree-dump-times "vectorized \[1-9]\[0-9]* loops in function" 5 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-9]\[0-9]* loops in function" 5 "vect" { target i?86-*-* x86_64-*-* aarch64-*-* } } } */ int a[1024][1024]; diff --git a/gcc/testsuite/gcc.dg/gomp/task-detach-1.c b/gcc/testsuite/gcc.dg/gomp/task-detach-1.c new file mode 100644 index 0000000..611044d --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/task-detach-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +typedef enum omp_event_handle_t +{ + __omp_event_handle_t_max__ = __UINTPTR_MAX__ +} omp_event_handle_t; + +extern void omp_fulfill_event (omp_event_handle_t); + +void f (omp_event_handle_t x) +{ + void g (void) + { + #pragma omp task detach (x) + omp_fulfill_event (x); + } + + g (); +} diff --git a/gcc/testsuite/gcc.dg/graphite/graphite.exp b/gcc/testsuite/gcc.dg/graphite/graphite.exp index fbd69a7..fa8fa6b 100644 --- a/gcc/testsuite/gcc.dg/graphite/graphite.exp +++ b/gcc/testsuite/gcc.dg/graphite/graphite.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2020 Free Software Foundation, Inc. +# Copyright (C) 2006-2021 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 diff --git a/gcc/testsuite/gcc.dg/guality/pr98219-1.c b/gcc/testsuite/gcc.dg/guality/pr98219-1.c new file mode 100644 index 0000000..c9cb8a5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr98219-1.c @@ -0,0 +1,49 @@ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } */ +/* { dg-options "-g -muintr -mgeneral-regs-only" } */ + +#include <x86gprintrin.h> + +extern void exit (int); +typedef unsigned int uword_t __attribute__ ((mode (__word__))); + +#define UIRRV 0x12345670 +#define RIP 0x12345671 +#define RFLAGS 0x12345672 +#define RSP 0x12345673 + +#define STRING(x) XSTRING(x) +#define XSTRING(x) #x +#define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname) +#define ASMNAME2(prefix, cname) XSTRING (prefix) cname + +void +__attribute__((interrupt, used)) +fn (struct __uintr_frame *frame, uword_t uirrv) +{ + if (UIRRV != uirrv) /* BREAK */ + __builtin_abort (); + if (RIP != frame->rip) + __builtin_abort (); + if (RFLAGS != frame->rflags) + __builtin_abort (); + if (RSP != frame->rsp) + __builtin_abort (); + + exit (0); +} + +int +main () +{ + asm ("push $" STRING (RSP) "; \ + push $" STRING (RFLAGS) "; \ + push $" STRING (RIP) "; \ + push $" STRING (UIRRV) "; \ + jmp " ASMNAME ("fn")); + return 0; +} + +/* { dg-final { gdb-test 22 "uirrv" "0x12345670" } } */ +/* { dg-final { gdb-test 22 "frame->rip" "0x12345671" } } */ +/* { dg-final { gdb-test 22 "frame->rflags" "0x12345672" } } */ +/* { dg-final { gdb-test 22 "frame->rsp" "0x12345673" } } */ diff --git a/gcc/testsuite/gcc.dg/guality/pr98219-2.c b/gcc/testsuite/gcc.dg/guality/pr98219-2.c new file mode 100644 index 0000000..1f74eb3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr98219-2.c @@ -0,0 +1,63 @@ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } */ +/* { dg-options "-g -muintr -mgeneral-regs-only" } */ + +#include <x86gprintrin.h> + +extern void exit (int); +typedef unsigned int uword_t __attribute__ ((mode (__word__))); +typedef int aligned __attribute__((aligned(64))); + +#define UIRRV 0x12345670 +#define RIP 0x12345671 +#define RFLAGS 0x12345672 +#define RSP 0x12345673 + +#define STRING(x) XSTRING(x) +#define XSTRING(x) #x +#define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname) +#define ASMNAME2(prefix, cname) XSTRING (prefix) cname + +int +check_int (int *i, int align) +{ + *i = 20; + if ((((ptrdiff_t) i) & (align - 1)) != 0) + __builtin_abort (); + return *i; +} + +void +__attribute__((interrupt, used)) +fn (struct __uintr_frame *frame, uword_t uirrv) +{ + aligned i; + if (check_int (&i, __alignof__(i)) != i) + __builtin_abort (); + + if (UIRRV != uirrv) /* BREAK */ + __builtin_abort (); + if (RIP != frame->rip) + __builtin_abort (); + if (RFLAGS != frame->rflags) + __builtin_abort (); + if (RSP != frame->rsp) + __builtin_abort (); + + exit (0); +} + +int +main () +{ + asm ("push $" STRING (RSP) "; \ + push $" STRING (RFLAGS) "; \ + push $" STRING (RIP) "; \ + push $" STRING (UIRRV) "; \ + jmp " ASMNAME ("fn")); + return 0; +} + +/* { dg-final { gdb-test 34 "uirrv" "0x12345670" } } */ +/* { dg-final { gdb-test 34 "frame->rip" "0x12345671" } } */ +/* { dg-final { gdb-test 34 "frame->rflags" "0x12345672" } } */ +/* { dg-final { gdb-test 34 "frame->rsp" "0x12345673" } } */ diff --git a/gcc/testsuite/gcc.dg/hwasan/hwasan.exp b/gcc/testsuite/gcc.dg/hwasan/hwasan.exp index 5c040ae..d930b8e 100644 --- a/gcc/testsuite/gcc.dg/hwasan/hwasan.exp +++ b/gcc/testsuite/gcc.dg/hwasan/hwasan.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2019 Free Software Foundation, Inc. +# Copyright (C) 2012-2021 Free Software Foundation, Inc. # # This file is part of GCC. # diff --git a/gcc/testsuite/gcc.dg/intmax_t-1.c b/gcc/testsuite/gcc.dg/intmax_t-1.c index 00b503c..03d4266 100644 --- a/gcc/testsuite/gcc.dg/intmax_t-1.c +++ b/gcc/testsuite/gcc.dg/intmax_t-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-Wall" } */ -/* { dg-error "" "" { target { { *arm*-*-*elf* xtensa*-*-elf* } || vxworks_kernel } } 0 } */ +/* { dg-error "" "" { target { { *arm*-*-*elf* xtensa*-*-elf* } || { vxworks_kernel && { ! *-*-vxworks7r* } } } } 0 } */ /* Compile with -Wall to get a warning if built-in and system intmax_t don't match. */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa.exp b/gcc/testsuite/gcc.dg/ipa/ipa.exp index c947b13..df81fde 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipa.exp +++ b/gcc/testsuite/gcc.dg/ipa/ipa.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/ipa/pr98222.c b/gcc/testsuite/gcc.dg/ipa/pr98222.c new file mode 100644 index 0000000..92e857c --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr98222.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, b, *c; + +int f (int j, int k) { + b = k / j; + if (a) + f(0, 0); + *c = f(b & a, 0); + return 0; +} + +int main() { + if (a) + while (1) + f(0, 0); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/lto.exp b/gcc/testsuite/gcc.dg/lto/lto.exp index 6889091..0ecd24d 100644 --- a/gcc/testsuite/gcc.dg/lto/lto.exp +++ b/gcc/testsuite/gcc.dg/lto/lto.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# Copyright (C) 2009-2021 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 diff --git a/gcc/testsuite/gcc.dg/noncompile/noncompile.exp b/gcc/testsuite/gcc.dg/noncompile/noncompile.exp index 77c4ada..2ce8c53 100644 --- a/gcc/testsuite/gcc.dg/noncompile/noncompile.exp +++ b/gcc/testsuite/gcc.dg/noncompile/noncompile.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/params/params.exp b/gcc/testsuite/gcc.dg/params/params.exp index 323cc1e..9bd0a0a 100644 --- a/gcc/testsuite/gcc.dg/params/params.exp +++ b/gcc/testsuite/gcc.dg/params/params.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2020 Free Software Foundation, Inc. +# Copyright (C) 2016-2021 Free Software Foundation, Inc. # # This file is part of GCC. # diff --git a/gcc/testsuite/gcc.dg/pch/pch.exp b/gcc/testsuite/gcc.dg/pch/pch.exp index c3882b9..b32767b 100644 --- a/gcc/testsuite/gcc.dg/pch/pch.exp +++ b/gcc/testsuite/gcc.dg/pch/pch.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-inlining-3.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-inlining-3.c index e1a4fca..56c9546 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-inlining-3.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-inlining-3.c @@ -35,7 +35,8 @@ int main() This test case captures this behavior. */ /* { dg-regexp "In function 'foo'," "" } */ -/* { dg-regexp " inlined from 'main' at .+/diagnostic-test-inlining-3.c:15:3:" "" } */ +/* { dg-regexp " inlined from 'bar' at .+/diagnostic-test-inlining-3.c:15:3," "" } */ +/* { dg-regexp " inlined from 'main' at .+/diagnostic-test-inlining-3.c:20:3:" "" } */ /* { dg-warning "3: message" "" { target *-*-* } 9 } */ /* { dg-begin-multiline-output "" } __emit_warning ("message"); diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v1.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v1.c new file mode 100644 index 0000000..8f6f716 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v1.c @@ -0,0 +1,71 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ +/* { dg-set-compiler-env-var GCC_EXTRA_DIAGNOSTIC_OUTPUT "fixits-v1" } +/* This is a collection of unittests for diagnostic_show_locus; + see the overview in diagnostic_plugin_test_show_locus.c. + + In particular, note the discussion of why we need a very long line here: +01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + and that we can't use macros in this file. */ + +/* Unit test for rendering of insertion fixit hints + (example taken from PR 62316). */ + +void test_fixit_insert (void) +{ +#if 0 + int a[2][2] = { 0, 1 , 2, 3 }; /* { dg-warning "insertion hints" } */ +/* { dg-regexp "fix-it:.*\\{17:20-17:20\\}:.*" } */ +/* { dg-regexp "fix-it:.*\\{17:24-17:24\\}:.*" } */ +#endif +} + +/* Unit test for rendering of "remove" fixit hints. */ + +void test_fixit_remove (void) +{ +#if 0 + int a;; /* { dg-warning "example of a removal hint" } */ +/* { dg-regexp "fix-it:.*\\{28:9-28:10\\}:.*" } */ +#endif +} + +/* Unit test for rendering of "replace" fixit hints. */ + +void test_fixit_replace (void) +{ +#if 0 + gtk_widget_showall (dlg); /* { dg-warning "example of a replacement hint" } */ +/* { dg-regexp "fix-it:.*\\{38:3-38:21\\}:.*" } */ +#endif +} + +/* Unit test for rendering of fix-it hints that add new lines. */ + +void test_fixit_insert_newline (void) +{ +#if 0 + switch (op) + { + case 'a': + x = a; + case 'b': /* { dg-warning "newline insertion" } */ + x = b; + } +/* { dg-regexp "fix-it:.*\\{52:1-52:1\\}:.*\\n" } */ +#endif +} + +/* Unit test for mutually-exclusive suggestions. */ + +void test_mutually_exclusive_suggestions (void) +{ +#if 0 + original; /* { dg-warning "warning 1" } */ +/* { dg-warning "warning 2" "" { target *-*-* } .-1 } */ +/* We should print the mutually-incompatible fix-it hints within + -fdiagnostics-parseable-fixits; verify that they are printed. */ +/* { dg-regexp "fix-it:.*\\{64:3-64:11}:.*\\n" } */ +/* { dg-regexp "fix-it:.*\\{64:3-64:11}:.*\\n" } */ +#endif +} diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v2.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v2.c new file mode 100644 index 0000000..d5ebd93 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v2.c @@ -0,0 +1,71 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ +/* { dg-set-compiler-env-var GCC_EXTRA_DIAGNOSTIC_OUTPUT "fixits-v2" } +/* This is a collection of unittests for diagnostic_show_locus; + see the overview in diagnostic_plugin_test_show_locus.c. + + In particular, note the discussion of why we need a very long line here: +01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + and that we can't use macros in this file. */ + +/* Unit test for rendering of insertion fixit hints + (example taken from PR 62316). */ + +void test_fixit_insert (void) +{ +#if 0 + int a[2][2] = { 0, 1 , 2, 3 }; /* { dg-warning "insertion hints" } */ +/* { dg-regexp "fix-it:.*\\{17:20-17:20\\}:.*" } */ +/* { dg-regexp "fix-it:.*\\{17:24-17:24\\}:.*" } */ +#endif +} + +/* Unit test for rendering of "remove" fixit hints. */ + +void test_fixit_remove (void) +{ +#if 0 + int a;; /* { dg-warning "example of a removal hint" } */ +/* { dg-regexp "fix-it:.*\\{28:9-28:10\\}:.*" } */ +#endif +} + +/* Unit test for rendering of "replace" fixit hints. */ + +void test_fixit_replace (void) +{ +#if 0 + gtk_widget_showall (dlg); /* { dg-warning "example of a replacement hint" } */ +/* { dg-regexp "fix-it:.*\\{38:3-38:21\\}:.*" } */ +#endif +} + +/* Unit test for rendering of fix-it hints that add new lines. */ + +void test_fixit_insert_newline (void) +{ +#if 0 + switch (op) + { + case 'a': + x = a; + case 'b': /* { dg-warning "newline insertion" } */ + x = b; + } +/* { dg-regexp "fix-it:.*\\{52:1-52:1\\}:.*\\n" } */ +#endif +} + +/* Unit test for mutually-exclusive suggestions. */ + +void test_mutually_exclusive_suggestions (void) +{ +#if 0 + original; /* { dg-warning "warning 1" } */ +/* { dg-warning "warning 2" "" { target *-*-* } .-1 } */ +/* We should print the mutually-incompatible fix-it hints within + -fdiagnostics-parseable-fixits; verify that they are printed. */ +/* { dg-regexp "fix-it:.*\\{64:3-64:11}:.*\\n" } */ +/* { dg-regexp "fix-it:.*\\{64:3-64:11}:.*\\n" } */ +#endif +} diff --git a/gcc/testsuite/gcc.dg/plugin/gil-1.c b/gcc/testsuite/gcc.dg/plugin/gil-1.c index 4e8f535..66872f0 100644 --- a/gcc/testsuite/gcc.dg/plugin/gil-1.c +++ b/gcc/testsuite/gcc.dg/plugin/gil-1.c @@ -13,7 +13,7 @@ void test_2 (PyObject *obj) { Py_BEGIN_ALLOW_THREADS /* { dg-message "releasing the GIL here" } */ - Py_INCREF (obj); /* { dg-warning "use of PyObject '\\*\\(obj\\)' without the GIL" } */ + Py_INCREF (obj); /* { dg-warning "use of PyObject '\\*obj' without the GIL" } */ Py_DECREF (obj); Py_END_ALLOW_THREADS @@ -60,7 +60,7 @@ void test_5 (PyObject *obj) static void __attribute__((noinline)) called_by_test_6 (PyObject *obj) { - Py_INCREF (obj); /* { dg-warning "use of PyObject '\\*\\(obj\\)' without the GIL" } */ + Py_INCREF (obj); /* { dg-warning "use of PyObject '\\*obj' without the GIL" } */ Py_DECREF (obj); } diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp index 7f0ffd6..66a437d 100644 --- a/gcc/testsuite/gcc.dg/plugin/plugin.exp +++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# Copyright (C) 2009-2021 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 @@ -79,6 +79,8 @@ set plugin_test_list [list \ diagnostic-test-show-locus-bw-line-numbers-2.c \ diagnostic-test-show-locus-color-line-numbers.c \ diagnostic-test-show-locus-parseable-fixits.c \ + diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v1.c \ + diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v2.c \ diagnostic-test-show-locus-generate-patch.c }\ { diagnostic_plugin_test_tree_expression_range.c \ diagnostic-test-expressions-1.c } \ diff --git a/gcc/testsuite/gcc.dg/pr60195.c b/gcc/testsuite/gcc.dg/pr60195.c index 8eccf7f..0a50a30 100644 --- a/gcc/testsuite/gcc.dg/pr60195.c +++ b/gcc/testsuite/gcc.dg/pr60195.c @@ -15,7 +15,7 @@ atomic_int fn2 (void) { atomic_int y = 0; - y; /* { dg-warning "statement with no effect" } */ + y; return y; } diff --git a/gcc/testsuite/gcc.dg/pr69047.c b/gcc/testsuite/gcc.dg/pr69047.c index 63d9fd9..d562663 100644 --- a/gcc/testsuite/gcc.dg/pr69047.c +++ b/gcc/testsuite/gcc.dg/pr69047.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -fdump-tree-cddce1" } */ +/* { dg-options "-O -fdump-tree-forwprop4" } */ __UINT8_TYPE__ f(__UINT16_TYPE__ b) @@ -15,4 +15,4 @@ f(__UINT16_TYPE__ b) return a; } -/* { dg-final { scan-tree-dump "_\[0-9\]+ = \\(\[^)\]+\\) b" "cddce1" } } */ +/* { dg-final { scan-tree-dump "_\[0-9\]+ = \\(\[^)\]+\\) b" "forwprop4" } } */ diff --git a/gcc/testsuite/gcc.dg/pr78973.c b/gcc/testsuite/gcc.dg/pr78973.c index 6f4f643..7dd67ce 100644 --- a/gcc/testsuite/gcc.dg/pr78973.c +++ b/gcc/testsuite/gcc.dg/pr78973.c @@ -9,7 +9,7 @@ static void f (void *p, int n) { if (n <= 4) - __builtin_memset (p, 0, n); /* { dg-warning "exceeds maximum object size" "pr79073" { xfail { ilp32 || { int16 && { ! msp430_large } } } } } */ + __builtin_memset (p, 0, n); /* { dg-warning "exceeds maximum object size" "pr79073" { xfail { int16 && { ! msp430_large } } } } */ } void g (void *d, unsigned n) diff --git a/gcc/testsuite/gcc.dg/pr90248.c b/gcc/testsuite/gcc.dg/pr90248.c new file mode 100644 index 0000000..2c89e1e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr90248.c @@ -0,0 +1,73 @@ +/* PR tree-optimization/90248 */ +/* { dg-do run } */ +/* { dg-options "-Ofast" } */ + +volatile float b1 = -1.f; +volatile float b2 = 0.f; + +__attribute__((noipa)) float +f1 (float x) +{ + return x > 0 ? 1.f : -1.f; +} + +__attribute__((noipa)) float +f2 (float x) +{ + return x >= 0 ? 1.f : -1.f; +} + +__attribute__((noipa)) float +f3 (float x) +{ + return x < 0 ? 1.f : -1.f; +} + +__attribute__((noipa)) float +f4 (float x) +{ + return x <= 0 ? 1.f : -1.f; +} + +__attribute__((noipa)) float +f5 (float x) +{ + return x > 0 ? -1.f : 1.f; +} + +__attribute__((noipa)) float +f6 (float x) +{ + return x >= 0 ? -1.f : 1.f; +} + +__attribute__((noipa)) float +f7 (float x) +{ + return x < 0 ? -1.f : 1.f; +} + +__attribute__((noipa)) float +f8 (float x) +{ + return x <= 0 ? -1.f : 1.f; +} + +int +main () +{ + float a = 0.f; + float b = b1 * b2; + float c = 2.f; + float d = -2.f; + if (f1 (a) != -1.f || f1 (b) != -1.f || f1 (c) != 1.f || f1 (d) != -1.f + || f2 (a) != 1.f || f2 (b) != 1.f || f2 (c) != 1.f || f2 (d) != -1.f + || f3 (a) != -1.f || f3 (b) != -1.f || f3 (c) != -1.f || f3 (d) != 1.f + || f4 (a) != 1.f || f4 (b) != 1.f || f4 (c) != -1.f || f4 (d) != 1.f + || f5 (a) != 1.f || f5 (b) != 1.f || f5 (c) != -1.f || f5 (d) != 1.f + || f6 (a) != -1.f || f6 (b) != -1.f || f6 (c) != -1.f || f6 (d) != 1.f + || f7 (a) != 1.f || f7 (b) != 1.f || f7 (c) != 1.f || f7 (d) != -1.f + || f8 (a) != -1.f || f8 (b) != -1.f || f8 (c) != 1.f || f8 (d) != -1.f) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr95582.c b/gcc/testsuite/gcc.dg/pr95582.c new file mode 100644 index 0000000..cc2ab46 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr95582.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -O3" } */ + +typedef _Bool bool8 __attribute__((signed_bool_precision(8))); + +bool8 data[16]; + +void __GIMPLE(ssa) foo(int f) +{ + _Bool t; + bool8 tp; + +__BB(2): + t_2 = f_1(D) != 0; + tp_3 = (bool8) t_2; + data[0] = tp_3; + data[1] = tp_3; + return; +} diff --git a/gcc/testsuite/gcc.dg/pr96239.c b/gcc/testsuite/gcc.dg/pr96239.c new file mode 100644 index 0000000..8af56e1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr96239.c @@ -0,0 +1,54 @@ +/* PR tree-optimization/96239 */ +/* { dg-do run { target { ilp32 || lp64 } } } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " r>> 8;" 1 "optimized" { target bswap } } } */ +/* { dg-final { scan-tree-dump-times " = __builtin_bswap64 " 1 "optimized" { target bswap } } } */ +/* { dg-final { scan-tree-dump-not " >> \(8\|16\|24\|32\|40\|48\|56\);" "optimized" { target bswap } } } */ + +typedef unsigned char V __attribute__((vector_size (2))); +typedef unsigned char W __attribute__((vector_size (8))); + +__attribute__((noipa)) void +foo (unsigned short x, V *p) +{ + *p = (V) { x >> 8, x }; +} + +__attribute__((noipa)) void +bar (unsigned long long x, W *p) +{ + *p = (W) { x >> 56, x >> 48, x >> 40, x >> 32, x >> 24, x >> 16, x >> 8, x }; +} + +__attribute__((noipa)) void +baz (unsigned short x, V *p) +{ + *p = (V) { x, x >> 8 }; +} + +__attribute__((noipa)) void +qux (unsigned long long x, W *p) +{ + *p = (W) { x, x >> 8, x >> 16, x >> 24, x >> 32, x >> 40, x >> 48, x >> 56 }; +} + +int +main () +{ + V a, c, e, g; + W b, d, f, h; + foo (0xcafe, &a); + bar (0xdeadbeefcafebabeULL, &b); + baz (0xdead, &c); + qux (0xfeedbac1beefdeadULL, &d); + e = (V) { 0xca, 0xfe }; + f = (W) { 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0xba, 0xbe }; + g = (V) { 0xad, 0xde }; + h = (W) { 0xad, 0xde, 0xef, 0xbe, 0xc1, 0xba, 0xed, 0xfe }; + if (__builtin_memcmp (&a, &e, sizeof (V)) + || __builtin_memcmp (&b, &f, sizeof (W)) + || __builtin_memcmp (&c, &g, sizeof (V)) + || __builtin_memcmp (&d, &h, sizeof (W))) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr96674.c b/gcc/testsuite/gcc.dg/pr96674.c new file mode 100644 index 0000000..194ce2e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr96674.c @@ -0,0 +1,40 @@ +/* { dg-do run } */ +/* { dg-options "-O -fdump-tree-optimized -fwrapv" } */ + +#include <limits.h> +#include <stdbool.h> + +bool __attribute__ ((noipa)) test1 (unsigned a, unsigned b) +{ + return (b == 0) | (a < b); +} + +bool __attribute__ ((noipa)) test2 (int a, int b) +{ + return (b == INT_MIN) | (a < b); +} + +bool __attribute__ ((noipa)) test3 (unsigned a, unsigned b) +{ + return (b != 0) & (a >= b); +} + +bool __attribute__ ((noipa)) test4 (int a, int b) +{ + return (b != INT_MIN) & (a >= b); +} + +int main() +{ + if (!test1 (1, 0) || !test1 (1, 2) || test1 (2, 1) || + !test2 (1, INT_MIN) || !test2 (1, 2) || test2 (2, 1) || + test3 (1, 0) || test3 (1, 2) || !test3 (2, 1) || + test4 (1, INT_MIN) || test4 (1, 2) || !test4 (2, 1)) { + __builtin_abort(); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "\\+ 4294967295;" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\\+ -1;" 2 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/pr97172.c b/gcc/testsuite/gcc.dg/pr97172.c new file mode 100644 index 0000000..ab5b2e9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97172.c @@ -0,0 +1,50 @@ +/* PR middle-end/97172 - ICE: tree code ‘ssa_name’ is not supported in LTO + streams + { dg-do compile } + { dg-options "-Wall -flto" } + { dg-require-effective-target lto } */ + +int n; + +void fn (int a[n]); +void fnp1 (int a[n + 1]); + +void fx_n (int a[][n]); +void fx_np1 (int a[][n + 1]); + +void f2_n (int a[2][n]); +void f2_np1 (int a[2][n + 1]); + +void fn_3 (int a[n][3]); +void fnp1_3 (int a[n + 1][3]); + +void fn_n (int a[n][n]); +void fn_np1 (int a[n][n + 1]); +void fnp1_np1 (int a[n + 1][n + 1]); + +void fn_n_n (int a[n][n][n]); +void fn_n_np1 (int a[n][n][n + 1]); +void fn_np1_np1 (int a[n][n + 1][n + 1]); +void fnp1_np1_np1 (int a[n + 1][n + 1][n + 1]); + + +void gn (int a[n]) { fn (a); } +void gnp1 (int a[n + 1]) { fnp1 (a); } + +void gx_n (int a[][n]) { fx_n (a); } +void gx_np1 (int a[][n + 1]) { fx_np1 (a); } + +void g2_n (int a[2][n]) { f2_n (a); } +void g2_np1 (int a[2][n + 1]) { f2_np1 (a); } + +void gn_3 (int a[n][3]) { fn_3 (a); } +void gnp1_3 (int a[n + 1][3]) { fnp1_3 (a); } + +void gn_n (int a[n][n]) { fn_n (a); } +void gn_np1 (int a[n][n + 1]) { fn_np1 (a); } +void gnp1_np1 (int a[n + 1][n + 1]) { fnp1_np1 (a); } + +void gn_n_n (int a[n][n][n]) { fn_n_n (a); } +void gn_n_np1 (int a[n][n][n + 1]) { fn_n_np1 (a); } +void gn_np1_np1 (int a[n][n + 1][n + 1]) { fn_np1_np1 (a); } +void gnp1_np1_np1 (int a[n + 1][n + 1][n + 1]) { fnp1_np1_np1 (a); } diff --git a/gcc/testsuite/gcc.dg/pr97750.c b/gcc/testsuite/gcc.dg/pr97750.c new file mode 100644 index 0000000..90c3dc2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97750.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/97750 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -Wextra" } */ + +char CopyPlane_src; +long CopyPlane_copy_pitch; +char *CopyFromUswc_src; +int CopyFromUswc_height; +void CopyPlane(char *dst) { + __builtin_memcpy(dst, &CopyPlane_src, CopyPlane_copy_pitch); +} +void CopyFromUswc(long src_pitch) { + char *dst; + for (; CopyFromUswc_height;) { + unsigned unaligned = (long)CopyFromUswc_src; + if (unaligned) + CopyPlane(&dst[unaligned]); + CopyFromUswc_src += src_pitch; + } +} +/* { dg-prune-output "-Wmaybe-uninitialized" } */ diff --git a/gcc/testsuite/gcc.dg/pr97981.c b/gcc/testsuite/gcc.dg/pr97981.c new file mode 100644 index 0000000..846b875 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97981.c @@ -0,0 +1,15 @@ +/* PR c/97981 */ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ +/* { dg-final { scan-tree-dump-times "atomic_load" 2 "original" } } */ + + +void f(void) +{ + volatile _Atomic int x; + x; + volatile _Atomic double a; + double b; + b = a; +} + diff --git a/gcc/testsuite/gcc.dg/pr98029.c b/gcc/testsuite/gcc.dg/pr98029.c new file mode 100644 index 0000000..148f23c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98029.c @@ -0,0 +1,21 @@ +/* pr98029 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +double f2 (void) +{ + volatile double d; + int i; + + for (d = 2.0, i = 0; i < 5; i++, d *= d) /* { dg-bogus "right-hand operand of comma expression has no effect" } */ + ; + + return d; +} + +int g(void) +{ + volatile int x; + (x = 1, (void)1); /* { dg-bogus "right-hand operand of comma expression has no effect" } */ + return x; +} diff --git a/gcc/testsuite/gcc.dg/pr98190.c b/gcc/testsuite/gcc.dg/pr98190.c new file mode 100644 index 0000000..bfdd17d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98190.c @@ -0,0 +1,33 @@ +/* PR middle-end/98190 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +static int __attribute__((noipa)) +foo (const char *p, const char *q, const int len) +{ + for (int i = 0; i < len; p++, q++, i++) + { + int equal; + _Bool x, y; + __builtin_memcpy ((char *) &x, p, sizeof x); + __builtin_memcpy ((char *) &y, q, sizeof y); + equal = (x == y); + if (equal <= 0) + return equal; + } + return 1; +} + +int +main () +{ + const _Bool buf[4] = { 1, 0, 0, 0 }; +#ifdef __aarch64__ + register long x4 asm ("x4") = 0xdeadbeefULL; + register long x5 asm ("x5") = 0xcafebabeULL; + asm volatile (""::"r" (x4), "r" (x5)); +#endif + if (foo ((char *) &buf[0], (char *) &buf[0], 1) != 1) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr98211.c b/gcc/testsuite/gcc.dg/pr98211.c new file mode 100644 index 0000000..cea371d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98211.c @@ -0,0 +1,51 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu90 -O3 -fgimple" } */ + +int test_var_3; +short arr_20[16]; +void __GIMPLE (ssa,startwith("slp")) +test (int var_1, short int a, short int b, short int c, short int d) +{ + _Bool tem2; + _Bool tem; + unsigned int i_5; + int _24; + _Bool _28; + short int _30; + short int _32; + + __BB(2): + _24 = test_var_3; + tem_25 = _24 != 0; + tem2_26 = var_1_11(D) != 0; + _28 = tem_25 | tem2_26; + _30 = _28 != _Literal (_Bool) 0 ? a_16(D) : b_15(D); + arr_20[0u] = _30; + _32 = _28 != _Literal (_Bool) 0 ? c_19(D) : d_18(D); + arr_20[8u] = _32; + arr_20[1u] = _30; + arr_20[9u] = _32; + arr_20[2u] = _30; + arr_20[10u] = _32; + arr_20[3u] = _30; + arr_20[11u] = _32; + arr_20[4u] = _30; + arr_20[12u] = _32; + arr_20[5u] = _30; + arr_20[13u] = _32; + arr_20[6u] = _30; + arr_20[14u] = _32; + arr_20[7u] = _30; + arr_20[15u] = _32; + return; +} + + +int +main() +{ + test (1, 0x88, 0x77, 0x77, 0x88); + if (arr_20[0] != 0x88) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr98255.c b/gcc/testsuite/gcc.dg/pr98255.c new file mode 100644 index 0000000..5cbed68 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98255.c @@ -0,0 +1,49 @@ +/* PR tree-optimization/98255 */ +/* { dg-do run } */ +/* { dg-options "-Os" } */ +/* { dg-additional-options "-fPIC" { target fpic } } */ + +struct A { volatile unsigned b; unsigned c; }; +int d, *e, h, k, l; +static struct A f; +long g; +static unsigned i = -2U; +volatile int j; + +long +foo (void) +{ + char n[4][4][3] + = { { {9, 2, 8}, {9, 2, 8}, {9, 2, 8}, {9} }, { {8} }, { {8} }, { {2} } }; + while (d) + { + for (; f.c < 4; f.c++) + { + *e = 0; + h = n[f.c + 4][0][d]; + } + while (g) + return n[0][3][i]; + while (1) + { + if (k) + { + j = 0; + if (j) + continue; + } + if (l) + break; + } + } + return 0; +} + +int +main () +{ + asm volatile ("" : "+g" (d), "+g" (g), "+g" (f.c)); + asm volatile ("" : "+g" (e), "+g" (k), "+g" (l)); + foo (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr98271.c b/gcc/testsuite/gcc.dg/pr98271.c new file mode 100644 index 0000000..b453434 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98271.c @@ -0,0 +1,13 @@ +/* PR rtl-optimization/98271 */ +/* PR rtl-optimization/98276 */ +/* PR tree-optimization/98279 */ +/* { dg-do compile } */ +/* { dg-options "-O --param=align-loop-iterations=1197120096074465280 --param=gcse-cost-distance-ratio=2147483648 --param=hot-bb-frequency-fraction=2147483648" } */ +/* { dg-error "argument to .--param=align-loop-iterations=. is bigger than 2147483647" "" { target *-*-* } 0 } */ +/* { dg-error "argument to .--param=gcse-cost-distance-ratio=. is bigger than 2147483647" "" { target *-*-* } 0 } */ +/* { dg-error "argument to .--param=hot-bb-frequency-fraction=. is bigger than 2147483647" "" { target *-*-* } 0 } */ + +void +foo (void) +{ +} diff --git a/gcc/testsuite/gcc.dg/pr98272.c b/gcc/testsuite/gcc.dg/pr98272.c new file mode 100644 index 0000000..126a616 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98272.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/98272 */ +/* Reported by Zdenek Sojka <zsojka@seznam.cz> */ + +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-forwprop" } */ + +void bar (void); + +void +foo (unsigned char uc) +{ + if (uc >= 5) + return; + + switch (uc) + { + case 0: + case 2: + case 4: + bar (); + } +} diff --git a/gcc/testsuite/gcc.dg/pr98330.c b/gcc/testsuite/gcc.dg/pr98330.c new file mode 100644 index 0000000..bc68a6f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98330.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +float f (__typeof (__builtin_pow) fn, float x) +{ + return fn (x, 2); +} diff --git a/gcc/testsuite/gcc.dg/pr98331.c b/gcc/testsuite/gcc.dg/pr98331.c new file mode 100644 index 0000000..951b758 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98331.c @@ -0,0 +1,18 @@ +/* PR debug/98331 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2 -fcompare-debug" } */ +/* { dg-additional-options "-march=x86-64" { target { i?86-*-* x86_64-*-* } } } */ + +void bar (const char *); +unsigned long long x; + +void +foo (void) +{ + int a = 1; + bar ("foo"); + int b = 2; + __atomic_fetch_add (&x, 1, 0); + int c = 3; + __builtin_unreachable (); +} diff --git a/gcc/testsuite/gcc.dg/pr98721-1.c b/gcc/testsuite/gcc.dg/pr98721-1.c new file mode 100644 index 0000000..868b071 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98721-1.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/98721 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +foo (int n) +{ + if (n <= 0) + { + char vla[n]; /* { dg-message "source object 'vla' of size 0" } */ + return __builtin_strlen (vla); /* { dg-warning "'__builtin_strlen' reading 1 or more bytes from a region of size 0" } */ + } + return -1; +} diff --git a/gcc/testsuite/gcc.dg/pr98721-2.c b/gcc/testsuite/gcc.dg/pr98721-2.c new file mode 100644 index 0000000..c8ca542 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98721-2.c @@ -0,0 +1,8 @@ +/* PR tree-optimization/98721 */ +/* { dg-do compile } */ + +int +foo (void) +{ + return __builtin_strlen (__builtin_alloca_with_align (0, 16)); /* { dg-warning "'__builtin_strlen' reading 1 or more bytes from a region of size 0" } */ +} /* { dg-message "source object '<unknown>' of size 0" "" { target *-*-* } .-1 } */ diff --git a/gcc/testsuite/gcc.dg/pr98766.c b/gcc/testsuite/gcc.dg/pr98766.c new file mode 100644 index 0000000..d388fd2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98766.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/98766. */ + +/* { dg-do compile } */ +/* { dg-options "-O3 --param=avoid-fma-max-bits=8 " } */ +/* { dg-additional-options "-march=armv8.2-a+sve" { target aarch64*-*-* } } */ + +extern int a[]; +void c(short *d) { + for (int e = 0; e < 9; e++) + a[e] = d[e] * 2; +} + diff --git a/gcc/testsuite/gcc.dg/pr98793.c b/gcc/testsuite/gcc.dg/pr98793.c new file mode 100644 index 0000000..bb1ae9c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98793.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -Wno-psabi" } */ + +typedef unsigned char u8; +typedef unsigned char __attribute__((__vector_size__ (8))) v64u8; +typedef unsigned char __attribute__((__vector_size__ (64))) v512u8; +typedef unsigned long long u64; + +u64 gx; +v512u8 gu; +v512u8 gv; + +v64u8 __attribute__((__noipa__)) foo0 (u8 ax, v512u8 au, u64 ay) +{ + u8 lx = ax && (u8) ay; + v512u8 lc = 7 <= au; + v512u8 ld = (u8) (ay && gx) == gu; + v512u8 le = (v512u8) ld + (v512u8) gv; + v512u8 lf = le + lc; + return (((union + { + v512u8 a; + v64u8 b[8]; + }) lf).b[3]) + lx; +} + +int +main (void) +{ + v64u8 x = foo0 (2, (v512u8) { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15 + }, + 2); + for (unsigned i = 0; i < sizeof (x); i++) + if (x[i] != (i ? 0 : 0xff)) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr98807.c b/gcc/testsuite/gcc.dg/pr98807.c new file mode 100644 index 0000000..d4eac5a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr98807.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-options "-O2 -Wno-psabi -w" } */ +/* { dg-additional-options "-mno-sse2" { target x86_64-*-* i?86-*-* } } */ + +#include <stdint.h> + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; +typedef u64 __attribute__((__vector_size__ (16))) v128u64; +u16 foo0_u16_0; +v128u64 foo0_v64u32_0; +u64 foo0_u64_0; +v128u64 foo0_v128u64_2; + +v128u64 +foo0 (u8 u8_0, v128u64 v128u64_0) +{ + u32 u32_1 = u8_0 || (0, 0); + foo0_v128u64_2 - u8_0; + foo0_u16_0 |= foo0_u64_0 && u8_0 > foo0_u64_0 <= u32_1; + v128u64 v128u64_4 = v128u64_0 >= u8_0; + return v128u64_4 + foo0_v64u32_0; +} + +int +main () +{ + v128u64 x = foo0 (3, (v128u64) { 0, 12 }); + if (x[0] != 0) __builtin_abort(); + if (x[1] != 0xffffffffffffffff) __builtin_abort(); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/predict-8.c b/gcc/testsuite/gcc.dg/predict-8.c index 5578175..ec755e2 100644 --- a/gcc/testsuite/gcc.dg/predict-8.c +++ b/gcc/testsuite/gcc.dg/predict-8.c @@ -8,4 +8,4 @@ int foo(float a, float b) { return 2; } -/* { dg-final { scan-rtl-dump-times "65.\[34]. .guessed" 2 "expand"} } */ +/* { dg-final { scan-rtl-dump-times "99.\[678]. .guessed" 2 "expand"} } */ diff --git a/gcc/testsuite/gcc.dg/pthread-init-1.c b/gcc/testsuite/gcc.dg/pthread-init-1.c index 8b600c3..3346c92 100644 --- a/gcc/testsuite/gcc.dg/pthread-init-1.c +++ b/gcc/testsuite/gcc.dg/pthread-init-1.c @@ -7,9 +7,9 @@ /* { dg-do compile } */ /* { dg-require-effective-target pthread_h } */ /* { dg-options "-Wextra -Wall" } */ -/* The RTP definition of PTHREAD_MUTEX_INITIALIZER is missing an - * initializer for mutexAttr.mutexAttrType. */ -/* { dg-xfail-if "missing initializer" { vxworks_rtp } } */ +/* The definition of PTHREAD_MUTEX_INITIALIZER is missing an initializer for + mutexAttr.mutexAttrType in kernel mode for various VxWorks versions. */ +/* { dg-xfail-if "missing initializer" { vxworks_kernel } } */ #include "pthread-init-common.h" diff --git a/gcc/testsuite/gcc.dg/pthread-init-2.c b/gcc/testsuite/gcc.dg/pthread-init-2.c index 8ec0515..d7cd66b 100644 --- a/gcc/testsuite/gcc.dg/pthread-init-2.c +++ b/gcc/testsuite/gcc.dg/pthread-init-2.c @@ -9,6 +9,9 @@ /* { dg-options "-Wextra -Wall -ansi" } */ /* { dg-options "-Wextra -Wall -ansi -D_POSIX_C_SOURCE=199506L" { target { *-*-hpux* } } } */ /* { dg-options "-Wextra -Wall -ansi -D_XOPEN_SOURCE=500" { target { powerpc-ibm-aix* } } } */ +/* The definition of PTHREAD_MUTEX_INITIALIZER is missing an initializer for + mutexAttr.mutexAttrType in kernel mode for various VxWorks versions. */ +/* { dg-xfail-if "missing initializer" { vxworks_kernel } } */ #include "pthread-init-common.h" diff --git a/gcc/testsuite/gcc.dg/qual-assign-7.c b/gcc/testsuite/gcc.dg/qual-assign-7.c new file mode 100644 index 0000000..3e064e8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/qual-assign-7.c @@ -0,0 +1,18 @@ +/* test that assignment drops qualifiers, Bug 98047 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + + +volatile int jv; +extern int j; +extern typeof(jv = 1) j; + +_Atomic int ja; +extern typeof(ja = 1) j; + +int * __restrict pa; +extern int *p; +extern typeof(pa = 0) p; + + + diff --git a/gcc/testsuite/gcc.dg/rtl/rtl.exp b/gcc/testsuite/gcc.dg/rtl/rtl.exp index fb9981c..5253314 100644 --- a/gcc/testsuite/gcc.dg/rtl/rtl.exp +++ b/gcc/testsuite/gcc.dg/rtl/rtl.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2020 Free Software Foundation, Inc. +# Copyright (C) 2016-2021 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 diff --git a/gcc/testsuite/gcc.dg/rtl/x86_64/test-return-const.c.before-fwprop.c b/gcc/testsuite/gcc.dg/rtl/x86_64/test-return-const.c.before-fwprop.c index 075f744..1dadf55 100644 --- a/gcc/testsuite/gcc.dg/rtl/x86_64/test-return-const.c.before-fwprop.c +++ b/gcc/testsuite/gcc.dg/rtl/x86_64/test-return-const.c.before-fwprop.c @@ -31,7 +31,7 @@ int __RTL (startwith ("fwprop1")) test_returning_constant (void) } /* Verify that insn 5 is eliminated. */ -/* { dg-final { scan-rtl-dump "deferring deletion of insn with uid = 5" "fwprop1" } } */ +/* { dg-final { scan-rtl-dump "deleting insn with uid = 5" "fwprop1" } } */ /* { dg-final { scan-rtl-dump "Deleted 1 trivially dead insns" "fwprop1" } } */ int main (void) diff --git a/gcc/testsuite/gcc.dg/sancov/sancov.exp b/gcc/testsuite/gcc.dg/sancov/sancov.exp index 0b16da0..ab69d12 100644 --- a/gcc/testsuite/gcc.dg/sancov/sancov.exp +++ b/gcc/testsuite/gcc.dg/sancov/sancov.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2020 Free Software Foundation, Inc. +# Copyright (C) 2015-2021 Free Software Foundation, Inc. # # This file is part of GCC. # diff --git a/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.exp b/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.exp index 26cd7ac..852e554 100644 --- a/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.exp +++ b/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2020 Free Software Foundation, Inc. +# Copyright (C) 2011-2021 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 diff --git a/gcc/testsuite/gcc.dg/special/mips-abi.exp b/gcc/testsuite/gcc.dg/special/mips-abi.exp index 1affab1..23aacf5 100644 --- a/gcc/testsuite/gcc.dg/special/mips-abi.exp +++ b/gcc/testsuite/gcc.dg/special/mips-abi.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2020 Free Software Foundation, Inc. +# Copyright (C) 2002-2021 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 diff --git a/gcc/testsuite/gcc.dg/special/special.exp b/gcc/testsuite/gcc.dg/special/special.exp index d92624c..29175f3 100644 --- a/gcc/testsuite/gcc.dg/special/special.exp +++ b/gcc/testsuite/gcc.dg/special/special.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 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 diff --git a/gcc/testsuite/gcc.dg/sso/sso.exp b/gcc/testsuite/gcc.dg/sso/sso.exp index 80f534b..1755823 100644 --- a/gcc/testsuite/gcc.dg/sso/sso.exp +++ b/gcc/testsuite/gcc.dg/sso/sso.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2020 Free Software Foundation, Inc. +# Copyright (C) 2013-2021 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 diff --git a/gcc/testsuite/gcc.dg/tls/tls.exp b/gcc/testsuite/gcc.dg/tls/tls.exp index 0ab3105..ef7d21c 100644 --- a/gcc/testsuite/gcc.dg/tls/tls.exp +++ b/gcc/testsuite/gcc.dg/tls/tls.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2020 Free Software Foundation, Inc. +# Copyright (C) 2002-2021 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 diff --git a/gcc/testsuite/gcc.dg/tm/tm.exp b/gcc/testsuite/gcc.dg/tm/tm.exp index a0a2ad5..804b087 100644 --- a/gcc/testsuite/gcc.dg/tm/tm.exp +++ b/gcc/testsuite/gcc.dg/tm/tm.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# Copyright (C) 2009-2021 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 diff --git a/gcc/testsuite/gcc.dg/torture/ftrapv-2.c b/gcc/testsuite/gcc.dg/torture/ftrapv-2.c index 75e464f..4d746c9 100644 --- a/gcc/testsuite/gcc.dg/torture/ftrapv-2.c +++ b/gcc/testsuite/gcc.dg/torture/ftrapv-2.c @@ -12,7 +12,7 @@ /* Verify SImode operations properly trap. PR middle-end/68046 */ -int i = 0x7fffffff; +volatile int i = 0x7fffffff; int main(void) { @@ -20,7 +20,7 @@ int main(void) int status = 0; if (child == 0) { - volatile int x = i + 1 < i; + i = i + 1; exit (0); } else if (child == -1) diff --git a/gcc/testsuite/gcc.dg/torture/pr97559-1.c b/gcc/testsuite/gcc.dg/torture/pr97559-1.c new file mode 100644 index 0000000..d5de3bd --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr97559-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +int printf (char *, ...); + +int a, b, c, d; + +void e () { + int f = a; + if (b) { + L1: + b = 0; + L2: + if (c) { + if (f) + printf("0"); + goto L1; + } + } + if (d) + goto L2; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr97559-2.c b/gcc/testsuite/gcc.dg/torture/pr97559-2.c new file mode 100644 index 0000000..b512e6d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr97559-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +int a, b, c, d; + +void e() { + int f = b; + if (a) { + L1: + a = 0; + L2: + if (a) { + c = b; + goto L1; + } + } + if (d) + goto L2; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr98191.c b/gcc/testsuite/gcc.dg/torture/pr98191.c new file mode 100644 index 0000000..7c4a6d1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr98191.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-w -Wno-psabi" } */ + +typedef double v2df __attribute__((vector_size(2*sizeof(double)))); + +v2df foo (double *y) +{ + v2df x = (v2df){ 1.0, 2.0 }; + x[0] = *y; + return x; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr98219-1.c b/gcc/testsuite/gcc.dg/torture/pr98219-1.c new file mode 100644 index 0000000..89b5aa3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr98219-1.c @@ -0,0 +1,45 @@ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } */ +/* { dg-skip-if "PR81210 sp not aligned to 16 bytes" { *-*-darwin* } } */ +/* { dg-options "-muintr -mgeneral-regs-only" } */ + +#include <x86gprintrin.h> + +extern void exit (int); +typedef unsigned int uword_t __attribute__ ((mode (__word__))); + +#define UIRRV 0x12345670 +#define RIP 0x12345671 +#define RFLAGS 0x12345672 +#define RSP 0x12345673 + +#define STRING(x) XSTRING(x) +#define XSTRING(x) #x +#define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname) +#define ASMNAME2(prefix, cname) XSTRING (prefix) cname + +void +__attribute__((interrupt, used)) +fn (struct __uintr_frame *frame, uword_t uirrv) +{ + if (UIRRV != uirrv) + __builtin_abort (); + if (RIP != frame->rip) + __builtin_abort (); + if (RFLAGS != frame->rflags) + __builtin_abort (); + if (RSP != frame->rsp) + __builtin_abort (); + + exit (0); +} + +int +main () +{ + asm ("push $" STRING (RSP) "; \ + push $" STRING (RFLAGS) "; \ + push $" STRING (RIP) "; \ + push $" STRING (UIRRV) "; \ + jmp " ASMNAME ("fn")); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr98219-2.c b/gcc/testsuite/gcc.dg/torture/pr98219-2.c new file mode 100644 index 0000000..c2f33f8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr98219-2.c @@ -0,0 +1,59 @@ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } */ +/* { dg-skip-if "PR81210 sp not aligned to 16 bytes" { *-*-darwin* } } */ +/* { dg-options "-muintr -mgeneral-regs-only" } */ + +#include <x86gprintrin.h> + +extern void exit (int); +typedef unsigned int uword_t __attribute__ ((mode (__word__))); +typedef int aligned __attribute__((aligned(64))); + +#define UIRRV 0x12345670 +#define RIP 0x12345671 +#define RFLAGS 0x12345672 +#define RSP 0x12345673 + +#define STRING(x) XSTRING(x) +#define XSTRING(x) #x +#define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname) +#define ASMNAME2(prefix, cname) XSTRING (prefix) cname + +int +check_int (int *i, int align) +{ + *i = 20; + if ((((ptrdiff_t) i) & (align - 1)) != 0) + __builtin_abort (); + return *i; +} + +void +__attribute__((interrupt, used)) +fn (struct __uintr_frame *frame, uword_t uirrv) +{ + aligned i; + if (check_int (&i, __alignof__(i)) != i) + __builtin_abort (); + + if (UIRRV != uirrv) + __builtin_abort (); + if (RIP != frame->rip) + __builtin_abort (); + if (RFLAGS != frame->rflags) + __builtin_abort (); + if (RSP != frame->rsp) + __builtin_abort (); + + exit (0); +} + +int +main () +{ + asm ("push $" STRING (RSP) "; \ + push $" STRING (RFLAGS) "; \ + push $" STRING (RIP) "; \ + push $" STRING (UIRRV) "; \ + jmp " ASMNAME ("fn")); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr98235.c b/gcc/testsuite/gcc.dg/torture/pr98235.c new file mode 100644 index 0000000..5f59013 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr98235.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fallow-store-data-races" } */ + +char tcube[3][9]; +int cur_move; +void perm_cube(void) { + int i, j, k, tmp; + for (; i < cur_move; i++) + while (k-- >= 0) + switch (j) { + case 0: + tmp = tcube[0][6]; + tcube[2][8] = tcube[0][8]; + tcube[0][8] = tmp; + tmp = tcube[0][5]; + tcube[0][5] = tcube[1][8]; + tcube[1][8] = tcube[2][5]; + tcube[2][5] = tcube[1][2]; + tcube[1][2] = tcube[2][1]; + tcube[2][1] = tcube[1][0]; + tcube[0][6] = tmp; + tmp = tcube[0][3]; + tcube[0][3] = tcube[1][0]; + tcube[1][0] = tcube[2][3]; + tcube[2][3] = tcube[1][6]; + tcube[1][6] = tmp; + break; + case 5: + tmp = tcube[2][0]; + tcube[2][0] = tcube[2][2]; + tcube[2][2] = tcube[2][8]; + tcube[2][3] = tmp; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr98289.c b/gcc/testsuite/gcc.dg/torture/pr98289.c new file mode 100644 index 0000000..07094a1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr98289.c @@ -0,0 +1,52 @@ +/* PR rtl-optimization/98289 */ +/* { dg-do compile { target freorder } } */ +/* { dg-options "-O2 -freorder-blocks-and-partition" } */ + +int bar (void) __attribute__((cold)); + +void +foo (int x) +{ + if (x) + __builtin_abort (); +} + +void +baz (int x) +{ + if (__builtin_expect (x, 0)) + { + bar (); + bar (); + bar (); + } +} + +void +qux (int x, int y, int z, int w) +{ + if (x || y || z || w) + __builtin_abort (); +} + +int +corge (int x, int y, int z, int w, int u) +{ + if (__builtin_expect (x, 0)) + goto lab; + u++; + if (__builtin_expect (y, 0)) + goto lab; + u *= 2; + if (__builtin_expect (z, 0)) + goto lab; + u |= 42; + if (__builtin_expect (w, 0)) + { + lab:; + bar (); + bar (); + if (bar () > 32) goto lab; + } + return u; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr98640.c b/gcc/testsuite/gcc.dg/torture/pr98640.c new file mode 100644 index 0000000..b187781 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr98640.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-require-effective-target stdint_types } */ + +#include <stdint.h> + +uint64_t var_0 = 18128133247277979402ULL; +int64_t var_14 = 6557021550272328915LL; +uint64_t var_83 = 10966786425750692026ULL; + +void test() +{ + var_14 = var_0 + (_Bool)7; + var_83 = 1 + (int)var_0; // 1 + 888395530 +} + +int main() +{ + test(); + if (var_83 != 888395531) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr98758.c b/gcc/testsuite/gcc.dg/torture/pr98758.c new file mode 100644 index 0000000..7b9fdb2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr98758.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +long *a, *b; +long c; +void d(void) +{ + b = a; + while (c) { + *a = (__INTPTR_TYPE__)(a += (long)1 << (sizeof(long) * 8 - 10)); + c = b[0]; + b = a; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr98773.c b/gcc/testsuite/gcc.dg/torture/pr98773.c new file mode 100644 index 0000000..026e8ef --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr98773.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ + +char a[128]; + +void __attribute__((noipa)) +foo () +{ + for (unsigned i = 27; i >= 5; --i) + a[i] = a[i-5]; +} + +int main() +{ + __builtin_memcpy (a, "Hello World", sizeof ("Hello World")); + foo (); + if (__builtin_memcmp (a + 5, "Hello World", sizeof ("Hello World")) != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr98786.c b/gcc/testsuite/gcc.dg/torture/pr98786.c new file mode 100644 index 0000000..ea36471 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr98786.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-dce" } */ + +void +func_30 (void); + +int __attribute__ ((pure, returns_twice)) +func_38 (int g_15, int p_39) +{ + return !!g_15 ? p_39 : 0; +} + +void +func_26 (int func_26___trans_tmp_1) +{ + long int l_37 = 0; + int __trans_tmp_1; + + func_26___trans_tmp_1 = func_38 (func_26___trans_tmp_1, 1); + __trans_tmp_1 = func_38 (func_26___trans_tmp_1, l_37); + l_37 = 1; + func_30 (); +} diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/stackalign.exp b/gcc/testsuite/gcc.dg/torture/stackalign/stackalign.exp index c2baddd..d77eae4 100644 --- a/gcc/testsuite/gcc.dg/torture/stackalign/stackalign.exp +++ b/gcc/testsuite/gcc.dg/torture/stackalign/stackalign.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2008-2020 Free Software Foundation, Inc. +# Copyright (C) 2008-2021 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 diff --git a/gcc/testsuite/gcc.dg/torture/tls/tls.exp b/gcc/testsuite/gcc.dg/torture/tls/tls.exp index d2ea1cc..ff085c2 100644 --- a/gcc/testsuite/gcc.dg/torture/tls/tls.exp +++ b/gcc/testsuite/gcc.dg/torture/tls/tls.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2020 Free Software Foundation, Inc. +# Copyright (C) 2010-2021 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 diff --git a/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp b/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp index ec61795..90f2c4d 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp +++ b/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 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 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/asm-2.c b/gcc/testsuite/gcc.dg/tree-ssa/asm-2.c index 00c3079..8f747b7 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/asm-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/asm-2.c @@ -7,9 +7,13 @@ #ifdef __moxie__ #define REGISTER "2" #else +#ifdef __iq2000__ +#define REGISTER "3" +#else #define REGISTER "0" #endif #endif +#endif void baz(void) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/asm-3.c b/gcc/testsuite/gcc.dg/tree-ssa/asm-3.c index 9e49303..7808634 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/asm-3.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/asm-3.c @@ -8,9 +8,13 @@ #ifdef __moxie__ #define REGISTER "8" #else +#ifdef __iq2000__ +#define REGISTER "3" +#else #define REGISTER "0" #endif #endif +#endif void foo (int); void bar (int); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-20.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-20.c index 5966eab..ec14057 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-20.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-20.c @@ -1,7 +1,8 @@ /* PR tree-optimization/87034 - missing -Wformat-overflow on a sprintf - %s with a wide string - { dg-do compile } - { dg-options "-O2 -Wall -Wformat-overflow -ftrack-macro-expansion=0" } */ + %s with a wide string. */ +/* { dg-do compile } */ +/* { dg-require-effective-target 4byte_wchar_t } */ +/* { dg-options "-O2 -Wall -Wformat-overflow -ftrack-macro-expansion=0" } */ typedef __WCHAR_TYPE__ wchar_t; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-1.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-1.c index c36112a..617a841 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-1.c @@ -33,4 +33,4 @@ float i1(float x) { return (x <= 0.f ? 1.f : -1.f); } -/* { dg-final { scan-tree-dump-times "copysign" 8 "gimple"} } */ +/* { dg-final { scan-tree-dump-not "copysign" "gimple"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-1.c b/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-1.c index e66fa73..e5da00b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-iftoswitch-optimized" } */ +/* { dg-options "-O2 -fdump-tree-iftoswitch-optimized --param case-values-threshold=5" } */ int global; int foo (); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-10.c b/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-10.c new file mode 100644 index 0000000..7b21c99 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/if-to-switch-10.c @@ -0,0 +1,44 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-iftoswitch-optimized --param case-values-threshold=5" } */ + +int global; +int foo (); + +int main(int argc, char **argv) +{ + if (argc != 1) + { + if (argc != 2) + { + if (argc == 3) + { + foo (); + foo (); + } + else if (argc == 4) + { + foo (); + } + else if (argc == 5) + { + global = 2; + } + else + global -= 123; + } + else + { + global += 1; + } + } + else + foo (); + + + global -= 12; + return 0; +} + +/* { dg-final { scan-tree-dump "Canonical GIMPLE case clusters: 1 2 3 4 5" "iftoswitch" } } */ +/* { dg-final { scan-tree-dump "Condition chain with \[^\n\r]\* BBs transformed into a switch statement." "iftoswitch" } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr47059.c b/gcc/testsuite/gcc.dg/tree-ssa/pr47059.c new file mode 100644 index 0000000..9f9c61a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr47059.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fdump-tree-optimized" } */ + + +struct struct1 +{ + void *data; + unsigned short f1; + unsigned short f2; +}; +typedef struct struct1 S1; + +struct struct2 +{ + int f3; + S1 f4; +}; +typedef struct struct2 S2; + + +extern void foo (S1 *ptr); +extern S2 gstruct2_var; +extern S1 gstruct1_var; + +static inline S1 bar (const S1 *ptr) __attribute__ ((always_inline)); + +static inline S1 +bar (const S1 *ptr) +{ + S1 ls_var = *ptr; + foo (&ls_var); + return ls_var; +} + +int +main () +{ + S2 *ps_var; + + ps_var = &gstruct2_var; + ps_var->f4 = bar (&gstruct1_var); + + return 0; +} +/* { dg-final { scan-tree-dump-times "short unsigned int\[^*\]*;" 0 "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr56719.c b/gcc/testsuite/gcc.dg/tree-ssa/pr56719.c new file mode 100644 index 0000000..cc999f9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr56719.c @@ -0,0 +1,33 @@ +/* PR tree-optimization/56719 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " > 1023" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " > 2047" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " > 8191" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " <= 1023" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " <= 4095" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " <= 8191" 1 "optimized" } } */ + +int +f1 (int x, int y) +{ + return x > 0x3ffU || y > 0x3ffU; +} + +int +f2 (int x, int y, int z, unsigned w) +{ + return x > 0x1fffU || z > 0x7ffU || w > 0x7ffU || y > 0x1fffU; +} + +int +f3 (int x, int y) +{ + return x <= 0x3ffU && y <= 0x3ffU; +} + +int +f4 (int x, int y, unsigned z, unsigned w) +{ + return x <= 0x1fffU && z <= 0xfff && w <= 0xfff && y <= 0x1fffU; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr94785.c b/gcc/testsuite/gcc.dg/tree-ssa/pr94785.c new file mode 100644 index 0000000..9239284 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr94785.c @@ -0,0 +1,36 @@ +/* PR tree-optimization/94785 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " = ABS_EXPR <v_\[0-9]*\\\(D\\\)>;" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " = ABSU_EXPR <v_\[0-9]*\\\(D\\\)>;" 2 "optimized" } } */ + +int +f1 (int v) +{ + return (1 | -(v < 0)) * v; +} + +unsigned +f2 (int v) +{ + return (1U | -(v < 0)) * v; +} + +int +f3 (int v) +{ + int a = v < 0; + int b = -a; + int c = 1 | b; + return c * v; +} + +unsigned +f4 (int v) +{ + int a = v < 0; + int b = -a; + unsigned c = b; + unsigned d = c | 1; + return d * v; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr94802-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr94802-1.c new file mode 100644 index 0000000..8175704 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr94802-1.c @@ -0,0 +1,68 @@ +/* PR tree-optimization/94802 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-not " = __builtin_clz " "optimized" } } */ + +__attribute__((noipa)) int +f1 (int a, int b) +{ + return __builtin_clz (a - b) != 0; +} + +__attribute__((noipa)) int +f2 (int x) +{ + return __builtin_clz (x) == 0; +} + +__attribute__((noipa)) int +f3 (int x) +{ + return __builtin_clz (x) != 0; +} + +__attribute__((noipa)) int +f4 (int a, int b) +{ + return __builtin_clz (a - b) == sizeof (int) * __CHAR_BIT__ - 1; +} + +__attribute__((noipa)) int +f5 (int x) +{ + return __builtin_clz (x) == sizeof (int) * __CHAR_BIT__ - 1; +} + +__attribute__((noipa)) int +f6 (int x) +{ + return __builtin_clz (x) != sizeof (int) * __CHAR_BIT__ - 1; +} + +int +main () +{ + if (f1 (5, 7) != 0 + || f1 (7, 5) != 1 + || f2 (1) != 0 + || f2 (137) != 0 + || f2 (-1) != 1 + || f2 (-137) != 1 + || f3 (1) != 1 + || f3 (137) != 1 + || f3 (-1) != 0 + || f3 (-137) != 0 + || f4 (5, 4) != 1 + || f4 (6, 4) != 0 + || f4 (4, 5) != 0 + || f5 (1) != 1 + || f5 (17) != 0 + || f5 (-1) != 0 + || f5 (-17) != 0 + || f6 (1) != 0 + || f6 (17) != 1 + || f6 (-1) != 1 + || f6 (-17) != 1) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr95731.c b/gcc/testsuite/gcc.dg/tree-ssa/pr95731.c new file mode 100644 index 0000000..39889be --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr95731.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/95731 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " >= 0\| < 0" 6 "optimized" } } */ + +int +foo (int x, int y, int z, int w, long long u, long long v) +{ + return x >= 0 && y >= 0 && z < 0 && u < 0 && w >= 0 && v < 0; +} + +int +bar (int x, int y, int z, int w, long long u, long long v) +{ + return u >= 0 && x >= 0 && y >= 0 && v < 0 && z >= 0 && w >= 0; +} + +int +baz (int x, int y, int z, int w, long long u, long long v) +{ + return x >= 0 || u < 0 || y >= 0 || v < 0 || z >= 0 || w >= 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr95867.c b/gcc/testsuite/gcc.dg/tree-ssa/pr95867.c new file mode 100644 index 0000000..8ab3690 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr95867.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/95867 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " \\* " 13 "optimized" } } */ + +#define A n * n * n * n * n * n * n * n +#define B A * A * A * A * A * A * A * A +#define C B * B * B * B * B * B * B * B + +unsigned +foo (unsigned n) +{ + return C * B * B * A * n * n * n * n * n; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96094.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96094.c new file mode 100644 index 0000000..fe9163d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96094.c @@ -0,0 +1,34 @@ +/* PR tree-optimization/96094 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "return 34;" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return y_\[0-9]*\\\(D\\\);" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return \[^\n\r;]*;" 4 "optimized" } } */ + +int +foo (int x) +{ + if (x >= 2U) + return 34; + return 34 / x; +} + +int +bar (int x, int y) +{ + if (x >= 2U) + return y; + return y / x; +} + +int +baz (_Bool x) +{ + return 34 / x; +} + +int +qux (_Bool x, int y) +{ + return y / x; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96239.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96239.c new file mode 100644 index 0000000..a099fd9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96239.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/96239 */ +/* { dg-do compile { target { ilp32 || lp64 } } } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump " r>> 8;" "optimized" { target bswap } } } */ + +union U { unsigned char c[2]; unsigned short s; }; + +unsigned short +foo (unsigned short x) +{ + union U u; + u.s = x; + unsigned char v = u.c[0]; + unsigned char w = u.c[1]; + u.c[0] = w; + u.c[1] = v; + return u.s; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96272.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96272.c new file mode 100644 index 0000000..4c9fa63 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96272.c @@ -0,0 +1,37 @@ +/* PR tree-optimization/96272 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-widening_mul" } */ + +unsigned +foo (unsigned a, unsigned b) +{ + if (a > ~0U - b) + return ~0U; + return a + b; +} + +unsigned +bar (unsigned a, unsigned b) +{ + if (a <= ~0U - b) + return ~0U; + return a + b; +} + +unsigned +baz (unsigned a, unsigned b) +{ + if (~0U - b < a) + return ~0U; + return a + b; +} + +unsigned +qux (unsigned a, unsigned b) +{ + if (~0U - b >= a) + return ~0U; + return a + b; +} + +/* { dg-final { scan-tree-dump-times "ADD_OVERFLOW" 4 "widening_mul" { target { i?86-*-* x86_64-*-* } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96669-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96669-1.c new file mode 100644 index 0000000..6a95a6b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96669-1.c @@ -0,0 +1,59 @@ +/* PR tree-optimization/96669 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ +/* { dg-final { scan-tree-dump "a == 0" "original" } } */ +/* { dg-final { scan-tree-dump "return 1;" "original" } } */ +/* { dg-final { scan-tree-dump "return c == 3;" "original" } } */ +/* { dg-final { scan-tree-dump "return d != 1;" "original" } } */ +/* { dg-final { scan-tree-dump "return e != 0;" "original" } } */ +/* { dg-final { scan-tree-dump "return f == 1;" "original" } } */ +/* { dg-final { scan-tree-dump "return 0;" "original" } } */ +/* { dg-final { scan-tree-dump "return h != 1;" "original" } } */ + +int +f1 (int a) +{ + return ((1 << a) & 1) != 0; +} + +int +f2 (int b) +{ + return ((2 << b) & 1) == 0; +} + +int +f3 (int c) +{ + return ((2 << c) & 16) != 0; +} + +int +f4 (int d) +{ + return ((16 << d) & 32) == 0; +} + +int +f5 (int e) +{ + return ((1 >> e) & 1) == 0; +} + +int +f6 (int f) +{ + return ((2 >> f) & 1) != 0; +} + +int +f7 (int g) +{ + return ((1 >> g) & 2) != 0; +} + +int +f8 (int h) +{ + return ((32 >> h) & 16) == 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96669-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96669-2.c new file mode 100644 index 0000000..47b885f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96669-2.c @@ -0,0 +1,30 @@ +/* PR tree-optimization/96669 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ +/* { dg-final { scan-tree-dump "a == 0" "original" } } */ +/* { dg-final { scan-tree-dump-times "return 0;" 2 "original" } } */ +/* { dg-final { scan-tree-dump "c == 0" "original" } } */ + +int +f1 (int a) +{ + return ((1 << a) & 1); +} + +int +f2 (int b) +{ + return ((2 << b) & 1); +} + +int +f3 (int c) +{ + return ((35 << c) & 1); +} + +int +f4 (int d) +{ + return ((42 << d) & 1); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96671-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96671-1.c new file mode 100644 index 0000000..42c5b27 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96671-1.c @@ -0,0 +1,51 @@ +/* PR tree-optimization/96671 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " \\^ " 6 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " ~" 6 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " & " 6 "optimized" } } */ + +int +foo (int a, int b, int c) +{ + return (a ^ b) & ((b ^ c) ^ a); +} + +int +bar (int a, int b, int c) +{ + return (a ^ b) & ((b ^ a) ^ c); +} + +int +baz (int a, int b, int c) +{ + return (a ^ b) & ((a ^ c) ^ b); +} + +int +qux (int a, int b, int c) +{ + int d = a ^ b; + int e = b ^ c; + int f = e ^ a; + return d & f; +} + +int +corge (int a, int b, int c) +{ + int d = a ^ b; + int e = b ^ a; + int f = c ^ e; + return d & f; +} + +int +garply (int a, int b, int c) +{ + int d = a ^ b; + int e = a ^ c; + int f = b ^ e; + return d & f; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96671-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96671-2.c new file mode 100644 index 0000000..185fd11 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96671-2.c @@ -0,0 +1,51 @@ +/* PR tree-optimization/96671 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " \\^ " 6 "optimized" } } */ +/* { dg-final { scan-tree-dump-not " ~" "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\| " 6 "optimized" } } */ + +int +foo (int a, int b, int c) +{ + return (a ^ b) | ((b ^ c) ^ a); +} + +int +bar (int a, int b, int c) +{ + return (a ^ b) | ((b ^ a) ^ c); +} + +int +baz (int a, int b, int c) +{ + return (a ^ b) | ((a ^ c) ^ b); +} + +int +qux (int a, int b, int c) +{ + int d = a ^ b; + int e = b ^ c; + int f = e ^ a; + return d | f; +} + +int +corge (int a, int b, int c) +{ + int d = a ^ b; + int e = b ^ a; + int f = c ^ e; + return d | f; +} + +int +garply (int a, int b, int c) +{ + int d = a ^ b; + int e = a ^ c; + int f = b ^ e; + return d | f; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96681.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96681.c new file mode 100644 index 0000000..6d72a1a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96681.c @@ -0,0 +1,35 @@ +/* PR tree-optimization/96681 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " \\^ " 5 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " (?:<|>=) 0" 5 "optimized" } } */ + +int +foo (int x, int y) +{ + return (x < 0) ^ (y < 0); +} + +int +bar (int x, int y) +{ + return (x > -1) ^ (y > -1); +} + +int +baz (int x, int y) +{ + return (x ^ y) < 0; +} + +int +qux (int x, int y) +{ + return (x ^ y) >= 0; +} + +int +corge (int x, int y) +{ + return (x >= 0) ^ (y < 0); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96685-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96685-1.c new file mode 100644 index 0000000..eb3b1ea --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96685-1.c @@ -0,0 +1,52 @@ +/* PR tree-optimization/96685 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "return 1;" 6 "optimized" } } */ + +unsigned +f1 (unsigned x, unsigned y) +{ + unsigned a = ~(x - y); + unsigned b = ~x + y; + return a == b; +} + +unsigned +f2 (unsigned x) +{ + unsigned a = ~(x + -124U); + unsigned b = ~x + 124U; + return a == b; +} + +unsigned +f3 (unsigned x) +{ + unsigned a = ~(x + 124U); + unsigned b = ~x + -124U; + return a == b; +} + +int +f4 (int x, int y) +{ + int a = ~(x - y); + int b = ~x + y; + return a == b; +} + +int +f5 (int x) +{ + int a = ~(x + -124); + int b = ~x + 124; + return a == b; +} + +int +f6 (int x) +{ + int a = ~(x + 124); + int b = ~x + -124; + return a == b; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96685-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96685-2.c new file mode 100644 index 0000000..e3c1ac7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96685-2.c @@ -0,0 +1,40 @@ +/* PR tree-optimization/96685 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "return 1;" 4 "optimized" } } */ + +int +f1 (unsigned x, unsigned y) +{ + unsigned int r1 = (x - y); + r1 = ~r1; + unsigned int r2 = ~(x - y); + return r1 == r2; +} + +int +f2 (unsigned x, unsigned y) +{ + unsigned int r1 = (x - 23); + r1 = ~r1; + unsigned int r2 = ~(x - 23); + return r1 == r2; +} + +int +f3 (int x, int y) +{ + int r1 = (x - y); + r1 = ~r1; + int r2 = ~(x - y); + return r1 == r2; +} + +int +f4 (int x, int y) +{ + int r1 = (x - 23); + r1 = ~r1; + int r2 = ~(x - 23); + return r1 == r2; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96685-3.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96685-3.c new file mode 100644 index 0000000..b3c1855 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96685-3.c @@ -0,0 +1,43 @@ +/* PR tree-optimization/96685 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "return 1;" 4 "optimized" } } */ + +int +f1 (unsigned x, unsigned y) +{ + unsigned int r1 = (x - y); + r1 = ~r1; + unsigned int r2 = (y - x); + r2 = r2 - 1; + return r1 == r2; +} + +int +f2 (unsigned x, unsigned y) +{ + unsigned int r1 = (x - 23); + r1 = ~r1; + unsigned int r2 = (23 - x); + r2 = r2 - 1; + return r1 == r2; +} + +int +f3 (int x, int y) +{ + int r1 = (x - 23); + r1 = ~r1; + int r2 = (23 - x); + --r2; + return r1 == r2; +} + +int +f4 (int x, int y) +{ + int r1 = (x - 23); + r1 = ~r1; + int r2 = (22 - x); + return r1 == r2; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96688.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96688.c new file mode 100644 index 0000000..acaa0f6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96688.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/96688 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " = -124 >> " 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " >> " 3 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " = ~" 1 "optimized" } } */ + +int +foo (int x) +{ + return ~(123 >> x); +} + +unsigned +bar (int x) +{ + return ~(123U >> x); +} + +unsigned +baz (int x) +{ + return ~(~123U >> x); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96691.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96691.c new file mode 100644 index 0000000..a254cc7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96691.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/96691 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " \\\| 123;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\\& 123;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\\^ -315;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\\^ 314;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-not " \\\^ 321;" "optimized" } } */ +/* { dg-final { scan-tree-dump-not " = ~" "optimized" } } */ + +int +foo (int x) +{ + return (~x | 123) ^ 321; +} + +int +bar (int x) +{ + return (~x & 123) ^ 321; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96782.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96782.c new file mode 100644 index 0000000..0444eef --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96782.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/96782 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "return 0;" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "return 1;" 1 "optimized" } } */ + +int +foo (int a) +{ + return a == ~a; +} + +int +bar (int b) +{ + return ~b != b; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96928.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96928.c new file mode 100644 index 0000000..2091357 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96928.c @@ -0,0 +1,38 @@ +/* PR tree-optimization/96928 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2" } */ +/* { dg-final { scan-tree-dump-times " = a_\[0-9]*\\\(D\\\) >> " 5 "phiopt2" } } */ +/* { dg-final { scan-tree-dump-times " = ~c_\[0-9]*\\\(D\\\);" 1 "phiopt2" } } */ +/* { dg-final { scan-tree-dump-times " = ~" 1 "phiopt2" } } */ +/* { dg-final { scan-tree-dump-times " = \[abc_0-9\\\(\\\)D]* \\\^ " 5 "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not "a < 0" "phiopt2" } } */ + +int +foo (int a) +{ + return a < 0 ? ~a : a; +} + +int +bar (int a, int b) +{ + return a < 0 ? ~b : b; +} + +unsigned +baz (int a, unsigned int b) +{ + return a < 0 ? ~b : b; +} + +unsigned +qux (int a, unsigned int c) +{ + return a >= 0 ? ~c : c; +} + +int +corge (int a, int b) +{ + return a >= 0 ? b : ~b; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr97260.c b/gcc/testsuite/gcc.dg/tree-ssa/pr97260.c new file mode 100644 index 0000000..9b3723b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr97260.c @@ -0,0 +1,11 @@ +/* PR tree-optimization/97260 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump "return 0;" "optimized" } } */ + +int +foo (void) +{ + const char a[] = "1234"; + return __builtin_memcmp (a, "1234", 4); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr98182.c b/gcc/testsuite/gcc.dg/tree-ssa/pr98182.c new file mode 100644 index 0000000..29a547e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr98182.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/98182 */ +/* { dg-do compile } */ +/* { dg-options "-O1 --param case-values-threshold=1 -fdump-tree-iftoswitch-optimized" } */ + +int global; +int foo (); + +int main(int argc, char **argv) +{ + if (argc != 1) + __builtin_abort (); + else if (argc != 2) + __builtin_abort (); + else + return 0; +} + +/* { dg-final { scan-tree-dump-not "Condition chain" "iftoswitch" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr98455.c b/gcc/testsuite/gcc.dg/tree-ssa/pr98455.c new file mode 100644 index 0000000..24e249f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr98455.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/98455 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-dce --param case-values-threshold=1" } */ + +void +n4 (int io, int vb) +{ + double uc[2] = { 1.0, 2.0, }; + + if (io == 0) + uc[0] = 0.0; + + for (;;) + if (io == 0) + if (vb == 0) + uc[0] = uc[1]; + else if (vb == 1) + uc[1] = 0.0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr98513.c b/gcc/testsuite/gcc.dg/tree-ssa/pr98513.c new file mode 100644 index 0000000..c15d6bd --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr98513.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fgimple" } */ + +__attribute__((noipa)) +void __GIMPLE (ssa,startwith("evrp")) +foo (int x, int minus_1) +{ + int tem; + unsigned int _1; + unsigned int _2; + + __BB(2): + tem_4 = minus_1_3(D); + tem_5 = tem_4 + 2; + _1 = (unsigned int) x_6(D); + _2 = _1 + 2147483647u; + if (_2 > 1u) + goto __BB3; + else + goto __BB6; + + __BB(3): + if (x_6(D) <= tem_5) + goto __BB4; + else + goto __BB6; + + __BB(4): + if (x_6(D) > 5) + goto __BB5; + else + goto __BB6; + + __BB(5): + __builtin_exit (0); + + __BB(6): + return; + +} + +int +main() +{ + foo (10, 100); + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-37.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-37.c index 624b2a8..948fa3b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-37.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-37.c @@ -12,5 +12,5 @@ foo (int x) } /* Check if the tests have been folded into a bit test. */ -/* { dg-final { scan-tree-dump "(8784908|0x0*860c0c)" "optimized" { target i?86-*-* x86_64-*-* } } } */ +/* { dg-final { scan-tree-dump "(8784908|-8784909|0x0*860c0c)" "optimized" { target i?86-*-* x86_64-*-* } } } */ /* { dg-final { scan-tree-dump "(<<|>>)" "optimized" { target i?86-*-* x86_64-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-54.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-54.c index be7537e..02ebf06 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-54.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-54.c @@ -1,6 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target int32plus } */ -/* { dg-options "-O -fdump-tree-fre1 -fdump-tree-dse1" } */ +/* { dg-options "-O -fdump-tree-forwprop4 -fdump-tree-dse1" } */ extern void abort (void); @@ -51,6 +51,6 @@ int main() return 0; } -/* { dg-final { scan-tree-dump "\\(char\\) i_" "fre1" } } */ -/* { dg-final { scan-tree-dump "\\(short int\\) i_" "fre1" } } */ +/* { dg-final { scan-tree-dump "\\(char\\) i_" "forwprop4" } } */ +/* { dg-final { scan-tree-dump "\\(short int\\) i_" "forwprop4" } } */ /* { dg-final { scan-tree-dump-not "u.i =" "dse1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/tree-ssa.exp b/gcc/testsuite/gcc.dg/tree-ssa/tree-ssa.exp index 7d262ff..2a22ea9 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/tree-ssa.exp +++ b/gcc/testsuite/gcc.dg/tree-ssa/tree-ssa.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/tsan/atomic-fence.c b/gcc/testsuite/gcc.dg/tsan/atomic-fence.c new file mode 100644 index 0000000..013720c --- /dev/null +++ b/gcc/testsuite/gcc.dg/tsan/atomic-fence.c @@ -0,0 +1,11 @@ +/* PR sanitizer/97868 */ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=thread" } */ + +int +main () +{ + __atomic_thread_fence (__ATOMIC_RELAXED); /* { dg-warning ".atomic_thread_fence. is not supported with .-fsanitize=thread." } */ + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/tsan/tsan.exp b/gcc/testsuite/gcc.dg/tsan/tsan.exp index 36a67c1..c760ae0 100644 --- a/gcc/testsuite/gcc.dg/tsan/tsan.exp +++ b/gcc/testsuite/gcc.dg/tsan/tsan.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2020 Free Software Foundation, Inc. +# Copyright (C) 2013-2021 Free Software Foundation, Inc. # # This file is part of GCC. # diff --git a/gcc/testsuite/gcc.dg/ubsan/ubsan.exp b/gcc/testsuite/gcc.dg/ubsan/ubsan.exp index 62968e4..16a0a53 100644 --- a/gcc/testsuite/gcc.dg/ubsan/ubsan.exp +++ b/gcc/testsuite/gcc.dg/ubsan/ubsan.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2020 Free Software Foundation, Inc. +# Copyright (C) 2013-2021 Free Software Foundation, Inc. # # This file is part of GCC. # diff --git a/gcc/testsuite/gcc.dg/uninit-38.c b/gcc/testsuite/gcc.dg/uninit-38.c new file mode 100644 index 0000000..8dacc8c --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-38.c @@ -0,0 +1,87 @@ +/* Verify that dereferencing uninitialized allocated objects and VLAs + correctly reflects offsets into the objects. + The test's main purpose is to exercise the formatting of MEM_REFs. + If -Wuninitialized gets smarter and detects uninitialized accesses + before they're turned into MEM_REFs the test will likely need to + be adjusted. Ditto if -Wuninitialized output changes for some + other reason. + { dg-do compile { target { { lp64 || ilp32 } || llp64 } } } + { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */ + +#define CONCAT(x, y) x ## y +#define CAT(x, y) CONCAT(x, y) +#define UNIQ(name) CAT (name, __LINE__) + +typedef __SIZE_TYPE__ size_t; + +extern void* malloc (size_t); + +void sink (void*, ...); + +#undef T +#define T(Type, idx, off) \ + __attribute__ ((noipa)) \ + void UNIQ (test_)(int n) \ + { \ + void *p = malloc (n); \ + Type *q = (Type*)((char*)p + off); \ + sink (p, q[idx]); \ + } \ + typedef void dummy_type + +T (int, 0, 0); // { dg-warning "'\\*\\(int \\*\\)p' is used uninitialized" } +T (int, 0, 1); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)'" } +T (int, 0, 2); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)p \\+ 2\\)'" } +T (int, 0, 3); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)p \\+ 3\\)'" } +T (int, 0, 4); // { dg-warning "'\\(\\(int \\*\\)p\\)\\\[1]'" } +T (int, 0, 5); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)\\)\\\[1]'" } +T (int, 0, 6); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 2\\)\\)\\\[1]'" } +T (int, 0, 7); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 3\\)\\)\\\[1]'" } +T (int, 0, 8); // { dg-warning "'\\(\\(int \\*\\)p\\)\\\[2]'" } +T (int, 0, 9); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)\\)\\\[2]'" } + + +T (int, 1, 0); // { dg-warning "'\\(\\(int \\*\\)p\\)\\\[1]' is used uninitialized" } +T (int, 1, 1); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)\\)\\\[1]'" } +T (int, 1, 2); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 2\\)\\)\\\[1]'" } +T (int, 1, 3); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 3\\)\\)\\\[1]'" } +T (int, 1, 4); // { dg-warning "'\\(\\(int \\*\\)p\\)\\\[2]'" } +T (int, 1, 5); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)\\)\\\[2]'" } +T (int, 1, 6); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 2\\)\\)\\\[2]'" } +T (int, 1, 7); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 3\\)\\)\\\[2]'" } +T (int, 1, 8); // { dg-warning "'\\(\\(int \\*\\)p\\)\\\[3]'" } +T (int, 1, 9); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)p \\+ 1\\)\\)\\\[3]'" } + +#undef T +#define T(Type, idx, off) \ + __attribute__ ((noipa)) \ + void UNIQ (test_)(int n) \ + { \ + char a[n], *p = a; \ + Type *q = (Type*)((char*)p + off); \ + sink (p, q[idx]); \ + } \ + typedef void dummy_type + +T (int, 0, 0); // { dg-warning "'\\*\\(int \\*\\)a' is used uninitialized" } +T (int, 0, 1); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)'" } +T (int, 0, 2); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)a \\+ 2\\)'" } +T (int, 0, 3); // { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)a \\+ 3\\)'" } +T (int, 0, 4); // { dg-warning "'\\(\\(int \\*\\)a\\)\\\[1]'" } +T (int, 0, 5); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)\\)\\\[1]'" } +T (int, 0, 6); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 2\\)\\)\\\[1]'" } +T (int, 0, 7); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 3\\)\\)\\\[1]'" } +T (int, 0, 8); // { dg-warning "'\\(\\(int \\*\\)a\\)\\\[2]'" } +T (int, 0, 9); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)\\)\\\[2]'" } + + +T (int, 1, 0); // { dg-warning "'\\(\\(int \\*\\)a\\)\\\[1]' is used uninitialized" } +T (int, 1, 1); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)\\)\\\[1]'" } +T (int, 1, 2); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 2\\)\\)\\\[1]'" } +T (int, 1, 3); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 3\\)\\)\\\[1]'" } +T (int, 1, 4); // { dg-warning "'\\(\\(int \\*\\)a\\)\\\[2]'" } +T (int, 1, 5); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)\\)\\\[2]'" } +T (int, 1, 6); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 2\\)\\)\\\[2]'" } +T (int, 1, 7); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 3\\)\\)\\\[2]'" } +T (int, 1, 8); // { dg-warning "'\\(\\(int \\*\\)a\\)\\\[3]'" } +T (int, 1, 9); // { dg-warning "'\\(\\(int \\*\\)\\(\\(char \\*\\)a \\+ 1\\)\\)\\\[3]'" } diff --git a/gcc/testsuite/gcc.dg/uninit-39.c b/gcc/testsuite/gcc.dg/uninit-39.c new file mode 100644 index 0000000..0f91854 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-39.c @@ -0,0 +1,47 @@ +/* PR c/98592 - ICE in gimple_canonical_types_compatible_p while formatting + a MEM_REF + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +void f (int); + +void vlaNx3_to_pia1 (int n) +{ + int a[n][3]; + + /* The VLA isn't formatted correctly due to PR 98587. Just verify + there is no ICE and a warning is issued. */ + f (((*(int(*)[4])&a[1][2]))[3]); // { dg-warning "\\\[-Wuninitialized" } +} + +void vlaNxN_to_pia1 (int n) +{ + int a[n][n]; + + /* Same as above. */ + f (((*(int(*)[4])&a[1][2]))[3]); // { dg-warning "\\\[-Wuninitialized" } +} + +void vlaNxN_to_pvla4xN (int n) +{ + int a[n][n]; + + /* Same as above. */ + f (((*(int(*)[4][n])&a[1][2]))[3][4]); // { dg-warning "\\\[-Wuninitialized" } +} + +void vlaN_to_pia2 (int n) +{ + int a[n]; + + /* Same as above. */ + f (((*(int(*)[3][4])&a[1]))[2][3]); // { dg-warning "\\\[-Wuninitialized" } +} + +void vlaN_to_pvlaNx4 (int n) +{ + int a[n]; + + /* Same as above. */ + f (((*(int(*)[n][4])&a[1]))[1][3]); // { dg-warning "\\\[-Wuninitialized" } +} diff --git a/gcc/testsuite/gcc.dg/uninit-40.c b/gcc/testsuite/gcc.dg/uninit-40.c new file mode 100644 index 0000000..c015191 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-40.c @@ -0,0 +1,50 @@ +/* PR tree-optimization/98597 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +union U { double d; int i; float f; }; +struct S { char a; int b; char c; unsigned d; union U e; int f[3]; unsigned g[3]; }; +struct T { char t; struct S u; int v; }; +typedef short V[2][2]; +void baz (V *); + +static inline int +bar (char *p) +{ + return *(int *) p; +} + +void +foo (int *q) +{ + struct T t; + t.t = 1; + t.u.c = 2; + char *pt = (char *) &t; + q[0] = bar (pt + __builtin_offsetof (struct T, u.b)); /* { dg-warning "'t\\.u\\.b' is used uninitialized" } */ + q[1] = bar (pt + __builtin_offsetof (struct T, u.e)); /* { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)&t \\+ offsetof\\(struct T, u\\.e\\)\\)' is used uninitialized" } */ + q[2] = bar (pt + __builtin_offsetof (struct T, v)); /* { dg-warning "'t\\.v' is used uninitialized" } */ + q[3] = bar (pt + __builtin_offsetof (struct T, u.d)); /* { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)&t \\+ offsetof\\(struct T, u\\.d\\)\\)' is used uninitialized" } */ + q[4] = bar (pt + __builtin_offsetof (struct T, u.f[2])); /* { dg-warning "'t\\.u\\.f\\\[2\\\]' is used uninitialized" } */ + q[5] = bar (pt + __builtin_offsetof (struct T, u.g[2])); /* { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)&t \\+ offsetof\\(struct T, u\\.g\\\[2\\\]\\)\\)' is used uninitialized" } */ + int s[3]; + s[0] = 1; + char *ps = (char *) s; + q[6] = bar (ps + sizeof (int)); /* { dg-warning "'s\\\[1\\\]' is used uninitialized" } */ + unsigned w[2][2]; + w[0][0] = 1; + char *pw = (char *) w; + q[7] = bar (pw + 3 * sizeof (unsigned)); /* { dg-warning "'\\*\\(int \\*\\)\\(&w\\\[1\\\]\\\[1\\\]\\)' is used uninitialized" } */ + struct T x[3][3]; + x[0][0].t = 1; + char *px = (char *) x; + q[8] = bar (px + 5 * sizeof (struct T) + __builtin_offsetof (struct T, u.b)); /* { dg-warning "'x\\\[1\\\]\\\[2\\\]\\.u\\.b' is used uninitialized" } */ + q[9] = bar (px + 6 * sizeof (struct T) + __builtin_offsetof (struct T, u.d)); /* { dg-warning "'\\*\\(int \\*\\)\\(\\(char \\*\\)&x\\\[2\\\]\\\[0\\\] \\+ offsetof\\(struct T, u\\.d\\)\\)' is used uninitialized" } */ +#if defined(__i386__) || defined(__x86_64__) + /* memcpy folding is too target dependent to test it everywhere. */ + V u[2], v[2]; + u[0][0][0] = 1; + __builtin_memcpy (&v[1], &u[1], sizeof (V)); /* { dg-warning "'\\*\\(\(long \)?long unsigned int \\*\\)\\(&u\\\[1\\\]\\\[0\\\]\\\[0\\\]\\)' is used uninitialized" "" { target i?86-*-* x86_64-*-* } } */ + baz (&v[1]); +#endif +} diff --git a/gcc/testsuite/gcc.dg/uninit-pr98578.c b/gcc/testsuite/gcc.dg/uninit-pr98578.c new file mode 100644 index 0000000..98d6117 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-pr98578.c @@ -0,0 +1,110 @@ +/* PR middle-end/98578 - ICE warning on uninitialized VLA access + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +void* malloc (__SIZE_TYPE__); + +void T (int, ...); + +void vla_n (int n, int i) +{ + int a1[n]; + + /* a1[I] should be formatted as as a1[I] (or, for I == 0, perhaps + as *a1), but definitely not as *a1[I]. This is a bug in VLA + formatting. */ + T (a1[0]); // { dg-warning "'a1\\\[0]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "'\\*a1\\\[0]' is used uninitialized" "spurious star" { target *-*-* } .-1 } + T (a1[1]); // { dg-warning "a1\\\[1]' is used uninitialized" } + T (a1[i]); // { dg-warning "a1\\\[i]' is used uninitialized" } +} + +void vla_n_2 (int n, int i) +{ + int a2[n][2]; + + T (a2[0][0]); // { dg-warning "a2\\\[0]\\\[0]' is used uninitialized" } + T (a2[2][1]); // { dg-warning "a2\\\[2]\\\[1]' is used uninitialized" } + T (a2[3][i]); // { dg-warning "a2\\\[3]\\\[i]' is used uninitialized" } + T (a2[i][0]); // { dg-warning "a2\\\[i]\\\[0]' is used uninitialized" } + T (a2[i][i]); // { dg-warning "a2\\\[i]\\\[i]' is used uninitialized" } +} + + +void vla_3_n (int n, int i) +{ + int a2[3][n]; + + T (a2[0][0]); // { dg-warning "a2\\\[0]\\\[0]' is used uninitialized" } + T (a2[1][2]); // { dg-warning "a2\\\[1]\\\[2]' is used uninitialized" } + T (a2[2][i]); // { dg-warning "a2\\\[2]\\\[i]' is used uninitialized" } + T (a2[i][3]); // { dg-warning "a2\\\[i]\\\[3]' is used uninitialized" } + T (a2[i][i]); // { dg-warning "a2\\\[i]\\\[i]' is used uninitialized" } +} + + +void vla_n_n (int n, int i) +{ + int a2[n][n]; + + T (a2[0][0]); // { dg-warning "a2\\\[0]\\\[0]' is used uninitialized" } + T (a2[4][5]); // { dg-warning "a2\\\[4]\\\[5]' is used uninitialized" } + T (a2[6][i]); // { dg-warning "a2\\\[6]\\\[i]' is used uninitialized" } + T (a2[i][7]); // { dg-warning "a2\\\[i]\\\[7]' is used uninitialized" } + T (a2[i][i]); // { dg-warning "a2\\\[i]\\\[i]' is used uninitialized" } +} + + +void char_ptr_n (int n, int i) +{ + char *p = malloc (n); + + T (p[0]); // { dg-warning "'\\\*p' is used uninitialized" } + T (p[1]); // { dg-warning "'p\\\[1]' is used uninitialized" } + T (p[i]); // { dg-warning "'p\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "is used uninitialized" "POINTER_PLUS_EXPR" { target *-*-* } .-1 } +} + + +void int_ptr_n (int n, int i) +{ + int *p = malloc (n); + + T (p[0]); // { dg-warning "'\\\*p' is used uninitialized" } + T (p[1]); // { dg-warning "'p\\\[1]' is used uninitialized" } + T (p[i]); // { dg-warning "'p\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "is used uninitialized" "POINTER_PLUS_EXPR" { target *-*-* } .-1 } +} + + +void int_arr_ptr_n (int n, int i) +{ + int (*p)[n] = malloc (n); + + T ((*p)[0]); // { dg-warning "\\(\\*p\\)\\\[0]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[0]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[1]); // { dg-warning "\\(\\*p\\)\\\[1]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[1]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[i]); // { dg-warning "\\(\\*p\\)\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[i]' is used uninitialized" "missing parens" { target *-*-* } .-1 } +} + + +void int_arr_ptr_n_n (int n, int i) +{ + int (*p)[n][n] = malloc (n); + + T ((*p)[0][0]); // { dg-warning "\\(\\*p\\)\\\[0]\\\[0]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[0]\\\[0]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[1][2]); // { dg-warning "\\(\\*p\\)\\\[1]\\\[2]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[1]\\\[2]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[0][i]); // { dg-warning "\\(\\*p\\)\\\[0]\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[0]\\\[i]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[3][i]); // { dg-warning "\\(\\*p\\)\\\[3]\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[3]\\\[i]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + T ((*p)[i][i]); // { dg-warning "\\(\\*p\\)\\\[i]\\\[i]' is used uninitialized" "pr98587" { xfail *-*-* } } + // { dg-warning "\\*p\\\[i]\\\[i]' is used uninitialized" "missing parens" { target *-*-* } .-1 } + + T ((*p)[i][i + 1]); // { dg-warning "\\(\\*p\\)\\\[i]\\\[i \\+ 1]' is used uninitialized" "pr98588" { xfail *-*-* } } + // { dg-warning "\\*p\\\[i]\\\[<unknown>]' is used uninitialized" "missing parens" { target *-*-* } .-1 } +} diff --git a/gcc/testsuite/gcc.dg/unused-9.c b/gcc/testsuite/gcc.dg/unused-9.c new file mode 100644 index 0000000..bdf36e1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/unused-9.c @@ -0,0 +1,13 @@ +/* PR c/98260 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + + +void g(void) +{ + int i = 0; + volatile int x; + (x, i++); /* { dg-bogus "set but not used" } */ +} + + diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-32.c b/gcc/testsuite/gcc.dg/vect/bb-slp-32.c index 020b636..84cc437 100644 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-32.c +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-32.c @@ -8,6 +8,7 @@ int foo (int *p, int a, int b) int x[4]; int tem0, tem1, tem2, tem3; int sum = 0; + p = __builtin_assume_aligned (p, __BIGGEST_ALIGNMENT__); tem0 = p[0] + 1 + a; sum += tem0; x[0] = tem0; diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-69.c b/gcc/testsuite/gcc.dg/vect/bb-slp-69.c index ca72a68..16c0d74 100644 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-69.c +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-69.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_condition } */ _Bool arr[16]; diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-9.c b/gcc/testsuite/gcc.dg/vect/bb-slp-9.c index b4cc101..2a42411 100644 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-9.c +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-9.c @@ -46,5 +46,5 @@ int main (void) return 0; } -/* { dg-final { scan-tree-dump-times "optimized: basic block" 1 "slp2" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ +/* { dg-final { scan-tree-dump-times "transform load" 1 "slp2" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-div-1.c b/gcc/testsuite/gcc.dg/vect/bb-slp-div-1.c index 87ffc9b..1eea923 100644 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-div-1.c +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-div-1.c @@ -16,4 +16,7 @@ f (void) x[7] /= 9; } -/* { dg-final { scan-tree-dump "optimized: basic block" "slp2" { xfail *-*-* } } } */ +/* We can vectorize the store from a CTOR built from scalar division + results but ideally we'd like to see vectorizing the load and the + division as well. */ +/* { dg-final { scan-tree-dump "transform load" "slp2" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr68892.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr68892.c deleted file mode 100644 index e9909cf..0000000 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-pr68892.c +++ /dev/null @@ -1,20 +0,0 @@ -/* { dg-do compile } */ -/* { dg-additional-options "-fvect-cost-model=dynamic" } */ -/* { dg-require-effective-target vect_double } */ - -double a[128][128]; -double b[128]; - -void foo(void) -{ - b[0] = a[0][0]; - b[1] = a[1][0]; - b[2] = a[2][0]; - b[3] = a[3][0]; -} - -/* ??? Due to the gaps we fall back to scalar loads which makes the - vectorization profitable. */ -/* { dg-final { scan-tree-dump "not profitable" "slp2" { xfail { ! aarch64*-*-* } } } } */ -/* { dg-final { scan-tree-dump "BB vectorization with gaps at the end of a load is not supported" "slp2" } } */ -/* { dg-final { scan-tree-dump-times "Basic block will be vectorized" 1 "slp2" { xfail aarch64*-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr95866.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr95866.c index edcaf17..14826b5 100644 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-pr95866.c +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr95866.c @@ -13,5 +13,5 @@ void foo() } /* The scalar shift argument should be extracted from the available vector. */ -/* { dg-final { scan-tree-dump "BIT_FIELD_REF" "slp2" } } */ +/* { dg-final { scan-tree-dump "BIT_FIELD_REF" "slp2" { target sse2 } } } */ /* { dg-final { scan-tree-dump "optimized: basic block" "slp2" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr98516-1.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98516-1.c new file mode 100644 index 0000000..c4c244c --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98516-1.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ + +double a[4], b[2]; + +void __attribute__((noipa)) +foo () +{ + double a0 = a[0]; + double a1 = a[1]; + double a2 = a[2]; + double a3 = a[3]; + b[0] = a1 - a3; + b[1] = a0 + a2; +} + +int main() +{ + a[0] = 1.; + a[1] = 2.; + a[2] = 3.; + a[3] = 4.; + foo (); + if (b[0] != -2 || b[1] != 4) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr98516-2.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98516-2.c new file mode 100644 index 0000000..f1a9341 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98516-2.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ + +float a[8], b[4]; + +void __attribute__((noipa)) +foo () +{ + float a0 = a[0]; + float a1 = a[1]; + float a2 = a[2]; + float a3 = a[3]; + float a4 = a[4]; + float a5 = a[5]; + float a6 = a[6]; + float a7 = a[7]; + b[0] = a1 - a5; + b[1] = a0 + a4; + b[2] = a3 - a7; + b[3] = a2 + a6; +} + +int main() +{ + a[0] = 1.; + a[1] = 2.; + a[2] = 3.; + a[3] = 4.; + a[4] = 5.; + a[5] = 6.; + a[6] = 7.; + a[7] = 8.; + foo (); + if (b[0] != -4 || b[1] != 6 || b[2] != -4 || b[3] != 10) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr98544.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98544.c new file mode 100644 index 0000000..756dc02 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98544.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ + +double a[2], b[2], c[2], d[2]; + +void __attribute__((noipa)) +foo() +{ + double a0 = a[0]; + double a1 = a[1]; + double b0 = b[0]; + double b1 = b[1]; + double c0 = c[0]; + double c1 = c[1]; + double tem1 = a1 - b1; + double tem2 = a0 + b0; + d[0] = tem1 * c1; + d[1] = tem2 * c0; +} + +int main() +{ + a[0] = 1.; + a[1] = 2.; + b[0] = 3.; + b[1] = 4.; + c[0] = 2.; + c[1] = 3.; + foo (); + if (d[0] != -6. || d[1] != 8.) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr98685.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98685.c new file mode 100644 index 0000000..b213335 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98685.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +char onelock_lock[16]; +void write(void); + +void lockit(int count) { + for (; count;) { + int pid, i; + char *p; + for (i = 0, p = (char *)&pid; i < sizeof 0; i++) + onelock_lock[i] = *p++; + write(); + } +} diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr98854.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98854.c new file mode 100644 index 0000000..0c8141e --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98854.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +double a[1024]; + +int bar(); +void foo (int n) +{ + double x = 0, y = 0; + int i = 1023; + do + { + x += a[i] + a[i+1]; + y += a[i] / a[i+1]; + if (bar ()) + break; + } + while (--i); + /* We want to avoid vectorizing the LC PHI and insert vector CTORs + inside of the loop where it is only needed here. */ + a[0] = x; + a[1] = y; +} + +/* { dg-final { scan-tree-dump-not "vectorizing SLP node starting from: ._\[0-9\]+ = PHI" "slp1" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-subgroups-3.c b/gcc/testsuite/gcc.dg/vect/bb-slp-subgroups-3.c index e27f956..03c062a 100644 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-subgroups-3.c +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-subgroups-3.c @@ -1,4 +1,5 @@ /* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_int_mult } */ /* PR tree-optimization/67682. */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-byte.c b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-byte.c new file mode 100644 index 0000000..aadee7f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-byte.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_byte } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE int8_t +#define N 16 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { xfail aarch64_sve2 } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { xfail aarch64_sve2 } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-int.c b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-int.c new file mode 100644 index 0000000..8eba24d --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-int.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_int } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE int32_t +#define N 16 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { xfail aarch64_sve2 } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-long.c b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-long.c new file mode 100644 index 0000000..9275ff1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-long.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_long } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE int64_t +#define N 16 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { xfail aarch64_sve2 } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-short.c b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-short.c new file mode 100644 index 0000000..8cbbdb8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-short.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_short } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE int16_t +#define N 16 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { xfail aarch64_sve2 } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-byte.c b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-byte.c new file mode 100644 index 0000000..b753914 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-byte.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_byte } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE uint8_t +#define N 16 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { xfail aarch64_sve2 } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { xfail aarch64_sve2 } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-int.c b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-int.c new file mode 100644 index 0000000..270c49e --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-int.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_int } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE uint32_t +#define N 16 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { xfail aarch64_sve2 } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-long.c b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-long.c new file mode 100644 index 0000000..88144e5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-long.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_long } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE uint64_t +#define N 16 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { xfail aarch64_sve2 } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-short.c b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-short.c new file mode 100644 index 0000000..445af39 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/bb-slp-complex-add-pattern-unsigned-short.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_short } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE uint16_t +#define N 16 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { xfail aarch64_sve2 } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/complex-add-pattern-template.c b/gcc/testsuite/gcc.dg/vect/complex/complex-add-pattern-template.c new file mode 100644 index 0000000..a99a929 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/complex-add-pattern-template.c @@ -0,0 +1,60 @@ +void add90 (TYPE a[restrict N], TYPE b[restrict N], TYPE c[restrict N]) +{ + for (int i=0; i < N; i+=2) + { + c[i] = a[i] - b[i+1]; + c[i+1] = a[i+1] + b[i]; + } +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ + +void add270 (TYPE a[restrict N], TYPE b[restrict N], TYPE c[restrict N]) +{ + for (int i=0; i < N; i+=2) + { + c[i] = a[i] + b[i+1]; + c[i+1] = a[i+1] - b[i]; + } +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ + +void addMixed (TYPE a[restrict N], TYPE b[restrict N], TYPE c[restrict N]) +{ + for (int i=0; i < N; i+=4) + { + c[i] = a[i] - b[i+1]; + c[i+1] = a[i+1] + b[i]; + c[i+2] = a[i+2] + b[i+3]; + c[i+3] = a[i+3] - b[i+2]; + } +} + +void add90HandUnrolled (TYPE a[restrict N], TYPE b[restrict N], + TYPE c[restrict N]) +{ + for (int i=0; i < (N /2); i+=4) + { + c[i] = a[i] - b[i+1]; + c[i+2] = a[i+2] - b[i+3]; + c[i+1] = a[i+1] + b[i]; + c[i+3] = a[i+3] + b[i+2]; + } +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ + +void add90Hybrid (TYPE a[restrict N], TYPE b[restrict N], TYPE c[restrict N], + TYPE d[restrict N]) +{ + for (int i=0; i < N; i+=2) + { + c[i] = a[i] - b[i+1]; + c[i+1] = a[i+1] + b[i]; + d[i] = a[i] - b[i]; + d[i+1] = a[i+1] - b[i+1]; + } +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 2 "vect" } } */
\ No newline at end of file diff --git a/gcc/testsuite/gcc.dg/vect/complex/complex-add-template.c b/gcc/testsuite/gcc.dg/vect/complex/complex-add-template.c new file mode 100644 index 0000000..32c81e6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/complex-add-template.c @@ -0,0 +1,79 @@ +#include <complex.h> + +void add0 (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + b[i]; +} + +void add90snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I); +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ + +void add180snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I * I); +} + +void add270snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I * I * I); +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ + +void add90fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] * I) + b[i]; +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ + +void add180fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] * I * I) + b[i]; +} + +void add270fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] * I * I * I) + b[i]; +} + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ + +void addconjfst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = ~a[i] + b[i]; +} + +void addconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + ~b[i]; +} + +void addconjboth (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = ~a[i] + ~b[i]; +} diff --git a/gcc/testsuite/gcc.dg/vect/complex/complex-mla-template.c b/gcc/testsuite/gcc.dg/vect/complex/complex-mla-template.c new file mode 100644 index 0000000..4b5c42b --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/complex-mla-template.c @@ -0,0 +1,101 @@ +#include <complex.h> + +void fma0 (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i]; +} + +void fma90snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I); +} + +void fma180snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I * I); +} + +void fma270snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I * I * I); +} + +void fma90fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += (a[i] * I) * b[i]; +} + +void fma180fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += (a[i] * I * I) * b[i]; +} + +void fma270fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += (a[i] * I * I * I) * b[i]; +} + +void fmaconjfst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += ~a[i] * b[i]; +} + +void fmaconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * ~b[i]; +} + +void fmaconjboth (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += ~a[i] * ~b[i]; +} + +void fma_elem (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b; +} + + +void fma_elemconjfst (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += ~a[i] * b; +} + +void fma_elemconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * ~b; +} + +void fma_elemconjboth (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += ~a[i] * ~b; +} + diff --git a/gcc/testsuite/gcc.dg/vect/complex/complex-mls-template.c b/gcc/testsuite/gcc.dg/vect/complex/complex-mls-template.c new file mode 100644 index 0000000..1954be8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/complex-mls-template.c @@ -0,0 +1,101 @@ +#include <complex.h> + +void fms0 (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i]; +} + +void fms90snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I); +} + +void fms180snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I * I); +} + +void fms270snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I * I * I); +} + +void fms90fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= (a[i] * I) * b[i]; +} + +void fms180fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= (a[i] * I * I) * b[i]; +} + +void fms270fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= (a[i] * I * I * I) * b[i]; +} + +void fmsconjfst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= ~a[i] * b[i]; +} + +void fmsconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * ~b[i]; +} + +void fmsconjboth (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= ~a[i] * ~b[i]; +} + +void fms_elem (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b; +} + + +void fms_elemconjfst (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= ~a[i] * b; +} + +void fms_elemconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * ~b; +} + +void fms_elemconjboth (_Complex TYPE a[restrict N], _Complex TYPE b, + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= ~a[i] * ~b; +} + diff --git a/gcc/testsuite/gcc.dg/vect/complex/complex-mul-template.c b/gcc/testsuite/gcc.dg/vect/complex/complex-mul-template.c new file mode 100644 index 0000000..770565c --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/complex-mul-template.c @@ -0,0 +1,71 @@ +#include <complex.h> + +void mul0 (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i]; +} + +void mul90snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I); +} + +void mul180snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I * I); +} + +void mul270snd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I * I * I); +} + +void mul90fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] * I) * b[i]; +} + +void mul180fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] * I * I) * b[i]; +} + +void mul270fst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] * I * I * I) * b[i]; +} + +void mulconjfst (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = ~a[i] * b[i]; +} + +void mulconjsnd (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * ~b[i]; +} + +void mulconjboth (_Complex TYPE a[restrict N], _Complex TYPE b[restrict N], + _Complex TYPE c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = ~a[i] * ~b[i]; +} diff --git a/gcc/testsuite/gcc.dg/vect/complex/complex-operations-run.c b/gcc/testsuite/gcc.dg/vect/complex/complex-operations-run.c new file mode 100644 index 0000000..a0348a7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/complex-operations-run.c @@ -0,0 +1,103 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#include <stdio.h> +#include <complex.h> +#include <string.h> +#include <float.h> +#include <math.h> + +#define PREF old +#pragma GCC push_options +#pragma GCC optimize ("no-tree-vectorize") +# include "complex-operations.c" +#pragma GCC pop_options +#undef PREF + +#define PREF new +# include "complex-operations.c" +#undef PREF + +#define TYPE double +#define TYPE2 double +#define EP pow(2, -45) + +#define xstr(s) str(s) +#define str(s) #s + +#define FCMP(A, B) \ + ((fabs (creal (A) - creal (B)) <= EP) && (fabs (cimag (A) - cimag (B)) <= EP)) + +#define CMP(A, B) \ + (FCMP(A,B) ? "PASS" : "FAIL") + +#define COMPARE(A,B) \ + memset (&c1, 0, sizeof (c1)); \ + memset (&c2, 0, sizeof (c2)); \ + A; B; \ + if (!FCMP(c1[0],c2[0]) || !FCMP(c1[1], c2[1])) \ + { \ + printf ("=> %s vs %s\n", xstr (A), xstr (B)); \ + printf ("%a\n", creal (c1[0]) - creal (c2[0])); \ + printf ("%a\n", cimag (c1[1]) - cimag (c2[1])); \ + printf ("%.2f+%.2fI == %.2f+%.2fI (%s)\n", creal (c1[0]), cimag (c1[0]), creal (c2[0]), cimag (c2[0]), CMP (c1[0], c2[0])); \ + printf ("%.2f+%.2fI == %.2f+%.2fI (%s)\n", creal (c1[1]), cimag (c1[1]), creal (c2[1]), cimag (c2[1]), CMP (c1[1], c2[1])); \ + printf ("\n"); \ + __builtin_abort (); \ + } + +int main () +{ + TYPE2 complex a[] = { 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I, 1.0 + 3.0 * I, 2.0 + 3.5 * I }; + TYPE complex b[] = { 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I, 1.1 + 3.1 * I, 2.1 + 3.6 * I }; + TYPE complex c2[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + TYPE complex c1[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + TYPE diff1, diff2; + + COMPARE(fma0_old(a, b, c1), fma0_new(a, b, c2)); + COMPARE(fma90_old(a, b, c1), fma90_new(a, b, c2)); + COMPARE(fma180_old(a, b, c1), fma180_new(a, b, c2)); + COMPARE(fma270_old(a, b, c1), fma270_new(a, b, c2)); + COMPARE(fma0_snd_old(a, b, c1), fma0_snd_new(a, b, c2)); + COMPARE(fma90_snd_old(a, b, c1), fma90_snd_new(a, b, c2)); + COMPARE(fma180_snd_old(a, b, c1), fma180_snd_new(a, b, c2)); + COMPARE(fma270_snd_old(a, b, c1), fma270_snd_new(a, b, c2)); + COMPARE(fma_conj_first_old(a, b, c1), fma_conj_first_new(a, b, c2)); + COMPARE(fma_conj_second_old(a, b, c1), fma_conj_second_new(a, b, c2)); + COMPARE(fma_conj_both_old(a, b, c1), fma_conj_both_new(a, b, c2)); + COMPARE(fms0_old(a, b, c1), fms0_new(a, b, c2)); + COMPARE(fms90_old(a, b, c1), fms90_new(a, b, c2)); + COMPARE(fms180_old(a, b, c1), fms180_new(a, b, c2)); + COMPARE(fms270_old(a, b, c1), fms270_new(a, b, c2)); + COMPARE(fms0_snd_old(a, b, c1), fms0_snd_new(a, b, c2)); + COMPARE(fms90_snd_old(a, b, c1), fms90_snd_new(a, b, c2)); + COMPARE(fms180_snd_old(a, b, c1), fms180_snd_new(a, b, c2)); + COMPARE(fms270_snd_old(a, b, c1), fms270_snd_new(a, b, c2)); + COMPARE(fms_conj_first_old(a, b, c1), fms_conj_first_new(a, b, c2)); + COMPARE(fms_conj_second_old(a, b, c1), fms_conj_second_new(a, b, c2)); + COMPARE(fms_conj_both_old(a, b, c1), fms_conj_both_new(a, b, c2)); + COMPARE(mul0_old(a, b, c1), mul0_new(a, b, c2)); + COMPARE(mul90_old(a, b, c1), mul90_new(a, b, c2)); + COMPARE(mul180_old(a, b, c1), mul180_new(a, b, c2)); + COMPARE(mul270_old(a, b, c1), mul270_new(a, b, c2)); + COMPARE(mul0_snd_old(a, b, c1), mul0_snd_new(a, b, c2)); + COMPARE(mul90_snd_old(a, b, c1), mul90_snd_new(a, b, c2)); + COMPARE(mul180_snd_old(a, b, c1), mul180_snd_new(a, b, c2)); + COMPARE(mul270_snd_old(a, b, c1), mul270_snd_new(a, b, c2)); + COMPARE(mul_conj_first_old(a, b, c1), mul_conj_first_new(a, b, c2)); + COMPARE(mul_conj_second_old(a, b, c1), mul_conj_second_new(a, b, c2)); + COMPARE(mul_conj_both_old(a, b, c1), mul_conj_both_new(a, b, c2)); + COMPARE(add0_old(a, b, c1), add0_new(a, b, c2)); + COMPARE(add90_old(a, b, c1), add90_new(a, b, c2)); + COMPARE(add180_old(a, b, c1), add180_new(a, b, c2)); + COMPARE(add270_old(a, b, c1), add270_new(a, b, c2)); + COMPARE(add0_snd_old(a, b, c1), add0_snd_new(a, b, c2)); + COMPARE(add90_snd_old(a, b, c1), add90_snd_new(a, b, c2)); + COMPARE(add180_snd_old(a, b, c1), add180_snd_new(a, b, c2)); + COMPARE(add270_snd_old(a, b, c1), add270_snd_new(a, b, c2)); + COMPARE(add_conj_first_old(a, b, c1), add_conj_first_new(a, b, c2)); + COMPARE(add_conj_second_old(a, b, c1), add_conj_second_new(a, b, c2)); + COMPARE(add_conj_both_old(a, b, c1), add_conj_both_new(a, b, c2)); +} diff --git a/gcc/testsuite/gcc.dg/vect/complex/complex-operations.c b/gcc/testsuite/gcc.dg/vect/complex/complex-operations.c new file mode 100644 index 0000000..fdce995 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/complex-operations.c @@ -0,0 +1,358 @@ +#include <stdio.h> +#include <complex.h> + +#ifndef PREF +#define PREF c +#endif + +#define FX(N,P) P ## _ ## N +#define MK(N,P) FX(P,N) + +#define N 32 +#define TYPE double + +// ------ FMA + +// Complex FMA instructions rotating the result + +__attribute__((noinline,noipa)) +void MK(fma0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fma90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i] * I; +} + +__attribute__((noinline,noipa)) +void MK(fma180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i] * I * I; +} + +__attribute__((noinline,noipa)) +void MK(fma270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i] * I * I * I; +} + +// Complex FMA instructions rotating the second parameter. + + +__attribute__((noinline,noipa)) +void MK(fma0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fma90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I); +} + +__attribute__((noinline,noipa)) +void MK(fma180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I * I); +} + +__attribute__((noinline,noipa)) +void MK(fma270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * (b[i] * I * I * I); +} + +// Complex FMA instructions with conjucated values. + + +__attribute__((noinline,noipa)) +void MK(fma_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += conj (a[i]) * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fma_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += a[i] * conj (b[i]); +} + +__attribute__((noinline,noipa)) +void MK(fma_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] += conj (a[i]) * conj (b[i]); +} + +// ----- FMS + +// Complex FMS instructions rotating the result + +__attribute__((noinline,noipa)) +void MK(fms0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fms90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i] * I; +} + +__attribute__((noinline,noipa)) +void MK(fms180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i] * I * I; +} + +__attribute__((noinline,noipa)) +void MK(fms270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i] * I * I * I; +} + +// Complex FMS instructions rotating the second parameter. + +__attribute__((noinline,noipa)) +void MK(fms0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fms90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I); +} + +__attribute__((noinline,noipa)) +void MK(fms180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I * I); +} + +__attribute__((noinline,noipa)) +void MK(fms270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * (b[i] * I * I * I); +} + +// Complex FMS instructions with conjucated values. + +__attribute__((noinline,noipa)) +void MK(fms_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= conj (a[i]) * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(fms_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= a[i] * conj (b[i]); +} + +__attribute__((noinline,noipa)) +void MK(fms_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] -= conj (a[i]) * conj (b[i]); +} + + +// ----- MUL + +// Complex MUL instructions rotating the result + +__attribute__((noinline,noipa)) +void MK(mul0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(mul90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i] * I; +} + +__attribute__((noinline,noipa)) +void MK(mul180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i] * I * I; +} + +__attribute__((noinline,noipa)) +void MK(mul270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i] * I * I * I; +} + +// Complex MUL instructions rotating the second parameter. + +__attribute__((noinline,noipa)) +void MK(mul0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(mul90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I); +} + +__attribute__((noinline,noipa)) +void MK(mul180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I * I); +} + +__attribute__((noinline,noipa)) +void MK(mul270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * (b[i] * I * I * I); +} + +// Complex FMS instructions with conjucated values. + +__attribute__((noinline,noipa)) +void MK(mul_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = conj (a[i]) * b[i]; +} + +__attribute__((noinline,noipa)) +void MK(mul_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] * conj (b[i]); +} + +__attribute__((noinline,noipa)) +void MK(mul_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = conj (a[i]) * conj (b[i]); +} + + +// ----- ADD + +// Complex ADD instructions rotating the result + +__attribute__((noinline,noipa)) +void MK(add0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + b[i]; +} + +__attribute__((noinline,noipa)) +void MK(add90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] + b[i]) * I; +} + +__attribute__((noinline,noipa)) +void MK(add180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] + b[i]) * I * I; +} + +__attribute__((noinline,noipa)) +void MK(add270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = (a[i] + b[i]) * I * I * I; +} + +// Complex ADD instructions rotating the second parameter. + +__attribute__((noinline,noipa)) +void MK(add0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + b[i]; +} + +__attribute__((noinline,noipa)) +void MK(add90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I); +} + +__attribute__((noinline,noipa)) +void MK(add180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I * I); +} + +__attribute__((noinline,noipa)) +void MK(add270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + (b[i] * I * I * I); +} + +// Complex ADD instructions with conjucated values. + +__attribute__((noinline,noipa)) +void MK(add_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = conj (a[i]) + b[i]; +} + +__attribute__((noinline,noipa)) +void MK(add_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = a[i] + conj (b[i]); +} + +__attribute__((noinline,noipa)) +void MK(add_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N]) +{ + for (int i=0; i < N; i++) + c[i] = conj (a[i]) + conj (b[i]); +} + + diff --git a/gcc/testsuite/gcc.dg/vect/complex/complex.exp b/gcc/testsuite/gcc.dg/vect/complex/complex.exp new file mode 100644 index 0000000..f94c7a8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/complex.exp @@ -0,0 +1,20 @@ +# Copyright (C) 1997-2021 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/>. + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_file $srcdir/$subdir/../vect.exp diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-double.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-double.c new file mode 100644 index 0000000..7bbb61a --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-double.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE double +#define N 16 +#include "complex-add-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" } } */ + diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-float.c new file mode 100644 index 0000000..cf99f1d --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-float.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE float +#define N 16 +#include "complex-add-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-half-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-half-float.c new file mode 100644 index 0000000..9f535dd --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-half-float.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE _Float16 +#define N 16 +#include "complex-add-template.c" + +/* Vectorization is failing for these cases. They should work but for now ignore. */ + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-double.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-double.c new file mode 100644 index 0000000..e121113 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-double.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE double +#define N 16 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-float.c new file mode 100644 index 0000000..8565833 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-float.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE float +#define N 16 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-half-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-half-float.c new file mode 100644 index 0000000..857ee9d --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-half-float.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE _Float16 +#define N 16 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "slp1" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "slp1" { xfail arm*-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-double.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-double.c new file mode 100644 index 0000000..d9d13c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-double.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE double +#define N 16 +#include "complex-mla-template.c" + diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-float.c new file mode 100644 index 0000000..ac680cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-float.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE float +#define N 16 +#include "complex-mla-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-half-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-half-float.c new file mode 100644 index 0000000..d0a48d0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-half-float.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE _Float16 +#define N 16 +#include "complex-mla-template.c" + diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-double.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-double.c new file mode 100644 index 0000000..d9d13c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-double.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE double +#define N 16 +#include "complex-mla-template.c" + diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-float.c new file mode 100644 index 0000000..ac680cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-float.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE float +#define N 16 +#include "complex-mla-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-half-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-half-float.c new file mode 100644 index 0000000..d0a48d0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-half-float.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE _Float16 +#define N 16 +#include "complex-mla-template.c" + diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-double.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-double.c new file mode 100644 index 0000000..ab8313f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-double.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE double +#define N 16 +#include "complex-mul-template.c" + diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-float.c new file mode 100644 index 0000000..49bf961 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-float.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE float +#define N 16 +#include "complex-mul-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-half-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-half-float.c new file mode 100644 index 0000000..f5c23fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-half-float.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE _Float16 +#define N 16 +#include "complex-mul-template.c" + diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-double.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-double.c new file mode 100644 index 0000000..0d4d3ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-double.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE double +#define N 200 +#include "complex-add-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 2 "vect" } } */
\ No newline at end of file diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-float.c new file mode 100644 index 0000000..b986696 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-float.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE float +#define N 200 +#include "complex-add-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 2 "vect" } } */
\ No newline at end of file diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-half-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-half-float.c new file mode 100644 index 0000000..c3dca57 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-half-float.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE _Float16 +#define N 200 +#include "complex-add-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 2 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 2 "vect" } } */
\ No newline at end of file diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-pattern-double.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-pattern-double.c new file mode 100644 index 0000000..df4d3f6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-pattern-double.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE double +#define N 200 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 4 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-pattern-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-pattern-float.c new file mode 100644 index 0000000..6df5c6d --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-pattern-float.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE float +#define N 200 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 4 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-pattern-half-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-pattern-half-float.c new file mode 100644 index 0000000..a725112 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-pattern-half-float.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE _Float16 +#define N 200 +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 4 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ + diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-double.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-double.c new file mode 100644 index 0000000..c85ff07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-double.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE double +#define N 200 +#include "complex-mla-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-float.c new file mode 100644 index 0000000..a17b91b --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-float.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE float +#define N 200 +#include "complex-mla-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-half-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-half-float.c new file mode 100644 index 0000000..fa81985 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-half-float.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE _Float16 +#define N 200 +#include "complex-mla-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-double.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-double.c new file mode 100644 index 0000000..c85ff07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-double.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE double +#define N 200 +#include "complex-mla-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-float.c new file mode 100644 index 0000000..a17b91b --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-float.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE float +#define N 200 +#include "complex-mla-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-half-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-half-float.c new file mode 100644 index 0000000..fa81985 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-half-float.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE _Float16 +#define N 200 +#include "complex-mla-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-double.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-double.c new file mode 100644 index 0000000..77c01a8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-double.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_double } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE double +#define N 200 +#include "complex-mul-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-float.c new file mode 100644 index 0000000..a8b44f2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-float.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_float } */ +/* { dg-add-options arm_v8_3a_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE float +#define N 200 +#include "complex-mul-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-half-float.c b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-half-float.c new file mode 100644 index 0000000..d57df82 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-half-float.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_half } */ +/* { dg-add-options arm_v8_3a_fp16_complex_neon } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE _Float16 +#define N 200 +#include "complex-mul-template.c" diff --git a/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-byte.c b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-byte.c new file mode 100644 index 0000000..438d219 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-byte.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_byte } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE int8_t +#define N 200 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-int.c b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-int.c new file mode 100644 index 0000000..04c27dc --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-int.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_int } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE int32_t +#define N 200 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-long.c b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-long.c new file mode 100644 index 0000000..27988ad --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-long.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_long } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE int64_t +#define N 200 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-short.c b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-short.c new file mode 100644 index 0000000..88d225d --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-short.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_short } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE int16_t +#define N 200 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-byte.c b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-byte.c new file mode 100644 index 0000000..59109c0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-byte.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_byte } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE uint8_t +#define N 200 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-int.c b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-int.c new file mode 100644 index 0000000..44d9635 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-int.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_int } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE uint32_t +#define N 200 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-long.c b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-long.c new file mode 100644 index 0000000..6671457 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-long.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_long } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE uint64_t +#define N 200 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-short.c b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-short.c new file mode 100644 index 0000000..841adf8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-add-pattern-unsigned-short.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_complex_add_short } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +#define TYPE uint16_t +#define N 200 +#include <stdint.h> +#include "complex-add-pattern-template.c" + +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT90" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "stmt.*COMPLEX_ADD_ROT270" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/i386/i386-costmodel-vect.exp b/gcc/testsuite/gcc.dg/vect/costmodel/i386/i386-costmodel-vect.exp index 08b1abc..a4d67b1 100644 --- a/gcc/testsuite/gcc.dg/vect/costmodel/i386/i386-costmodel-vect.exp +++ b/gcc/testsuite/gcc.dg/vect/costmodel/i386/i386-costmodel-vect.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/ppc/ppc-costmodel-vect.exp b/gcc/testsuite/gcc.dg/vect/costmodel/ppc/ppc-costmodel-vect.exp index 7e49af1..040b0de 100644 --- a/gcc/testsuite/gcc.dg/vect/costmodel/ppc/ppc-costmodel-vect.exp +++ b/gcc/testsuite/gcc.dg/vect/costmodel/ppc/ppc-costmodel-vect.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp index 7d89241..167c5dc 100644 --- a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp +++ b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/x86_64-costmodel-vect.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/vect/pr91403.c b/gcc/testsuite/gcc.dg/vect/pr91403.c new file mode 100644 index 0000000..5b9b760 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr91403.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + +extern int a[][1000000]; +int b; +void c() +{ + for (int d = 2; d <= 9; d++) + for (int e = 32; e <= 41; e++) + b += a[d][5]; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr92205.c b/gcc/testsuite/gcc.dg/vect/pr92205.c index a031c1f..ea06660 100644 --- a/gcc/testsuite/gcc.dg/vect/pr92205.c +++ b/gcc/testsuite/gcc.dg/vect/pr92205.c @@ -10,4 +10,4 @@ int b(int n, unsigned char *a) return d; } -/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { vect_unpack && { ! vect_no_bitwise } } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr94994.c b/gcc/testsuite/gcc.dg/vect/pr94994.c new file mode 100644 index 0000000..e98aeb0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr94994.c @@ -0,0 +1,61 @@ +#include <stdint.h> +#include "tree-vect.h" + +#define BLOCK_SIZE (sizeof (uint32_t)) + +struct unaligned { + uint32_t x; +} __attribute__((packed, may_alias)); + +static inline uint32_t +load_unaligned (const char *p) +{ + return ((struct unaligned *) p)->x; +} + +static inline void +store_unaligned (uint32_t x, char *p) +{ + ((struct unaligned *) p)->x = x; +} + +void __attribute__((noipa)) +copy (char *dst, const char *src, size_t n) +{ + for (size_t i = 0; i < n; i += BLOCK_SIZE) + store_unaligned (load_unaligned (src + i), dst + i); +} + +#define INPUT_SIZE 64 +#define MAX_STEP 32 + +char x[INPUT_SIZE + MAX_STEP]; + +int +main (void) +{ + check_vect (); + + for (unsigned int i = 1; i < MAX_STEP; ++i) + { + for (unsigned int j = 0; j < INPUT_SIZE + MAX_STEP; ++j) + x[j] = j + 10; + copy (x + i, x, INPUT_SIZE); + for (int j = 0; j < INPUT_SIZE + i; ++j) + { + int expected; + if (j < i) + expected = j + 10; + else if (i >= BLOCK_SIZE) + expected = j % i + 10; + else if ((j - i) % BLOCK_SIZE < i) + expected = x[j - i]; + else + expected = j - i + 10; + if (x[j] != expected) + __builtin_abort (); + } + } + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr97678.c b/gcc/testsuite/gcc.dg/vect/pr97678.c index d9ffb7a..7fb6c93 100644 --- a/gcc/testsuite/gcc.dg/vect/pr97678.c +++ b/gcc/testsuite/gcc.dg/vect/pr97678.c @@ -1,4 +1,6 @@ /* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_int_mult } */ +/* { dg-require-effective-target vect_pack_trunc } */ /* { dg-additional-options "-mavx2" { target avx2_runtime } } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/pr97929.c b/gcc/testsuite/gcc.dg/vect/pr97929.c new file mode 100644 index 0000000..a027b31 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr97929.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +#include <stdint.h> +#define ARR_SIZE 1024 +extern void foo (int32_t *bar, int16_t a) +{ + for( int i = 0; i < ARR_SIZE;i++) + { + bar[i] = a + 1; + } +} diff --git a/gcc/testsuite/gcc.dg/vect/pr98069.c b/gcc/testsuite/gcc.dg/vect/pr98069.c new file mode 100644 index 0000000..e60549f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr98069.c @@ -0,0 +1,22 @@ +long long int var_3 = -166416893043554447LL; +short var_8 = (short)27092; +unsigned int var_17 = 75036300U; +short arr_165[23]; + +static long c(long e, long f) { return f ? e : f; } +void __attribute((noipa)) test() +{ + for (int b = 0; b < 19; b = var_17) + for (int d = (int)(~c(-2147483647 - 1, var_3)) - 2147483647; d < 22; d++) + arr_165[d] = var_8; +} + +int main() +{ + for (unsigned i_3 = 0; i_3 < 23; ++i_3) + arr_165[i_3] = (short)-8885; + test(); + if (arr_165[0] != 27092) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr98302.c b/gcc/testsuite/gcc.dg/vect/pr98302.c new file mode 100644 index 0000000..dec6016 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr98302.c @@ -0,0 +1,22 @@ +#include "tree-vect.h" + +int c = 1705; +char a; +long f = 50887638; +unsigned long long *h(unsigned long long *k, unsigned long long *l) { + return *k ? k : l; +} +void aa() {} +int main() { + check_vect (); + + long d = f; + for (char g = 0; g < (char)c - 10; g += 2) { + unsigned long long i = d, j = 4; + a = *h(&i, &j) << ((d ? 169392992 : 0) - 169392955LL); + } + if (a) + __builtin_abort(); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr98308.c b/gcc/testsuite/gcc.dg/vect/pr98308.c new file mode 100644 index 0000000..7d717b1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr98308.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-march=skylake-avx512" { target avx512f } } */ + +extern unsigned long long int arr_86[]; +extern unsigned long long int arr_87[][15]; + +void test(_Bool a, unsigned short c[][15], unsigned char d[]) +{ + for (short h = 0; h < 10; h++) + for (char i = 0; i < 15; i += 2) + { + arr_86[0] = d[0]; + arr_87[h][0] = a ? c[h][i] : 0; + } +} diff --git a/gcc/testsuite/gcc.dg/vect/pr98560-1.c b/gcc/testsuite/gcc.dg/vect/pr98560-1.c new file mode 100644 index 0000000..2583fc4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr98560-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -fno-tree-vrp -fno-tree-fre -fno-tree-pre -fno-code-hoisting -fvect-cost-model=dynamic" } */ +/* { dg-additional-options "-msve-vector-bits=128" { target aarch64_sve } } */ + +#include <stdint.h> + +void +f (uint16_t *restrict dst, uint32_t *restrict src1, float *restrict src2) +{ + int i = 0; + for (int j = 0; j < 4; ++j) + { + uint16_t tmp = src1[i] >> 1; + dst[i] = (uint16_t) (src2[i] < 0 && i < 4 ? tmp : 1); + i += 1; + } +} diff --git a/gcc/testsuite/gcc.dg/vect/pr98560-2.c b/gcc/testsuite/gcc.dg/vect/pr98560-2.c new file mode 100644 index 0000000..7759a5e --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr98560-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3 -fno-tree-vrp -fno-tree-fre -fno-tree-pre -fno-code-hoisting -fvect-cost-model=dynamic" } */ +/* { dg-additional-options "-msve-vector-bits=128" { target aarch64_sve } } */ + +#include <stdint.h> + +void +f (uint16_t *restrict dst, uint32_t *restrict src1, float *restrict src2) +{ + int i = 0; + for (int j = 0; j < 4; ++j) + { + uint16_t tmp = src1[i] >> 1; + dst[i] = (uint16_t) (src2[i] == 0 && i < 4 ? tmp : 1); + i += 1; + } +} diff --git a/gcc/testsuite/gcc.dg/vect/pr98674.c b/gcc/testsuite/gcc.dg/vect/pr98674.c new file mode 100644 index 0000000..0f1b6cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr98674.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-msse2" { target sse2 } } */ + +void swap(short *p, int cnt) +{ + while (cnt-- > 0) + { + *p = ((*p << 8) & 0xFF00) | ((*p >> 8) & 0x00FF); + ++p; + } +} + +/* Dependence analysis should not fail. */ +/* { dg-final { scan-tree-dump "dependence distance == 0" "vect" } } */ +/* On x86 with SSE2 we can vectorize this with psllw/psrlw. */ +/* { dg-final { scan-tree-dump "loop vectorized" "vect" { target sse2 } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr98848.c b/gcc/testsuite/gcc.dg/vect/pr98848.c new file mode 100644 index 0000000..5cf7c9f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr98848.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/98848 */ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +short a[9000]; + +int +foo (void) +{ + int b = a[0]; + int i; + for (i = 1; i < 9000; i ++) + if (a[i] < b) + b = a[i]; + return b; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { xfail { vect_no_int_add || vect_no_int_min_max } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-11b.c b/gcc/testsuite/gcc.dg/vect/slp-11b.c index 0aece80..c4d9ab0 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-11b.c +++ b/gcc/testsuite/gcc.dg/vect/slp-11b.c @@ -12,13 +12,13 @@ main1 () unsigned int out[N*8], a0, a1, a2, a3, a4, a5, a6, a7, b1, b0, b2, b3, b4, b5, b6, b7; unsigned int in[N*8] = {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,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; - /* Requires permutation - not SLPable. */ + /* Requires permutation for SLP. */ for (i = 0; i < N*2; i++) { out[i*4] = (in[i*4] + 2) * 3; out[i*4 + 1] = (in[i*4 + 2] + 2) * 7; out[i*4 + 2] = (in[i*4 + 1] + 7) * 3; - out[i*4 + 3] = (in[i*4 + 3] + 3) * 4; + out[i*4 + 3] = (in[i*4 + 3] + 3) * 7; } /* check results: */ @@ -27,7 +27,7 @@ main1 () if (out[i*4] != (in[i*4] + 2) * 3 || out[i*4 + 1] != (in[i*4 + 2] + 2) * 7 || out[i*4 + 2] != (in[i*4 + 1] + 7) * 3 - || out[i*4 + 3] != (in[i*4 + 3] + 3) * 4) + || out[i*4 + 3] != (in[i*4 + 3] + 3) * 7) abort (); } @@ -43,7 +43,5 @@ int main (void) return 0; } -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_strided4 && vect_int_mult } } } } */ -/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { ! { vect_strided4 && vect_int_mult } } } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { ! vect_load_lanes } } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_load_lanes } } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { { vect_strided4 || vect_perm } && vect_int_mult } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm && vect_int_mult } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-43.c b/gcc/testsuite/gcc.dg/vect/slp-43.c index 0344cc9..3cee613 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-43.c +++ b/gcc/testsuite/gcc.dg/vect/slp-43.c @@ -78,4 +78,6 @@ int main() } /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 13 "vect" { target vect_hw_misalign } } } */ -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target { ! vect_hw_misalign } } } } */ +/* For ! vect_hw_misalign it depends on vector size and actual alignment + requirements of the target which functions can be vectorized. Avoid + that bean-counting and per-target listing here. */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-45.c b/gcc/testsuite/gcc.dg/vect/slp-45.c index 1e35d35..fadc4e5 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-45.c +++ b/gcc/testsuite/gcc.dg/vect/slp-45.c @@ -77,4 +77,4 @@ int main() return 0; } -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 13 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 13 "vect" { target vect_hw_misalign } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-reduc-11.c b/gcc/testsuite/gcc.dg/vect/slp-reduc-11.c new file mode 100644 index 0000000..a2f86fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/slp-reduc-11.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double dotprod(const double *a, const double *b, unsigned long long n) +{ + double d1 = 0.0; + double d2 = 0.0; + + for (unsigned long long i = 0; i < n; i += 2) { + d1 += a[i] * b[i]; + d2 += a[i + 1] * b[i + 1]; + } + + return (d1 + d2); +} + +/* We should use a SLP reduction even without -ffast-math by using a + VF of one. */ +/* { dg-final { scan-tree-dump "vectorizing stmts using SLP" "vect" } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-reduc-3.c b/gcc/testsuite/gcc.dg/vect/slp-reduc-3.c index 4969fe8..9e29757 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-reduc-3.c +++ b/gcc/testsuite/gcc.dg/vect/slp-reduc-3.c @@ -46,6 +46,7 @@ int main (void) for (i=0; i<N; i++) { X[i] = i; Y[i] = 64-i; + asm volatile ("" ::: "memory"); } foo1 (N/2, &dot1, &dot2); @@ -58,6 +59,7 @@ int main (void) /* The initialization loop in main also gets vectorized. */ /* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" { xfail *-*-* } } } */ -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target { vect_short_mult && { vect_widen_sum_hi_to_si && vect_unpack } } } } } */ -/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail { vect_widen_sum_hi_to_si_pattern || { ! vect_unpack } } } } } */ -/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_short_mult && { vect_widen_sum_hi_to_si && vect_unpack } } } } } */ +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail { vect_widen_sum_hi_to_si_pattern || { ! { vect_short_mult && { vect_widen_sum_hi_to_si && vect_unpack } } } } } } } */ +/* Check we can elide permutes if SLP vectorizing the reduction. */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" { xfail { { { vect_widen_sum_hi_to_si_pattern || { ! vect_unpack } } && { ! vect_load_lanes } } && { vect_short_mult && { vect_widen_sum_hi_to_si && vect_unpack } } } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-live-6.c b/gcc/testsuite/gcc.dg/vect/vect-live-6.c index c986c97..0e7aa22 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-live-6.c +++ b/gcc/testsuite/gcc.dg/vect/vect-live-6.c @@ -28,4 +28,4 @@ int main() return 0; } -/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target vect_int } } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { vect_int && vect_condition } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-in-order-4.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-in-order-4.c index 7706a2d..eff3994 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-reduc-in-order-4.c +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-in-order-4.c @@ -41,6 +41,4 @@ main () return 0; } -/* { dg-final { scan-tree-dump {in-order unchained SLP reductions not supported} "vect" } } */ -/* { dg-final { scan-tree-dump-not {vectorizing stmts using SLP} "vect" } } */ /* { dg-final { scan-tree-dump-times "VECT_PERM_EXPR" 0 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect.exp b/gcc/testsuite/gcc.dg/vect/vect.exp index efe17ac..dca9a4d 100644 --- a/gcc/testsuite/gcc.dg/vect/vect.exp +++ b/gcc/testsuite/gcc.dg/vect/vect.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/vmx/vmx.exp b/gcc/testsuite/gcc.dg/vmx/vmx.exp index dc2b2a6..9d1da87 100644 --- a/gcc/testsuite/gcc.dg/vmx/vmx.exp +++ b/gcc/testsuite/gcc.dg/vmx/vmx.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2020 Free Software Foundation, Inc. +# Copyright (C) 2004-2021 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 diff --git a/gcc/testsuite/gcc.dg/vxworks/initpri1.c b/gcc/testsuite/gcc.dg/vxworks/initpri1.c index 555bffe..1d26b0e 100644 --- a/gcc/testsuite/gcc.dg/vxworks/initpri1.c +++ b/gcc/testsuite/gcc.dg/vxworks/initpri1.c @@ -6,6 +6,7 @@ /* The selector below excludes VxWorks AE because AE does not support RTP mode. */ /* { dg-do compile { target { *-*-vxworks* && { ! *-*-vxworksae* } } } } */ +/* { dg-skip-if "vxworks7 SR06x0 now uses .init_array" { *-*-vxworks7r* } } */ /* { dg-options "-mrtp" } */ /* { dg-final { scan-assembler "ctors\.00000" } } */ /* { dg-final { scan-assembler "dtors\.00000" } } */ diff --git a/gcc/testsuite/gcc.dg/vxworks/initpri2.c b/gcc/testsuite/gcc.dg/vxworks/initpri2.c index 7f483ef..31b4e9b 100644 --- a/gcc/testsuite/gcc.dg/vxworks/initpri2.c +++ b/gcc/testsuite/gcc.dg/vxworks/initpri2.c @@ -2,6 +2,7 @@ Instead, initialization is handled by munch. */ /* { dg-do compile { target vxworks_kernel } } */ +/* { dg-skip-if "vxworks7 SR06x0 now uses .init_array" { *-*-vxworks7r* } } */ /* { dg-final { scan-assembler-not "\.ctors" } } */ /* { dg-final { scan-assembler-not "\.dtors" } } */ diff --git a/gcc/testsuite/gcc.dg/vxworks/vxworks.exp b/gcc/testsuite/gcc.dg/vxworks/vxworks.exp index d8d91c0..8f8d822 100644 --- a/gcc/testsuite/gcc.dg/vxworks/vxworks.exp +++ b/gcc/testsuite/gcc.dg/vxworks/vxworks.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 diff --git a/gcc/testsuite/gcc.dg/weak/weak.exp b/gcc/testsuite/gcc.dg/weak/weak.exp index be87d5d..c4359e9 100644 --- a/gcc/testsuite/gcc.dg/weak/weak.exp +++ b/gcc/testsuite/gcc.dg/weak/weak.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 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 |