[tree-ssa] Work around for an unfortunate fold-const vs. tree-optimizer interaction

law@redhat.com law@redhat.com
Mon Nov 10 20:08:00 GMT 2003


In message <7123585.1068139442266.SLOX.WebMail.wwwrun@groupware.suse.de>, Steve
n Bosschner writes:
 >Hi,
 >
 >gcc.dg/tree-ssa/ssa-ccp-5.c is FAILing because we've already lost the
 > ability to propagate the known value of a variable into the branches of
 > the conditional even before reaching the tree optimizers (in fact, already
 > in the front end).
[ ... ]
Well, IMHO, the optimizers should be able to handle this kind of code.
A user could create code like this just as easily as fold_truthop.

What's needed here is a bit of knowledge to use the result of a
later conditional to determine the values of expressions which
occurred before the conditional.


test55 (x, y)
{
  int u;
  _Bool T.3;
  _Bool T.2;
  _Bool T.1;

  T.1_2 = x_1 == 5
  T.2_4 = y_3 != 0
  T.3_5 = T.1_2 && T.2_4
  if (T.3_5)
    {
      goto <Ue800>;
    }
  else
    {
      goto <Ue880>;
    }
<Ue800>:;
  u_6 = x_1 + 22
  if (u_6 != 27)
    {
      goto <Ue900>;
    }
  else
    {
      goto <Ue880>;
    }
<Ue900>:;
  link_error ()   /* we scan the tree dump for this, and die.  */
  goto <Ue880>;
<Ue880>:;
<Uea80>:;
}

ie, when T.3_5 is true we know that T.1_2 and T.2_4 must also be true.

When T.1_2 is true, we know that x1 == 5.  When T.2_4 is true y3 != 0.

I don't think this will be terribly difficult to add to our optimizers,
and in fact, it's closely related to some stuff Jason and I briefly
discussed. 

Mostly this is just a matter of following the use-def chains backwards
and creating temporary equivalences.



jeff



More information about the Gcc-patches mailing list