diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg')
216 files changed, 8635 insertions, 217 deletions
diff --git a/gcc/testsuite/gcc.dg/20020416-1.c b/gcc/testsuite/gcc.dg/20020416-1.c index db1a2617fcd..44916ef1b83 100644 --- a/gcc/testsuite/gcc.dg/20020416-1.c +++ b/gcc/testsuite/gcc.dg/20020416-1.c @@ -1,6 +1,7 @@ /* PR bootstrap/6315 */ /* { dg-do compile } */ -/* { dg-options "-O2" } */ +/* APPLE LOCAL -Wlong-double */ +/* { dg-options "-O2 -Wno-long-double" } */ /* { dg-options "-O2 -mhard-quad-float" { target sparc*-*-* } } */ /* { dg-options "-O2" { target sparclet*-*-* sparclite*-*-* sparc86x-*-* } } */ diff --git a/gcc/testsuite/gcc.dg/20040322-1.c b/gcc/testsuite/gcc.dg/20040322-1.c new file mode 100644 index 00000000000..af5e0b4820c --- /dev/null +++ b/gcc/testsuite/gcc.dg/20040322-1.c @@ -0,0 +1,4 @@ +/* PR c/14069 */ +/* { dg-do compile } */ +struct S { int a; char b[]; char *c; }; /* { dg-error "error" "flexible array member not" } */ +struct S s = { .b = "foo", .c = .b }; /* { dg-error "error" "parse error before" } */ diff --git a/gcc/testsuite/gcc.dg/20040331-1.c b/gcc/testsuite/gcc.dg/20040331-1.c new file mode 100644 index 00000000000..4cef3d3297a --- /dev/null +++ b/gcc/testsuite/gcc.dg/20040331-1.c @@ -0,0 +1,14 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fwrapv" } */ + +extern void abort (void); +extern void exit (int); + +int +main (void) +{ + struct { int count: 2; } s = { -2 }; + while (s.count-- != -2) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/20040409-1.c b/gcc/testsuite/gcc.dg/20040409-1.c new file mode 100644 index 00000000000..dc9206a0ae0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20040409-1.c @@ -0,0 +1,4 @@ +/* This tests to make sure that the attribute noreturn + can be used on function pointers. */ + +int (*temp) (void) __attribute__((noreturn)); diff --git a/gcc/testsuite/gcc.dg/Wshadow-2.c b/gcc/testsuite/gcc.dg/Wshadow-2.c new file mode 100644 index 00000000000..b0c051271ee --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wshadow-2.c @@ -0,0 +1,10 @@ +/* Bogus warning for a double declaration of the same extern variable, + first at file scope, then at block scope. PR 13129. */ + +/* { dg-options "-Wshadow" } */ + +extern struct foo bar; +void dummy() +{ + extern struct foo bar; /* { dg-bogus "shadows" } */ +} diff --git a/gcc/testsuite/gcc.dg/altivec-2.c b/gcc/testsuite/gcc.dg/altivec-2.c index f64081ff813..914910c3476 100644 --- a/gcc/testsuite/gcc.dg/altivec-2.c +++ b/gcc/testsuite/gcc.dg/altivec-2.c @@ -4,13 +4,12 @@ /* Program to test the vector_size attribute. This needs to run on a target that has vectors, so use AltiVec. */ -#define vector __attribute__((vector_size(16))) - vector int foobar; /* Only floats and integrals allowed. We don't care if they map to SIs. */ struct X { int frances; }; -vector struct X hotdog; /* { dg-error "invalid vector type" } */ +/* APPLE LOCAL AltiVec */ +vector struct X hotdog; /* { dg-error "(syntax error|invalid vector type)" } */ /* Arrays of vectors. */ vector char b[10], ouch; diff --git a/gcc/testsuite/gcc.dg/altivec-4.c b/gcc/testsuite/gcc.dg/altivec-4.c index 175663581ac..f5a46493152 100644 --- a/gcc/testsuite/gcc.dg/altivec-4.c +++ b/gcc/testsuite/gcc.dg/altivec-4.c @@ -1,8 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ /* { dg-options "-maltivec -O0 -Wall" } */ -#define vector __attribute__((vector_size(16))) - static int __attribute__((mode(V4SI))) x, y; static vector signed int i,j; diff --git a/gcc/testsuite/gcc.dg/altivec-5.c b/gcc/testsuite/gcc.dg/altivec-5.c index 0adfdb84d19..37c9a9fa79b 100644 --- a/gcc/testsuite/gcc.dg/altivec-5.c +++ b/gcc/testsuite/gcc.dg/altivec-5.c @@ -1,8 +1,6 @@ /* { dg-do compile { target powerpc*-*-* } } */ /* { dg-options "-maltivec -O2" } */ -#define vector __attribute__((vector_size(16))) - void foo (const unsigned long x, vector signed int a, vector signed int b) { diff --git a/gcc/testsuite/gcc.dg/altivec-varargs-1.c b/gcc/testsuite/gcc.dg/altivec-varargs-1.c index 14e5e6ee976..72e6c4ad9ba 100644 --- a/gcc/testsuite/gcc.dg/altivec-varargs-1.c +++ b/gcc/testsuite/gcc.dg/altivec-varargs-1.c @@ -6,7 +6,11 @@ #include "altivec_check.h" +/* APPLE LOCAL begin AltiVec */ +#ifndef vector #define vector __attribute__((mode(V4SI))) +#endif +/* APPLE LOCAL end AltiVec */ const vector unsigned int v1 = {10,11,12,13}; const vector unsigned int v2 = {20,21,22,23}; diff --git a/gcc/testsuite/gcc.dg/builtin-inf-1.c b/gcc/testsuite/gcc.dg/builtin-inf-1.c index d2d28415899..0e97114cfca 100644 --- a/gcc/testsuite/gcc.dg/builtin-inf-1.c +++ b/gcc/testsuite/gcc.dg/builtin-inf-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ - +/* { dg-options "-Wno-long-double" { target *-apple-darwin* } } */ float fi = __builtin_inff(); double di = __builtin_inf(); long double li = __builtin_infl(); diff --git a/gcc/testsuite/gcc.dg/builtins-35.c b/gcc/testsuite/gcc.dg/builtins-35.c new file mode 100644 index 00000000000..f898707e24a --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtins-35.c @@ -0,0 +1,6 @@ +/* Test that nan functions are not built-in in C90 mode. Bug 14635. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=c89" } */ + +int nan, nanf, nanl, nans, nansf, nansl; diff --git a/gcc/testsuite/gcc.dg/builtins-36.c b/gcc/testsuite/gcc.dg/builtins-36.c new file mode 100644 index 00000000000..dc711988448 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtins-36.c @@ -0,0 +1,79 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check sin, sinf, sinl, cos, cosf and cosl built-in functions + eventually compile to sincos, sincosf and sincosl. + + Written by Uros Bizjak, 5th April 2004. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double sin(double); +extern float sinf(float); +extern long double sinl(long double); + +extern double cos(double); +extern float cosf(float); +extern long double cosl(long double); + + +double test1(double x) +{ + double y1, y2; + + y1 = sin(x); + y2 = cos(x); + + return y1 - y2; +} + +float test1f(float x) +{ + float y1, y2; + + y1 = sinf(x); + y2 = cosf(x); + + return y1 - y2; +} + +long double test1l(long double x) +{ + long double y1, y2; + + y1 = sinl(x); + y2 = cosl(x); + + return y1 - y2; +} + +double test2(double x) +{ + return sin(x); +} + +float test2f(float x) +{ + return sinf(x); +} + +long double test2l(long double x) +{ + return sinl(x); +} + +double test3(double x) +{ + return cos(x); +} + +float test3f(float x) +{ + return cosf(x); +} + +long double test3l(long double x) +{ + return cosl(x); +} + diff --git a/gcc/testsuite/gcc.dg/builtins-37.c b/gcc/testsuite/gcc.dg/builtins-37.c new file mode 100644 index 00000000000..e366a6ac552 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtins-37.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Check tan, tanf and tanl built-in functions. + + Written by Uros Bizjak, 7th April 2004. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +extern double tan(double); +extern float tanf(float); +extern long double tanl(long double); + + +double test1(double x) +{ + return tan(x); +} + +float test1f(float x) +{ + return tanf(x); +} + +long double test1l(long double x) +{ + return tanl(x); +} + diff --git a/gcc/testsuite/gcc.dg/c90-intprom-1.c b/gcc/testsuite/gcc.dg/c90-intprom-1.c new file mode 100644 index 00000000000..78e4b39ef35 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c90-intprom-1.c @@ -0,0 +1,47 @@ +/* Test for integer promotion rules: C90 subset of types. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +#include <limits.h> + +#define CHECK(T1, T2, TC) \ + do { \ + T1 a = 0; \ + T2 b = 0; \ + TC *c = 0; \ + __typeof__(a+b) *d = 0; \ + c = d; \ + d = c; \ + } while (0) + +void +f (void) +{ + /* One type is unsigned long. */ + CHECK(unsigned long, unsigned long, unsigned long); + CHECK(unsigned int, unsigned long, unsigned long); + CHECK(unsigned long, unsigned int, unsigned long); + CHECK(int, unsigned long, unsigned long); + CHECK(long, unsigned long, unsigned long); + CHECK(unsigned long, int, unsigned long); + CHECK(unsigned long, long, unsigned long); + /* long and unsigned int. */ +#if LONG_MAX >= UINT_MAX + CHECK(unsigned int, long, long); + CHECK(long, unsigned int, long); +#else + CHECK(unsigned int, long, unsigned long); + CHECK(long, unsigned int, unsigned long); +#endif + /* One type is long. */ + CHECK(long, long, long); + CHECK(int, long, long); + CHECK(long, int, long); + /* One type is unsigned int. */ + CHECK(unsigned int, unsigned int, unsigned int); + CHECK(int, unsigned int, unsigned int); + CHECK(unsigned int, int, unsigned int); + /* Otherwise int. */ + CHECK(int, int, int); +} diff --git a/gcc/testsuite/gcc.dg/c99-complex-1.c b/gcc/testsuite/gcc.dg/c99-complex-1.c index 2e1ba7df539..494cdd6a266 100644 --- a/gcc/testsuite/gcc.dg/c99-complex-1.c +++ b/gcc/testsuite/gcc.dg/c99-complex-1.c @@ -1,8 +1,8 @@ /* Test for _Complex: in C99 only. A few basic tests. */ /* Origin: Joseph Myers <jsm28@cam.ac.uk> */ /* { dg-do compile } */ -/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ - +/* APPLE LOCAL -Wlong-double */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -Wno-long-double" } */ /* Test _Complex allowed on floating types. */ float _Complex a; diff --git a/gcc/testsuite/gcc.dg/c99-intprom-1.c b/gcc/testsuite/gcc.dg/c99-intprom-1.c new file mode 100644 index 00000000000..0d7a33ee8be --- /dev/null +++ b/gcc/testsuite/gcc.dg/c99-intprom-1.c @@ -0,0 +1,77 @@ +/* Test for integer promotion rules: extended to long long by C99. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +#include <limits.h> + +#define CHECK(T1, T2, TC) \ + do { \ + T1 a = 0; \ + T2 b = 0; \ + TC *c = 0; \ + __typeof__(a+b) *d = 0; \ + c = d; \ + d = c; \ + } while (0) + +void +f (void) +{ + /* Same type. */ + CHECK(int, int, int); + CHECK(unsigned int, unsigned int, unsigned int); + CHECK(long, long, long); + CHECK(unsigned long, unsigned long, unsigned long); + CHECK(long long, long long, long long); + CHECK(unsigned long long, unsigned long long, unsigned long long); + /* Both signed. */ + CHECK(int, long, long); + CHECK(int, long long, long long); + CHECK(long, int, long); + CHECK(long, long long, long long); + CHECK(long long, int, long long); + CHECK(long long, long, long long); + /* Both unsigned. */ + CHECK(unsigned int, unsigned long, unsigned long); + CHECK(unsigned int, unsigned long long, unsigned long long); + CHECK(unsigned long, unsigned int, unsigned long); + CHECK(unsigned long, unsigned long long, unsigned long long); + CHECK(unsigned long long, unsigned int, unsigned long long); + CHECK(unsigned long long, unsigned long, unsigned long long); + /* Unsigned of greater or equal rank. */ + CHECK(int, unsigned int, unsigned int); + CHECK(int, unsigned long, unsigned long); + CHECK(int, unsigned long long, unsigned long long); + CHECK(unsigned int, int, unsigned int); + CHECK(long, unsigned long, unsigned long); + CHECK(long, unsigned long long, unsigned long long); + CHECK(unsigned long, int, unsigned long); + CHECK(unsigned long, long, unsigned long); + CHECK(long long, unsigned long long, unsigned long long); + CHECK(unsigned long long, int, unsigned long long); + CHECK(unsigned long long, long, unsigned long long); + CHECK(unsigned long long, long long, unsigned long long); + /* Signed of greater rank. */ +#if LONG_MAX >= UINT_MAX + CHECK(unsigned int, long, long); + CHECK(long, unsigned int, long); +#else + CHECK(unsigned int, long, unsigned long); + CHECK(long, unsigned int, unsigned long); +#endif +#if LLONG_MAX >= UINT_MAX + CHECK(unsigned int, long long, long long); + CHECK(long long, unsigned int, long long); +#else + CHECK(unsigned int, long long, unsigned long long); + CHECK(long long, unsigned int, unsigned long long); +#endif +#if LLONG_MAX >= ULONG_MAX + CHECK(unsigned long, long long, long long); + CHECK(long long, unsigned long, long long); +#else + CHECK(unsigned long, long long, unsigned long long); + CHECK(long long, unsigned long, unsigned long long); +#endif +} diff --git a/gcc/testsuite/gcc.dg/cast-ptr-1.c b/gcc/testsuite/gcc.dg/cast-ptr-1.c new file mode 100644 index 00000000000..cb42d13ac48 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cast-ptr-1.c @@ -0,0 +1,15 @@ +/* APPLE LOCAL file pointer casts */ +/* Test that casts of pointer to unsigned long long aren't sign extended */ +/* Author: Matt Austern <austern@apple.com> */ +/* { dg-do run } */ +/* { dg-options "-Wno-error -w" } */ + +int main () { + /* Note: test assumes sizeof(long long) >= sizeof(void*) */ + + unsigned long x1 = 0x80000000ul; + void* p = (void*) x1; + unsigned long long x2 = (unsigned long long) p; + + return !(x1 == x2); +} diff --git a/gcc/testsuite/gcc.dg/charset/asm1.c b/gcc/testsuite/gcc.dg/charset/asm1.c deleted file mode 100644 index d7578d418f6..00000000000 --- a/gcc/testsuite/gcc.dg/charset/asm1.c +++ /dev/null @@ -1,14 +0,0 @@ -/* { dg-do compile } - { dg-require-iconv "IBM-1047" } - { dg-final { scan-assembler ".ascii bar" } } - { dg-final { scan-assembler ".ascii foo" } } - */ -extern int x, y; - -asm (".ascii bar"); - -int foo (void) -{ - __asm__ (".ascii foo"); - return 0; -} diff --git a/gcc/testsuite/gcc.dg/charset/asm3.c b/gcc/testsuite/gcc.dg/charset/asm3.c deleted file mode 100644 index 8d8dbbb524d..00000000000 --- a/gcc/testsuite/gcc.dg/charset/asm3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Test for complex asm statements. Make sure it compiles - then test for some of the asm statements not being translated. */ -/* { dg-do compile { target i?86-*-* } } - { dg-require-iconv "IBM-1047" } - { dg-final { scan-assembler "std" } } - { dg-final { scan-assembler "cld" } } - { dg-final { scan-assembler "rep" } } - { dg-final { scan-assembler "movsb" } } */ -#define size_t int -void * -memmove (void *__dest, __const void *__src, size_t __n) -{ - register unsigned long int __d0, __d1, __d2; - if (__dest < __src) - __asm__ __volatile__ - ("cld\n\t" - "rep\n\t" - "movsb" - : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) - : "0" (__n), "1" (__src), "2" (__dest) - : "memory"); - else - __asm__ __volatile__ - ("std\n\t" - "rep\n\t" - "movsb\n\t" - "cld" - : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) - : "0" (__n), "1" (__n - 1 + (const char *) __src), - "2" (__n - 1 + (char *) __dest) - : "memory"); - return __dest; -} diff --git a/gcc/testsuite/gcc.dg/charset/asm4.c b/gcc/testsuite/gcc.dg/charset/asm4.c deleted file mode 100644 index cd850c3e81f..00000000000 --- a/gcc/testsuite/gcc.dg/charset/asm4.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Simple asm test. */ -/* { dg-do compile } - { dg-require-iconv "IBM-1047" } - { dg-final { scan-assembler "foo" } } */ -extern int bar; - -int main (void) -{ - asm ("foo %0" : "=r" (bar)); -} diff --git a/gcc/testsuite/gcc.dg/charset/asm5.c b/gcc/testsuite/gcc.dg/charset/asm5.c deleted file mode 100644 index fa93f40fdaf..00000000000 --- a/gcc/testsuite/gcc.dg/charset/asm5.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Test for string translation. */ -/* { dg-do compile } - { dg-require-iconv "IBM-1047" } - { dg-final { scan-assembler-not "translate" } } */ -void foo (void) -{ - asm ("xx" : : "r"("translate") : "cc"); -} diff --git a/gcc/testsuite/gcc.dg/charset/attribute1.c b/gcc/testsuite/gcc.dg/charset/attribute1.c deleted file mode 100644 index 993c7934c80..00000000000 --- a/gcc/testsuite/gcc.dg/charset/attribute1.c +++ /dev/null @@ -1,10 +0,0 @@ -/* Test for attribute non-translation. */ -/* { dg-do compile } - { dg-require-iconv "IBM-1047" } - { dg-final { scan-assembler "foo" } } */ -int walrus __attribute__ ((section (".foo"))); - -int main (void) -{ - return 0; -} diff --git a/gcc/testsuite/gcc.dg/charset/attribute2.c b/gcc/testsuite/gcc.dg/charset/attribute2.c deleted file mode 100644 index 4ce95a51f84..00000000000 --- a/gcc/testsuite/gcc.dg/charset/attribute2.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Test to make sure that invalid attributes aren't translated. - If error recovery is ever testable then "foobar" should be - translated. */ -/* { dg-do compile } - { dg-require-iconv "IBM-1047" } - */ -int foo __attribute__ ((walrus)); /* { dg-error "walrus" "ignored" } */ -char x[] = "foobar"; diff --git a/gcc/testsuite/gcc.dg/charset/string.c b/gcc/testsuite/gcc.dg/charset/string.c deleted file mode 100644 index 375e28a2ed6..00000000000 --- a/gcc/testsuite/gcc.dg/charset/string.c +++ /dev/null @@ -1,5 +0,0 @@ -/* Simple character translation test. */ -/* { dg-do compile } - { dg-require-iconv "IBM-1047" } - { dg-final { scan-assembler-not "string foobar" } } */ -char *foo = "string foobar"; diff --git a/gcc/testsuite/gcc.dg/compare8.c b/gcc/testsuite/gcc.dg/compare8.c new file mode 100644 index 00000000000..d723c45a095 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compare8.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Wsign-compare" } */ + +int +f(unsigned short a1, unsigned short a2, unsigned int b) +{ + return ((a1+a2)|5) > b ? 2 : 3; /* { dg-bogus "signed and unsigned" } */ +} + +int +g(unsigned short a1, unsigned short a2, unsigned int b) +{ + return ((a1+a2)&5) > b ? 2 : 3; /* { dg-bogus "signed and unsigned" } */ +} + +int +h(unsigned short a1, unsigned short a2, unsigned int b) +{ + return ((a1+a2)^5) > b ? 2 : 3; /* { dg-bogus "signed and unsigned" } */ +} + diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_main.c new file mode 100644 index 00000000000..d6f9eff2563 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are float + scalars. */ + +extern void struct_by_value_5a_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_5a_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_x.c new file mode 100644 index 00000000000..90738a7a7e8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(f, float) +CHECKS(f, float) + +TEST(Sf1, float) +TEST(Sf2, float) +TEST(Sf3, float) +TEST(Sf4, float) +TEST(Sf5, float) +TEST(Sf6, float) +TEST(Sf7, float) +TEST(Sf8, float) + +#undef T + +void +struct_by_value_5a_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sf1, float) +T(Sf2, float) +T(Sf3, float) +T(Sf4, float) +T(Sf5, float) +T(Sf6, float) +T(Sf7, float) +T(Sf8, float) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_y.c new file mode 100644 index 00000000000..9ac1f913474 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(f,float) +INITS(f, float) + +TEST(Sf1, float) +TEST(Sf2, float) +TEST(Sf3, float) +TEST(Sf4, float) +TEST(Sf5, float) +TEST(Sf6, float) +TEST(Sf7, float) +TEST(Sf8, float) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_main.c new file mode 100644 index 00000000000..dcb5f27ed09 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are float + scalars. */ + +extern void struct_by_value_5b_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_5b_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_x.c new file mode 100644 index 00000000000..3c371558728 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(f, float) +CHECKS(f, float) + +TEST(Sf9, float) +TEST(Sf10, float) +TEST(Sf11, float) +TEST(Sf12, float) +TEST(Sf13, float) +TEST(Sf14, float) +TEST(Sf15, float) +TEST(Sf16, float) + +#undef T + +void +struct_by_value_5b_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sf9, float) +T(Sf10, float) +T(Sf11, float) +T(Sf12, float) +T(Sf13, float) +T(Sf14, float) +T(Sf15, float) +T(Sf16, float) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c new file mode 100644 index 00000000000..cedc1660709 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(f,float) +INITS(f, float) + +TEST(Sf9, float) +TEST(Sf10, float) +TEST(Sf11, float) +TEST(Sf12, float) +TEST(Sf13, float) +TEST(Sf14, float) +TEST(Sf15, float) +TEST(Sf16, float) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_main.c new file mode 100644 index 00000000000..609c1d67308 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are double + scalars. */ + +extern void struct_by_value_6a_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_6a_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_x.c new file mode 100644 index 00000000000..e6852d9c9b7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(d, double) +CHECKS(d, double) + +TEST(Sd1, double) +TEST(Sd2, double) +TEST(Sd3, double) +TEST(Sd4, double) +TEST(Sd5, double) +TEST(Sd6, double) +TEST(Sd7, double) +TEST(Sd8, double) + +#undef T + +void +struct_by_value_6a_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sd1, double) +T(Sd2, double) +T(Sd3, double) +T(Sd4, double) +T(Sd5, double) +T(Sd6, double) +T(Sd7, double) +T(Sd8, double) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_y.c new file mode 100644 index 00000000000..8684b53c2f3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(d, double) +INITS(d, double) + +TEST(Sd1, double) +TEST(Sd2, double) +TEST(Sd3, double) +TEST(Sd4, double) +TEST(Sd5, double) +TEST(Sd6, double) +TEST(Sd7, double) +TEST(Sd8, double) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_main.c new file mode 100644 index 00000000000..ff17221718f --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are double + scalars. */ + +extern void struct_by_value_6b_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_6b_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_x.c new file mode 100644 index 00000000000..5b285c9c5b6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(d, double) +CHECKS(d, double) + +TEST(Sd9, double) +TEST(Sd10, double) +TEST(Sd11, double) +TEST(Sd12, double) +TEST(Sd13, double) +TEST(Sd14, double) +TEST(Sd15, double) +TEST(Sd16, double) + +#undef T + +void +struct_by_value_6b_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sd9, double) +T(Sd10, double) +T(Sd11, double) +T(Sd12, double) +T(Sd13, double) +T(Sd14, double) +T(Sd15, double) +T(Sd16, double) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_y.c new file mode 100644 index 00000000000..c568761b241 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(d, double) +INITS(d, double) + +TEST(Sd9, double) +TEST(Sd10, double) +TEST(Sd11, double) +TEST(Sd12, double) +TEST(Sd13, double) +TEST(Sd14, double) +TEST(Sd15, double) +TEST(Sd16, double) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_main.c new file mode 100644 index 00000000000..8379dc563c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are long double + scalars. */ + +extern void struct_by_value_7a_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_7a_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_x.c new file mode 100644 index 00000000000..9818c3c2251 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(ld, long double) +CHECKS(ld, long double) + +TEST(Sld1, long double) +TEST(Sld2, long double) +TEST(Sld3, long double) +TEST(Sld4, long double) +TEST(Sld5, long double) +TEST(Sld6, long double) +TEST(Sld7, long double) +TEST(Sld8, long double) + +#undef T + +void +struct_by_value_7a_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sld1, long double) +T(Sld2, long double) +T(Sld3, long double) +T(Sld4, long double) +T(Sld5, long double) +T(Sld6, long double) +T(Sld7, long double) +T(Sld8, long double) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_y.c new file mode 100644 index 00000000000..cb53df89dac --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(ld, long double) +INITS(ld, long double) + +TEST(Sld1, long double) +TEST(Sld2, long double) +TEST(Sld3, long double) +TEST(Sld4, long double) +TEST(Sld5, long double) +TEST(Sld6, long double) +TEST(Sld7, long double) +TEST(Sld8, long double) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_main.c new file mode 100644 index 00000000000..5d6908bfc1f --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are long double + scalars. */ + +extern void struct_by_value_7b_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_7b_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_x.c new file mode 100644 index 00000000000..508ff616584 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(ld, long double) +CHECKS(ld, long double) + +TEST(Sld9, long double) +TEST(Sld10, long double) +TEST(Sld11, long double) +TEST(Sld12, long double) +TEST(Sld13, long double) +TEST(Sld14, long double) +TEST(Sld15, long double) +TEST(Sld16, long double) + +#undef T + +void +struct_by_value_7b_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sld9, long double) +T(Sld10, long double) +T(Sld11, long double) +T(Sld12, long double) +T(Sld13, long double) +T(Sld14, long double) +T(Sld15, long double) +T(Sld16, long double) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_y.c new file mode 100644 index 00000000000..cc70a7d2925 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(ld, long double) +INITS(ld, long double) + +TEST(Sld9, long double) +TEST(Sld10, long double) +TEST(Sld11, long double) +TEST(Sld12, long double) +TEST(Sld13, long double) +TEST(Sld14, long double) +TEST(Sld15, long double) +TEST(Sld16, long double) diff --git a/gcc/testsuite/gcc.dg/const-cfstring-2.c b/gcc/testsuite/gcc.dg/const-cfstring-2.c new file mode 100644 index 00000000000..90475112453 --- /dev/null +++ b/gcc/testsuite/gcc.dg/const-cfstring-2.c @@ -0,0 +1,13 @@ +/* APPLE LOCAL file constant cfstrings */ +/* Test whether the __builtin__CFStringMakeConstantString + "function" fails gracefully when used without the + -fconstant-cfstrings flag. */ +/* Developed by Ziemowit Laski <zlaski@apple.com>. */ + +/* { dg-options "-fno-constant-cfstrings" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +#include <CoreFoundation/CFBase.h> + +const CFStringRef S = ((CFStringRef)__builtin___CFStringMakeConstantString("Testing")); +/* { dg-error "built-in" "built-in function .* requires .* flag" { target *-*-* } 12 } */ diff --git a/gcc/testsuite/gcc.dg/cpp/c++98-pedantic.cc b/gcc/testsuite/gcc.dg/cpp/c++98-pedantic.cc new file mode 100644 index 00000000000..1e8c160a96f --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/c++98-pedantic.cc @@ -0,0 +1,11 @@ +/* APPLE LOCAL file rename for HFS */ +/* Copyright (C) 2000 Free Software Foundation, Inc. */ + +/* { dg-do preprocess } */ +/* { dg-options "-std=c++98 -pedantic" } */ + +/* This file is for testing the preprocessor in -std=c++98 -pedantic mode. + Neil Booth, 2 Dec 2000. */ + +#if 1LL /* { dg-warning "long long" } */ +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/c++98.cc b/gcc/testsuite/gcc.dg/cpp/c++98.cc new file mode 100644 index 00000000000..a9843b878fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/c++98.cc @@ -0,0 +1,11 @@ +/* APPLE LOCAL file rename for HFS */ +/* Copyright (C) 2000 Free Software Foundation, Inc. */ + +/* { dg-do preprocess } */ +/* { dg-options "-std=c++98" } */ + +/* This file is for testing the preprocessor in -std=c++98 mode. + Neil Booth, 2 Dec 2000. */ + +#if 1LL +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/endif-pedantic2.c b/gcc/testsuite/gcc.dg/cpp/endif-pedantic2.c index d5c6eb960e6..a5db0fbc80f 100644 --- a/gcc/testsuite/gcc.dg/cpp/endif-pedantic2.c +++ b/gcc/testsuite/gcc.dg/cpp/endif-pedantic2.c @@ -1,8 +1,8 @@ /* Copyright (C) 2002 Free Software Foundation, Inc. */ - /* { dg-do preprocess } */ /* { dg-options "-Wno-endif-labels -pedantic" } */ - +/* APPLE LOCAL No error emit by Apple's default, use -Wextra-tokens to enable */ +/* { dg-options "-Wextra-tokens -Wno-endif-labels -pedantic" { target *-apple-darwin* } } */ /* Tests combinations of -pedantic and -Wno-endif-labels; see extratokens2.c for more general tests. */ diff --git a/gcc/testsuite/gcc.dg/cpp/extratokens.c b/gcc/testsuite/gcc.dg/cpp/extratokens.c index c06a41d4c2b..e57374cef93 100644 --- a/gcc/testsuite/gcc.dg/cpp/extratokens.c +++ b/gcc/testsuite/gcc.dg/cpp/extratokens.c @@ -1,7 +1,8 @@ /* Copyright (C) 2000 Free Software Foundation, Inc. */ /* { dg-do preprocess } */ -/* { dg-options "-fno-show-column" } */ +/* APPLE LOCAL Wextra-tokens */ +/* { dg-options "-fno-show-column -Wextra-tokens" } */ /* Tests all directives that do not permit excess tokens at the end of the line. */ diff --git a/gcc/testsuite/gcc.dg/cpp/if-2.c b/gcc/testsuite/gcc.dg/cpp/if-2.c index 866d25c3a60..6630bf55d65 100644 --- a/gcc/testsuite/gcc.dg/cpp/if-2.c +++ b/gcc/testsuite/gcc.dg/cpp/if-2.c @@ -18,6 +18,8 @@ #endif #if 'abcd' /* { dg-warning "multi-character character constant" "multi-character charconst" } */ +# /* APPLE LOCAL enable the warning with the -Wfour-char-constants flag */ +# /* { dg-options "-Wfour-char-constants" { target *-apple-darwin* } } */ #endif #if 'abcdefghi' /* { dg-error "character constant (is )?too long" "charconst too long" } */ diff --git a/gcc/testsuite/gcc.dg/cpp/include2.c b/gcc/testsuite/gcc.dg/cpp/include2.c index 60edfccb0cd..e935703b614 100644 --- a/gcc/testsuite/gcc.dg/cpp/include2.c +++ b/gcc/testsuite/gcc.dg/cpp/include2.c @@ -1,10 +1,10 @@ /* Copyright (C) 2000 Free Software Foundation, Inc. */ /* { dg-do preprocess } */ - +/* APPLE LOCAL BEGIN Apple disable this warning by default */ /* Tests that #include does not allow the terminating '>' or '"' to be escaped, as per the standard. */ - +/* { dg-options "-Wextra-tokens" } */ /* Source: Neil Booth, 4 Nov 2000. */ #include <silly\>> /* { dg-warning "extra tokens" "" } */ @@ -13,4 +13,4 @@ /* These error is No such file or directory, just once. However, this message is locale-dependent, so don't test for it. */ /* { dg-error "silly" "" { target *-*-* } 10 } */ - +/* APPLE LOCAL END */ diff --git a/gcc/testsuite/gcc.dg/cpp/skipping2.c b/gcc/testsuite/gcc.dg/cpp/skipping2.c index 3b0d0f32c8e..21378003fe2 100644 --- a/gcc/testsuite/gcc.dg/cpp/skipping2.c +++ b/gcc/testsuite/gcc.dg/cpp/skipping2.c @@ -6,6 +6,9 @@ /* Source: Neil Booth, 25 Jul 2001. */ +/* APPLE LOCAL -Wextra-tokens required in Apple's compiler to elicit req'd warnings here */ +/* { dg-options "-Wextra-tokens" } */ + #if 0 #if foo #else foo /* { dg-bogus "extra tokens" "extra tokens in skipped block" } */ diff --git a/gcc/testsuite/gcc.dg/cpp/sysmac2.c b/gcc/testsuite/gcc.dg/cpp/sysmac2.c index 0d1efabdc07..19ddf6ccb94 100644 --- a/gcc/testsuite/gcc.dg/cpp/sysmac2.c +++ b/gcc/testsuite/gcc.dg/cpp/sysmac2.c @@ -1,7 +1,8 @@ /* Copyright (C) 2001 Free Software Foundation, Inc. */ /* { dg-do compile } */ -/* { dg-options "-std=gnu99 -pedantic -Wtraditional -fno-show-column" } */ +/* APPLE LOCAL -Wlong-double */ +/* { dg-options "-std=gnu99 -pedantic -Wtraditional -fno-show-column -Wno-long-double" } */ /* Tests diagnostics are suppressed for some macros defined in system headers. */ diff --git a/gcc/testsuite/gcc.dg/debug/20020220-1.c b/gcc/testsuite/gcc.dg/debug/20020220-1.c index 07109e86a98..21bdc22b62b 100644 --- a/gcc/testsuite/gcc.dg/debug/20020220-1.c +++ b/gcc/testsuite/gcc.dg/debug/20020220-1.c @@ -3,6 +3,8 @@ constant -4.0 in constant pool was never referenced by anything but Dwarf-2 location descriptor. */ /* { dg-do run } */ +/* APPLE LOCAL -Wlong-double */ +/* { dg-options "-Wno-long-double" } */ void __attribute__((noinline)) foo (const char *x __attribute__((unused)), diff --git a/gcc/testsuite/gcc.dg/debug/debug-1.c b/gcc/testsuite/gcc.dg/debug/debug-1.c index 8cc520dcd79..b6faed04519 100644 --- a/gcc/testsuite/gcc.dg/debug/debug-1.c +++ b/gcc/testsuite/gcc.dg/debug/debug-1.c @@ -1,7 +1,8 @@ /* Verify that the scheduler does not discard the lexical block. */ /* { dg-do compile } */ /* { dg-options "-dA" } */ -/* { dg-final { scan-assembler "xyzzy" } } */ +/* APPLE LOCAL xfail for Apple only, serena */ +/* { dg-final { scan-assembler "xyzzy" { xfail *-apple-darwin* } } } */ long p; diff --git a/gcc/testsuite/gcc.dg/debug/debug-2.c b/gcc/testsuite/gcc.dg/debug/debug-2.c index b164ff97734..f3a3cf80777 100644 --- a/gcc/testsuite/gcc.dg/debug/debug-2.c +++ b/gcc/testsuite/gcc.dg/debug/debug-2.c @@ -1,7 +1,8 @@ /* Verify that the scheduler does not discard the lexical block. */ /* { dg-do compile } */ /* { dg-options "-dA" } */ -/* { dg-final { scan-assembler "xyzzy" } } */ +/* APPLE LOCAL xfail for Apple only, serena */ +/* { dg-final { scan-assembler "xyzzy" { xfail *-apple-darwin* } } } */ long p; diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die1.c deleted file mode 100644 index 39f0bf2792a..00000000000 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die1.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Verify that inline function never actually inlined has no abstract DIE. */ -/* { dg-do compile */ -/* { dg-options "-O2 -gdwarf-2 -dA" } */ -/* { dg-final { scan-assembler-not "DW_AT_inline" } } */ -inline int t() -{ -} -int (*q)()=t; diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die2.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die2.c deleted file mode 100644 index 48bce243d41..00000000000 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die2.c +++ /dev/null @@ -1,7 +0,0 @@ -/* Verify that inline function never actually emit has no DIE. */ -/* { dg-do compile */ -/* { dg-options "-O0 -gdwarf-2 -dA" } */ -/* { dg-final { scan-assembler-not "CIE Version" } } */ -static inline int t() -{ -} diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die3.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die3.c deleted file mode 100644 index 34fddfaffc0..00000000000 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die3.c +++ /dev/null @@ -1,11 +0,0 @@ -/* Verify that extern inline function never actually inlined has no abstract DIE. */ -/* { dg-do compile */ -/* { dg-options "-O0 -gdwarf-2 -dA" } */ -/* { dg-final { scan-assembler-not "DW_AT_inline" } } */ -extern inline int t() -{ -} -int (*q)()=t; -int t() -{ -} diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die5.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die5.c deleted file mode 100644 index b3a245d2b11..00000000000 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die5.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Inlined inline function must have abstract DIE */ -/* { dg-do compile */ -/* { dg-options "-O2 -gdwarf-2 -dA -fpreprocessed" } */ -/* { dg-final { scan-assembler "3.*DW_AT_inline" } } */ -#1 "test.h" -inline int t() -{ -} -int q() -{ - t(); -} diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die6.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die6.c deleted file mode 100644 index 40cdc8dee37..00000000000 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die6.c +++ /dev/null @@ -1,12 +0,0 @@ -/* not inline inline function must not have abstract DIE */ -/* { dg-do compile */ -/* { dg-options "-O2 -fno-inline -gdwarf-2 -dA -fpreprocessed" } */ -/* { dg-final { scan-assembler-not "DW_AT_inline" } } */ -#1 "test.h" -inline int t() -{ -} -int q() -{ - t(); -} diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die7.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die7.c deleted file mode 100644 index d8d013af38c..00000000000 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-die7.c +++ /dev/null @@ -1,14 +0,0 @@ -/* Inlined non-inline function must have abstract DIE */ -/* { dg-do compile */ -/* { dg-options "-O2 -gdwarf-2 -dA -fpreprocessed" } */ -/* { dg-final { scan-assembler "1.*DW_AT_inline" } } */ -#1 "test.h" -void f(void); -static int t() -{ - f(); -} -int q() -{ - t(); -} diff --git a/gcc/testsuite/gcc.dg/dg.exp b/gcc/testsuite/gcc.dg/dg.exp index 14cf79d7e14..eb11a3a70c5 100644 --- a/gcc/testsuite/gcc.dg/dg.exp +++ b/gcc/testsuite/gcc.dg/dg.exp @@ -22,7 +22,7 @@ load_lib gcc-dg.exp # If a testcase doesn't have special options, use these. global DEFAULT_CFLAGS if ![info exists DEFAULT_CFLAGS] then { - set DEFAULT_CFLAGS " -ansi -pedantic-errors" + set DEFAULT_CFLAGS " -ansi -pedantic-errors -Wno-long-double" } # Initialize `dg'. diff --git a/gcc/testsuite/gcc.dg/format/c90-printf-1.c b/gcc/testsuite/gcc.dg/format/c90-printf-1.c index e4c18f76862..f2a566aa5fa 100644 --- a/gcc/testsuite/gcc.dg/format/c90-printf-1.c +++ b/gcc/testsuite/gcc.dg/format/c90-printf-1.c @@ -4,7 +4,8 @@ */ /* Origin: Joseph Myers <jsm28@cam.ac.uk> */ /* { dg-do compile } */ -/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */ +/* APPLE LOCAL -Wlong-double */ +/* { dg-options "-std=iso9899:1990 -pedantic -Wformat -Wno-long-double" } */ #include "format.h" diff --git a/gcc/testsuite/gcc.dg/format/c90-scanf-1.c b/gcc/testsuite/gcc.dg/format/c90-scanf-1.c index ea42f1e131e..2a949f937a7 100644 --- a/gcc/testsuite/gcc.dg/format/c90-scanf-1.c +++ b/gcc/testsuite/gcc.dg/format/c90-scanf-1.c @@ -4,7 +4,8 @@ */ /* Origin: Joseph Myers <jsm28@cam.ac.uk> */ /* { dg-do compile } */ -/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */ +/* APPLE LOCAL -Wlong-double */ +/* { dg-options "-std=iso9899:1990 -pedantic -Wformat -Wno-long-double" } */ #include "format.h" diff --git a/gcc/testsuite/gcc.dg/format/strfmon-1.c b/gcc/testsuite/gcc.dg/format/strfmon-1.c index d163751328c..94c68586f49 100644 --- a/gcc/testsuite/gcc.dg/format/strfmon-1.c +++ b/gcc/testsuite/gcc.dg/format/strfmon-1.c @@ -1,7 +1,8 @@ /* Test for strfmon format checking. */ /* Origin: Joseph Myers <jsm28@cam.ac.uk> */ /* { dg-do compile } */ -/* { dg-options "-std=gnu99 -Wformat" } */ +/* APPLE LOCAL -Wlong-double */ +/* { dg-options "-std=gnu99 -Wformat -Wno-long-double" } */ #include "format.h" diff --git a/gcc/testsuite/gcc.dg/gnu89-init-3.c b/gcc/testsuite/gcc.dg/gnu89-init-3.c new file mode 100644 index 00000000000..bd4283ec875 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu89-init-3.c @@ -0,0 +1,18 @@ +/* PR 11527 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu89" } */ + +typedef struct smrdd_memory_blocks_s +{ + int blocks; + int block[]; +} smrdd_memory_blocks_t; + +const smrdd_memory_blocks_t smrdd_memory_blocks = +{ + 3, + { + [5] = 5, + [1] = 2, + } +}; diff --git a/gcc/testsuite/gcc.dg/i386-387-7.c b/gcc/testsuite/gcc.dg/i386-387-7.c new file mode 100644 index 00000000000..43c916c61d0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/i386-387-7.c @@ -0,0 +1,10 @@ +/* Verify that 387 fsincos instruction is generated. */ +/* { dg-do compile { target "i?86-*-*" } } */ +/* { dg-options "-O -ffast-math -march=i686" } */ +/* { dg-final { scan-assembler "fsincos" } } */ + +double f1(double x) +{ + return sin(x) + cos (x); +} + diff --git a/gcc/testsuite/gcc.dg/i386-387-8.c b/gcc/testsuite/gcc.dg/i386-387-8.c new file mode 100644 index 00000000000..05787160b00 --- /dev/null +++ b/gcc/testsuite/gcc.dg/i386-387-8.c @@ -0,0 +1,12 @@ +/* Verify that 387 fptan instruction is generated. Also check fptan + peephole2 optimizer. */ +/* { dg-do compile { target "i?86-*-*" } } */ +/* { dg-options "-O2 -ffast-math -march=i686" } */ +/* { dg-final { scan-assembler "fptan" } } */ +/* { dg-final { scan-assembler-not "fld1" } } */ + +double f1(double x) +{ + return 1.0 / tan(x); +} + diff --git a/gcc/testsuite/gcc.dg/noncompile/incomplete-3.c b/gcc/testsuite/gcc.dg/noncompile/incomplete-3.c new file mode 100644 index 00000000000..735ef465b38 --- /dev/null +++ b/gcc/testsuite/gcc.dg/noncompile/incomplete-3.c @@ -0,0 +1,9 @@ +/* Both occurrences of "c" should get diagnostics. PR 12391. */ +typedef struct { int a; } b_t; + +int foo (void) +{ + b_t d; + struct b_t *c = &d; /* { dg-warning "incompatible pointer type" } */ + c->a; /* { dg-error "incomplete type" } */ +} diff --git a/gcc/testsuite/gcc.dg/noncompile/undeclared-1.c b/gcc/testsuite/gcc.dg/noncompile/undeclared-1.c new file mode 100644 index 00000000000..5bb7c2a4df9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/noncompile/undeclared-1.c @@ -0,0 +1,8 @@ +/* Test for no ICE with an undeclared identifier in an enum in old-style + parameter decls. PR 12560. */ +/* { dg-options "-w" } */ + +foo(c) + enum { a = b } c; /* { dg-error "undeclared|for each" } */ +{ +} diff --git a/gcc/testsuite/gcc.dg/noncompile/undeclared-2.c b/gcc/testsuite/gcc.dg/noncompile/undeclared-2.c new file mode 100644 index 00000000000..36cd0eaf175 --- /dev/null +++ b/gcc/testsuite/gcc.dg/noncompile/undeclared-2.c @@ -0,0 +1,3 @@ +/* Invalid, but should not ICE. PRs 11944, 14734. */ + +void foo(const int[i]); /* { dg-error "undeclared|for each" } */ diff --git a/gcc/testsuite/gcc.dg/pch/apple-altivec-1.c b/gcc/testsuite/gcc.dg/pch/apple-altivec-1.c new file mode 100644 index 00000000000..7dc24c0d797 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/apple-altivec-1.c @@ -0,0 +1,126 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc-*-darwin* } } */ +/* { dg-options "-faltivec -Wno-long-double -I." } */ + +#include "apple-altivec-1.h" + +/* Test for correct handling of AltiVec constants passed + through '...' (va_arg). */ + +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> + +#define CHECK_INVARIANT(expr) \ + if (!(expr)) { \ + printf ("ASSERT FAILED: %d: %s\n", __LINE__, #expr); \ + abort (); \ + } + +struct foo { int x; int y; }; +struct vfoo { int x; __vector signed int v; int y; }; +union u { __vector signed int v; signed int i[4]; }; + +struct foo x_g = { 3, 4}; +struct vfoo vx_g = { 10, (vector signed int)(11, 12, 13, 14), 15 }; +__vector signed int v_g = (vector signed int) (22, 23, 24, 25); +struct vfoo vx2_g = { 30, (vector signed int)(31, 32, 33, 34), 35 }; +__vector signed int v2_g = (vector signed int)(40, 41, 42, 43); +int i_1 = 99, i_2 = 33; +double d_2 = 1.5, d_3 = 1.75; +long double ld_1 = 1.25; + +void bar (int i, ... ) +{ + struct foo xi; + double d; + long double ld; + float f; + char c; + short s; + va_list ap; + va_start(ap, i); + xi = va_arg(ap, struct foo); + s = (short)va_arg(ap, int); + f = (float)va_arg(ap, double); + ld = va_arg(ap, long double); + c = (char)va_arg(ap, int); + d = va_arg(ap, double); + va_end(ap); + + CHECK_INVARIANT (xi.x == x_g.x && xi.y == x_g.y); + CHECK_INVARIANT (s == (short)i_2); + CHECK_INVARIANT (f == (float)d_2); + CHECK_INVARIANT (ld == ld_1); + CHECK_INVARIANT (c == (char)i_1); + CHECK_INVARIANT (d == d_3); +} + +void baz (int i, ... ) +{ + struct vfoo vx, vx2; + __vector signed int v_i, v2_i; + int j, k, l; + va_list ap; + va_start(ap, i); + v_i = va_arg(ap, __vector signed int); + j = va_arg(ap, int); + vx = va_arg(ap, struct vfoo); + k = va_arg(ap, int); + v2_i = va_arg(ap, __vector signed int); + l = va_arg(ap, int); + vx2 = va_arg(ap, struct vfoo); + va_end(ap); + + CHECK_INVARIANT (vec_all_eq (v_i, v_g)); + CHECK_INVARIANT (j == i_1); + CHECK_INVARIANT (vx.x == vx_g.x && vec_all_eq(vx.v, vx_g.v) && vx.y == vx_g.y); + CHECK_INVARIANT (k == i_1); + CHECK_INVARIANT (vec_all_eq (v2_i, v2_g)); + CHECK_INVARIANT (l == i_1); + CHECK_INVARIANT (vx2.x == vx2_g.x && vec_all_eq(vx2.v, vx2_g.v) && vx2.y == vx2_g.y); +} + +void quux (int i, ... ) +{ + __vector signed int v_i, v2_i; + union u vi, v2i; + va_list ap; + va_start(ap, i); + v_i = va_arg(ap, __vector signed int); + v2_i = va_arg(ap, __vector signed int); + va_end(ap); + vi.v = v_i; + v2i.v = v2_i; + + CHECK_INVARIANT (vec_all_eq (v_i, v_g)); + CHECK_INVARIANT (vec_all_eq (v2_i, v_g)); + CHECK_INVARIANT (vec_all_eq (vi.v, v_g)); + CHECK_INVARIANT (vec_all_eq (v2i.v, v_g)); +} + +void baz2 (int i, ... ) +{ + struct vfoo vx; + union u vxi; + va_list ap; + va_start(ap, i); + vx = va_arg(ap, struct vfoo); + va_end(ap); + vxi.v = vx.v; + + CHECK_INVARIANT (vx.x == vx_g.x && vec_all_eq(vx.v, vx_g.v) && vx.y == vx_g.y); + CHECK_INVARIANT (vec_all_eq (vxi.v, vx_g.v)); +} + +int main(void) +{ + CHECK_INVARIANT (sizeof(struct foo) == 8 && sizeof(struct vfoo) == 48); + + bar(i_1, x_g, (short)i_2, (float)d_2, ld_1, (char)i_1, d_3); + baz(i_1, v_g, i_1, vx_g, i_1, v2_g, i_1, vx2_g); + quux(i_1, v_g, v_g); + baz2(i_1, vx_g); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pch/apple-altivec-1.hs b/gcc/testsuite/gcc.dg/pch/apple-altivec-1.hs new file mode 100644 index 00000000000..d31591ae112 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/apple-altivec-1.hs @@ -0,0 +1,2 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-options "-faltivec -Wno-long-double" } */ diff --git a/gcc/testsuite/gcc.dg/pch/valid-1.c b/gcc/testsuite/gcc.dg/pch/valid-1.c new file mode 100644 index 00000000000..ebfa85a9949 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-1.c @@ -0,0 +1,5 @@ +/* { dg-options "-I. -Winvalid-pch -g" } */ + +#include "valid-1.h"/* { dg-error "created with -gnone, but used with -g|No such file|they were invalid" } */ + +int x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-1.hs b/gcc/testsuite/gcc.dg/pch/valid-1.hs new file mode 100644 index 00000000000..e1ed11df4cc --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-1.hs @@ -0,0 +1,3 @@ +/* { dg-options "-I. -Winvalid-pch -g0" } */ + +extern int x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-1b.c b/gcc/testsuite/gcc.dg/pch/valid-1b.c new file mode 100644 index 00000000000..a2709967c07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-1b.c @@ -0,0 +1,5 @@ +/* { dg-options "-I. -Winvalid-pch -g0" } */ + +#include "valid-1b.h" + +int x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-1b.hs b/gcc/testsuite/gcc.dg/pch/valid-1b.hs new file mode 100644 index 00000000000..6dc358735a7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-1b.hs @@ -0,0 +1,3 @@ +/* { dg-options "-I. -Winvalid-pch -g" } */ + +extern int x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-2.c b/gcc/testsuite/gcc.dg/pch/valid-2.c new file mode 100644 index 00000000000..52a2e35a441 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-2.c @@ -0,0 +1,5 @@ +/* { dg-options "-I. -Winvalid-pch -fexceptions" } */ + +#include "valid-2.h"/* { dg-error "settings for -fexceptions do not match|No such file|they were invalid" } */ + +int x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-2.hs b/gcc/testsuite/gcc.dg/pch/valid-2.hs new file mode 100644 index 00000000000..2497af651c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-2.hs @@ -0,0 +1 @@ +extern int x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-3.c b/gcc/testsuite/gcc.dg/pch/valid-3.c new file mode 100644 index 00000000000..741a917df5d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-3.c @@ -0,0 +1,5 @@ +/* { dg-options "-I. -Winvalid-pch -fno-unit-at-a-time" } */ + +#include "valid-3.h"/* { dg-error "settings for -funit-at-a-time do not match|No such file|they were invalid" } */ + +int x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-3.hs b/gcc/testsuite/gcc.dg/pch/valid-3.hs new file mode 100644 index 00000000000..2a0af94c9f7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-3.hs @@ -0,0 +1,3 @@ +/* { dg-options "-I. -Winvalid-pch -funit-at-a-time" } */ + +extern int x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-4.c b/gcc/testsuite/gcc.dg/pch/valid-4.c new file mode 100644 index 00000000000..1249531ef67 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-4.c @@ -0,0 +1,6 @@ +/* { dg-options "-I. -Winvalid-pch -Wtrigraphs" } */ + +#include "valid-4.h" + +char * x = "??/"; /* { dg-error "trigraph" } */ + diff --git a/gcc/testsuite/gcc.dg/pch/valid-4.hs b/gcc/testsuite/gcc.dg/pch/valid-4.hs new file mode 100644 index 00000000000..051c720ee3f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-4.hs @@ -0,0 +1 @@ +extern char * x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-5.c b/gcc/testsuite/gcc.dg/pch/valid-5.c new file mode 100644 index 00000000000..4022d0458f2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-5.c @@ -0,0 +1,5 @@ +/* { dg-options "-I. -Winvalid-pch -pedantic-errors" } */ + +#include "valid-5.h" + +int x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-5.hs b/gcc/testsuite/gcc.dg/pch/valid-5.hs new file mode 100644 index 00000000000..2497af651c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-5.hs @@ -0,0 +1 @@ +extern int x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-6.c b/gcc/testsuite/gcc.dg/pch/valid-6.c new file mode 100644 index 00000000000..f111c31ae99 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-6.c @@ -0,0 +1,5 @@ +/* { dg-options "-I. -Winvalid-pch -dH -pipe -fcond-mismatch" } */ + +#include "valid-6.h" + +int x; diff --git a/gcc/testsuite/gcc.dg/pch/valid-6.hs b/gcc/testsuite/gcc.dg/pch/valid-6.hs new file mode 100644 index 00000000000..2497af651c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/valid-6.hs @@ -0,0 +1 @@ +extern int x; diff --git a/gcc/testsuite/gcc.dg/reg-vol-struct-1.c b/gcc/testsuite/gcc.dg/reg-vol-struct-1.c new file mode 100644 index 00000000000..7751bb4a117 --- /dev/null +++ b/gcc/testsuite/gcc.dg/reg-vol-struct-1.c @@ -0,0 +1,18 @@ +/* Test cases of structures with volatile fields declared register: + should be allowed unless register name given but explicitly taking + the address forbidden. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ + +/* { dg-do compile } */ + +struct S { volatile int field; }; + +void +f (void) +{ + register struct S a; + register struct S b[2]; + register struct S c __asm__("nosuchreg"); /* { dg-error "object with volatile field" "explicit reg name" } */ + &a; /* { dg-warning "address of register" "explicit address" } */ + b; /* { dg-warning "address of register" "implicit address" } */ +} diff --git a/gcc/testsuite/gcc.dg/spill-1.c b/gcc/testsuite/gcc.dg/spill-1.c new file mode 100644 index 00000000000..b85942e87aa --- /dev/null +++ b/gcc/testsuite/gcc.dg/spill-1.c @@ -0,0 +1,15 @@ +/* This caused an ICE during register spilling when targeting thumb. + There are 8 registers available for arithmetic operations (r0-r7) + r7 is the frame pointer, and r0-r3 are used to pass arguments. + Combine was extending the lives of the arguments (in r0-r3) up until the + call to z. This leaves only 3 regs free which isn't enough to preform the + doubleword addition. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-omit-frame-pointer" } */ +void z(int); +int foo(int a, int b, int c, int d, long long *q) +{ + *q=*q+1; + z (a+b+c+d); +} + diff --git a/gcc/testsuite/gcc.dg/ss/README b/gcc/testsuite/gcc.dg/ss/README new file mode 100644 index 00000000000..ca8a96a5483 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ss/README @@ -0,0 +1,17 @@ +APPLE LOCAL entire file + +This directory contains tests for Symbol Separation. + +Information about various files in this directory: + +README : This file +ss.exp : Driver for Symbol Separation tests +*.h : Normal header file +*.ssh : Header file is candidate for making separate + repository. This header is included in source + file as *.h. It will renamed on the fly during + test. + +*.c : Normal source file +*_part_2.c : Second source file associated with corrosponding + *.c source file. diff --git a/gcc/testsuite/gcc.dg/ss/one.c b/gcc/testsuite/gcc.dg/ss/one.c new file mode 100644 index 00000000000..866177926c9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ss/one.c @@ -0,0 +1,18 @@ +/* APPLE LOCAL entire file */ +/* Copyright (C) 2003 Free Software Foundation. + Contributed by Devang Patel <dpatel@apple.com> */ + +/* Test simple use of symbol repository. + Include file one.h is supplied as one.ssh in this directory, + so that ss.exp can pick it up as candidate for making + repository. */ +/* { dg-do assemble } */ + +#include "one.h" +int main () +{ + struct x_y_point a; + a.x = 0; + a.y = 0; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ss/one.ssh b/gcc/testsuite/gcc.dg/ss/one.ssh new file mode 100644 index 00000000000..57d77bbf06d --- /dev/null +++ b/gcc/testsuite/gcc.dg/ss/one.ssh @@ -0,0 +1,13 @@ +/* APPLE LOCAL entire file */ + +/* Copyright (C) 2003 Free Software Foundation. + Contributed by Devang Patel <dpatel@apple.com> */ + +/* Test simple use of symbol repository. + Part of one.c test. */ + +struct x_y_point +{ + int x; + int y; +}; diff --git a/gcc/testsuite/gcc.dg/ss/ss-cmd1.c b/gcc/testsuite/gcc.dg/ss/ss-cmd1.c new file mode 100644 index 00000000000..167d666f63e --- /dev/null +++ b/gcc/testsuite/gcc.dg/ss/ss-cmd1.c @@ -0,0 +1,10 @@ +/* APPLE LOCAL entire file */ +/* Copyright (C) 2003 Free Software Foundation. + Contributed by Devang Patel <dpatel@apple.com> */ +/* Test command line option -grepository */ +/* { dg-do compile } */ +/* { dg-options "-grepository" } */ +int main() +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/ss/ss.exp b/gcc/testsuite/gcc.dg/ss/ss.exp new file mode 100644 index 00000000000..b393f973425 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ss/ss.exp @@ -0,0 +1,235 @@ +# APPLE LOCAL entire file +# Copyright (C) 1997, 2002, 2003 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 2 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# GCC testsuite for symbol separation interaction, +# that uses the `dg.exp' driver. + +# Load support procs. +load_lib gcc-dg.exp + +# Initialize `dg'. +dg-init + +# Get checksum (first field of BINCL and EXCL stab information +proc get_checksum {input_file search_string} { + + # Regular expression to extract hexadecimal word + set hexexp {[0-9a-fA-F]+} + + # Do nm on input_file and grep for search_string + catch {exec nm -ap $input_file >& $input_file.nm} + catch {exec grep "$search_string" $input_file.nm >& $input_file.grep} + + # Extract dummy-checksum from the grep result (first hexdecimal word) + # and save it in RESULT + set file_h [open $input_file.grep r] + while {[gets $file_h line] >= 0} { + # We expect only one line in file_h + regexp $hexexp $line RESULT + } + close $file_h + + # Clean up + catch { file delete "$input_file.nm" } + catch { file delete "$input_file.grep" } + + # Return check sum + return $RESULT +} + +set old_dg_do_what_default "${dg-do-what-default}" + +# Main loop. +foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { + global runtests torture_without_loops dg-do-what-default + + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $test] { + continue + } + + # [file tail name] returns part of name after last / + set nshort "$subdir/[file tail $test]" + set short_bname "[file rootname [file tail $test]]" + set bname "[file rootname $test]" + set hexexp {[0-9a-fA-F]+} + set ss_exp_debug 0 + + catch { file delete "$bname.h" } + catch { file delete "$bname.h.cinfo" } + catch { file delete "$bname.o" } + catch { file delete "$bname.h.o" } + + # We don't try to use the loop-optimizing options, since they are highly + # unlikely to make any difference to CINFO. + foreach flags $torture_without_loops { + verbose "Testing $nshort, $flags" 1 + + if {$ss_exp_debug == 1} { + puts "ss_exp_debug: various names" + puts "ss_exp_debug bname:"; puts $bname + puts "ss_exp_debug bname.ssh:"; puts $bname.ssh + puts "ss_exp_debug test:"; puts $test + puts "ss_exp_debug short_bname:"; puts $short_bname + } + + # 1) compile foo.h to create foo.cinfo and foo.h.o + if { [ file exists "$bname.ssh" ] } { + + # For the header files, the default is to make repository + set dg-do-what-default assemble + + # Header files are supplied using .ssh extension, so that we can + # identify candidates for makeing symbol repository. Get header copy + # with .h here. + file copy -force "$bname.ssh" "$bname.h" + file copy -force "$bname.ssh" "$short_bname.h" + + # Make repository + # This will create two output files, $short_bname.o and $short_h.cinfo + dg-test -keep-output "$bname.h" $flags "-fsave-repository=. " + + if { [ file exists "$short_bname.o" ] } { + file rename -force "$short_bname.o" "$bname.h.o" + + # Do nm on $bname.h.o and grep for "BINCL $bname.h" + # Extract dummy-checksum from the grep result and save it in RESULT1 + set RESULT1 [get_checksum $bname.h.o "BINCL $bname.h"] + + if {$ss_exp_debug == 1} { + puts "ss_exp_debug: RESULT1"; puts $RESULT1 + } + + pass "$nshort $flags Make Repository" + + } else { + set RESULT1 " " + fail "$nshort $flags Make Repository" + } + + if { [ file exists "$short_bname.h.cinfo" ] } { + + # 2) compile foo.c to create foo.o + dg-test -keep-output $test $flags "-I. -grepository -Winvalid-sr" + if { [ file exists "$short_bname.o" ] } { + + # Do nm on $bname.o and grep for "EXCL $bname.h" + # Extract dummy-checksum from the grep result and save it in RESULT2 + set RESULT2 [get_checksum $short_bname.o "EXCL $bname.h"] + + if {$ss_exp_debug == 1} { + puts "ss_exp_debug: RESULT2"; puts $RESULT2 + } + + pass "$nshort $flags Use symbol repository" + + } else { + set RESULT2 " " + fail "$nshort $flags Use symbol repository YES" + } + + + if { [ file exists "$bname.part_2.c" ] } { + + # 3) compile foo_part_2.c to create foo_part_2.o + dg-test -keep-output "$bname_part_2.c" $flags "-I. -grepository" + if { [ file exists "$short_bname_part_2.o" ] } { + + # Do nm on $bname_part_2.o and grep for "EXCL $bname.h" + # Extract dummy-checksum from the grep result and save it in RESULT3 + set RESULT3 [get_checksum $short_bname_part_2.o "EXCL $bname.h"] + + if {$ss_exp_debug == 1} { + puts "ss_exp_debug: RESULT3"; puts $RESULT3 + } + + pass "$nshort $flags Use symbol repository" + + } else { + set RESULT3 " " + fail "$nshort $flags Use symbol repository" + } + + # 4) Link foo.h.o foo.o and foo_part_2.o to create foo + set dg-do-what-default link + dg-test -keep-output "$bname.h.o" "$bname.o" "$bname_part_2.o" "-o $short_bname.out" + + # 5) do 'nm |grep ' on final assembler and save result in RES4 + # Do nm on $bname.out and grep for "EXCL $bname.h" + # Extract dummy-checksum from the grep result and save it in RESULT4 + set RESULT4 [get_checksum $short_bname.out "EXCL $bname.h"] + + # Do nm on $bname.out and grep for "BINCL $bname.h" + # Extract dummy-checksum from the grep result and save it in RESULT5 + set RESULT5 [get_checksum $short_bname.out "BINCL $bname.h"] + + if {$ss_exp_debug == 1} { + puts "ss_exp_debug: RESULT4"; puts $RESULT4 + puts "ss_exp_debug: RESULT5"; puts $RESULT5 + } + + pass "$nshort $flags symbol separation: linking" + + } else { + + # If we are not testing second part then set values so that comparison test succeeds + set RESULT3 $RESULT2 + set RESULT4 $RESULT2 + set RESULT5 $RESULT2 + if {$ss_exp_debug == 1} { + puts "ss_exp_debug: RESULT3"; puts $RESULT3 + puts "ss_exp_debug: RESULT4"; puts $RESULT4 + puts "ss_exp_debug: RESULT5"; puts $RESULT5 + } + } + + # 6) Compare RES1 and RES2 and RES3 and RES4 + if { ( $RESULT1 == $RESULT2 ) + && ( $RESULT1 == $RESULT3 ) + && ( $RESULT1 == $RESULT4 ) } { + pass "$nshort $flags symbol separation valid use test" + } else { + fail "$nshort $flags symbol separation valid use test" + } + if { ( $RESULT1 == $RESULT5 ) } { + pass "$nshort $flags symbol separation link test" + } else { + fail "$nshort $flags symbol separation link test" + } + + } else { + fail "$nshort $flags Make repository" + } + } else { + + # Normal test + set dg-do-what-default compile + dg-test -keep-output $test $flags "-I." + } + + # Clean up + catch { file delete "$bname.h" } + catch { file delete "$bname.h.cinfo" } + catch { file delete "$bname.o" } + catch { file delete "$bname.h.o" } + } +} + +set dg-do-what-default "$old_dg_do_what_default" + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.dg/torture/builtin-convert-1.c b/gcc/testsuite/gcc.dg/torture/builtin-convert-1.c new file mode 100644 index 00000000000..ac671590d20 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/builtin-convert-1.c @@ -0,0 +1,138 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that built-in math function conversion to smaller FP types + is correctly performed by the compiler. + + Written by Kaveh Ghazi, 2004-03-17. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math" } */ + +#include "../builtins-config.h" + +/* This check is necessary when converting to a C99 function. */ +#ifdef HAVE_C99_RUNTIME +#define C99CODE(CODE) (CODE) +#define MAYBEC99(CODE, C99) (CODE) +#else +#define C99CODE(CODE) 0 +#define MAYBEC99(CODE, C99) (!(C99) && (CODE)) +#endif + +#define PROTOTYPE1(FN) extern double FN(double); extern float FN##f(float); \ + extern long double FN##l(long double); + +void test(double d1, float f1, long double ld1) +{ + /* Test converting math builtins to narrower FP types based on a + narrowing cast on the outside of the call. MATHFN is the + function to test, and C99 is 0/1 depending on whether the + `double' version of MATHFN is a C99 function. The optimization + is only performed if the replacement function is actually + narrower in width, so check that first. */ +#define OUTER_CAST1(MATHFN, C99) \ + PROTOTYPE1 (MATHFN) \ + extern void link_failure_outer_##MATHFN##l_##MATHFN##_1(void); \ + extern void link_failure_outer_##MATHFN##l_##MATHFN##_2(void); \ + extern void link_failure_outer_##MATHFN##l_##MATHFN##f_1(void); \ + extern void link_failure_outer_##MATHFN##l_##MATHFN##f_2(void); \ + extern void link_failure_outer_##MATHFN##_##MATHFN##f_1(void); \ + extern void link_failure_outer_##MATHFN##_##MATHFN##f_2(void); \ + if (sizeof (long double) > sizeof (double) \ + && MAYBEC99 ((double) MATHFN##l((double)ld1) != MATHFN(ld1), C99)) \ + link_failure_outer_##MATHFN##l_##MATHFN##_1(); \ + if (sizeof (long double) > sizeof (double) \ + && MAYBEC99 ((double) MATHFN##l(d1) != MATHFN(d1), C99)) \ + link_failure_outer_##MATHFN##l_##MATHFN##_1(); \ + if (sizeof (long double) > sizeof (double) \ + && MAYBEC99 ((double) MATHFN##l(f1) != MATHFN(f1), C99)) \ + link_failure_outer_##MATHFN##l_##MATHFN##_2(); \ + if (sizeof (long double) > sizeof (float) \ + && C99CODE ((float) MATHFN##l((float) ld1) != MATHFN##f(ld1))) \ + link_failure_outer_##MATHFN##l_##MATHFN##f_1(); \ + if (sizeof (long double) > sizeof (float) \ + && C99CODE ((float) MATHFN##l((float) d1) != MATHFN##f(d1))) \ + link_failure_outer_##MATHFN##l_##MATHFN##f_1(); \ + if (sizeof (long double) > sizeof (float) \ + && C99CODE ((float) MATHFN##l(f1) != MATHFN##f(f1))) \ + link_failure_outer_##MATHFN##l_##MATHFN##f_2(); \ + if (sizeof (double) > sizeof (float) \ + && C99CODE ((float) MATHFN((float) ld1) != MATHFN##f(ld1))) \ + link_failure_outer_##MATHFN##_##MATHFN##f_1(); \ + if (sizeof (double) > sizeof (float) \ + && C99CODE ((float) MATHFN((float) d1) != MATHFN##f(d1))) \ + link_failure_outer_##MATHFN##_##MATHFN##f_1(); \ + if (sizeof (double) > sizeof (float) \ + && C99CODE ((float) MATHFN(f1) != MATHFN##f(f1))) \ + link_failure_outer_##MATHFN##_##MATHFN##f_2() + + /* Test converting math builtins to narrower FP types based on if + the argument is a narrower type (perhaps implicitly) cast to a + wider one. */ +#define INNER_CAST1(MATHFN, C99) \ + PROTOTYPE1 (MATHFN) \ + extern void link_failure_inner_##MATHFN##l_##MATHFN(void); \ + extern void link_failure_inner_##MATHFN##l_##MATHFN##f(void); \ + extern void link_failure_inner_##MATHFN##_##MATHFN##f(void); \ + if (sizeof (long double) > sizeof (double) \ + && MAYBEC99 (MATHFN##l(d1) != (long double) MATHFN(d1), C99)) \ + link_failure_inner_##MATHFN##l_##MATHFN(); \ + if (sizeof (long double) > sizeof (float) \ + && C99CODE (MATHFN##l(f1) != (long double) MATHFN##f(f1))) \ + link_failure_inner_##MATHFN##l_##MATHFN##f(); \ + if (sizeof (long double) > sizeof (float) \ + && C99CODE (MATHFN##l((double)f1) != (long double) MATHFN##f(f1))) \ + link_failure_inner_##MATHFN##l_##MATHFN##f(); \ + if (sizeof (double) > sizeof (float) \ + && C99CODE (MATHFN(f1) != (double) MATHFN##f(f1))) \ + link_failure_inner_##MATHFN##_##MATHFN##f() + + +#ifdef __OPTIMIZE__ + OUTER_CAST1 (acos, /*C99=*/ 0); + OUTER_CAST1 (acosh, /*C99=*/ 1); + OUTER_CAST1 (asin, /*C99=*/ 1); + OUTER_CAST1 (asinh, /*C99=*/ 1); + OUTER_CAST1 (atan, /*C99=*/ 0); + OUTER_CAST1 (atanh, /*C99=*/ 1); + OUTER_CAST1 (cbrt, /*C99=*/ 1); + OUTER_CAST1 (cos, /*C99=*/ 0); + OUTER_CAST1 (cosh, /*C99=*/ 0); + OUTER_CAST1 (erf, /*C99=*/ 1); + OUTER_CAST1 (erfc, /*C99=*/ 1); + OUTER_CAST1 (exp, /*C99=*/ 0); + OUTER_CAST1 (exp2, /*C99=*/ 1); + OUTER_CAST1 (expm1, /*C99=*/ 1); + OUTER_CAST1 (fabs, /*C99=*/ 0); + OUTER_CAST1 (lgamma, /*C99=*/ 1); + OUTER_CAST1 (log, /*C99=*/ 0); + OUTER_CAST1 (log10, /*C99=*/ 0); + OUTER_CAST1 (log1p, /*C99=*/ 1); + OUTER_CAST1 (log2, /*C99=*/ 1); + OUTER_CAST1 (logb, /*C99=*/ 1); + OUTER_CAST1 (sin, /*C99=*/ 0); + OUTER_CAST1 (sinh, /*C99=*/ 0); + OUTER_CAST1 (sqrt, /*C99=*/ 0); + OUTER_CAST1 (tan, /*C99=*/ 0); + OUTER_CAST1 (tanh, /*C99=*/ 0); + OUTER_CAST1 (tgamma, /*C99=*/ 1); + + INNER_CAST1 (ceil, /*C99=*/ 0); + OUTER_CAST1 (ceil, /*C99=*/ 0); + INNER_CAST1 (floor, /*C99=*/ 0); + OUTER_CAST1 (floor, /*C99=*/ 0); + INNER_CAST1 (nearbyint, /*C99=*/ 1); + OUTER_CAST1 (nearbyint, /*C99=*/ 1); + INNER_CAST1 (rint, /*C99=*/ 1); + OUTER_CAST1 (rint, /*C99=*/ 1); + INNER_CAST1 (round, /*C99=*/ 1); + OUTER_CAST1 (round, /*C99=*/ 1); + INNER_CAST1 (trunc, /*C99=*/ 1); + OUTER_CAST1 (trunc, /*C99=*/ 1); +#endif /* __OPTIMIZE__ */ +} + +int main (void) +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/builtin-ctype-1.c b/gcc/testsuite/gcc.dg/torture/builtin-ctype-1.c new file mode 100644 index 00000000000..ad6fc1c60b6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/builtin-ctype-1.c @@ -0,0 +1,44 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that built-in ctype function attributes are correctly set by + the compiler. + + Written by Kaveh Ghazi, 2004-03-23. */ + +/* { dg-do link } */ + + +void test(int i) +{ + /* All of these ctype functions should be const/pure and thus + eliminated. */ +#define TEST_CTYPE(FN) \ + extern int FN(int); \ + extern void link_failure_##FN(void); \ + if (FN(i) != FN(i)) \ + link_failure_##FN() + +#ifdef __OPTIMIZE__ + TEST_CTYPE(isalnum); + TEST_CTYPE(isalpha); + TEST_CTYPE(isascii); + TEST_CTYPE(isblank); + TEST_CTYPE(iscntrl); + TEST_CTYPE(isdigit); + TEST_CTYPE(isgraph); + TEST_CTYPE(islower); + TEST_CTYPE(isprint); + TEST_CTYPE(ispunct); + TEST_CTYPE(isspace); + TEST_CTYPE(isupper); + TEST_CTYPE(isxdigit); + TEST_CTYPE(toascii); + TEST_CTYPE(tolower); + TEST_CTYPE(toupper); +#endif /* __OPTIMIZE__ */ +} + +int main (void) +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c b/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c new file mode 100644 index 00000000000..7046aad6562 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/builtin-ctype-2.c @@ -0,0 +1,107 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that built-in ctype transformations are done correctly by + the compiler. + + Written by Kaveh Ghazi, 2004-04-05. */ + +/* { dg-do link } */ + +extern void link_failure_var(void); + +void test(int i) +{ + /* All of these ctype calls should compile-time evaluate to true. */ +#define TEST_CTYPE_CST_TRUE(FN, VALUE) \ + extern void link_failure_##FN##_cst_true(void); \ + extern int FN(int); \ + if (! FN(VALUE)) \ + link_failure_##FN##_cst_true() + + /* All of these ctype calls should compile-time evaluate to false. */ +#define TEST_CTYPE_CST_FALSE(FN, VALUE) \ + extern void link_failure_##FN##_cst_false(void); \ + extern int FN(int); \ + if (FN(VALUE)) \ + link_failure_##FN##_cst_false() + + /* All of these ctype calls should compile-time evaluate to true. */ +#define TEST_TOCTYPE_CST_TRUE(FN, VALUE) \ + extern void link_failure_##FN##_cst_true(void); \ + extern int FN(int); \ + if (FN(VALUE) != (VALUE)) \ + link_failure_##FN##_cst_true() + + /* All of these ctype calls should compile-time evaluate to false. */ +#define TEST_TOCTYPE_CST_FALSE(FN, VALUE) \ + extern void link_failure_##FN##_cst_false(void); \ + extern int FN(int); \ + if (FN(VALUE) == (VALUE)) \ + link_failure_##FN##_cst_false() + +#ifdef __OPTIMIZE__ + TEST_CTYPE_CST_TRUE (isascii, 0); + TEST_CTYPE_CST_TRUE (isascii, 1); + TEST_CTYPE_CST_TRUE (isascii, 126); + TEST_CTYPE_CST_TRUE (isascii, 127); + + TEST_CTYPE_CST_FALSE (isascii, -1); + TEST_CTYPE_CST_FALSE (isascii, 128); + TEST_CTYPE_CST_FALSE (isascii, 129); + TEST_CTYPE_CST_FALSE (isascii, 255); + TEST_CTYPE_CST_FALSE (isascii, 256); + TEST_CTYPE_CST_FALSE (isascii, 257); + TEST_CTYPE_CST_FALSE (isascii, 10000); + TEST_CTYPE_CST_FALSE (isascii, __INT_MAX__); + + /* This ctype call should transform into another expression. */ + if (isascii(i) != ((i & ~0x7f) == 0)) + link_failure_var(); + + TEST_TOCTYPE_CST_TRUE (toascii, 0); + TEST_TOCTYPE_CST_TRUE (toascii, 1); + TEST_TOCTYPE_CST_TRUE (toascii, 126); + TEST_TOCTYPE_CST_TRUE (toascii, 127); + + TEST_TOCTYPE_CST_FALSE (toascii, -1); + TEST_TOCTYPE_CST_FALSE (toascii, 128); + TEST_TOCTYPE_CST_FALSE (toascii, 129); + TEST_TOCTYPE_CST_FALSE (toascii, 255); + TEST_TOCTYPE_CST_FALSE (toascii, 256); + TEST_TOCTYPE_CST_FALSE (toascii, 10000); + TEST_TOCTYPE_CST_FALSE (toascii, __INT_MAX__); + + /* This ctype call should transform into another expression. */ + if (toascii(i) != (i & 0x7f)) + link_failure_var(); + + TEST_CTYPE_CST_TRUE (isdigit, '0'); + TEST_CTYPE_CST_TRUE (isdigit, '1'); + TEST_CTYPE_CST_TRUE (isdigit, '2'); + TEST_CTYPE_CST_TRUE (isdigit, '3'); + TEST_CTYPE_CST_TRUE (isdigit, '4'); + TEST_CTYPE_CST_TRUE (isdigit, '5'); + TEST_CTYPE_CST_TRUE (isdigit, '6'); + TEST_CTYPE_CST_TRUE (isdigit, '7'); + TEST_CTYPE_CST_TRUE (isdigit, '8'); + TEST_CTYPE_CST_TRUE (isdigit, '9'); + + TEST_CTYPE_CST_FALSE (isdigit, '0'-1); + TEST_CTYPE_CST_FALSE (isdigit, '9'+1); + TEST_CTYPE_CST_FALSE (isdigit, -1); + TEST_CTYPE_CST_FALSE (isdigit, 0); + TEST_CTYPE_CST_FALSE (isdigit, 255); + TEST_CTYPE_CST_FALSE (isdigit, 256); + TEST_CTYPE_CST_FALSE (isdigit, 10000); + TEST_CTYPE_CST_FALSE (isdigit, __INT_MAX__); + + /* This ctype call should transform into another expression. */ + if (isdigit(i) != ((unsigned)i - '0' <= 9)) + link_failure_var(); +#endif /* __OPTIMIZE__ */ +} + +int main (void) +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/builtin-power-1.c b/gcc/testsuite/gcc.dg/torture/builtin-power-1.c new file mode 100644 index 00000000000..45566118a81 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/builtin-power-1.c @@ -0,0 +1,105 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that built-in folding of various math "power" functions is + correctly performed by the compiler. + + Written by Kaveh Ghazi, 2004-03-11. */ + +/* { dg-do link } */ +/* { dg-options "-ffast-math" } */ + +#include "../builtins-config.h" + +#ifdef HAVE_C99_RUNTIME +#define C99CODE(CODE) CODE +#else +#define C99CODE(CODE) 0 +#endif + +#define PROTOTYPE(FN) extern double FN(double); extern float FN##f(float); \ + extern long double FN##l(long double); +#define PROTOTYPE2(FN) extern double FN(double, double); \ + extern float FN##f(float, float); \ + extern long double FN##l(long double, long double); + +PROTOTYPE(sqrt) +PROTOTYPE(cbrt) +PROTOTYPE2(pow) + +void test(double d1, double d2, double d3, + float f1, float f2, float f3, + long double ld1, long double ld2, long double ld3) +{ + /* Test N1root(N2root(x)) -> pow(x,1/(N1*N2)). */ + /* E.g. sqrt(cbrt(x)) -> pow(x,1/6). */ +#define ROOT_ROOT(FN1,N1,FN2,N2) \ + extern void link_failure_##FN1##_##FN2(void); \ + if (FN1(FN2(d1)) != pow(d1,1.0/(N1*N2)) \ + || C99CODE (FN1##f(FN2##f(f1)) != powf(f1,1.0F/(N1*N2))) \ + || C99CODE (FN1##l(FN2##l(ld1)) != powl(ld1,1.0L/(N1*N2)))) \ + link_failure_##FN1##_##FN2() + + ROOT_ROOT(sqrt,2,sqrt,2); + ROOT_ROOT(sqrt,2,cbrt,3); + ROOT_ROOT(cbrt,3,sqrt,2); + /*ROOT_ROOT(cbrt,3,cbrt,3); Intentionally not implemented. */ + + /* Test pow(Nroot(x),y) -> pow(x,y/N). */ +#define POW_ROOT(FN,N) \ + extern void link_failure_pow_##FN(void); \ + if (pow(FN(d1), d2) != pow(d1,d2/N) \ + || powf(FN##f(f1),f2) != powf(f1,f2/N) \ + || powl(FN##l(ld1),ld2) != powl(ld1,ld2/N)) \ + link_failure_pow_##FN() + + POW_ROOT(sqrt,2); + /*POW_ROOT(cbrt,3); Intentionally not implemented. */ + + /* Test Nroot(pow(x,y)) -> pow(x,y/N). */ +#define ROOT_POW(FN,N) \ + extern void link_failure_##FN##_pow(void); \ + if (FN(pow(d1, d2)) != pow(d1,d2/N) \ + || FN##f(powf(f1,f2)) != powf(f1,f2/N) \ + || FN##l(powl(ld1,ld2)) != powl(ld1,ld2/N)) \ + link_failure_##FN##_pow() + + ROOT_POW(sqrt,2); + /*ROOT_POW(cbrt,3); Intentionally not implemented. */ + + /* Test pow(pow(x,y),z) -> pow(x,y*z). */ +#define POW_POW \ + extern void link_failure_pow_pow(void); \ + if (pow(pow(d1, d2), d3) != pow(d1,d2*d3) \ + || powf(powf(f1,f2),f3) != powf(f1,f2*f3) \ + || powl(powl(ld1,ld2),ld3) != powl(ld1,ld2*ld3)) \ + link_failure_pow_pow() + + POW_POW; + + /* Test Nroot(x)*Nroot(y) -> Nroot(x*y). */ +#define ROOT_X_ROOT(FN) \ + extern void link_failure_root_x_root(void); \ + if (FN(d1)*FN(d2) != FN(d1*d2) \ + || FN##f(f1)*FN##f(f2) != FN##f(f1*f2) \ + || FN##l(ld1)*FN##l(ld2) != FN##l(ld1*ld2)) \ + link_failure_root_x_root() + + ROOT_X_ROOT(sqrt); + ROOT_X_ROOT(cbrt); + + /* Test pow(x,y)*pow(x,z) -> pow(x,y+z). */ +#define POW_X_POW \ + extern void link_failure_pow_x_pow(void); \ + if (pow(d1,d2)*pow(d1,d3) != pow(d1,d2+d3) \ + || powf(f1,f2)*powf(f1,f3) != powf(f1,f2+f3) \ + || powl(ld1,ld2)*powl(ld1,ld3) != powl(ld1,ld2+ld3)) \ + link_failure_pow_x_pow() + + POW_X_POW; + +} + +int main (void) +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c b/gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c new file mode 100644 index 00000000000..b8338de0bd1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/builtin-wctype-1.c @@ -0,0 +1,42 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Verify that built-in wctype function attributes are correctly set + by the compiler. + + Written by Kaveh Ghazi, 2004-03-25. */ + +/* { dg-do link } */ + + +void test(int i) +{ + /* All of these ctype functions should be const/pure and thus + eliminated. */ +#define TEST_CTYPE(FN) \ + extern int FN(int); \ + extern void link_failure_##FN(void); \ + if (FN(i) != FN(i)) \ + link_failure_##FN() + +#ifdef __OPTIMIZE__ + TEST_CTYPE(iswalnum); + TEST_CTYPE(iswalpha); + TEST_CTYPE(iswblank); + TEST_CTYPE(iswcntrl); + TEST_CTYPE(iswdigit); + TEST_CTYPE(iswgraph); + TEST_CTYPE(iswlower); + TEST_CTYPE(iswprint); + TEST_CTYPE(iswpunct); + TEST_CTYPE(iswspace); + TEST_CTYPE(iswupper); + TEST_CTYPE(iswxdigit); + TEST_CTYPE(towlower); + TEST_CTYPE(towupper); +#endif /* __OPTIMIZE__ */ +} + +int main (void) +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/20040216-1.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/20040216-1.c new file mode 100644 index 00000000000..f4ac534bcc7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/20040216-1.c @@ -0,0 +1,26 @@ +/* Test dependence graph. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fscalar-evolutions -ftree-ddg -c -fdump-tree-all" } */ + +#define N 16 +void bar(int *); +void foo() +{ + int i,j; + int A[N]; + int X[N]; + int Y[N]; + int Z[N]; + + for (i=2; i<9; i++) + { + X[i] = Y[i] + Z[i]; + A[i] = X[i-1] + 1; + } + + bar (A); +} + +/* Find 4 Dependence nodes */ +/* { dg-final { scan-tree-dump-times "Dependence Node" 4 "ddg"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-01.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-01.c new file mode 100644 index 00000000000..f293f9b8c37 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-01.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int main(void) +{ + unsigned a; + int b; + int c; + + /* loop_1 runs exactly 4 times. */ + for (a = 22; a < 50; a+=1) + { + /* loop_2 runs exactly 6 times. On exit, the variable B is equal to 53. */ + for (b = 23; b < 50; b+=5) + { + ++a; + + /* loop_3 runs {{77, +, -7}_1, +, -1}_2 times. */ + for (c = a; c < 100; c++) + { + + } + } + } +} + +/* The analyzer has to detect the following evolution functions: + b -> {23, +, 5}_2 + a -> {{22, +, 7}_1, +, 1}_2 + c -> {{{23, +, 7}_1, +, 1}_2, +, 1}_3 +*/ +/* { dg-final { scan-tree-dump-times "nb_iterations 4" 1 "scev"} } */ +/* { dg-final { scan-tree-dump-times "nb_iterations 6" 1 "scev"} } */ + + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-02.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-02.c new file mode 100644 index 00000000000..4baecaceb1b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-02.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int main(void) +{ + int a; + int b; + int *c; + + /* The following loop runs exactly 3 times. */ + for (a = 11; a < 50; a++) + { + /* The following loop runs exactly 9 times. */ + for (b = 8; b < 50; b+=5) + { + c[a + 5] = 5; + c[b] = 6; + a+=2; + } + } +} + +/* The analyzer has to detect the following evolution functions: + b -> {8, +, 5}_2 + a -> {{11, +, 19}_1, +, 2}_2 +*/ +/* { dg-final { scan-tree-dump-times "nb_iterations 3" 1 "scev"} } */ +/* { dg-final { scan-tree-dump-times "nb_iterations 9" 1 "scev"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-03.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-03.c new file mode 100644 index 00000000000..9b681273c15 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-03.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-stats" } */ + + +int main(void) +{ + int a; + int b; + int *c; + + /* loop_1 runs exactly 5 times. */ + for (a = 11; a < 50; a++) + { + /* loop_2 runs exactly 7 times. */ + for (b = 8; b < 50; b+=5) + { + c[a++] = 5; + c[b++] = 6; + } + } +} + +/* The analyzer has to detect the following evolution functions: + b -> {8, +, 6}_2 + a -> {{11, +, 8}_1, +, 1}_2 +*/ +/* { dg-final { scan-tree-dump-times "nb_iterations 5" 1 "scev"} } */ +/* { dg-final { scan-tree-dump-times "nb_iterations 7" 1 "scev"} } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-04.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-04.c new file mode 100644 index 00000000000..99986cfdbc6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-04.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -ftree-elim-checks -fdump-tree-scev-details -fdump-tree-elck-details -fdump-tree-optimized" } */ + +void remove_me (void); + +int main(void) +{ + int a; + int b = 22; + + /* loop_1 runs exactly 28 times. */ + for (a = 22; a < 50; a++) /* a -> {22, +, 1}_1 */ + { + if (a > b) /* This condition is always false. */ + remove_me (); + b = b + 2; /* b -> {22, +, 2}_1 */ + } +} + +/* { dg-final { scan-tree-dump-times "nb_iterations 28" 1 "scev"} } */ +/* { dg-final { scan-tree-dump-times "remove_me" 0 "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-05.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-05.c new file mode 100644 index 00000000000..cb02875e674 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-05.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main(void) +{ + int a; + int b; + int c; + + /* nb_iterations 28 */ + for (a = 22; a < 50; a++) + { + /* nb_iterations 6 */ + for (b = 23; b < 50; b+=5) + { + /* nb_iterations {78, +, -1}_1 */ + for (c = a; c < 100; c++) + { + + } + } + } +} + +/* The analyzer has to detect the following evolution functions: + a -> {22, +, 1}_1 + b -> {23, +, 5}_2 + c -> {{22, +, 1}_1, +, 1}_3 +*/ +/* { dg-final { scan-tree-dump-times "nb_iterations 28" 1 "scev"} } */ +/* { dg-final { scan-tree-dump-times "nb_iterations 6" 1 "scev"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-06.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-06.c new file mode 100644 index 00000000000..7d720c94f2b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-06.c @@ -0,0 +1,50 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -ftree-elim-checks -fdump-tree-scev-details -fdump-tree-optimized" } */ + +void remove_me (void); + +int main(void) +{ + int a; + int b; + int c; + + /* loop_1 runs 2 times. */ + for (a = 22; a < 83; a+=1) /* a -> {22, +, 60}_1 */ + { + c = a; + + /* loop_2 runs exactly 6 times. */ + for (b = 23; b < 50; b+=5) /* b -> {23, +, 5}_2 */ + { + ++a; + } + /* The following stmt exercises the value of B on the exit of the loop. + In this case the value of B out of the loop is that of the evolution + function of B applied to the number of iterations the inner loop_2 runs. + Value (B) = {23, +, 5}_2 (6) = 53. */ + + /* At this point, the variable A has the evolution function: + {{22, +, 6}_1, +, 1}_2. */ + if (b != 53 + || a != c + 6) + remove_me (); + + a = a + b; + /* At this point, the variable A has the evolution function: + {{22, +, 59}_1, +, 1}_2. The evolution of the variable B in + the loop_2 does not matter, and is not recorded in the + evolution of A. The above statement is equivalent to: + "a = a + 53", ie. the scalar value of B on exit of the loop_2. */ + + if (a != c + 59) + remove_me (); + + /* And finally the a+=1 from the FOR_STMT produces the evolution + function: {{22, +, 60}_1, +, 1}_2. */ + } +} + +/* { dg-final { scan-tree-dump-times "nb_iterations 2" 1 "scev"} } */ +/* { dg-final { scan-tree-dump-times "nb_iterations 6" 1 "scev"} } */ +/* { dg-final { scan-tree-dump-times "remove_me" 0 "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-07.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-07.c new file mode 100644 index 00000000000..8cc619a6f47 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-07.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-elim-checks -fdump-tree-optimized" } */ + +void remove_me (void); + +int main(void) +{ + int a = -100; + int b = 2; + int d = -1; + int e = -100; + + while (a) + { + /* Exercises higher order polynomials. */ + a = a + b; /* a -> {-100, +, {2, +, 3}_1}_1 */ + b = b + 3; /* b -> {2, +, 3}_1 */ + + d = d + 3; /* d -> {-1, +, 3}_1 */ + e = e + d; /* e -> {-100, +, {2, +, 3}_1}_1 */ + + if (a != e) /* a -> {-98, +, {5, +, 3}_1}_1 */ + remove_me (); + } +} + +/* { dg-final { scan-tree-dump-times "remove_me" 0 "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-08.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-08.c new file mode 100644 index 00000000000..3d6eb7ba3b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-08.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-elim-checks -fdump-tree-optimized" } */ + +void remove_me (void); + +int main(void) +{ + int a = -100; + int b = 2; + int c = 3; + int d = -5; + int e = 3; + int f = -100; + + while (a) + { + /* Exercises higher order polynomials. */ + a = a + b; /* a -> {-100, +, 2, +, 3, +, 4}_1 */ + b = b + c; /* b -> {2, +, 3, +, 4}_1 */ + c = c + 4; /* c -> {3, +, 4}_1 */ + + d = d + 4; /* d -> {-5, +, 4}_1 */ + e = e + d; /* e -> {3, +, -1, +, 4}_1 */ + f = f + e; /* f -> {-100, +, 2, +, 3, +, 4}_1 */ + + if (a != f) /* (a == f) -> {-98, +, 5, +, 7, +, 4}_1 */ + remove_me (); + } +} + +/* { dg-final { scan-tree-dump-times "remove_me" 0 "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-09.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-09.c new file mode 100644 index 00000000000..9964a6d30c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-09.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int main(void) +{ + int a = -100; + int b = 2; + int c = 3; + int d = 4; + int e = 5; + + while (a) + { + /* Exercises the cycle detector: a -> b -> (c -> d -> e -> c)*. */ + a += b; + b += c; + c += d; + d += e; + e += c; + } +} + +/* This is what is commonly called a "mixer". It whirls the data in a + strongly connected component. We expect the following evolution + functions: + + e -> {5, +, c_13}_1 + d -> {4, +, {5, +, c_13}_1}_1 + c -> {3, +, {4, +, {5, +, c_13}_1}_1}_1 + b -> {2, +, {3, +, {4, +, {5, +, c_13}_1}_1}_1}_1 + a -> {-100, +, {2, +, {3, +, {4, +, {5, +, c_13}_1}_1}_1}_1}_1 +*/ + +/* FIXME: + For the moment this testcase does not test for anything, but for + not ICEing, and for documentation purposes (okay here is the + definition of a mixer). However, I'm considering testing something + around the lines of ssa-chrec-08.c, ie. build two mixers, and then + compare their values. But that is difficult, and low priority. */ + + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-10.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-10.c new file mode 100644 index 00000000000..649dfb0b2d8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-10.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev -fall-data-deps -fdump-tree-ddall" } */ + +void bar (int); + +int foo (void) +{ + int a; + int x; + int c[100][100]; + + /* loop_1 runs 39 times. */ + for (a = 11; a < 50; a++) + { + /* Array access functions have to be analyzed. */ + x = a + 5; + c[x][a+1] = c[x+2][a+3] + c[x-1][a+2]; + } + bar (c[1][2]); +} + +/* The analyzer has to detect the scalar functions: + a -> {11, +, 1}_1 + x -> {16, +, 1}_1 + x+2 -> {18, +, 1}_1 + x-1 -> {15, +, 1}_1 +*/ + +/* { dg-final { scan-tree-dump-times "nb_iterations 39" 1 "scev"} } */ +/* { dg-final { diff-tree-dumps "ddall" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-10.c.ddall b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-10.c.ddall new file mode 100644 index 00000000000..5bf0e92b185 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-10.c.ddall @@ -0,0 +1,215 @@ + +;; Function foo (foo) + + +(Data Dep (A = 0, B = 0): + (subscript 0: + access_fn_A: {14, +, 1}_1 + access_fn_B: {14, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {18, +, 1}_1 + access_fn_B: {18, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 0, B = 1): (no dependence) + +) +(Data Dep (A = 0, B = 2): + (subscript 0: + access_fn_A: {14, +, 1}_1 + access_fn_B: {12, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {2, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {18, +, 1}_1 + access_fn_B: {16, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {2, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(2 +) +(2 +) + ) + (Direction Vector: +(+) +(+) + ) + +) +(Data Dep (A = 0, B = 3): (no dependence) + +) +(Data Dep (A = 1, B = 0): (no dependence) + +) +(Data Dep (A = 1, B = 1): + (subscript 0: + access_fn_A: {13, +, 1}_1 + access_fn_B: {13, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {15, +, 1}_1 + access_fn_B: {15, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 1, B = 2): (no dependence) + +) +(Data Dep (A = 1, B = 3): (no dependence) + +) +(Data Dep (A = 2, B = 0): + (subscript 0: + access_fn_A: {12, +, 1}_1 + access_fn_B: {14, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {2, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {16, +, 1}_1 + access_fn_B: {18, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {2, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(-2 +) +(-2 +) + ) + (Direction Vector: +(-) +(-) + ) + +) +(Data Dep (A = 2, B = 1): (no dependence) + +) +(Data Dep (A = 2, B = 2): + (subscript 0: + access_fn_A: {12, +, 1}_1 + access_fn_B: {12, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {16, +, 1}_1 + access_fn_B: {16, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 2, B = 3): (no dependence) + +) +(Data Dep (A = 3, B = 0): (no dependence) + +) +(Data Dep (A = 3, B = 1): (no dependence) + +) +(Data Dep (A = 3, B = 2): (no dependence) + +) +(Data Dep (A = 3, B = 3): + (subscript 0: + access_fn_A: 2 + access_fn_B: 2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: 1 + access_fn_B: 1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-11.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-11.c new file mode 100644 index 00000000000..b68b3d5bf1f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-11.c @@ -0,0 +1,59 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main(void) +{ + int a = -100; + int b = 2; + + int f = 6; + int g = 7; + int h = 8; + + /* Exercises complex loop exit conditions. + FIXME: This is a strange case where the compiler cc1 and the wrapper gcc + don't produce the same representation: + + (with gcc from command line) + + T.1_9 = f_2 | a_1; + if (T.1_9 == 0) + { + goto <UL47e0>; + } + + versus (with cc1 called from gdb): + + if (f_2 == 0) + { + if (a_1 == 0) + { + goto <ULc7e0>; + } + else + { + (void)0 + } + } + else + { + (void)0 + }; + */ + while (f || a) + { + a += b; + + f += g; + g += h; + } +} + +/* + g -> {7, +, 8}_1 + f -> {6, +, {7, +, 8}_1}_1 + a -> {-100, +, 2}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-12.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-12.c new file mode 100644 index 00000000000..ab43eaf0a1a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-12.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int bar (void); + +int foo () +{ + int a = -100; + int b = 2; + int c = 3; + int d = 4; + + while (a) + { + a = a + b; + + /* Exercises if-phi-nodes. */ + if (bar ()) + b = b + c; + + c = c + d; + } +} + +/* The analyzer has to detect the following evolution functions: + c -> {3, +, 4}_1 + b -> {2, +, {[0, 3], +, [0, 4]}_1}_1 + a -> {-100, +, {2, +, {[0, 3], +, [0, 4]}_1}_1}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-13.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-13.c new file mode 100644 index 00000000000..37fba692f27 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-13.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int foo (void); + +int main (void) +{ + int a = -100; + int b = 2; + int c = 3; + + while (a) + { + /* Exercises if-phi-nodes. */ + if (foo ()) + a += b; + else + a += c; + + b++; + c++; + } +} + +/* The analyzer has to detect the following evolution function: + a -> {-100, +, {[2, 3], +, 1}_1}_1 +*/ + +/* FIXME. */ + + + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-14.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-14.c new file mode 100644 index 00000000000..e541160ebb6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-14.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int foo (void); + +int main (void) +{ + int a = -100; + int b = 2; + int c = 3; + int d = 4; + + while (d) + { + if (foo ()) + a += b; + else + a += c; + + b += 1; + c += 5; + + /* Exercises the initial condition of A after the if-phi-node. */ + d = d + a; + } +} + +/* The analyzer has to detect the following evolution function: + b -> {2, +, 1}_1 + c -> {3, +, 5}_1 + a -> {-100, +, {[2, 3], +, [1, 5]}_1}_1 + d -> {4, +, {[-98, -97], +, {[2, 3], +, [1, 5]}_1}_1}_1 +*/ + +/* FIXME. */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-15.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-15.c new file mode 100644 index 00000000000..e56a7dd91b6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-15.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main (void) +{ + int a; + int b; + int c; + + /* Exercises the MINUS_EXPR. loop_1 runs 50 times. */ + for (a = 100; a > 50; a--) + { + + } +} + +/* The analyzer has to detect the following evolution function: + a -> {100, +, -1}_1 +*/ + +/* { dg-final { scan-tree-dump-times "nb_iterations 50" 1 "scev"} } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-16.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-16.c new file mode 100644 index 00000000000..b2c26348dc0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-16.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main (void) +{ + int a = -100; + int b = 2; + int c = 3; + int d = 4; + + /* Determining the number of iterations for the != or == is work in + progress. Same for polynomials of degree >= 2, where we have to + find the zeros of the polynomial. */ + while (d) + { + a += 23; + d = a + d; + } +} + +/* a -> {-100, +, 23}_1 + d -> {4, +, {-77, +, 23}_1}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-17.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-17.c new file mode 100644 index 00000000000..9c624b08ca9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-17.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int bar (void); + +void foo () +{ + int a = -100; + int b = 2; + + while (b) + { + if (bar ()) + a += 3; + else + a = 2; + + /* Exercises the case when one of the branches of the if-phi-node is a constant. + FIXME: + - What is the chrec representation of such an evolution? + - Does this kind of code exist in real codes? */ + b += a; + } +} + +/* For the moment the analyzer is expected to output a "don't know" answer, + both for the initial condition and for the evolution part. This is done + in the merge condition branches information. + + a -> [-oo, +oo] + b -> {2, +, a_1}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-18.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-18.c new file mode 100644 index 00000000000..73996eac447 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-18.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int bar (void); + +int foo (int x) +{ + int a = -100; + int b = 2; + + while (b) + { + if (x) + a += 3; + else + a += bar (); + + /* Exercises the case when one of the branches of the if-phi-node cannot + be determined: [-oo, +oo]. + Since the evolution function is too difficult to handle in the expanded + form, we have to keep it in its symbolic form: "b -> {2, +, a_1}_1". */ + b += a; + } +} + +/* a -> {-100, +, [min<t, 3>, max<t, 3>]}_1 + b -> {2, +, {[min<t, 3>, max<t, 3>] - 100, +, [min<t, 3>, max<t, 3>]}_1}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-19.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-19.c new file mode 100644 index 00000000000..47219680039 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-19.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main () +{ + int b = 2; + + while (b) + { + /* Exercises the MULT_EXPR. */ + b = 2*b; + } +} + +/* b -> {2, *, 2}_1 +*/ + +/* FIXME. */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-20.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-20.c new file mode 100644 index 00000000000..521f60efe52 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-20.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main () +{ + int a = 3; + int b = 2; + + while (a) + { + b += 5; + a += b; + + /* Exercises the sum of a polynomial of degree 2 with an + evolution of degree 1: + + (loop_num = 1, chrec_var = {3, +, 7, +, 5}, to_add = 2). + The result should be: {3, +, 9, +, 5}. */ + a += 2; + } +} + +/* + b -> {2, +, 5}_1 + a -> {3, +, {9, +, 5}_1}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-21.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-21.c new file mode 100644 index 00000000000..1f8d0e600d3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-21.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main () +{ + int a = 3; + int b = 2; + + while (b) + { + a *= 4; + b *= a; + } +} + +/* a -> {3, *, 4}_1 + b -> {{2, *, 12}_1, *, 4}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-22.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-22.c new file mode 100644 index 00000000000..a6df37051d7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-22.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main () +{ + int a = 2; + int b = 4; + + while (a) + { + a *= 3; + a *= b; + b *= 5; + } +} + +/* + b -> {4, *, 5}_1 + a -> {2, *, {12, *, 5}_1}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-23.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-23.c new file mode 100644 index 00000000000..2b67406b6a9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-23.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main () +{ + int a = 1; + int b = 1; + + while (a) + { + a *= b; + b += 1; + } +} + +/* a -> {1, *, {1, +, 1}_1}_1 +*/ + +/* FIXME. */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-24.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-24.c new file mode 100644 index 00000000000..a81957e583d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-24.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int bar (void); + +int foo () +{ + int c; + + /* This exercises the initial condition propagator: + Interval Copy Constant Propagation (ICCP). */ + if (bar ()) + c = 2; + else + c = 3; + + while (c) + { + c += 5; + } +} + +/* + c -> {[2, 3], +, 5}_1 +*/ + +/* FIXME. */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-25.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-25.c new file mode 100644 index 00000000000..5c535707cca --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-25.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int bar (void); + +int foo () +{ + int c = 7; + + /* This exercises the initial condition propagator: + Interval Copy Constant Propagation (ICCP). */ + if (bar ()) + c = 2; + else + c += 3; + + while (c) + { + c += 5; + } +} + +/* + c -> {[2, 10], +, 5}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-26.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-26.c new file mode 100644 index 00000000000..b9e08d45810 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-26.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int bar (void); + +int foo () +{ + int a = -100; + int b = -10; + + /* This exercises a code with two loop nests. */ + + while (a) + a++; + + while (b) + b++; +} + +/* a -> {-100, +, 1}_1 + b -> {-10, +, 1}_2 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-27.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-27.c new file mode 100644 index 00000000000..c699bc6ac80 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-27.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int bar (void); + +int foo () +{ + int a = -100; + + /* This exercises a code with two loop nests. */ + + /* loop_1 runs 100 times. */ + while (a < 0) + a++; + + a -= 77; + + /* loop_2 runs 26 times. */ + while (a < 0) + a+=3; +} + +/* The analyzer sees two loop nests: + for the first, it determines the evolution: + a -> {-100, +, 1}_1 + + and for the second, it determines that the first loop ends at 0 and then: + a -> {-77, +, 3}_2 + + When the constant propagation is postponed, the analyzer detects + for the second loop the evolution function: + a -> {a_5, +, 3}_2 + +*/ + +/* { dg-final { scan-tree-dump-times "nb_iterations 100" 1 "scev"} } */ +/* { dg-final { scan-tree-dump-times "nb_iterations 26" 1 "scev"} } */ + + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-28.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-28.c new file mode 100644 index 00000000000..59702851d9a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-28.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int bar (void); + +int foo () +{ + int i; + int a = 2; + + while (a) + { + a *= 3; + + for (i = 0; i < 100; i++) + a += 4; + } +} + +/* FIXME: We have to transform the evolution function of "a" into an infinite + sum, a -> {//2, *, 2//}, and then to add the 400 from the inner sum... + But this is quite difficult, and cases like this one do not happen often. + + (Francois Irigoin consider that this case falls into the 0.01 percent + rule, and it is no worth to implement a solution for this testcase in a + production compiler. ) +*/ + +/* Do nothing for this testcase. + The following evolutions are detected: + + i -> {0, +, 1}_2 + a -> {{2, *, [-oo, +oo]}_1, +, 4}_2 + +*/ + +/* FIXME. */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-29.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-29.c new file mode 100644 index 00000000000..716797361fe --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-29.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int bar (void); + +int foo () +{ + int i; + int a = 2; + + while (a) + { + a *= 3; + a += 5; + } +} + +/* FIXME: This exposes a problem in the representation. Is it + possible to have an exponential and a polynomial together? + + The first assignment constructs "a -> {2, *, 3}_1", + while the second adds 5 as a polynomial function. + + The following two representations are not correct: + "a -> {{2, *, 3}_1, +, 5}_1" + "a -> {{2, +, 5}_1, *, 3}_1" + + The right solution is: + "a -> {2, *, 3}_1 + {0, +, 5}_1" + but this exposes yet again the "exp + poly" problem: the representation + is not homogen. Going into a Taylor decomposition could solve this problem. + + This is too difficult for the moment, and does not happen often. +*/ + +/* Do nothing for this testcase. */ + +/* FIXME. */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-30.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-30.c new file mode 100644 index 00000000000..3a36c5173c0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-30.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details -fall-data-deps -fdump-tree-ddall" } */ + +void foo (int); + +int main () +{ + int c[100][200]; + int a; + int x; + + for (a = 1; a < 50; a++) + { + x = a; + c[x-7][1] = c[x+2][3] + c[x-1][2]; + c[x][2] = c[x+2][3]; + } + foo (c[12][13]); +} + +/* { dg-final { diff-tree-dumps "ddall" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-30.c.ddall b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-30.c.ddall new file mode 100644 index 00000000000..1e9a201c189 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-30.c.ddall @@ -0,0 +1,383 @@ + +;; Function main (main) + + +(Data Dep (A = 0, B = 0): + (subscript 0: + access_fn_A: 3 + access_fn_B: 3 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {3, +, 1}_1 + access_fn_B: {3, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 0, B = 1): (no dependence) + +) +(Data Dep (A = 0, B = 2): (no dependence) + +) +(Data Dep (A = 0, B = 3): + (subscript 0: + access_fn_A: 3 + access_fn_B: 3 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {3, +, 1}_1 + access_fn_B: {3, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 0, B = 4): (no dependence) + +) +(Data Dep (A = 0, B = 5): (no dependence) + +) +(Data Dep (A = 1, B = 0): (no dependence) + +) +(Data Dep (A = 1, B = 1): + (subscript 0: + access_fn_A: 2 + access_fn_B: 2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {0, +, 1}_1 + access_fn_B: {0, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 1, B = 2): (no dependence) + +) +(Data Dep (A = 1, B = 3): (no dependence) + +) +(Data Dep (A = 1, B = 4): + (subscript 0: + access_fn_A: 2 + access_fn_B: 2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {0, +, 1}_1 + access_fn_B: {1, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {1, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(-1 +) + ) + (Direction Vector: +(=) +(-) + ) + +) +(Data Dep (A = 1, B = 5): (no dependence) + +) +(Data Dep (A = 2, B = 0): (no dependence) + +) +(Data Dep (A = 2, B = 1): (no dependence) + +) +(Data Dep (A = 2, B = 2): + (subscript 0: + access_fn_A: 1 + access_fn_B: 1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {-6, +, 1}_1 + access_fn_B: {-6, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 2, B = 3): (no dependence) + +) +(Data Dep (A = 2, B = 4): (no dependence) + +) +(Data Dep (A = 2, B = 5): (no dependence) + +) +(Data Dep (A = 3, B = 0): + (subscript 0: + access_fn_A: 3 + access_fn_B: 3 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {3, +, 1}_1 + access_fn_B: {3, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 3, B = 1): (no dependence) + +) +(Data Dep (A = 3, B = 2): (no dependence) + +) +(Data Dep (A = 3, B = 3): + (subscript 0: + access_fn_A: 3 + access_fn_B: 3 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {3, +, 1}_1 + access_fn_B: {3, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 3, B = 4): (no dependence) + +) +(Data Dep (A = 3, B = 5): (no dependence) + +) +(Data Dep (A = 4, B = 0): (no dependence) + +) +(Data Dep (A = 4, B = 1): + (subscript 0: + access_fn_A: 2 + access_fn_B: 2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {1, +, 1}_1 + access_fn_B: {0, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {1, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(1 +) + ) + (Direction Vector: +(=) +(+) + ) + +) +(Data Dep (A = 4, B = 2): (no dependence) + +) +(Data Dep (A = 4, B = 3): (no dependence) + +) +(Data Dep (A = 4, B = 4): + (subscript 0: + access_fn_A: 2 + access_fn_B: 2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {1, +, 1}_1 + access_fn_B: {1, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 4, B = 5): (no dependence) + +) +(Data Dep (A = 5, B = 0): (no dependence) + +) +(Data Dep (A = 5, B = 1): (no dependence) + +) +(Data Dep (A = 5, B = 2): (no dependence) + +) +(Data Dep (A = 5, B = 3): (no dependence) + +) +(Data Dep (A = 5, B = 4): (no dependence) + +) +(Data Dep (A = 5, B = 5): + (subscript 0: + access_fn_A: 13 + access_fn_B: 13 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: 12 + access_fn_B: 12 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-31.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-31.c new file mode 100644 index 00000000000..bb3f29cab3e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-31.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details -fall-data-deps -fdump-tree-ddall" } */ + +void bar (short); + +#define N 100 +foo (){ + short a[N]; + short b[N]; + short c[N]; + int i; + + for (i=0; i<N; i++){ + a[i] = b[i] + c[i]; + } + bar (a[2]); +} + +/* { dg-final { diff-tree-dumps "ddall" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-31.c.ddall b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-31.c.ddall new file mode 100644 index 00000000000..6aaf0f386c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-31.c.ddall @@ -0,0 +1,143 @@ + +;; Function foo (foo) + + +(Data Dep (A = 0, B = 0): + (subscript 0: + access_fn_A: {0, +, 1}_1 + access_fn_B: {0, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 0, B = 1): (no dependence) + +) +(Data Dep (A = 0, B = 2): (no dependence) + +) +(Data Dep (A = 0, B = 3): (no dependence) + +) +(Data Dep (A = 1, B = 0): (no dependence) + +) +(Data Dep (A = 1, B = 1): + (subscript 0: + access_fn_A: {0, +, 1}_1 + access_fn_B: {0, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 1, B = 2): (no dependence) + +) +(Data Dep (A = 1, B = 3): (no dependence) + +) +(Data Dep (A = 2, B = 0): (no dependence) + +) +(Data Dep (A = 2, B = 1): (no dependence) + +) +(Data Dep (A = 2, B = 2): + (subscript 0: + access_fn_A: {0, +, 1}_1 + access_fn_B: {0, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 2, B = 3): + (subscript 0: + access_fn_A: {0, +, 1}_1 + access_fn_B: 2 + iterations_that_access_an_element_twice_in_A: 2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(-2 +) + ) + (Direction Vector: +(-) + ) + +) +(Data Dep (A = 3, B = 0): (no dependence) + +) +(Data Dep (A = 3, B = 1): (no dependence) + +) +(Data Dep (A = 3, B = 2): + (subscript 0: + access_fn_A: 2 + access_fn_B: {0, +, 1}_1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(2 +) + ) + (Direction Vector: +(+) + ) + +) +(Data Dep (A = 3, B = 3): + (subscript 0: + access_fn_A: 2 + access_fn_B: 2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-32.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-32.c new file mode 100644 index 00000000000..784caef3270 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-32.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details -fall-data-deps -fdump-tree-ddall" } */ + +void bar (short); + +#define N 100 +#define NPad 10 +#define M 32 +void foo() +{ + short coef[M]; + short input[N]; + short output[N]; + + int i,j,k; + int sum; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < M; j++) { + sum += input[i+NPad-j] * coef[j]; + } + output[i] = sum; + } + bar (sum); +} + +/* The following evolution functions have to be detected: + + i -> {0, +, 1}_1 + j -> {0, +, 1}_2 + +*/ + +/* { dg-final { diff-tree-dumps "ddall" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-32.c.ddall b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-32.c.ddall new file mode 100644 index 00000000000..2929ec3271a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-32.c.ddall @@ -0,0 +1,47 @@ + +;; Function foo (foo) + + +(Data Dep (A = 0, B = 0): + (subscript 0: + access_fn_A: {{10, +, 1}_1, +, -1}_2 + access_fn_B: {{10, +, 1}_1, +, -1}_2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 0, B = 1): (no dependence) + +) +(Data Dep (A = 1, B = 0): (no dependence) + +) +(Data Dep (A = 1, B = 1): + (subscript 0: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-33.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-33.c new file mode 100644 index 00000000000..a2a24a7e4e3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-33.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details -fall-data-deps -fdump-tree-ddall" } */ + +void bar (int); + +#define N 100 +#define NPad 10 +#define M 32 + +void foo () +{ + short coefs[2*M]; + short input[2*N]; + short output[2*N]; + + int sum_real, sum_imag; + int i,j,k; + + k = NPad; + for (i = 0; i < N; i++) + { + sum_real = 0; + sum_imag = 0; + for (j = 0; j < M; j++) + { + sum_real += + input[2*k-2*j+1]*coefs[2*j+1] - input[2*k-2*j]*coefs[2*j]; + + sum_imag += + input[2*k-2*j]*coefs[2*j+1] + input[2*k-2*j+1]*coefs[2*j]; + } + output[2*i+1] = sum_imag; + output[2*i] = sum_real; + k++; + } + bar (sum_imag); +} + +/* The following evolution functions have to be detected: + + i -> {0, +, 1}_1 + j -> {0, +, 1}_2 + +*/ + +/* { dg-final { diff-tree-dumps "ddall" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-33.c.ddall b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-33.c.ddall new file mode 100644 index 00000000000..1e9f1ee4002 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-33.c.ddall @@ -0,0 +1,113 @@ + +;; Function foo (foo) + + +(Data Dep (A = 0, B = 0): + (subscript 0: + access_fn_A: {{21, +, 2}_1, +, -2}_2 + access_fn_B: {{21, +, 2}_1, +, -2}_2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 0, B = 1): (no dependence) + +) +(Data Dep (A = 0, B = 2): (no dependence) + +) +(Data Dep (A = 0, B = 3): (no dependence) + +) +(Data Dep (A = 1, B = 0): (no dependence) + +) +(Data Dep (A = 1, B = 1): + (subscript 0: + access_fn_A: {1, +, 2}_2 + access_fn_B: {1, +, 2}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 1, B = 2): (no dependence) + +) +(Data Dep (A = 1, B = 3): (no dependence) + +) +(Data Dep (A = 2, B = 0): (no dependence) + +) +(Data Dep (A = 2, B = 1): (no dependence) + +) +(Data Dep (A = 2, B = 2): + (subscript 0: + access_fn_A: {{20, +, 2}_1, +, -2}_2 + access_fn_B: {{20, +, 2}_1, +, -2}_2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 2, B = 3): (no dependence) + +) +(Data Dep (A = 3, B = 0): (no dependence) + +) +(Data Dep (A = 3, B = 1): (no dependence) + +) +(Data Dep (A = 3, B = 2): (no dependence) + +) +(Data Dep (A = 3, B = 3): + (subscript 0: + access_fn_A: {0, +, 2}_2 + access_fn_B: {0, +, 2}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-34.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-34.c new file mode 100644 index 00000000000..1a5687a527b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-34.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details -fall-data-deps -fdump-tree-ddall" } */ + +void bar (int); + +#define M 16 +#define N 8 + +short foo (short image[][M], short block[][N]){ + int sad, diff = 0; + int i, j; + int tmp; + + for (i = 0; i < N; i++) { + sad = 0; + for (j = 0; j < N; j++) { + tmp = image[i][j] - block[i][j]; + sad += (tmp < 0) ? -tmp : tmp; + } + diff += sad; + } + + return diff; +} + +/* The following evolution functions have to be detected: + + i -> {0, +, 1}_1 + j -> {0, +, 1}_2 + +*/ + +/* { dg-final { diff-tree-dumps "ddall" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-34.c.ddall b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-34.c.ddall new file mode 100644 index 00000000000..9f3d13edc91 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-34.c.ddall @@ -0,0 +1,47 @@ + +;; Function foo (foo) + + +(Data Dep (A = 0, B = 0): + (subscript 0: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 0, B = 1): (no dependence) + +) +(Data Dep (A = 1, B = 0): (no dependence) + +) +(Data Dep (A = 1, B = 1): + (subscript 0: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-35.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-35.c new file mode 100644 index 00000000000..f33f28b397a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-35.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details -fall-data-deps -fdump-tree-ddall" } */ + +#define L 100 +#define M 100 +#define N 100 + +int bar (float); + +int foo (float A[][M][N]) +{ + int i, j, k; + + for (i = 0; i < L; i++) + for (j = 0; j < M; j++) + for (k = 0; k < N; k++) + A[i][j][j] = A[i][j][k]; + + return bar (A[10][11][12]); +} + +/* The following evolution functions have to be detected: + + i -> {0, +, 1}_1 + j -> {0, +, 1}_2 + k -> {0, +, 1}_3 + + For the subscript [j] vs. [k], "{0, +, 1}_2" vs. "{0, +, 1}_3" + the overlapping elements are respectively located at iterations: + {0, +, 1}_3 and {0, +, 1}_2. + +*/ + +/* { dg-final { diff-tree-dumps "ddall" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-35.c.ddall b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-35.c.ddall new file mode 100644 index 00000000000..858b925f649 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-35.c.ddall @@ -0,0 +1,167 @@ + +;; Function foo (foo) + + +(Data Dep (A = 0, B = 0): + (subscript 0: + access_fn_A: {0, +, 1}_3 + access_fn_B: {0, +, 1}_3 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_3 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_3 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 0, B = 1): + (subscript 0: + access_fn_A: {0, +, 1}_3 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_3 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +([-oo, +oo] +) +(0 +) + ) + (Direction Vector: +(*) +(=) + ) + +) +(Data Dep (A = 0, B = 2): (no dependence) + +) +(Data Dep (A = 1, B = 0): + (subscript 0: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_3 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_3 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +([-oo, +oo] +) +(0 +) + ) + (Direction Vector: +(*) +(=) + ) + +) +(Data Dep (A = 1, B = 1): + (subscript 0: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 1, B = 2): (no dependence) + +) +(Data Dep (A = 2, B = 0): (no dependence) + +) +(Data Dep (A = 2, B = 1): (no dependence) + +) +(Data Dep (A = 2, B = 2): + (subscript 0: + access_fn_A: 12 + access_fn_B: 12 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: 11 + access_fn_B: 11 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-36.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-36.c new file mode 100644 index 00000000000..916c81548c8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-36.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details -fall-data-deps -fdump-tree-ddall" } */ + +int foo (int); + +int main () +{ + int res; + int c[100][200]; + int a; + int x; + + for (a = 1; a < 50; a++) + { + c[a+1][a] = 2; + res += c[a][a]; + + /* This case exercises the subscript coupling detection: the dependence + detectors have to determine that there is no dependence between + c[a+1][a] and c[a][a]. */ + } + + return res + foo (c[12][13]); +} + +/* This also exercises the case when, after a PRE, the loop phi node contains: + " # a_1 = PHI <1(0), T.1_11(1)>; + ... + T.1_11 = a_1 + 1;". + In fact this creates a cycle: a -> T.1 -> a. + The PRE has screwed up the case... + ...I really have to implement the mixers analyzers. */ + +/* { dg-final { diff-tree-dumps "ddall" } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-36.c.ddall b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-36.c.ddall new file mode 100644 index 00000000000..ac9536852cd --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-36.c.ddall @@ -0,0 +1,221 @@ + +;; Function main (main) + + +(Data Dep (A = 0, B = 0): + (subscript 0: + access_fn_A: {1, +, 1}_1 + access_fn_B: {1, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {2, +, 1}_1 + access_fn_B: {2, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 0, B = 1): (no dependence) + +) +(Data Dep (A = 0, B = 2): + (subscript 0: + access_fn_A: {1, +, 1}_1 + access_fn_B: 13 + iterations_that_access_an_element_twice_in_A: 12 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {2, +, 1}_1 + access_fn_B: 12 + iterations_that_access_an_element_twice_in_A: 10 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(-12 +) +(-10 +) + ) + (Direction Vector: +(-) +(-) + ) + +) +(Data Dep (A = 1, B = 0): (no dependence) + +) +(Data Dep (A = 1, B = 1): + (subscript 0: + access_fn_A: {1, +, 1}_1 + access_fn_B: {1, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {1, +, 1}_1 + access_fn_B: {1, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 1, B = 2): + (subscript 0: + access_fn_A: {1, +, 1}_1 + access_fn_B: 13 + iterations_that_access_an_element_twice_in_A: 12 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {1, +, 1}_1 + access_fn_B: 12 + iterations_that_access_an_element_twice_in_A: 11 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(-12 +) +(-11 +) + ) + (Direction Vector: +(-) +(-) + ) + +) +(Data Dep (A = 2, B = 0): + (subscript 0: + access_fn_A: 13 + access_fn_B: {1, +, 1}_1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 12 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: 12 + access_fn_B: {2, +, 1}_1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 10 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(12 +) +(10 +) + ) + (Direction Vector: +(+) +(+) + ) + +) +(Data Dep (A = 2, B = 1): + (subscript 0: + access_fn_A: 13 + access_fn_B: {1, +, 1}_1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 12 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: 12 + access_fn_B: {1, +, 1}_1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 11 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(12 +) +(11 +) + ) + (Direction Vector: +(+) +(+) + ) + +) +(Data Dep (A = 2, B = 2): + (subscript 0: + access_fn_A: 13 + access_fn_B: 13 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: 12 + access_fn_B: 12 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-37.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-37.c new file mode 100644 index 00000000000..43653454dfd --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-37.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main () +{ + int a; + int b = 2; + int c = 11; + + for (a = -123; a < 0; c += 12, b += 5) + { + a += b; + + /* The next stmt exercises the add_function_to_loop_evolution + (loop_num = 1, chrec_before = {-123, +, {2, +, 5}_1}_1, to_add = {11, +, 12}_1). + The result should be: {-123, +, {13, +, 17}_1}_1. */ + a += c; + } +} + +/* + b -> {2, +, 5}_1 + c -> {11, +, 12}_1 + a -> {-123, +, {13, +, 17}_1}_1 +*/ + + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-38.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-38.c new file mode 100644 index 00000000000..3108ec24851 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-38.c @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main () +{ + int a = 3; + int b = 2; + int c = 11; + int d = -5; + + while (a) + { + b += 5; + a += b; + + for (d = -5; d < 0; d++) + { + /* Exercises the build_polynomial_evolution_in_loop function in the following context: + (add_to_evolution + loop_num = 2 + chrec_before = {3, +, 7, +, 5}_1 + to_add = {11, +, 12}_1 + res = {{3, +, 7, +, 5}_1, +, {11, +, 12}_1}_2 + ) + + This also exercises the chrec_apply function in the following context: + (chrec_apply + var = 2 + chrec = {0, +, {11, +, 12}_1}_2 + x = 5 + res = {55, +, 60}_1 + ) + */ + a += c; + } + c += 12; + } +} + +/* + b -> {2, +, 5}_1 + c -> {11, +, 12}_1 + d -> {-5, +, 1}_2 + a -> {{3, +, 62, +, 65}_1, +, {11, +, 12}_1}_2 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-39.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-39.c new file mode 100644 index 00000000000..8e1857277c1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-39.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int foo (int ParmN) +{ + int a = 3; + int b = 2; + int d = -5; + + while (a) + { + b += 25; + a += b; + + for (d = -5; d < 0; d++) + { + /* Exercises the build_polynomial_evolution_in_loop in the following context: + (add_to_evolution + loop_num = 2 + chrec_before = {3, +, {27, +, 25}_1}_1 + to_add = ParmN_15 + res = {{3, +, {27, +, 25}_1}_1, +, ParmN_15}_2 + ) + + Then it exercises the add_expr_to_loop_evolution in the following context: + (add_to_evolution + loop_num = 1 + chrec_before = {{3, +, {27, +, 25}_1}_1, +, ParmN_15}_2 + to_add = ParmN_15 * 5 + res = {{3, +, {ParmN_15 * 5 + 27, +, 25}_1}_1, +, ParmN_15}_2 + ) + */ + a += ParmN; + } + } +} + +/* + b -> {2, +, 25}_1 + d -> {-5, +, 1}_2 + a -> {{3, +, {ParmN * 5 + 27, +, 25}_1}_1, +, ParmN}_2 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-40.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-40.c new file mode 100644 index 00000000000..6603a960275 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-40.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main () +{ + int a = 1; + int b = 1; + + while (a) + { + a += b; + b *= 2; + } +} + +/* + b -> {1, *, 2}_1 + a -> {1, +, {1, *, 2}_1}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-41.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-41.c new file mode 100644 index 00000000000..f8c0cd0ca20 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-41.c @@ -0,0 +1,52 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main () +{ + int a = 2; + int b = 4; + int c = 2; + + while (a) + { + a *= 3; + for (c = -10; c < 0; c++) + { + /* Exercises the build_exponential_evolution_in_loop function in the following context: + (multiply_evolution + loop_num = 2 + chrec_before = {2, *, 3}_1 + to_mult = {4, *, 5}_1 + res = {{2, *, 3}_1, *, {4, *, 5}_1}_2 + ) + + Then it exerces the chrec_apply in the following context: + (chrec_apply + var = 2 + chrec = {0, +, {4, *, 5}_1}_2 + x = 10 + res = {40, *, 5}_1 + ) + + Finally it tests the + (add_to_evolution + loop_num = 1 + chrec_before = {{2, *, 3}_1, *, {4, *, 5}_1}_2 + to_add = {40, *, 5}_1 + res = {{2, *, {120, *, 5}_1}_1, *, {4, *, 5}_1}_2 + ) + */ + a *= b; + } + b *= 5; + } +} + +/* + c -> {-10, +, 1}_2 + b -> {4, *, 5}_1 + a -> {{2, *, {120, *, 5}_1}_1, *, {4, *, 5}_1}_2 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-42.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-42.c new file mode 100644 index 00000000000..7b62a712d9e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-42.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main () +{ + int a = 1; + int b = 2; + int c = 0; + int d = 5; + + while (a) + { + a += b; + a += d; + + b += c; + c += 1; + d += 9; + } +} + +/* + c -> {0, +, 1}_1 + b -> {2, +, 0, +, 1}_1 + d -> {5, +, 9}_1 + a -> {1, +, 7, +, 9, +, 1}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-43.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-43.c new file mode 100644 index 00000000000..16ea96731b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-43.c @@ -0,0 +1,64 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + + +int main () +{ + int a = 1; + int b = 2; + int c = 0; + int d = 5; + int e; + + while (a) + { + /* The following statement produces the evolution function: + (add_to_evolution + loop_num = 1 + chrec_before = 1 + to_add = {{2, +, 0}_1, +, 10}_1 + res = {{{1, +, 2}_1, +, 0}_1, +, 10}_1 + ) + Note that the evolution of B in the inner loop_2 is not + relevant to the evolution of A in the loop_1. */ + a += b; + + /* And finally the following statement produces the expected scev: + (add_to_evolution + loop_num = 1 + chrec_before = {{{1, +, 2}_1, +, 0}_1, +, 10}_1 + to_add = {5, +, 9}_1 + res = {{{1, +, 7}_1, +, 9}_1, +, 10}_1 + ) + That ends this not so formal proof ("CQFD" in french ;-). */ + a += d; + + for (e = 0; e < 10; e++) + b += c; + /* After having analyzed this loop, the overall effect is added to the evolution of b. + This corresponds to the following operation: + (add_to_evolution + loop_num = 1 + chrec_before = {2, +, {0, +, 1}_1}_2 + to_add = {0, +, 10}_1 + res = {{{2, +, 0}_1, +, 10}_1, +, {0, +, 1}_1}_2 + ). + Note that the variable c has not yet been updated in the loop, and thus its value + at this version is "{0, +, 1}_1". Since the loop_2 runs exactly 10 times, the overall + effect of the loop is "10 * {0, +, 1}_1": that is the TO_ADD argument. + */ + + c += 1; + d += 9; + } +} + +/* + c -> {0, +, 1}_1 + e -> {0, +, 1}_2 + b -> {{2, +, 0, +, 10}_1, +, {0, +, 1}_1}_2 + d -> {5, +, 9}_1 + a -> {1, +, 7, +, 9, +, 10}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-44.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-44.c new file mode 100644 index 00000000000..1a3099a90a6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-44.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +/* That's a reduced testcase of one of my favourite simulation programs. + This is also known under the name: "Newton's falling apple". + The general version is known under the name: "the N-body simulation problem". + + The physics terminology is the best to describe the scalar evolution algorithm: + - first determine the initial conditions of the system, + - then analyze its evolution. +*/ + +double Newton_s_apple () +{ + /* Initial conditions. */ + double g = -10.0; + double speed_z = 0; + double altitude = 3000; + double delta_t = 0.1; + double total_time = 0; + + /* Laws of evolution. */ + while (altitude > 0.0) + { + speed_z += g * delta_t; + altitude += speed_z * delta_t; + total_time += delta_t; + } + + return total_time; +} + +/* + speed_z -> {0.0, +, -1.0e+0}_1 + altitude -> {3.0e+3, +, {(0.0 + -1.0e+0) * 1.00000000000000005551115123125782702118158340454e-1, +, -1.0e+0 * 1.00000000000000005551115123125782702118158340454e-1}_1}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-45.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-45.c new file mode 100644 index 00000000000..5ece3403a42 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-45.c @@ -0,0 +1,44 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +/* That's a reduced testcase of one of my favourite simulation programs. + This is also known under the name: "Newton's falling apple". + The general version is known under the name: "the N-body simulation problem". + + The physics terminology is the best to describe the scalar evolution algorithm: + - first determine the initial conditions of the system, + - then analyze its evolution. +*/ + +double Newton_s_apple () +{ + /* Initial conditions. */ + double g = 10.0; + double speed_z = 0; + double altitude = 3000; + double delta_t = 0.1; + double total_time = 0; + + /* Laws of evolution. */ + while (altitude > 0.0) + { + speed_z += g * delta_t; + altitude -= speed_z * delta_t; + total_time += delta_t; + } + + return total_time; +} + +/* + speed_z -> {0.0, +, 1.0e+0}_1 + altitude -> {3.0e+3, +, {(0.0 + 1.0e+0) * 1.00000000000000005551115123125782702118158340454e-1 * -1, +, 1.0e+0 * 1.00000000000000005551115123125782702118158340454e-1 * -1}_1}_1 + + When computing evolutions in the "symbolic as long as possible" strategy, + the analyzer extracts only the following: + + altitude -> {3.0e+3, +, T.2_11 * -1}_1 + +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-46.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-46.c new file mode 100644 index 00000000000..6c21ae23d80 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-46.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int +foo (int i, + int precision) +{ + i = precision - i - 1; + + /* At this point the analyzer is confused by the initialisation of "i". + It keeps the initial condition under a symbolic form: "i_1". */ + + while (--i); +} + +/* i -> {i_1, +, -1}_1 */ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-47.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-47.c new file mode 100644 index 00000000000..ea38c59df1b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-47.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int +foo (int unknown_parm, int a, int b) +{ + int p; + + if (unknown_parm) + { + p = a + 2; + } + else + { + p = b + 1; + } + + /* At this point the initial condition of "p" is unknown. + In this case, the analyzer has to keep the initial condition under a symbolic form. */ + + while (p) + p--; + +} + +/* + p -> {p_1, +, -1}_1 + + or, when the Value Range Propagation does its work: + + p -> {[MIN_EXPR <p_4, p_6>, MAX_EXPR <p_4, p_6>], +, -1}_1 + +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-48.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-48.c new file mode 100644 index 00000000000..400f08d7078 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-48.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int +foo (int *c) +{ + int i; + int j = 10; + + for (i = 0; i < 5; i++) + { + for (j = 10;; j--) + { + if (j == 0) + break; + + *(c + j) = *(c + j) - 1; + } + } + + return j; +} + +/* + j -> {10, +, -1}_2 + i -> {0, +, 1}_1 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-49.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-49.c new file mode 100644 index 00000000000..6b911b692b7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-49.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int +foo (int *c) +{ + int i = 0; + int j = 10; + + while (1) + { + if (i == j) + break; + + i++; + j--; + } + + return j; +} + +/* i -> {0, +, 1}_1 */ +/* j -> {10, +, -1}_1 */ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-50.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-50.c new file mode 100644 index 00000000000..3da547ccd11 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-50.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int +foo (int *c) +{ + int i = 0; + int j = 10; + + while (1) + { + /* This case exercises the number of iterations detector for + {0, +, 1}_1 == {10, +, -1}_1 + */ + if (i == j) + break; + + i++; + j--; + } + + return j; +} + +/* FIXME. */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-51.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-51.c new file mode 100644 index 00000000000..b2a92edc474 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-51.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int +foo (int j) +{ + int i = 0; + int temp_var; + + while (i < 100) + { + /* This exercises the analyzer on strongly connected + components: here "i -> temp_var -> i". */ + temp_var = i + j; + i = temp_var + 2; + } + + return i; +} + +/* FIXME. */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-52.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-52.c new file mode 100644 index 00000000000..594a583b645 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-52.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details -fall-data-deps -fdump-tree-ddall" } */ + +int bar (int); + +int foo (void) +{ + int a; + int parm = 11; + int x; + int c[100]; + + for (a = parm; a < 50; a++) + { + /* Array access functions have to be analyzed. */ + x = a + 5; + c[x] = c[x+2] + c[x-1]; + } + bar (c[1]); +} + +/* { dg-final { diff-tree-dumps "ddall" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-52.c.ddall b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-52.c.ddall new file mode 100644 index 00000000000..4c1fc50d97d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-52.c.ddall @@ -0,0 +1,203 @@ + +;; Function foo (foo) + + +(Data Dep (A = 0, B = 0): + (subscript 0: + access_fn_A: {18, +, 1}_1 + access_fn_B: {18, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 0, B = 1): + (subscript 0: + access_fn_A: {18, +, 1}_1 + access_fn_B: {15, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {3, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(3 +) + ) + (Direction Vector: +(+) + ) + +) +(Data Dep (A = 0, B = 2): + (subscript 0: + access_fn_A: {18, +, 1}_1 + access_fn_B: {16, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {2, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(2 +) + ) + (Direction Vector: +(+) + ) + +) +(Data Dep (A = 0, B = 3): (no dependence) + +) +(Data Dep (A = 1, B = 0): + (subscript 0: + access_fn_A: {15, +, 1}_1 + access_fn_B: {18, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {3, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(-3 +) + ) + (Direction Vector: +(-) + ) + +) +(Data Dep (A = 1, B = 1): + (subscript 0: + access_fn_A: {15, +, 1}_1 + access_fn_B: {15, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 1, B = 2): + (subscript 0: + access_fn_A: {15, +, 1}_1 + access_fn_B: {16, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {1, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(-1 +) + ) + (Direction Vector: +(-) + ) + +) +(Data Dep (A = 1, B = 3): (no dependence) + +) +(Data Dep (A = 2, B = 0): + (subscript 0: + access_fn_A: {16, +, 1}_1 + access_fn_B: {18, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {2, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(-2 +) + ) + (Direction Vector: +(-) + ) + +) +(Data Dep (A = 2, B = 1): + (subscript 0: + access_fn_A: {16, +, 1}_1 + access_fn_B: {15, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {1, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(1 +) + ) + (Direction Vector: +(+) + ) + +) +(Data Dep (A = 2, B = 2): + (subscript 0: + access_fn_A: {16, +, 1}_1 + access_fn_B: {16, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 2, B = 3): (no dependence) + +) +(Data Dep (A = 3, B = 0): (no dependence) + +) +(Data Dep (A = 3, B = 1): (no dependence) + +) +(Data Dep (A = 3, B = 2): (no dependence) + +) +(Data Dep (A = 3, B = 3): + (subscript 0: + access_fn_A: 1 + access_fn_B: 1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-53.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-53.c new file mode 100644 index 00000000000..9e36aecca52 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-53.c @@ -0,0 +1,128 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details -fall-data-deps -fdump-tree-ddall" } */ + +#define N 16 + +void fbar (float *); +void ibar (int *); +void sbar (short *); + +/* Should be vectorized */ + +foo (int n) +{ + float a[N+1]; + float b[N]; + float c[N]; + float d[N]; + int ia[N]; + int ib[N]; + int ic[N]; + double da[N]; + double db[N]; + short sa[N]; + short sb[N]; + short sc[N]; + int i,j; + int diff = 0; + char cb[N]; + char cc[N]; + char image[N][N]; + char block[N][N]; + + /* Not vetorizable yet (unknown loop bound). */ + for (i = 0; i < n; i++){ + a[i] = b[i]; + } + fbar (a); + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i]; + } + fbar (a); + + /* Not Vectorizable (mode not supported). */ + for (i = 0; i < N; i++){ + da[i] = db[i]; + } + fbar (a); + + /* Not vetorizable yet (constant assignment). */ + for (i = 0; i < N; i++){ + a[i] = 5; + } + fbar (a); + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i] + d[i]; + } + fbar (a); + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i] * c[i]; + } + fbar (a); + + /* Vectorizable. */ + for (i = 0; i < N/2; i++){ + a[i] = b[i+N/2] * c[i+N/2] - b[i] * c[i]; + d[i] = b[i] * c[i+N/2] + b[i+N/2] * c[i]; + } + fbar (a); + + /* Not vetorizable yet (too conservative dependence test). */ + for (i = 0; i < N/2; i++){ + a[i] = b[i+N/2] * c[i+N/2] - b[i] * c[i]; + a[i+N/2] = b[i] * c[i+N/2] + b[i+N/2] * c[i]; + } + fbar (a); + + /* Not vetorizable yet (access pattern). */ + for (i = 0; i < N/2; i++){ + a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; + d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]; + } + fbar (a); + + /* Not vetorizable yet (too conservative dependence test; access pattern). */ + for (i = 0; i < N/2; i++){ + a[2*i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; + a[2*i+1] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]; + } + fbar (a); + + /* Not vetorizable yet (no support for integer mult). */ + for (i = 0; i < N; i++){ + ia[i] = ib[i] * ic[i]; + } + ibar (ia); + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i]; + d[i] = b[i] + c[i]; + ia[i] = ib[i] + ic[i]; + } + ibar (ia); + fbar (a); + fbar (d); + + /* Not vectorizable yet (two types with different nunits in vector). */ + for (i = 0; i < N; i++){ + ia[i] = ib[i] + ic[i]; + sa[i] = sb[i] + sc[i]; + } + ibar (ia); + sbar (sa); + + /* Not vetorizable yet (too conservative dependence test). */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i]; + a[i+1] = b[i] + c[i]; + } + fbar (a); +} + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-54.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-54.c new file mode 100644 index 00000000000..9dfc15b642f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-54.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int main(void) +{ + int a = 5; + int b = 6; + int c = 20; + + while (a <= 100) + { + int i; + + a = b; + for (i = 0; i <= 12; i++) + { + a++; + } + b = b + c; + } +} + +/* This example has been distilled from Pattern1 that cannot be + handled: "Big steps, small steps" from the ICS'01 paper "Monotonic + Evolution" by Peng Wu. + + The analyzer has to detect the following evolution functions: + i -> {0, +, 1}_2 + b -> {6, +, 20}_1 + a -> {{6, +, 20}_1, +, 1}_2 +*/ + +/* FIXME. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-55.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-55.c new file mode 100644 index 00000000000..796cceb4b50 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-55.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */ + +int main(int argc) +{ + int I, J; + const int N = 30; + const int M = 40; + for (J = argc; J < N; J += 3) + { + for (I = J; I < M; I++) + { + printf ("%d %d\n", I, J); + } + } +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-56.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-56.c new file mode 100644 index 00000000000..ba2b69ca867 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-56.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -ftree-elim-checks -fdump-tree-elck-details -fdump-tree-optimized" } */ + +void remove_me (void); + +int main (void) +{ + int a = -100; + int b = 0; + int c = 3; + + for (a = 0; a < 100; a++) + { + b = b + 3; + if (b != c) + remove_me (); + c = c + 3; + } +} + +/* { dg-final { scan-tree-dump-times "remove_me" 0 "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-57.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-57.c new file mode 100644 index 00000000000..a873b9fc314 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-57.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -ftree-elim-checks -fdump-tree-elck-details -fdump-tree-optimized" } */ + +void remove_me (void); + +int main (void) +{ + int a = -100; + int b = 0; + int c = 3; + + for (a = 0; a < 100; a++) + { + if (b > c) + remove_me (); + b = b + 2; + c = c + 3; + } +} + + +/* { dg-final { scan-tree-dump-times "remove_me" 0 "optimized"} } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-58.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-58.c new file mode 100644 index 00000000000..b0ef757fbb3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-58.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -ftree-elim-checks -fdump-tree-elck-details -fdump-tree-optimized" } */ + +void remove_me (void); + +int main (void) +{ + int a, b; + int N = 100; + + a = 0; + b = 0; + while (a < N) + { + if (b >= 5*N - 4) + remove_me (); + a++; + b+=5; + } +} + +/* { dg-final { scan-tree-dump-times "remove_me" 0 "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-59.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-59.c new file mode 100644 index 00000000000..9d19bdfb19a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-59.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev -fall-data-deps -fdump-tree-ddall" } */ + +extern int foo (float A[100][200]); + +int bar () +{ + int i, j; + float A[100][200]; + + for (i=0; i<5; i++) + for (j=0; j<5; j++) + A[i][j] = A[i+1][j]; + foo (A); + return A[1][2]; +} + +/* { dg-final { diff-tree-dumps "ddall" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-59.c.ddall b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-59.c.ddall new file mode 100644 index 00000000000..44b70258d3d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-59.c.ddall @@ -0,0 +1,275 @@ + +;; Function bar (bar) + + +(Data Dep (A = 0, B = 0): + (subscript 0: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {1, +, 1}_1 + access_fn_B: {1, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 0, B = 1): + (subscript 0: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {1, +, 1}_1 + access_fn_B: {0, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {1, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(1 +) + ) + (Direction Vector: +(=) +(+) + ) + +) +(Data Dep (A = 0, B = 2): + (subscript 0: + access_fn_A: {0, +, 1}_2 + access_fn_B: 2 + iterations_that_access_an_element_twice_in_A: 2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {1, +, 1}_1 + access_fn_B: 1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(-2 +) +(0 +) + ) + (Direction Vector: +(-) +(=) + ) + +) +(Data Dep (A = 1, B = 0): + (subscript 0: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {0, +, 1}_1 + access_fn_B: {1, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {1, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(-1 +) + ) + (Direction Vector: +(=) +(-) + ) + +) +(Data Dep (A = 1, B = 1): + (subscript 0: + access_fn_A: {0, +, 1}_2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {0, +, 1}_1 + access_fn_B: {0, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) +(Data Dep (A = 1, B = 2): + (subscript 0: + access_fn_A: {0, +, 1}_2 + access_fn_B: 2 + iterations_that_access_an_element_twice_in_A: 2 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: {0, +, 1}_1 + access_fn_B: 1 + iterations_that_access_an_element_twice_in_A: 1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(-2 +) +(-1 +) + ) + (Direction Vector: +(-) +(-) + ) + +) +(Data Dep (A = 2, B = 0): + (subscript 0: + access_fn_A: 2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: 1 + access_fn_B: {1, +, 1}_1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(2 +) +(0 +) + ) + (Direction Vector: +(+) +(=) + ) + +) +(Data Dep (A = 2, B = 1): + (subscript 0: + access_fn_A: 2 + access_fn_B: {0, +, 1}_2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 2 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: 1 + access_fn_B: {0, +, 1}_1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(2 +) +(1 +) + ) + (Direction Vector: +(+) +(+) + ) + +) +(Data Dep (A = 2, B = 2): + (subscript 0: + access_fn_A: 2 + access_fn_B: 2 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + + (subscript 1: + access_fn_A: 1 + access_fn_B: 1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) +(0 +) + ) + (Direction Vector: +(=) +(=) + ) + +) + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-60.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-60.c new file mode 100644 index 00000000000..f71561252b0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-60.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev -fall-data-deps -fdump-tree-ddall" } */ + +extern int foo (float A[100]); + +int bar () +{ + int i, j; + float A[100]; + + for (i=0; i<5; i++) + { + A[i * 3] = i + 3; + A[i + 7] = i; + } + + foo (A); + return A[1]; +} + +/* { dg-final { diff-tree-dumps "ddall" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-60.c.ddall b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-60.c.ddall new file mode 100644 index 00000000000..6310edfed42 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-60.c.ddall @@ -0,0 +1,107 @@ + +;; Function bar (bar) + + +(Data Dep (A = 0, B = 0): + (subscript 0: + access_fn_A: {0, +, 3}_1 + access_fn_B: {0, +, 3}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 0, B = 1): + (subscript 0: + access_fn_A: {0, +, 3}_1 + access_fn_B: {7, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {3, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {2, +, 3}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +([-oo, +oo] +) + ) + (Direction Vector: +(*) + ) + +) +(Data Dep (A = 0, B = 2): (no dependence) + +) +(Data Dep (A = 1, B = 0): + (subscript 0: + access_fn_A: {7, +, 1}_1 + access_fn_B: {0, +, 3}_1 + iterations_that_access_an_element_twice_in_A: {2, +, 3}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {3, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +([-oo, +oo] +) + ) + (Direction Vector: +(*) + ) + +) +(Data Dep (A = 1, B = 1): + (subscript 0: + access_fn_A: {7, +, 1}_1 + access_fn_B: {7, +, 1}_1 + iterations_that_access_an_element_twice_in_A: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: {0, +, 1}_1 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) +(Data Dep (A = 1, B = 2): (no dependence) + +) +(Data Dep (A = 2, B = 0): (no dependence) + +) +(Data Dep (A = 2, B = 1): (no dependence) + +) +(Data Dep (A = 2, B = 2): + (subscript 0: + access_fn_A: 1 + access_fn_B: 1 + iterations_that_access_an_element_twice_in_A: 0 + last_iteration_that_access_an_element_twice_in_A: [-oo, +oo] + iterations_that_access_an_element_twice_in_B: 0 + last_iteration_that_access_an_element_twice_in_B: [-oo, +oo] + ) + (Distance Vector: +(0 +) + ) + (Direction Vector: +(=) + ) + +) + diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp b/gcc/testsuite/gcc.dg/tree-ssa-chrec/tree-ssa-scev.exp index 6e3621db3ce..ee8394880ba 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2.exp +++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/tree-ssa-scev.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 1997 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 @@ -22,21 +22,14 @@ load_lib gcc-dg.exp # If a testcase doesn't have special options, use these. global DEFAULT_CFLAGS if ![info exists DEFAULT_CFLAGS] then { - set DEFAULT_CFLAGS " -ansi -pedantic-errors -gdwarf-2" + set DEFAULT_CFLAGS " -ansi -pedantic-errors" } # Initialize `dg'. dg-init # Main loop. -set comp_output [gcc_target_compile \ - "$srcdir/$subdir/../trivial.c" "trivial.S" assembly \ - "additional_flags=-gdwarf-2"] -if { ! [string match "*: target system does not support the * debug format*" \ - $comp_output] } { - dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ - "" $DEFAULT_CFLAGS -} +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" $DEFAULT_CFLAGS # All done. dg-finish diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-1.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-1.c new file mode 100644 index 00000000000..f1fae42e0ef --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-1.c @@ -0,0 +1,101 @@ +/* { dg-do compile { target powerpc*-*-* i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#define N 16 + +void fbar (float *); +void ibar (int *); +void sbar (short *); + +/* multiple loops */ + +foo (int n) +{ + float a[N+1]; + float b[N]; + float c[N]; + float d[N]; + int ia[N]; + int ib[N]; + int ic[N]; + short sa[N]; + short sb[N]; + short sc[N]; + int i,j; + int diff = 0; + char cb[N]; + char cc[N]; + char image[N][N]; + char block[N][N]; + + /* Not vetorizable yet (cross-iteration cycle). */ + diff = 0; + for (i = 0; i < N; i++) { + diff += (cb[i] - cc[i]); + } + ibar (&diff); + + + /* Not vetorizable yet (outer-loop: not attempted. + inner-loop: cross iteration cycle; multi-dimensional arrays). */ + diff = 0; + for (i = 0; i < N; i++) { + for (i = 0; i < N; i++) { + diff += (image[i][j] - block[i][j]); + } + } + ibar (&diff); + + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i]; + } + fbar (a); + + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i] + d[i]; + } + fbar (a); + + + /* Not vetorizable yet (access pattern). */ + for (i = 0; i < N/2; i++){ + a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; + d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]; + } + fbar (a); + + + /* Vectorizable. */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i]; + d[i] = b[i] + c[i]; + ia[i] = ib[i] + ic[i]; + } + ibar (ia); + fbar (a); + fbar (d); + + + /* Not vectorizable yet (two types with different nunits in vector). */ + for (i = 0; i < N; i++){ + ia[i] = ib[i] + ic[i]; + sa[i] = sb[i] + sc[i]; + } + ibar (ia); + sbar (sa); + + + /* Not vetorizable yet (too conservative dependence test). */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i]; + a[i+1] = b[i] + c[i]; + } + fbar (a); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-10.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-10.c new file mode 100644 index 00000000000..7cb6240aea3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-10.c @@ -0,0 +1,27 @@ +/* { dg-do compile { target powerpc*-*-* i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#define N 16 + +short a[N]; +short d[N]; + +int foo () +{ + int i; + short b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + short c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + + + /* Not vetorizable yet (strided access pattern). */ + for (i = 0; i < N/2; i++) + { + a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; + d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]; + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-11.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-11.c new file mode 100644 index 00000000000..907f5b92dac --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-11.c @@ -0,0 +1,51 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 16 + +int main1 () +{ + int i; + int ia[N]; + int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + + /* Not vetorizable yet (integer mult). */ + for (i = 0; i < N; i++) + { + ia[i] = ib[i] * ic[i]; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i] * ic[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-12.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-12.c new file mode 100644 index 00000000000..98db33915ea --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-12.c @@ -0,0 +1,55 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 16 + +int main1 () +{ + int i; + int ia[N]; + int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + short sa[N]; + short sc[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + short sb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + + /* Not vetorizable yet (multiple types with different nunits in vector). */ + for (i = 0; i < N; i++) + { + ia[i] = ib[i] + ic[i]; + sa[i] = sb[i] + sc[i]; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i] + ic[i] || sa[i] != sb[i] + sc[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-13.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-13.c new file mode 100644 index 00000000000..f32451d4d02 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-13.c @@ -0,0 +1,25 @@ +/* { dg-do compile { target powerpc*-*-* i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + + +#define N 16 + +int a[N]; +int results[N] = {0,1,2,3,0,0,0,0,0,0,0,0,12,13,14,15}; + +int main () +{ + int i; + int b[N] = {0,1,2,3,-4,-5,-6,-7,-8,-9,-10,-11,12,13,14,15}; + + /* Not vectorizable yet (condition in loop). */ + for (i = 0; i < N; i++) + { + a[i] = (b[i] >= 0 ? b[i] : 0); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-14.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-14.c new file mode 100644 index 00000000000..6aed7b99b57 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-14.c @@ -0,0 +1,49 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 16 + +int main1 () +{ + int i; + int ia[N]; + + + /* Not vetorizable yet (induction). */ + for ( i = 0; i < N; i++) { + ia[i] = i; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != i) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-15.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-15.c new file mode 100644 index 00000000000..5f0ea5ead9a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-15.c @@ -0,0 +1,50 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 16 + +int main1 () +{ + int i; + int a[N]; + int b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + + /* Not vetorizable yet (reverse access and forward access). */ + for (i = N; i > 0; i--) + { + a[N-i] = b[i-1]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (a[i] != b[N-1-i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-16.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-16.c new file mode 100644 index 00000000000..9818dc4a09e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-16.c @@ -0,0 +1,49 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 16 +#define DIFF 240 + +int main1 () +{ + int i; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + float diff; + + /* Not vetorizable yet (reduction). */ + diff = 0; + for (i = 0; i < N; i++) { + diff += (b[i] - c[i]); + } + + /* check results: */ + if (diff != DIFF) + abort (); + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-17.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-17.c new file mode 100644 index 00000000000..4799dd5a634 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-17.c @@ -0,0 +1,140 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 64 + +int +main1 () +{ + int i; + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = ib[i] & ic[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ia[i] != ib[i] & ic[i]) + abort (); + } + + /* Check chars. */ + + for (i = 0; i < N; i++) + { + ca[i] = cb[i] & cc[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ca[i] != cb[i] & cc[i]) + abort (); + } + + /* Check shorts. */ + + for (i = 0; i < N; i++) + { + sa[i] = sb[i] & sc[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (sa[i] != sb[i] & sc[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-18.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-18.c new file mode 100644 index 00000000000..f66c3d4aca8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-18.c @@ -0,0 +1,139 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 64 + +int +main1 () +{ + int i; + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = (ib[i] | ic[i]); + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ia[i] != (ib[i] | ic[i])) + abort (); + } + + /* Check chars. */ + + for (i = 0; i < N; i++) + { + ca[i] = (cb[i] | cc[i]); + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ca[i] != (cb[i] | cc[i])) + abort (); + } + + /* Check shorts. */ + + for (i = 0; i < N; i++) + { + sa[i] = (sb[i] | sc[i]); + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (sa[i] != (sb[i] | sc[i])) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-19.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-19.c new file mode 100644 index 00000000000..87f1bc41d07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-19.c @@ -0,0 +1,139 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 64 + +int +main1 () +{ + int i; + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = ib[i] ^ ic[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ia[i] != ib[i] ^ ic[i]) + abort (); + } + + /* Check chars. */ + + for (i = 0; i < N; i++) + { + ca[i] = cb[i] ^ cc[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ca[i] != cb[i] ^ cc[i]) + abort (); + } + + /* Check shorts. */ + + for (i = 0; i < N; i++) + { + sa[i] = sb[i] ^ sc[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (sa[i] != sb[i] ^ sc[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-2.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-2.c new file mode 100644 index 00000000000..397519f08a6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-2.c @@ -0,0 +1,50 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 16 + +int main1 () +{ + char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + char ca[N]; + int i; + + for (i = 0; i < N; i++) + { + ca[i] = cb[i]; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ca[i] != cb[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-20.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-20.c new file mode 100644 index 00000000000..10347d10150 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-20.c @@ -0,0 +1,139 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 64 + +int +main1 () +{ + int i; + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = ~ib[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ia[i] != ~ib[i]) + abort (); + } + + /* Check chars. */ + + for (i = 0; i < N; i++) + { + ca[i] = ~cb[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ca[i] != ~cb[i]) + abort (); + } + + /* Check shorts. */ + + for (i = 0; i < N; i++) + { + sa[i] = ~sb[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (sa[i] != ~sb[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-21.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-21.c new file mode 100644 index 00000000000..feea2e5c5f9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-21.c @@ -0,0 +1,140 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 64 + +int +main1 () +{ + int i; + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = !ib[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ia[i] != !ib[i]) + abort (); + } + + /* Check chars. */ + + for (i = 0; i < N; i++) + { + ca[i] = !cb[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ca[i] != !cb[i]) + abort (); + } + + /* Check shorts. */ + + for (i = 0; i < N; i++) + { + sa[i] = !sb[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (sa[i] != !sb[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-22.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-22.c new file mode 100644 index 00000000000..064fbab2333 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-22.c @@ -0,0 +1,140 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 64 + +int +main1 () +{ + int i; + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = -ib[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ia[i] != -ib[i]) + abort (); + } + + /* Check chars. */ + + for (i = 0; i < N; i++) + { + ca[i] = -cb[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ca[i] != -cb[i]) + abort (); + } + + /* Check shorts. */ + + for (i = 0; i < N; i++) + { + sa[i] = -sb[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (sa[i] != -sb[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-23.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-23.c new file mode 100644 index 00000000000..6781ad1caf5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-23.c @@ -0,0 +1,140 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 64 + +int +main1 () +{ + int i; + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = ib[i] && ic[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ia[i] != ib[i] && ic[i]) + abort (); + } + + /* Check chars. */ + + for (i = 0; i < N; i++) + { + ca[i] = cb[i] && cc[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ca[i] != cb[i] && cc[i]) + abort (); + } + + /* Check shorts. */ + + for (i = 0; i < N; i++) + { + sa[i] = sb[i] && sc[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (sa[i] != sb[i] && sc[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-24.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-24.c new file mode 100644 index 00000000000..08f0cff3d75 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-24.c @@ -0,0 +1,140 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 64 + +int +main1 () +{ + int i; + int ia[N]; + int ib[N]= + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + int ic[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char ca[N]; + char cb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + char cc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sa[N]; + short sb[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + short sc[N] = + {1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0, + 1,1,0,0,1,0,1,0}; + + /* Check ints. */ + + for (i = 0; i < N; i++) + { + ia[i] = (ib[i] || ic[i]); + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ia[i] != (ib[i] || ic[i])) + abort (); + } + + /* Check chars. */ + + for (i = 0; i < N; i++) + { + ca[i] = (cb[i] || cc[i]); + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (ca[i] != (cb[i] || cc[i])) + abort (); + } + + /* Check shorts. */ + + for (i = 0; i < N; i++) + { + sa[i] = (sb[i] || sc[i]); + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (sa[i] != (sb[i] || sc[i])) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-25.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-25.c new file mode 100644 index 00000000000..bdfc38367bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-25.c @@ -0,0 +1,66 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 128 + +int main1 (int n, int *p) +{ + int i; + int ib[N]; + int ia[N]; + int k; + + for (i = 0; i < N; i++) + { + ia[i] = n; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != n) + abort (); + } + + k = *p; + for (i = 0; i < N; i++) + { + ib[i] = k; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ib[i] != k) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + int m = 8; + + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (m, &m); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect"} } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-26.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-26.c new file mode 100644 index 00000000000..9afe6a27aaa --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-26.c @@ -0,0 +1,51 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 128 + +/* unaligned store. */ + +int main1 () +{ + int i; + int ia[N+1]; + + for (i = 1; i <= N; i++) + { + ia[i] = 5; + } + + /* check results: */ + for (i = 1; i <= N; i++) + { + if (ia[i] != 5) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-27.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-27.c new file mode 100644 index 00000000000..42f55fdb6bc --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-27.c @@ -0,0 +1,57 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 128 + +/* unaligned load. */ + +int main1 () +{ + int i; + int ia[N]; + int ib[N+1]; + + for (i=0; i < N; i++) + { + ib[i] = i; + } + + for (i = 1; i <= N; i++) + { + ia[i-1] = ib[i]; + } + + /* check results: */ + for (i = 1; i <= N; i++) + { + if (ia[i-1] != ib[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-28.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-28.c new file mode 100644 index 00000000000..2154aeb9f93 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-28.c @@ -0,0 +1,54 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 128 +#define OFF 3 + +/* unaligned store. */ + +int main1 (int off) +{ + int i; + int ia[N+OFF]; + + for (i = 0; i < N; i++) + { + ia[i+off] = 5; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i+off] != 5) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + main1 (0); /* aligned */ + main1 (OFF); /* unaligned */ + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-29.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-29.c new file mode 100644 index 00000000000..98dfa585bb2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-29.c @@ -0,0 +1,60 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 128 +#define OFF 3 + +/* unaligned load. */ + +int main1 (int off) +{ + int i; + int ia[N]; + int ib[N+OFF]; + + for (i = 0; i < N+OFF; i++) + { + ib[i] = i; + } + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + main1 (0); /* aligned */ + main1 (OFF); /* unaligned */ + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-3.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-3.c new file mode 100644 index 00000000000..0a0d8231d27 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-3.c @@ -0,0 +1,63 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 20 + +int +main1 () +{ + int i; + float a[N]; + float e[N]; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; + int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ia[N]; + + for (i = 0; i < N; i++) + { + a[i] = b[i] + c[i] + d[i]; + e[i] = b[i] + c[i] + d[i]; + ia[i] = ib[i] + ic[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + float fres = b[i] + c[i] + d[i]; + int ires = ib[i] + ic[i]; + if (a[i] != fres || e[i] != fres || ia[i] != ires) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"} } */ + + + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-4.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-4.c new file mode 100644 index 00000000000..698e8a1b3c1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-4.c @@ -0,0 +1,51 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 20 + +int +main1 () +{ + int i; + float a[N]; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + + for (i = 0; i < N; i++) + { + a[i] = b[i] * c[i]; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (a[i] != b[i] * c[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-5.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-5.c new file mode 100644 index 00000000000..d5445c8c119 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-5.c @@ -0,0 +1,69 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 16 + +int main1 () +{ + int i, j; + float a[N]; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; + + i = 0; + j = 0; + while (i < 5*N) + { + a[j] = c[j]; + i += 5; + j++; + } + + /* check results: */ + for (i = 0; i <N; i++) + { + if (a[i] != c[i]) + abort (); + } + + + for (i = N; i > 0; i--) + { + a[N-i] = d[N-i]; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (a[i] != d[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-6.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-6.c new file mode 100644 index 00000000000..3a40503e1ff --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-6.c @@ -0,0 +1,71 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 16 + +float results1[N] = {192.00,240.00,288.00,336.00,384.00,432.00,480.00,528.00,0.00}; +float results2[N] = {0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,54.00,120.00,198.00,288.00,390.00,504.00,630.00}; + +int main1 () +{ + int i; + float a[N] = {0}; + float e[N] = {0}; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + + for (i = 0; i < N/2; i++) + { + a[i] = b[i+N/2] * c[i+N/2] - b[i] * c[i]; + e[i+N/2] = b[i] * c[i+N/2] + b[i+N/2] * c[i]; + } + + for (i=0; i<N; i++) + { + if (a[i] != results1[i] || e[i] != results2[i]) + abort(); + } + + /* check results: */ + + for (i = 1; i <=N-4; i++) + { + a[i+3] = b[i-1]; + } + + /* check results: */ + for (i = 1; i <=N-4; i++) + { + if (a[i+3] != b[i-1]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ + + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-7.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-7.c new file mode 100644 index 00000000000..d54ef642d1d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-7.c @@ -0,0 +1,64 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 128 + +int main1 () +{ + int i; + short sa[N]; + short sb[N]; + + for (i = 0; i < N; i++) + { + sb[i] = 5; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (sb[i] != 5) + abort (); + } + + for (i = 0; i < N; i++) + { + sa[i] = sb[i] + 100; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (sa[i] != 105) + abort (); + } + + return 0; +} + + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect"} } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-8.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-8.c new file mode 100644 index 00000000000..e66718f77ef --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-8.c @@ -0,0 +1,50 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 16 + +float b[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; +float a[N]; + +int main1 (int n) +{ + int i; + + /* Not vetorizable yet (unknown loop bound). */ + for (i = 0; i < n; i++){ + a[i] = b[i]; + } + + /* check results: */ + for (i = 0; i < n; i++) + { + if (a[i] != b[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (N); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-9.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-9.c new file mode 100644 index 00000000000..939e265d539 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-9.c @@ -0,0 +1,50 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 16 + +int main1 () +{ + int i; + short sb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ia[N]; + + /* Not vetorizable yet (type cast). */ + for (i = 0; i < N; i++) + { + ia[i] = (int) sb[i]; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != (int) sb[i]) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-all.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-all.c new file mode 100644 index 00000000000..2c3fee0cf2a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-all.c @@ -0,0 +1,228 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#include <stdarg.h> +#include <signal.h> + +#define N 16 + +int iadd_results[N] = {0,6,12,18,24,30,36,42,48,54,60,66,72,78,84,90}; +float fadd_results[N] = {0.0,6.0,12.0,18.0,24.0,30.0,36.0,42.0,48.0,54.0,60.0,66.0,72.0,78.0,84.0,90.0}; +float fmul_results[N] = {0.0,3.0,12.0,27.0,48.0,75.0,108.0,147.0,192.0,243.0,300.0,363.0,432.0,507.0,588.0,675.0}; +float fresults1[N] = {192.00,240.00,288.00,336.00,384.00,432.00,480.00,528.00,48.00,54.00,60.00,66.00,72.00,78.00,84.00,90.00}; +float fresults2[N] = {0.00,6.00,12.00,18.00,24.00,30.00,36.00,42.00,0.00,54.00,120.00,198.00,288.00,390.00,504.00,630.00}; + +/****************************************************/ +void icheck_results (int *a, int *results) +{ + int i; + for (i = 0; i < N; i++) + { + if (a[i] != results[i]) + abort (); + } +} + +void fcheck_results (float *a, float *results) +{ + int i; + for (i = 0; i < N; i++) + { + if (a[i] != results[i]) + abort (); + } +} + +void +fbar_mul (float *a) +{ + fcheck_results (a, fmul_results); +} + +void +fbar_add (float *a) +{ + fcheck_results (a, fadd_results); +} + +void +ibar_add (int *a) +{ + icheck_results (a, iadd_results); +} + +void +fbar1 (float *a) +{ + fcheck_results (a, fresults1); +} + +void +fbar2 (float *a) +{ + fcheck_results (a, fresults2); +} + + +/* All of the loops below are currently vectorizable. */ + +int +main1 () +{ + int i,j; + float a[N]; + float e[N]; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; + int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ia[N]; + char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + char ca[N]; + short sa[N]; + + /* Test 1: copy chars. */ + for (i = 0; i < N; i++) + { + ca[i] = cb[i]; + } + /* check results: */ + for (i = 0; i < N; i++) + { + if (ca[i] != cb[i]) + abort (); + } + + + /* Test 2: fp mult. */ + for (i = 0; i < N; i++) + { + a[i] = b[i] * c[i]; + } + fbar_mul (a); + + + /* Test 3: mixed types (int, fp), same nunits in vector. */ + for (i = 0; i < N; i++) + { + a[i] = b[i] + c[i] + d[i]; + e[i] = b[i] + c[i] + d[i]; + ia[i] = ib[i] + ic[i]; + } + ibar_add (ia); + fbar_add (a); + fbar_add (e); + + + /* Test 4: access with offset. */ + for (i = 0; i < N/2; i++) + { + a[i] = b[i+N/2] * c[i+N/2] - b[i] * c[i]; + e[i+N/2] = b[i] * c[i+N/2] + b[i+N/2] * c[i]; + } + fbar1 (a); + fbar2 (e); + + + /* Test 5: access with offset */ + for (i = 1; i <=N-4; i++) + { + a[i+3] = b[i-1]; + } + /* check results: */ + for (i = 1; i <=N-4; i++) + { + if (a[i+3] != b[i-1]) + abort (); + } + + + /* Test 6 - loop induction with stride != 1. */ + i = 0; + j = 0; + while (i < 5*N) + { + a[j] = c[j]; + i += 5; + j++; + } + /* check results: */ + for (i = 0; i <N; i++) + { + if (a[i] != c[i]) + abort (); + } + + + /* Test 7 - reverse access. */ + for (i = N; i > 0; i--) + { + a[N-i] = d[N-i]; + } + /* check results: */ + for (i = 0; i <N; i++) + { + if (a[i] != d[i]) + abort (); + } + + + /* Tests 8,9,10 - constants. */ + for (i = 0; i < N; i++) + { + a[i] = 5.0; + } + /* check results: */ + for (i = 0; i < N; i++) + { + if (a[i] != 5.0) + abort (); + } + + for (i = 0; i < N; i++) + { + sa[i] = 5; + } + /* check results: */ + for (i = 0; i < N; i++) + { + if (sa[i] != 5) + abort (); + } + + for (i = 0; i < N; i++) + { + ia[i] = ib[i] + 5; + } + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i] + 5) + abort (); + } + + return 0; +} + +void +sig_ill_handler (int sig) +{ + exit(0); +} + +int main (void) +{ + /* Exit on systems without altivec. */ + signal (SIGILL, sig_ill_handler); + /* Altivec instruction, 'vor %v0,%v0,%v0'. */ + asm volatile (".long 0x10000484"); + signal (SIGILL, SIG_DFL); + + return main1 (); +} + + +/* { dg-final { scan-tree-dump-times "vectorized 10 loops" 1 "vect"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-none.c b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-none.c new file mode 100644 index 00000000000..2d90a15b9b5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect-none.c @@ -0,0 +1,190 @@ +/* { dg-do compile { target powerpc*-*-* i?86-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */ +/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* } } */ + +#define N 16 + +int iadd_results[N] = {0,6,12,18,24,30,36,42,48,54,60,66,72,78,84,90}; +float fadd_results[N] = {0.0,6.0,12.0,18.0,24.0,30.0,36.0,42.0,48.0,54.0,60.0,66.0,72.0,78.0,84.0,90.0}; +float fmul_results[N] = {0.0,3.0,12.0,27.0,48.0,75.0,108.0,147.0,192.0,243.0,300.0,363.0,432.0,507.0,588.0,675.0}; +float fresults1[N] = {192.00,240.00,288.00,336.00,384.00,432.00,480.00,528.00,48.00,54.00,60.00,66.00,72.00,78.00,84.00,90.00}; +float fresults2[N] = {0.00,6.00,12.00,18.00,24.00,30.00,36.00,42.00,0.00,54.00,120.00,198.00,288.00,390.00,504.00,630.00}; + +/****************************************************/ +void icheck_results (int *a, int *results) +{ + int i; + for (i = 0; i < N; i++) + { + if (a[i] != results[i]) + abort (); + } +} + +void fcheck_results (float *a, float *results) +{ + int i; + for (i = 0; i < N; i++) + { + if (a[i] != results[i]) + abort (); + } +} + +void +fbar_mul (float *a) +{ + fcheck_results (a, fmul_results); +} + +void +fbar_add (float *a) +{ + fcheck_results (a, fadd_results); +} + +void +ibar_add (int *a) +{ + icheck_results (a, iadd_results); +} + +void +fbar1 (float *a) +{ + fcheck_results (a, fresults1); +} + +void +fbar2 (float *a) +{ + fcheck_results (a, fresults2); +} + + +/* None of the loops below is currently vectorizable. The vectorizer will + be enhanced to vectorize most of these loops. */ + +int +foo (int n) +{ + int i,j; + float a[N]; + float e[N]; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; + short sc[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + short sb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + short sa[N]; + int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int ia[N]; + int diff = 0; + char cb[N]; + char cc[N]; + char image[N][N]; + char block[N][N]; + + + /* Test 1 - unknown loop bound. */ + for (i = 0; i < n; i++) + { + a[i] = b[i]; + } + fbar (a); + + + /* Test 2 - type cast. */ + for (i = 0; i < N; i++) + { + ia[i] = (int) sb[i]; + } + fbar (a); + + + /* Test 3 - strided access pattern. */ + for (i = 0; i < N/2; i++) + { + a[i] = b[2*i+1] * c[2*i+1] - b[2*i] * c[2*i]; + d[i] = b[2*i] * c[2*i+1] + b[2*i+1] * c[2*i]; + } + fbar (a); + + + /* Test 4 - no target support for integer mult. */ + for (i = 0; i < N; i++) + { + ia[i] = ib[i] * ic[i]; + } + ibar (ia); + + + /* Test 5 - two types with different nunits in vector. */ + for (i = 0; i < N; i++) + { + ia[i] = ib[i] + ic[i]; + sa[i] = sb[i] + sc[i]; + } + ibar (ia); + sbar (sa); + + + /* Test 6 - too conservative dependence test. */ + for (i = 0; i < N; i++){ + a[i] = b[i] + c[i]; + a[i+1] = b[i] + c[i]; + } + fbar (a); + + + /* Test 7 - condition in loop. */ + for (i = 0; i < N; i++){ + a[i] = (b[i] > 0 ? b[i] : 0); + } + fbar (a); + + + /* Test 8 - cross-iteration cycle. */ + diff = 0; + for (i = 0; i < N; i++) { + diff += (cb[i] - cc[i]); + } + ibar (&diff); + + + /* Test 9 - outer-loop not attempted; inner-loop has cross + iteration cycle and multi-dimensional arrays. */ + diff = 0; + for (i = 0; i < N; i++) { + for (i = 0; i < N; i++) { + diff += (image[i][j] - block[i][j]); + } + } + ibar (&diff); + + + /* Test 10 - induction. */ + for ( i = 0; i < N; i++) { + a[i] = i; + } + fbar (a); + + + /* Test 11 - reverse access and forward access. */ + for (i = N; i > 0; i--) + { + a[N-i] = b[i-1]; + } + /* check results: */ + for (i = 0; i <N; i++) + { + if (a[i] != b[N-1-i]) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorized " 3 "vect"} } */ +/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 3 "vect"} } */ diff --git a/gcc/testsuite/gcc.dg/charset/charset.exp b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect.exp index ad75cb55af8..ee8394880ba 100644 --- a/gcc/testsuite/gcc.dg/charset/charset.exp +++ b/gcc/testsuite/gcc.dg/tree-ssa-vect/tree-ssa-vect.exp @@ -1,44 +1,35 @@ -# Copyright (C) 2004 Free Software Foundation, Inc. +# Copyright (C) 1997 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 2 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 this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# GCC testsuite that uses the 'dg.exp' driver. - -# There's a bunch of headers we need. -if [is_remote host] { - foreach header [glob -nocomplain $srcdir/$subdir/*.{h,def} ] { - remote_download host $header - } -} +# GCC testsuite that uses the `dg.exp' driver. # Load support procs. load_lib gcc-dg.exp -load_lib target-supports.exp # If a testcase doesn't have special options, use these. -global DEFAULT_CHARSETCFLAGS -if ![info exists DEFAULT_CHARSETCFLAGS] then { - set DEFAULT_CHARSETCFLAGS "-fexec-charset=IBM-1047" +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" } # Initialize `dg'. dg-init # Main loop. -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,S} ]] \ - "" $DEFAULT_CHARSETCFLAGS +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" $DEFAULT_CFLAGS # All done. dg-finish diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20030711-1.c b/gcc/testsuite/gcc.dg/tree-ssa/20030711-1.c index eba207a25e5..c51c4fe5925 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/20030711-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/20030711-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O1 -fdump-tree-dom3" } */ +/* { dg-options "-O1 -fdump-tree-dom3 -ftree-loop-optimize" } */ union tree_node; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20030714-2.c b/gcc/testsuite/gcc.dg/tree-ssa/20030714-2.c index 6a43360b07f..76f7b62d469 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/20030714-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/20030714-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O1 -fdump-tree-dom3" } */ +/* { dg-options "-O1 -fdump-tree-dom3 -ftree-loop-optimize" } */ union tree_node; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040308-1.c b/gcc/testsuite/gcc.dg/tree-ssa/20040308-1.c new file mode 100644 index 00000000000..59397d8cbb1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/20040308-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-phiopt1-details" } */ + +int t( int i) +{ + int j; + if(i ==0) + j = 1; + else + j = 0; + + + return j; +} + +/* We should convert one COND_EXPRs into straightline code. */ +/* { dg-final { scan-tree-dump-times "straightline" 1 "phiopt1" {xfail *-*-* } } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040308-2.c b/gcc/testsuite/gcc.dg/tree-ssa/20040308-2.c new file mode 100644 index 00000000000..3d2daae6f47 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/20040308-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt1-details -fdump-tree-tailc-details" } */ + + +int f(int i) +{ + int result; + result = t(i); + if (result) + return result; + return 0; +} + +/* We should convert one COND_EXPRs into straightline code. */ +/* { dg-final { scan-tree-dump-times "straightline" 1 "phiopt1" } } */ +/* Also we should have found that the call to t is tail called. */ +/* { dg-final { scan-tree-dump-times "Found tail call" 1 "tailc" } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040308-3.c b/gcc/testsuite/gcc.dg/tree-ssa/20040308-3.c new file mode 100644 index 00000000000..86f003f127a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/20040308-3.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-phiopt1-details" } */ + +int t( int i) +{ + int j; + if(i>=0) + j = i; + else + j = -i; + return j; +} + +/* We should convert one COND_EXPRs into straightline code with ABS. */ +/* { dg-final { scan-tree-dump-times "straightline" 1 "phiopt1"} } */ +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 1 "phiopt1"} } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040308-4.c b/gcc/testsuite/gcc.dg/tree-ssa/20040308-4.c new file mode 100644 index 00000000000..ac85077551f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/20040308-4.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-phiopt1-details" } */ + +int t( int i, int k) +{ + int j; + if(i!=k) + j = i; + else + j = k; + + return j; +} + +/* We should convert one COND_EXPRs into straightline code. */ +/* { dg-final { scan-tree-dump-times "straightline" 1 "phiopt1"} } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-headers.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-headers.c index efe831beab5..eb03840e770 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/copy-headers.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-headers.c @@ -1,15 +1,18 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-ch-details" } */ +/* { dg-options "-O2 -fdump-tree-dom1 -ftree-loop-optimize" } */ -extern int foo (int); +extern void link_error (void); void bla (void) { - int i, n = foo (0); + int i, j = 1; - for (i = 0; i < n; i++) - foo (i); + for (i = 0; i < 100; i++) + j = 0; + + if (j) + link_error (); } -/* There should be a header scheduled for duplication. */ -/* { dg-final { scan-tree-dump-times "Scheduled" 1 "ch"} } */ +/* There should be no link_error call in the dom1 dump. */ +/* { dg-final { scan-tree-dump-times "link_error" 0 "dom1"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ivcanon-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ivcanon-1.c new file mode 100644 index 00000000000..430a9514ca5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ivcanon-1.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-optimize -fscalar-evolutions -funroll-loops -fdump-tree-optimized" } */ + +void foo(void) +{ + int n = 16875; + + while (n) + { + if (n&1) + bar (n); + n >>= 1; + } +} + +static inline int power (long x, unsigned int n) +{ + long y = n % 2 ? x : 1; + + while (n >>= 1) + { + x = x * x; + if (n % 2) + y = y * x; + } + + return y; +} + +void test(long x) +{ + bar (power (x, 10)); + bar (power (x, 27)); +} + +/* All loops should be completely unrolled, so there should be no labels. */ +/* { dg-final { scan-tree-dump-times "<L" 0 "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/typespec-1.c b/gcc/testsuite/gcc.dg/typespec-1.c index 1acaaf73676..a0e0c1a9992 100644 --- a/gcc/testsuite/gcc.dg/typespec-1.c +++ b/gcc/testsuite/gcc.dg/typespec-1.c @@ -11,7 +11,8 @@ not requiring -pedantic. */ /* Origin: Joseph Myers <jsm28@cam.ac.uk> */ /* { dg-do compile } */ -/* { dg-options "-std=gnu99" } */ +/* APPLE LOCAL -Wlong-double */ +/* { dg-options "-std=gnu99 -Wno-long-double" } */ typedef char type; void *x0; diff --git a/gcc/testsuite/gcc.dg/va-arg-2.c b/gcc/testsuite/gcc.dg/va-arg-2.c index 2e2849c1528..5140545f121 100644 --- a/gcc/testsuite/gcc.dg/va-arg-2.c +++ b/gcc/testsuite/gcc.dg/va-arg-2.c @@ -6,7 +6,10 @@ #include <varargs.h> /* { dg-bogus "varargs.h" "missing file" } */ /* { dg-error "" "In file included from" { target *-*-* } 6 } */ -/* { dg-error "no longer implements" "#error 1" { target *-*-* } 4 } */ -/* { dg-error "Revise your code" "#error 2" { target *-*-* } 5 } */ + +/* APPLE LOCAL BEGIN - varargs.h changes to line numbers hartoog@apple.com */ +/* { dg-error "no longer implements" "#error 1" { target *-*-* } 10 } */ +/* { dg-error "Revise your code" "#error 2" { target *-*-* } 11 } */ +/* APPLE LOCAL END - varargs.h changes to line numbers hartoog@apple.com */ int x; /* prevent empty-source-file warning */ diff --git a/gcc/testsuite/gcc.dg/verbose-asm-2.c b/gcc/testsuite/gcc.dg/verbose-asm-2.c new file mode 100644 index 00000000000..4a8b1b45972 --- /dev/null +++ b/gcc/testsuite/gcc.dg/verbose-asm-2.c @@ -0,0 +1,13 @@ +/* APPLE LOCAL entire file */ +/* Test whether -fverbose-asm emits option values. */ +/* Contibuted by Devang Patel <dpatel@apple.com>. */ + +/* { dg-do compile } */ +/* { dg-options "-fverbose-asm" } */ +/* { dg-final { scan-assembler "fpeephole=0" } } */ + +int +main (int argc, char *argv []) +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/wtr-conversion-1.c b/gcc/testsuite/gcc.dg/wtr-conversion-1.c index 18d26165f2a..b133ff1e8c4 100644 --- a/gcc/testsuite/gcc.dg/wtr-conversion-1.c +++ b/gcc/testsuite/gcc.dg/wtr-conversion-1.c @@ -2,7 +2,8 @@ Note, gcc should omit these warnings in system header files. By Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 4/09/2001. */ /* { dg-do compile } */ -/* { dg-options "-Wtraditional" } */ +/* APPLE LOCAL -Wlong-double */ +/* { dg-options "-Wtraditional -Wno-long-double" } */ extern void foo_i (int); extern void foo_f (float); |