On Thu, Mar 29, 2012 at 5:25 PM, Bin.Cheng <amker.ch...@gmail.com> wrote:
> On Thu, Mar 29, 2012 at 6:14 PM, Richard Guenther
> <richard.guent...@gmail.com> wrote:
>> On Thu, Mar 29, 2012 at 12:10 PM, Bin.Cheng <amker.ch...@gmail.com> wrote:
>>> On Thu, Mar 29, 2012 at 6:07 PM, Richard Guenther
>>> <richard.guent...@gmail.com> wrote:
>>>> On Thu, Mar 29, 2012 at 12:02 PM, Bin.Cheng <amker.ch...@gmail.com> wrote:
>>>>> Hi,
>>>>> Following is the tree dump of 094t.pre for a test program.
>>>>> Question is loads of D.5375_12/D.5375_14 are redundant on path <bb2,
>>>>> bb7, bb5, bb6>,
>>>>> but why not lowered into basic block 3, where it is used.
>>>>>
>>>>> BTW, seems no tree pass handles this case currently.
>>>>
>>>> tree-ssa-sink.c should do this.
>>>>
>>> It does not work for me, I will double check and update soon.
>>
>> Well, "should" as in, it's the place to do it.  And certainly the pass can 
>> sink
>> loads, so this must be a missed optimization.
>>
> Curiously, it is said explicitly that "We don't want to sink loads from 
> memory."
> in tree-ssa-sink.c function statement_sink_location, and the condition is
>
>  if (stmt_ends_bb_p (stmt)
>      || gimple_has_side_effects (stmt)
>      || gimple_has_volatile_ops (stmt)
>      || (gimple_vuse (stmt) && !gimple_vdef (stmt))
> <-----------------check load
>      || (cfun->has_local_explicit_reg_vars
>          && TYPE_MODE (TREE_TYPE (gimple_assign_lhs (stmt))) == BLKmode))
>    return false;
>
> I haven't found any clue about this decision in ChangeLogs.

Ah, that's probably because usually you want to hoist loads and sink stores,
separating them (like a scheduler would do).  We'd want to restrict sinking
of loads to sink into not post-dominated regions (thus where they end up
being executed less times).

Richard.

>
> --
> Best Regards.

Reply via email to