(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
store_merging_19.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 } } } */
       5  
       6  __attribute__((noipa)) void
       7  foo (unsigned char *buf, unsigned char *tab)
       8  {
       9    tab = __builtin_assume_aligned (tab, 2);
      10    buf = __builtin_assume_aligned (buf, 2);
      11    unsigned v = tab[1] ^ (tab[0] << 8);
      12    buf[0] = ~(v >> 8);
      13    buf[1] = ~v;
      14  }
      15  
      16  __attribute__((noipa)) void
      17  bar (unsigned char *buf, unsigned char *tab)
      18  {
      19    tab = __builtin_assume_aligned (tab, 2);
      20    buf = __builtin_assume_aligned (buf, 2);
      21    unsigned v = tab[1] ^ (tab[0] << 8);
      22    buf[0] = (v >> 8);
      23    buf[1] = ~v;
      24  }
      25  
      26  __attribute__((noipa)) void
      27  baz (unsigned char *buf, unsigned char *tab)
      28  {
      29    tab = __builtin_assume_aligned (tab, 2);
      30    buf = __builtin_assume_aligned (buf, 2);
      31    unsigned v = tab[1] ^ (tab[0] << 8);
      32    buf[0] = ~(v >> 8);
      33    buf[1] = v;
      34  }
      35  
      36  int
      37  main ()
      38  {
      39    volatile unsigned char l1 = 0;
      40    volatile unsigned char l2 = 1;
      41    unsigned char buf[2] __attribute__((aligned (2)));
      42    unsigned char tab[2] __attribute__((aligned (2))) = { l1 + 1, l2 * 2 };
      43    foo (buf, tab);
      44    if (buf[0] != (unsigned char) ~1 || buf[1] != (unsigned char) ~2)
      45      __builtin_abort ();
      46    buf[0] = l1 + 7;
      47    buf[1] = l2 * 8;
      48    bar (buf, tab);
      49    if (buf[0] != 1 || buf[1] != (unsigned char) ~2)
      50      __builtin_abort ();
      51    buf[0] = l1 + 9;
      52    buf[1] = l2 * 10;
      53    baz (buf, tab);
      54    if (buf[0] != (unsigned char) ~1 || buf[1] != 2)
      55      __builtin_abort ();
      56    return 0;
      57  }