Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.dg / store_merging_18.c
blob66e157e3272fd9ca44d579f6a1d0a20e76ffe518
1 /* PR tree-optimization/83843 */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -fdump-tree-store-merging" } */
4 /* { dg-final { scan-tree-dump-times "Merging successful" 3 "store-merging" { target { store_merge && { ! arm*-*-* } } } } } */
6 __attribute__((noipa)) void
7 foo (unsigned char *buf, unsigned char *tab)
9 unsigned v = tab[1] ^ (tab[0] << 8);
10 buf[0] = ~(v >> 8);
11 buf[1] = ~v;
14 __attribute__((noipa)) void
15 bar (unsigned char *buf, unsigned char *tab)
17 unsigned v = tab[1] ^ (tab[0] << 8);
18 buf[0] = (v >> 8);
19 buf[1] = ~v;
22 __attribute__((noipa)) void
23 baz (unsigned char *buf, unsigned char *tab)
25 unsigned v = tab[1] ^ (tab[0] << 8);
26 buf[0] = ~(v >> 8);
27 buf[1] = v;
30 int
31 main ()
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;