diff options
author | Jeff Law <law@redhat.com> | 2017-05-06 09:03:40 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2017-05-06 09:03:40 -0600 |
commit | 973dfbb4a63ba7c580e4de0c99b4970ef159631c (patch) | |
tree | 4c8e6a9ca78122f5f070154b3bc851d9e0c3ed1c /gcc/testsuite | |
parent | 8ffa3150d30b90a11aba7d7bba3c6462b6461101 (diff) | |
download | gcc-973dfbb4a63ba7c580e4de0c99b4970ef159631c.zip gcc-973dfbb4a63ba7c580e4de0c99b4970ef159631c.tar.gz gcc-973dfbb4a63ba7c580e4de0c99b4970ef159631c.tar.bz2 |
re PR tree-optimization/78496 (Missed opportunities for jump threading)
PR tree-optimization/78496
* tree-vrp.c (simplify_assert_expr_using_ranges): New function.
(simplify_stmt_using_ranges): Call it.
(vrp_dom_walker::before_dom_children): Extract equivalences
from an ASSERT_EXPR with an equality comparison against a
constant.
PR tree-optimization/78496
* gcc.dg/tree-ssa/ssa-thread-16.c: New test.
* gcc.dg/tree-ssa/ssa-thread-17.c: New test.
From-SVN: r247721
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-16.c | 38 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-17.c | 36 |
3 files changed, 80 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fca5b87..42782a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-05-06 Jeff Law <law@redhat.com> + + PR tree-optimization/78496 + * gcc.dg/tree-ssa/ssa-thread-16.c: New test. + * gcc.dg/tree-ssa/ssa-thread-17.c: New test. + 2017-05-06 Richard Sandiford <richard.sandiford@linaro.org> * gcc.target/aarch64/spill_1.c: New test. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-16.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-16.c new file mode 100644 index 0000000..78c349c --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-16.c @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp1-details" } */ + +/* We should thread the if (exp == 2) conditional on the + the path from inside the if (x) THEN arm. It is the only + jump threading opportunity in this code. */ + +/* { dg-final { scan-tree-dump-times "Threaded" 1 "vrp1" } } */ + + +extern void abort (void) __attribute__ ((__nothrow__, __leaf__)) + __attribute__ ((__noreturn__)); + +int x; + + +int code; +void +do_jump (int exp) +{ + switch (code) + { + case 4: + if ((exp) == 1) + goto normal; + if (x) + { + if (exp != 0) + abort (); + } + if ((exp) == 2) + goto normal; + case 3: + abort (); + } + normal: + ; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-17.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-17.c new file mode 100644 index 0000000..692658f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-17.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-vrp1-details" } */ + +/* We should simplify one ASSERT_EXPR from a relational + into an equality test. */ +/* { dg-final { scan-tree-dump-times "Folded into:\[^\r\n\]*ASSERT_EXPR\*\[^\r\n\]* == 1" 1 "vrp1" } } */ + +/* And simplification of the ASSERT_EXPR leads to a jump threading opportunity. */ +/* { dg-final { scan-tree-dump-times "Threaded" 1 "vrp1" } } */ + +extern void abort (void) __attribute__ ((__nothrow__, __leaf__)) + __attribute__ ((__noreturn__)); + +union gimple_statement_d; +typedef union gimple_statement_d *gimple; + + + +union gimple_statement_d +{ + unsigned num_ops; +}; + +void +gimple_assign_set_rhs_with_ops_1 (int code, gimple stmt, unsigned new_rhs_ops) +{ + + stmt->num_ops = new_rhs_ops + 1; + if (stmt->num_ops <= 1) + abort (); + if (new_rhs_ops > 1) + if (stmt->num_ops <= 2) + abort (); + if (new_rhs_ops > 2) + abort (); +} |