diff options
author | Jakub Jelinek <jakub@redhat.com> | 2014-10-17 12:54:54 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2014-10-17 12:54:54 +0200 |
commit | 73049af5fa62c7eeca27585f8f318e9bea7c47ae (patch) | |
tree | 3d9f1e754cc0f6442d99387021c379a081f76de3 /gcc/testsuite | |
parent | 4eb4a256cd4a39555f4d834c47cabc2e136ed02a (diff) | |
download | gcc-73049af5fa62c7eeca27585f8f318e9bea7c47ae.zip gcc-73049af5fa62c7eeca27585f8f318e9bea7c47ae.tar.gz gcc-73049af5fa62c7eeca27585f8f318e9bea7c47ae.tar.bz2 |
re PR tree-optimization/63464 (compare one character to many: faster)
PR tree-optimization/63464
* gimple.h (gimple_seq_discard): New prototype.
* gimple.c: Include stringpool.h and tree-ssanames.h.
(gimple_seq_discard): New function.
* optabs.h (lshift_cheap_p): New prototype.
* optabs.c (lshift_cheap_p): New function, moved from...
* tree-switch-conversion.c (lshift_cheap_p): ... here.
* tree-ssa-reassoc.c: Include gimplify.h and optabs.h.
(reassoc_branch_fixups): New variable.
(update_range_test): Add otherrangep and seq arguments.
Unshare exp. If otherrange is NULL, use for other ranges
array of pointers pointed by otherrangep instead.
Emit seq before gimplified statements for tem.
(optimize_range_tests_diff): Adjust update_range_test
caller.
(optimize_range_tests_xor): Likewise. Fix up comment.
(extract_bit_test_mask, optimize_range_tests_to_bit_test): New
functions.
(optimize_range_tests): Adjust update_range_test caller.
Call optimize_range_tests_to_bit_test.
(branch_fixup): New function.
(execute_reassoc): Call branch_fixup.
* gcc.dg/torture/pr63464.c: New test.
* gcc.dg/tree-ssa/reassoc-37.c: New test.
* gcc.dg/tree-ssa/reassoc-38.c: New test.
From-SVN: r216393
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr63464.c | 92 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/reassoc-37.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/reassoc-38.c | 18 |
4 files changed, 132 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0cc6221..e38cfd6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2014-10-17 Jakub Jelinek <jakub@redhat.com> + PR tree-optimization/63464 + * gcc.dg/torture/pr63464.c: New test. + * gcc.dg/tree-ssa/reassoc-37.c: New test. + * gcc.dg/tree-ssa/reassoc-38.c: New test. + PR tree-optimization/63302 * gcc.c-torture/execute/pr63302.c: New test. diff --git a/gcc/testsuite/gcc.dg/torture/pr63464.c b/gcc/testsuite/gcc.dg/torture/pr63464.c new file mode 100644 index 0000000..b6a9559 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr63464.c @@ -0,0 +1,92 @@ +/* PR tree-optimization/63464 */ +/* { dg-do run { target int32plus } } */ + +int cnt; + +__attribute__((noinline, noclone)) void +bar (int x, int y) +{ + cnt++; + switch (y) + { + case 1: + if ((unsigned) x < 24U && ((1U << x) & 0x860c0cU) != 0) + __builtin_abort (); + break; + case 2: + if ((unsigned) x >= 24U || ((1U << x) & 0x860c0cU) == 0) + __builtin_abort (); + break; + case 3: + if ((unsigned) x - 43U < 40U && ((1ULL << (x - 43U)) & 0x8f0000004fULL) != 0) + __builtin_abort (); + break; + case 4: + if ((unsigned) x - 43U >= 40U || ((1ULL << (x - 43U)) & 0x8f0000004fULL) == 0) + __builtin_abort (); + break; + default: + __builtin_abort (); + } +} + +__attribute__((noinline, noclone)) void +f1 (int x) +{ + if (x != 2 && x != 3 && x != 10 && x != 11 && x != 17 && x != 18 && x != 23) + bar (x, 1); +} + +__attribute__((noinline, noclone)) void +f2 (int x) +{ + if (x == 2 || x == 3 || x == 10 || x == 11 || x == 17 || x == 18 || x == 23) + bar (x, 2); +} + +__attribute__((noinline, noclone)) void +f3 (int x) +{ + if (x != 43 && x != 76 && x != 44 && x != 78 && x != 49 + && x != 77 && x != 46 && x != 75 && x != 45 && x != 82) + bar (x, 3); +} + +__attribute__((noinline, noclone)) void +f4 (int x) +{ + if (x == 43 || x == 76 || x == 44 || x == 78 || x == 49 + || x == 77 || x == 46 || x == 75 || x == 45 || x == 82) + bar (x, 4); +} + +int +main () +{ + int i; + f1 (-__INT_MAX__ - 1); + for (i = -3; i < 92; i++) + f1 (i); + f1 (__INT_MAX__); + if (cnt != 97 - 7) + __builtin_abort (); + f2 (-__INT_MAX__ - 1); + for (i = -3; i < 92; i++) + f2 (i); + f2 (__INT_MAX__); + if (cnt != 97) + __builtin_abort (); + f3 (-__INT_MAX__ - 1); + for (i = -3; i < 92; i++) + f3 (i); + f3 (__INT_MAX__); + if (cnt != 97 * 2 - 10) + __builtin_abort (); + f4 (-__INT_MAX__ - 1); + for (i = -3; i < 92; i++) + f4 (i); + f4 (__INT_MAX__); + if (cnt != 97 * 2) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-37.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-37.c new file mode 100644 index 0000000..5f5d36f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-37.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/63464 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +void bar (void); + +void +foo (int x) +{ + if (x != 2 && x != 3 && x != 10 && x != 11 && x != 17 && x != 18 && x != 23) + bar (); +} + +/* Check if the tests have been folded into a bit test. */ +/* { dg-final { scan-tree-dump "(8784908|0x0*860c0c)" "optimized" { target i?86-*-* x86_64-*-* } } } */ +/* { dg-final { scan-tree-dump "(<<|>>)" "optimized" { target i?86-*-* x86_64-*-* } } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-38.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-38.c new file mode 100644 index 0000000..b894339 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-38.c @@ -0,0 +1,18 @@ +/* PR tree-optimization/63464 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +void bar (void); + +void +foo (int x) +{ + if (x == 43 || x == 76 || x == 44 || x == 78 || x == 49 + || x == 77 || x == 46 || x == 75 || x == 45 || x == 82) + bar (); +} + +/* Check if the tests have been folded into a bit test. */ +/* { dg-final { scan-tree-dump "(614180323407|0x0*8f0000004f)" "optimized" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ +/* { dg-final { scan-tree-dump "(<<|>>)" "optimized" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ |