Improve backward threading with switches.
authorAldy Hernandez <aldyh@redhat.com>
Thu, 28 Oct 2021 09:44:13 +0000 (11:44 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Thu, 28 Oct 2021 12:30:06 +0000 (14:30 +0200)
commit113dab2b9d511f3aadc30a6a921fc30bd5f93706
tree6cb4c293fa0eccb941dfac4e7cb36c5bad5aaa4a
parent7f6c22585229b43b13fc9c8d3c08aedd9f7c493a
Improve backward threading with switches.

We've been essentially using find_taken_edge_switch_expr() in the
backward threader, but this is suboptimal because said function only
works with singletons.  VRP has a much smarter find_case_label_range
that works with ranges.

Tested on x86-64 Linux with:

a) Bootstrap & regtests.

b) Verifying we get more threads than before.

c) Asserting that the new code catches everything the old one
code caught (over a set of bootstrap .ii files).

gcc/ChangeLog:

* tree-ssa-threadbackward.c
(back_threader::find_taken_edge_switch): Use find_case_label_range
instead of find_taken_edge.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/vrp106.c: Adjust for threading.
* gcc.dg/tree-ssa/vrp113.c: Same.
gcc/testsuite/gcc.dg/tree-ssa/vrp106.c
gcc/testsuite/gcc.dg/tree-ssa/vrp113.c
gcc/tree-ssa-threadbackward.c