On 11/19/14 06:12, Richard Biener wrote:

PR63677 shows that late complete unrolling can expose quite some memory
CSE opportunities
Yes, we saw the same thing with unrolling in RTL. So this is not a surprise at all.



(and followup simplifications) which we fail to
exploit because currently DOMs ability to do memory CSE is quite
limited (it requires the redundant load to optimize to directly follow the
load or store).  This is actually a regression from before
alias-improvements, thus to the time where we had multiple virtual
operand symbols which made us handle some cases better than now
with a single memory operand symbol.
I certainly wasn't aware of the "directly follow" requirement -- it should just be depending on the state of the operands, both real and virtual.

Certainly the change away from multiple virtual operand symbols to a single one has hurt DOM's ability to perform CSE of loads. Those changes went in while I wasn't doing GCC work, so I never looked at how bad they mucked things up.


The easiest way to do that is to no longer hash virtual operands
and use the expression hash lookup result as "candidate" if
the expression involves memory.  We can then verify if the candidate
can be used by using the alias walker to walk to the candidate.
If there is an intermediate possibly aliasing stmt we simply
replace the hashtable entry and set up enough info to be able
to rewind to the previous state during unwinding.
Seems quite reasonable.

2014-11-19   Richard Biener  <rguent...@suse.de>

        PR tree-optimization/63677
        * tree-ssa-dom.c: Include gimplify.h for unshare_expr.
        (avail_exprs_stack): Make a vector of pairs.
        (struct hash_expr_elt): Replace stmt member with vop member.
        (expr_elt_hasher::equal): Simplify.
        (initialize_hash_element): Adjust.
        (initialize_hash_element_from_expr): Likewise.
        (dom_opt_dom_walker::thread_across_edge): Likewise.
        (record_cond): Likewise.
        (dom_opt_dom_walker::before_dom_children): Likewise.
        (print_expr_hash_elt): Likewise.
        (remove_local_expressions_from_table): Restore previous state
        if requested.
        (record_equivalences_from_stmt): Record &x + CST as constant
        &MEM[&x, CST] for further propagation.
        (vuse_eq): New function.
        (lookup_avail_expr): For loads use the alias oracle to see
        whether a candidate from the expr hash is usable.
        (avail_expr_hash): Do not hash VUSEs.

        * gcc.dg/tree-ssa/ssa-dom-cse-2.c: New testcase.
        * gcc.dg/tree-ssa/ssa-dom-cse-3.c: Likewise.
Looks good to me.

Jeff


Reply via email to