LWG 3035. std::allocator's constructors should be constexpr
[official-gcc.git] / gcc / testsuite / gcc.dg / store-motion-fgcse-sm.c
blob0e988b8081fcbd6af886ea4144d621d24511b934
1 /* { dg-do run } */
2 /* { dg-options "-O2 -ftree-pre -fno-tree-loop-im -fgcse-sm -fdump-rtl-store_motion" } */
4 /* tree-pre moves the *sum load out of the loop. ftree-loop-im moves the *sum
5 store out of the loop, so we disable it, to allow fgcse-sm to do it
6 instead. */
8 #include <stdlib.h>
10 void __attribute__((noinline))
11 f (unsigned int *__restrict__ a, unsigned int *__restrict__ sum, unsigned int n)
13 unsigned int i;
14 for (i = 0; i < n; ++i)
15 *sum += a[i];
18 int
19 main ()
21 unsigned int a[] = { 1, 10, 100 };
22 unsigned sum = 1000;
24 f (a, &sum, 3);
25 if (sum != 1111)
26 abort ();
28 return 0;
31 /* Check that -fgcse-sm did something for f. */
32 /* { dg-final { scan-rtl-dump "STORE_MOTION of f, .* basic blocks, 1 insns deleted, 1 insns created" "store_motion" } } */