Hi, this patch adds a fgcse-sm test with a scan-rtl-dump directive.
The other fgcse-sm tests: ... ./gcc/testsuite/gcc.dg/pr45352-3.c ./gcc/testsuite/gcc.dg/torture/pr24257.c ./gcc/testsuite/gcc.target/i386/movsi-sm-1.c ./gcc/testsuite/g++.dg/opt/pr36185.C ... do not check whether fgcse-sm actually does something. Committed as trivial. Thanks, - Tom
2014-11-21 Tom de Vries <t...@codesourcery.com> * gcc.dg/store-motion-fgcse-sm.c: New test. --- gcc/testsuite/gcc.dg/store-motion-fgcse-sm.c | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/store-motion-fgcse-sm.c diff --git a/gcc/testsuite/gcc.dg/store-motion-fgcse-sm.c b/gcc/testsuite/gcc.dg/store-motion-fgcse-sm.c new file mode 100644 index 0000000..b331a24 --- /dev/null +++ b/gcc/testsuite/gcc.dg/store-motion-fgcse-sm.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-pre -fno-tree-loop-im -fgcse-sm -fdump-rtl-store_motion" } */ + +/* tree-pre moves the *sum load out of the loop. ftree-loop-im moves the *sum + store out of the loop, so we disable it, to allow fgcse-sm to do it + instead. */ + +#include <stdlib.h> + +void __attribute__((noinline)) +f (unsigned int *__restrict__ a, unsigned int *__restrict__ sum, unsigned int n) +{ + unsigned int i; + for (i = 0; i < n; ++i) + *sum += a[i]; +} + +int +main () +{ + unsigned int a[] = { 1, 10, 100 }; + unsigned sum = 1000; + + f (a, &sum, 3); + if (sum != 1111) + abort (); + + return 0; +} + +/* Check that -fgcse-sm did something for f. */ +/* { dg-final { scan-rtl-dump "STORE_MOTION of f, .* basic blocks, 1 insns deleted, 1 insns created" "store_motion" } } */ -- 1.9.1