On Wed, Aug 30, 2017 at 1:13 PM, Martin Liška <mli...@suse.cz> wrote: > Hi. > > Simple transformation of switch statements where degenerated switch can be > interpreted > as gimple condition (or removed if having any non-default case). I originally > though > that we don't have switch statements without non-default cases, but PR82032 > shows we > can see it. > > Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. > > Ready to be installed?
While I guess this case is ok to handle here it would be nice if CFG cleanup would do the same. I suppose find_taken_edge somehow doesn't work for this case even after my last enhancement? Or is CFG cleanup for some reason not run? Richard. > Martin > > gcc/ChangeLog: > > 2017-08-25 Martin Liska <mli...@suse.cz> > > PR tree-optimization/82032 > * tree-switch-conversion.c (generate_high_low_equality): New > function. > (expand_degenerated_switch): Likewise. > (process_switch): Call expand_degenerated_switch. > (try_switch_expansion): Likewise. > (emit_case_nodes): Use generate_high_low_equality. > > gcc/testsuite/ChangeLog: > > 2017-08-25 Martin Liska <mli...@suse.cz> > > PR tree-optimization/82032 > * gcc.dg/tree-ssa/pr68198.c: Update jump threading expectations. > * gcc.dg/tree-ssa/switch-expansion.c: New test. > * gcc.dg/tree-ssa/vrp34.c: Update scanned pattern. > * g++.dg/other/pr82032.C: New test. > --- > gcc/testsuite/g++.dg/other/pr82032.C | 36 +++++++ > gcc/testsuite/gcc.dg/tree-ssa/pr68198.c | 6 +- > gcc/testsuite/gcc.dg/tree-ssa/switch-expansion.c | 14 +++ > gcc/testsuite/gcc.dg/tree-ssa/vrp34.c | 5 +- > gcc/tree-switch-conversion.c | 123 > ++++++++++++++++++----- > 5 files changed, 152 insertions(+), 32 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/other/pr82032.C > create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/switch-expansion.c > >