[patch 1/2] PR27313 Discover non-trapping memory accesses

Steven Bosscher stevenb.gcc@gmail.com
Sat Apr 14 14:44:00 GMT 2007


On Saturday 14 April 2007 13:40, Richard Guenther wrote:
> I believe that if we could eliminate the dominating trapping memory
> access as dead we have proved the non-trapping memory accesses
> are also dead (maybe I'm missing something).

This is obviously not true.  Not even within one basic block:

  v_1 = load from X
  v_2 = load from X

You would mark the load to v_2 as not trapping because it is
dominated by the load to v_1, and when v_1 turns out to be dead
code, the load to v_1 would also be removed and you've exposed
the load into v_2.

The questions is, when this can happen.

One obvious case is when tree DCE does not run, but we nuke dead
code on RTL later on.  Another case is when v_1 becomes dead code
after pass_nontrap.

Your new pass runs after FRE, so fully redundant loads without a
store in between should be eliminated. (At least most of the time,
but not always: The dominator tree might change between FRE and
pass_nontrap.)
So I'm guessing that pass_nontrap is probably marking loads which
have a dominating load and a store on the path in between.  If
this is true, then you're relying on the elimination of fully
redundant loads before pass_nontrap.  I don't think this is safe.
(BTW is a store to an address before a load sufficient to prove that
the load cannot trap?)

But, maybe I'm missing something, too :-)

Gr.
Steven



More information about the Gcc-patches mailing list