https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70879

            Bug ID: 70879
           Summary: Missed jump threading opportunity with multiple !=
                    conditions
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppalka at gcc dot gnu.org
  Target Milestone: ---

Test case:

void bar (void);
void baz (void);

void
foo (int a)
{
  if (a != 5 && a != 10)
    bar ();
  if (a == 10)
    baz ();
}

VRP1 dump:

SSA form after inserting ASSERT_EXPRs
void foo(int) (int a)
{
  bool _4;
  bool _5;
  bool _6;

  <bb 2>:
  _4 = a_3(D) != 5;
  _5 = a_3(D) != 10;
  _6 = _4 & _5;
  if (_6 != 0)
    goto <bb 3>;
  else
    goto <bb 4>;

  <bb 3>:
  a_10 = ASSERT_EXPR <a_3(D), a_3(D) != 5>;
  a_11 = ASSERT_EXPR <a_10, a_10 != 10>;
  bar ();

  <bb 4>:
  if (a_3(D) == 5)
    goto <bb 5>;
  else
    goto <bb 6>;

  <bb 5>:
  baz ();

  <bb 6>:
  return;

}

If bar is called then baz cannot possibly be called so in bb3 we ought to jump
straight to bb6 instead of falling through to bb4.

The problem is that when discovering dominating ASSERT_EXPRs of a_3 we only
look at the immediate uses of a_3 so we use the ASSERT_EXPR a_10 instead of
a_11, but the latter contains more information.

Reply via email to