1  /* { dg-do compile } */
       2  /* { dg-options "-O2 -fno-tree-loop-optimize -fdump-tree-optimized" } */
       3  
       4  #define PREC (__CHAR_BIT__)
       5  
       6  int clz_count1 (unsigned char b) {
       7      int c = 0;
       8  
       9      if (b == 0)
      10        return 0;
      11  
      12      while (!(b & (1 << (PREC - 1)))) {
      13  	b <<= 1;
      14  	c++;
      15      }
      16      if (c <= PREC - 1)
      17        return 0;
      18      else
      19        return 34567;
      20  }
      21  
      22  int clz_count2 (unsigned char b) {
      23      int c = 0;
      24  
      25      if (b == 0)
      26        return 0;
      27  
      28      while (!(b & (1 << PREC - 1))) {
      29  	b <<= 1;
      30  	c++;
      31      }
      32      if (c <= PREC - 2)
      33        return 0;
      34      else
      35        return 76543;
      36  }
      37  
      38  int ctz_count1 (unsigned char b) {
      39      int c = 0;
      40  
      41      if (b == 0)
      42        return 0;
      43  
      44      while (!(b & 1)) {
      45  	b >>= 1;
      46  	c++;
      47      }
      48      if (c <= PREC - 1)
      49        return 0;
      50      else
      51        return 23456;
      52  }
      53  
      54  int ctz_count2 (unsigned char b) {
      55      int c = 0;
      56  
      57      if (b == 0)
      58        return 0;
      59  
      60      while (!(b & 1)) {
      61  	b >>= 1;
      62  	c++;
      63      }
      64      if (c <= PREC - 2)
      65        return 0;
      66      else
      67        return 65432;
      68  }
      69  /* { dg-final { scan-tree-dump-times "34567" 0 "optimized" } } */
      70  /* { dg-final { scan-tree-dump-times "76543" 1 "optimized" } } */
      71  /* { dg-final { scan-tree-dump-times "23456" 0 "optimized" } } */
      72  /* { dg-final { scan-tree-dump-times "65432" 1 "optimized" } } */