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/15353] New: [tree-ssa] Merge two "if"s if one subsumes the other.


void bar (void);

void
foo (int a, int b)
{
  do
    {
      if (a < b)
	break;
      if (a != b)
	break;
      bar ();
    }
  while (0);
}

I get:

foo (a, b)
{
<bb 0>:
  if (a_1 < b_2) goto <L2>; else goto <L0>;

<L0>:;
  if (a_1 != b_2) goto <L2>; else goto <L1>;

<L1>:;
  bar () [tail call];

<L2>:;
  return;

}

Note that the second "if" completely subsumes the first.
We would like:

foo (a, b)
{
<bb 0>:
  if (a_1 == b_2) goto <L0>; else goto <L1>;

<L0>:;
  bar () [tail call];

<L1>:;
  return;

}

This comes from shorten_compare from c-common.c.

-- 
           Summary: [tree-ssa] Merge two "if"s if one subsumes the other.
           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=15353


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