------- Comment #4 from rguenth at gcc dot gnu dot org  2008-11-01 17:11 -------
We need to be careful with simplifying to SSA_NAMEs as the following example
shows:

int foo (int i, int b)
{
  int mask;
  int result;
  if (b)
    mask = -1;
  else
    mask = 0;
  result = i + 1;
  result = result & mask;
  return result;
}

we have a phi-translation for result & mask that is 0 or result dependent
on the path through the CFG.  But we cannot insert this as a PHI as one
argument (result with value i + 1) is not available there.

The PRE of 4.3 inserts i + 1, re-generating the expression recursively and
exposing a code hoisting opportunity:

<bb 2>:
  if (b_2(D) != 0)
    goto <bb 5>;
  else
    goto <bb 3>;

<bb 5>:
  pretmp.6_10 = i_5(D) + 1;
  pretmp.6_11 = pretmp.6_10;
  goto <bb 4>;

<bb 3>:
  pretmp.6_13 = i_5(D) + 1;

<bb 4>:
  # prephitmp.7_14 = PHI <pretmp.6_10(5), pretmp.6_13(3)>
  # prephitmp.7_12 = PHI <pretmp.6_11(5), 0(3)>
  # mask_1 = PHI <-1(5), 0(3)>
  result_6 = prephitmp.7_14;
  result_7 = prephitmp.7_12;
  return result_7;

I don't think we want to do this now (without code hoisting implemented), but
for cases where result_6 is available we surely want it.

I'm trying to find a way to detect whether it is safe to phi-translate to
result_6.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dberlin at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37542

Reply via email to