This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Expand switch statements with a single (or none) non-default case.


On 08/30/2017 02:28 PM, Richard Biener wrote:
> On Wed, Aug 30, 2017 at 1:13 PM, Martin Liška <mliska@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?

Do you mean both with # of non-default edges equal to 0 and 1?
Let me take a look.

Martin

> 
> Richard.
> 
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2017-08-25  Martin Liska  <mliska@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  <mliska@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
>>
>>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]