On Thu, Jul 12, 2012 at 2:24 PM, Steven Bosscher <stevenb....@gmail.com> wrote:
> Hello,
>
> The global variable first_pass_instance exists to hack jump threading,
> see tree-pass.h:
>
> /* Set to true if the pass is called the first time during compilation of the
>    current function.  Note that using this information in the optimization
>    passes is considered not to be clean, and it should be avoided if possible.
>    This flag is currently used to prevent loops from being peeled repeatedly
>    in jump threading; it will be removed once we preserve loop structures
>    throughout the compilation -- we will be able to mark the affected loops
>    directly in jump threading, and avoid peeling them next time.  */
> extern bool first_pass_instance;
>
> AFAIU, GCC now actually does preserve loops, so it should be possible
> to remove this hack.
>
> But the recent changes in tree-ssa-reassoc.c introduced a new user of
> first_pass_instance (apparently a fat comment discouraging its use is
> not enough...).
>
> The attached patch fixes this by splitting pass_reassoc in an early
> and a late pass. The pass names are reassoc1 and reassoc2 to avoid
> changing a large number of test cases. Admittedly also not ideal, but
> better than first_pass_instance.
>
> Richi, could you please have a look at jump threading, and see if
> first_pass_instance can be remove?
>
> Bootstrapped&tested on x86_64-unknown-linux-gnu. OK for trunk?

This was proposed before and I did not like that, it makes -fdump-tree-reassoc
non-functional (you have to use -fdump-tree-reassoc1 -fdump-tree-reassoc2).
I much prefer an internal "hack" than such externally visible oddity.

That said, add to struct pass a member "instance number" which a
pass can check via current_pass.

Richard.

> Ciao!
> Steven
>
>         * tree-ssa-reassoc.c (linearize_expr_tree, undistribute_ops_list,
>         reassociate_bb, do_reassoc, execute_reassoc): Take extra EARLY_PASS
>         bool argument to distinguish between the early and late reassociation
>         pass.
>         (acceptable_pow_call): Do not look at first_pass_instance.
>         (execute_early_reassoc, execute_late_reassoc): New functions.
>         (pass_early_reassoc, pass_late_reassoc): New gimple_opt_pass structs.
>         (pass_reassoc): Removed.
>         * tree-pass.h (pass_reassoc): Removed.
>         (pass_early_reassoc, pass_late_reassoc): Declare.
>         * passes.c (init_optimization_passes): Schedule pass_early_reassoc and
>         pass_late_reassoc instead of pass_reassoc.

Reply via email to