This is the mail archive of the gcc@gcc.gnu.org mailing 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]

Canonical form of the RTL CFG for an IF-THEN-ELSE block?


Hi,

We would like to know if there is some way to find the true and false
branches of a conditional jump in RTL.  In the tree CFG, we have two
edge flags for that, EDGE_{TRUE,FALSE}_VALUE, but those flags have no
meaning for the RTL CFG.  So our question is, is there some other way
to tell what edge will be taken in a conditional jump if the condition
is true?

It seems that some passes assume a canonical form of IF-THEN-ELSE even
on RTL.  From ifcvt.c:find_if_header:

  /* The THEN edge is canonically the one that falls through.  */
  if (then_edge->flags & EDGE_FALLTHRU)
    ;
  else if (else_edge->flags & EDGE_FALLTHRU)
    {
      edge e = else_edge;
      else_edge = then_edge;
      then_edge = e;
    }
  else
    /* Otherwise this must be a multiway branch of some sort.  */
    return NULL;

On the other hand, in cfgexpand.c:expand_gimple_cond_expr we have,

  false_edge->flags |= EDGE_FALLTHRU;

and loop-unswitch.c assumes that the BRANCH_EDGE is the true_edge:

  true_edge = BRANCH_EDGE (unswitch_on_alt);
  false_edge = FALLTHRU_EDGE (unswitch_on);

So which is it?  Is BRANCH_EDGE always taken if the condition is true,
or FALLTHRU_EDGE, or do you have to look at the condition to know?
Who knows an answer?  :-)

Gr.
Steven


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