(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.c-torture/
execute/
pr51933.c
       1  /* PR rtl-optimization/51933 */
       2  
       3  static signed char v1;
       4  static unsigned char v2[256], v3[256];
       5  
       6  __attribute__((noclone, noinline)) void
       7  foo (void)
       8  {
       9  #if defined(__s390__) && !defined(__zarch__)
      10    /* S/390 31 bit cannot deal with more than one literal pool
      11       reference per insn.  */
      12    asm volatile ("" : : "g" (&v1) : "memory");
      13    asm volatile ("" : : "g" (&v2[0]));
      14    asm volatile ("" : : "g" (&v3[0]));
      15  #else
      16    asm volatile ("" : : "g" (&v1), "g" (&v2[0]), "g" (&v3[0]) : "memory");
      17  #endif
      18  }
      19  
      20  __attribute__((noclone, noinline)) int
      21  bar (const int x, const unsigned short *y, char *z)
      22  {
      23    int i;
      24    unsigned short u;
      25    if (!v1)
      26      foo ();
      27    for (i = 0; i < x; i++)
      28      {
      29        u = y[i];
      30        z[i] = u < 0x0100 ? v2[u] : v3[u & 0xff];
      31      }
      32    z[x] = '\0';
      33    return x;
      34  }
      35  
      36  int
      37  main (void)
      38  {
      39    char buf[18];
      40    unsigned short s[18];
      41    unsigned char c[18] = "abcdefghijklmnopq";
      42    int i;
      43    for (i = 0; i < 256; i++)
      44      {
      45        v2[i] = i;
      46        v3[i] = i + 1;
      47      }
      48    for (i = 0; i < 18; i++)
      49      s[i] = c[i];
      50    s[5] |= 0x600;
      51    s[6] |= 0x500;
      52    s[11] |= 0x2000;
      53    s[15] |= 0x500;
      54    foo ();
      55    if (bar (17, s, buf) != 17
      56        || __builtin_memcmp (buf, "abcdeghhijkmmnoqq", 18) != 0)
      57      __builtin_abort ();
      58    return 0;
      59  }