1 /* { dg-do compile } */
2 /* { dg-require-effective-target popcountl } */
3 /* { dg-options "-O3 -fdump-tree-optimized -fno-tree-ch" } */
4 
5 extern int foo (int);
6 
PopCount(long b)7 int PopCount (long b) {
8     int c = 0;
9     b++;
10 
11     while (b) {
12 	b &= b - 1;
13 	c++;
14     }
15     return c;
16 }
PopCount2(long b)17 int PopCount2 (long b) {
18     int c = 0;
19 
20     while (b) {
21 	b &= b - 1;
22 	c++;
23     }
24     foo (c);
25     return foo (c);
26 }
27 
PopCount3(long b1)28 void PopCount3 (long b1) {
29 
30     for (long i = 0; i < b1; ++i)
31       {
32 	long b = i;
33 	int c = 0;
34 	while (b) {
35 	    b &= b - 1;
36 	    c++;
37 	}
38 	foo (c);
39       }
40 }
41 
42 /* { dg-final { scan-tree-dump-times "__builtin_popcount" 3 "optimized" } } */
43