diff options
author | Ian Lance Taylor <iant@golang.org> | 2023-06-21 11:04:04 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2023-06-21 11:04:04 -0700 |
commit | 97e31a0a2a2d2273687fcdb4e5416aab1a2186e1 (patch) | |
tree | d5c1cae4de436a0fe54a5f0a2a197d309f3d654c /gcc/testsuite/gcc.dg/tree-ssa | |
parent | 6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced (diff) | |
parent | 577223aebc7acdd31e62b33c1682fe54a622ae27 (diff) | |
download | gcc-97e31a0a2a2d2273687fcdb4e5416aab1a2186e1.zip gcc-97e31a0a2a2d2273687fcdb4e5416aab1a2186e1.tar.gz gcc-97e31a0a2a2d2273687fcdb4e5416aab1a2186e1.tar.bz2 |
Merge from trunk revision 577223aebc7acdd31e62b33c1682fe54a622ae27.
Diffstat (limited to 'gcc/testsuite/gcc.dg/tree-ssa')
90 files changed, 1207 insertions, 60 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/abs-1.c b/gcc/testsuite/gcc.dg/tree-ssa/abs-1.c new file mode 100644 index 0000000..ce40411 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/abs-1.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/109722 */ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-gimple -fdump-tree-optimized" } */ + +int g(signed char x){ + x = x < 0 ? -x : x; + return x == 0; +} + +/* This should work even if int is 16bits. */ +/* { dg-final { scan-tree-dump "ABSU_EXPR" "gimple"} } */ +/* { dg-final { scan-tree-dump-not "ABSU_EXPR" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/abs-2.c b/gcc/testsuite/gcc.dg/tree-ssa/abs-2.c new file mode 100644 index 0000000..f8bbeb4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/abs-2.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/49959 */ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-phiopt1-details" } */ + +#define ABS(X) (((X)>0)?(X):-(X)) +unsigned long +test_abs(int *cur) +{ + unsigned long sad = 0; + if (cur[0] > 0) + sad = cur[0]; + else + sad = -cur[0]; + return sad; +} + +/* We should figure out that test_abs has an ABS_EXPR in it. */ +/* { dg-final { scan-tree-dump " = ABS_EXPR" "phiopt1"} } */ +/* { dg-final { scan-tree-dump-times "changed to factor operation out from" 1 "phiopt1"} } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/abs-3.c b/gcc/testsuite/gcc.dg/tree-ssa/abs-3.c new file mode 100644 index 0000000..d2638e8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/abs-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ +/* PR tree-optimization/109829 */ + +float abs_f(float x) { return __builtin_signbit(x) ? -x : x; } +double abs_d(double x) { return __builtin_signbit(x) ? -x : x; } +long double abs_ld(long double x) { return __builtin_signbit(x) ? -x : x; } + + +/* __builtin_signbit(x) ? -x : x. Should be convert into ABS_EXP<x> */ +/* { dg-final { scan-tree-dump-not "signbit" "optimized"} } */ +/* { dg-final { scan-tree-dump-not "= -" "optimized"} } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 3 "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c new file mode 100644 index 0000000..6197519 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ +/* PR tree-optimization/109829 */ + +float abs_f(float x) { return __builtin_signbit(x) ? x : -x; } +double abs_d(double x) { return __builtin_signbit(x) ? x : -x; } +long double abs_ld(long double x) { return __builtin_signbit(x) ? x : -x; } + + +/* __builtin_signbit(x) ? x : -x. Should be convert into - ABS_EXP<x> */ +/* { dg-final { scan-tree-dump-not "signbit" "optimized"} } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 3 "optimized"} } */ +/* { dg-final { scan-tree-dump-times "= -" 3 "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-19.c b/gcc/testsuite/gcc.dg/tree-ssa/alias-19.c index 330ec00..219db9b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/alias-19.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-19.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O2 -fdump-tree-alias" } */ +/* { dg-options "-O2 -fdump-tree-alias-details" } */ const static int a; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bool-12.c b/gcc/testsuite/gcc.dg/tree-ssa/bool-12.c new file mode 100644 index 0000000..e62594e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bool-12.c @@ -0,0 +1,44 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized -fdump-tree-original -fdump-tree-phiopt1 -fdump-tree-forwprop2" } */ +#define bool _Bool +int maxbool(bool ab, bool bb) +{ + int a = ab; + int b = bb; + int c; + if (a > b) + c = a; + else + c = b; + return c; +} +int minbool(bool ab, bool bb) +{ + int a = ab; + int b = bb; + int c; + if (a < b) + c = a; + else + c = b; + return c; +} +/* In Original, we should still have the if form as that is what is written. */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "original" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 0 "original" } } */ +/* { dg-final { scan-tree-dump-times "if " 2 "original" } } */ + +/* PHI-OPT1 should have converted it into min/max */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "if " 0 "phiopt1" } } */ + +/* Forwprop2 (after ccp) will convert it into &\| */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "forwprop2" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 0 "forwprop2" } } */ +/* { dg-final { scan-tree-dump-times "if " 0 "forwprop2" } } */ + +/* By optimize there should be no min/max nor if */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "if " 0 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bool-13.c b/gcc/testsuite/gcc.dg/tree-ssa/bool-13.c new file mode 100644 index 0000000..438f15a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bool-13.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized -fdump-tree-original -fdump-tree-phiopt1 -fdump-tree-forwprop2" } */ +#define bool _Bool +int maxbool(bool ab, bool bb) +{ + int a = ab; + int b = bb; + int c; + c = a > b ? a : b; + return c; +} +int minbool(bool ab, bool bb) +{ + int a = ab; + int b = bb; + int c; + c = a < b ? a : b; + return c; +} +/* In Original, we should still have the min/max form as that is what is written. */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "if " 0 "original" } } */ + +/* PHI-OPT1 should have kept it as min/max. */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "if " 0 "phiopt1" } } */ + +/* Forwprop2 (after ccp) will convert it into &\| */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "forwprop2" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 0 "forwprop2" } } */ +/* { dg-final { scan-tree-dump-times "if " 0 "forwprop2" } } */ + +/* By optimize there should be no min/max nor if */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "if " 0 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/branchless-cond-add-2.c b/gcc/testsuite/gcc.dg/tree-ssa/branchless-cond-add-2.c new file mode 100644 index 0000000..27607e1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/branchless-cond-add-2.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* PR tree-optimization/97711 */ + +int f (int x) { return x & 1 ? x - 1 : x; } + +/* { dg-final { scan-tree-dump-times " & -2" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "if " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/branchless-cond-add.c b/gcc/testsuite/gcc.dg/tree-ssa/branchless-cond-add.c new file mode 100644 index 0000000..0d81c07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/branchless-cond-add.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* PR tree-optimization/110155 */ + +int f1(unsigned int x, unsigned int y, unsigned int z) +{ + return ((x & 1) == 0) ? y : z + y; +} + +int f2(unsigned int x, unsigned int y, unsigned int z) +{ + return ((x & 1) != 0) ? z + y : y; +} + +/* { dg-final { scan-tree-dump-times " \\\*" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\\+ " 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " & " 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "if " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/branchless-cond.c b/gcc/testsuite/gcc.dg/tree-ssa/branchless-cond.c index 68087ae..e063dc4 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/branchless-cond.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/branchless-cond.c @@ -21,6 +21,6 @@ int f4(unsigned int x, unsigned int y, unsigned int z) return ((x & 1) != 0) ? z | y : y; } -/* { dg-final { scan-tree-dump-times " -" 4 "optimized" } } */ -/* { dg-final { scan-tree-dump-times " & " 8 "optimized" } } */ -/* { dg-final { scan-tree-dump-not "if" "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\\*" 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " & " 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "if " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp-ignore.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp-ignore.c index 9bfaed6..ee93e5a 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/evrp-ignore.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp-ignore.c @@ -25,4 +25,4 @@ void foo (int x, int y, int z) kill(); } -/* { dg-final { scan-tree-dump-not "kill" "evrp" } } */ +/* { dg-final { scan-tree-dump-not "kill" "evrp" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp11.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp11.c index d791305..018aded 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/evrp11.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp11.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-evrp -fdelete-null-pointer-checks" } */ +/* { dg-skip-if "" keeps_null_pointer_checks } */ extern void link_error (); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp7.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp7.c index 16fbe65..0731430 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/evrp7.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp7.c @@ -11,4 +11,4 @@ int test1(int i, int k) return 1; } -/* { dg-final { scan-tree-dump "Removing dead stmt \[^\r\n\]* = j_.* == 10" "evrp" } } */ +/* { dg-final { scan-tree-dump "Removing dead stmt:\[^\r\n\]* = j_.* == 10" "evrp" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp8.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp8.c index b7e5c7a..a968346 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/evrp8.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp8.c @@ -8,4 +8,4 @@ int foo(int i) return 1; } -/* { dg-final { scan-tree-dump "Removing dead stmt \[^\r\n\]* = i_.* == 1" "evrp" } } */ +/* { dg-final { scan-tree-dump "Removing dead stmt:\[^\r\n\]* = i_.* == 1" "evrp" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c index 8a39871..6731f91 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-15.c @@ -30,5 +30,6 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ +/* There should only be two MIN_EXPR left, the 3rd one was removed. */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c index 4febd09..094364e 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-16.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O -fdump-tree-phiopt -g" } */ +/* { dg-options "-O -fdump-tree-phiopt -fdump-tree-optimized -g" } */ #include <stdint.h> @@ -25,5 +25,8 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ +/* After phiopt1, will be only 2 MIN_EXPR in the IR (including debug statements). */ +/* xk will only have the final result so the extra debug info does not change anything. */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "optimized" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-17.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-17.c new file mode 100644 index 0000000..7c76cfc --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-17.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-phiopt1-details" } */ + +static inline unsigned long long g(int t) +{ + unsigned t1 = t; + return t1; +} +unsigned long long test_max(int c, int d, int e) +{ + unsigned long long t; + if (c > d) + t = g(c); + else + t = g(d); + return t; +} + +/* We should figure out that test_max has an MAX_EXPR in it. */ +/* { dg-final { scan-tree-dump " = MAX_EXPR" "phiopt1"} } */ +/* { dg-final { scan-tree-dump-times "changed to factor operation out from" 2 "phiopt1"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-18.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-18.c new file mode 100644 index 0000000..c8e1670 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-18.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-phiopt1-details" } */ + +static inline unsigned long long g(int t) +{ + unsigned t1 = t; + return t1; +} +static inline int abs1(int a) +{ + if (a < 0) + a = -a; + return a; +} +unsigned long long f(int c, int d, int e) +{ + unsigned long long t; + if (d > e) + t = g(abs1(d)); + else + t = g(abs1(e)); + return t; +} + +/* { dg-final { scan-tree-dump " = MAX_EXPR" "phiopt1"} } */ +/* { dg-final { scan-tree-dump-times " = ABS_EXPR" 2 "phiopt1"} } */ +/* { dg-final { scan-tree-dump-times "changed to factor operation out from" 3 "phiopt1"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-19.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-19.c new file mode 100644 index 0000000..5ed55fe --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-19.c @@ -0,0 +1,10 @@ +/* PR tree-optimization/109424 */ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-phiopt1-details" } */ + +int f2(int x, int y) +{ + return (x > y) ? ~x : ~y; +} +/* { dg-final { scan-tree-dump " = MAX_EXPR" "phiopt1"} } */ +/* { dg-final { scan-tree-dump-times "changed to factor operation out from" 1 "phiopt1"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-20.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-20.c new file mode 100644 index 0000000..ab64033 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-20.c @@ -0,0 +1,27 @@ +/* PR tree-optimization/109424 */ +/* { dg-do compile } */ +/* Need -O2 for early non-zero */ +/* { dg-options "-O2 -fdump-tree-forwprop1-raw" } */ + +#define bool _Bool +int maxbool(bool ab, bool bb) +{ + int a = ab; + int b = bb; + int c; + c = (a > b)?a : b; + return c; +} +int minbool(bool ab, bool bb) +{ + int a = ab; + int b = bb; + int c; + c = (a < b)?a : b; + return c; +} + +/* { dg-final { scan-tree-dump-not "max_expr, " "forwprop1"} } */ +/* { dg-final { scan-tree-dump-not "min_expr, " "forwprop1"} } */ +/* { dg-final { scan-tree-dump-times "bit_and_expr, " 1 "forwprop1"} } */ +/* { dg-final { scan-tree-dump-times "bit_ior_expr, " 1 "forwprop1"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-21.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-21.c new file mode 100644 index 0000000..5f2b8af --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-21.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/109424 */ +/* { dg-do compile } */ +/* Need -O2 for early non-zero bits */ +/* { dg-options "-O2 -fdump-tree-forwprop1-raw -fdump-tree-optimized-raw" } */ + + +int maxbool(int ab, int bb) +{ + int a = ab & 1; + int b = bb & 1; + int c; + c = (a > b)?a : b; + return c; +} +int minbool(int ab, int bb) +{ + int a = ab & 1; + int b = bb & 1; + int c; + c = (a < b)?a : b; + return c; +} + +/* { dg-final { scan-tree-dump-not "max_expr, " "forwprop1"} } */ +/* { dg-final { scan-tree-dump-not "min_expr, " "forwprop1"} } */ +/* There should only be 3 total bit_and_expr, one &1 for each function and one & for minbool. */ +/* { dg-final { scan-tree-dump-times "bit_and_expr, " 3 "optimized"} } */ +/* { dg-final { scan-tree-dump-times "bit_ior_expr, " 1 "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-22.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-22.c new file mode 100644 index 0000000..481c375 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-22.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2" } */ + +int f(int num) +{ + if (num < 3) __builtin_unreachable(); + return num != 3 ? num : 4; +} + +/* In phiopt2 with the range information, this should be turned into + a MAX_EXPR. */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt2" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c index 2af1077..521afe3 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-3.c @@ -25,5 +25,5 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 0 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c index 973f39b..49e2718 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-4.c @@ -26,4 +26,4 @@ main (void) } /* { dg-final { scan-tree-dump-times "MIN_EXPR" 0 "phiopt1" } } */ -/* { dg-final { scan-tree-dump-times "MAX_EXPR" 3 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 2 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c index 34e4e72..194c881 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-5.c @@ -25,5 +25,5 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "MIN_EXPR" 2 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ /* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c index 0160e57..d5cb531 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-8.c @@ -26,4 +26,4 @@ main (void) } /* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "phiopt1" } } */ -/* { dg-final { scan-tree-dump-times "MAX_EXPR" 2 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/negneq-1.c b/gcc/testsuite/gcc.dg/tree-ssa/negneq-1.c new file mode 100644 index 0000000..94ff57d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/negneq-1.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/110134 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ + +int fu(unsigned a) +{ + a = -a; + return a != 0; +} +int fs(signed a) +{ + a = -a; + return a != 0; +} + +/* We should have optimized out the a = -a; statements. */ +/* { dg-final { scan-tree-dump-not "= -a" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/negneq-2.c b/gcc/testsuite/gcc.dg/tree-ssa/negneq-2.c new file mode 100644 index 0000000..9a3bb48 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/negneq-2.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/110134 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ + +int fu(unsigned a) +{ + a = -a; + return a == 1; +} +int fs(signed a) +{ + a = -a; + return a == 1; +} + +/* We should have optimized out the a = -a; statements. */ +/* { dg-final { scan-tree-dump-not "= -a" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/negneq-3.c b/gcc/testsuite/gcc.dg/tree-ssa/negneq-3.c new file mode 100644 index 0000000..14546a6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/negneq-3.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/110134 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ + +int fu(unsigned a, unsigned b) +{ + a = -a; + b = -b; + return a == b; +} +int fs(signed a, signed b) +{ + a = -a; + b = -b; + return a == b; +} + +/* We should have optimized out the a = -; statements. */ +/* { dg-final { scan-tree-dump-not "= -a" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "= -b" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/negneq-4.c b/gcc/testsuite/gcc.dg/tree-ssa/negneq-4.c new file mode 100644 index 0000000..1b66854 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/negneq-4.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/110134 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ + +int fu(unsigned a, unsigned b) +{ + a = -a; + b = -b; + return a != b; +} +int fs(signed a, signed b) +{ + a = -a; + b = -b; + return a != b; +} + +/* We should have optimized out the a = -; statements. */ +/* { dg-final { scan-tree-dump-not "= -a" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "= -b" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/peel1.c b/gcc/testsuite/gcc.dg/tree-ssa/peel1.c index 36f3ea0..dc5848c 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/peel1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/peel1.c @@ -7,5 +7,5 @@ void add(struct foo *a,int l) for (i=0;i<l;i++) a->a[i]++; } -/* { dg-final { scan-tree-dump "Loop 1 likely iterates at most 3 times." "cunroll"} } */ -/* { dg-final { scan-tree-dump "Peeled loop 1, 4 times." "cunroll"} } */ +/* { dg-final { scan-tree-dump "Loop 1 likely iterates at most 2 times." "cunroll"} } */ +/* { dg-final { scan-tree-dump "Peeled loop 1, 3 times." "cunroll"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-2.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-2.c index 5c7815e..006e8e8 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-2.c @@ -14,10 +14,8 @@ _Bool f1(_Bool a, _Bool b) } -/* There should be only one if, the outer one; the inner one - should have been changed to straight line code with the - value of b (except that we don't fold ! (b != 0) into b - which can be fixed in a different patch). - Test this only when known to be !LOGICAL_OP_NON_SHORT_CIRCUIT, - otherwise ifcombine may convert this into return a & b;. */ -/* { dg-final { scan-tree-dump-times "if" 1 "optimized" } } */ +/* There should be no if statements and be fold into just return a & b. + This can be done without ifcombine but in phiopt where a ? b : 0 is + converted into a & b. */ +/* { dg-final { scan-tree-dump-not "if" "optimized" } } */ +/* { dg-final { scan-tree-dump-times " & " 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-23.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-23.c index ff658cd..86aab95 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-23.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-23.c @@ -38,7 +38,7 @@ int f5(int A) return -A; } -/* These should be optimized in phiopt1 but is confused by predicts. */ -/* { dg-final { scan-tree-dump-not "if" "phiopt1" { xfail *-*-* } } } */ +/* f4 and f5 are not allowed to be optimized in early phi-opt. */ +/* { dg-final { scan-tree-dump-times "if" 2 "phiopt1" } } */ /* { dg-final { scan-tree-dump-not "if" "phiopt2" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-24.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-24.c index eb89dec..bd8308e 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-24.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-24.c @@ -38,7 +38,7 @@ float f5(float A) return -A; } -/* These should be optimized in phiopt1 but is confused by predicts. */ -/* { dg-final { scan-tree-dump-not "if" "phiopt1" { xfail *-*-* } } } */ +/* f4 and f5 are not allowed to be optimized in early phi-opt. */ +/* { dg-final { scan-tree-dump-times "if" 2 "phiopt1" } } */ /* { dg-final { scan-tree-dump-not "if" "phiopt2" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25a.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25a.c new file mode 100644 index 0000000..faecac5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25a.c @@ -0,0 +1,89 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +unsigned short test_bswap16(unsigned short x) +{ + if (x) + return __builtin_bswap16(x); + return 0; +} + +unsigned int test_bswap32(unsigned int x) +{ + if (x) + return __builtin_bswap32(x); + return 0; +} + +unsigned long long test_bswap64(unsigned long long x) +{ + if (x) + return __builtin_bswap64(x); + return 0; +} + +int test_clrsb(int x) +{ + if (x) + return __builtin_clrsb(x); + return (__SIZEOF_INT__*8-1); +} + +int test_clrsbl(long x) +{ + if (x) + return __builtin_clrsbl(x); + return (__SIZEOF_LONG__*8-1); +} + +int test_clrsbll(long long x) +{ + if (x) + return __builtin_clrsbll(x); + return (__SIZEOF_LONG_LONG__*8-1); +} + +int test_parity(int x) +{ + if (x) + return __builtin_parity(x); + return 0; +} + +int test_parityl(long x) +{ + if (x) + return __builtin_parityl(x); + return 0; +} + +int test_parityll(long long x) +{ + if (x) + return __builtin_parityll(x); + return 0; +} + +int test_popcount(int x) +{ + if (x) + return __builtin_popcount(x); + return 0; +} + +int test_popcountl(long x) +{ + if (x) + return __builtin_popcountl(x); + return 0; +} + +int test_popcountll(long long x) +{ + if (x) + return __builtin_popcountll(x); + return 0; +} + +/* { dg-final { scan-tree-dump-not "goto" "optimized" } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25b.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25b.c new file mode 100644 index 0000000..7298da0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25b.c @@ -0,0 +1,72 @@ +/* PR tree-optimization/109702 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +/* Test to make sure unrelated arguments and comparisons + don't get optimized incorrectly. */ + +unsigned short test_bswap16(unsigned short x, unsigned short y) +{ + return x ? __builtin_bswap16(y) : 0; +} + +unsigned int test_bswap32(unsigned int x, unsigned int y) +{ + return x ? __builtin_bswap32(y) : 0; +} + +unsigned long long test_bswap64(unsigned long long x, unsigned long long y) +{ + return x ? __builtin_bswap64(y) : 0; +} + +int test_clrsb(int x, int y) +{ + return x ? __builtin_clrsb(y) : (__SIZEOF_INT__*8-1); +} + +int test_clrsbl(long x, long y) +{ + return x ? __builtin_clrsbl(y) : (__SIZEOF_LONG__*8-1); +} + +int test_clrsbll(long long x, long long y) +{ + return x ? __builtin_clrsbll(y) : (__SIZEOF_LONG_LONG__*8-1); +} + +int test_parity(unsigned int x, unsigned int y) +{ + return x ? __builtin_parity(y) : 0; +} + +int test_parityl(unsigned long x, unsigned long y) +{ + return x ? __builtin_parityl(y) : 0; +} + +int test_parityll(unsigned long long x, unsigned long long y) +{ + return x ? __builtin_parityll(y) : 0; +} + +int test_popcount(unsigned int x, unsigned int y) +{ + return x ? __builtin_popcount(y) : 0; +} + +int test_popcountl(unsigned long x, unsigned long y) +{ + return x ? __builtin_popcountl(y) : 0; +} + +int test_popcountll(unsigned long long x, unsigned long long y) +{ + return x ? __builtin_popcountll(y) : 0; +} + +/* 3 types of functions (not including parity), each with 3 types and there are 2 goto each */ +/* { dg-final { scan-tree-dump-times "goto " 18 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "x_..D. != 0" 12 "optimized" } } */ +/* parity case will be optimized to x!=0 & parity(y) . */ +/* { dg-final { scan-tree-dump-times " & " 3 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-27.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-27.c new file mode 100644 index 0000000..11f85b9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-27.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ + +_Bool f1(_Bool a, _Bool b) +{ + if (a) + return b; + return 0; +} + + +/* There should be no if statements and be fold into just return a & b. */ +/* { dg-final { scan-tree-dump-not "if" "optimized" } } */ +/* { dg-final { scan-tree-dump-times " & " 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-28.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-28.c new file mode 100644 index 0000000..43dadd9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-28.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ + +_Bool f1(_Bool a, _Bool b) +{ + if (a) + return 1; + return b; +} + + +/* There should be no if statements and be fold into just return a & b. */ +/* { dg-final { scan-tree-dump-not "if" "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\\| " 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-29.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-29.c new file mode 100644 index 0000000..53aa01d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-29.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/89263 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized-raw" } */ + +_Bool f0(_Bool a, _Bool b) +{ + return a ? b : 0; +} +_Bool f1(_Bool a, _Bool b) +{ + return a ? b : 1; +} +_Bool t0(_Bool a, _Bool b) +{ + return a ? 0 : b; +} +_Bool t1(_Bool a, _Bool b) +{ + return a ? 1 : b; +} + +/* { dg-final { scan-tree-dump-not "gimple_cond " "optimized" } } */ +/* { dg-final { scan-tree-dump-times "bit_and_expr," 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "bit_ior_expr," 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "bit_not_expr," 2 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-30.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-30.c new file mode 100644 index 0000000..cdfee26 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-30.c @@ -0,0 +1,55 @@ +/* PR tree-optimization/20083 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized-raw" } */ + + +int f(int i, int j, int l) +{ + int k = 0; + if (i) + k = 1; + if (j) + k = 1; + if (l) + k = 1; + return k; +} +int f1(int i, int j, int l) +{ + int k = 0; + if (i) + k = 1; + else if (j) + k = 1; + else if (l) + k = 1; + return k; +} +int f2(int i, int j, int l) +{ + return i||j||l; +} +int f3(int i, int j, int l) +{ + int t = i | j; + _Bool t1 = l != 0; + _Bool t2 = t ? 1 : t1; + return t2; +} + +int f4(int i, int j, int l) +{ + int t = i | j; + _Bool t1 = l != 0; + _Bool t2; + if (t) + t2 = 1; + else + t2 = t1; + return t2; +} + +/* { dg-final { scan-tree-dump-not "gimple_cond " "optimized" } } */ +/* 2 ior for each function. */ +/* { dg-final { scan-tree-dump-times "bit_ior_expr," 10 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "ne_expr," 5 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-31.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-31.c new file mode 100644 index 0000000..e312cdb --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-31.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/94898 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized-raw" } */ + + +_Bool f(int x, int y) +{ + if (x >= y) + return x - y; + return 0; +} + +/* { dg-final { scan-tree-dump-not "gimple_cond " "optimized" } } */ +/* { dg-final { scan-tree-dump-times "gt_expr," 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "ne_expr," "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-32.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-32.c new file mode 100644 index 0000000..f51e79f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-32.c @@ -0,0 +1,12 @@ +/* PR tree-optimization/99069 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized-raw" } */ + +_Bool f(_Bool x, _Bool y) +{ + return (x ? y : 0) ? x : 0; +} + + +/* { dg-final { scan-tree-dump-not "gimple_cond " "optimized" } } */ +/* { dg-final { scan-tree-dump-times "bit_and_expr," 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-5.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-5.c index 5a00f3d..e78d9d8 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-5.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-5.c @@ -16,9 +16,9 @@ float repl1 (float varx) varx_4 = MIN_EXPR <1.0e+0, varx_2>; varx_5 = MAX_EXPR <varx_4, 0.0>; */ -/* phiopt1 confused by predictors. */ -/* { dg-final { scan-tree-dump "varx.*MIN_EXPR.*1\\.0" "phiopt1" { xfail *-*-* } } } */ -/* { dg-final { scan-tree-dump "varx.*MAX_EXPR.*0\\.0" "phiopt1" { xfail *-*-* } } } */ +/* phiopt1 was confused by predictors. */ +/* { dg-final { scan-tree-dump "varx.*MIN_EXPR.*1\\.0" "phiopt1" } } */ +/* { dg-final { scan-tree-dump "varx.*MAX_EXPR.*0\\.0" "phiopt1" } } */ /* { dg-final { scan-tree-dump "varx.*MIN_EXPR.*1\\.0" "phiopt2"} } */ /* { dg-final { scan-tree-dump "varx.*MAX_EXPR.*0\\.0" "phiopt2"} } */ @@ -38,8 +38,8 @@ float repl2 (float vary) vary_5 = MIN_EXPR <vary_4, 1.0e+0>; */ /* phiopt1 confused by predictors. */ -/* { dg-final { scan-tree-dump "vary.*MAX_EXPR.*0\\.0" "phiopt1" { xfail *-*-* } } } */ -/* { dg-final { scan-tree-dump "vary.*MIN_EXPR.*1\\.0" "phiopt1" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "vary.*MAX_EXPR.*0\\.0" "phiopt1" } } */ +/* { dg-final { scan-tree-dump "vary.*MIN_EXPR.*1\\.0" "phiopt1" } } */ /* { dg-final { scan-tree-dump "vary.*MAX_EXPR.*0\\.0" "phiopt2"} } */ /* { dg-final { scan-tree-dump "vary.*MIN_EXPR.*1\\.0" "phiopt2"} } */ @@ -61,6 +61,6 @@ float repl3 (float varz, float vara, float varb) vara_6 = MAX_EXPR <varb_5, varz_2>; */ /* phiopt1 confused by predictors. */ -/* { dg-final { scan-tree-dump "vara.*MAX_EXPR" "phiopt1" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "vara.*MAX_EXPR" "phiopt1" } } */ /* { dg-final { scan-tree-dump "if .*varz" "phiopt2"} } */ /* { dg-final { scan-tree-dump "vara.*MAX_EXPR" "phiopt2"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phiprop-1.c b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-1.c new file mode 100644 index 0000000..b448e83 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-phiprop1-details -fdump-tree-release_ssa" } */ +int max(int a, int b) +{ + int *ptr; + if (a > b) + ptr = &a; + else + ptr = &b; + return *ptr; +} + +/* { dg-final { scan-tree-dump-times "Inserting PHI for result of load" 1 "phiprop1"} } */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "release_ssa"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr101856.c b/gcc/testsuite/gcc.dg/tree-ssa/pr101856.c new file mode 100644 index 0000000..987737a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr101856.c @@ -0,0 +1,11 @@ +/* PR tree-optimization/101856 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump " .MUL_OVERFLOW " "optimized" { target i?86-*-* x86_64-*-* aarch64*-*-* powerpc64le-*-* } } } */ + +int +foo (unsigned long x, unsigned long y) +{ + unsigned long z = x * y; + return z / y != x; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr102232.c b/gcc/testsuite/gcc.dg/tree-ssa/pr102232.c index 62bca69..59ec52a 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr102232.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr102232.c @@ -1,6 +1,7 @@ /* PR tree-optimization/102232 */ /* { dg-do run } */ /* { dg-options "-O -fdump-tree-optimized" } */ +/* { dg-require-effective-target int32plus } */ int __attribute__ ((noipa)) foo (int a, int b) { @@ -49,4 +50,4 @@ main (void) /* Verify that multiplication and division has been removed. */ /* { dg-final { scan-tree-dump-not " \\* " "optimized" } } */ -/* { dg-final { scan-tree-dump-not " / " "optimized" } } */
\ No newline at end of file +/* { dg-final { scan-tree-dump-not " / " "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr103345.c b/gcc/testsuite/gcc.dg/tree-ssa/pr103345.c index dc8810a..87b237b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr103345.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr103345.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-bswap-details" } */ -typedef unsigned int uint32_t; +typedef __UINT32_TYPE__ uint32_t; typedef unsigned char uint8_t; uint32_t load_le_32_or(const uint8_t *ptr) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr103771.c b/gcc/testsuite/gcc.dg/tree-ssa/pr103771.c new file mode 100644 index 0000000..8061e2d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr103771.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-phiopt1-details" } */ +/* { dg-final { scan-tree-dump-times "changed to factor operation out from COND_EXPR." 1 "phiopt1" } } */ + +typedef unsigned char uint8_t; + +#if __SIZEOF_INT__ < 4 +#define int __INT32_TYPE__ +#endif + +static uint8_t x264_clip_uint8 (int x) +{ + return x & (~255) ? (-x) >> 31 : x; +} + +void +mc_weight (uint8_t* __restrict dst, uint8_t* __restrict src, + int i_width,int i_scale) +{ + for(int x = 0; x < i_width; x++) + dst[x] = x264_clip_uint8 (src[x] * i_scale); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr105860.c b/gcc/testsuite/gcc.dg/tree-ssa/pr105860.c index 77bcb4a..bbfaa45 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr105860.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr105860.c @@ -1,5 +1,6 @@ /* { dg-do run } */ /* { dg-options "-O1" } */ +/* { dg-require-effective-target int32plus } */ struct S1 { unsigned int _0; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr109031-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr109031-1.c index 84e1a08..9e85f10 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr109031-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr109031-1.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ unsigned char uc; -unsigned short us; +__UINT16_TYPE__ us; void testuc() { unsigned int g = 0; @@ -18,9 +18,9 @@ void testuc() { } void testus() { - unsigned int g = 0; - unsigned int *p1 = &g; - unsigned short *p2 = &us; + __UINT32_TYPE__ g = 0; + __UINT32_TYPE__ *p1 = &g; + __UINT16_TYPE__ *p2 = &us; do { (*p1)++; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr109031-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr109031-2.c index 6f28b3b..51f4b7a 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr109031-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr109031-2.c @@ -1,7 +1,7 @@ /* { dg-do run } */ /* { dg-options "-O2 -fwrapv" } */ signed char sc; -signed short ss; +__INT16_TYPE__ ss; void testsc() { unsigned int g = 0; @@ -18,9 +18,9 @@ void testsc() { } void testss() { - unsigned int g = 0; - unsigned int *p1 = &g; - signed short *p2 = &ss; + __UINT32_TYPE__ g = 0; + __UINT32_TYPE__ *p1 = &g; + __INT16_TYPE__ *p2 = &ss; do { (*p1)++; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr109639.c b/gcc/testsuite/gcc.dg/tree-ssa/pr109639.c new file mode 100644 index 0000000..897e62c --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr109639.c @@ -0,0 +1,20 @@ +// { dg-do compile } +// { dg-options "-O2" } + +extern int k[]; +int m; +int* j(); +void f(int *howto) { + short __trans_tmp_1; + long offset = howto - k; + __trans_tmp_1 = offset; + for (;;) { + if (howto == 0) + return; + if (__trans_tmp_1) { + howto = j(); + m = *howto; + } + f(howto); + } +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr109643.c b/gcc/testsuite/gcc.dg/tree-ssa/pr109643.c new file mode 100644 index 0000000..2bd6f25 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr109643.c @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-options "-O2" } + +int g_variant_type_info_basic_table[1]; +int g_variant_type_info_check__g_boolean_var_, g_variant_type_info_get_index; +int *g_variant_type_info_get_info; +int g_assertion_message_expr(); +void g_variant_type_info_check(int *info) { + int index = info - g_variant_type_info_basic_table; + if (index) + g_variant_type_info_check__g_boolean_var_ = 1; + g_assertion_message_expr(); +} +void g_variant_type_info_get() { + g_variant_type_info_get_info = + g_variant_type_info_basic_table + g_variant_type_info_get_index; + g_variant_type_info_check(g_variant_type_info_get_info); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr109711-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr109711-1.c new file mode 100644 index 0000000..8177750 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr109711-1.c @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-options "-O2" } + +void lspf2lpc(); + +void interpolate_lpc(int subframe_num) { + float weight = 0.25 * subframe_num + 1; + if (weight) + lspf2lpc(); +} + +void qcelp_decode_frame() { + int i; + for (;; i++) + interpolate_lpc(i); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr109711-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr109711-2.c new file mode 100644 index 0000000..f80bb1a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr109711-2.c @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-O2" } + +void lspf2lpc(); + +int interpolate_lpc_q_0; + +void +interpolate_lpc(int subframe_num) { + float weight; + if (interpolate_lpc_q_0) + weight = subframe_num; + else + weight = 1.0; + if (weight != 1.0) + lspf2lpc(); +} + +void +qcelp_decode_frame() { + int i; + for (;; i++) + interpolate_lpc(i); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr109834-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr109834-1.c new file mode 100644 index 0000000..f2af18b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr109834-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-optimized" } */ + +int f (char v) +{ + return __builtin_popcount((int)__builtin_bswap16(v)); +} + +/* We should be able to remove the bswap here as it does not matter + for the popcount. */ +/* { dg-final { scan-tree-dump-not "bswap" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr109934.c b/gcc/testsuite/gcc.dg/tree-ssa/pr109934.c new file mode 100644 index 0000000..08bd5ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr109934.c @@ -0,0 +1,22 @@ +// { dg-do run } +// { dg-options "-O3" } + +int printf(const char *, ...); +short a; +long b = 3, c; +int d(int e) { + switch (e) + case 111: + case 222: + case 44: + return 0; + return e; +} +int main() { + for (; a >= 0; --a) + if (d(c + 23) - 23) + b = 0; + + if (b != 3) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr110269.c b/gcc/testsuite/gcc.dg/tree-ssa/pr110269.c new file mode 100644 index 0000000..c68a6f9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr110269.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp2 -fdump-tree-optimized" } */ + +void foo(void); +static int a = 1, c; +static int *b = &a; +static int **d = &b; +static int ***e = &d; +void __assert_fail() __attribute__((__noreturn__)); +static int f() { + if (a) return a; + for (; c;) *e = 0; + if (b) __assert_fail(); + return 6; +} +int main() { + if (f()) { + *d = 0; + if (b == 0) + ; + else { + __builtin_unreachable(); + __assert_fail(); + } + } + if (b == 0) + ; + else + foo(); + ; +} + +/* { dg-final { scan-tree-dump-times "Folding predicate" 2 "ccp2" } } */ +/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21463.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21463.c index ed0829a..c6f1226 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr21463.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21463.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -fdump-tree-phiprop-details" } */ +/* { dg-options "-O -fdump-tree-phiprop1-details" } */ struct f { @@ -16,4 +16,4 @@ int g(int i, int c, struct f *ff, int g) return *t; } -/* { dg-final { scan-tree-dump-times "Inserting PHI for result of load" 1 "phiprop" } } */ +/* { dg-final { scan-tree-dump-times "Inserting PHI for result of load" 1 "phiprop1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr23109.c b/gcc/testsuite/gcc.dg/tree-ssa/pr23109.c index 7cdf1d0..059f658 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr23109.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr23109.c @@ -1,6 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -funsafe-math-optimizations -ftrapping-math -fdump-tree-recip -fdump-tree-lim2" } */ +/* { dg-options "-O2 -funsafe-math-optimizations -ftrapping-math -fdump-tree-recip -fdump-tree-lim2 --param=ranger-recompute-depth=1" } */ /* { dg-warning "'-fassociative-math' disabled" "" { target *-*-* } 0 } */ +/* ranger-recompute-depth prevents the optimizers from being too smart. */ double F[2] = { 0., 0. }, e = 0.; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr66726-4.c b/gcc/testsuite/gcc.dg/tree-ssa/pr66726-4.c index 4e43522..930ad5f 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr66726-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr66726-4.c @@ -9,4 +9,7 @@ foo (unsigned char *p, int i) *p = SAT (i); } -/* { dg-final { scan-tree-dump-times "COND_EXPR .*and PHI .*converted to straightline code" 1 "phiopt1" } } */ +/* fold could optimize SAT before phiopt1 so only match on the + MIN/MAX here. */ +/* { dg-final { scan-tree-dump-times "= MIN_EXPR" 1 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "= MAX_EXPR" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr66726-5.c b/gcc/testsuite/gcc.dg/tree-ssa/pr66726-5.c new file mode 100644 index 0000000..4b5066c --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr66726-5.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt1-details -fdump-tree-phiopt2-details -fdump-tree-optimized" } */ + +#define SAT(x) (x < 0 ? 0 : (x > 255 ? 255 : x)) + +unsigned char +foo (unsigned char *p, int i) +{ + if (i < 0) + return 0; + { + int t; + if (i > 255) + t = 255; + else + t = i; + return t; + } +} + +/* Because of the way PHIOPT works, it only does the merging of BBs after it is done so we get the case were we can't + optimize the above until phiopt2 right now. */ +/* { dg-final { scan-tree-dump-times "COND_EXPR .*and PHI .*converted to straightline code" 2 "phiopt1" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "COND_EXPR .*and PHI .*converted to straightline code" 0 "phiopt2" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "= MIN_EXPR" 1 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "= MAX_EXPR" 1 "phiopt1" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "= MIN_EXPR" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "= MAX_EXPR" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr66726-6.c b/gcc/testsuite/gcc.dg/tree-ssa/pr66726-6.c new file mode 100644 index 0000000..5c6b499 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr66726-6.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt1-details" } */ + + +unsigned char +foo1 (unsigned char *p, int i) +{ + if (i < 0) + return 0; + { + int t = i > 255 ? 255 : i; + return t; + } +} +/* testing to see if moving the cast out of the conditional. */ + +/* { dg-final { scan-tree-dump-times "COND_EXPR .*and PHI .*converted to straightline code" 1 "phiopt1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr83648.c b/gcc/testsuite/gcc.dg/tree-ssa/pr83648.c index 954eb2f..d3dd12d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr83648.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr83648.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-local-pure-const-details -fdelete-null-pointer-checks" } */ +/* { dg-skip-if "" keeps_null_pointer_checks } */ void *g(unsigned n) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr93435.c b/gcc/testsuite/gcc.dg/tree-ssa/pr93435.c index cb8e749..ca2e091 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr93435.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr93435.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2" } */ +/* { dg-require-effective-target size32plus } */ typedef signed char int8_T; typedef int int32_T; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96730.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96730.c index 39a0684..8eb2006 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr96730.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96730.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O1" } */ +/* { dg-require-effective-target int32plus } */ struct a { int b; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96779-disabled.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96779-disabled.c index 205133d..9686205 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr96779-disabled.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96779-disabled.c @@ -1,6 +1,7 @@ /* PR tree-optimization/96779 */ /* { dg-do run } */ /* { dg-options "-O -fdump-tree-optimized -fwrapv" } */ +/* { dg-require-effective-target int32plus } */ #include <stdbool.h> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96779.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96779.c index 0d46e8e..03618bf 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr96779.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96779.c @@ -1,6 +1,7 @@ /* PR tree-optimization/96779 */ /* { dg-do run } */ /* { dg-options "-O -fdump-tree-optimized" } */ +/* { dg-require-effective-target int32plus } */ #include <stdbool.h> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr98513.c b/gcc/testsuite/gcc.dg/tree-ssa/pr98513.c index c15d6bd..859d7ac 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr98513.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr98513.c @@ -1,5 +1,6 @@ /* { dg-do run } */ /* { dg-options "-O2 -fgimple" } */ +/* { dg-require-effective-target int32plus } */ __attribute__((noipa)) void __GIMPLE (ssa,startwith("evrp")) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr98737-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr98737-1.c index e313a7f..8e105b4 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr98737-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr98737-1.c @@ -2,8 +2,11 @@ /* { dg-do compile { target i?86-*-* x86_64-*-* powerpc*-*-* aarch64*-*-* } } */ /* { dg-options "-O2 -fdump-tree-optimized -fcompare-debug" } */ /* { dg-additional-options "-march=i686" { target ia32 } } */ -/* { dg-final { scan-tree-dump-not "__atomic_fetch_" "optimized" } } */ -/* { dg-final { scan-tree-dump-not "__sync_fetch_and_" "optimized" } } */ +/* Note the choice between __atomic_fetch_and_* and __atomic_and_*_fetch + if the result is not used does not matter. so check if make sure we don't + have __atomic_fetch_ with an assignment */ +/* { dg-final { scan-tree-dump-not "= __atomic_fetch_" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "= __sync_fetch_and_" "optimized" } } */ typedef signed char schar; typedef unsigned long ulong; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c index d8fe51c..1c54679 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-2.c @@ -1,5 +1,6 @@ /* { dg-do run } */ /* { dg-options "-O2 -funroll-loops --param max-unroll-times=8 -fpredictive-commoning -fdump-tree-pcom-details -fno-tree-pre" } */ +/* { dg-additional-options "-fno-tree-vectorize" { target amdgcn-*-* } } */ void abort (void); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c b/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c index b9a57d8..c7e96fb 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 --param max-fields-for-field-sensitive=2 -fdump-tree-alias" } */ +/* { dg-options "-O2 --param max-fields-for-field-sensitive=2 -fdump-tree-alias-details" } */ struct Foo { int *p, *q; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pta-fp.c b/gcc/testsuite/gcc.dg/tree-ssa/pta-fp.c index 1ff007e..59652c3 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pta-fp.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pta-fp.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-alias" } */ +/* { dg-options "-O2 -fdump-tree-alias-details" } */ extern double cos (double); extern double sin (double); double f(double a) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-1.c index b56d589..9e4c0fe 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fno-tree-forwprop -fno-tree-ccp -fdump-tree-ealias" } */ +/* { dg-options "-O2 -fno-tree-forwprop -fno-tree-ccp -fdump-tree-ealias-details" } */ extern void abort (void); struct X { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-2.c index be06a75..70b432f 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pta-ptrarith-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fno-tree-forwprop -fno-tree-ccp -fdump-tree-ealias" } */ +/* { dg-options "-O2 -fno-tree-forwprop -fno-tree-ccp -fdump-tree-ealias-details" } */ extern void abort (void); struct X { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/range-sincos-2.c b/gcc/testsuite/gcc.dg/tree-ssa/range-sincos-2.c new file mode 100644 index 0000000..fd578aa --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/range-sincos-2.c @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-evrp -fno-thread-jumps" } + +void use (double); +void link_error (); + +void +foo (double x) +{ + double y; + if (x >= 0.5 && x <= 1.3) + { + y = __builtin_sin (x); + if (y < 0.45 || y > 0.97) + link_error (); + use (y); + } + if (x >= 0.5 && x < 1.75) + { + y = __builtin_sin (x); + if (y < 0.45 || y > 1.05) + link_error (); + use (y); + } + if (x >= -1.57 && x <= 1.57) + { + y = __builtin_cos (x); + if (y < 0.0007 || y > 1.05) + link_error (); + use (y); + } +} + +// { dg-final { scan-tree-dump-not "link_error" "evrp" { target { { *-*-linux* } && { glibc } } } } } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/range-sincos.c b/gcc/testsuite/gcc.dg/tree-ssa/range-sincos.c new file mode 100644 index 0000000..337f9cd --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/range-sincos.c @@ -0,0 +1,43 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-evrp -fno-thread-jumps" } + +#include <math.h> + +void use (double); +void link_error (); + +void +foo (double x) +{ + if (__builtin_isnan (x)) + __builtin_unreachable (); + x = sin (x); + if (x < -1.0 || x > 1.0) + link_error (); + use (x); +} + +void +bar (double x) +{ + if (!__builtin_isnan (sin (x))) + { + if (__builtin_isnan (x)) + link_error (); + if (__builtin_isinf (x)) + link_error (); + } +} + +void +stool (double x) +{ + double res1 = sin (x); + double res2 = __builtin_sin (x); + if (res1 < -1.0 || res2 < -1.0) + link_error (); + if (res1 > 1.0 || res2 > 1.0) + link_error (); +} + +// { dg-final { scan-tree-dump-not "link_error" "evrp" { target { { *-*-linux* } && { glibc } } } } } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/range-sqrt-2.c b/gcc/testsuite/gcc.dg/tree-ssa/range-sqrt-2.c new file mode 100644 index 0000000..a146d9d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/range-sqrt-2.c @@ -0,0 +1,44 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-evrp -fno-thread-jumps" } + +#include <math.h> + +void use (double); +void link_error (); + +void +foo (double x) +{ + if (x < 1.0 || x > 9.0) + __builtin_unreachable (); + x = sqrt (x); + if (x < 0.875 || x > 3.125) + link_error (); + use (x); +} + +void +bar (double x) +{ + if (sqrt (x) >= 2.0 && sqrt (x) <= 4.0) + { + if (__builtin_isnan (x)) + link_error (); + if (x < 3.875 || x > 16.125) + link_error (); + } +} + +void +stool (double x) +{ + if (x >= 64.0) + { + double res1 = sqrt (x); + double res2 = __builtin_sqrt (x); + if (res1 < 7.875 || res2 < 7.875) + link_error (); + } +} + +// { dg-final { scan-tree-dump-not "link_error" "evrp" { target { { *-*-linux* } && { glibc } } } } } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/range-sqrt.c b/gcc/testsuite/gcc.dg/tree-ssa/range-sqrt.c new file mode 100644 index 0000000..d2a2626 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/range-sqrt.c @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-evrp -fno-thread-jumps" } + +#include <math.h> + +void use (double); +void link_error (); + +void +foo (double x) +{ + if (__builtin_isnan (x)) + __builtin_unreachable (); + x = sqrt (x); + if (x < -0.0) + link_error (); + use (x); +} + +void +bar (double x) +{ + if (!__builtin_isnan (sqrt (x))) + { + if (__builtin_isnan (x)) + link_error (); + if (x < -0.0) + link_error (); + } +} + +void +stool (double x) +{ + double res1 = sqrt (x); + double res2 = __builtin_sqrt (x); + if (res1 < -0.0 || res2 < -0.0) + link_error (); +} + +// { dg-final { scan-tree-dump-not "link_error" "evrp" { target { { *-*-linux* } && { glibc } } } } } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c b/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c index 902dde4..b670dee 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c @@ -1,5 +1,6 @@ /* { dg-do run } */ -/* { dg-options "-O2 -fsplit-paths -fdump-tree-split-paths-details --param max-jump-thread-duplication-stmts=20 -fno-ssa-phiopt" } */ +/* Note both PHI-OPT and the loop if conversion pass converts the inner if to be branchless using min/max. */ +/* { dg-options "-O2 -fsplit-paths -fdump-tree-split-paths-details --param max-jump-thread-duplication-stmts=20 -fno-ssa-phiopt -fno-tree-loop-if-convert" } */ #include <stdio.h> #include <stdlib.h> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-41.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-41.c index d2b054e..e0a0b6b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-41.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-41.c @@ -1,11 +1,15 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-optimized" } */ +#if __SIZEOF_INT__ == 2 +#define int __INT32_TYPE__ +#endif + int foo(int x) { int p = x & 24; int r = 1 << p; - return r & (1<<17); + return r & ((int)1<<17); } /* { dg-final { scan-tree-dump "return 0;" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-47.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-47.c new file mode 100644 index 0000000..659f1d0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-47.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-dse1-details" } */ + +int a; +int b[3]; +void test() +{ + if (a > 0) + { + b[0] = 0; + b[1] = 1; + b[2] = 2; + __builtin_unreachable (); + } +} + +/* { dg-final { scan-tree-dump-times "Deleted dead store" 3 "dse1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-hoist-8.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-hoist-8.c new file mode 100644 index 0000000..66bb48e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-hoist-8.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-pre-stats" } */ + +int mem; +void foo (); +int bar (int flag) +{ + int res; + foo (); + /* Hoist the load of mem here even though foo () clobbers it. */ + if (flag) + res = mem; + else + { + res = mem; + mem = 2; + } + return res; +} + +/* { dg-final { scan-tree-dump "HOIST inserted: 1" "pre" } } */ +/* { dg-final { scan-tree-dump-times " = mem;" 1 "pre" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-hoist-9.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-hoist-9.c new file mode 100644 index 0000000..388f79f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-hoist-9.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-pre-stats" } */ + +int foo (int flag, int * __restrict a, int * __restrict b) +{ + int res; + if (flag) + res = *a + *b; + else + { + res = *a; + *a = 1; + res += *b; + } + return res; +} + +/* { dg-final { scan-tree-dump "HOIST inserted: 3" "pre" } } */ +/* { dg-final { scan-tree-dump-times " = \\\*" 2 "pre" } } */ +/* { dg-final { scan-tree-dump-times " = \[^\r\n\]* \\\+ \[^\r\n\]*;" 1 "pre" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c index 425eb3d..7976544 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ifcombine-13.c @@ -1,5 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-O1 -fdump-tree-optimized-details-blocks --param logical-op-non-short-circuit=1" } */ +/* Disable phi-opt as it is no longer confused by predicate which had allowed ifcombine to work in the past. + Note this testcase is about ifcombine rather than phi-opt. */ +/* { dg-options "-O1 -fdump-tree-optimized-details-blocks --param logical-op-non-short-circuit=1 -fno-ssa-phiopt" } */ _Bool f1(_Bool a, _Bool b) { diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-18.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-18.c index 9ac0fc6e..fd6c867 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-18.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-18.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-sink-stats" } */ +/* { dg-require-effective-target int32plus } */ #include <stdint.h> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-21.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-21.c index 16537cc..1123b3e 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-21.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-21.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-thread2-stats -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-tree-thread2-stats -fdump-tree-optimized -fno-ssa-phiopt" } */ long a; int b; @@ -19,6 +19,7 @@ int main() { a = b; } +/* Disable phiopt as the threading opportunity goes away. */ /* We need to perform a non-multi-way branch FSM thread creating an irreducible loop in thread2 to allow followup threading to remove the call to foo (). */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp06.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp06.c index 898477e..8f5f860 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp06.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp06.c @@ -30,4 +30,4 @@ foo (int i, int j, int a) /* { dg-final { scan-tree-dump-times "Folding predicate \[i|j\]_\[0-9\]+.*0 to 0" 1 "vrp1" } } */ /* { dg-final { scan-tree-dump-times "Folding predicate \[i|j\]_\[0-9\]+.*0 to 1" 1 "vrp1" } } */ -/* { dg-final { scan-tree-dump-times "Folding predicate i_\[0-9]+.*j_\[0-9\]+.* to 0" 1 "vrp1" } } */ +/* { dg-final { scan-tree-dump-times "Folding predicate i_\[0-9]+.*j_\[0-9\]+.* to 0" 1 "vrp1" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp35.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp35.c index a372a18..1d76677b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp35.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp35.c @@ -11,4 +11,4 @@ int test1(int i, int k) return 1; } -/* { dg-final { scan-tree-dump "Removing dead stmt \[^\r\n\]* = j_.* == 10" "vrp1" } } */ +/* { dg-final { scan-tree-dump "Removing dead stmt:\[^\r\n\]* = j_.* == 10" "vrp1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp36.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp36.c index 1f77b53..1e9c7f4 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp36.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp36.c @@ -8,4 +8,4 @@ int foo(int i) return 1; } -/* { dg-final { scan-tree-dump "Removing dead stmt \[^\r\n\]* = i_.* == 1" "vrp1" } } */ +/* { dg-final { scan-tree-dump "Removing dead stmt:\[^\r\n\]* = i_.* == 1" "vrp1" } } */ |