(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
tree-ssa/
pr94802-1.c
       1  /* PR tree-optimization/94802 */
       2  /* { dg-do run } */
       3  /* { dg-options "-O2 -fdump-tree-optimized" } */
       4  /* { dg-final { scan-tree-dump-not " = __builtin_clz " "optimized" } } */
       5  
       6  __attribute__((noipa)) int
       7  f1 (int a, int b)
       8  {
       9    return __builtin_clz (a - b) != 0;
      10  }
      11  
      12  __attribute__((noipa)) int
      13  f2 (int x)
      14  {
      15    return __builtin_clz (x) == 0;
      16  }
      17  
      18  __attribute__((noipa)) int
      19  f3 (int x)
      20  {
      21    return __builtin_clz (x) != 0;
      22  }
      23  
      24  __attribute__((noipa)) int
      25  f4 (int a, int b)
      26  {
      27    return __builtin_clz (a - b) == sizeof (int) * __CHAR_BIT__ - 1;
      28  }
      29  
      30  __attribute__((noipa)) int
      31  f5 (int x)
      32  {
      33    return __builtin_clz (x) == sizeof (int) * __CHAR_BIT__ - 1;
      34  }
      35  
      36  __attribute__((noipa)) int
      37  f6 (int x)
      38  {
      39    return __builtin_clz (x) != sizeof (int) * __CHAR_BIT__ - 1;
      40  }
      41  
      42  int
      43  main ()
      44  {
      45    if (f1 (5, 7) != 0
      46        || f1 (7, 5) != 1
      47        || f2 (1) != 0
      48        || f2 (137) != 0
      49        || f2 (-1) != 1
      50        || f2 (-137) != 1
      51        || f3 (1) != 1
      52        || f3 (137) != 1
      53        || f3 (-1) != 0
      54        || f3 (-137) != 0
      55        || f4 (5, 4) != 1
      56        || f4 (6, 4) != 0
      57        || f4 (4, 5) != 0
      58        || f5 (1) != 1
      59        || f5 (17) != 0
      60        || f5 (-1) != 0
      61        || f5 (-17) != 0
      62        || f6 (1) != 0
      63        || f6 (17) != 1
      64        || f6 (-1) != 1
      65        || f6 (-17) != 1)
      66      __builtin_abort ();
      67    return 0;
      68  }