aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/cltz-complement-max.c
blob: 7b3599a8a4e7074e8dcac848e77c2d6ce04cc36a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* { dg-do compile } */
/* { dg-options "-O2 -fno-tree-loop-optimize -fdump-tree-optimized" } */

#define PREC (__CHAR_BIT__)

#if __SIZEOF_INT__ < 4
#define int __INT32_TYPE__
#endif

int clz_complement_count1 (unsigned char b) {
    int c = 0;

    while (b) {
	b >>= 1;
	c++;
    }
    if (c <= PREC)
      return 0;
    else
      return 34567;
}

int clz_complement_count2 (unsigned char b) {
    int c = 0;

    while (b) {
	b >>= 1;
	c++;
    }
    if (c <= PREC - 1)
      return 0;
    else
      return 76543;
}

int ctz_complement_count1 (unsigned char b) {
    int c = 0;

    while (b) {
	b <<= 1;
	c++;
    }
    if (c <= PREC)
      return 0;
    else
      return 23456;
}

int ctz_complement_count2 (unsigned char b) {
    int c = 0;

    while (b) {
	b <<= 1;
	c++;
    }
    if (c <= PREC - 1)
      return 0;
    else
      return 65432;
}
/* { dg-final { scan-tree-dump-times "34567" 0 "optimized" } } */
/* { dg-final { scan-tree-dump-times "76543" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times "23456" 0 "optimized" } } */
/* { dg-final { scan-tree-dump-times "65432" 1 "optimized" } } */