(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
store_merging_18.c
       1  /* PR tree-optimization/83843 */
       2  /* { dg-do run } */
       3  /* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-store-merging" } */
       4  /* { dg-final { scan-tree-dump-times "Merging successful" 3 "store-merging" { target { store_merge && { ! arm*-*-* } } } } } */
       5  
       6  __attribute__((noipa)) void
       7  foo (unsigned char *buf, unsigned char *tab)
       8  {
       9    unsigned v = tab[1] ^ (tab[0] << 8);
      10    buf[0] = ~(v >> 8);
      11    buf[1] = ~v;
      12  }
      13  
      14  __attribute__((noipa)) void
      15  bar (unsigned char *buf, unsigned char *tab)
      16  {
      17    unsigned v = tab[1] ^ (tab[0] << 8);
      18    buf[0] = (v >> 8);
      19    buf[1] = ~v;
      20  }
      21  
      22  __attribute__((noipa)) void
      23  baz (unsigned char *buf, unsigned char *tab)
      24  {
      25    unsigned v = tab[1] ^ (tab[0] << 8);
      26    buf[0] = ~(v >> 8);
      27    buf[1] = v;
      28  }
      29  
      30  int
      31  main ()
      32  {
      33    volatile unsigned char l1 = 0;
      34    volatile unsigned char l2 = 1;
      35    unsigned char buf[2];
      36    unsigned char tab[2] = { l1 + 1, l2 * 2 };
      37    foo (buf, tab);
      38    if (buf[0] != (unsigned char) ~1 || buf[1] != (unsigned char) ~2)
      39      __builtin_abort ();
      40    buf[0] = l1 + 7;
      41    buf[1] = l2 * 8;
      42    bar (buf, tab);
      43    if (buf[0] != 1 || buf[1] != (unsigned char) ~2)
      44      __builtin_abort ();
      45    buf[0] = l1 + 9;
      46    buf[1] = l2 * 10;
      47    baz (buf, tab);
      48    if (buf[0] != (unsigned char) ~1 || buf[1] != 2)
      49      __builtin_abort ();
      50    return 0;
      51  }