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

            Bug ID: 68498
           Summary: Replace LOOPS_MAY_HAVE_MULTIPLE_LATCHES with
                    LOOPS_HAVE_SINGLE_LATCH
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Consider apply_loop_flags:
...
static void
apply_loop_flags (unsigned flags)
{
  if (flags & LOOPS_MAY_HAVE_MULTIPLE_LATCHES)
    {
      /* If the loops may have multiple latches, we cannot canonicalize
         them further (and most of the loop manipulation functions will
         not work).  However, we avoid modifying cfg, which some
         passes may want.  */
      gcc_assert ((flags & ~(LOOPS_MAY_HAVE_MULTIPLE_LATCHES
                             | LOOPS_HAVE_RECORDED_EXITS)) == 0);
      loops_state_set (LOOPS_MAY_HAVE_MULTIPLE_LATCHES);
    }
  else
    disambiguate_loops_with_multiple_latches ();

  /* Create pre-headers.  */
  if (flags & LOOPS_HAVE_PREHEADERS)
    {
      int cp_flags = CP_SIMPLE_PREHEADERS;

      if (flags & LOOPS_HAVE_FALLTHRU_PREHEADERS)
        cp_flags |= CP_FALLTHRU_PREHEADERS;

      create_preheaders (cp_flags);
    }

  /* Force all latches to have only single successor.  */
  if (flags & LOOPS_HAVE_SIMPLE_LATCHES)
    force_single_succ_latches ();

  /* Mark irreducible loops.  */
  if (flags & LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)
    mark_irreducible_loops ();

  if (flags & LOOPS_HAVE_RECORDED_EXITS)
    record_loop_exits ();
}
...

Most properties in there have a handling bit: if property, do something.

The odd one out is LOOPS_MAY_HAVE_MULTIPLE_LATCHES, where we have if !property,
do something.

LOOPS_MAY_HAVE_MULTIPLE_LATCHES is not really a property, it's the absence of
LOOPS_MAY_HAVE_MULTIPLE_LATCHES that's a property, which we might call
LOOPS_HAVE_SINGLE_LATCH).

It would properly be better to replace uses of LOOPS_MAY_HAVE_MULTIPLE_LATCHES
with uses of LOOPS_HAVE_SINGLE_LATCH. We would get in apply_loop_flags:
...
  if (flags & LOOPS_HAVE_SINGLE_LATCH)
    disambiguate_loops_with_multiple_latches ();
  else
    {
      /* If the loops may have multiple latches, we cannot canonicalize
         them further (and most of the loop manipulation functions will
         not work).  However, we avoid modifying cfg, which some
         passes may want.  */
      gcc_assert ((flags & ~(LOOPS_HAVE_RECORDED_EXITS)) == 0);
    }
...

Reply via email to