[PATCH] if-to-switch pass
Richard Biener
richard.guenther@gmail.com
Mon Jun 24 12:28:00 GMT 2013
On Fri, Jun 21, 2013 at 10:37 PM, Cesar Philippidis
<cesar_philippidis@mentor.com> wrote:
> Here is an updated version of Tom's if-to-switch conversion pass that
> was originally posted here:
>
> <http://gcc.gnu.org/ml/gcc-patches/2013-01/msg01210.html>.
>
> I corrected a build problem with ARM by including "tm_p.h" and an ICE
> caused by NULL_TREE argument being passed to fold_binary () inside
> refine_range_plus (). Also, TODO_ggc_collect has been removed in the
> gimple_opt_pass struct.
>
> I bootstrapped and regression tested on x86_64-unknown-linux-gnu and
> arm-none-linux-gnueabi. OK for trunk?
As we are doing switch-to-if conversion in the pass after this it looks like
as if we can save us intermediate code generation if the two passes were
unified? That is, have a analysis phase that populates an internal
representation
of the switch / cascaded if and peforms transforms based on a single analysis
of that representation.
I also dislike the two passes being in early optimizations - that way they do
not see the effects of IPA inlining / LTO IPA-CP transforms. I'd rather move
it way down towards RTL expansion (though eventually some may say that
switch-conversion may enable vectorization opportunities for example).
That wasn't a patch review of course.
Richard.
> Cesar
>
>
> 2013-06-21 Tom de Vries <tom@codesourcery.com>
> Cesar Philippidis <cesar@codesourcery.com>
>
> * tree-if-switch-conversion.c: New pass.
> * tree-pass.h (pass_if_to_switch): Declare.
> * common.opt (ftree-if-to-switch-conversion): New switch.
> * opts.c (default_options_table): Set flag_tree_if_to_switch_conversion
> at -O2 and higher.
> * passes.c (init_optimization_passes): Use new pass.
> * doc/invoke.texi (-ftree-if-to-switch-conversion): New item.
> (Optimization Options, option -O2): Add -ftree-if-to-switch-conversion.
> * Makefile.in (OBJS): Add tree-if-switch-conversion.o.
> (tree-if-switch-conversion.o): New rule.
> * tree.h (expand_switch_using_bit_tests_p): Declare as extern.
> * tree-switch-conversion.c (expand_switch_using_bit_tests_p): Remove
> static from definition.
>
> * gcc.dg/if-to-switch.c: New test.
> * gcc.dg/if-to-switch.c-2: Same.
> * gcc.dg/if-to-switch.c-3: Same.
> * gcc.dg/tree-ssa/vrp33.c: Run with -fno-tree-if-to-switch-conversion.
> * gcc.dg/tree-ssa/vrp63.c: Same.
> * gcc.dg/tree-ssa/vrp64.c: Same.
> * gcc.dg/pr21643.c: Same.
More information about the Gcc-patches
mailing list