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 optimization/15352] New: [tree-ssa]


int
foo (int a, int b, int c)
{
  if (a == 1 || b == 2)
    {
      if (a == 1 || c == 3)
	f1 ();
      else
	f2 ();
    }
}

I get:

foo (a, b, c)
{
  _Bool T.4;
  _Bool T.3;
  _Bool T.2;
  _Bool T.1;
  _Bool T.0;

<bb 0>:
  T.0_2 = a_1 == 1;
  T.1_4 = b_3 == 2;
  T.2_5 = T.0_2 || T.1_4;
  if (T.2_5) goto <L0>; else goto <L3>;

<L0>:;
  T.3_8 = c_7 == 3;
  T.4_9 = T.0_2 || T.3_8;
  if (T.4_9) goto <L1>; else goto <L2>;

<L1>:;
  f1 () [tail call];
  goto <bb 4> (<L3>);

<L2>:;
  f2 () [tail call];

<L3>:;
  return;

}

Note that a jump threading opportunity of T.0_2 is missed.
Ideally, we should get something like:

bar (a, b, c)
{
<bb 0>:
  if (a_1 != 1) goto <L0>; else goto <L6>;

<L0>:;
  if (b_3 != 2) goto <L1>; else goto <L4>;

<L1>:;
  return;

<L4>:;
  if (c_2 != 3) goto <L5>; else goto <L6>;

<L5>:;
  f2 () [tail call];
  return;

<L6>:;
  f1 () [tail call];
  return;

}

We should probably prefer short circuit to reduce the number of temporaries
during SSA optimizations to get full exposure to jump threading.
We "un-short-circuit" later as needed.

-- 
           Summary: [tree-ssa]
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Keywords: pessimizes-code
          Severity: enhancement
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        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=15352


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