Add fgcse-sm test with scan-rtl-dump
authorTom de Vries <tom@codesourcery.com>
Fri, 21 Nov 2014 12:26:11 +0000 (12:26 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Fri, 21 Nov 2014 12:26:11 +0000 (12:26 +0000)
2014-11-21  Tom de Vries  <tom@codesourcery.com>

* gcc.dg/store-motion-fgcse-sm.c: New test.

From-SVN: r217916

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/store-motion-fgcse-sm.c [new file with mode: 0644]

index 26b2c25073a9e461c6912a9f5fe6760d297a5ddc..1c6cb24869f4c6cc278aa3d21bfc889d37503515 100644 (file)
@@ -1,3 +1,7 @@
+2014-11-21  Tom de Vries  <tom@codesourcery.com>
+
+       * gcc.dg/store-motion-fgcse-sm.c: New test.
+
 2014-11-21  Evgeny Stupachenko  <evstupac@gmail.com>
 
        PR target/60451
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 (file)
index 0000000..b331a24
--- /dev/null
@@ -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" } } */