This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/52254] New: VRP does not fold (~a) & N to a ^ N if a has range [0, N]


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

             Bug #: 52254
           Summary: VRP does not fold (~a) & N to a ^ N if a has range [0,
                    N]
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pinskia@gcc.gnu.org


While working on moving fold-const.c bit expression optimizations to a SSA
based optimization, I found that if we optimize (a^N)&N to ~a & N, VRP does not
change that to just a ^ N.
Simple example:
/* { dg-do compile } */
/* { dg-options "-O2 -fno-tree-ccp -fdump-tree-vrp1" } */

int f(int x)
{
  if (x >= 0 && x <= 3)
    {
      x = (x ^ 3) & 3;
    }
  return x;
}

/* { dg-final { scan-tree-dump-times " & 3;" 0 "vrp1" { xfail *-*-* } } } */
/* { dg-final { cleanup-tree-dump "vrp1" } } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]