1  /* PR tree-optimization/94800 */
       2  /* { dg-do compile { target int32plus } } */
       3  /* { dg-require-effective-target popcountl } */
       4  /* { dg-options "-O2 -fdump-tree-optimized" } */
       5  
       6  #if __SIZEOF_LONG__ == 4
       7  const unsigned long m1  = 0x55555555UL;
       8  const unsigned long m2  = 0x33333333UL;
       9  const unsigned long m4  = 0x0F0F0F0FUL;
      10  const int shift = 24;
      11  #else
      12  const unsigned long m1  = 0x5555555555555555UL;
      13  const unsigned long m2  = 0x3333333333333333UL;
      14  const unsigned long m4  = 0x0f0f0f0f0f0f0f0fUL;
      15  const int shift = 56;
      16  #endif
      17  
      18  
      19  int popcount64c(unsigned long x)
      20  {
      21      x -= (x >> 1) & m1;
      22      x = (x & m2) + ((x >> 2) & m2);
      23      x = (x + (x >> 4)) & m4;
      24      x += (x << 8);
      25      x += (x << 16);
      26  #if __SIZEOF_LONG__ != 4
      27      x += (x << 32);
      28  #endif
      29      return x >> shift;
      30  }
      31  
      32  /* { dg-final { scan-tree-dump-times "\.POPCOUNT" 1 "optimized" } } */