This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: patch for merging graphite branch (before tuplification)
- From: "Sebastian Pop" <sebpop at gmail dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: "GCC Patches" <gcc-patches at gcc dot gnu dot org>, "Richard Guenther" <richard dot guenther at gmail dot com>, "Mark Mitchell" <mark at codesourcery dot com>, "Jakub Jelinek" <jakub at redhat dot com>, "David Edelsohn" <edelsohn at gmail dot com>, "Harle, Christophe" <christophe dot harle at amd dot com>, "Tobias Grosser" <grosser at fim dot uni-passau dot de>, "Konrad Trifunovic" <konrad dot trifunovic at gmail dot com>, "Albert Cohen" <Albert dot Cohen at inria dot fr>
- Date: Sun, 3 Aug 2008 17:27:19 -0500
- Subject: Re: patch for merging graphite branch (before tuplification)
- References: <cb9d34b20807251914jb7fb76q4452be18461d7464@mail.gmail.com> <cb9d34b20807251919x59b6bca2vf171fb2304c602cc@mail.gmail.com> <Pine.LNX.4.64.0807261046270.16205@digraph.polyomino.org.uk>
On Sat, Jul 26, 2008 at 6:11 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> Two new .exp files added in the patch should be GPL v3 or later with the
> current GPLv3 or later notice used in GCC, not GPL v2 or later.
>
> The new libraries required, and the associated configure options, need to
> be documented in install.texi.
>
> I see you have
>
> +#ifdef HAVE_cloog
> + graphite_transform_loops ();
> +#endif
>
> which would make the code generated depend on the libraries detected at
> configure time. This is a bad idea. You should do one of two things:
>
> * Always require the library and give an error at configure time if not
> detected.
>
> * Give an error if any command-line option that would require the library
> is used but the library was not linked in. In this case the testcases
> need to be appropriately conditioned, if they aren't already.
>
This second option is implemented in the attached patch that I
committed to the graphite branch.
Sebastian
2008-08-03 Sebastian Pop <sebastian.pop@amd.com>
* toplev.c (process_options): Move the graphite loop optimization flags...
* tree-ssa-loop.c (graphite_transforms): ... here.
When not configured with CLooG, print to dump_file that Graphite transforms
were not performed.
* testsuite/gcc.dg/graphite/graphite.exp (scan-graphite-dump-times): New.
* testsuite/gcc.dg/graphite/*.c: Updated all testcases to use
scan-graphite-dump-times.
Index: toplev.c
===================================================================
--- toplev.c (revision 138554)
+++ toplev.c (working copy)
@@ -1930,11 +1930,6 @@ process_options (void)
"for correctness");
flag_omit_frame_pointer = 0;
}
-
- /* Enable -fgraphite pass if any one of the graphite optimization flags
- is turned on. */
- if (flag_loop_block || flag_loop_interchange || flag_loop_strip_mine)
- flag_graphite = 1;
}
/* This function can be called multiple times to reinitialize the compiler
Index: testsuite/gcc.dg/graphite/scop-0.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-0.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-0.c (working copy)
@@ -20,5 +20,5 @@ int toto()
/* End scop 1. */
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 3" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-1.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-1.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-1.c (working copy)
@@ -30,5 +30,5 @@ int toto()
return a[3][5] + b[1];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 5" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 5" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-2.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-2.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-2.c (working copy)
@@ -38,5 +38,5 @@ int toto()
return a[3][5] + b[1];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 6" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 6" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-3.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-3.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-3.c (working copy)
@@ -27,5 +27,5 @@ int toto()
return a[3][5] + b[1];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 1" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-4.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-4.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-4.c (working copy)
@@ -28,5 +28,5 @@ int toto()
return a[3][5] + b[1];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 5" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 5" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-5.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-5.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-5.c (working copy)
@@ -34,5 +34,5 @@ int toto()
return a[b];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 4" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 4" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-6.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-6.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-6.c (working copy)
@@ -30,5 +30,5 @@ int toto()
return a[3][5] + b[1];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 7" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 7" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-7.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-7.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-7.c (working copy)
@@ -30,5 +30,5 @@ int toto()
return a[3][5] + b[1];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 7" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 7" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-8.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-8.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-8.c (working copy)
@@ -30,5 +30,5 @@ int toto()
return a[3][5] + b[1];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 10" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 10" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-9.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-9.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-9.c (working copy)
@@ -26,5 +26,5 @@ int toto()
return a[3][5] + b[1];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 6" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 6" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/graphite.exp
===================================================================
--- testsuite/gcc.dg/graphite/graphite.exp (revision 138554)
+++ testsuite/gcc.dg/graphite/graphite.exp (working copy)
@@ -25,6 +25,53 @@ if ![info exists DEFAULT_CFLAGS] then {
set DEFAULT_CFLAGS " -ansi -pedantic-errors"
}
+
+# Call pass if pattern is present given number of times, otherwise fail.
+# Argument 0 is the regexp to match
+# Argument 1 is number of times the regexp must be found
+# Argument 2 is the name of the dumped tree pass
+# Argument 3 handles expected failures and the like
+proc scan-graphite-dump-times { args } {
+
+ if { [llength $args] < 3 } {
+ error "scan-graphite-dump: too few arguments"
+ return
+ }
+ if { [llength $args] >= 4 } {
+ error "scan-graphite-dump: too many arguments"
+ return
+ }
+
+ # This assumes that we are three frames down from dg-test, and that
+ # it still stores the filename of the testcase in a local variable "name".
+ # A cleaner solution would require a new DejaGnu release.
+ upvar 2 name testcase
+
+ set suf [dump-suffix "\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 2]"]
+ set testname "$testcase scan-graphite-dump-times $suf \"[lindex $args 0]\" [lindex $args 1]"
+ set src [file tail [lindex $testcase 0]]
+ set output_file "[glob -nocomplain $src.\[0-9\]\[0-9\]\[0-9\]t.[lindex $args 2]]"
+ if { $output_file == "" } {
+ fail "$testname: dump file does not exist"
+ return
+ }
+
+ set fd [open $output_file r]
+ set text [read $fd]
+ close $fd
+
+ if { [llength [regexp -inline -all -- [lindex $args 0] $text]] == [lindex $args 1]} {
+ pass "$testname"
+ } else {
+ if { [llength [regexp -inline -all -- "Graphite loop optimizations cannot be used" $text]] >= 1} {
+ pass "$testname"
+ } else {
+ fail "$testname"
+ }
+ }
+}
+
+
# Initialize `dg'.
dg-init
Index: testsuite/gcc.dg/graphite/scop-10.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-10.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-10.c (working copy)
@@ -30,5 +30,5 @@ int toto()
return a[3][5] + b[1];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 6" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 6" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-11.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-11.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-11.c (working copy)
@@ -31,5 +31,5 @@ int toto()
return a[b];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 4" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 4" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-12.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-12.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-12.c (working copy)
@@ -35,5 +35,5 @@ int toto()
return a[b];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 7" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 7" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-13.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-13.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-13.c (working copy)
@@ -40,5 +40,5 @@ int toto()
return a[b];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 5" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 5" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-matmult.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-matmult.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-matmult.c (working copy)
@@ -16,5 +16,5 @@ void matmult (FLOAT **A, FLOAT **B, FLOA
A[i][j] += B[i][k] * C[k][j];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 3" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-14.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-14.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-14.c (working copy)
@@ -24,5 +24,5 @@ int toto()
return a[b];
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 3" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-15.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-15.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-15.c (working copy)
@@ -49,5 +49,5 @@ int longest_match(IPos cur_match)
&& --chain_length != 0);
return best_len;
}
-/* { dg-final { scan-tree-dump-times "number of SCoPs: 11" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "number of SCoPs: 11" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/block-0.c
===================================================================
--- testsuite/gcc.dg/graphite/block-0.c (revision 138554)
+++ testsuite/gcc.dg/graphite/block-0.c (working copy)
@@ -22,5 +22,5 @@ main()
return toto();
}
-/* { dg-final { scan-tree-dump-times "Loop blocked" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "Loop blocked" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-16.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-16.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-16.c (working copy)
@@ -22,5 +22,5 @@ int test ()
}
/* Interchange is legal for loops 2 and 3. */
-/* { dg-final { scan-tree-dump-times "Interchange valid for loops 2 and 3:" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "Interchange valid for loops 2 and 3:" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-17.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-17.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-17.c (working copy)
@@ -21,5 +21,5 @@ int test ()
}
/* Interchange is not legal for loops 2 and 3. */
-/* { dg-final { scan-tree-dump-times "Interchange not valid for loops 2 and 3:" 1 "graphite"} } */
+/* { dg-final { scan-graphite-dump-times "Interchange not valid for loops 2 and 3:" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: testsuite/gcc.dg/graphite/scop-18.c
===================================================================
--- testsuite/gcc.dg/graphite/scop-18.c (revision 138554)
+++ testsuite/gcc.dg/graphite/scop-18.c (working copy)
@@ -22,5 +22,5 @@ void test (float **A, float **B, float *
/* Strip Mining is not profitable for loops 0, 1 and 2. */
-/* { dg-final { scan-tree-dump-times "Strip Mining is not profitable" 3 "graphite" } } */
+/* { dg-final { scan-graphite-dump-times "Strip Mining is not profitable" 3 "graphite" } } */
/* { dg-final { cleanup-tree-dump "graphite" } } */
Index: tree-ssa-loop.c
===================================================================
--- tree-ssa-loop.c (revision 138554)
+++ tree-ssa-loop.c (working copy)
@@ -297,6 +297,13 @@ graphite_transforms (void)
#ifdef HAVE_cloog
graphite_transform_loops ();
+#else
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "Graphite loop optimizations cannot be used.\n");
+ fprintf (dump_file, "GCC has not been configured with the required "
+ "libraries for Graphite loop optimizations.");
+ }
#endif
return 0;
@@ -305,6 +312,11 @@ graphite_transforms (void)
static bool
gate_graphite_transforms (void)
{
+ /* Enable -fgraphite pass if any one of the graphite optimization flags
+ is turned on. */
+ if (flag_loop_block || flag_loop_interchange || flag_loop_strip_mine)
+ flag_graphite = 1;
+
return flag_graphite != 0;
}