diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index f8e12836c04c354046e87744e2c97b04572b3efc..e26c71769f110df096d114c30acb40e26c88fa91 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,8 @@
+2009-10-22  Sebastian Pop  <sebastian.pop@amd.com>
+
+	* g++.dg/graphite/graphite.exp: Add the same rules as in
+	gcc.dg/graphite/graphite.exp.
+
 2009-10-22  Sebastian Pop  <sebastian.pop@amd.com>
 
 	* g++.dg/graphite/id-1.C: New.
diff --git a/gcc/testsuite/g++.dg/graphite/graphite.exp b/gcc/testsuite/g++.dg/graphite/graphite.exp
index d1993a2e805f3fa00066167b1db5fa81b7d6a4f4..ba7c8ccec89ebe9ae88ffa5926237567fe19f6bf 100644
--- a/gcc/testsuite/g++.dg/graphite/graphite.exp
+++ b/gcc/testsuite/g++.dg/graphite/graphite.exp
@@ -23,23 +23,68 @@ if ![check_effective_target_fgraphite] {
   return
 }
 
+# Remove VALUE from LIST_VARIABLE.
+proc lremove {list_variable value} {
+    upvar 1 $list_variable var
+    set idx [lsearch -exact $var $value]
+    set var [lreplace $var $idx $idx]
+}
+
 # The default action for a test is 'compile'.  Save current default.
 global dg-do-what-default
 set save-dg-do-what-default ${dg-do-what-default}
 set dg-do-what-default compile
 
-# If a testcase doesn't have special options, use these.
-global DEFAULT_CFLAGS
-if ![info exists DEFAULT_CFLAGS] then {
-    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
-}
-
 # Initialize `dg'.
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] \
-	"" $DEFAULT_CFLAGS
+
+set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.C ] ]
+
+# Flags using for block-* files.
+set DEFAULT_FLAGS_GRAPHITE_BLOCK "-O2 -floop-block -fno-loop-strip-mine \
+ -fno-loop-interchange -fdump-tree-graphite-all"
+set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.C ] ]
+dg-runtest $block_files "" $DEFAULT_FLAGS_GRAPHITE_BLOCK
+foreach block_file $block_files {lremove wait_to_run_files $block_file}
+
+# Flags using for id-* files.
+set DEFAULT_FLAGS_GRAPHITE_IDENTITY "-O2 -fgraphite-identity"
+set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.C ] ]
+dg-runtest $id_files "" $DEFAULT_FLAGS_GRAPHITE_IDENTITY
+foreach id_file $id_files {lremove wait_to_run_files $id_file}
+
+# Flags using for interchange-* files.
+set DEFAULT_FLAGS_GRAPHITE_INTERCHANGE "-O2 -fdump-tree-graphite-all \
+ -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math"
+set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.C ] ]
+dg-runtest $interchange_files "" $DEFAULT_FLAGS_GRAPHITE_INTERCHANGE
+foreach interchange_file $interchange_files {lremove wait_to_run_files $interchange_file}
+
+# Flags using for scop-* files.
+set DEFAULT_FLAGS_GRAPHITE_SCOP "-O2 -fgraphite -fdump-tree-graphite-all"
+set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.C ] ]
+dg-runtest $scop_files "" $DEFAULT_FLAGS_GRAPHITE_SCOP
+foreach scop_file $scop_files {lremove wait_to_run_files $scop_file}
+
+
+# Schedule now the tests to be run.
+set dg-do-what-default run
+
+# Flags using for run-id-* files.
+set DEFAULT_FLAGS_RUN_ID "-O2 -fgraphite-identity"
+set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.C ] ]
+dg-runtest $run_id_files "" $DEFAULT_FLAGS_RUN_ID
+foreach run_id_file $run_id_files {lremove wait_to_run_files $run_id_file}
+
+
+# The default action for the rest of the files is 'compile'.
+set dg-do-what-default compile
+
+# Flags using for other files.
+set DEFAULT_FLAGS_GRAPHITE "-ansi -pedantic-errors"
+dg-runtest $wait_to_run_files "" $DEFAULT_FLAGS_GRAPHITE
 
 # Clean up.
 set dg-do-what-default ${save-dg-do-what-default}