Richard Guenther - Re: [PATCH] Fix PR19431, not folding *& if a PHI node is involved (original) (raw)

This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

On Sun, 11 Feb 2007, Steven Bosscher wrote:

On Sunday 11 February 2007 16:14, Richard Guenther wrote:

This allows for less addressable variables from using std::min/max. I placed this in the forwprop pass because that pass already deals with *& folding and because forwprop is run during early optimizations which makes it possible for the first phiopt pass to recognize std::min/max as MIN/MAX_EXPR.

Can the first PHIOPT pass also recognize the MIN/MAX_EXPR if you perform this transformation before the scalar transformations in phiopt?

What place exactly did you have in mind? I didn't really look at adding this to PHIOPT, but I expect to recognize the MIN/MAX_EXPR we need at least copyprop/ssa_rename the extra loads (see below) (actually this currently happens because we go out of and back into ssa and get rid of the addressable of x and y) and do a cleanup of the CFG. After this transformation (forwprop1) we have

int test_min_ref(int, int) (x, y) { int D.2469; int D.2468; int D.2464; int D.2465; const int & x; int D.2446;

<bb 2>: D.2464_6 = x; D.2465_7 = y; if (D.2464_6 < D.2465_7) goto ; else goto ;

:; D.2468_5 = y; goto <bb 4> ();

:; D.2469_4 = x;

D.2446_2 = PHI <D.2468_5(5), D.2469_4(3)>

x_8 = PHI <&y(5), &x(3)>

:; x_9 = x_8; x_1 = x_9; return D.2446_2;

}

and phiopt needs to identify the PHI arguments with the comparison operands.

  •   update_stmt (tmp);
  •   mark_symbols_for_renaming (tmp);

Why mark the symbols for renaming? You should be able to construct valid SSA form statements yourself here, and AFAICT you're actually doing so, too.

As the old phi arguments look like &x I need to add a temporary and load from x, so actually the transformation result looks like

VUSE tmpx_1 = x; goto :; VUSE tmpy_1 = y;

z_2 = PHI <tmpx_1, tmpy_1>

:;

so the renaming is for the VUSEs of the loads added.

Richard.

-- Richard Guenther rguenther@suse.de Novell / SUSE Labs


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]