This is the mail archive of the gcc-bugs@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]

[Bug tree-optimization/20913] New: copy-prop does not fold conditionals


Consider:

int
foo (int a, int b, int c, int d)
{
  int x, y;

  b = a;
  if (a == b)
    x = c;
  else
    x = d;

  if (x == c)
    return a;
  else
    return b;
}

Run ./cc1 -quiet -O2 -fno-tree-dominator-opts.

Here is the result.

foo (a, b, c, d)
{
  int y;
  int x;
  int D.1145;

<bb 0>:
  b_4 = a_3;
  x_11 = c_5;

  # x_1 = PHI <c_5(0)>;
<L2>:;
  if (x_1 == c_5) goto <L3>; else goto <L4>;

<L3>:;
  a_8 = a_3;
  goto <bb 4> (<L5>);

<L4>:;
  b_7 = a_3;

  # a_2 = PHI <a_3(2), a_3(3)>;
<L5>:;
  return a_3;

}

Note that x == c, but the copy-prop doesn't fold the "if" statement.

This is because find_taken_edge no longer folds conditionals.

-- 
           Summary: copy-prop does not fold conditionals
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: kazu at cs dot umass dot edu
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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