[RFC] Move ehcleanup pass to before early SRA

Richard Biener richard.guenther@gmail.com
Wed Jan 15 14:39:00 GMT 2014


On Wed, Jan 15, 2014 at 1:06 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> What you want is tree-eh.c:optimize_clobbers, right?  Can't we
>> do this optimization during EH refactoring / lowering as well?
>
> We need the SSA form for sink_clobbers.

I know, I'm saying it may be possible to implement an equivalent
optimization without SSA form.

>> Also why does SRA refuse to scalarize here?
>
> Because of the EH handler and the following predicate:
>
> /* Disqualify LHS and RHS for scalarization if STMT must end its basic block
>    in modes in which it matters, return true iff they have been disqualified.
>    RHS may be NULL, in that case ignore it.  If we scalarize an aggregate in
>    intra-SRA we may need to add statements after each statement.  This is not
>    possible if a statement unconditionally has to end the basic block.  */
> static bool
> disqualify_ops_if_throwing_stmt (gimple stmt, tree lhs, tree rhs)
> {
>   if ((sra_mode == SRA_MODE_EARLY_INTRA || sra_mode == SRA_MODE_INTRA)
>       && (stmt_can_throw_internal (stmt) || stmt_ends_bb_p (stmt)))
>     {
>       disqualify_base_of_expr (lhs, "LHS of a throwing stmt.");
>       if (rhs)
>         disqualify_base_of_expr (rhs, "RHS of a throwing stmt.");
>       return true;
>     }
>   return false;
> }
>
>> It will end up scalarizing during regular opts as
>>
>> <L1>:
>>   result = decls_support.get_private (100);
>>   result$i_12 = MEM[(struct decls_support__t_private *)&result];
>
> Yes, it's scalarized during SRA but not ESRA because there is an ehcleanup
> pass in-between.  It used to be scalarized during ESRA up to 4.6.x.

I'm saying even ESRA should be able to scalarize it just fine.  It just
needs to be careful where to insert the loads from the aggregate result
(on the single outgoing non-EH edge).

Wouldn't that fix your issue?

>> The current placement of EH cleanup is to make it catch
>> all opportunities before early inlining sees the function as
>> callee.  And I guess both FRE and DCE will expose quite
>> some EH cleanup opportunities especially with non-call-exceptions.
>
> Early inlining or regular inlining (I'm always slightly confused here)?

Early inlining.

> p.adb.003t.original
> p.adb.004t.gimple
> p.adb.005t.nested
> p.adb.006t.omplower
> p.adb.007t.lower
> p.adb.009t.ehopt
> p.adb.010t.eh
> p.adb.011t.cfg
> p.adb.015t.ssa
> p.adb.017t.inline_param1
> p.adb.018t.einline
> p.adb.019t.early_optimizations
> p.adb.020t.copyrename1
> p.adb.021t.ccp1
> p.adb.022t.forwprop1
> p.adb.023t.ealias
> p.adb.024t.esra
> p.adb.025t.fre1
> p.adb.026t.copyprop1
> p.adb.027t.mergephi1
> p.adb.028t.cddce1
> p.adb.029t.eipa_sra
> p.adb.030t.tailr1
> p.adb.031t.switchconv
> p.adb.032t.ehcleanup1
> p.adb.033t.profile_estimate
> p.adb.034t.local-pure-const1
> p.adb.035t.fnsplit
> p.adb.036t.release_ssa
> p.adb.037t.inline_param2
> p.adb.054t.copyrename2
>
> Then we could add another ehcleanup pass before early inlining, i.e. between
> 015t.ssa and 017t.inline_param1, to achieve the same goal.
>
> --
> Eric Botcazou



More information about the Gcc-patches mailing list