diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/tree-ssa')
19 files changed, 406 insertions, 10 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20031106-6.c b/gcc/testsuite/gcc.dg/tree-ssa/20031106-6.c index 56d1887b..c7e0088 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/20031106-6.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/20031106-6.c @@ -1,5 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-O1 -fno-tree-sra -fdump-tree-optimized" } */ +/* { dg-options "-O1 -fno-tree-sra -fdump-tree-optimized -fdump-tree-forwprop1-details" } */ + +/* PR tree-optimization/14295 */ extern void link_error (void); @@ -25,4 +27,6 @@ struct s foo (struct s r) /* There should be no references to any of "temp_struct*" temporaries. */ -/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" } } */ +/* Also check that forwprop pass did the copy prop. */ +/* { dg-final { scan-tree-dump-times "after previous" 3 "forwprop1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c index 4144d1c..f43018d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O1 -fdump-tree-optimized" } */ -/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ +/* { dg-additional-options "-msse2 -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ /* PR tree-optimization/109829 */ float abs_f(float x) { return __builtin_signbit(x) ? x : -x; } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c b/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c index dbde681..efb53f1 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O -fdump-tree-backprop-details" } */ -/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ +/* { dg-additional-options "-msse2 -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ void start (void *); void end (void *); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/cswtch-6.c b/gcc/testsuite/gcc.dg/tree-ssa/cswtch-6.c new file mode 100644 index 0000000..d765a03 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/cswtch-6.c @@ -0,0 +1,43 @@ +/* PR tree-optimization/120451 */ +/* { dg-do compile { target elf } } */ +/* { dg-options "-O2" } */ + +void foo (int, int); + +__attribute__((noinline, noclone)) void +f1 (int v, int w) +{ + int i, j; + if (w) + { + i = 129; + j = i - 1; + goto lab; + } + switch (v) + { + case 170: + j = 7; + i = 27; + break; + case 171: + i = 8; + j = 122; + break; + case 172: + i = 21; + j = -19; + break; + case 173: + i = 18; + j = 17; + break; + default: + __builtin_abort (); + } + + lab: + foo (i, j); +} + +/* { dg-final { scan-assembler ".rodata.cst16" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-41.c b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-41.c index a1f0828..1c5b500 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-41.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-41.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-optimized -Wno-psabi -w" } */ +/* { dg-additional-options "-msse" { target i?86-*-* x86_64-*-* } } */ #define vector __attribute__((__vector_size__(16) )) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ifcvt-fix-trunc-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ifcvt-fix-trunc-1.c new file mode 100644 index 0000000..801a53f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ifcvt-fix-trunc-1.c @@ -0,0 +1,19 @@ + /* { dg-do compile } */ + /* { dg-options "-O2 -ftree-vectorize -fdump-tree-ifcvt-stats" } */ + +void +test (int *dst, float *arr, int *pred, int n) +{ + for (int i = 0; i < n; i++) + { + int pred_i = pred[i]; + float arr_i = arr[i]; + + dst[i] = pred_i ? (int)arr_i : 5; + } +} + +/* We expect this to fail if_convertible_loop_p so long as we have no + conditional IFN for FIX_TRUNC_EXPR. */ + +/* { dg-final { scan-tree-dump-times "Applying if-conversion" 0 "ifcvt" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ifcvt-fix-trunc-2.c b/gcc/testsuite/gcc.dg/tree-ssa/ifcvt-fix-trunc-2.c new file mode 100644 index 0000000..628b754 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ifcvt-fix-trunc-2.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize -fno-trapping-math -fdump-tree-ifcvt-stats" } */ + +#include "ifcvt-fix-trunc-1.c" + +/* { dg-final { scan-tree-dump-times "Applying if-conversion" 1 "ifcvt" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phiprop-2.c b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-2.c new file mode 100644 index 0000000..ae0d181 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-2.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-phiopt1 -fdump-tree-phiprop1-details" } */ + +/* PR tree-optimization/116824 */ + +int g(int i, int *tt) +{ + const int t = 10; + const int *a; + { + if (t < i) + { + *tt = 1; + a = &t; + } + else + { + *tt = 1; + a = &i; + } + } + return *a; +} + +/* Check that phiprop1 can do the insert of the loads. */ +/* { dg-final { scan-tree-dump-times "Inserting PHI for result of load" 1 "phiprop1"} } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR " 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr108358-a.c b/gcc/testsuite/gcc.dg/tree-ssa/pr108358-a.c new file mode 100644 index 0000000..342e1c1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr108358-a.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fdump-tree-optimized" } */ + +/* PR tree-optimization/108358 */ + +struct a { + int b; + int c; + short d; + int e; + int f; +}; +struct g { + struct a f; + struct a h; +}; +int i; +void foo(); +void bar31_(void); +int main() { + struct g j, l = {2, 1, 6, 1, 1, 7, 5, 1, 0, 1}; + for (; i; ++i) + bar31_(); + j = l; + struct g m = j; + struct g k = m; + if (k.h.b) + ; + else + foo(); +} +/* The call to foo should be optimized away. */ +/* { dg-final { scan-tree-dump-not "foo " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr114169-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr114169-1.c new file mode 100644 index 0000000..37766fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr114169-1.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop-details -fdump-tree-optimized" } */ + + +/* PR tree-optimization/114169 */ + +#include <stdint.h> + +struct S1 { + uint32_t f0; + uint8_t f1; + uint64_t f2; + uint64_t f3; + int32_t f4; +}; + +union U8 { + struct S1 f0; + int32_t f1; + int64_t f2; + uint8_t f3; + const int64_t f4; +}; + +/* --- GLOBAL VARIABLES --- */ +struct S1 g_16 = {4294967293UL,1UL,1UL,0xA9C1C73B017290B1LL,0x5ADF851FL}; +union U8 g_37 = {{1UL,1UL,0x2361AE7D51263067LL,0xEEFD7F9B64A47447LL,0L}}; +struct S1 g_50 = {0x0CFC2012L,1UL,0x43E1243B3BE7B8BBLL,0x03C5CEC10C1A6FE1LL,1L}; + + +/* --- FORWARD DECLARATIONS --- */ + +void func_32(union U8 e) { + e.f3 = e.f0.f4; + g_16 = e.f0 = g_50; +} +/* The union e should not make a difference here. */ +/* { dg-final { scan-tree-dump-times "after previous" 1 "forwprop1" } } */ +/* { dg-final { scan-tree-dump "g_16 = g_50;" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr120231-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr120231-1.c new file mode 100644 index 0000000..c1ce44f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr120231-1.c @@ -0,0 +1,67 @@ +/* PR tree-optimization/120231 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-add-options float32 } */ +/* { dg-add-options float64 } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float32 } */ +/* { dg-require-effective-target float64 } */ +/* { dg-require-effective-target float128 } */ +/* { dg-final { scan-tree-dump-not "link_failure \\\(\\\);" "optimized" } } */ + +void link_failure (void); + +void +foo (_Float64 x) +{ + if (x >= -64.0f64 && x <= 0x1.p+140f64) + { + _Float32 z = x; + _Float128 w = z; + _Float128 v = x; + if (__builtin_isnan (z) + || __builtin_isnan (w) + || __builtin_isnan (v) + || z < -64.0f32 + || w < -64.0f128 + || __builtin_isinf (v) + || v < -64.0f128 + || v > 0x1.p+140f128) + link_failure (); + } +} + +void +bar (_Float64 x) +{ + _Float32 z = x; + if (z >= -64.0f32 && z <= 0x1.p+38f32) + { + if (__builtin_isnan (x) + || __builtin_isinf (x) + || x < -0x1.000001p+6f64 + || x > 0x1.000001p+38f64) + link_failure (); + } +} + +void +baz (_Float64 x) +{ + _Float128 w = x; + if (w >= -64.0f128 && w <= 0x1.p+1026f128) + { + if (__builtin_isnan (x) + || __builtin_isinf (x) + || x < -64.0f64) + link_failure (); + } + if (w >= 128.25f128 && w <= 0x1.p+1020f128) + { + if (__builtin_isnan (x) + || __builtin_isinf (x) + || x < 128.25f64 + || x > 0x1.p+1020f64) + link_failure (); + } +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr120231-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr120231-2.c new file mode 100644 index 0000000..d2b41ba --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr120231-2.c @@ -0,0 +1,107 @@ +/* PR tree-optimization/120231 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-add-options float64 } */ +/* { dg-require-effective-target float64 } */ +/* { dg-final { scan-tree-dump-not "link_failure \\\(\\\);" "optimized" } } */ + +void link_failure (void); + +static _Float64 __attribute__((noinline)) +f1 (signed char x) +{ + return x; +} + +static _Float64 __attribute__((noinline)) +f2 (signed char x) +{ + if (x >= -37 && x <= 42) + return x; + return 0.0f64; +} + +void +f3 (signed char x) +{ + _Float64 y = f1 (x); + if (y < (_Float64) (-__SCHAR_MAX__ - 1) || y > (_Float64) __SCHAR_MAX__) + link_failure (); + y = f2 (x); + if (y < -37.0f64 || y > 42.0f64) + link_failure (); +} + +static _Float64 __attribute__((noinline)) +f4 (long long x) +{ + return x; +} + +static _Float64 __attribute__((noinline)) +f5 (long long x) +{ + if (x >= -0x3ffffffffffffffeLL && x <= 0x3ffffffffffffffeLL) + return x; + return 0.0f64; +} + +void +f6 (long long x) +{ + _Float64 y = f4 (x); + if (y < (_Float64) (-__LONG_LONG_MAX__ - 1) || y > (_Float64) __LONG_LONG_MAX__) + link_failure (); + y = f5 (x); + if (y < (_Float64) -0x3ffffffffffffffeLL || y > (_Float64) 0x3ffffffffffffffeLL) + link_failure (); +} + +static signed char __attribute__((noinline)) +f7 (_Float64 x) +{ + if (x >= -78.5f64 && x <= 98.25f64) + return x; + return 0; +} + +static unsigned char __attribute__((noinline)) +f8 (_Float64 x) +{ + if (x >= -0.75f64 && x <= 231.625f64) + return x; + return 31; +} + +static long long __attribute__((noinline)) +f9 (_Float64 x) +{ + if (x >= -3372587051122780362.75f64 && x <= 3955322825938799366.25f64) + return x; + return 0; +} + +static unsigned long long __attribute__((noinline)) +f10 (_Float64 x) +{ + if (x >= 31.25f64 && x <= 16751991430751148048.125f64) + return x; + return 4700; +} + +void +f11 (_Float64 x) +{ + signed char a = f7 (x); + if (a < -78 || a > 98) + link_failure (); + unsigned char b = f8 (x); + if (b > 231) + link_failure (); + long long c = f9 (x); + if (c < -3372587051122780160LL || c > 3955322825938799616LL) + link_failure (); + unsigned long long d = f10 (x); + if (d < 31 || d > 16751991430751148032ULL) + link_failure (); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr120231-3.c b/gcc/testsuite/gcc.dg/tree-ssa/pr120231-3.c new file mode 100644 index 0000000..d578c5b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr120231-3.c @@ -0,0 +1,40 @@ +/* PR tree-optimization/120231 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-add-options float64 } */ +/* { dg-require-effective-target float64 } */ +/* { dg-final { scan-tree-dump-not "link_failure \\\(\\\);" "optimized" } } */ + +void link_failure (void); + +void +foo (long long x) +{ + _Float64 y = x; + if (y >= -8577328745032543176.25f64 && y <= 699563045341050951.75f64) + { + if (x < -8577328745032544256LL || x > 699563045341051136LL) + link_failure (); + } + if (y >= -49919160463252.125f64 && y <= 757060336735329.625f64) + { + if (x < -49919160463252LL || x > 757060336735329LL) + link_failure (); + } +} + +void +bar (_Float64 x) +{ + long long y = x; + if (y >= -6923230004751524066LL && y <= 2202103129706786704LL) + { + if (x < -6923230004751524864.0f64 || x > 2202103129706786816.0f64) + link_failure (); + } + if (y >= -171621738469699LL && y <= 45962470357748LL) + { + if (x <= -1716217384696970.f64 || x >= 45962470357749.0f64) + link_failure (); + } +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr35286.c b/gcc/testsuite/gcc.dg/tree-ssa/pr35286.c index 4429cc8..b4f8c7c 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr35286.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr35286.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fno-code-hoisting -fno-tree-cselim -fdump-tree-pre-stats" } */ +/* { dg-options "-O2 -fno-code-hoisting -fno-tree-cselim -fno-ssa-phiopt -fdump-tree-pre-stats" } */ int g2; struct A { int a; int b; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr57361-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr57361-1.c new file mode 100644 index 0000000..dc4fadb --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr57361-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-forwprop1-details" } */ + +struct A { int x; double y; }; +void f (struct A *a) { + *a = *a; +} + +/* xfailed until figuring out the best way to handle aliasing barriers. */ +/* { dg-final { scan-tree-dump "into a NOP" "forwprop1" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr57361.c b/gcc/testsuite/gcc.dg/tree-ssa/pr57361.c index 81f27b3..7e273db 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr57361.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr57361.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -fdump-tree-dse1-details" } */ +/* { dg-options "-O -fdump-tree-dse1-details -fno-tree-forwprop" } */ struct A { int x; double y; }; void f (struct A *a) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/split-path-6.c b/gcc/testsuite/gcc.dg/tree-ssa/split-path-6.c index 71e6362..e2b0a95 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/split-path-6.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/split-path-6.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fsplit-paths -fno-tree-cselim -fdump-tree-split-paths-details -fno-finite-loops -fno-tree-dominator-opts -fno-tree-vrp -w" } */ +/* { dg-options "-O2 -fsplit-paths -fno-tree-cselim -fno-ssa-phiopt -fdump-tree-split-paths-details -fno-finite-loops -fno-tree-dominator-opts -fno-tree-vrp -w" } */ struct __sFILE { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/split-path-7.c b/gcc/testsuite/gcc.dg/tree-ssa/split-path-7.c index 252fe06..35634ab 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/split-path-7.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/split-path-7.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fsplit-paths -fno-tree-cselim -fno-tree-sink -fdump-tree-split-paths-details -w" } */ +/* { dg-options "-O2 -fsplit-paths -fno-tree-cselim -fno-ssa-phiopt -fno-tree-sink -fdump-tree-split-paths-details -w" } */ struct _reent diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c index 59891f2..1c2cfa4 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c @@ -11,8 +11,8 @@ to change decisions in switch expansion which in turn can expose new jump threading opportunities. Skip the later tests on aarch64. */ /* { dg-final { scan-tree-dump-not "Jumps threaded" "dom3" { target { ! aarch64*-*-* } } } } */ -/* { dg-final { scan-tree-dump "Jumps threaded: 10" "thread2" { target { ! aarch64*-*-* } } } } */ -/* { dg-final { scan-tree-dump "Jumps threaded: 17" "thread2" { target { aarch64*-*-* } } } } */ +/* { dg-final { scan-tree-dump "Jumps threaded: 8" "thread2" { target { ! aarch64*-*-* } } } } */ +/* { dg-final { scan-tree-dump "Jumps threaded: 8" "thread2" { target { aarch64*-*-* } } } } */ enum STATE { S0=0, |