This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Minor loop-iv tweaks for doloops


This allows us to generate slightly more hardware loops on the Blackfin.
 When walking through arrays on the stack, we often generate comparisons
based on the stack or frame pointer; we should treat these as invariant
everywhere.  Some earlier patches already went in that direction, this
one just converts a few more places.

Bootstrapped and regression tested on i686-linux.  Ok?

I'm also attaching a patch with three Blackfin-specific testcases which
verify that we're generating hardware loops as expected.


Bernd
-- 
This footer brought to you by insane German lawmakers.
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368
Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif
	* loop-iv.c (iv_analyze_op): Use function_invariant_p, not CONSTANT_P,
	to test for GRD_INVARIANT.
	(simple_rhs_p): Anything that's function_invariant_p is fine.

Index: loop-iv.c
===================================================================
--- loop-iv.c	(revision 152180)
+++ loop-iv.c	(working copy)
@@ -1120,7 +1120,7 @@ iv_analyze_op (rtx insn, rtx op, struct 
       print_rtl_single (dump_file, insn);
     }
 
-  if (CONSTANT_P (op))
+  if (function_invariant_p (op))
     res = GRD_INVARIANT;
   else if (GET_CODE (op) == SUBREG)
     {
@@ -1329,7 +1329,7 @@ simple_rhs_p (rtx rhs)
 {
   rtx op0, op1;
 
-  if (CONSTANT_P (rhs)
+  if (function_invariant_p (rhs)
       || (REG_P (rhs) && !HARD_REGISTER_P (rhs)))
     return true;
 
Index: testsuite/gcc.target/bfin/lsetup-1.c
===================================================================
--- testsuite/gcc.target/bfin/lsetup-1.c	(revision 0)
+++ testsuite/gcc.target/bfin/lsetup-1.c	(revision 0)
@@ -0,0 +1,45 @@
+/* { dg-do compile { target bfin-*-* } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-times "LSETUP" 6 } } */
+
+#define SIZE 1024
+
+int foo (int (*x)[SIZE])
+{
+    int i, sum = 0;
+
+    for  (i = 0; i < SIZE; i++) {
+	int j;
+	for (j = 0; j < SIZE; j++)
+		sum += x[i][j];	
+    }
+
+    return sum;
+}
+
+int bar (int **x)
+{
+    int i, sum = 0;
+
+    for  (i = 0; i < SIZE; i++) {
+	int j;
+	for (j = 0; j < SIZE; j++)
+		sum += x[i][j];	
+    }
+
+    return sum;
+}
+
+int baz ()
+{
+    int i, sum = 0;
+    int x[SIZE][SIZE];
+    fill(x);
+    for  (i = 0; i < SIZE; i++) {
+	int j;
+	for (j = 0; j < SIZE; j++)
+		sum += x[i][j];	
+    }
+
+    return sum;
+}
Index: testsuite/gcc.target/bfin/lsetup-2.c
===================================================================
--- testsuite/gcc.target/bfin/lsetup-2.c	(revision 0)
+++ testsuite/gcc.target/bfin/lsetup-2.c	(revision 0)
@@ -0,0 +1,33 @@
+/* { dg-do compile { target bfin-*-* } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-times "LSETUP" 2 } } */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#define SIZE 1024
+
+void foo ()
+{
+    int index, sum = 0, *x;
+
+    x = malloc (SIZE);
+
+    for  (index = 0; index < SIZE ; index++) {
+	sum += x[index];
+    }
+
+    printf("%i",sum);
+}
+
+void bar ()
+{
+    int index, sum = 0, x[SIZE];
+
+    for  (index = 0; index < SIZE ; index++) {
+	sum += x[index];
+    }
+
+    printf("%i",sum);
+}
+
Index: testsuite/gcc.target/bfin/lsetup-3.c
===================================================================
--- testsuite/gcc.target/bfin/lsetup-3.c	(revision 0)
+++ testsuite/gcc.target/bfin/lsetup-3.c	(revision 0)
@@ -0,0 +1,13 @@
+/* { dg-do compile { target bfin-*-* } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler "LSETUP" } } */
+
+void test(unsigned int start, unsigned int end)
+{
+  unsigned int count;
+  start = start & -32;
+  end = end & -32;
+  for (count = (end - start); count; count -= 32)
+    __asm__ __volatile__("FLUSH[%0++];" :
+			 "+p"(start));
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]