re PR target/55160 (Counterproductive loop induction variable optimization)
authorOleg Endo <olegendo@gcc.gnu.org>
Thu, 1 Nov 2012 21:28:49 +0000 (21:28 +0000)
committerOleg Endo <olegendo@gcc.gnu.org>
Thu, 1 Nov 2012 21:28:49 +0000 (21:28 +0000)
PR target/55160
* gcc.target/sh/pr55160.c: New.

From-SVN: r193071

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/sh/pr55160.c [new file with mode: 0644]

index 9b8914f56c6249cc949a942eeeb12694707dc9c3..9c59446a38243752b811085e97092dc29c8c4613 100644 (file)
@@ -1,3 +1,8 @@
+2012-11-01  Oleg Endo  <olegendo@gcc.gnu.org>
+
+       PR target/55160
+       * gcc.target/sh/pr55160.c: New.
+
 2012-11-01  David Edelsohn  <dje.gcc@gmail.com>
 
        * gcc.target/powerpc/vsx-mass-1.c: Check for dot symbols in
diff --git a/gcc/testsuite/gcc.target/sh/pr55160.c b/gcc/testsuite/gcc.target/sh/pr55160.c
new file mode 100644 (file)
index 0000000..ae0d83a
--- /dev/null
@@ -0,0 +1,25 @@
+/* Check that the decrement-and-test instruction is generated.  */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O1" } */
+/* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } }  */
+/* { dg-final { scan-assembler-times "dt\tr" 2 } } */
+
+int
+test_00 (int* x, int c)
+{
+  int s = 0;
+  int i;
+  for (i = 0; i < c; ++i)
+    s += x[i];
+  return s;
+}
+
+int
+test_01 (int* x, int c)
+{
+  int s = 0;
+  int i;
+  for (i = 0; i < c; ++i)
+    s += *--x;
+  return s;
+}