(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
torture/
pr45830.c
       1  /* PR tree-optimization/45830 */
       2  /* { dg-do run } */
       3  /* { dg-additional-options "-fno-tree-switch-conversion" { target avr-*-* } } */
       4  
       5  extern void abort (void);
       6  
       7  long long va, vb, vc, vd, ve;
       8  
       9  __attribute__((noinline)) int
      10  foo (int x)
      11  {
      12    long long a, b, c, d, e;
      13    switch (x)
      14      {
      15      case 0:
      16      case 3:
      17      case 1:
      18      case 2:
      19      case 4:
      20        a = 1;
      21        b = 129;
      22        c = -12;
      23        d = -4;
      24        e = 128;
      25        break;
      26      case 23:
      27      case 26:
      28      case 19:
      29      case 65:
      30      case 5:
      31        a = 2;
      32        b = 138;
      33        c = 115;
      34        d = 128;
      35        e = -16;
      36        break;
      37      case 21:
      38      case 20:
      39      case 22:
      40      case 38:
      41      case 27:
      42      case 66:
      43      case 45:
      44      case 47:
      45        a = 3;
      46        b = 6;
      47        c = 127;
      48        d = 25;
      49        e = 257;
      50        break;
      51      default:
      52        a = 0;
      53        b = 18;
      54        c = 0;
      55        d = 64;
      56        e = 32768L;
      57        break;
      58      }
      59    va = a;
      60    vb = b;
      61    vc = c;
      62    vd = d;
      63    ve = e;
      64  }
      65  
      66  int
      67  bar (int x)
      68  {
      69    if (x < 0)
      70      return 3;
      71    if (x < 5)
      72      return 0;
      73    if (x == 5 || x == 19 || x == 23 | x == 26 || x == 65)
      74      return 1;
      75    if ((x >= 20 && x <= 22) || x == 27 || x == 38
      76        || x == 45 || x == 47 || x == 66)
      77      return 2;
      78    return 3;
      79  }
      80  
      81  long long expected[] =
      82  { 1, 129, -12, -4, 128, 2, 138, 115, 128, -16,
      83    3, 6, 127, 25, 257, 0, 18, 0, 64, 32768L };
      84  
      85  int
      86  main (void)
      87  {
      88    int i, v;
      89    for (i = -4; i < 70; i++)
      90      {
      91        foo (i);
      92        v = bar (i);
      93        if (va != expected[5 * v] || vb != expected[5 * v + 1]
      94  	  || vc != expected[5 * v + 2] || vd != expected[5 * v + 3]
      95  	  || ve != expected[5 * v + 4])
      96  	abort ();
      97      }
      98    return 0;
      99  }