These two functions should produce the same code:
int f(int y, int x)
{
  return x & ((~x) | y);
}
int g(int y, int x)
{
  return y & x;
}

x & ((~x) | y) is the same as (x & ~x) | (x & y) using distribution and that
becomes (x & y) because (x & ~x) is always 0 and 0 | x is x.

This should be done at both the tree level and the RTL level.


-- 
           Summary: Simple bitwise simplification missed
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


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

Reply via email to