f1 in the following could be optimized to generate the same code as f2.
(Taken from rs6000.c:rs6000_legitimate_offset_address_p.)

int
f1 (unsigned long offset, int x)
{
  unsigned long extra = 0;

  if (x)
    extra = 4;

  return offset < 0x100 && offset + extra < 0x100;
}

int
f2 (unsigned long offset, int x)
{
  unsigned long extra = 0;

  if (x)
    extra = 4;

  return offset < 0x100 - extra;
}


-- 
           Summary: missed vrp optimization with unsigned comparison
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: amodra at bigpond dot net dot au


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26270

Reply via email to