view gcc/testsuite/gcc.dg/tree-ssa/popcount.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children 1830386684a0
line wrap: on
line source

/* { dg-do compile } */
/* { dg-options "-O3 -fdump-tree-optimized -fno-tree-ch" } */

extern int foo (int);

int PopCount (long b) {
    int c = 0;
    b++;

    while (b) {
	b &= b - 1;
	c++;
    }
    return c;
}
int PopCount2 (long b) {
    int c = 0;

    while (b) {
	b &= b - 1;
	c++;
    }
    foo (c);
    return foo (c);
}

void PopCount3 (long b1) {

    for (long i = 0; i < b1; ++i)
      {
	long b = i;
	int c = 0;
	while (b) {
	    b &= b - 1;
	    c++;
	}
	foo (c);
      }
}

/* { dg-final { scan-tree-dump-times "__builtin_popcount" 3 "optimized" } } */