(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
20111227-2.c
       1  /* Testcase derived from 20111227-1.c to ensure that REE is combining
       2     redundant zero extends with zero extend to wider mode.  */
       3  /* { dg-do compile  { target i?86-*-* x86_64-*-* } } */
       4  /* { dg-options "-fdump-rtl-ree -O -free" } */
       5  
       6  extern void abort (void);
       7  
       8  unsigned short s;
       9  unsigned int i;
      10  unsigned long l;
      11  unsigned char v = -1;
      12  
      13  void __attribute__((noinline,noclone))
      14  bar (int t)
      15  {
      16    if (t == 2 && s != 0xff)
      17      abort ();
      18    if (t == 1 && i != 0xff)
      19      abort ();
      20    if (t == 0 && l != 0xff)
      21      abort ();
      22  }
      23  
      24  void __attribute__((noinline,noclone))
      25  foo (unsigned char *a, int t)
      26  {
      27    unsigned char r = v;
      28  
      29    if (t == 2)
      30      s = (unsigned short) r;
      31    else if (t == 1)
      32      i = (unsigned int) r;
      33    else if (t == 0)
      34      l = (unsigned long) r;
      35    bar (t);
      36  }
      37  
      38  int main(void)
      39  {
      40    foo (&v, 0);
      41    foo (&v, 1);
      42    foo (&v, 2);
      43    return 0;
      44  }
      45  /* { dg-final { scan-rtl-dump "Elimination opportunities = 3 realized = 3" "ree" } }  */