[Bug tree-optimization/52267] New: a&~N where N has all the bits set up till a specific point can be folded to ((unsigned)a) < N

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Feb 16 03:51:00 GMT 2012


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

             Bug #: 52267
           Summary: a&~N where N has all the bits set up till a specific
                    point can be folded to ((unsigned)a) < N
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pinskia@gcc.gnu.org


Take the following two functions.
int f(int a, int b)
{
  if (a>3||a<0) return a;
  a&=3;
  return a&3;
}

int f1(int a)
{
  if (a&~03)  return a;
  return a&3;
}

They should return just the argument.  Right now the first function does but
not the second.



More information about the Gcc-bugs mailing list