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

            Bug ID: 70715
           Summary: SCEV failed to prove no-overflow-ness information
                    unsigned loop IV
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amker at gcc dot gnu.org
  Target Milestone: ---

Hi, below is a case in which SCEV failed to prove no-overflow-ness of converted
unsigned type loop IV.  As a result, the address of pointer dereference isn't
recognized as SCEV.

/* { dg-do compile } */
/* { dg-options "-O3 -fdump-tree-ldist" } */

int
foo (char *p, unsigned n)
{
  while(n--)
    {
      p[n]='A';
    }
  return 0;
}

/* Loop can be transformed into builtin memset since &p[n] is SCEV.  */
/* { dg-final { scan-tree-dump "builtin_memset" "ldist" } } */

Actually, I added code supporting NE_EXPR as comparison code in loop exit
condition for PR68529.  The only problem is: in function
number_of_iterations_exit, control_iv.base is expanded by
expand_simple_operations.
Given we have already encountered problems caused by this kind of expanding, we
may want to remove it in the future.  For the moment, this can be easily fixed
by checking expanded expression in loop_exits_before_overflow.

I am testing a patch for this.

Reply via email to