diff gcc/testsuite/gcc.dg/store-motion-fgcse-sm.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/gcc.dg/store-motion-fgcse-sm.c	Fri Oct 27 22:46:09 2017 +0900
@@ -0,0 +1,33 @@
+/* { 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" } } */
+