Patchwork Move Graphite from using PPL over to ISL

login
register
mail settings
Submitter Richard Guenther
Date June 27, 2012, 3:06 p.m.
Message ID <alpine.LNX.2.00.1206271659380.15781@jbgna.fhfr.qr>
Download mbox | patch
Permalink /patch/167663/
State New
Headers show

Comments

Richard Guenther - June 27, 2012, 3:06 p.m.
This merges from the graphite branch the move of PPL to ISL,
and completes it where it was lacking - thanks to Micha.
It leaves unmerged the addition of a pluto-like ISL optimizer
as well as a bugfix for stride > 1 which did not come with
a testcase.

With this patch (ontop of the one requiring ClooG 0.17.0)
we will require ISL 0.10 for enabling Graphite.

I've bootstrapped and built various combinations with in-tree
and out-of-tree cloog and ISL, so I'm pretty confident that
this works.

With out-of-tree ClooG and ISL a slightly older patch ontop of its 
prerequesite passed bootstrap and testing on x86_64-unknown-linux-gnu.

Currently re-bootstrapping and testing on x86_64-unknown-linux-gnu.

Ok for trunk?

Thanks,
Richard.

2012-06-27  Richard Guenther  <rguenther@suse.de>
	Michael Matz  <matz@suse.de>
	Tobias Grosser <tobias@grosser.es>
	Sebastian Pop <sebpop@gmail.com>

	config/
	* cloog.m4: Set up to work against ISL only.
	* isl.m4: New file.

	* Makefile.def: Add ISL host module, remove PPL host module.
	Adjust ClooG host module to use the proper ISL.
	* Makefile.tpl: Pass ISL include flags instead of PPL ones.
	* configure.ac: Include config/isl.m4.  Add ISL host library,
	remove PPL.  Remove PPL configury, add ISL configury, adjust
	ClooG configury.
	* Makefile.in: Regenerated.
	* configure: Likewise.

	gcc/
	* Makefile.in: Remove PPL flags in favor of ISL ones.
	(BACKENDLIBS): Remove PPL libs.
	(INCLUDES): Remove PPL includes in favor of ISL ones.
	(graphite-clast-to-gimple.o): Remove graphite-dependences.h and
	graphite-cloog-compat.h dependencies.
	(graphite-dependences.o): Likewise.
	(graphite-poly.o): Likewise.
	* configure.ac: Declare ISL vars instead of PPL ones.
	* configure: Regenerated.
	* doc/install.texi: Replace PPL requirement documentation
	with ISL one.
	* graphite-blocking.c: Remove PPL code, add ISL equivalent.
	* graphite-clast-to-gimple.c: Likewise.
	* graphite-dependences.c: Likewise.
	* graphite-interchange.c: Likewise.
	* graphite-poly.h: Likewise.
	* graphite-poly.c: Likewise.
	* graphite-sese-to-poly.c: Likewise.
	* graphite.c: Likewise.
	* graphite-scop-detection.c: Re-arrange includes.
	* graphite-cloog-util.c: Remove.
	* graphite-cloog-util.h: Likewise.
	* graphite-ppl.h: Likewise.
	* graphite-ppl.c: Likewise.
	* graphite-dependences.h: Likewise.

	libgomp/
	* testsuite/libgomp.graphite/force-parallel-4.c: Adjust.
	* testsuite/libgomp.graphite/force-parallel-5.c: Likewise.
	* testsuite/libgomp.graphite/force-parallel-7.c: Likewise.
	* testsuite/libgomp.graphite/force-parallel-8.c: Likewise.
Sebastian Pop - June 27, 2012, 6:39 p.m.
On Wed, Jun 27, 2012 at 10:06 AM, Richard Guenther <rguenther@suse.de> wrote:
> With this patch (ontop of the one requiring ClooG 0.17.0)
> we will require ISL 0.10 for enabling Graphite.

Thanks Richi, Micha, and Tobi for picking up this code and making this
transition happen.  I owe each of you a beer ;-)

Sebastian
Tobias Grosser - June 28, 2012, 8:58 a.m.
On 06/27/2012 05:06 PM, Richard Guenther wrote:
>
> This merges from the graphite branch the move of PPL to ISL,
> and completes it where it was lacking - thanks to Micha.
> It leaves unmerged the addition of a pluto-like ISL optimizer
> as well as a bugfix for stride>  1 which did not come with
> a testcase.
>
> With this patch (ontop of the one requiring ClooG 0.17.0)
> we will require ISL 0.10 for enabling Graphite.
>
> I've bootstrapped and built various combinations with in-tree
> and out-of-tree cloog and ISL, so I'm pretty confident that
> this works.
>
> With out-of-tree ClooG and ISL a slightly older patch ontop of its
> prerequesite passed bootstrap and testing on x86_64-unknown-linux-gnu.
>
> Currently re-bootstrapping and testing on x86_64-unknown-linux-gnu.
>
> Ok for trunk?

Hi Richard, hi Micha,

thanks a lot for pushing this forward. Especially the fast 
implementation of the interchange heuristic was impressive!
I am fine with the general goal and think the patch is close to get in, 
but I would like to give feedback on the interchange heuristic. I will 
try to review it today or tomorrow.

Thanks again!!

Tobias
Diego Novillo - June 28, 2012, 12:45 p.m.
On 12-06-27 11:06 , Richard Guenther wrote:

> 2012-06-27  Richard Guenther  <rguenther@suse.de>
> 	Michael Matz  <matz@suse.de>
> 	Tobias Grosser <tobias@grosser.es>
> 	Sebastian Pop <sebpop@gmail.com>
>
> 	config/
> 	* cloog.m4: Set up to work against ISL only.
> 	* isl.m4: New file.
>
> 	* Makefile.def: Add ISL host module, remove PPL host module.
> 	Adjust ClooG host module to use the proper ISL.
> 	* Makefile.tpl: Pass ISL include flags instead of PPL ones.
> 	* configure.ac: Include config/isl.m4.  Add ISL host library,
> 	remove PPL.  Remove PPL configury, add ISL configury, adjust
> 	ClooG configury.
> 	* Makefile.in: Regenerated.
> 	* configure: Likewise.
>
> 	gcc/
> 	* Makefile.in: Remove PPL flags in favor of ISL ones.
> 	(BACKENDLIBS): Remove PPL libs.
> 	(INCLUDES): Remove PPL includes in favor of ISL ones.
> 	(graphite-clast-to-gimple.o): Remove graphite-dependences.h and
> 	graphite-cloog-compat.h dependencies.
> 	(graphite-dependences.o): Likewise.
> 	(graphite-poly.o): Likewise.
> 	* configure.ac: Declare ISL vars instead of PPL ones.
> 	* configure: Regenerated.
> 	* doc/install.texi: Replace PPL requirement documentation
> 	with ISL one.
> 	* graphite-blocking.c: Remove PPL code, add ISL equivalent.
> 	* graphite-clast-to-gimple.c: Likewise.
> 	* graphite-dependences.c: Likewise.
> 	* graphite-interchange.c: Likewise.
> 	* graphite-poly.h: Likewise.
> 	* graphite-poly.c: Likewise.
> 	* graphite-sese-to-poly.c: Likewise.
> 	* graphite.c: Likewise.
> 	* graphite-scop-detection.c: Re-arrange includes.
> 	* graphite-cloog-util.c: Remove.
> 	* graphite-cloog-util.h: Likewise.
> 	* graphite-ppl.h: Likewise.
> 	* graphite-ppl.c: Likewise.
> 	* graphite-dependences.h: Likewise.
>
> 	libgomp/
> 	* testsuite/libgomp.graphite/force-parallel-4.c: Adjust.
> 	* testsuite/libgomp.graphite/force-parallel-5.c: Likewise.
> 	* testsuite/libgomp.graphite/force-parallel-7.c: Likewise.
> 	* testsuite/libgomp.graphite/force-parallel-8.c: Likewise.

OK.


Diego.
Richard Guenther - July 2, 2012, 11:43 a.m.
On Thu, 28 Jun 2012, Diego Novillo wrote:

> On 12-06-27 11:06 , Richard Guenther wrote:
> 
> > 2012-06-27  Richard Guenther  <rguenther@suse.de>
> > 	Michael Matz  <matz@suse.de>
> > 	Tobias Grosser <tobias@grosser.es>
> > 	Sebastian Pop <sebpop@gmail.com>
> > 
> > 	config/
> > 	* cloog.m4: Set up to work against ISL only.
> > 	* isl.m4: New file.
> > 
> > 	* Makefile.def: Add ISL host module, remove PPL host module.
> > 	Adjust ClooG host module to use the proper ISL.
> > 	* Makefile.tpl: Pass ISL include flags instead of PPL ones.
> > 	* configure.ac: Include config/isl.m4.  Add ISL host library,
> > 	remove PPL.  Remove PPL configury, add ISL configury, adjust
> > 	ClooG configury.
> > 	* Makefile.in: Regenerated.
> > 	* configure: Likewise.
> > 
> > 	gcc/
> > 	* Makefile.in: Remove PPL flags in favor of ISL ones.
> > 	(BACKENDLIBS): Remove PPL libs.
> > 	(INCLUDES): Remove PPL includes in favor of ISL ones.
> > 	(graphite-clast-to-gimple.o): Remove graphite-dependences.h and
> > 	graphite-cloog-compat.h dependencies.
> > 	(graphite-dependences.o): Likewise.
> > 	(graphite-poly.o): Likewise.
> > 	* configure.ac: Declare ISL vars instead of PPL ones.
> > 	* configure: Regenerated.
> > 	* doc/install.texi: Replace PPL requirement documentation
> > 	with ISL one.
> > 	* graphite-blocking.c: Remove PPL code, add ISL equivalent.
> > 	* graphite-clast-to-gimple.c: Likewise.
> > 	* graphite-dependences.c: Likewise.
> > 	* graphite-interchange.c: Likewise.
> > 	* graphite-poly.h: Likewise.
> > 	* graphite-poly.c: Likewise.
> > 	* graphite-sese-to-poly.c: Likewise.
> > 	* graphite.c: Likewise.
> > 	* graphite-scop-detection.c: Re-arrange includes.
> > 	* graphite-cloog-util.c: Remove.
> > 	* graphite-cloog-util.h: Likewise.
> > 	* graphite-ppl.h: Likewise.
> > 	* graphite-ppl.c: Likewise.
> > 	* graphite-dependences.h: Likewise.
> > 
> > 	libgomp/
> > 	* testsuite/libgomp.graphite/force-parallel-4.c: Adjust.
> > 	* testsuite/libgomp.graphite/force-parallel-5.c: Likewise.
> > 	* testsuite/libgomp.graphite/force-parallel-7.c: Likewise.
> > 	* testsuite/libgomp.graphite/force-parallel-8.c: Likewise.
> 
> OK.

Committed.

Richard.
Jack Howarth - July 2, 2012, 1:37 p.m.
On Mon, Jul 02, 2012 at 01:43:56PM +0200, Richard Guenther wrote:
> On Thu, 28 Jun 2012, Diego Novillo wrote:
> 
> > On 12-06-27 11:06 , Richard Guenther wrote:
> > 
> > > 2012-06-27  Richard Guenther  <rguenther@suse.de>
> > > 	Michael Matz  <matz@suse.de>
> > > 	Tobias Grosser <tobias@grosser.es>
> > > 	Sebastian Pop <sebpop@gmail.com>
> > > 
> > > 	config/
> > > 	* cloog.m4: Set up to work against ISL only.
> > > 	* isl.m4: New file.
> > > 
> > > 	* Makefile.def: Add ISL host module, remove PPL host module.
> > > 	Adjust ClooG host module to use the proper ISL.
> > > 	* Makefile.tpl: Pass ISL include flags instead of PPL ones.
> > > 	* configure.ac: Include config/isl.m4.  Add ISL host library,
> > > 	remove PPL.  Remove PPL configury, add ISL configury, adjust
> > > 	ClooG configury.
> > > 	* Makefile.in: Regenerated.
> > > 	* configure: Likewise.
> > > 
> > > 	gcc/
> > > 	* Makefile.in: Remove PPL flags in favor of ISL ones.
> > > 	(BACKENDLIBS): Remove PPL libs.
> > > 	(INCLUDES): Remove PPL includes in favor of ISL ones.
> > > 	(graphite-clast-to-gimple.o): Remove graphite-dependences.h and
> > > 	graphite-cloog-compat.h dependencies.
> > > 	(graphite-dependences.o): Likewise.
> > > 	(graphite-poly.o): Likewise.
> > > 	* configure.ac: Declare ISL vars instead of PPL ones.
> > > 	* configure: Regenerated.
> > > 	* doc/install.texi: Replace PPL requirement documentation
> > > 	with ISL one.
> > > 	* graphite-blocking.c: Remove PPL code, add ISL equivalent.
> > > 	* graphite-clast-to-gimple.c: Likewise.
> > > 	* graphite-dependences.c: Likewise.
> > > 	* graphite-interchange.c: Likewise.
> > > 	* graphite-poly.h: Likewise.
> > > 	* graphite-poly.c: Likewise.
> > > 	* graphite-sese-to-poly.c: Likewise.
> > > 	* graphite.c: Likewise.
> > > 	* graphite-scop-detection.c: Re-arrange includes.
> > > 	* graphite-cloog-util.c: Remove.
> > > 	* graphite-cloog-util.h: Likewise.
> > > 	* graphite-ppl.h: Likewise.
> > > 	* graphite-ppl.c: Likewise.
> > > 	* graphite-dependences.h: Likewise.
> > > 
> > > 	libgomp/
> > > 	* testsuite/libgomp.graphite/force-parallel-4.c: Adjust.
> > > 	* testsuite/libgomp.graphite/force-parallel-5.c: Likewise.
> > > 	* testsuite/libgomp.graphite/force-parallel-7.c: Likewise.
> > > 	* testsuite/libgomp.graphite/force-parallel-8.c: Likewise.
> > 
> > OK.
> 
> Committed.
> 
> Richard.

Richard,
   At r189157, with isl 0.10 and cloog.org 0.17.0 installed from the infrastructure
directory, I am seeing a configure failure with...

  $ ../gcc-4.8-20120702/configure --prefix=/sw --prefix=/sw/lib/gcc4.8 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.8/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.8

of...

configure:5697: checking for version 0.10 of ISL
configure:5725: gcc -o conftest -g -O2 -I/sw/include -I/sw/include -I/sw/include    -L/sw/lib -lisl -lisl conftest.c  >&5
conftest.c:15:11: error: expected ';' at end of declaration
int main()
          ^
          ;
1 error generated.
configure:5725: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define LT_OBJDIR ".libs/"
| /* end confdefs.h.  */
| #include <isl/version.h>
|    #include <string.h>
| int
| main ()
| {
| int main()
|    {
|      if (strncmp (isl_version (), "isl-0.10", strlen ("isl-0.10")) != 0)
|        return 1;
|      return 0;
|    }
|   ;
|   return 0;
| }
configure:5735: result: no
configure:5769: error: Unable to find a usable ISL.  See config.log for details.
Jack Howarth - July 2, 2012, 1:52 p.m.
On Mon, Jul 02, 2012 at 09:37:20AM -0400, Jack Howarth wrote:
> On Mon, Jul 02, 2012 at 01:43:56PM +0200, Richard Guenther wrote:
> > On Thu, 28 Jun 2012, Diego Novillo wrote:
> > 
> > > On 12-06-27 11:06 , Richard Guenther wrote:
> > > 
> > > > 2012-06-27  Richard Guenther  <rguenther@suse.de>
> > > > 	Michael Matz  <matz@suse.de>
> > > > 	Tobias Grosser <tobias@grosser.es>
> > > > 	Sebastian Pop <sebpop@gmail.com>
> > > > 
> > > > 	config/
> > > > 	* cloog.m4: Set up to work against ISL only.
> > > > 	* isl.m4: New file.
> > > > 
> > > > 	* Makefile.def: Add ISL host module, remove PPL host module.
> > > > 	Adjust ClooG host module to use the proper ISL.
> > > > 	* Makefile.tpl: Pass ISL include flags instead of PPL ones.
> > > > 	* configure.ac: Include config/isl.m4.  Add ISL host library,
> > > > 	remove PPL.  Remove PPL configury, add ISL configury, adjust
> > > > 	ClooG configury.
> > > > 	* Makefile.in: Regenerated.
> > > > 	* configure: Likewise.
> > > > 
> > > > 	gcc/
> > > > 	* Makefile.in: Remove PPL flags in favor of ISL ones.
> > > > 	(BACKENDLIBS): Remove PPL libs.
> > > > 	(INCLUDES): Remove PPL includes in favor of ISL ones.
> > > > 	(graphite-clast-to-gimple.o): Remove graphite-dependences.h and
> > > > 	graphite-cloog-compat.h dependencies.
> > > > 	(graphite-dependences.o): Likewise.
> > > > 	(graphite-poly.o): Likewise.
> > > > 	* configure.ac: Declare ISL vars instead of PPL ones.
> > > > 	* configure: Regenerated.
> > > > 	* doc/install.texi: Replace PPL requirement documentation
> > > > 	with ISL one.
> > > > 	* graphite-blocking.c: Remove PPL code, add ISL equivalent.
> > > > 	* graphite-clast-to-gimple.c: Likewise.
> > > > 	* graphite-dependences.c: Likewise.
> > > > 	* graphite-interchange.c: Likewise.
> > > > 	* graphite-poly.h: Likewise.
> > > > 	* graphite-poly.c: Likewise.
> > > > 	* graphite-sese-to-poly.c: Likewise.
> > > > 	* graphite.c: Likewise.
> > > > 	* graphite-scop-detection.c: Re-arrange includes.
> > > > 	* graphite-cloog-util.c: Remove.
> > > > 	* graphite-cloog-util.h: Likewise.
> > > > 	* graphite-ppl.h: Likewise.
> > > > 	* graphite-ppl.c: Likewise.
> > > > 	* graphite-dependences.h: Likewise.
> > > > 
> > > > 	libgomp/
> > > > 	* testsuite/libgomp.graphite/force-parallel-4.c: Adjust.
> > > > 	* testsuite/libgomp.graphite/force-parallel-5.c: Likewise.
> > > > 	* testsuite/libgomp.graphite/force-parallel-7.c: Likewise.
> > > > 	* testsuite/libgomp.graphite/force-parallel-8.c: Likewise.
> > > 
> > > OK.
> > 
> > Committed.
> > 
> > Richard.
> 
> Richard,
>    At r189157, with isl 0.10 and cloog.org 0.17.0 installed from the infrastructure
> directory, I am seeing a configure failure with...
> 
>   $ ../gcc-4.8-20120702/configure --prefix=/sw --prefix=/sw/lib/gcc4.8 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.8/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.8
> 
> of...
> 
> configure:5697: checking for version 0.10 of ISL
> configure:5725: gcc -o conftest -g -O2 -I/sw/include -I/sw/include -I/sw/include    -L/sw/lib -lisl -lisl conftest.c  >&5
> conftest.c:15:11: error: expected ';' at end of declaration
> int main()
>           ^
>           ;
> 1 error generated.
> configure:5725: $? = 1
> configure: program exited with status 1
> configure: failed program was:
> | /* confdefs.h */
> | #define PACKAGE_NAME ""
> | #define PACKAGE_TARNAME ""
> | #define PACKAGE_VERSION ""
> | #define PACKAGE_STRING ""
> | #define PACKAGE_BUGREPORT ""
> | #define PACKAGE_URL ""
> | #define LT_OBJDIR ".libs/"
> | /* end confdefs.h.  */
> | #include <isl/version.h>
> |    #include <string.h>
> | int
> | main ()
> | {
> | int main()
> |    {
> |      if (strncmp (isl_version (), "isl-0.10", strlen ("isl-0.10")) != 0)
> |        return 1;
> |      return 0;
> |    }
> |   ;
> |   return 0;
> | }
> configure:5735: result: no
> configure:5769: error: Unable to find a usable ISL.  See config.log for details.

Richard,
   Regenerating the top-level configure with 'autoconf -I. -I./config' at r189157 doesn't resolve the issue.
                  Jack
Richard Guenther - July 2, 2012, 2 p.m.
On Mon, 2 Jul 2012, Jack Howarth wrote:

> On Mon, Jul 02, 2012 at 09:37:20AM -0400, Jack Howarth wrote:
> > On Mon, Jul 02, 2012 at 01:43:56PM +0200, Richard Guenther wrote:
> > > On Thu, 28 Jun 2012, Diego Novillo wrote:
> > > 
> > > > On 12-06-27 11:06 , Richard Guenther wrote:
> > > > 
> > > > > 2012-06-27  Richard Guenther  <rguenther@suse.de>
> > > > > 	Michael Matz  <matz@suse.de>
> > > > > 	Tobias Grosser <tobias@grosser.es>
> > > > > 	Sebastian Pop <sebpop@gmail.com>
> > > > > 
> > > > > 	config/
> > > > > 	* cloog.m4: Set up to work against ISL only.
> > > > > 	* isl.m4: New file.
> > > > > 
> > > > > 	* Makefile.def: Add ISL host module, remove PPL host module.
> > > > > 	Adjust ClooG host module to use the proper ISL.
> > > > > 	* Makefile.tpl: Pass ISL include flags instead of PPL ones.
> > > > > 	* configure.ac: Include config/isl.m4.  Add ISL host library,
> > > > > 	remove PPL.  Remove PPL configury, add ISL configury, adjust
> > > > > 	ClooG configury.
> > > > > 	* Makefile.in: Regenerated.
> > > > > 	* configure: Likewise.
> > > > > 
> > > > > 	gcc/
> > > > > 	* Makefile.in: Remove PPL flags in favor of ISL ones.
> > > > > 	(BACKENDLIBS): Remove PPL libs.
> > > > > 	(INCLUDES): Remove PPL includes in favor of ISL ones.
> > > > > 	(graphite-clast-to-gimple.o): Remove graphite-dependences.h and
> > > > > 	graphite-cloog-compat.h dependencies.
> > > > > 	(graphite-dependences.o): Likewise.
> > > > > 	(graphite-poly.o): Likewise.
> > > > > 	* configure.ac: Declare ISL vars instead of PPL ones.
> > > > > 	* configure: Regenerated.
> > > > > 	* doc/install.texi: Replace PPL requirement documentation
> > > > > 	with ISL one.
> > > > > 	* graphite-blocking.c: Remove PPL code, add ISL equivalent.
> > > > > 	* graphite-clast-to-gimple.c: Likewise.
> > > > > 	* graphite-dependences.c: Likewise.
> > > > > 	* graphite-interchange.c: Likewise.
> > > > > 	* graphite-poly.h: Likewise.
> > > > > 	* graphite-poly.c: Likewise.
> > > > > 	* graphite-sese-to-poly.c: Likewise.
> > > > > 	* graphite.c: Likewise.
> > > > > 	* graphite-scop-detection.c: Re-arrange includes.
> > > > > 	* graphite-cloog-util.c: Remove.
> > > > > 	* graphite-cloog-util.h: Likewise.
> > > > > 	* graphite-ppl.h: Likewise.
> > > > > 	* graphite-ppl.c: Likewise.
> > > > > 	* graphite-dependences.h: Likewise.
> > > > > 
> > > > > 	libgomp/
> > > > > 	* testsuite/libgomp.graphite/force-parallel-4.c: Adjust.
> > > > > 	* testsuite/libgomp.graphite/force-parallel-5.c: Likewise.
> > > > > 	* testsuite/libgomp.graphite/force-parallel-7.c: Likewise.
> > > > > 	* testsuite/libgomp.graphite/force-parallel-8.c: Likewise.
> > > > 
> > > > OK.
> > > 
> > > Committed.
> > > 
> > > Richard.
> > 
> > Richard,
> >    At r189157, with isl 0.10 and cloog.org 0.17.0 installed from the infrastructure
> > directory, I am seeing a configure failure with...
> > 
> >   $ ../gcc-4.8-20120702/configure --prefix=/sw --prefix=/sw/lib/gcc4.8 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.8/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.8
> > 
> > of...
> > 
> > configure:5697: checking for version 0.10 of ISL
> > configure:5725: gcc -o conftest -g -O2 -I/sw/include -I/sw/include -I/sw/include    -L/sw/lib -lisl -lisl conftest.c  >&5
> > conftest.c:15:11: error: expected ';' at end of declaration
> > int main()
> >           ^
> >           ;
> > 1 error generated.
> > configure:5725: $? = 1
> > configure: program exited with status 1
> > configure: failed program was:
> > | /* confdefs.h */
> > | #define PACKAGE_NAME ""
> > | #define PACKAGE_TARNAME ""
> > | #define PACKAGE_VERSION ""
> > | #define PACKAGE_STRING ""
> > | #define PACKAGE_BUGREPORT ""
> > | #define PACKAGE_URL ""
> > | #define LT_OBJDIR ".libs/"
> > | /* end confdefs.h.  */
> > | #include <isl/version.h>
> > |    #include <string.h>
> > | int
> > | main ()
> > | {
> > | int main()
> > |    {
> > |      if (strncmp (isl_version (), "isl-0.10", strlen ("isl-0.10")) != 0)
> > |        return 1;
> > |      return 0;
> > |    }
> > |   ;
> > |   return 0;
> > | }
> > configure:5735: result: no
> > configure:5769: error: Unable to find a usable ISL.  See config.log for details.
> 
> Richard,
>    Regenerating the top-level configure with 'autoconf -I. -I./config' at r189157 doesn't resolve the issue.

Yeah, I see the issue ;)  Still my host compilers happily accept
int main() { int main () {} } and do not error:

configure:5697: checking for version 0.10 of ISL
configure:5725: gcc -o conftest -g      -lisl -lisl conftest.c  >&5
configure:5725: $? = 0
configure:5725: ./conftest
configure:5725: $? = 0
configure:5735: result: yes

I'll test a fix.

Thanks,
Richard.
Nenad Vukicevic - July 2, 2012, 6:25 p.m.
On 6/27/2012 8:06 AM, Richard Guenther wrote:
> This merges from the graphite branch the move of PPL to ISL,
> and completes it where it was lacking - thanks to Micha.
> It leaves unmerged the addition of a pluto-like ISL optimizer
> as well as a bugfix for stride > 1 which did not come with
> a testcase.
>
> With this patch (ontop of the one requiring ClooG 0.17.0)
> we will require ISL 0.10 for enabling Graphite.
>
> I've bootstrapped and built various combinations with in-tree
> and out-of-tree cloog and ISL, so I'm pretty confident that
> this works.
>
> With out-of-tree ClooG and ISL a slightly older patch ontop of its
> prerequesite passed bootstrap and testing on x86_64-unknown-linux-gnu.
>
> Currently re-bootstrapping and testing on x86_64-unknown-linux-gnu.
>
> Ok for trunk?

After trying to build from the trunk I got this error on x86_64 platform:

make[3]: Entering directory `/eng/upc/dev/nenad/bart/bld-trunk/cloog/test'
   CC     generate_test.o
cd ..; make  libcloog-isl.la
make[4]: Entering directory `/eng/upc/dev/nenad/bart/bld-trunk/cloog'
   CC     libcloog_isl_la-domain.lo
In file included from 
../../gcc-trunk/cloog/include/cloog/isl/constraintset.h:4:0,
                  from ../../gcc-trunk/cloog/include/cloog/isl/cloog.h:9,
                  from ../../gcc-trunk/cloog/source/isl/domain.c:6:
../../gcc-trunk/cloog/include/cloog/isl/backend.h:4:28: fatal error: 
isl/constraint.h: No such file or directory
compilation terminated.

After this point if I "cd cloog; make; cd ..; make" everything builds to 
the end.

I unpacked isl/cloog under the GCC source tree and used this to 
configure/make:

../gcc-trunk/configure --enable-languages=c,c++ --disable-bootstrap; make

Similar thing happens if I specify an absolute path for configure script.

Nenad
Tristan Gingold - July 4, 2012, 8:53 a.m.
On Jul 2, 2012, at 1:43 PM, Richard Guenther wrote:

> On Thu, 28 Jun 2012, Diego Novillo wrote:
> 
>> On 12-06-27 11:06 , Richard Guenther wrote:
>> 
>>> 2012-06-27  Richard Guenther  <rguenther@suse.de>
>>> 	Michael Matz  <matz@suse.de>
>>> 	Tobias Grosser <tobias@grosser.es>
>>> 	Sebastian Pop <sebpop@gmail.com>
>>> 
>>> 	config/
>>> 	* cloog.m4: Set up to work against ISL only.
>>> 	* isl.m4: New file.

Shouldn't ENABLE_IS_CHECK be automatically set to no when building a cross canadian ?
Richard Guenther - July 4, 2012, 8:58 a.m.
On Wed, 4 Jul 2012, Tristan Gingold wrote:

> 
> On Jul 2, 2012, at 1:43 PM, Richard Guenther wrote:
> 
> > On Thu, 28 Jun 2012, Diego Novillo wrote:
> > 
> >> On 12-06-27 11:06 , Richard Guenther wrote:
> >> 
> >>> 2012-06-27  Richard Guenther  <rguenther@suse.de>
> >>> 	Michael Matz  <matz@suse.de>
> >>> 	Tobias Grosser <tobias@grosser.es>
> >>> 	Sebastian Pop <sebpop@gmail.com>
> >>> 
> >>> 	config/
> >>> 	* cloog.m4: Set up to work against ISL only.
> >>> 	* isl.m4: New file.
> 
> Shouldn't ENABLE_IS_CHECK be automatically set to no when building a cross canadian ?

Probably yes, as it is a runtime test.  Thus at any time when host != 
build.  Care to post a patch?  You probably know best what the canonical
way to check this is.

Richard.

Patch

diff --git a/Makefile.def b/Makefile.def
index 24aadc9..3969bf6 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -61,13 +61,15 @@  host_modules= { module= mpfr; lib_path=.libs; bootstrap=true;
 host_modules= { module= mpc; lib_path=.libs; bootstrap=true;
 		extra_configure_flags='--disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@';
 		no_install= true; };
-host_modules= { module= ppl; lib_path=src/.libs; bootstrap=true;
-		extra_configure_flags='--disable-shared --with-libgmp-prefix=$$r/$(HOST_SUBDIR)/gmp/ --with-libgmpxx-prefix=$$r/$(HOST_SUBDIR)/gmp/';
+host_modules= { module= isl; lib_path=.libs; bootstrap=true;
+		extra_configure_flags='--disable-shared --with-gmp-library=$$r/$(HOST_SUBDIR)/gmp/.libs --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-bits=gmp';
+		extra_exports='CPPFLAGS="${CPPFLAGS}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS"; export LDFLAGS; ';
+		extra_make_flags='CPPFLAGS="${CPPFLAGS}" LDFLAGS="$$LDFLAGS"';
 		no_install= true; };
 host_modules= { module= cloog; lib_path=.libs; bootstrap=true;
-		extra_configure_flags='--disable-shared --with-gmp-library=$$r/$(HOST_SUBDIR)/gmp/.libs --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-bits=gmp --with-ppl';
-		extra_exports='CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS; ';
-		extra_make_flags='CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"';
+		extra_configure_flags='--disable-shared --with-gmp-library=$$r/$(HOST_SUBDIR)/gmp/.libs --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-bits=gmp --with-isl=system';
+		extra_exports='CPPFLAGS="-I$$r/$(HOST_SUBDIR)/isl/include -I$$s/isl/include ${CPPFLAGS}"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS; ';
+		extra_make_flags='CPPFLAGS="${CPPFLAGS}" LDFLAGS="$$LDFLAGS"';
 		no_install= true; };
 host_modules= { module= libelf; lib_path=.libs; bootstrap=true;
 		extra_configure_flags='--disable-shared';
@@ -295,7 +297,6 @@  dependencies = { module=all-gcc; on=all-gmp; };
 dependencies = { module=all-gcc; on=all-intl; };
 dependencies = { module=all-gcc; on=all-mpfr; };
 dependencies = { module=all-gcc; on=all-mpc; };
-dependencies = { module=all-gcc; on=all-ppl; };
 dependencies = { module=all-gcc; on=all-cloog; };
 dependencies = { module=all-gcc; on=all-build-texinfo; };
 dependencies = { module=all-gcc; on=all-build-bison; };
@@ -332,9 +333,9 @@  dependencies = { module=all-utils; on=all-libiberty; };
 
 dependencies = { module=configure-mpfr; on=all-gmp; };
 dependencies = { module=configure-mpc; on=all-mpfr; };
-dependencies = { module=configure-ppl; on=all-gmp; };
-dependencies = { module=configure-ppl; on=all-mpfr; };
-dependencies = { module=configure-cloog; on=all-ppl; };
+dependencies = { module=configure-isl; on=all-gmp; };
+dependencies = { module=configure-cloog; on=all-isl; };
+dependencies = { module=configure-cloog; on=all-gmp; };
 
 // Host modules specific to gdb.
 dependencies = { module=configure-gdb; on=all-intl; };
diff --git a/Makefile.tpl b/Makefile.tpl
index d898b7d..2573eee 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -222,8 +222,7 @@  HOST_EXPORTS = \
 	HOST_LIBS="$(STAGE1_LIBS)"; export HOST_LIBS; \
 	GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \
 	GMPINC="$(HOST_GMPINC)"; export GMPINC; \
-	PPLLIBS="$(HOST_PPLLIBS)"; export PPLLIBS; \
-	PPLINC="$(HOST_PPLINC)"; export PPLINC; \
+	ISLINC="$(HOST_ISLINC)"; export ISLINC; \
 	CLOOGLIBS="$(HOST_CLOOGLIBS)"; export CLOOGLIBS; \
 	CLOOGINC="$(HOST_CLOOGINC)"; export CLOOGINC; \
 	LIBELFLIBS="$(HOST_LIBELFLIBS)" ; export LIBELFLIBS; \
@@ -313,9 +312,8 @@  NORMAL_TARGET_EXPORTS = \
 HOST_GMPLIBS = @gmplibs@
 HOST_GMPINC = @gmpinc@
 
-# Where to find PPL
-HOST_PPLLIBS = @ppllibs@
-HOST_PPLINC = @pplinc@
+# Where to find ISL
+HOST_ISLINC = @islinc@
 
 # Where to find CLOOG
 HOST_CLOOGLIBS = @clooglibs@
diff --git a/config/cloog.m4 b/config/cloog.m4
index 9c42445..603df6b 100644
--- a/config/cloog.m4
+++ b/config/cloog.m4
@@ -63,6 +63,17 @@  AC_DEFUN([CLOOG_INIT_FLAGS],
   if test "x${with_cloog_lib}" != x; then
     clooglibs="-L$with_cloog_lib"
   fi
+  dnl If no --with-cloog flag was specified and there is in-tree ClooG
+  dnl source, set up flags to use that.
+  if test "x${clooginc}" == x && test "x${clooglibs}" == x \
+     && test -d ${srcdir}/cloog; then
+     echo FooBar
+     clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' '
+     clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include -I'${srcdir}'/cloog/include '
+  fi
+
+  clooginc="-DCLOOG_INT_GMP ${clooginc}"
+  clooglibs="${clooglibs} -lcloog-isl ${isllibs}"
 
   dnl Flags needed for CLOOG
   AC_SUBST(clooglibs)
@@ -89,63 +100,11 @@  AC_DEFUN([CLOOG_REQUESTED],
 ]
 )
 
-# _CLOOG_ORG_PROG_ISL ()
-# ------------------
-# Helper for detecting CLooG.org's ISL backend.
-m4_define([_CLOOG_ORG_PROG_ISL],[AC_LANG_PROGRAM(
-  [#include "cloog/cloog.h" ],
-  [cloog_version ()])])
-
-# CLOOG_FIND_FLAGS ()
-# ------------------
-# Detect the used CLooG-backend and set clooginc/clooglibs/cloog_org.
-# Only look for the CLooG backend type specified in --enable-cloog-backend
-AC_DEFUN([CLOOG_FIND_FLAGS],
-[
-  AC_REQUIRE([CLOOG_INIT_FLAGS])
-
-  _cloog_saved_CFLAGS=$CFLAGS
-  _cloog_saved_CPPFLAGS=$CPPFLAGS
-  _cloog_saved_LDFLAGS=$LDFLAGS
-  _cloog_saved_LIBS=$LIBS
-
-  _cloogorginc="-DCLOOG_INT_GMP"
- 
-  dnl clooglibs & clooginc may have been initialized by CLOOG_INIT_FLAGS.
-  CFLAGS="${CFLAGS} ${clooginc} ${gmpinc}"
-  CPPFLAGS="${CPPFLAGS} ${_cloogorginc}"
-  LDFLAGS="${LDFLAGS} ${clooglibs}"
-
-  AC_CACHE_CHECK([for installed CLooG ISL], [gcc_cv_cloog_type],
-    [LIBS="-lcloog-isl ${_cloog_saved_LIBS}"
-    AC_LINK_IFELSE([_CLOOG_ORG_PROG_ISL], [gcc_cv_cloog_type="ISL"],
-		   [gcc_cv_cloog_type=no])])
-
-  case $gcc_cv_cloog_type in
-    "ISL")
-      clooginc="${clooginc} ${_cloogorginc}"
-      clooglibs="${clooglibs} -lcloog-isl -lisl"
-      cloog_org=yes
-      ;;
-    *)
-      clooglibs=
-      clooginc=
-      cloog_org=
-      ;;
-  esac
-
-  LIBS=$_cloog_saved_LIBS
-  CFLAGS=$_cloog_saved_CFLAGS
-  CPPFLAGS=$_cloog_saved_CPPFLAGS
-  LDFLAGS=$_cloog_saved_LDFLAGS
-]
-)
-
 # _CLOOG_CHECK_CT_PROG(MAJOR, MINOR, REVISION)
 # --------------------------------------------
 # Helper for verifying CLooG's compile time version.
 m4_define([_CLOOG_CHECK_CT_PROG],[AC_LANG_PROGRAM(
-  [#include "cloog/cloog.h"],
+  [#include "cloog/version.h"],
   [#if CLOOG_VERSION_MAJOR != $1 \
     || CLOOG_VERSION_MINOR != $2 \
     || CLOOG_VERSION_REVISION < $3
@@ -158,14 +117,14 @@  m4_define([_CLOOG_CHECK_CT_PROG],[AC_LANG_PROGRAM(
 # REVISION.
 AC_DEFUN([CLOOG_CHECK_VERSION],
 [
-  AC_REQUIRE([CLOOG_FIND_FLAGS])
+  AC_REQUIRE([CLOOG_INIT_FLAGS])
 
   if test "${ENABLE_CLOOG_CHECK}" = yes ; then
     _cloog_saved_CFLAGS=$CFLAGS
     _cloog_saved_LDFLAGS=$LDFLAGS
 
-    CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
-    LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs} ${ppllibs}"
+    CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${islinc} ${gmpinc}"
+    LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs} ${isllibs} ${gmplib}"
 
     AC_CACHE_CHECK([for version $1.$2.$3 of CLooG],
       [gcc_cv_cloog],
diff --git a/config/isl.m4 b/config/isl.m4
new file mode 100644
index 0000000..0ddeddb
--- /dev/null
+++ b/config/isl.m4
@@ -0,0 +1,162 @@ 
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 3, or (at your option) any later
+# version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+#
+# Contributed by Richard Guenther <rguenther@suse.de>
+# Based on cloog.m4
+
+# ISL_INIT_FLAGS ()
+# -------------------------
+# Provide configure switches for ISL support.
+# Initialize isllibs/islinc according to the user input.
+AC_DEFUN([ISL_INIT_FLAGS],
+[
+  AC_ARG_WITH(isl,
+    [AS_HELP_STRING(
+      [--with-isl=PATH],
+      [Specify prefix directory for the installed ISL package.
+       Equivalent to --with-isl-include=PATH/include
+       plus --with-isl-lib=PATH/lib])])
+  AC_ARG_WITH([isl-include],
+    [AS_HELP_STRING(
+      [--with-isl-include=PATH],
+      [Specify directory for installed ISL include files])])
+  AC_ARG_WITH([isl-lib],
+    [AS_HELP_STRING(
+      [--with-isl-lib=PATH],
+      [Specify the directory for the installed ISL library])])
+
+  AC_ARG_ENABLE(isl-version-check,
+    [AS_HELP_STRING(
+      [--disable-isl-version-check],
+      [disable check for ISL version])],
+    ENABLE_ISL_CHECK=$enableval,
+    ENABLE_ISL_CHECK=yes)
+  
+  # Initialize isllibs and islinc.
+  case $with_isl in
+    no)
+      isllibs=
+      islinc=
+      ;;
+    "" | yes)
+      ;;
+    *)
+      isllibs="-L$with_isl/lib"
+      islinc="-I$with_isl/include"
+      ;;
+  esac
+  if test "x${with_isl_include}" != x ; then
+    islinc="-I$with_isl_include"
+  fi
+  if test "x${with_isl_lib}" != x; then
+    isllibs="-L$with_isl_lib"
+  fi
+  dnl If no --with-isl flag was specified and there is in-tree ISL
+  dnl source, set up flags to use that and skip any version tests
+  dnl as we cannot run them before building ISL.
+  if test "x${islinc}" = x && test "x${isllibs}" = x \
+     && test -d ${srcdir}/isl; then
+    isllibs='-L$$r/$(HOST_SUBDIR)/isl/'"$lt_cv_objdir"' '
+    islinc='-I$$r/$(HOST_SUBDIR)/isl/include -I$$s/isl/include'
+    ENABLE_ISL_CHECK=no
+  fi
+
+  isllibs="${isllibs} -lisl"
+
+  dnl Flags needed for ISL
+  AC_SUBST(isllibs)
+  AC_SUBST(islinc)
+]
+)
+
+# ISL_REQUESTED (ACTION-IF-REQUESTED, ACTION-IF-NOT)
+# ----------------------------------------------------
+# Provide actions for failed CLooG detection.
+AC_DEFUN([ISL_REQUESTED],
+[
+  AC_REQUIRE([ISL_INIT_FLAGS])
+
+  if test "x${with_isl}" = xno; then
+    $2
+  elif test "x${with_isl}" != x \
+    || test "x${with_isl_include}" != x \
+    || test "x${with_isl_lib}" != x ; then
+    $1
+  else
+    $2
+  fi
+]
+)
+
+# _ISL_CHECK_CT_PROG(MAJOR, MINOR)
+# --------------------------------------------
+# Helper for verifying CLooG's compile time version.
+m4_define([_ISL_CHECK_CT_PROG],[AC_LANG_PROGRAM(
+  [#include <isl/version.h>
+   #include <string.h>],
+  [int main()
+   {
+     if (strncmp (isl_version (), "isl-0.10", strlen ("isl-$1.$2")) != 0)
+       return 1;
+     return 0;
+   }])])
+
+# ISL_CHECK_VERSION ISL_CHECK_VERSION (MAJOR, MINOR)
+# ----------------------------------------------------------------
+# Test the found ISL to be exact of version MAJOR.MINOR and at least
+# REVISION.
+AC_DEFUN([ISL_CHECK_VERSION],
+[
+  if test "${ENABLE_ISL_CHECK}" = yes ; then
+    _isl_saved_CFLAGS=$CFLAGS
+    _isl_saved_LDFLAGS=$LDFLAGS
+
+    CFLAGS="${_isl_saved_CFLAGS} ${islinc} ${gmpinc}"
+    LDFLAGS="${_isl_saved_LDFLAGS} ${isllibs} -lisl"
+    echo $CFLAGS
+
+    AC_CACHE_CHECK([for version $1.$2 of ISL],
+      [gcc_cv_isl],
+      [AC_RUN_IFELSE([_ISL_CHECK_CT_PROG($1,$2)],
+	[gcc_cv_isl=yes],
+	[gcc_cv_isl=no])])
+
+    CFLAGS=$_isl_saved_CFLAGS
+    LDFLAGS=$_isl_saved_LDFLAGS
+  fi
+]
+)
+
+# ISL_IF_FAILED (ACTION-IF-FAILED)
+# ----------------------------------
+# Executes ACTION-IF-FAILED, if GRAPHITE was requested and
+# the checks failed.
+AC_DEFUN([ISL_IF_FAILED],
+[
+  ISL_REQUESTED([graphite_requested=yes], [graphite_requested=no])
+  
+  if test "${gcc_cv_isl}" = no ; then
+    isllibs=
+    islinc=
+  fi
+
+  if test "${graphite_requested}" = yes \
+    && test "x${isllibs}" = x \
+    && test "x${islinc}" = x ; then
+    $1
+  fi
+]
+)
diff --git a/configure.ac b/configure.ac
index 179e2a7..7f325a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,7 @@  m4_include([ltoptions.m4])
 m4_include([ltsugar.m4])
 m4_include([ltversion.m4])
 m4_include([lt~obsolete.m4])
+m4_include([config/isl.m4])
 m4_include([config/cloog.m4])
 
 AC_INIT(move-if-change)
@@ -132,7 +133,7 @@  build_tools="build-texinfo build-flex build-bison build-m4 build-fixincludes"
 
 # these libraries are used by various programs built for the host environment
 #
-host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libcpp libdecnumber gmp mpfr mpc ppl cloog libelf libiconv"
+host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libcpp libdecnumber gmp mpfr mpc isl cloog libelf libiconv"
 
 # these tools are built for the host environment
 # Note, the powerpc-eabi build depends on sim occurring before gdb in order to
@@ -1517,107 +1518,23 @@  AC_ARG_WITH(boot-ldflags,
  fi])
 AC_SUBST(poststage1_ldflags)
 
-# Check for PPL
-ppllibs=
-pplinc=
-pwllib=
-
-AC_ARG_WITH(ppl,
-[AS_HELP_STRING([--with-ppl=PATH],
-		[specify prefix directory for the installed PPL package.
-		 Equivalent to --with-ppl-include=PATH/include
-		 plus --with-ppl-lib=PATH/lib])])
-AC_ARG_WITH(ppl-include,
-[AS_HELP_STRING([--with-ppl-include=PATH],
-		[specify directory for installed PPL include files])])
-AC_ARG_WITH(ppl-lib,
-[AS_HELP_STRING([--with-ppl-lib=PATH],
-		[specify directory for the installed PPL library])])
-
-AC_ARG_ENABLE(ppl-version-check,
-[AS_HELP_STRING([--disable-ppl-version-check],
-		[disable check for PPL version])])
-
-case $with_ppl in
-  yes | no | "")
-    ;;
-  *)
-    ppllibs="-L$with_ppl/lib"
-    pplinc="-I$with_ppl/include $pplinc"
-    if test -d "$with_ppl/lib" && test -d "$with_ppl/include"; then
-      with_ppl=yes
-    else
-      AC_MSG_ERROR([cannot find directories "$with_ppl/lib" or "$with_ppl/include"])
-    fi
-    ;;
-esac
-
-if test x"$with_ppl_include" != x; then
-  pplinc="-I$with_ppl_include $pplinc"
-  with_ppl=yes
-fi
-
-if test "x$with_ppl_lib" != x; then
-  ppllibs="-L$with_ppl_lib"
-  with_ppl=yes
-fi
-
-if test x"$with_ppl$with_ppl_include$with_ppl_lib" = x && test -d ${srcdir}/ppl; then
-  if test x"$enable_watchdog" = xyes; then
-    pwllib="-lpwl"
-  fi
-  ppllibs='-L$$r/$(HOST_SUBDIR)/ppl/interfaces/C/'"$lt_cv_objdir"' -L$$r/$(HOST_SUBDIR)/ppl/src/'"$lt_cv_objdir"
-  pplinc='-I$$r/$(HOST_SUBDIR)/ppl/src -I$$r/$(HOST_SUBDIR)/ppl/interfaces/C '
-  enable_ppl_version_check=no
-  with_ppl=yes
-fi
-
-if test "x$with_ppl" != xno; then
-  if test "x$pwllib" = x; then
-    saved_LIBS="$LIBS"
-    LIBS="$LIBS $ppllibs -lstdc++ -lm"
-    AC_CHECK_LIB(pwl, PWL_handle_timeout, [pwllib="-lpwl"])
-    LIBS="$saved_LIBS"
-  fi
-
-  ppllibs="$ppllibs -lppl_c -lppl $pwllib -lgmpxx"
+# Check for ISL
+dnl Provide configure switches and initialize islinc & isllibs
+dnl with user input.
+ISL_INIT_FLAGS
+if test "x$with_isl" != "xno"; then
+  dnl The minimal version of ISL required for Graphite.
+  ISL_CHECK_VERSION(0,10)
 
-  if test "$enable_ppl_version_check" != no; then
-    saved_CFLAGS="$CFLAGS"
-    CFLAGS="$CFLAGS $pplinc $gmpinc"
-    AC_MSG_CHECKING([for version 0.11 (revision 0 or later) of PPL])
-    AC_TRY_COMPILE([#include "ppl_c.h"],[
-    #if PPL_VERSION_MAJOR != 0 || PPL_VERSION_MINOR < 11
-    choke me
-    #endif
-    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); ppllibs= ; pplinc= ; with_ppl=no ])
-    CFLAGS="$saved_CFLAGS"
-  fi
+  dnl Only execute fail-action, if ISL has been requested.
+  ISL_IF_FAILED([
+    AC_MSG_ERROR([Unable to find a usable ISL.  See config.log for details.])])
 fi
 
-# Flags needed for PPL
-AC_SUBST(ppllibs)
-AC_SUBST(pplinc)
-
-
 # Check for CLOOG
-
 dnl Provide configure switches and initialize clooginc & clooglibs
 dnl with user input.
 CLOOG_INIT_FLAGS
-if test "x$with_ppl" = "xno"; then
-  dnl Only execute fail-action, if CLooG has been requested.
-  CLOOG_REQUESTED([graphite_requested=yes], [graphite_requested=no])
-  if test "${graphite_requested}" = yes; then
-    AC_MSG_ERROR([Unable to find a usable PPL.  See config.log for details.])
-  fi
-  with_cloog=no
-fi
-if test "x${with_cloog}" = x && test "x${with_cloog_include}" = x \
-  && test "x${with_cloog_lib}" = x && test -d ${srcdir}/cloog; then
-  clooglibs='-L$$r/$(HOST_SUBDIR)/cloog/'"$lt_cv_objdir"' '
-  clooginc='-I$$r/$(HOST_SUBDIR)/cloog/include -I$$s/cloog/include '
-fi
 if test "x$with_cloog" != "xno"; then
   dnl The minimal version of CLooG required for Graphite.
   dnl
@@ -2681,7 +2598,7 @@  changequote(,)
 changequote([,])
 
     case $lib in
-    mpc | mpfr | gmp | ppl | cloog)
+    mpc | mpfr | gmp | cloog)
       # If we're processing --with-$lib, --with-$lib-include or
       # --with-$lib-lib, for one of the libs above, and target is
       # different from host, don't pass the current argument to any
@@ -3263,9 +3180,6 @@  case "$target" in
   hppa*64*-*-hpux*) ;;
   hppa*-*-hpux*) compare_exclusions="gcc/cc*-checksum\$(objext) | */libgcc/lib2funcs* | gcc/ada/*tools/*" ;;
 esac
-case " $configdirs " in
-*" ppl "*) compare_exclusions="$compare_exclusions | ppl/src/ppl-config.o" ;;
-esac
 AC_SUBST(compare_exclusions)
 
 AC_CONFIG_FILES([Makefile],
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index a7406bd..2c6729d 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -325,9 +325,8 @@  ZLIBINC = @zlibinc@
 GMPLIBS = @GMPLIBS@
 GMPINC = @GMPINC@
 
-# How to find PPL
-PPLLIBS = @PPLLIBS@
-PPLINC = @PPLINC@
+# How to find ISL
+ISLINC = @ISLINC@
 
 # How to find CLOOG
 CLOOGLIBS = @CLOOGLIBS@
@@ -954,7 +953,6 @@  REAL_H = real.h $(MACHMODE_H)
 IRA_INT_H = ira.h ira-int.h $(CFGLOOP_H) alloc-pool.h
 DBGCNT_H = dbgcnt.h dbgcnt.def
 EBITMAP_H = ebitmap.h sbitmap.h
-GRAPHITE_PPL_H = graphite-ppl.h $(TREE_H)
 LTO_STREAMER_H = lto-streamer.h $(LINKER_PLUGIN_API_H) $(TARGET_H) \
 		$(CGRAPH_H) $(VEC_H) vecprim.h $(TREE_H) $(GIMPLE_H) \
 		$(GCOV_IO_H) $(DIAGNOSTIC_H) alloc-pool.h
@@ -1027,7 +1025,7 @@  BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
 # and the system's installed libraries.
 LIBS = @LIBS@ libcommon.a $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBIBERTY) \
 	$(LIBDECNUMBER) $(HOST_LIBS)
-BACKENDLIBS = $(CLOOGLIBS) $(PPLLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
+BACKENDLIBS = $(CLOOGLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
 	$(ZLIB)
 # Any system libraries needed just for GNAT.
 SYSLIBS = @GNAT_LIBEXC@
@@ -1059,7 +1057,7 @@  BUILD_ERRORS = build/errors.o
 INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
 	   -I$(srcdir)/../include @INCINTL@ \
 	   $(CPPINC) $(GMPINC) $(DECNUMINC) \
-	   $(PPLINC) $(CLOOGINC)
+	   $(CLOOGINC) $(ISLINC)
 
 .c.o:
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $< $(OUTPUT_OPTION)
@@ -1253,11 +1251,9 @@  OBJS = \
 	graphite.o \
 	graphite-blocking.o \
 	graphite-clast-to-gimple.o \
-	graphite-cloog-util.o \
 	graphite-dependences.o \
 	graphite-interchange.o \
 	graphite-poly.o \
-	graphite-ppl.o \
 	graphite-scop-detection.o \
 	graphite-sese-to-poly.o \
 	gtype-desc.o \
@@ -2617,37 +2613,30 @@  sese.o : sese.c sese.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TREE_PRETTY_PRINT_H
    $(TREE_FLOW_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) $(TREE_PASS_H) value-prof.h
 graphite.o : graphite.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(DIAGNOSTIC_CORE_H) \
    $(TREE_FLOW_H) $(TREE_DUMP_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) sese.h \
-   $(DBGCNT_H) $(GRAPHITE_PPL_H) graphite-poly.h graphite-scop-detection.h \
+   $(DBGCNT_H) graphite-poly.h graphite-scop-detection.h \
    graphite-clast-to-gimple.h graphite-sese-to-poly.h
 graphite-blocking.o : graphite-blocking.c $(CONFIG_H) $(SYSTEM_H) \
    coretypes.h $(TREE_FLOW_H) $(TREE_DUMP_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) \
-   sese.h $(GRAPHITE_PPL_H) graphite-poly.h
+   sese.h graphite-poly.h
 graphite-clast-to-gimple.o : graphite-clast-to-gimple.c $(CONFIG_H) \
    $(SYSTEM_H) coretypes.h $(DIAGNOSTIC_CORE_H) $(TREE_FLOW_H) $(TREE_DUMP_H) \
-   $(CFGLOOP_H) $(TREE_DATA_REF_H) sese.h graphite-cloog-util.h \
-   $(GRAPHITE_PPL_H) graphite-poly.h graphite-clast-to-gimple.h \
-   graphite-dependences.h graphite-cloog-compat.h
-graphite-cloog-util.o : graphite-cloog-util.c $(CONFIG_H) $(SYSTEM_H) \
-   coretypes.h graphite-cloog-util.h
+   $(CFGLOOP_H) $(TREE_DATA_REF_H) sese.h \
+   graphite-poly.h graphite-clast-to-gimple.h
 graphite-dependences.o : graphite-dependences.c $(CONFIG_H) $(SYSTEM_H) \
    coretypes.h $(TREE_FLOW_H) $(TREE_DUMP_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) \
-   sese.h $(GRAPHITE_PPL_H) graphite-poly.h graphite-dependences.h \
-   graphite-cloog-util.h
+   sese.h graphite-poly.h
 graphite-interchange.o : graphite-interchange.c $(CONFIG_H) $(SYSTEM_H) \
    coretypes.h $(TREE_FLOW_H) $(TREE_DUMP_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) \
-   sese.h $(GRAPHITE_PPL_H) graphite-poly.h
+   sese.h graphite-poly.h
 graphite-poly.o : graphite-poly.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(DIAGNOSTIC_CORE_H) $(TREE_FLOW_H) $(TREE_DUMP_H) $(GIMPLE_PRETTY_PRINT_H) \
-   $(CFGLOOP_H) $(TREE_DATA_REF_H) sese.h $(GRAPHITE_PPL_H) graphite-poly.h \
-   graphite-dependences.h graphite-cloog-util.h
-graphite-ppl.o : graphite-ppl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
-   graphite-cloog-util.h $(GRAPHITE_PPL_H)
+   $(CFGLOOP_H) $(TREE_DATA_REF_H) sese.h graphite-poly.h
 graphite-scop-detection.o : graphite-scop-detection.c $(CONFIG_H) $(SYSTEM_H) \
    coretypes.h $(TREE_FLOW_H) $(CFGLOOP_H) $(TREE_DATA_REF_H) $(TREE_PASS_H) \
-   sese.h $(GRAPHITE_PPL_H) graphite-poly.h graphite-scop-detection.h
+   sese.h graphite-poly.h graphite-scop-detection.h
 graphite-sese-to-poly.o : graphite-sese-to-poly.c $(CONFIG_H) \
    $(SYSTEM_H) coretypes.h $(TREE_FLOW_H) $(TREE_DUMP_H) $(CFGLOOP_H) \
-   $(TREE_DATA_REF_H) domwalk.h sese.h $(GRAPHITE_PPL_H) graphite-poly.h \
+   $(TREE_DATA_REF_H) domwalk.h sese.h graphite-poly.h \
    graphite-sese-to-poly.h
 tree-vect-loop.o: tree-vect-loop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TM_H) $(GGC_H) $(TREE_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) \
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 22dab55..ab1faad 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4992,8 +4992,8 @@  fi
 AC_ARG_VAR(GMPLIBS,[How to link GMP])
 AC_ARG_VAR(GMPINC,[How to find GMP include files])
 
-AC_ARG_VAR(PPLLIBS,[How to link PPL])
-AC_ARG_VAR(PPLINC,[How to find PPL include files])
+AC_ARG_VAR(ISLLIBS,[How to link ISL])
+AC_ARG_VAR(ISLINC,[How to find ISL include files])
 
 AC_ARG_VAR(CLOOGLIBS,[How to link CLOOG])
 AC_ARG_VAR(CLOOGINC,[How to find CLOOG include files])
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index b262bee..436f656 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -362,12 +362,12 @@  installed but it is not in your default library search path, the
 @option{--with-mpc} configure option should be used.  See also
 @option{--with-mpc-lib} and @option{--with-mpc-include}.
 
-@item Parma Polyhedra Library (PPL) version 0.11
+@item ISL Library version 0.10
 
 Necessary to build GCC with the Graphite loop optimizations.
-It can be downloaded from @uref{http://www.cs.unipr.it/ppl/Download/}.
+It can be downloaded from @uref{ftp://gcc.gnu.org/pub/gcc/infrastructure/}.
 
-The @option{--with-ppl} configure option should be used if PPL is not
+The @option{--with-isl} configure option should be used if ISL is not
 installed in your default library search path.
 
 @item CLooG 0.17.0
@@ -1630,14 +1630,14 @@  a cross compiler, they will not be used to configure target libraries.
 @itemx --with-cloog=@var{pathname}
 @itemx --with-cloog-include=@var{pathname}
 @itemx --with-cloog-lib=@var{pathname}
-If you do not have PPL (the Parma Polyhedra Library) and the CLooG
+If you do not have ISL and the CLooG
 libraries installed in a standard location and you want to build GCC,
 you can explicitly specify the directory where they are installed
-(@samp{--with-ppl=@/@var{pplinstalldir}},
+(@samp{--with-isl=@/@var{islinstalldir}},
 @samp{--with-cloog=@/@var{clooginstalldir}}). The
-@option{--with-ppl=@/@var{pplinstalldir}} option is shorthand for
-@option{--with-ppl-lib=@/@var{pplinstalldir}/lib} and
-@option{--with-ppl-include=@/@var{pplinstalldir}/include}.  Likewise the
+@option{--with-isl=@/@var{islinstalldir}} option is shorthand for
+@option{--with-isl-lib=@/@var{islinstalldir}/lib} and
+@option{--with-isl-include=@/@var{islinstalldir}/include}.  Likewise the
 @option{--with-cloog=@/@var{clooginstalldir}} option is shorthand for
 @option{--with-cloog-lib=@/@var{clooginstalldir}/lib} and
 @option{--with-cloog-include=@/@var{clooginstalldir}/include}.  If these
diff --git a/gcc/graphite-blocking.c b/gcc/graphite-blocking.c
index 967de9d..b4ac522 100644
--- a/gcc/graphite-blocking.c
+++ b/gcc/graphite-blocking.c
@@ -1,7 +1,7 @@ 
 /* Heuristics and transform for loop blocking and strip mining on
    polyhedral representation.
 
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Pranav Garg  <pranav.garg2107@gmail.com>.
 
@@ -20,7 +20,18 @@  GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
+
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <isl/constraint.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
@@ -31,8 +42,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "sese.h"
 
 #ifdef HAVE_cloog
-#include "ppl_c.h"
-#include "graphite-ppl.h"
 #include "graphite-poly.h"
 
 
@@ -92,65 +101,39 @@  along with GCC; see the file COPYING3.  If not see
 static void
 pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, int stride)
 {
-  ppl_dimension_type iter, dim, strip;
-  ppl_Polyhedron_t res = PBB_TRANSFORMED_SCATTERING (pbb);
+  isl_space *d;
+  isl_constraint *c;
+  int iter, strip;
   /* STRIP is the dimension that iterates with stride STRIDE.  */
   /* ITER is the dimension that enumerates single iterations inside
      one strip that has at most STRIDE iterations.  */
   strip = time_depth;
   iter = strip + 2;
 
-  psct_add_scattering_dimension (pbb, strip);
-  psct_add_scattering_dimension (pbb, strip + 1);
-
-  ppl_Polyhedron_space_dimension (res, &dim);
+  pbb->transformed = isl_map_insert_dims (pbb->transformed, isl_dim_out,
+					  strip, 2);
 
   /* Lower bound of the striped loop.  */
-  {
-    ppl_Constraint_t new_cstr;
-    ppl_Linear_Expression_t expr;
-
-    ppl_new_Linear_Expression_with_dimension (&expr, dim);
-    ppl_set_coef (expr, strip, -1 * stride);
-    ppl_set_coef (expr, iter, 1);
-
-    ppl_new_Constraint (&new_cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-    ppl_delete_Linear_Expression (expr);
-    ppl_Polyhedron_add_constraint (res, new_cstr);
-    ppl_delete_Constraint (new_cstr);
-  }
+  d = isl_map_get_space (pbb->transformed);
+  c = isl_inequality_alloc (isl_local_space_from_space (d));
+  c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip, -stride);
+  c = isl_constraint_set_coefficient_si (c, isl_dim_out, iter, 1);
+  pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
 
   /* Upper bound of the striped loop.  */
-  {
-    ppl_Constraint_t new_cstr;
-    ppl_Linear_Expression_t expr;
-
-    ppl_new_Linear_Expression_with_dimension (&expr, dim);
-    ppl_set_coef (expr, strip, stride);
-    ppl_set_coef (expr, iter, -1);
-    ppl_set_inhomogeneous (expr, stride - 1);
-
-    ppl_new_Constraint (&new_cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-    ppl_delete_Linear_Expression (expr);
-    ppl_Polyhedron_add_constraint (res, new_cstr);
-    ppl_delete_Constraint (new_cstr);
-  }
+  d = isl_map_get_space (pbb->transformed);
+  c = isl_inequality_alloc (isl_local_space_from_space (d));
+  c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip, stride);
+  c = isl_constraint_set_coefficient_si (c, isl_dim_out, iter, -1);
+  c = isl_constraint_set_constant_si (c, stride - 1);
+  pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
 
   /* Static scheduling for ITER level.
      This is mandatory to keep the 2d + 1 canonical scheduling format.  */
-  {
-    ppl_Constraint_t new_cstr;
-    ppl_Linear_Expression_t expr;
-
-    ppl_new_Linear_Expression_with_dimension (&expr, dim);
-    ppl_set_coef (expr, strip + 1, 1);
-    ppl_set_inhomogeneous (expr, 0);
-
-    ppl_new_Constraint (&new_cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
-    ppl_delete_Linear_Expression (expr);
-    ppl_Polyhedron_add_constraint (res, new_cstr);
-    ppl_delete_Constraint (new_cstr);
-  }
+  d = isl_map_get_space (pbb->transformed);
+  c = isl_equality_alloc (isl_local_space_from_space (d));
+  c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip + 1, 1);
+  pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
 }
 
 /* Returns true when strip mining with STRIDE of the loop LST is
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 9ab746e..0219afe 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -19,6 +19,19 @@  along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <isl/list.h>
+#include <isl/constraint.h>
+#include <isl/ilp.h>
+#include <isl/aff.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h"
@@ -32,12 +45,8 @@  along with GCC; see the file COPYING3.  If not see
 
 #ifdef HAVE_cloog
 #include "cloog/cloog.h"
-#include "ppl_c.h"
-#include "graphite-cloog-util.h"
-#include "graphite-ppl.h"
 #include "graphite-poly.h"
 #include "graphite-clast-to-gimple.h"
-#include "graphite-dependences.h"
 
 typedef const struct clast_expr *clast_name_p;
 
@@ -45,6 +54,47 @@  typedef const struct clast_expr *clast_name_p;
 #define CLOOG_LANGUAGE_C LANGUAGE_C
 #endif
 
+
+/* Converts a GMP constant VAL to a tree and returns it.  */
+
+static tree
+gmp_cst_to_tree (tree type, mpz_t val)
+{
+  tree t = type ? type : integer_type_node;
+  mpz_t tmp;
+  double_int di;
+
+  mpz_init (tmp);
+  mpz_set (tmp, val);
+  di = mpz_get_double_int (t, tmp, true);
+  mpz_clear (tmp);
+
+  return double_int_to_tree (t, di);
+}
+
+/* Sets RES to the min of V1 and V2.  */
+
+static void
+value_min (mpz_t res, mpz_t v1, mpz_t v2)
+{
+  if (mpz_cmp (v1, v2) < 0)
+    mpz_set (res, v1);
+  else
+    mpz_set (res, v2);
+}
+
+/* Sets RES to the max of V1 and V2.  */
+
+static void
+value_max (mpz_t res, mpz_t v1, mpz_t v2)
+{
+  if (mpz_cmp (v1, v2) < 0)
+    mpz_set (res, v2);
+  else
+    mpz_set (res, v1);
+}
+
+
 /* This flag is set when an error occurred during the translation of
    CLAST to Gimple.  */
 static bool gloog_error;
@@ -695,23 +745,18 @@  type_for_clast_expr (struct clast_expr *e, ivs_params_p ip, mpz_t bound_one,
   return NULL_TREE;
 }
 
-/* Returns the type for the equation CLEQ.  */
+/* Returns true if the clast expression E is a constant with VALUE.  */
 
-static tree
-type_for_clast_eq (struct clast_equation *cleq, ivs_params_p ip)
+static bool
+clast_expr_const_value_p (struct clast_expr *e, int value)
 {
-  mpz_t bound_one, bound_two;
-  tree l, r;
-
-  mpz_init (bound_one);
-  mpz_init (bound_two);
-
-  l = type_for_clast_expr (cleq->LHS, ip, bound_one, bound_two);
-  r = type_for_clast_expr (cleq->RHS, ip, bound_one, bound_two);
-
-  mpz_clear (bound_one);
-  mpz_clear (bound_two);
-  return max_precision_type (l, r);
+  struct clast_term *t;
+  if (e->type != clast_expr_term)
+    return false;
+  t = (struct clast_term *)e;
+  if (t->var)
+    return false;
+  return 0 == mpz_cmp_si (t->val, value);
 }
 
 /* Translates a clast equation CLEQ to a tree.  */
@@ -721,19 +766,49 @@  graphite_translate_clast_equation (struct clast_equation *cleq,
 				   ivs_params_p ip)
 {
   enum tree_code comp;
-  tree type = type_for_clast_eq (cleq, ip);
-  tree lhs = clast_to_gcc_expression (type, cleq->LHS, ip);
-  tree rhs = clast_to_gcc_expression (type, cleq->RHS, ip);
+  tree type, lhs, rhs, ltype, rtype;
+  mpz_t bound_one, bound_two;
+  struct clast_expr *clhs, *crhs;
 
+  clhs = cleq->LHS;
+  crhs = cleq->RHS;
   if (cleq->sign == 0)
     comp = EQ_EXPR;
-
   else if (cleq->sign > 0)
     comp = GE_EXPR;
-
   else
     comp = LE_EXPR;
 
+  /* Special cases to reduce range of arguments to hopefully
+     don't need types with larger precision than the input.  */
+  if (crhs->type == clast_expr_red
+      && comp != EQ_EXPR)
+    {
+      struct clast_reduction *r = (struct clast_reduction *) crhs;
+      /* X >= A+1 --> X > A and
+         X <= A-1 --> X < A  */
+      if (r->n == 2
+	  && r->type == clast_red_sum
+	  && clast_expr_const_value_p (r->elts[1], comp == GE_EXPR ? 1 : -1))
+	{
+	  crhs = r->elts[0];
+	  comp = comp == GE_EXPR ? GT_EXPR : LT_EXPR;
+	}
+    }
+
+  mpz_init (bound_one);
+  mpz_init (bound_two);
+
+  ltype = type_for_clast_expr (clhs, ip, bound_one, bound_two);
+  rtype = type_for_clast_expr (crhs, ip, bound_one, bound_two);
+
+  mpz_clear (bound_one);
+  mpz_clear (bound_two);
+  type = max_precision_type (ltype, rtype);
+
+  lhs = clast_to_gcc_expression (type, clhs, ip);
+  rhs = clast_to_gcc_expression (type, crhs, ip);
+
   return fold_build2 (comp, boolean_type_node, lhs, rhs);
 }
 
@@ -776,87 +851,59 @@  graphite_create_new_guard (edge entry_edge, struct clast_guard *stmt,
 static void
 compute_bounds_for_param (scop_p scop, int param, mpz_t low, mpz_t up)
 {
-  ppl_Linear_Expression_t le;
+  isl_int v;
+  isl_aff *aff = isl_aff_zero_on_domain
+    (isl_local_space_from_space (isl_set_get_space (scop->context)));
 
-  /* Prepare the linear expression corresponding to the parameter that
-     we want to maximize/minimize.  */
-  ppl_new_Linear_Expression_with_dimension (&le, scop_nb_params (scop));
-  ppl_set_coef (le, param, 1);
+  aff = isl_aff_add_coefficient_si (aff, isl_dim_param, param, 1);
 
-  ppl_max_for_le_pointset (SCOP_CONTEXT (scop), le, up);
-  ppl_min_for_le_pointset (SCOP_CONTEXT (scop), le, low);
-  ppl_delete_Linear_Expression (le);
+  isl_int_init (v);
+  isl_set_min (scop->context, aff, &v);
+  isl_int_get_gmp (v, low);
+  isl_set_max (scop->context, aff, &v);
+  isl_int_get_gmp (v, up);
+  isl_int_clear (v);
+  isl_aff_free (aff);
 }
 
 /* Compute the lower bound LOW and upper bound UP for the induction
-   variable at LEVEL for the statement PBB, based on the transformed
-   scattering of PBB: T|I|G|Cst, with T the scattering transform, I
-   the iteration domain, and G the context parameters.  */
-
-static void
-compute_bounds_for_level (poly_bb_p pbb, int level, mpz_t low, mpz_t up)
-{
-  ppl_Pointset_Powerset_C_Polyhedron_t ps;
-  ppl_Linear_Expression_t le;
-
-  combine_context_id_scat (&ps, pbb, false);
-
-  /* Prepare the linear expression corresponding to the level that we
-     want to maximize/minimize.  */
-  {
-    ppl_dimension_type dim = pbb_nb_scattering_transform (pbb)
-      + pbb_dim_iter_domain (pbb) + pbb_nb_params (pbb);
-
-    ppl_new_Linear_Expression_with_dimension (&le, dim);
-    ppl_set_coef (le, psct_dynamic_dim (pbb, level), 1);
-  }
-
-  ppl_max_for_le_pointset (ps, le, up);
-  ppl_min_for_le_pointset (ps, le, low);
-  ppl_delete_Linear_Expression (le);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (ps);
-}
-
-/* Walks a CLAST and returns the first statement in the body of a
-   loop.
-
-   FIXME: This function should not be used to get a PBB in the STMT
-   loop in order to find out the iteration domain of the loop: the
-   counter example from Tobias is:
+   variable of loop LOOP.
 
-   | for (i = 0; i < 100; i++)
-   |   {
-   |     if (i == 0)
-   |       S1;
-   |     S2;
-   |   }
+   FIXME: This one is not entirely correct, as min/max expressions in the
+	  calculation can yield to incorrect results. To be completely
+	  correct, we need to evaluate each subexpression generated by
+          CLooG. CLooG does not yet support this, so this is as good as
+	  it can be. */
 
-   This function would return S1 whose iteration domain contains only
-   one point "i = 0", whereas the iteration domain of S2 has 100 points.
-
-   This should be implemented using some functionality existing in
-   CLooG-ISL.  */
-
-static struct clast_user_stmt *
-clast_get_body_of_loop (struct clast_stmt *stmt)
+static void
+compute_bounds_for_loop (struct clast_for *loop, mpz_t low, mpz_t up)
 {
-  if (!stmt
-      || CLAST_STMT_IS_A (stmt, stmt_user))
-    return (struct clast_user_stmt *) stmt;
+  isl_set *domain;
+  isl_aff *dimension;
+  isl_local_space *local_space;
+  isl_int isl_value;
+  enum isl_lp_result lp_result;
 
-  if (CLAST_STMT_IS_A (stmt, stmt_for))
-    return clast_get_body_of_loop (((struct clast_for *) stmt)->body);
+  domain = isl_set_copy (isl_set_from_cloog_domain (loop->domain));
+  local_space = isl_local_space_from_space (isl_set_get_space (domain));
+  dimension = isl_aff_zero_on_domain (local_space);
+  dimension = isl_aff_add_coefficient_si (dimension, isl_dim_in,
+					  isl_set_dim (domain, isl_dim_set) - 1,
+					  1);
 
-  if (CLAST_STMT_IS_A (stmt, stmt_guard))
-    return clast_get_body_of_loop (((struct clast_guard *) stmt)->then);
+  isl_int_init (isl_value);
 
-  if (CLAST_STMT_IS_A (stmt, stmt_block))
-    return clast_get_body_of_loop (((struct clast_block *) stmt)->body);
+  lp_result = isl_set_min (domain, dimension, &isl_value);
+  assert (lp_result == isl_lp_ok);
+  isl_int_get_gmp (isl_value, low);
 
-  if (CLAST_STMT_IS_A (stmt, stmt_ass))
-    return clast_get_body_of_loop (stmt->next);
+  lp_result = isl_set_max (domain, dimension, &isl_value);
+  assert (lp_result == isl_lp_ok);
+  isl_int_get_gmp (isl_value, up);
 
-  gcc_unreachable ();
+  isl_int_clear (isl_value);
+  isl_set_free (domain);
+  isl_aff_free (dimension);
 }
 
 /* Returns the type for the induction variable for the loop translated
@@ -895,10 +942,6 @@  graphite_create_new_loop (edge entry_edge, struct clast_for *stmt,
 {
   mpz_t low, up;
 
-  struct clast_user_stmt *body
-    = clast_get_body_of_loop ((struct clast_stmt *) stmt);
-  poly_bb_p pbb = (poly_bb_p) body->statement->usr;
-
   tree stride = gmp_cst_to_tree (type, stmt->stride);
   tree ivvar = create_tmp_var (type, "graphite_IV");
   tree iv, iv_after_increment;
@@ -910,7 +953,7 @@  graphite_create_new_loop (edge entry_edge, struct clast_for *stmt,
 
   mpz_init (low);
   mpz_init (up);
-  compute_bounds_for_level (pbb, level, low, up);
+  compute_bounds_for_loop (stmt, low, up);
   save_clast_name_index (ip->newivs_index, stmt->iterator,
 			 VEC_length (tree, *(ip->newivs)), level, low, up);
   mpz_clear (low);
@@ -982,7 +1025,7 @@  mark_bb_with_pbb (poly_bb_p pbb, basic_block bb, htab_t bb_pbb_mapping)
 
 /* Find BB's related poly_bb_p in hash table BB_PBB_MAPPING.  */
 
-static poly_bb_p
+poly_bb_p
 find_pbb_via_hash (htab_t bb_pbb_mapping, basic_block bb)
 {
   bb_pbb_def tmp;
@@ -997,41 +1040,32 @@  find_pbb_via_hash (htab_t bb_pbb_mapping, basic_block bb)
   return NULL;
 }
 
-/* Check data dependency in LOOP at level LEVEL.
-   BB_PBB_MAPPING is a basic_block and it's related poly_bb_p
-   mapping.  */
+/* Return the scop of the loop and initialize PBBS the set of
+   poly_bb_p that belong to the LOOP.  BB_PBB_MAPPING is a map created
+   by the CLAST code generator between a generated basic_block and its
+   related poly_bb_p.  */
 
-static bool
-dependency_in_loop_p (loop_p loop, htab_t bb_pbb_mapping, int level)
+scop_p
+get_loop_body_pbbs (loop_p loop, htab_t bb_pbb_mapping,
+		    VEC (poly_bb_p, heap) **pbbs)
 {
-  unsigned i,j;
+  unsigned i;
   basic_block *bbs = get_loop_body_in_dom_order (loop);
+  scop_p scop = NULL;
 
   for (i = 0; i < loop->num_nodes; i++)
     {
-      poly_bb_p pbb1 = find_pbb_via_hash (bb_pbb_mapping, bbs[i]);
-
-      if (pbb1 == NULL)
-       continue;
+      poly_bb_p pbb = find_pbb_via_hash (bb_pbb_mapping, bbs[i]);
 
-      for (j = 0; j < loop->num_nodes; j++)
-       {
-	 poly_bb_p pbb2 = find_pbb_via_hash (bb_pbb_mapping, bbs[j]);
-
-	 if (pbb2 == NULL)
-	   continue;
+      if (pbb == NULL)
+	continue;
 
-	 if (dependency_between_pbbs_p (pbb1, pbb2, level))
-	   {
-	     free (bbs);
-	     return true;
-	   }
-       }
+      scop = PBB_SCOP (pbb);
+      VEC_safe_push (poly_bb_p, heap, *pbbs, pbb);
     }
 
   free (bbs);
-
-  return false;
+  return scop;
 }
 
 /* Translates a clast user statement STMT to gimple.
@@ -1138,7 +1172,7 @@  translate_clast_for_loop (loop_p context_loop, struct clast_for *stmt,
   set_immediate_dominator (CDI_DOMINATORS, next_e->dest, next_e->src);
 
   if (flag_loop_parallelize_all
-      && !dependency_in_loop_p (loop, bb_pbb_mapping, level))
+      && loop_is_parallel_p (loop, bb_pbb_mapping, level))
     loop->can_be_parallel = true;
 
   return last_e;
@@ -1358,14 +1392,52 @@  init_cloog_input_file (int scop_number)
   return graphite_out_file;
 }
 
+/* Extend the scattering to NEW_DIMS scattering dimensions.  */
+
+static
+isl_map *extend_scattering(isl_map *scattering, int new_dims)
+{
+  int old_dims, i;
+  isl_space *space;
+  isl_basic_map *change_scattering;
+  isl_map *change_scattering_map;
+
+  old_dims = isl_map_dim (scattering, isl_dim_out);
+
+  space = isl_space_alloc (isl_map_get_ctx (scattering), 0, old_dims, new_dims);
+  change_scattering = isl_basic_map_universe (isl_space_copy (space));
+
+  for (i = 0; i < old_dims; i++)
+    {
+      isl_constraint *c;
+      c = isl_equality_alloc
+	(isl_local_space_from_space (isl_space_copy (space)));
+      isl_constraint_set_coefficient_si (c, isl_dim_in, i, 1);
+      isl_constraint_set_coefficient_si (c, isl_dim_out, i, -1);
+      change_scattering = isl_basic_map_add_constraint (change_scattering, c);
+    }
+
+  for (i = old_dims; i < new_dims; i++)
+    {
+      isl_constraint *c;
+      c = isl_equality_alloc
+	(isl_local_space_from_space (isl_space_copy (space)));
+      isl_constraint_set_coefficient_si (c, isl_dim_out, i, 1);
+      change_scattering = isl_basic_map_add_constraint (change_scattering, c);
+    }
+
+  change_scattering_map = isl_map_from_basic_map (change_scattering);
+  change_scattering_map = isl_map_align_params (change_scattering_map, space);
+  return isl_map_apply_range (scattering, change_scattering_map);
+}
+
 /* Build cloog union domain for SCoP.  */
 
 static CloogUnionDomain *
-build_cloog_union_domain (scop_p scop)
+build_cloog_union_domain (scop_p scop, int nb_scattering_dims)
 {
   int i;
   poly_bb_p pbb;
-
   CloogUnionDomain *union_domain =
     cloog_union_domain_alloc (scop_nb_params (scop));
 
@@ -1376,16 +1448,12 @@  build_cloog_union_domain (scop_p scop)
 
       /* Dead code elimination: when the domain of a PBB is empty,
 	 don't generate code for the PBB.  */
-      if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (PBB_DOMAIN (pbb)))
+      if (isl_set_is_empty(pbb->domain))
 	continue;
 
-      domain = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb),
-							    scop_nb_params (scop),
-							    cloog_state);
-
-      scattering = new_Cloog_Scattering_from_ppl_Polyhedron
-	(PBB_TRANSFORMED_SCATTERING (pbb), scop_nb_params (scop),
-	 pbb_nb_scattering_transform (pbb), cloog_state);
+      domain = cloog_domain_from_isl_set(isl_set_copy(pbb->domain));
+      scattering = cloog_scattering_from_isl_map(extend_scattering(isl_map_copy(pbb->transformed),
+						 nb_scattering_dims));
 
       union_domain = cloog_union_domain_add_domain (union_domain, "", domain,
 						    scattering, pbb);
@@ -1422,6 +1490,11 @@  set_cloog_options (void)
        A  */
   options->strides = 1;
 
+  /* We want the clast to provide the iteration domains of the executed loops.
+     This allows us to derive minimal/maximal values for the induction
+     variables.  */
+  options->save_domains = 1;
+
   /* Disable optimizations and make cloog generate source code closer to the
      input.  This is useful for debugging,  but later we want the optimized
      code.
@@ -1456,20 +1529,38 @@  debug_clast_stmt (struct clast_stmt *stmt)
   print_clast_stmt (stderr, stmt);
 }
 
+/* Get the maximal number of scattering dimensions in the scop SCOP.  */
+
+static
+int get_max_scattering_dimensions (scop_p scop)
+{
+  int i;
+  poly_bb_p pbb;
+  int scattering_dims = 0;
+
+  FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
+    {
+      int pbb_scatt_dims = isl_map_dim (pbb->transformed, isl_dim_out);
+      if (pbb_scatt_dims > scattering_dims)
+	scattering_dims = pbb_scatt_dims;
+    }
+
+  return scattering_dims;
+}
+
 static CloogInput *
 generate_cloog_input (scop_p scop, htab_t params_index)
 {
   CloogUnionDomain *union_domain;
   CloogInput *cloog_input;
   CloogDomain *context;
+  int nb_scattering_dims = get_max_scattering_dimensions (scop);
 
-  int nb_scattering_dims = unify_scattering_dimensions (scop);
-  union_domain = build_cloog_union_domain (scop);
+  union_domain = build_cloog_union_domain (scop, nb_scattering_dims);
   union_domain = add_names_to_union_domain (scop, union_domain,
 					    nb_scattering_dims,
 					    params_index);
-  context = new_Cloog_Domain_from_ppl_Pointset_Powerset
-    (SCOP_CONTEXT (scop), scop_nb_params (scop), cloog_state);
+  context = cloog_domain_from_isl_set (isl_set_copy (scop->context));
 
   cloog_input = cloog_input_alloc (context, union_domain);
 
diff --git a/gcc/graphite-clast-to-gimple.h b/gcc/graphite-clast-to-gimple.h
index c82bb6a..8fdee90 100644
--- a/gcc/graphite-clast-to-gimple.h
+++ b/gcc/graphite-clast-to-gimple.h
@@ -21,8 +21,6 @@  along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_GRAPHITE_CLAST_TO_GIMPLE_H
 #define GCC_GRAPHITE_CLAST_TO_GIMPLE_H
 
-#include "graphite-cloog-util.h"
-
 extern CloogState *cloog_state;
 
 /* Data structure for CLooG program representation.  */
diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
deleted file mode 100644
index 83cfb54..0000000
--- a/gcc/graphite-cloog-util.c
+++ /dev/null
@@ -1,409 +0,0 @@ 
-/* Gimple Represented as Polyhedra.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
-   Contributed by Sebastian Pop <sebastian.pop@inria.fr>
-   and Tobias Grosser <grosser@fim.uni-passau.de>.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-
-#ifdef HAVE_cloog
-
-#include "ppl_c.h"
-#include "cloog/cloog.h"
-#include "graphite-cloog-util.h"
-
-/* Counts the number of constraints in PCS.  */
-
-static int
-ppl_Constrain_System_number_of_constraints (ppl_const_Constraint_System_t pcs)
-{
-  ppl_Constraint_System_const_iterator_t cit, end;
-  int num = 0;
-
-  ppl_new_Constraint_System_const_iterator (&cit);
-  ppl_new_Constraint_System_const_iterator (&end);
-
-  for (ppl_Constraint_System_begin (pcs, cit),
-       ppl_Constraint_System_end (pcs, end);
-       !ppl_Constraint_System_const_iterator_equal_test (cit, end);
-       ppl_Constraint_System_const_iterator_increment (cit))
-    num++;
-
-  ppl_delete_Constraint_System_const_iterator (cit);
-  ppl_delete_Constraint_System_const_iterator (end);
-  return num;
-}
-
-static void
-oppose_constraint (CloogMatrix *m, int row)
-{
-  int k;
-
-  /* Do not oppose the first column: it is the eq/ineq one.  */
-  /* Cast needed to remove warning that is generated as CLooG isl
-     is using an unsigned int for NbColumns and CLooG PPL is
-     using a signed int for NBColumns.  */
-  for (k = 1; k < (int)m->NbColumns; k++)
-    mpz_neg (m->p[row][k], m->p[row][k]);
-}
-
-/* Inserts constraint CSTR at row ROW of matrix M.  */
-
-static void
-insert_constraint_into_matrix (CloogMatrix *m, int row,
-			       ppl_const_Constraint_t cstr)
-{
-  ppl_Coefficient_t c;
-  ppl_dimension_type i, dim, nb_cols = m->NbColumns;
-
-  ppl_Constraint_space_dimension (cstr, &dim);
-  ppl_new_Coefficient (&c);
-
-  for (i = 0; i < dim; i++)
-    {
-      ppl_Constraint_coefficient (cstr, i, c);
-      ppl_Coefficient_to_mpz_t (c, m->p[row][i + 1]);
-    }
-
-  for (i = dim; i < nb_cols - 1; i++)
-    mpz_set_si (m->p[row][i + 1], 0);
-
-  ppl_Constraint_inhomogeneous_term  (cstr, c);
-  ppl_Coefficient_to_mpz_t (c, m->p[row][nb_cols - 1]);
-  mpz_set_si (m->p[row][0], 1);
-
-  switch (ppl_Constraint_type (cstr))
-    {
-    case PPL_CONSTRAINT_TYPE_LESS_THAN:
-      oppose_constraint (m, row);
-    case PPL_CONSTRAINT_TYPE_GREATER_THAN:
-      mpz_sub_ui (m->p[row][nb_cols - 1],
-		     m->p[row][nb_cols - 1], 1);
-      break;
-
-    case PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL:
-      oppose_constraint (m, row);
-    case PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL:
-      break;
-
-    case PPL_CONSTRAINT_TYPE_EQUAL:
-      mpz_set_si (m->p[row][0], 0);
-      break;
-
-    default:
-      /* Not yet implemented.  */
-      gcc_unreachable();
-    }
-
-  ppl_delete_Coefficient (c);
-}
-
-/* Creates a CloogMatrix from constraint system PCS.  */
-
-static CloogMatrix *
-new_Cloog_Matrix_from_ppl_Constraint_System (ppl_const_Constraint_System_t pcs)
-{
-  CloogMatrix *matrix;
-  ppl_Constraint_System_const_iterator_t cit, end;
-  ppl_dimension_type dim;
-  int rows;
-  int row = 0;
-
-  rows = ppl_Constrain_System_number_of_constraints (pcs);
-  ppl_Constraint_System_space_dimension (pcs, &dim);
-  matrix = cloog_matrix_alloc (rows, dim + 2);
-  ppl_new_Constraint_System_const_iterator (&cit);
-  ppl_new_Constraint_System_const_iterator (&end);
-
-  for (ppl_Constraint_System_begin (pcs, cit),
-       ppl_Constraint_System_end (pcs, end);
-       !ppl_Constraint_System_const_iterator_equal_test (cit, end);
-       ppl_Constraint_System_const_iterator_increment (cit))
-    {
-      ppl_const_Constraint_t c;
-      ppl_Constraint_System_const_iterator_dereference (cit, &c);
-      insert_constraint_into_matrix (matrix, row, c);
-      row++;
-    }
-
-  ppl_delete_Constraint_System_const_iterator (cit);
-  ppl_delete_Constraint_System_const_iterator (end);
-
-  return matrix;
-}
-
-/* Creates a CloogMatrix from polyhedron PH.  */
-
-CloogMatrix *
-new_Cloog_Matrix_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph)
-{
-  ppl_const_Constraint_System_t pcs;
-  CloogMatrix *res;
-
-  ppl_Polyhedron_get_constraints (ph, &pcs);
-  res = new_Cloog_Matrix_from_ppl_Constraint_System (pcs);
-
-  return res;
-}
-
-/* Translates row ROW of the CloogMatrix MATRIX to a PPL Constraint.  */
-
-static ppl_Constraint_t
-cloog_matrix_to_ppl_constraint (CloogMatrix *matrix, int row)
-{
-  int j;
-  ppl_Constraint_t cstr;
-  ppl_Coefficient_t coef;
-  ppl_Linear_Expression_t expr;
-  ppl_dimension_type dim = matrix->NbColumns - 2;
-
-  ppl_new_Coefficient (&coef);
-  ppl_new_Linear_Expression_with_dimension (&expr, dim);
-
-  /* Cast needed to remove warning that is generated as CLooG isl
-     is using an unsigned int for NbColumns and CLooG PPL is
-     using a signed int for NBColumns.  */
-  for (j = 1; j < (int)matrix->NbColumns - 1; j++)
-    {
-      ppl_assign_Coefficient_from_mpz_t (coef, matrix->p[row][j]);
-      ppl_Linear_Expression_add_to_coefficient (expr, j - 1, coef);
-    }
-
-  ppl_assign_Coefficient_from_mpz_t (coef,
-				     matrix->p[row][matrix->NbColumns - 1]);
-  ppl_Linear_Expression_add_to_inhomogeneous (expr, coef);
-  ppl_delete_Coefficient (coef);
-
-  if (mpz_sgn (matrix->p[row][0]) == 0)
-    ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
-  else
-    ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-
-  ppl_delete_Linear_Expression (expr);
-  return cstr;
-}
-
-/* Creates a PPL constraint system from MATRIX.  */
-
-static void
-new_Constraint_System_from_Cloog_Matrix (ppl_Constraint_System_t *pcs,
-					 CloogMatrix *matrix)
-{
-  int i;
-
-  ppl_new_Constraint_System (pcs);
-
-  /* Cast needed to remove warning that is generated as CLooG isl
-     is using an unsigned int for NbColumns and CLooG PPL is
-     using a signed int for NBColumns.  */
-  for (i = 0; i < (int)matrix->NbRows; i++)
-    {
-      ppl_Constraint_t c = cloog_matrix_to_ppl_constraint (matrix, i);
-      ppl_Constraint_System_insert_Constraint (*pcs, c);
-      ppl_delete_Constraint (c);
-    }
-}
-
-/* Creates a PPL Polyhedron from MATRIX.  */
-
-void
-new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *ph,
-				      CloogMatrix *matrix)
-{
-  ppl_Constraint_System_t cs;
-  new_Constraint_System_from_Cloog_Matrix (&cs, matrix);
-  ppl_new_C_Polyhedron_recycle_Constraint_System (ph, cs);
-}
-
-/* Creates a CloogDomain from polyhedron PH.  */
-
-CloogDomain *
-new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph, int nb_params,
-                                      CloogState *state)
-{
-  CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
-  CloogDomain *res = cloog_domain_from_cloog_matrix (state, mat, nb_params);
-  cloog_matrix_free (mat);
-  return res;
-}
-
-/* Create a CloogScattering from polyhedron PH.  */
-
-CloogScattering *
-new_Cloog_Scattering_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph,
-                                          int nb_params,
-                                          int nb_scatt,
-                                          CloogState *state)
-{
-  CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
-  CloogScattering *res = cloog_scattering_from_cloog_matrix (state, mat,
-                                                             nb_scatt,
-                                                             nb_params);
-
-  cloog_matrix_free (mat);
-  return res;
-}
-
-/* Creates a CloogDomain from a pointset powerset PS.  */
-
-CloogDomain *
-new_Cloog_Domain_from_ppl_Pointset_Powerset
-  (ppl_Pointset_Powerset_C_Polyhedron_t ps, int nb_params,
-   CloogState *state)
-{
-  CloogDomain *res = NULL;
-  ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end;
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&it);
-  ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&end);
-
-  for (ppl_Pointset_Powerset_C_Polyhedron_iterator_begin (ps, it),
-       ppl_Pointset_Powerset_C_Polyhedron_iterator_end (ps, end);
-       !ppl_Pointset_Powerset_C_Polyhedron_iterator_equal_test (it, end);
-       ppl_Pointset_Powerset_C_Polyhedron_iterator_increment (it))
-    {
-      ppl_const_Polyhedron_t ph;
-      CloogDomain *tmp;
-
-      ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph);
-      tmp = new_Cloog_Domain_from_ppl_Polyhedron (ph, nb_params, state);
-
-      if (res == NULL)
-	res = tmp;
-      else
-	res = cloog_domain_union (res, tmp);
-    }
-
-  ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (it);
-  ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (end);
-
-  gcc_assert (res != NULL);
-
-  return res;
-}
-
-/* Print to FILE the matrix MAT in OpenScop format.  OUTPUT is the number
-   of output dimensions, INPUT is the number of input dimensions, LOCALS
-   is the number of existentially quantified variables and PARAMS is the
-   number of parameters.  */
-
-static void
-openscop_print_cloog_matrix (FILE *file, CloogMatrix *mat,
-			     int output, int input, int locals,
-			     int params)
-{
-  unsigned i, j;
-
-  fprintf (file, "%d %d %d %d %d %d \n", mat->NbRows,
-	   mat->NbColumns, output, input, locals, params);
-
-  for (i = 0; i < mat->NbRows; i++)
-    {
-      for (j = 0; j < mat->NbColumns; j++)
-        if (j == 0)
-	  fprintf (file, "%ld ", mpz_get_si (mat->p[i][j]));
-        else
-	  fprintf (file, "%6ld ", mpz_get_si (mat->p[i][j]));
-
-      fprintf (file, "\n");
-    }
-}
-
-/* Print to FILE the polyhedron PH in OpenScop format.  OUTPUT is the number
-   of output dimensions, INPUT is the number of input dimensions, LOCALS is
-   the number of existentially quantified variables and PARAMS is the number
-   of parameters.  */
-
-void
-openscop_print_polyhedron_matrix (FILE *file, ppl_const_Polyhedron_t ph,
-				  int output, int input, int locals,
-				  int params)
-{
-  CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
-  openscop_print_cloog_matrix (file, mat, output, input, locals, params);
-  cloog_matrix_free (mat);
-}
-
-/* Read from FILE a matrix in OpenScop format.  OUTPUT is the number of
-   output dimensions, INPUT is the number of input dimensions, LOCALS
-   is the number of existentially quantified variables and PARAMS is the
-   number of parameters.  */
-
-static CloogMatrix *
-openscop_read_cloog_matrix (FILE *file, int *output, int *input, int *locals,
-			    int *params)
-{
-  int nb_rows, nb_cols, i, j;
-  CloogMatrix *mat;
-  int *openscop_matrix_header, *matrix_line;
-
-  openscop_matrix_header = openscop_read_N_int (file, 6);
-
-  nb_rows = openscop_matrix_header[0];
-  nb_cols = openscop_matrix_header[1];
-  *output = openscop_matrix_header[2];
-  *input = openscop_matrix_header[3];
-  *locals = openscop_matrix_header[4];
-  *params = openscop_matrix_header[5];
-
-  free (openscop_matrix_header);
-
-  if (nb_rows == 0 || nb_cols == 0)
-    return NULL;
-
-  mat = cloog_matrix_alloc (nb_rows, nb_cols);
-  mat->NbRows = nb_rows;
-  mat->NbColumns = nb_cols;
-
-  for (i = 0; i < nb_rows; i++)
-    {
-      matrix_line = openscop_read_N_int (file, nb_cols);
-
-      for (j = 0; j < nb_cols; j++)
-        mpz_set_si (mat->p[i][j], matrix_line[j]);
-    }
-
-  return mat;
-}
-
-/* Read from FILE the polyhedron PH in OpenScop format.  OUTPUT is the number
-   of output dimensions, INPUT is the number of input dimensions, LOCALS is
-   the number of existentially quantified variables and PARAMS is the number
-   of parameters.  */
-
-void
-openscop_read_polyhedron_matrix (FILE *file, ppl_Polyhedron_t *ph,
-				 int *output, int *input, int *locals,
-				 int *params)
-{
-  CloogMatrix *mat;
-
-  mat = openscop_read_cloog_matrix (file, output, input, locals, params);
-
-  if (!mat)
-    *ph = NULL;
-  else
-    {
-      new_C_Polyhedron_from_Cloog_Matrix (ph, mat);
-      cloog_matrix_free (mat);
-    }
-}
-
-#endif
diff --git a/gcc/graphite-cloog-util.h b/gcc/graphite-cloog-util.h
deleted file mode 100644
index da26ee9..0000000
--- a/gcc/graphite-cloog-util.h
+++ /dev/null
@@ -1,41 +0,0 @@ 
-/* Gimple Represented as Polyhedra.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
-   Contributed by Sebastian Pop <sebastian.pop@inria.fr>
-   and Tobias Grosser <grosser@fim.uni-passau.de>.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-#ifndef GRAPHITE_CLOOG_UTIL_H
-#define GRAPHITE_CLOOG_UTIL_H
-
-#include "cloog/cloog.h"
-
-CloogMatrix *new_Cloog_Matrix_from_ppl_Polyhedron (ppl_const_Polyhedron_t);
-CloogDomain *new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t,
-						   int, CloogState *);
-CloogScattering *new_Cloog_Scattering_from_ppl_Polyhedron
-  (ppl_const_Polyhedron_t, int, int, CloogState *);
-CloogDomain * new_Cloog_Domain_from_ppl_Pointset_Powerset
-  (ppl_Pointset_Powerset_C_Polyhedron_t, int, CloogState *);
-void new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *, CloogMatrix *);
-void openscop_print_polyhedron_matrix (FILE *, ppl_const_Polyhedron_t, int,
-				       int, int, int);
-void openscop_read_polyhedron_matrix (FILE *, ppl_Polyhedron_t *, int *, int *,
-	       			     int *, int *);
-
-extern int *openscop_read_N_int (FILE *, int);
-
-#endif /* GRAPHITE_CLOOG_UTIL_H */
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index fb49f16..0c10e60 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -1,5 +1,5 @@ 
 /* Data dependence analysis for Graphite.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Konrad Trifunovic <konrad.trifunovic@inria.fr>.
 
@@ -20,6 +20,17 @@  along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <isl/flow.h>
+#include <isl/constraint.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
@@ -31,904 +42,556 @@  along with GCC; see the file COPYING3.  If not see
 #include "sese.h"
 
 #ifdef HAVE_cloog
-#include "ppl_c.h"
-#include "graphite-ppl.h"
 #include "graphite-poly.h"
-#include "graphite-dependences.h"
-#include "graphite-cloog-util.h"
 
-/* Comparison function for poly_ddr hash table.  */
+/* Add the constraints from the set S to the domain of MAP.  */
 
-int
-eq_poly_ddr_p (const void *pddr1, const void *pddr2)
+static isl_map *
+constrain_domain (isl_map *map, isl_set *s)
 {
-  const struct poly_ddr *p1 = (const struct poly_ddr *) pddr1;
-  const struct poly_ddr *p2 = (const struct poly_ddr *) pddr2;
+  isl_space *d = isl_map_get_space (map);
+  isl_id *id = isl_space_get_tuple_id (d, isl_dim_in);
 
-  return (PDDR_SOURCE (p1) == PDDR_SOURCE (p2)
-          && PDDR_SINK (p1) == PDDR_SINK (p2));
+  s = isl_set_set_tuple_id (s, id);
+  isl_space_free (d);
+  return isl_map_intersect_domain (map, s);
 }
 
-/* Hash function for poly_ddr hashtable.  */
+/* Constrain pdr->accesses with pdr->extent and pbb->domain.  */
 
-hashval_t
-hash_poly_ddr_p (const void *pddr)
+static isl_map *
+add_pdr_constraints (poly_dr_p pdr, poly_bb_p pbb)
 {
-  const struct poly_ddr *p = (const struct poly_ddr *) pddr;
-
-  return (hashval_t) ((long) PDDR_SOURCE (p) + (long) PDDR_SINK (p));
+  isl_map *x = isl_map_intersect_range (isl_map_copy (pdr->accesses),
+					isl_set_copy (pdr->extent));
+  x = constrain_domain (x, isl_set_copy (pbb->domain));
+  return x;
 }
 
-/* Returns true when PDDR has no dependence.  */
+/* Returns all the memory reads in SCOP.  */
 
-static bool
-pddr_is_empty (poly_ddr_p pddr)
+static isl_union_map *
+scop_get_reads (scop_p scop, VEC (poly_bb_p, heap) *pbbs)
 {
-  if (!pddr)
-    return true;
-
-  gcc_assert (PDDR_KIND (pddr) != unknown_dependence);
-
-  return PDDR_KIND (pddr) == no_dependence ? true : false;
-}
-
-/* Prints to FILE the layout of the dependence polyhedron of PDDR:
-
-   T1|I1|T2|I2|S1|S2|G
-
-   with
-   | T1 and T2 the scattering dimensions for PDDR_SOURCE and PDDR_SINK
-   | I1 and I2 the iteration domains
-   | S1 and S2 the subscripts
-   | G the global parameters.  */
-
-static void
-print_dependence_polyhedron_layout (FILE *file, poly_ddr_p pddr)
-{
-  poly_dr_p pdr1 = PDDR_SOURCE (pddr);
-  poly_dr_p pdr2 = PDDR_SINK (pddr);
-  poly_bb_p pbb1 = PDR_PBB (pdr1);
-  poly_bb_p pbb2 = PDR_PBB (pdr2);
-
-  graphite_dim_t i;
-  graphite_dim_t tdim1 = PDDR_ORIGINAL_SCATTERING_P (pddr) ?
-    pbb_nb_scattering_orig (pbb1) : pbb_nb_scattering_transform (pbb1);
-  graphite_dim_t tdim2 = PDDR_ORIGINAL_SCATTERING_P (pddr) ?
-    pbb_nb_scattering_orig (pbb2) : pbb_nb_scattering_transform (pbb2);
-  graphite_dim_t idim1 = pbb_dim_iter_domain (pbb1);
-  graphite_dim_t idim2 = pbb_dim_iter_domain (pbb2);
-  graphite_dim_t sdim1 = PDR_NB_SUBSCRIPTS (pdr1) + 1;
-  graphite_dim_t sdim2 = PDR_NB_SUBSCRIPTS (pdr2) + 1;
-  graphite_dim_t gdim = scop_nb_params (PBB_SCOP (pbb1));
-
-  fprintf (file, "#  eq");
-
-  for (i = 0; i < tdim1; i++)
-    fprintf (file, "   t1_%d", (int) i);
-  for (i = 0; i < idim1; i++)
-    fprintf (file, "   i1_%d", (int) i);
-  for (i = 0; i < tdim2; i++)
-    fprintf (file, "   t2_%d", (int) i);
-  for (i = 0; i < idim2; i++)
-    fprintf (file, "   i2_%d", (int) i);
-  for (i = 0; i < sdim1; i++)
-    fprintf (file, "   s1_%d", (int) i);
-  for (i = 0; i < sdim2; i++)
-    fprintf (file, "   s2_%d", (int) i);
-  for (i = 0; i < gdim; i++)
-    fprintf (file, "    g_%d", (int) i);
-
-  fprintf (file, "    cst\n");
-}
-
-/* Prints to FILE the poly_ddr_p PDDR.  */
-
-void
-print_pddr (FILE *file, poly_ddr_p pddr)
-{
-  fprintf (file, "pddr (kind: ");
-
-  if (PDDR_KIND (pddr) == unknown_dependence)
-    fprintf (file, "unknown_dependence");
-  else if (PDDR_KIND (pddr) == no_dependence)
-    fprintf (file, "no_dependence");
-  else if (PDDR_KIND (pddr) == has_dependence)
-    fprintf (file, "has_dependence");
-
-  fprintf (file, "\n  source ");
-  print_pdr (file, PDDR_SOURCE (pddr), 2);
-
-  fprintf (file, "\n  sink ");
-  print_pdr (file, PDDR_SINK (pddr), 2);
+  int i, j;
+  poly_bb_p pbb;
+  poly_dr_p pdr;
+  isl_space *space = isl_set_get_space (scop->context);
+  isl_union_map *res = isl_union_map_empty (space);
 
-  if (PDDR_KIND (pddr) == has_dependence)
+  FOR_EACH_VEC_ELT (poly_bb_p, pbbs, i, pbb)
     {
-      fprintf (file, "\n  dependence polyhedron (\n");
-      print_dependence_polyhedron_layout (file, pddr);
-      ppl_print_powerset_matrix (file, PDDR_DDP (pddr));
-      ppl_io_fprint_Pointset_Powerset_C_Polyhedron (file, PDDR_DDP (pddr));
-      fprintf (file, ")\n");
+      FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), j, pdr)
+	if (pdr_read_p (pdr))
+	  res = isl_union_map_add_map (res, add_pdr_constraints (pdr, pbb));
     }
 
-  fprintf (file, ")\n");
-}
-
-/* Prints to STDERR the poly_ddr_p PDDR.  */
-
-DEBUG_FUNCTION void
-debug_pddr (poly_ddr_p pddr)
-{
-  print_pddr (stderr, pddr);
-}
-
-
-/* Remove all the dimensions except alias information at dimension
-   ALIAS_DIM.  */
-
-static void
-build_alias_set_powerset (ppl_Pointset_Powerset_C_Polyhedron_t alias_powerset,
-			  ppl_dimension_type alias_dim)
-{
-  ppl_dimension_type *ds;
-  ppl_dimension_type access_dim;
-  unsigned i, pos;
-
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (alias_powerset,
-						      &access_dim);
-  ds = XNEWVEC (ppl_dimension_type, access_dim - 1);
-  gcc_assert (alias_dim < access_dim);
-
-  for (pos = 0, i = 0; i < access_dim; i++)
-    if (i != alias_dim)
-      ds[pos++] = i;
-
-  ppl_Pointset_Powerset_C_Polyhedron_remove_space_dimensions (alias_powerset,
-							      ds,
-							      access_dim - 1);
-  free (ds);
-}
-
-/* Return true when PDR1 and PDR2 may alias.  */
-
-static bool
-poly_drs_may_alias_p (poly_dr_p pdr1, poly_dr_p pdr2)
-{
-  ppl_Pointset_Powerset_C_Polyhedron_t alias_powerset1, alias_powerset2;
-  ppl_Pointset_Powerset_C_Polyhedron_t accesses1 = PDR_ACCESSES (pdr1);
-  ppl_Pointset_Powerset_C_Polyhedron_t accesses2 = PDR_ACCESSES (pdr2);
-  ppl_dimension_type alias_dim1 = pdr_alias_set_dim (pdr1);
-  ppl_dimension_type alias_dim2 = pdr_alias_set_dim (pdr2);
-  int empty_p;
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-    (&alias_powerset1, accesses1);
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-    (&alias_powerset2, accesses2);
-
-  build_alias_set_powerset (alias_powerset1, alias_dim1);
-  build_alias_set_powerset (alias_powerset2, alias_dim2);
-
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign
-    (alias_powerset1, alias_powerset2);
-
-  empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (alias_powerset1);
-
-  ppl_delete_Pointset_Powerset_C_Polyhedron (alias_powerset1);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (alias_powerset2);
-
-  return !empty_p;
+  return res;
 }
 
-/* Swap [cut0, ..., cut1] to the end of DR: "a CUT0 b CUT1 c" is
-   transformed into "a CUT0 c CUT1' b"
-
-   Add NB0 zeros before "a":  "00...0 a CUT0 c CUT1' b"
-   Add NB1 zeros between "a" and "c":  "00...0 a 00...0 c CUT1' b"
-   Add DIM - NB0 - NB1 - PDIM zeros between "c" and "b":
-   "00...0 a 00...0 c 00...0 b".  */
+/* Returns all the memory must writes in SCOP.  */
 
-static ppl_Pointset_Powerset_C_Polyhedron_t
-map_dr_into_dep_poly (graphite_dim_t dim,
-		      ppl_Pointset_Powerset_C_Polyhedron_t dr,
-		      graphite_dim_t cut0, graphite_dim_t cut1,
-		      graphite_dim_t nb0, graphite_dim_t nb1)
+static isl_union_map *
+scop_get_must_writes (scop_p scop, VEC (poly_bb_p, heap) *pbbs)
 {
-  ppl_dimension_type pdim;
-  ppl_dimension_type *map;
-  ppl_Pointset_Powerset_C_Polyhedron_t res;
-  ppl_dimension_type i;
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-    (&res, dr);
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (res, &pdim);
-
-  map = (ppl_dimension_type *) XNEWVEC (ppl_dimension_type, pdim);
-
-  /* First mapping: move 'g' vector to right position.  */
-  for (i = 0; i < cut0; i++)
-    map[i] = i;
-
-  for (i = cut0; i < cut1; i++)
-    map[i] = pdim - cut1 + i;
-
-  for (i = cut1; i < pdim; i++)
-    map[i] = cut0 + i - cut1;
-
-  ppl_Pointset_Powerset_C_Polyhedron_map_space_dimensions (res, map, pdim);
-  free (map);
-
-  /* After swapping 's' and 'g' vectors, we have to update a new cut.  */
-  cut1 = pdim - cut1 + cut0;
+  int i, j;
+  poly_bb_p pbb;
+  poly_dr_p pdr;
+  isl_space *space = isl_set_get_space (scop->context);
+  isl_union_map *res = isl_union_map_empty (space);
 
-  ppl_insert_dimensions_pointset (res, 0, nb0);
-  ppl_insert_dimensions_pointset (res, nb0 + cut0, nb1);
-  ppl_insert_dimensions_pointset (res, nb0 + nb1 + cut1,
-				  dim - nb0 - nb1 - pdim);
+  FOR_EACH_VEC_ELT (poly_bb_p, pbbs, i, pbb)
+    {
+      FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), j, pdr)
+	if (pdr_write_p (pdr))
+	  res = isl_union_map_add_map (res, add_pdr_constraints (pdr, pbb));
+    }
 
   return res;
 }
 
-/* Builds subscript equality constraints.  */
+/* Returns all the memory may writes in SCOP.  */
 
-static ppl_Pointset_Powerset_C_Polyhedron_t
-dr_equality_constraints (graphite_dim_t dim,
-		         graphite_dim_t pos, graphite_dim_t nb_subscripts)
+static isl_union_map *
+scop_get_may_writes (scop_p scop, VEC (poly_bb_p, heap) *pbbs)
 {
-  ppl_Polyhedron_t eqs;
-  ppl_Pointset_Powerset_C_Polyhedron_t res;
-  graphite_dim_t i;
-
-  ppl_new_C_Polyhedron_from_space_dimension (&eqs, dim, 0);
+  int i, j;
+  poly_bb_p pbb;
+  poly_dr_p pdr;
+  isl_space *space = isl_set_get_space (scop->context);
+  isl_union_map *res = isl_union_map_empty (space);
 
-  for (i = 0; i < nb_subscripts; i++)
+  FOR_EACH_VEC_ELT (poly_bb_p, pbbs, i, pbb)
     {
-      ppl_Constraint_t cstr
-	= ppl_build_relation (dim, pos + i, pos + i + nb_subscripts,
-			      0, PPL_CONSTRAINT_TYPE_EQUAL);
-      ppl_Polyhedron_add_constraint (eqs, cstr);
-      ppl_delete_Constraint (cstr);
+      FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), j, pdr)
+	if (pdr_may_write_p (pdr))
+	  res = isl_union_map_add_map (res, add_pdr_constraints (pdr, pbb));
     }
 
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&res, eqs);
-  ppl_delete_Polyhedron (eqs);
   return res;
 }
 
-/* Builds scheduling inequality constraints: when DIRECTION is
-   1 builds a GE constraint,
-   0 builds an EQ constraint,
-   -1 builds a LE constraint.
-   DIM is the dimension of the scheduling space.
-   POS and POS + OFFSET are the dimensions that are related.  */
+/* Returns all the original schedules in SCOP.  */
 
-static ppl_Pointset_Powerset_C_Polyhedron_t
-build_pairwise_scheduling (graphite_dim_t dim,
-			   graphite_dim_t pos,
-			   graphite_dim_t offset,
-			   int direction)
+static isl_union_map *
+scop_get_original_schedule (scop_p scop, VEC (poly_bb_p, heap) *pbbs)
 {
-  ppl_Pointset_Powerset_C_Polyhedron_t res;
-  ppl_Polyhedron_t equalities;
-  ppl_Constraint_t cstr;
-  graphite_dim_t a = pos;
-  graphite_dim_t b = pos + offset;
-
-  ppl_new_C_Polyhedron_from_space_dimension (&equalities, dim, 0);
+  int i;
+  poly_bb_p pbb;
+  isl_space *space = isl_set_get_space (scop->context);
+  isl_union_map *res = isl_union_map_empty (space);
 
-  switch (direction)
+  FOR_EACH_VEC_ELT (poly_bb_p, pbbs, i, pbb)
     {
-    case 1:
-      /* Builds "a + 1 <= b.  */
-      cstr = ppl_build_relation (dim, a, b, 1,
-				 PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL);
-      break;
-
-    case 0:
-      /* Builds "a = b.  */
-      cstr = ppl_build_relation (dim, a, b, 0,
-				 PPL_CONSTRAINT_TYPE_EQUAL);
-      break;
-
-    case -1:
-      /* Builds "a >= b + 1.  */
-      cstr = ppl_build_relation (dim, a, b, -1,
-				 PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-      break;
-
-    default:
-      gcc_unreachable ();
+      res = isl_union_map_add_map
+	(res, constrain_domain (isl_map_copy (pbb->schedule),
+				isl_set_copy (pbb->domain)));
     }
 
-  ppl_Polyhedron_add_constraint (equalities, cstr);
-  ppl_delete_Constraint (cstr);
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&res, equalities);
-  ppl_delete_Polyhedron (equalities);
   return res;
 }
 
-/* Add to a non empty polyhedron BAG the precedence constraints for
-   the lexicographical comparison of time vectors in BAG following the
-   lexicographical order.  DIM is the dimension of the polyhedron BAG.
-   TDIM is the number of loops common to the two statements that are
-   compared lexicographically, i.e. the number of loops containing
-   both statements.  OFFSET is the number of dimensions needed to
-   represent the first statement, i.e. dimT1 + dimI1 in the layout of
-   the BAG polyhedron: T1|I1|T2|I2|S1|S2|G.  When DIRECTION is set to
-   1, compute the direct dependence from PDR1 to PDR2, and when
-   DIRECTION is -1, compute the reversed dependence relation, from
-   PDR2 to PDR1.  */
+/* Returns all the transformed schedules in SCOP.  */
 
-static ppl_Pointset_Powerset_C_Polyhedron_t
-build_lexicographical_constraint (ppl_Pointset_Powerset_C_Polyhedron_t bag,
-				  graphite_dim_t dim,
-				  graphite_dim_t tdim,
-				  graphite_dim_t offset,
-				  int direction)
+static isl_union_map *
+scop_get_transformed_schedule (scop_p scop, VEC (poly_bb_p, heap) *pbbs)
 {
-  graphite_dim_t i;
-  ppl_Pointset_Powerset_C_Polyhedron_t res, lex;
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (&res, dim, 1);
-
-  lex = build_pairwise_scheduling (dim, 0, offset, direction);
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (lex, bag);
-
-  if (!ppl_powerset_is_empty (lex))
-    ppl_Pointset_Powerset_C_Polyhedron_upper_bound_assign (res, lex);
-
-  ppl_delete_Pointset_Powerset_C_Polyhedron (lex);
+  int i;
+  poly_bb_p pbb;
+  isl_space *space = isl_set_get_space (scop->context);
+  isl_union_map *res = isl_union_map_empty (space);
 
-  for (i = 0; i < tdim - 1; i++)
+  FOR_EACH_VEC_ELT (poly_bb_p, pbbs, i, pbb)
     {
-      ppl_Pointset_Powerset_C_Polyhedron_t sceq;
-
-      sceq = build_pairwise_scheduling (dim, i, offset, 0);
-      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (bag, sceq);
-      ppl_delete_Pointset_Powerset_C_Polyhedron (sceq);
-
-      if (ppl_powerset_is_empty (bag))
-	break;
-
-      lex = build_pairwise_scheduling (dim, i + 1, offset, direction);
-      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (lex, bag);
-
-      if (!ppl_powerset_is_empty (lex))
-	ppl_Pointset_Powerset_C_Polyhedron_upper_bound_assign (res, lex);
-
-      ppl_delete_Pointset_Powerset_C_Polyhedron (lex);
+      res = isl_union_map_add_map
+	(res, constrain_domain (isl_map_copy (pbb->transformed),
+				isl_set_copy (pbb->domain)));
     }
 
   return res;
 }
 
-/* Build the dependence polyhedron for data references PDR1 and PDR2.
-   The layout of the dependence polyhedron is:
-
-   T1|I1|T2|I2|S1|S2|G
+/* Helper function used on each MAP of a isl_union_map.  Computes the
+   maximal output dimension.  */
 
-   with
-   | T1 and T2 the scattering dimensions for PDR1 and PDR2
-   | I1 and I2 the iteration domains
-   | S1 and S2 the subscripts
-   | G the global parameters.
-
-   When DIRECTION is set to 1, compute the direct dependence from PDR1
-   to PDR2, and when DIRECTION is -1, compute the reversed dependence
-   relation, from PDR2 to PDR1.  */
-
-static ppl_Pointset_Powerset_C_Polyhedron_t
-dependence_polyhedron (poly_dr_p pdr1, poly_dr_p pdr2,
-		       int direction, bool original_scattering_p)
+static int
+max_number_of_out_dimensions (__isl_take isl_map *map, void *user)
 {
-  poly_bb_p pbb1 = PDR_PBB (pdr1);
-  poly_bb_p pbb2 = PDR_PBB (pdr2);
-  scop_p scop = PBB_SCOP (pbb1);
-  graphite_dim_t tdim1 = original_scattering_p ?
-    pbb_nb_scattering_orig (pbb1) : pbb_nb_scattering_transform (pbb1);
-  graphite_dim_t tdim2 = original_scattering_p ?
-    pbb_nb_scattering_orig (pbb2) : pbb_nb_scattering_transform (pbb2);
-  graphite_dim_t ddim1 = pbb_dim_iter_domain (pbb1);
-  graphite_dim_t ddim2 = pbb_dim_iter_domain (pbb2);
-  graphite_dim_t sdim1 = PDR_NB_SUBSCRIPTS (pdr1) + 1;
-  graphite_dim_t sdim2 = PDR_NB_SUBSCRIPTS (pdr2) + 1;
-  graphite_dim_t gdim = scop_nb_params (scop);
-  graphite_dim_t dim1 = pdr_dim (pdr1);
-  graphite_dim_t dim2 = pdr_dim (pdr2);
-  graphite_dim_t dim = tdim1 + tdim2 + dim1 + dim2 - gdim;
-  ppl_Pointset_Powerset_C_Polyhedron_t res;
-  ppl_Pointset_Powerset_C_Polyhedron_t idr1, idr2;
-  ppl_Pointset_Powerset_C_Polyhedron_t sc1, sc2, dreq;
-  ppl_Pointset_Powerset_C_Polyhedron_t lex;
-
-  gcc_assert (PBB_SCOP (pbb1) == PBB_SCOP (pbb2));
-
-  combine_context_id_scat (&sc1, pbb1, original_scattering_p);
-  combine_context_id_scat (&sc2, pbb2, original_scattering_p);
-
-  ppl_insert_dimensions_pointset (sc1, tdim1 + ddim1,
-				  tdim2 + ddim2 + sdim1 + sdim2);
-
-  ppl_insert_dimensions_pointset (sc2, 0, tdim1 + ddim1);
-  ppl_insert_dimensions_pointset (sc2, tdim1 + ddim1 + tdim2 + ddim2,
-				  sdim1 + sdim2);
+  int global_max = *((int *) user);
+  isl_space *space = isl_map_get_space (map);
+  int nb_out = isl_space_dim (space, isl_dim_out);
 
-  idr1 = map_dr_into_dep_poly (dim, PDR_ACCESSES (pdr1), ddim1, ddim1 + gdim,
-			       tdim1, tdim2 + ddim2);
-  idr2 = map_dr_into_dep_poly (dim, PDR_ACCESSES (pdr2), ddim2, ddim2 + gdim,
-			       tdim1 + ddim1 + tdim2, sdim1);
+  if (global_max < nb_out)
+    *((int *) user) = nb_out;
 
-  /* Now add the subscript equalities.  */
-  dreq = dr_equality_constraints (dim, tdim1 + ddim1 + tdim2 + ddim2, sdim1);
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (&res, dim, 0);
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, sc1);
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, sc2);
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, idr1);
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, idr2);
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, dreq);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (sc1);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (sc2);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (idr1);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (idr2);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (dreq);
-
-  if (ppl_powerset_is_empty (res))
-    return NULL;
-
-  lex = build_lexicographical_constraint (res, dim, MIN (tdim1, tdim2),
-					  tdim1 + ddim1, direction);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (res);
-
-  return lex;
+  isl_map_free (map);
+  isl_space_free (space);
+  return 0;
 }
 
-/* Build the dependence polyhedron for data references PDR1 and PDR2.
-   If possible use already cached information.
-
-   When DIRECTION is set to 1, compute the direct dependence from PDR1
-   to PDR2, and when DIRECTION is -1, compute the reversed dependence
-   relation, from PDR2 to PDR1.  */
+/* Extends the output dimension of MAP to MAX dimensions.  */
 
-static poly_ddr_p
-new_poly_ddr (poly_dr_p pdr1, poly_dr_p pdr2,
-	      int direction, bool original_scattering_p)
+static __isl_give isl_map *
+extend_map (__isl_take isl_map *map, int max)
 {
-  PTR *x = NULL;
-  poly_ddr_p res;
-  bool may_alias;
+  isl_space *space = isl_map_get_space (map);
+  int n = isl_space_dim (space, isl_dim_out);
 
-  /* Return the PDDR from the cache if it already has been computed.  */
-  if (original_scattering_p)
-    {
-      struct poly_ddr tmp;
-      scop_p scop = PBB_SCOP (PDR_PBB (pdr1));
-
-      tmp.source = pdr1;
-      tmp.sink = pdr2;
-      x = htab_find_slot (SCOP_ORIGINAL_PDDRS (scop),
-                          &tmp, INSERT);
-
-      if (x && *x)
-	return (poly_ddr_p) *x;
-    }
-
-  res = XNEW (struct poly_ddr);
-  PDDR_SOURCE (res) = pdr1;
-  PDDR_SINK (res) = pdr2;
-  PDDR_DDP (res) = NULL;
-  PDDR_ORIGINAL_SCATTERING_P (res) = original_scattering_p;
-  PDDR_KIND (res) = unknown_dependence;
-
-  may_alias = poly_drs_may_alias_p (pdr1, pdr2);
-
-  if (!(pdr_read_p (pdr1) && pdr_read_p (pdr2))
-      && PDR_BASE_OBJECT_SET (pdr1) != PDR_BASE_OBJECT_SET (pdr2)
-      && may_alias)
-    PDDR_KIND (res) = unknown_dependence;
-
-  else if (!(pdr_read_p (pdr1) && pdr_read_p (pdr2))
-	   && same_pdr_p (pdr1, pdr2)
-	   && may_alias)
-    {
-      PDDR_DDP (res) = dependence_polyhedron (pdr1, pdr2, direction,
-					      original_scattering_p);
-      if (PDDR_DDP (res))
-	PDDR_KIND (res) = has_dependence;
-      else
-	PDDR_KIND (res) = no_dependence;
-    }
-  else
-    PDDR_KIND (res) = no_dependence;
-
-  if (original_scattering_p)
-    *x = res;
-
-  return res;
+  isl_space_free (space);
+  return isl_map_add_dims (map, isl_dim_out, max - n);
 }
 
-/* Free the data dependence relation poly_ddr_p P.  */
+/* Structure used to pass parameters to extend_schedule_1.  */
 
-void
-free_poly_ddr (void *p)
-{
-  poly_ddr_p pddr = (poly_ddr_p) p;
-  ppl_delete_Pointset_Powerset_C_Polyhedron (PDDR_DDP (pddr));
-  free (pddr);
-}
+struct extend_schedule_str {
+  int max;
+  isl_union_map *umap;
+};
 
-/* Return true when the data dependence relation between the data
-   references PDR1 belonging to PBB1 and PDR2 is part of a
-   reduction.  */
+/* Helper function for extend_schedule.  */
 
-static inline bool
-reduction_dr_1 (poly_bb_p pbb1, poly_dr_p pdr1, poly_dr_p pdr2)
+static int
+extend_schedule_1 (__isl_take isl_map *map, void *user)
 {
-  int i;
-  poly_dr_p pdr;
-
-  FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb1), i, pdr)
-    if (PDR_TYPE (pdr) == PDR_WRITE
-	&& same_pdr_p (pdr, pdr1) && same_pdr_p (pdr, pdr2))
-      return true;
-
-  return false;
+  struct extend_schedule_str *str = (struct extend_schedule_str *) user;
+  str->umap = isl_union_map_add_map (str->umap, extend_map (map, str->max));
+  return 0;
 }
 
-/* Return true when the data dependence relation between the data
-   references PDR1 belonging to PBB1 and PDR2 belonging to PBB2 is
-   part of a reduction.  */
+/* Return a relation that has uniform output dimensions.  */
 
-static inline bool
-reduction_dr_p (poly_dr_p pdr1, poly_dr_p pdr2)
+__isl_give isl_union_map *
+extend_schedule (__isl_take isl_union_map *x)
 {
-  poly_bb_p pbb1 = PDR_PBB (pdr1);
-  poly_bb_p pbb2 = PDR_PBB (pdr2);
+  int max = 0;
+  int res;
+  struct extend_schedule_str str;
 
-  if (PBB_IS_REDUCTION (pbb1))
-    return reduction_dr_1 (pbb1, pdr1, pdr2);
+  res = isl_union_map_foreach_map (x, max_number_of_out_dimensions, (void *) &max);
+  gcc_assert (res == 0);
 
-  if (PBB_IS_REDUCTION (pbb2))
-    return reduction_dr_1 (pbb2, pdr2, pdr1);
+  str.max = max;
+  str.umap = isl_union_map_empty (isl_union_map_get_space (x));
+  res = isl_union_map_foreach_map (x, extend_schedule_1, (void *) &str);
+  gcc_assert (res == 0);
 
-  return false;
+  isl_union_map_free (x);
+  return str.umap;
 }
 
-/* Returns true when the PBB_TRANSFORMED_SCATTERING functions of PBB1
-   and PBB2 respect the data dependences of PBB_ORIGINAL_SCATTERING
-   functions.  */
+/* Applies SCHEDULE to the in and out dimensions of the dependences
+   DEPS and return the resulting relation.  */
 
-static bool
-graphite_legal_transform_dr (poly_dr_p pdr1, poly_dr_p pdr2)
+static isl_map *
+apply_schedule_on_deps (__isl_keep isl_union_map *schedule,
+			__isl_keep isl_union_map *deps)
 {
-  ppl_Pointset_Powerset_C_Polyhedron_t po, pt;
-  graphite_dim_t ddim1, otdim1, otdim2, ttdim1, ttdim2;
-  ppl_Pointset_Powerset_C_Polyhedron_t po_temp;
-  ppl_dimension_type pdim;
-  bool is_empty_p;
-  poly_ddr_p opddr, tpddr;
-  poly_bb_p pbb1, pbb2;
-
-  if (reduction_dr_p (pdr1, pdr2))
-    return true;
+  isl_map *x;
+  isl_union_map *ux, *trans;
 
-  /* We build the reverse dependence relation for the transformed
-     scattering, such that when we intersect it with the original PO,
-     we get an empty intersection when the transform is legal:
-     i.e. the transform should reverse no dependences, and so PT, the
-     reversed transformed PDDR, should have no constraint from PO.  */
-  opddr = new_poly_ddr (pdr1, pdr2, 1, true);
+  trans = isl_union_map_copy (schedule);
+  trans = extend_schedule (trans);
+  ux = isl_union_map_copy (deps);
+  ux = isl_union_map_apply_domain (ux, isl_union_map_copy (trans));
+  ux = isl_union_map_apply_range (ux, trans);
+  x = isl_map_from_union_map (ux);
 
-  if (PDDR_KIND (opddr) == unknown_dependence)
-    return false;
-
-    /* There are no dependences between PDR1 and PDR2 in the original
-       version of the program, or after the transform, so the
-       transform is legal.  */
-  if (pddr_is_empty (opddr))
-    return true;
-
-  tpddr = new_poly_ddr (pdr1, pdr2, -1, false);
-
-  if (PDDR_KIND (tpddr) == unknown_dependence)
-    {
-      free_poly_ddr (tpddr);
-      return false;
-    }
-
-  if (pddr_is_empty (tpddr))
-    {
-      free_poly_ddr (tpddr);
-      return true;
-    }
-
-  po = PDDR_DDP (opddr);
-  pt = PDDR_DDP (tpddr);
-
-  /* Copy PO into PO_TEMP, such that PO is not destroyed.  PO is
-     stored in a cache and should not be modified or freed.  */
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (po, &pdim);
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (&po_temp,
-							       pdim, 0);
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (po_temp, po);
-
-  /* Extend PO and PT to have the same dimensions.  */
-  pbb1 = PDR_PBB (pdr1);
-  pbb2 = PDR_PBB (pdr2);
-  ddim1 = pbb_dim_iter_domain (pbb1);
-  otdim1 = pbb_nb_scattering_orig (pbb1);
-  otdim2 = pbb_nb_scattering_orig (pbb2);
-  ttdim1 = pbb_nb_scattering_transform (pbb1);
-  ttdim2 = pbb_nb_scattering_transform (pbb2);
-  ppl_insert_dimensions_pointset (po_temp, otdim1, ttdim1);
-  ppl_insert_dimensions_pointset (po_temp, otdim1 + ttdim1 + ddim1 + otdim2,
-				  ttdim2);
-  ppl_insert_dimensions_pointset (pt, 0, otdim1);
-  ppl_insert_dimensions_pointset (pt, otdim1 + ttdim1 + ddim1, otdim2);
-
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (po_temp, pt);
-  is_empty_p = ppl_powerset_is_empty (po_temp);
-
-  ppl_delete_Pointset_Powerset_C_Polyhedron (po_temp);
-  free_poly_ddr (tpddr);
-
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    fprintf (dump_file, "\nloop carries dependency.\n");
-
-  return is_empty_p;
-}
-
-/* Return true when the data dependence relation for PBB1 and PBB2 is
-   part of a reduction.  */
-
-static inline bool
-reduction_ddr_p (poly_bb_p pbb1, poly_bb_p pbb2)
-{
-  return pbb1 == pbb2 && PBB_IS_REDUCTION (pbb1);
+  return x;
 }
 
-/* Iterates over the data references of PBB1 and PBB2 and detect
-   whether the transformed schedule is correct.  */
+/* Return true when SCHEDULE does not violate the data DEPS: that is
+   when the intersection of LEX with the DEPS transformed by SCHEDULE
+   is empty.  LEX is the relation in which the outputs occur before
+   the inputs.  */
 
 static bool
-graphite_legal_transform_bb (poly_bb_p pbb1, poly_bb_p pbb2)
+no_violations (__isl_keep isl_union_map *schedule,
+	       __isl_keep isl_union_map *deps)
 {
-  int i, j;
-  poly_dr_p pdr1, pdr2;
-
-  if (!PBB_PDR_DUPLICATES_REMOVED (pbb1))
-    pbb_remove_duplicate_pdrs (pbb1);
-
-  if (!PBB_PDR_DUPLICATES_REMOVED (pbb2))
-    pbb_remove_duplicate_pdrs (pbb2);
+  bool res;
+  isl_space *space;
+  isl_map *lex, *x;
 
-  if (reduction_ddr_p (pbb1, pbb2))
+  if (isl_union_map_is_empty (deps))
     return true;
 
-  FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb1), i, pdr1)
-    FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb2), j, pdr2)
-      if (!graphite_legal_transform_dr (pdr1, pdr2))
-	return false;
-
-  return true;
-}
-
-/* Iterates over the SCOP and detect whether the transformed schedule
-   is correct.  */
+  x = apply_schedule_on_deps (schedule, deps);
+  space = isl_map_get_space (x);
+  space = isl_space_range (space);
+  lex = isl_map_lex_ge (space);
+  x = isl_map_intersect (x, lex);
+  res = isl_map_is_empty (x);
 
-bool
-graphite_legal_transform (scop_p scop)
-{
-  int i, j;
-  poly_bb_p pbb1, pbb2;
-
-  timevar_push (TV_GRAPHITE_DATA_DEPS);
-
-  FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb1)
-    FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), j, pbb2)
-      if (!graphite_legal_transform_bb (pbb1, pbb2))
-	{
-	  timevar_pop (TV_GRAPHITE_DATA_DEPS);
-	  return false;
-	}
-
-  timevar_pop (TV_GRAPHITE_DATA_DEPS);
-  return true;
+  isl_map_free (x);
+  return res;
 }
 
-/* Returns TRUE when the dependence polyhedron between PDR1 and
-   PDR2 represents a loop carried dependence at level LEVEL.  */
+/* Return true when DEPS is non empty and the intersection of LEX with
+   the DEPS transformed by SCHEDULE is non empty.  LEX is the relation
+   in which all the inputs before DEPTH occur at the same time as the
+   output, and the input at DEPTH occurs before output.  */
 
 static bool
-graphite_carried_dependence_level_k (poly_dr_p pdr1, poly_dr_p pdr2,
-				     int level)
+carries_deps (__isl_keep isl_union_map *schedule,
+	      __isl_keep isl_union_map *deps,
+	      int depth)
 {
-  ppl_Pointset_Powerset_C_Polyhedron_t po;
-  ppl_Pointset_Powerset_C_Polyhedron_t eqpp;
-  poly_bb_p pbb = PDR_PBB (pdr1);
-  graphite_dim_t tdim1 = pbb_nb_scattering_transform (pbb);
-  graphite_dim_t ddim1 = pbb_dim_iter_domain (pbb);
-  ppl_dimension_type dim;
-  bool empty_p;
-  poly_ddr_p pddr = new_poly_ddr (pdr1, pdr2, 1, false);
-  graphite_dim_t pos;
-
-  if (PDDR_KIND (pddr) == unknown_dependence)
-    {
-      free_poly_ddr (pddr);
-      return true;
-    }
+  bool res;
+  int idx, i;
+  isl_space *space;
+  isl_map *lex, *x;
+  isl_constraint *ineq;
 
-  if (pddr_is_empty (pddr))
-    {
-      free_poly_ddr (pddr);
-      return false;
-    }
+  if (isl_union_map_is_empty (deps))
+    return false;
 
-  po = PDDR_DDP (pddr);
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (po, &dim);
-  pos = psct_dynamic_dim (pbb, level);
-  eqpp = build_pairwise_scheduling (dim, pos, tdim1 + ddim1, 1);
+  x = apply_schedule_on_deps (schedule, deps);
+  space = isl_map_get_space (x);
+  space = isl_space_range (space);
+  lex = isl_map_lex_le (space);
+  space = isl_map_get_space (x);
+  ineq = isl_inequality_alloc (isl_local_space_from_space (space));
 
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (eqpp, po);
-  empty_p = ppl_powerset_is_empty (eqpp);
+  idx = 2 * depth + 1;
+  for (i = 0; i < idx; i++)
+    lex = isl_map_equate (lex, isl_dim_in, i, isl_dim_out, i);
 
-  ppl_delete_Pointset_Powerset_C_Polyhedron (eqpp);
-  free_poly_ddr (pddr);
+  /* in + 1 <= out  */
+  ineq = isl_constraint_set_coefficient_si (ineq, isl_dim_out, idx, 1);
+  ineq = isl_constraint_set_coefficient_si (ineq, isl_dim_in, idx, -1);
+  ineq = isl_constraint_set_constant_si (ineq, -1);
+  lex = isl_map_add_constraint (lex, ineq);
+  x = isl_map_intersect (x, lex);
+  res = !isl_map_is_empty (x);
 
-  return !empty_p;
+  isl_map_free (x);
+  return res;
 }
 
-/* Check data dependency between PBB1 and PBB2 at level LEVEL.  */
+/* Subtract from the RAW, WAR, and WAW dependences those relations
+   that have been marked as belonging to an associative commutative
+   reduction.  */
 
-bool
-dependency_between_pbbs_p (poly_bb_p pbb1, poly_bb_p pbb2, int level)
+static void
+subtract_commutative_associative_deps (scop_p scop,
+				       VEC (poly_bb_p, heap) *pbbs,
+				       isl_union_map *original,
+				       isl_union_map **must_raw,
+				       isl_union_map **may_raw,
+				       isl_union_map **must_raw_no_source,
+				       isl_union_map **may_raw_no_source,
+				       isl_union_map **must_war,
+				       isl_union_map **may_war,
+				       isl_union_map **must_war_no_source,
+				       isl_union_map **may_war_no_source,
+				       isl_union_map **must_waw,
+				       isl_union_map **may_waw,
+				       isl_union_map **must_waw_no_source,
+				       isl_union_map **may_waw_no_source)
 {
   int i, j;
-  poly_dr_p pdr1, pdr2;
-
-  timevar_push (TV_GRAPHITE_DATA_DEPS);
-
-  FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb1), i, pdr1)
-    FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb2), j, pdr2)
-      if (graphite_carried_dependence_level_k (pdr1, pdr2, level))
-	{
-	  timevar_pop (TV_GRAPHITE_DATA_DEPS);
-	  return true;
-	}
+  poly_bb_p pbb;
+  poly_dr_p pdr;
+  isl_space *space = isl_set_get_space (scop->context);
 
-  timevar_pop (TV_GRAPHITE_DATA_DEPS);
-  return false;
-}
+  FOR_EACH_VEC_ELT (poly_bb_p, pbbs, i, pbb)
+    if (PBB_IS_REDUCTION (pbb))
+      {
+	int res;
+	isl_union_map *r = isl_union_map_empty (isl_space_copy (space));
+	isl_union_map *must_w = isl_union_map_empty (isl_space_copy (space));
+	isl_union_map *may_w = isl_union_map_empty (isl_space_copy (space));
+	isl_union_map *all_w;
+	isl_union_map *empty;
+	isl_union_map *x_must_raw;
+	isl_union_map *x_may_raw;
+	isl_union_map *x_must_raw_no_source;
+	isl_union_map *x_may_raw_no_source;
+	isl_union_map *x_must_war;
+	isl_union_map *x_may_war;
+	isl_union_map *x_must_war_no_source;
+	isl_union_map *x_may_war_no_source;
+	isl_union_map *x_must_waw;
+	isl_union_map *x_may_waw;
+	isl_union_map *x_must_waw_no_source;
+	isl_union_map *x_may_waw_no_source;
 
-/* When ORIG is true, pretty print to FILE all the original data
-   dependences of SCoP in DOT format, otherwise print the transformed
-   data deps.  */
+	FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), j, pdr)
+	  if (pdr_read_p (pdr))
+	    r = isl_union_map_add_map (r, add_pdr_constraints (pdr, pbb));
 
-static void
-dot_deps_stmt_2 (FILE *file, scop_p scop, bool orig)
-{
-  int i, j, k, l;
-  poly_bb_p pbb1, pbb2;
-  poly_dr_p pdr1, pdr2;
+	FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), j, pdr)
+	  if (pdr_write_p (pdr))
+	    must_w = isl_union_map_add_map (must_w,
+					    add_pdr_constraints (pdr, pbb));
 
-  FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb1)
-    FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), j, pbb2)
-      {
-	FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb1), k, pdr1)
-	  FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb2), l, pdr2)
-	    {
-	      poly_ddr_p pddr = new_poly_ddr (pdr1, pdr2, 1, orig);
+	FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), j, pdr)
+	  if (pdr_may_write_p (pdr))
+	    may_w = isl_union_map_add_map (may_w,
+					   add_pdr_constraints (pdr, pbb));
 
-	      if (!pddr_is_empty (pddr))
-		{
-		  fprintf (file, orig ? "OS%d -> OS%d\n" : "TS%d -> TS%d\n",
-			   pbb_index (pbb1), pbb_index (pbb2));
+	all_w = isl_union_map_union
+	  (isl_union_map_copy (must_w), isl_union_map_copy (may_w));
+	empty = isl_union_map_empty (isl_union_map_get_space (all_w));
 
-		  free_poly_ddr (pddr);
-		  goto done;
-		}
+	res = isl_union_map_compute_flow (isl_union_map_copy (r),
+					  isl_union_map_copy (must_w),
+					  isl_union_map_copy (may_w),
+					  isl_union_map_copy (original),
+					  &x_must_raw, &x_may_raw,
+					  &x_must_raw_no_source,
+					  &x_may_raw_no_source);
+	gcc_assert (res == 0);
+	res = isl_union_map_compute_flow (isl_union_map_copy (all_w),
+					  r, empty,
+					  isl_union_map_copy (original),
+					  &x_must_war, &x_may_war,
+					  &x_must_war_no_source,
+					  &x_may_war_no_source);
+	gcc_assert (res == 0);
+	res = isl_union_map_compute_flow (all_w, must_w, may_w,
+					  isl_union_map_copy (original),
+					  &x_must_waw, &x_may_waw,
+					  &x_must_waw_no_source,
+					  &x_may_waw_no_source);
+	gcc_assert (res == 0);
 
-	      free_poly_ddr (pddr);
-	    }
-      done:;
+	*must_raw = isl_union_map_subtract (*must_raw, x_must_raw);
+	*may_raw = isl_union_map_subtract (*may_raw, x_may_raw);
+	*must_raw_no_source = isl_union_map_subtract (*must_raw_no_source,
+						      x_must_raw_no_source);
+	*may_raw_no_source = isl_union_map_subtract (*may_raw_no_source,
+						     x_may_raw_no_source);
+	*must_war = isl_union_map_subtract (*must_war, x_must_war);
+	*may_war = isl_union_map_subtract (*may_war, x_may_war);
+	*must_war_no_source = isl_union_map_subtract (*must_war_no_source,
+						      x_must_war_no_source);
+	*may_war_no_source = isl_union_map_subtract (*may_war_no_source,
+						     x_may_war_no_source);
+	*must_waw = isl_union_map_subtract (*must_waw, x_must_waw);
+	*may_waw = isl_union_map_subtract (*may_waw, x_may_waw);
+	*must_waw_no_source = isl_union_map_subtract (*must_waw_no_source,
+						      x_must_waw_no_source);
+	*may_waw_no_source = isl_union_map_subtract (*may_waw_no_source,
+						     x_may_waw_no_source);
       }
+
+  isl_union_map_free (original);
+  isl_space_free (space);
 }
 
-/* Pretty print to FILE all the data dependences of SCoP in DOT
-   format.  */
+/* Compute the original data dependences in SCOP for all the reads and
+   writes in PBBS.  */
 
 static void
-dot_deps_stmt_1 (FILE *file, scop_p scop)
+compute_deps (scop_p scop, VEC (poly_bb_p, heap) *pbbs,
+	      isl_union_map **must_raw,
+	      isl_union_map **may_raw,
+	      isl_union_map **must_raw_no_source,
+	      isl_union_map **may_raw_no_source,
+	      isl_union_map **must_war,
+	      isl_union_map **may_war,
+	      isl_union_map **must_war_no_source,
+	      isl_union_map **may_war_no_source,
+	      isl_union_map **must_waw,
+	      isl_union_map **may_waw,
+	      isl_union_map **must_waw_no_source,
+	      isl_union_map **may_waw_no_source)
 {
-  fputs ("digraph all {\n", file);
+  isl_union_map *reads = scop_get_reads (scop, pbbs);
+  isl_union_map *must_writes = scop_get_must_writes (scop, pbbs);
+  isl_union_map *may_writes = scop_get_may_writes (scop, pbbs);
+  isl_union_map *all_writes = isl_union_map_union
+    (isl_union_map_copy (must_writes), isl_union_map_copy (may_writes));
+  isl_space *space = isl_union_map_get_space (all_writes);
+  isl_union_map *empty = isl_union_map_empty (space);
+  isl_union_map *original = scop_get_original_schedule (scop, pbbs);
+  int res;
 
-  dot_deps_stmt_2 (file, scop, true);
-  dot_deps_stmt_2 (file, scop, false);
+  res = isl_union_map_compute_flow (isl_union_map_copy (reads),
+				    isl_union_map_copy (must_writes),
+				    isl_union_map_copy (may_writes),
+				    isl_union_map_copy (original),
+				    must_raw, may_raw, must_raw_no_source,
+				    may_raw_no_source);
+  gcc_assert (res == 0);
+  res = isl_union_map_compute_flow (isl_union_map_copy (all_writes),
+				    reads, empty,
+				    isl_union_map_copy (original),
+				    must_war, may_war, must_war_no_source,
+				    may_war_no_source);
+  gcc_assert (res == 0);
+  res = isl_union_map_compute_flow (all_writes, must_writes, may_writes,
+				    isl_union_map_copy (original),
+				    must_waw, may_waw, must_waw_no_source,
+				    may_waw_no_source);
+  gcc_assert (res == 0);
 
-  fputs ("}\n\n", file);
+  subtract_commutative_associative_deps
+    (scop, pbbs, original,
+     must_raw, may_raw, must_raw_no_source, may_raw_no_source,
+     must_war, may_war, must_war_no_source, may_war_no_source,
+     must_waw, may_waw, must_waw_no_source, may_waw_no_source);
 }
 
-/* When ORIG is true, pretty print to FILE all the original data
-   dependences of SCoP in DOT format, otherwise print the transformed
-   data deps.  */
+/* Given a TRANSFORM, check whether it respects the original
+   dependences in SCOP.  Returns true when TRANSFORM is a safe
+   transformation.  */
 
-static void
-dot_deps_2 (FILE *file, scop_p scop, bool orig)
+static bool
+transform_is_safe (scop_p scop, isl_union_map *transform)
 {
-  int i, j, k, l;
-  poly_bb_p pbb1, pbb2;
-  poly_dr_p pdr1, pdr2;
+  bool res;
 
-  FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb1)
-    FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), j, pbb2)
-      FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb1), k, pdr1)
-	FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb2), l, pdr2)
-          {
-	    poly_ddr_p pddr = new_poly_ddr (pdr1, pdr2, 1, orig);
+  if (!scop->must_raw)
+    compute_deps (scop, SCOP_BBS (scop),
+		  &scop->must_raw, &scop->may_raw,
+		  &scop->must_raw_no_source, &scop->may_raw_no_source,
+		  &scop->must_war, &scop->may_war,
+		  &scop->must_war_no_source, &scop->may_war_no_source,
+		  &scop->must_waw, &scop->may_waw,
+		  &scop->must_waw_no_source, &scop->may_waw_no_source);
 
-	    if (!pddr_is_empty (pddr))
-	      fprintf (file, orig
-		       ? "OS%d_D%d -> OS%d_D%d\n" : "TS%d_D%d -> TS%d_D%d\n",
-		       pbb_index (pbb1), PDR_ID (pdr1),
-		       pbb_index (pbb2), PDR_ID (pdr2));
+  res = (no_violations (transform, scop->must_raw)
+	 && no_violations (transform, scop->may_raw)
+	 && no_violations (transform, scop->must_war)
+	 && no_violations (transform, scop->may_war)
+	 && no_violations (transform, scop->must_waw)
+	 && no_violations (transform, scop->may_waw));
 
-	    free_poly_ddr (pddr);
-	  }
+  isl_union_map_free (transform);
+  return res;
 }
 
-/* Pretty print to FILE all the data dependences of SCoP in DOT
-   format.  */
+/* Return true when the SCOP transformed schedule is correct.  */
 
-static void
-dot_deps_1 (FILE *file, scop_p scop)
+bool
+graphite_legal_transform (scop_p scop)
 {
-  fputs ("digraph all {\n", file);
+  int res;
+  isl_union_map *transform;
 
-  dot_deps_2 (file, scop, true);
-  dot_deps_2 (file, scop, false);
+  timevar_push (TV_GRAPHITE_DATA_DEPS);
+  transform = scop_get_transformed_schedule (scop, SCOP_BBS (scop));
+  res = transform_is_safe (scop, transform);
+  timevar_pop (TV_GRAPHITE_DATA_DEPS);
 
-  fputs ("}\n\n", file);
+  return res;
 }
 
-/* Display all the data dependences in SCoP using dotty.  */
+/* Return true when the loop at DEPTH carries dependences.  BODY is
+   the body of the loop.  */
 
-DEBUG_FUNCTION void
-dot_deps (scop_p scop)
+static bool
+loop_level_carries_dependences (scop_p scop, VEC (poly_bb_p, heap) *body,
+				int depth)
 {
-  /* When debugging, enable the following code.  This cannot be used
-     in production compilers because it calls "system".  */
-#if 0
-  FILE *stream = fopen ("/tmp/scopdeps.dot", "w");
-  gcc_assert (stream);
+  isl_union_map *transform = scop_get_transformed_schedule (scop, body);
+  isl_union_map *must_raw, *may_raw;
+  isl_union_map *must_war, *may_war;
+  isl_union_map *must_waw, *may_waw;
+  int res;
 
-  dot_deps_1 (stream, scop);
-  fclose (stream);
+  compute_deps (scop, body,
+		&must_raw, &may_raw, NULL, NULL,
+		&must_war, &may_war, NULL, NULL,
+		&must_waw, &may_waw, NULL, NULL);
 
-  system ("dotty /tmp/scopdeps.dot &");
-#else
-  dot_deps_1 (stderr, scop);
-#endif
+  res = (carries_deps (transform, must_raw, depth)
+	 || carries_deps (transform, may_raw, depth)
+	 || carries_deps (transform, must_war, depth)
+	 || carries_deps (transform, may_war, depth)
+	 || carries_deps (transform, must_waw, depth)
+	 || carries_deps (transform, may_waw, depth));
+
+  isl_union_map_free (transform);
+  isl_union_map_free (must_raw);
+  isl_union_map_free (may_raw);
+  isl_union_map_free (must_war);
+  isl_union_map_free (may_war);
+  isl_union_map_free (must_waw);
+  isl_union_map_free (may_waw);
+  return res;
 }
 
-/* Display all the statement dependences in SCoP using dotty.  */
+/* Returns true when the loop L at level DEPTH is parallel.
+   BB_PBB_MAPPING is a map between a basic_block and its related
+   poly_bb_p.  */
 
-DEBUG_FUNCTION void
-dot_deps_stmt (scop_p scop)
+bool
+loop_is_parallel_p (loop_p loop, htab_t bb_pbb_mapping, int depth)
 {
-  /* When debugging, enable the following code.  This cannot be used
-     in production compilers because it calls "system".  */
-#if 0
-  FILE *stream = fopen ("/tmp/scopdeps.dot", "w");
-  gcc_assert (stream);
+  bool dependences;
+  scop_p scop;
+  VEC (poly_bb_p, heap) *body = VEC_alloc (poly_bb_p, heap, 3);
 
-  dot_deps_stmt_1 (stream, scop);
-  fclose (stream);
+  timevar_push (TV_GRAPHITE_DATA_DEPS);
+  scop = get_loop_body_pbbs (loop, bb_pbb_mapping, &body);
+  dependences = loop_level_carries_dependences (scop, body, depth);
+  VEC_free (poly_bb_p, heap, body);
+  timevar_pop (TV_GRAPHITE_DATA_DEPS);
 
-  system ("dotty /tmp/scopdeps.dot &");
-#else
-  dot_deps_stmt_1 (stderr, scop);
-#endif
+  return !dependences;
 }
 
 #endif
diff --git a/gcc/graphite-dependences.h b/gcc/graphite-dependences.h
deleted file mode 100644
index 5f2a4a0..0000000
--- a/gcc/graphite-dependences.h
+++ /dev/null
@@ -1,64 +0,0 @@ 
-/* Graphite polyhedral representation.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
-   Contributed by Konrad Trifunovic <konrad.trifunovic@gmail.com>
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-#ifndef GCC_GRAPHITE_DEPENDENCES_H
-#define GCC_GRAPHITE_DEPENDENCES_H
-
-extern bool graphite_legal_transform (scop_p);
-extern bool dependency_between_pbbs_p (poly_bb_p, poly_bb_p, int);
-
-enum poly_dependence_kind {
-  unknown_dependence,
-  no_dependence,
-  has_dependence
-};
-
-/* Represents a Polyhedral Data Dependence Relation.  */
-
-typedef struct poly_ddr
-{
-  /* Source and sink data references of the dependence.  */
-  poly_dr_p source, sink;
-
-  /* Data dependence polyhedron.  */
-  ppl_Pointset_Powerset_C_Polyhedron_t ddp;
-
-  enum poly_dependence_kind kind;
-
-  /* True when the dependence relation is for the original scattering.  */
-  bool original_scattering_p;
-
-} *poly_ddr_p;
-
-#define PDDR_SOURCE(PDDR) (PDDR->source)
-#define PDDR_SINK(PDDR) (PDDR->sink)
-#define PDDR_DDP(PDDR) (PDDR->ddp)
-#define PDDR_KIND(PDDR) (PDDR->kind)
-#define PDDR_ORIGINAL_SCATTERING_P(PDDR) (PDDR->original_scattering_p)
-
-extern int eq_poly_ddr_p (const void *, const void *);
-extern hashval_t hash_poly_ddr_p (const void *);
-extern void free_poly_ddr (void *);
-extern void dot_deps (scop_p);
-extern void dot_deps_stmt (scop_p);
-extern void print_pddr (FILE *, poly_ddr_p);
-extern void debug_pddr (poly_ddr_p);
-
-#endif
diff --git a/gcc/graphite-interchange.c b/gcc/graphite-interchange.c
index ae3262a..dbef03a 100644
--- a/gcc/graphite-interchange.c
+++ b/gcc/graphite-interchange.c
@@ -1,7 +1,7 @@ 
 /* Interchange heuristics and transform for loop interchange on
    polyhedral representation.
 
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Harsha Jagasia <harsha.jagasia@amd.com>.
 
@@ -20,7 +20,19 @@  GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
+
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/aff.h>
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <isl/ilp.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
@@ -32,10 +44,9 @@  along with GCC; see the file COPYING3.  If not see
 #include "sese.h"
 
 #ifdef HAVE_cloog
-#include "ppl_c.h"
-#include "graphite-ppl.h"
 #include "graphite-poly.h"
 
+/* XXX isl rewrite following comment */
 /* Builds a linear expression, of dimension DIM, representing PDR's
    memory access:
 
@@ -53,87 +64,90 @@  along with GCC; see the file COPYING3.  If not see
    where the expression itself is:
    c_0 * s_0 + c_1 * s_1 + ... c_n * s_n.  */
 
-static ppl_Linear_Expression_t
-build_linearized_memory_access (ppl_dimension_type offset, poly_dr_p pdr)
+static isl_constraint *
+build_linearized_memory_access (isl_map *map, poly_dr_p pdr)
 {
-  ppl_Linear_Expression_t res;
-  ppl_Linear_Expression_t le;
-  ppl_dimension_type i;
-  ppl_dimension_type first = pdr_subscript_dim (pdr, 0);
-  ppl_dimension_type last = pdr_subscript_dim (pdr, PDR_NB_SUBSCRIPTS (pdr));
-  mpz_t size, sub_size;
-  graphite_dim_t dim = offset + pdr_dim (pdr);
-
-  ppl_new_Linear_Expression_with_dimension (&res, dim);
+  isl_constraint *res;
+  isl_local_space *ls = isl_local_space_from_space (isl_map_get_space (map));
+  unsigned offset, nsubs;
+  int i;
+  isl_int size, subsize;
 
-  mpz_init (size);
-  mpz_set_si (size, 1);
-  mpz_init (sub_size);
-  mpz_set_si (sub_size, 1);
+  res = isl_equality_alloc (ls);
+  isl_int_init (size);
+  isl_int_set_ui (size, 1);
+  isl_int_init (subsize);
+  isl_int_set_ui (subsize, 1);
 
-  for (i = last - 1; i >= first; i--)
+  nsubs = isl_set_dim (pdr->extent, isl_dim_set);
+  /* -1 for the already included L dimension.  */
+  offset = isl_map_dim (map, isl_dim_out) - 1 - nsubs;
+  res = isl_constraint_set_coefficient_si (res, isl_dim_out, offset + nsubs, -1);
+  /* Go through all subscripts from last to first.  First dimension
+     is the alias set, ignore it.  */
+  for (i = nsubs - 1; i >= 1; i--)
     {
-      ppl_set_coef_gmp (res, i + offset, size);
+      isl_space *dc;
+      isl_aff *aff;
 
-      ppl_new_Linear_Expression_with_dimension (&le, dim - offset);
-      ppl_set_coef (le, i, 1);
-      ppl_max_for_le_pointset (PDR_ACCESSES (pdr), le, sub_size);
-      mpz_mul (size, size, sub_size);
-      ppl_delete_Linear_Expression (le);
+      res = isl_constraint_set_coefficient (res, isl_dim_out, offset + i, size);
+
+      dc = isl_set_get_space (pdr->extent);
+      aff = isl_aff_zero_on_domain (isl_local_space_from_space (dc));
+      aff = isl_aff_set_coefficient_si (aff, isl_dim_in, i, 1);
+      isl_set_max (pdr->extent, aff, &subsize);
+      isl_aff_free (aff);
+      isl_int_mul (size, size, subsize);
     }
 
-  mpz_clear (sub_size);
-  mpz_clear (size);
+  isl_int_clear (subsize);
+  isl_int_clear (size);
+
   return res;
 }
 
-/* Builds a partial difference equations and inserts them
-   into pointset powerset polyhedron P.  Polyhedron is assumed
-   to have the format: T|I|T'|I'|G|S|S'|l1|l2.
-
-   TIME_DEPTH is the time dimension w.r.t. which we are
-   differentiating.
-   OFFSET represents the number of dimensions between
-   columns t_{time_depth} and t'_{time_depth}.
-   DIM_SCTR is the number of scattering dimensions.  It is
-   essentially the dimensionality of the T vector.
-
-   The following equations are inserted into the polyhedron P:
-    | t_1 = t_1'
-    | ...
-    | t_{time_depth-1} = t'_{time_depth-1}
-    | t_{time_depth} = t'_{time_depth} + 1
-    | t_{time_depth+1} = t'_{time_depth + 1}
-    | ...
-    | t_{dim_sctr} = t'_{dim_sctr}.  */
+/* Set STRIDE to the stride of PDR in memory by advancing by one in
+   the loop at DEPTH.  */
 
 static void
-build_partial_difference (ppl_Pointset_Powerset_C_Polyhedron_t *p,
-                          ppl_dimension_type time_depth,
-                          ppl_dimension_type offset,
-                          ppl_dimension_type dim_sctr)
+pdr_stride_in_loop (mpz_t stride, graphite_dim_t depth, poly_dr_p pdr)
 {
-  ppl_Constraint_t new_cstr;
-  ppl_Linear_Expression_t le;
-  ppl_dimension_type i;
-  ppl_dimension_type dim;
-  ppl_Pointset_Powerset_C_Polyhedron_t temp;
+  poly_bb_p pbb = PDR_PBB (pdr);
+  isl_map *map;
+  isl_set *set;
+  isl_aff *aff;
+  isl_space *dc;
+  isl_constraint *lma, *c;
+  isl_int islstride;
+  graphite_dim_t time_depth;
+  unsigned offset, nt;
+  unsigned i;
+  /* XXX isl rewrite following comments.  */
+  /* Builds a partial difference equations and inserts them
+     into pointset powerset polyhedron P.  Polyhedron is assumed
+     to have the format: T|I|T'|I'|G|S|S'|l1|l2.
+
+     TIME_DEPTH is the time dimension w.r.t. which we are
+     differentiating.
+     OFFSET represents the number of dimensions between
+     columns t_{time_depth} and t'_{time_depth}.
+     DIM_SCTR is the number of scattering dimensions.  It is
+     essentially the dimensionality of the T vector.
+
+     The following equations are inserted into the polyhedron P:
+     | t_1 = t_1'
+     | ...
+     | t_{time_depth-1} = t'_{time_depth-1}
+     | t_{time_depth} = t'_{time_depth} + 1
+     | t_{time_depth+1} = t'_{time_depth + 1}
+     | ...
+     | t_{dim_sctr} = t'_{dim_sctr}.  */
 
   /* Add the equality: t_{time_depth} = t'_{time_depth} + 1.
      This is the core part of this alogrithm, since this
      constraint asks for the memory access stride (difference)
      between two consecutive points in time dimensions.  */
 
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (*p, &dim);
-  ppl_new_Linear_Expression_with_dimension (&le, dim);
-  ppl_set_coef (le, time_depth, 1);
-  ppl_set_coef (le, time_depth + offset, -1);
-  ppl_set_inhomogeneous (le, 1);
-  ppl_new_Constraint (&new_cstr, le, PPL_CONSTRAINT_TYPE_EQUAL);
-  ppl_Pointset_Powerset_C_Polyhedron_add_constraint (*p, new_cstr);
-  ppl_delete_Linear_Expression (le);
-  ppl_delete_Constraint (new_cstr);
-
   /* Add equalities:
      | t1 = t1'
      | ...
@@ -149,156 +163,80 @@  build_partial_difference (ppl_Pointset_Powerset_C_Polyhedron_t *p,
      is stripmined dimension, and the other dimension corresponds
      to the point loop inside stripmined dimension.  */
 
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron (&temp, *p);
-
-  for (i = 0; i < dim_sctr; i++)
-    if (i != time_depth)
-      {
-        ppl_new_Linear_Expression_with_dimension (&le, dim);
-        ppl_set_coef (le, i, 1);
-        ppl_set_coef (le, i + offset, -1);
-        ppl_new_Constraint (&new_cstr, le, PPL_CONSTRAINT_TYPE_EQUAL);
-        ppl_Pointset_Powerset_C_Polyhedron_add_constraint (temp, new_cstr);
-
-        if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (temp))
-          {
-            ppl_delete_Pointset_Powerset_C_Polyhedron (temp);
-            ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron (&temp, *p);
-          }
-        else
-          ppl_Pointset_Powerset_C_Polyhedron_add_constraint (*p, new_cstr);
-        ppl_delete_Linear_Expression (le);
-        ppl_delete_Constraint (new_cstr);
-      }
+  /* pdr->accesses:    [P1..nb_param,I1..nb_domain]->[a,S1..nb_subscript]
+          ??? [P] not used for PDRs?
+     pdr->extent:      [a,S1..nb_subscript]
+     pbb->domain:      [P1..nb_param,I1..nb_domain]
+     pbb->transformed: [P1..nb_param,I1..nb_domain]->[T1..Tnb_sctr]
+          [T] includes local vars (currently unused)
+     
+     First we create [P,I] -> [T,a,S].  */
+  
+  map = isl_map_flat_range_product (isl_map_copy (pbb->transformed),
+				    isl_map_copy (pdr->accesses));
+  /* Add a dimension for L: [P,I] -> [T,a,S,L].*/
+  map = isl_map_add_dims (map, isl_dim_out, 1);
+  /* Build a constraint for "lma[S] - L == 0", effectively calculating
+     L in terms of subscripts.  */
+  lma = build_linearized_memory_access (map, pdr);
+  /* And add it to the map, so we now have:
+     [P,I] -> [T,a,S,L] : lma([S]) == L.  */
+  map = isl_map_add_constraint (map, lma);
 
-  ppl_delete_Pointset_Powerset_C_Polyhedron (temp);
-}
-
-
-/* Set STRIDE to the stride of PDR in memory by advancing by one in
-   the loop at DEPTH.  */
-
-static void
-pdr_stride_in_loop (mpz_t stride, graphite_dim_t depth, poly_dr_p pdr)
-{
-  ppl_dimension_type time_depth;
-  ppl_Linear_Expression_t le, lma;
-  ppl_Constraint_t new_cstr;
-  ppl_dimension_type i, *map;
-  ppl_Pointset_Powerset_C_Polyhedron_t p1, p2, sctr;
-  graphite_dim_t nb_subscripts = PDR_NB_SUBSCRIPTS (pdr) + 1;
-  poly_bb_p pbb = PDR_PBB (pdr);
-  ppl_dimension_type offset = pbb_nb_scattering_transform (pbb)
-                              + pbb_nb_local_vars (pbb)
-                              + pbb_dim_iter_domain (pbb);
-  ppl_dimension_type offsetg = offset + pbb_nb_params (pbb);
-  ppl_dimension_type dim_sctr = pbb_nb_scattering_transform (pbb)
-                                + pbb_nb_local_vars (pbb);
-  ppl_dimension_type dim_L1 = offset + offsetg + 2 * nb_subscripts;
-  ppl_dimension_type dim_L2 = offset + offsetg + 2 * nb_subscripts + 1;
-  ppl_dimension_type new_dim = offset + offsetg + 2 * nb_subscripts + 2;
-
-  /* The resulting polyhedron should have the following format:
-     T|I|T'|I'|G|S|S'|l1|l2
-     where:
-     | T = t_1..t_{dim_sctr}
-     | I = i_1..i_{dim_iter_domain}
-     | T'= t'_1..t'_{dim_sctr}
-     | I'= i'_1..i'_{dim_iter_domain}
-     | G = g_1..g_{nb_params}
-     | S = s_1..s_{nb_subscripts}
-     | S'= s'_1..s'_{nb_subscripts}
-     | l1 and l2 are scalars.
-
-     Some invariants:
-     offset = dim_sctr + dim_iter_domain + nb_local_vars
-     offsetg = dim_sctr + dim_iter_domain + nb_local_vars + nb_params.  */
-
-  /* Construct the T|I|0|0|G|0|0|0|0 part.  */
-  {
-    ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
-      (&sctr, PBB_TRANSFORMED_SCATTERING (pbb));
-    ppl_Pointset_Powerset_C_Polyhedron_add_space_dimensions_and_embed
-      (sctr, 2 * nb_subscripts + 2);
-    ppl_insert_dimensions_pointset (sctr, offset, offset);
-  }
-
-  /* Construct the 0|I|0|0|G|S|0|0|0 part.  */
-  {
-    ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-      (&p1, PDR_ACCESSES (pdr));
-    ppl_Pointset_Powerset_C_Polyhedron_add_space_dimensions_and_embed
-      (p1, nb_subscripts + 2);
-    ppl_insert_dimensions_pointset (p1, 0, dim_sctr);
-    ppl_insert_dimensions_pointset (p1, offset, offset);
-  }
-
-  /* Construct the 0|0|0|0|0|S|0|l1|0 part.  */
-  {
-    lma = build_linearized_memory_access (offset + dim_sctr, pdr);
-    ppl_set_coef (lma, dim_L1, -1);
-    ppl_new_Constraint (&new_cstr, lma, PPL_CONSTRAINT_TYPE_EQUAL);
-    ppl_Pointset_Powerset_C_Polyhedron_add_constraint (p1, new_cstr);
-    ppl_delete_Linear_Expression (lma);
-    ppl_delete_Constraint (new_cstr);
-  }
-
-  /* Now intersect all the parts to get the polyhedron P1:
-     T|I|0|0|G|0|0|0 |0
-     0|I|0|0|G|S|0|0 |0
-     0|0|0|0|0|S|0|l1|0
-     ------------------
-     T|I|0|0|G|S|0|l1|0.  */
-
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (p1, sctr);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (sctr);
-
-  /* Build P2, which would have the following form:
-     0|0|T'|I'|G|0|S'|0|l2
-
-     P2 is built, by remapping the P1 polyhedron:
-     T|I|0|0|G|S|0|l1|0
-
-     using the following mapping:
-     T->T'
-     I->I'
-     S->S'
-     l1->l2.  */
-  {
-    ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-      (&p2, p1);
-
-    map = ppl_new_id_map (new_dim);
-
-    /* TI -> T'I'.  */
-    for (i = 0; i < offset; i++)
-      ppl_interchange (map, i, i + offset);
-
-    /* l1 -> l2.  */
-    ppl_interchange (map, dim_L1, dim_L2);
-
-    /* S -> S'.  */
-    for (i = 0; i < nb_subscripts; i++)
-      ppl_interchange (map, offset + offsetg + i,
-		       offset + offsetg + nb_subscripts + i);
-
-    ppl_Pointset_Powerset_C_Polyhedron_map_space_dimensions (p2, map, new_dim);
-    free (map);
-  }
+  /* Then we create  [P,I,P',I'] -> [T,a,S,L,T',a',S',L'].  */
+  map = isl_map_flat_product (map, isl_map_copy (map));
 
+  /* Now add the equality T[time_depth] == T'[time_depth]+1.  This will
+     force L' to be the linear address at T[time_depth] + 1. */
   time_depth = psct_dynamic_dim (pbb, depth);
+  /* Length of [a,S] plus [L] ...  */
+  offset = 1 + isl_map_dim (pdr->accesses, isl_dim_out);
+  /* ... plus [T].  */
+  offset += isl_map_dim (pbb->transformed, isl_dim_out);
 
-  /* P1 = P1 inter P2.  */
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (p1, p2);
-  build_partial_difference (&p1, time_depth, offset, dim_sctr);
+  c = isl_equality_alloc (isl_local_space_from_space (isl_map_get_space (map)));
+  c = isl_constraint_set_coefficient_si (c, isl_dim_out, time_depth, 1);
+  c = isl_constraint_set_coefficient_si (c, isl_dim_out,
+					 offset + time_depth, -1);
+  c = isl_constraint_set_constant_si (c, 1);
+  map = isl_map_add_constraint (map, c);
 
-  /* Maximise the expression L2 - L1.  */
-  {
-    ppl_new_Linear_Expression_with_dimension (&le, new_dim);
-    ppl_set_coef (le, dim_L2, 1);
-    ppl_set_coef (le, dim_L1, -1);
-    ppl_max_for_le_pointset (p1, le, stride);
-  }
+  /* Now we equate most of the T/T' elements (making PITaSL nearly
+     the same is (PITaSL)', except for one dimension, namely for 'depth'
+     (an index into [I]), after translating to index into [T].  Take care
+     to not produce an empty map, which indicates we wanted to equate
+     two dimensions that are already coupled via the above time_depth
+     dimension.  Happens with strip mining where several scatter dimension
+     are interdependend.  */
+  /* Length of [T].  */
+  nt = pbb_nb_scattering_transform (pbb) + pbb_nb_local_vars (pbb);
+  for (i = 0; i < nt; i++)
+    if (i != time_depth)
+      {
+	isl_map *temp = isl_map_equate (isl_map_copy (map),
+					isl_dim_out, i,
+					isl_dim_out, offset + i);
+	if (isl_map_is_empty (temp))
+	  isl_map_free (temp);
+	else
+	  {
+	    isl_map_free (map);
+	    map = temp;
+	  }
+      }
+
+  /* Now maximize the expression L' - L.  */
+  set = isl_map_range (map);
+  dc = isl_set_get_space (set);
+  aff = isl_aff_zero_on_domain (isl_local_space_from_space (dc));
+  aff = isl_aff_set_coefficient_si (aff, isl_dim_in, offset - 1, -1);
+  aff = isl_aff_set_coefficient_si (aff, isl_dim_in, offset + offset - 1, 1);
+  isl_int_init (islstride);
+  isl_set_max (set, aff, &islstride);
+  isl_int_get_gmp (islstride, stride);
+  isl_int_clear (islstride);
+  isl_aff_free (aff);
+  isl_set_free (set);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
@@ -312,13 +250,8 @@  pdr_stride_in_loop (mpz_t stride, graphite_dim_t depth, poly_dr_p pdr)
       mp_get_memory_functions (NULL, NULL, &gmp_free);
       (*gmp_free) (str, strlen (str) + 1);
     }
-
-  ppl_delete_Pointset_Powerset_C_Polyhedron (p1);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (p2);
-  ppl_delete_Linear_Expression (le);
 }
 
-
 /* Sets STRIDES to the sum of all the strides of the data references
    accessed in LOOP at DEPTH.  */
 
@@ -475,23 +408,23 @@  static void
 pbb_interchange_loop_depths (graphite_dim_t depth1, graphite_dim_t depth2,
 			     poly_bb_p pbb)
 {
-  ppl_dimension_type i, dim;
-  ppl_dimension_type *map;
-  ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb);
-  ppl_dimension_type dim1 = psct_dynamic_dim (pbb, depth1);
-  ppl_dimension_type dim2 = psct_dynamic_dim (pbb, depth2);
-
-  ppl_Polyhedron_space_dimension (poly, &dim);
-  map = (ppl_dimension_type *) XNEWVEC (ppl_dimension_type, dim);
+  unsigned i;
+  unsigned dim1 = psct_dynamic_dim (pbb, depth1);
+  unsigned dim2 = psct_dynamic_dim (pbb, depth2);
+  isl_space *d = isl_map_get_space (pbb->transformed);
+  isl_space *d1 = isl_space_range (d);
+  unsigned n = isl_space_dim (d1, isl_dim_out);
+  isl_space *d2 = isl_space_add_dims (d1, isl_dim_in, n);
+  isl_map *x = isl_map_universe (d2);
 
-  for (i = 0; i < dim; i++)
-    map[i] = i;
+  x = isl_map_equate (x, isl_dim_in, dim1, isl_dim_out, dim2);
+  x = isl_map_equate (x, isl_dim_in, dim2, isl_dim_out, dim1);
 
-  map[dim1] = dim2;
-  map[dim2] = dim1;
+  for (i = 0; i < n; i++)
+    if (i != dim1 && i != dim2)
+      x = isl_map_equate (x, isl_dim_in, i, isl_dim_out, i);
 
-  ppl_Polyhedron_map_space_dimensions (poly, map, dim);
-  free (map);
+  pbb->transformed = isl_map_apply_range (pbb->transformed, x);
 }
 
 /* Apply the interchange of loops at depths DEPTH1 and DEPTH2 to all
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index 9f3ba1d..e3563a2 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -1,5 +1,5 @@ 
 /* Graphite polyhedral representation.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Tobias Grosser <grosser@fim.uni-passau.de>.
 
@@ -18,7 +18,20 @@  GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
+
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <isl/constraint.h>
+#include <isl/ilp.h>
+#include <isl/aff.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h"
@@ -32,14 +45,24 @@  along with GCC; see the file COPYING3.  If not see
 #include "sese.h"
 
 #ifdef HAVE_cloog
-#include "ppl_c.h"
-#include "graphite-ppl.h"
 #include "graphite-poly.h"
-#include "graphite-dependences.h"
-#include "graphite-cloog-util.h"
 
 #define OPENSCOP_MAX_STRING 256
 
+
+/* Print to STDERR the GMP value VAL.  */
+
+DEBUG_FUNCTION void
+debug_gmp_value (mpz_t val)
+{
+  char *str = mpz_get_str (0, 10, val);
+  void (*gmp_free) (void *, size_t);
+
+  fprintf (stderr, "%s", str);
+  mp_get_memory_functions (NULL, NULL, &gmp_free);
+  (*gmp_free) (str, strlen (str) + 1);
+}
+
 /* Return the maximal loop depth in SCOP.  */
 
 int
@@ -59,223 +82,6 @@  scop_max_loop_depth (scop_p scop)
   return max_nb_loops;
 }
 
-/* Extend the scattering matrix of PBB to MAX_SCATTERING scattering
-   dimensions.  */
-
-static void
-extend_scattering (poly_bb_p pbb, int max_scattering)
-{
-  ppl_dimension_type nb_old_dims, nb_new_dims;
-  int nb_added_dims, i;
-  ppl_Coefficient_t coef;
-  mpz_t one;
-
-  nb_added_dims = max_scattering - pbb_nb_scattering_transform (pbb);
-  mpz_init (one);
-  mpz_set_si (one, 1);
-  ppl_new_Coefficient (&coef);
-  ppl_assign_Coefficient_from_mpz_t (coef, one);
-
-  gcc_assert (nb_added_dims >= 0);
-
-  nb_old_dims = pbb_nb_scattering_transform (pbb) + pbb_dim_iter_domain (pbb)
-    + scop_nb_params (PBB_SCOP (pbb));
-  nb_new_dims = nb_old_dims + nb_added_dims;
-
-  ppl_insert_dimensions (PBB_TRANSFORMED_SCATTERING (pbb),
-			 pbb_nb_scattering_transform (pbb), nb_added_dims);
-  PBB_NB_SCATTERING_TRANSFORM (pbb) += nb_added_dims;
-
-  /* Add identity matrix for the added dimensions.  */
-  for (i = max_scattering - nb_added_dims; i < max_scattering; i++)
-    {
-      ppl_Constraint_t cstr;
-      ppl_Linear_Expression_t expr;
-
-      ppl_new_Linear_Expression_with_dimension (&expr, nb_new_dims);
-      ppl_Linear_Expression_add_to_coefficient (expr, i, coef);
-      ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
-      ppl_Polyhedron_add_constraint (PBB_TRANSFORMED_SCATTERING (pbb), cstr);
-      ppl_delete_Constraint (cstr);
-      ppl_delete_Linear_Expression (expr);
-    }
-
-  ppl_delete_Coefficient (coef);
-  mpz_clear (one);
-}
-
-/* All scattering matrices in SCOP will have the same number of scattering
-   dimensions.  */
-
-int
-unify_scattering_dimensions (scop_p scop)
-{
-  int i;
-  poly_bb_p pbb;
-  graphite_dim_t max_scattering = 0;
-
-  FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
-    max_scattering = MAX (pbb_nb_scattering_transform (pbb), max_scattering);
-
-  FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
-    extend_scattering (pbb, max_scattering);
-
-  return max_scattering;
-}
-
-/* Print to FILE the pdr PH in OpenScop format.  NB_SUBSCRIPTS is the number
-   of subscripts in PH, ALIAS_SET_DIM is the dimension of the alias set and
-   NB_PARAMS is the number of parameters in PH.  */
-
-static void
-openscop_print_pdr_polyhedron (FILE *file, ppl_const_Polyhedron_t ph,
-			       int nb_subscripts, int alias_set_dimension,
-			       int nb_params)
-{
-  int input, locals, output;
-  ppl_dimension_type alias_set_dim = (ppl_dimension_type) alias_set_dimension;
-  ppl_dimension_type sub_dim_last = alias_set_dim + nb_subscripts;
-  ppl_dimension_type *map, i, ph_space_dim = sub_dim_last + 1;
-  ppl_Polyhedron_t pph;
-
-  ppl_new_C_Polyhedron_from_C_Polyhedron (&pph, ph);
-
-  map = (ppl_dimension_type *) XNEWVEC (ppl_dimension_type, ph_space_dim);
-
-  for (i = 0; i < alias_set_dim - 1; i++)
-    map[i] = nb_subscripts + 1 + i;
-
-  for (i = alias_set_dim - 1; i < sub_dim_last; i++)
-    map[i] = i - alias_set_dim + 1;
-
-  ppl_Polyhedron_map_space_dimensions (pph, map, ph_space_dim - 1);
-
-  locals = 0;
-  input = alias_set_dim - nb_params - 1;
-
-  /* According to OpenScop specification, the alias set column is a part of
-     the output columns.  */
-  output = nb_subscripts + 1;
-
-  openscop_print_polyhedron_matrix (file, pph, output, input, locals, nb_params);
-}
-
-/* Print to FILE the powerset PDR.  NB_SUBSCRIPTS is the number of subscripts
-   in PDR, ALIAS_SET_DIM is the dimension of the alias set in PDR and
-   NB_PARAMS is the number of parameters in PDR.  */
-
-static void
-openscop_print_pdr_powerset (FILE *file,
-			     ppl_Pointset_Powerset_C_Polyhedron_t ps,
-			     int nb_subscripts,
-			     int alias_set_dim,
-			     int nb_params)
-{
-  size_t nb_disjuncts;
-  ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end;
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&it);
-  ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&end);
-
-  ppl_Pointset_Powerset_C_Polyhedron_size (ps, &nb_disjuncts);
-  fprintf (file, "%d\n", (int) nb_disjuncts);
-
-  for (ppl_Pointset_Powerset_C_Polyhedron_iterator_begin (ps, it),
-       ppl_Pointset_Powerset_C_Polyhedron_iterator_end (ps, end);
-       !ppl_Pointset_Powerset_C_Polyhedron_iterator_equal_test (it, end);
-       ppl_Pointset_Powerset_C_Polyhedron_iterator_increment (it))
-    {
-      ppl_const_Polyhedron_t ph;
-
-      ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph);
-      openscop_print_pdr_polyhedron (file, ph, nb_subscripts, alias_set_dim,
-				     nb_params);
-    }
-
-  ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (it);
-  ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (end);
-}
-
-/* Print to FILE the powerset PS in its OpenScop matrix form.  */
-
-static void
-openscop_print_powerset_matrix (FILE *file,
-				ppl_Pointset_Powerset_C_Polyhedron_t ps,
-				int output, int input, int locals,
-				int params)
-{
-  size_t nb_disjuncts;
-  ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end;
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&it);
-  ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&end);
-
-  ppl_Pointset_Powerset_C_Polyhedron_size (ps, &nb_disjuncts);
-  fprintf (file, "%d\n", (int) nb_disjuncts);
-
-  for (ppl_Pointset_Powerset_C_Polyhedron_iterator_begin (ps, it),
-       ppl_Pointset_Powerset_C_Polyhedron_iterator_end (ps, end);
-       !ppl_Pointset_Powerset_C_Polyhedron_iterator_equal_test (it, end);
-       ppl_Pointset_Powerset_C_Polyhedron_iterator_increment (it))
-    {
-      ppl_const_Polyhedron_t ph;
-
-      ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph);
-      openscop_print_polyhedron_matrix (file, ph, output, input, locals,
-				        params);
-    }
-
-  ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (it);
-  ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (end);
-}
-
-/* Prints to FILE the scattering function of PBB in OpenScop format, at some
-   VERBOSITY level.  */
-
-static void
-openscop_print_scattering_function_1 (FILE *file, poly_bb_p pbb, int verbosity)
-{
-  graphite_dim_t i;
-  ppl_const_Polyhedron_t ph;
-
-  if (verbosity > 0)
-    {
-      fprintf (file, "# scattering bb_%d (\n", pbb_index (pbb));
-      fprintf (file, "#eq");
-
-      for (i = 0; i < pbb_nb_scattering_transform (pbb); i++)
-	fprintf (file, "     s%d", (int) i);
-
-      for (i = 0; i < pbb_nb_local_vars (pbb); i++)
-	fprintf (file, "    lv%d", (int) i);
-
-      for (i = 0; i < pbb_dim_iter_domain (pbb); i++)
-	fprintf (file, "     i%d", (int) i);
-
-      for (i = 0; i < pbb_nb_params (pbb); i++)
-	fprintf (file, "     p%d", (int) i);
-
-      fprintf (file, "    cst\n");
-    }
-
-  /* Number of disjunct components.  Remove this when
-     PBB_TRANSFORMED_SCATTERING will be a pointset_powerset.  */
-  fprintf (file, "1\n");
-
-  ph = PBB_TRANSFORMED_SCATTERING (pbb)
-    ? PBB_TRANSFORMED_SCATTERING (pbb)
-    : PBB_ORIGINAL_SCATTERING (pbb);
-
-  openscop_print_polyhedron_matrix (file, ph,
-				    pbb_nb_scattering_transform (pbb),
-				    pbb_dim_iter_domain (pbb),
-				    pbb_nb_local_vars (pbb),
-				    pbb_nb_params (pbb));
-
-  if (verbosity > 0)
-    fprintf (file, "#)\n");
-}
-
 /* Prints to FILE the scattering function of PBB, at some VERBOSITY
    level.  */
 
@@ -304,12 +110,8 @@  print_scattering_function_1 (FILE *file, poly_bb_p pbb, int verbosity)
       fprintf (file, "    cst\n");
     }
 
-  /* Number of disjunct components.  Remove this when
-     PBB_TRANSFORMED_SCATTERING will be a pointset_powerset.  */
-  fprintf (file, "1\n");
-  ppl_print_polyhedron_matrix (file, PBB_TRANSFORMED_SCATTERING (pbb)
-			       ? PBB_TRANSFORMED_SCATTERING (pbb)
-			       : PBB_ORIGINAL_SCATTERING (pbb));
+  fprintf (file, "isl\n");
+  print_isl_map (file, pbb->transformed ? pbb->transformed : pbb->schedule);
 
   if (verbosity > 0)
     fprintf (file, "#)\n");
@@ -324,8 +126,7 @@  print_scattering_function (FILE *file, poly_bb_p pbb, int verbosity)
   if (!PBB_TRANSFORMED (pbb))
     return;
 
-  if (PBB_TRANSFORMED_SCATTERING (pbb)
-      || PBB_ORIGINAL_SCATTERING (pbb))
+  if (pbb->schedule || pbb->transformed)
     {
       if (verbosity > 0)
 	fprintf (file, "# Scattering function is provided\n");
@@ -341,7 +142,7 @@  print_scattering_function (FILE *file, poly_bb_p pbb, int verbosity)
       return;
     }
 
-  openscop_print_scattering_function_1 (file, pbb, verbosity);
+  print_scattering_function_1 (file, pbb, verbosity);
 
   if (verbosity > 0)
     fprintf (file, "# Scattering names are not provided\n");
@@ -420,334 +221,12 @@  debug_iteration_domains (scop_p scop, int verbosity)
   print_iteration_domains (stderr, scop, verbosity);
 }
 
-/* Read N integer from FILE.  */
-
-int *
-openscop_read_N_int (FILE *file, int N)
-{
-  char s[OPENSCOP_MAX_STRING];
-  char *str;
-  int i, *res = (int *) xmalloc (OPENSCOP_MAX_STRING * sizeof (int));
-
-  /* Skip blank and commented lines.  */
-  while (fgets (s, sizeof s, file) == (char *) 0
-	 || s[0] == '#'
-	 || ISSPACE (s[0]))
-    ;
-
-  str = s;
-
-  for (i = 0; i < N; i++)
-    {
-      sscanf (str, "%d", &res[i]);
-
-      /* Jump the integer that was read.  */
-      while ((*str) && !ISSPACE (*str) && (*str != '#'))
-	str++;
-
-      /* Jump spaces.  */
-      while ((*str) && ISSPACE (*str) && (*str != '#'))
-	str++;
-    }
-
-  return res;
-}
-
-/* Read one integer from FILE.  */
-
-static int
-openscop_read_one_int (FILE *file)
-{
-  int *x = openscop_read_N_int (file, 1);
-  int res = *x;
-
-  free (x);
-  return res;
-}
-
-/* Read N string from FILE.  */
-
-static char *
-openscop_read_N_string (FILE *file, int N)
-{
-  int count, i;
-  char str[OPENSCOP_MAX_STRING];
-  char *tmp = (char *) xmalloc (sizeof (char) * OPENSCOP_MAX_STRING);
-  char *s = NULL;
-
-  /* Skip blank and commented lines.  */
-  while (fgets (str, sizeof str, file) == (char *) 0
-	 || str[0] == '#'
-	 || ISSPACE (str[0]))
-    ;
-
-  s = str;
-  count = 0;
-
-  for (i = 0; i < N; i++)
-    {
-      /* Read the first word.  */
-      for (; (*s) && (!ISSPACE (*s)) && (*s != '#'); ++count)
-        tmp[count] = *(s++);
-
-      tmp[count] = ' ';
-      count++;
-
-      /* Jump spaces.  */
-      while ((*s) && ISSPACE (*s) && (*s != '#'))
-	s++;
-    }
-
-  tmp[count-1] = '\0';
-
-  return tmp;
-}
-
-/* Read one string from FILE.  */
-
-static char *
-openscop_read_one_string (FILE *file)
-{
-  return openscop_read_N_string (file, 1);
-}
-
-/* Read from FILE the powerset PS in its OpenScop matrix form.  OUTPUT is the
-   number of output dimensions, INPUT is the number of input dimensions,
-   LOCALS is the number of existentially quantified variables and PARAMS is
-   the number of parameters.  */
-
-static void
-openscop_read_powerset_matrix (FILE *file,
-			       ppl_Pointset_Powerset_C_Polyhedron_t *ps,
-			       int *output, int *input, int *locals,
-			       int *params)
-{
-  int nb_disjuncts, i;
-
-  nb_disjuncts = openscop_read_one_int (file);
-
-  for (i = 0; i < nb_disjuncts; i++)
-    {
-      ppl_Polyhedron_t ph;
-
-      openscop_read_polyhedron_matrix (file, &ph, output, input, locals,
-				       params);
-      if (!ph)
-        *ps = NULL;
-      else if (i == 0)
-        ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (ps, ph);
-      else
-        ppl_Pointset_Powerset_C_Polyhedron_add_disjunct (*ps, ph);
-    }
-}
-
-/* Read a scattering function from FILE and save it to PBB.  Return whether
-   the scattering function was provided or not.  */
-
-static bool
-graphite_read_scatt (FILE *file, poly_bb_p pbb)
-{
-  bool scattering_provided = false;
-  int output, input, locals, params;
-  ppl_Polyhedron_t newp;
-
-  if (openscop_read_one_int (file) > 0)
-    {
-      /* Read number of disjunct components.  */
-      openscop_read_one_int (file);
-
-      /* Read scattering function.  */
-      openscop_read_polyhedron_matrix (file, &newp, &output, &input,
-				       &locals, &params);
-      store_scattering (PBB_SCOP (pbb));
-      PBB_TRANSFORMED (pbb) = poly_scattering_new ();
-      PBB_TRANSFORMED_SCATTERING (pbb) = newp;
-      PBB_NB_LOCAL_VARIABLES (pbb) = locals;
-
-      /* New scattering dimension.  */
-      PBB_NB_SCATTERING_TRANSFORM (pbb) = output;
-
-      scattering_provided = true;
-    }
-
-  return scattering_provided;
-}
-
-/* Read a scop file.  Return true if the scop is transformed.  */
-
-static bool
-graphite_read_scop_file (FILE *file, scop_p scop)
-{
-  char *tmp, *language;
-  size_t i, j, nb_statements, nbr, nbw;
-  int input, output, locals, params;
-  ppl_Pointset_Powerset_C_Polyhedron_t ps;
-  poly_bb_p pbb;
-  bool transform_done = false;
-
-  /* Ensure that the file is in OpenScop format.  */
-  tmp = openscop_read_N_string (file, 2);
-
-  if (strcmp (tmp, "SCoP 1"))
-    {
-      error ("the file is not in OpenScop format");
-      return false;
-    }
-
-  free (tmp);
-
-  /* Read the language.  */
-  language = openscop_read_one_string (file);
-
-  if (strcmp (language, "Gimple"))
-    {
-      error ("the language is not recognized");
-      return false;
-    }
-
-  free (language);
-
-  /* Read the context but do not use it.  */
-  openscop_read_powerset_matrix (file, &ps, &input, &output, &locals, &params);
-
-  if ((size_t) params != scop->nb_params)
-    {
-      error ("parameters number in the scop file is different from the"
-	     " internal scop parameter number");
-      return false;
-    }
-
-  /* Read parameter names if provided.  */
-  if (openscop_read_one_int (file))
-    openscop_read_N_string (file, scop->nb_params);
-
-  nb_statements = openscop_read_one_int (file);
-
-  if (nb_statements != VEC_length (poly_bb_p, SCOP_BBS (scop)))
-    {
-      error ("number of statements in the OpenScop file does not match"
-	     " the graphite internal statements number");
-      return false;
-    }
-
-  for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
-    {
-      /* Read iteration domain.  */
-      openscop_read_powerset_matrix (file, &ps, &input, &output, &locals,
-				     &params);
-
-      /* Read scattering.  */
-      transform_done = graphite_read_scatt (file, pbb);
-
-      /* Scattering names.  */
-      openscop_read_one_int (file);
-
-      /* Read access functions.  */
-      if (openscop_read_one_int (file) > 0)
-	{
-	  nbr = openscop_read_one_int (file);
-
-	  /* Read access functions.  */
-	  for (j = 0; j < nbr; j++)
-	    openscop_read_powerset_matrix (file, &ps, &input, &output, &locals,
-					   &params);
-
-	  nbw = openscop_read_one_int (file);
-
-	  /* Write access functions.  */
-	  for (j = 0; j < nbw; j++)
-	    openscop_read_powerset_matrix (file, &ps, &input, &output, &locals,
-					   &params);
-	}
-
-      /* Statement body.  */
-      openscop_read_one_int (file);
-    }
-
-  return transform_done;
-}
-
-/* Initialize and return a file that will be used to write a scop.  SCOP_NUMBER
-   is a sequential number (identifier) used to differentiate scop files.
-   Examples of the generated file names: dump_base_name.0.graphite,
-   dump_base_name.1.graphite, dump_base_name.2.graphite, etc.  */
-
-static FILE *
-init_graphite_out_file (int scop_number)
-{
-  FILE *graphite_out_file;
-  int len = strlen (dump_base_name);
-  char *dumpname = XNEWVEC (char, len + 25);
-  char *s_scop_number = XNEWVEC (char, 15);
-
-  memcpy (dumpname, dump_base_name, len + 1);
-  strip_off_ending (dumpname, len);
-  sprintf (s_scop_number, ".%d", scop_number);
-  strcat (dumpname, s_scop_number);
-  strcat (dumpname, ".graphite");
-  graphite_out_file = fopen (dumpname, "w+b");
-
-  if (graphite_out_file == 0)
-    fatal_error ("can%'t open %s for writing: %m", dumpname);
-
-  free (dumpname);
-
-  return graphite_out_file;
-}
-
-/* Open and return a file used for scop reading.  SCOP_NUMBER is a sequential
-   number (identifier) used to differentiate scop files.  Examples of the
-   generated file names: dump_base_name.0.graphite, dump_base_name.1.graphite,
-   dump_base_name.2.graphite, etc.  */
-
-static FILE *
-init_graphite_in_file (int scop_number)
-{
-  FILE *graphite_in_file;
-  int len = strlen (dump_base_name);
-  char *dumpname = XNEWVEC (char, len + 25);
-  char *s_scop_number = XNEWVEC (char, 15);
-
-  memcpy (dumpname, dump_base_name, len + 1);
-  strip_off_ending (dumpname, len);
-  sprintf (s_scop_number, ".%d", scop_number);
-  strcat (dumpname, s_scop_number);
-  strcat (dumpname, ".graphite");
-  graphite_in_file = fopen (dumpname, "r+b");
-
-  if (graphite_in_file == 0)
-    fatal_error ("can%'t open %s for reading: %m", dumpname);
-
-  free (dumpname);
-
-  return graphite_in_file;
-}
-
 /* Apply graphite transformations to all the basic blocks of SCOP.  */
 
 bool
 apply_poly_transforms (scop_p scop)
 {
   bool transform_done = false;
-  FILE *graphite_file;
-  static size_t file_scop_number = 0;
-
-  /* This feature is only enabled in the Graphite branch.  */
-  if (0)
-    {
-      graphite_file = init_graphite_in_file (file_scop_number);
-      transform_done |= graphite_read_scop_file (graphite_file, scop);
-
-      /* We cannot check for the legality of the transform here: there
-	 are cases where graphite_legal_transform cannot determine the
-	 dependence at compile time.  For an example, see the
-	 explanation of why http://gcc.gnu.org/PR45450 is invalid.  */
-      if (0 && !graphite_legal_transform (scop))
-	fatal_error ("the graphite file read for scop %d does not contain a legal transform",
-		     (int) file_scop_number);
-
-      file_scop_number++;
-    }
 
   /* Generate code even if we did not apply any real transformation.
      This also allows to check the performance for the identity
@@ -771,70 +250,17 @@  apply_poly_transforms (scop_p scop)
 	transform_done |= scop_do_interchange (scop);
     }
 
-  /* This feature is only enabled in the Graphite branch.  */
-  if (0)
-    {
-      graphite_file = init_graphite_out_file (file_scop_number);
-      print_scop (graphite_file, scop, 1);
-      file_scop_number++;
-    }
-
   return transform_done;
 }
 
-/* Returns true when it PDR1 is a duplicate of PDR2: same PBB, and
-   their ACCESSES, TYPE, and NB_SUBSCRIPTS are the same.  */
-
-static inline bool
-can_collapse_pdrs (poly_dr_p pdr1, poly_dr_p pdr2)
-{
-  bool res;
-  ppl_Pointset_Powerset_C_Polyhedron_t af1, af2, diff;
-
-  if (PDR_PBB (pdr1) != PDR_PBB (pdr2)
-      || PDR_NB_SUBSCRIPTS (pdr1) != PDR_NB_SUBSCRIPTS (pdr2)
-      || PDR_TYPE (pdr1) != PDR_TYPE (pdr2))
-    return false;
-
-  af1 = PDR_ACCESSES (pdr1);
-  af2 = PDR_ACCESSES (pdr2);
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-    (&diff, af1);
-  ppl_Pointset_Powerset_C_Polyhedron_difference_assign (diff, af2);
-
-  res = ppl_Pointset_Powerset_C_Polyhedron_is_empty (diff);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (diff);
-  return res;
-}
-
-/* Removes duplicated data references in PBB.  */
-
-void
-pbb_remove_duplicate_pdrs (poly_bb_p pbb)
-{
-  int i, j;
-  poly_dr_p pdr1, pdr2;
-
-  FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), i, pdr1)
-    for (j = i + 1; VEC_iterate (poly_dr_p, PBB_DRS (pbb), j, pdr2); j++)
-      if (can_collapse_pdrs (pdr1, pdr2))
-	{
-	  PDR_NB_REFS (pdr1) += PDR_NB_REFS (pdr2);
-	  free_poly_dr (pdr2);
-	  VEC_ordered_remove (poly_dr_p, PBB_DRS (pbb), j);
-	}
-
-  PBB_PDR_DUPLICATES_REMOVED (pbb) = true;
-}
-
 /* Create a new polyhedral data reference and add it to PBB.  It is
    defined by its ACCESSES, its TYPE, and the number of subscripts
    NB_SUBSCRIPTS.  */
 
 void
 new_poly_dr (poly_bb_p pbb, int dr_base_object_set,
-	     ppl_Pointset_Powerset_C_Polyhedron_t accesses,
-	     enum poly_dr_type type, void *cdr, graphite_dim_t nb_subscripts)
+	     enum poly_dr_type type, void *cdr, graphite_dim_t nb_subscripts,
+	     isl_map *acc, isl_set *extent)
 {
   static int id = 0;
   poly_dr_p pdr = XNEW (struct poly_dr);
@@ -843,7 +269,8 @@  new_poly_dr (poly_bb_p pbb, int dr_base_object_set,
   PDR_BASE_OBJECT_SET (pdr) = dr_base_object_set;
   PDR_NB_REFS (pdr) = 1;
   PDR_PBB (pdr) = pbb;
-  PDR_ACCESSES (pdr) = accesses;
+  pdr->accesses = acc;
+  pdr->extent = extent;
   PDR_TYPE (pdr) = type;
   PDR_CDR (pdr) = cdr;
   PDR_NB_SUBSCRIPTS (pdr) = nb_subscripts;
@@ -855,7 +282,8 @@  new_poly_dr (poly_bb_p pbb, int dr_base_object_set,
 void
 free_poly_dr (poly_dr_p pdr)
 {
-  ppl_delete_Pointset_Powerset_C_Polyhedron (PDR_ACCESSES (pdr));
+  isl_map_free (pdr->accesses);
+  isl_set_free (pdr->extent);
   XDELETE (pdr);
 }
 
@@ -866,7 +294,10 @@  new_poly_bb (scop_p scop, void *black_box)
 {
   poly_bb_p pbb = XNEW (struct poly_bb);
 
-  PBB_DOMAIN (pbb) = NULL;
+  pbb->domain = NULL;
+  pbb->schedule = NULL;
+  pbb->transformed = NULL;
+  pbb->saved = NULL;
   PBB_SCOP (pbb) = scop;
   pbb_set_black_box (pbb, black_box);
   PBB_TRANSFORMED (pbb) = NULL;
@@ -874,7 +305,6 @@  new_poly_bb (scop_p scop, void *black_box)
   PBB_ORIGINAL (pbb) = NULL;
   PBB_DRS (pbb) = VEC_alloc (poly_dr_p, heap, 3);
   PBB_IS_REDUCTION (pbb) = false;
-  PBB_PDR_DUPLICATES_REMOVED (pbb) = false;
   GBB_PBB ((gimple_bb_p) black_box) = pbb;
 
   return pbb;
@@ -888,16 +318,10 @@  free_poly_bb (poly_bb_p pbb)
   int i;
   poly_dr_p pdr;
 
-  ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
-
-  if (PBB_TRANSFORMED (pbb))
-    poly_scattering_free (PBB_TRANSFORMED (pbb));
-
-  if (PBB_SAVED (pbb))
-    poly_scattering_free (PBB_SAVED (pbb));
-
-  if (PBB_ORIGINAL (pbb))
-    poly_scattering_free (PBB_ORIGINAL (pbb));
+  isl_set_free (pbb->domain);
+  isl_map_free (pbb->schedule);
+  isl_map_free (pbb->transformed);
+  isl_map_free (pbb->saved);
 
   if (PBB_DRS (pbb))
     FOR_EACH_VEC_ELT (poly_dr_p, PBB_DRS (pbb), i, pdr)
@@ -934,8 +358,6 @@  print_pdr_access_layout (FILE *file, poly_bb_p pbb, poly_dr_p pdr)
 void
 print_pdr (FILE *file, poly_dr_p pdr, int verbosity)
 {
-  int alias_set_dim;
-
   if (verbosity > 1)
     {
       fprintf (file, "# pdr_%d (", PDR_ID (pdr));
@@ -967,13 +389,7 @@  print_pdr (FILE *file, poly_dr_p pdr, int verbosity)
       print_pdr_access_layout (file, PDR_PBB (pdr), pdr);
     }
 
-  alias_set_dim = pdr_alias_set_dim (pdr) + 1;
-
-  openscop_print_pdr_powerset (file,
-			       PDR_ACCESSES (pdr),
-			       PDR_NB_SUBSCRIPTS (pdr),
-			       alias_set_dim,
-			       pbb_nb_params (PDR_PBB (pdr)));
+  /* XXX isl dump accesses/subscripts */
 
   if (verbosity > 0)
     fprintf (file, "#)\n");
@@ -998,11 +414,21 @@  new_scop (void *region)
 {
   scop_p scop = XNEW (struct scop);
 
-  SCOP_CONTEXT (scop) = NULL;
+  scop->context = NULL;
+  scop->must_raw = NULL;
+  scop->may_raw = NULL;
+  scop->must_raw_no_source = NULL;
+  scop->may_raw_no_source = NULL;
+  scop->must_war = NULL;
+  scop->may_war = NULL;
+  scop->must_war_no_source = NULL;
+  scop->may_war_no_source = NULL;
+  scop->must_waw = NULL;
+  scop->may_waw = NULL;
+  scop->must_waw_no_source = NULL;
+  scop->may_waw_no_source = NULL;
   scop_set_region (scop, region);
   SCOP_BBS (scop) = VEC_alloc (poly_bb_p, heap, 3);
-  SCOP_ORIGINAL_PDDRS (scop) = htab_create (10, hash_poly_ddr_p,
-					    eq_poly_ddr_p, free_poly_ddr);
   SCOP_ORIGINAL_SCHEDULE (scop) = NULL;
   SCOP_TRANSFORMED_SCHEDULE (scop) = NULL;
   SCOP_SAVED_SCHEDULE (scop) = NULL;
@@ -1024,10 +450,19 @@  free_scop (scop_p scop)
 
   VEC_free (poly_bb_p, heap, SCOP_BBS (scop));
 
-  if (SCOP_CONTEXT (scop))
-    ppl_delete_Pointset_Powerset_C_Polyhedron (SCOP_CONTEXT (scop));
-
-  htab_delete (SCOP_ORIGINAL_PDDRS (scop));
+  isl_set_free (scop->context);
+  isl_union_map_free (scop->must_raw);
+  isl_union_map_free (scop->may_raw);
+  isl_union_map_free (scop->must_raw_no_source);
+  isl_union_map_free (scop->may_raw_no_source);
+  isl_union_map_free (scop->must_war);
+  isl_union_map_free (scop->may_war);
+  isl_union_map_free (scop->must_war_no_source);
+  isl_union_map_free (scop->may_war_no_source);
+  isl_union_map_free (scop->must_waw);
+  isl_union_map_free (scop->may_waw);
+  isl_union_map_free (scop->must_waw_no_source);
+  isl_union_map_free (scop->may_waw_no_source);
   free_lst (SCOP_ORIGINAL_SCHEDULE (scop));
   free_lst (SCOP_TRANSFORMED_SCHEDULE (scop));
   free_lst (SCOP_SAVED_SCHEDULE (scop));
@@ -1043,7 +478,7 @@  openscop_print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity)
   graphite_dim_t i;
   gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
 
-  if (!PBB_DOMAIN (pbb))
+  if (!pbb->domain)
     return;
 
   if (verbosity > 0)
@@ -1060,14 +495,7 @@  openscop_print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity)
       fprintf (file, "    cst\n");
     }
 
-  if (PBB_DOMAIN (pbb))
-    openscop_print_powerset_matrix (file, PBB_DOMAIN (pbb),
-				    pbb_dim_iter_domain (pbb),
-				    0,
-				    0,
-				    pbb_nb_params (pbb));
-  else
-    fprintf (file, "0\n");
+  fprintf (file, "XXX isl\n");
 
   if (verbosity > 0)
     fprintf (file, "#)\n");
@@ -1076,35 +504,9 @@  openscop_print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity)
 /* Print to FILE the domain of PBB, at some VERBOSITY level.  */
 
 void
-print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity)
+print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity ATTRIBUTE_UNUSED)
 {
-  graphite_dim_t i;
-  gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
-
-  if (!PBB_DOMAIN (pbb))
-    return;
-
-  if (verbosity > 0)
-    {
-      fprintf (file, "# Iteration domain of bb_%d (\n", GBB_BB (gbb)->index);
-      fprintf (file, "#  eq");
-
-      for (i = 0; i < pbb_dim_iter_domain (pbb); i++)
-	fprintf (file, "     i%d", (int) i);
-
-      for (i = 0; i < pbb_nb_params (pbb); i++)
-	fprintf (file, "     p%d", (int) i);
-
-      fprintf (file, "    cst\n");
-    }
-
-  if (PBB_DOMAIN (pbb))
-    ppl_print_powerset_matrix (file, PBB_DOMAIN (pbb));
-  else
-    fprintf (file, "0\n");
-
-  if (verbosity > 0)
-    fprintf (file, "#)\n");
+  print_isl_set (file, pbb->domain);
 }
 
 /* Dump the cases of a graphite basic block GBB on FILE.  */
@@ -1354,9 +756,9 @@  openscop_print_scop_context (FILE *file, scop_p scop, int verbosity)
       fprintf (file, "    cst\n");
     }
 
-  if (SCOP_CONTEXT (scop))
-    openscop_print_powerset_matrix (file, SCOP_CONTEXT (scop), 0, 0, 0,
-				    scop_nb_params (scop));
+  if (scop->context)
+    /* XXX isl print context */
+    fprintf (file, "XXX isl\n");
   else
     fprintf (file, "0 %d 0 0 0 %d\n", (int) scop_nb_params (scop) + 2,
 	     (int) scop_nb_params (scop));
@@ -1383,10 +785,10 @@  print_scop_context (FILE *file, scop_p scop, int verbosity)
       fprintf (file, "    cst\n");
     }
 
-  if (SCOP_CONTEXT (scop))
-    ppl_print_powerset_matrix (file, SCOP_CONTEXT (scop));
+  if (scop->context)
+    print_isl_set (file, scop->context);
   else
-    fprintf (file, "0 %d\n", (int) scop_nb_params (scop) + 2);
+    fprintf (file, "no isl context %d\n", (int) scop_nb_params (scop) + 2);
 
   if (verbosity > 0)
     fprintf (file, "# )\n");
@@ -1476,13 +878,10 @@  print_cloog (FILE *file, scop_p scop, int verbosity)
     fprintf (file, "# Number of scattering functions\n");
 
   fprintf (file, "%d\n", VEC_length (poly_bb_p, SCOP_BBS (scop)));
-  unify_scattering_dimensions (scop);
 
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
     {
-      if (!PBB_TRANSFORMED (pbb)
-	  || !(PBB_TRANSFORMED_SCATTERING (pbb)
-	       || PBB_ORIGINAL_SCATTERING (pbb)))
+      if (!(pbb->transformed || pbb->schedule))
 	continue;
 
       if (verbosity > 1)
@@ -1554,66 +953,61 @@  debug_scop_params (scop_p scop, int verbosity)
   print_scop_params (stderr, scop, verbosity);
 }
 
-
-/* The dimension in the transformed scattering polyhedron of PBB
-   containing the scattering iterator for the loop at depth LOOP_DEPTH.  */
-
-ppl_dimension_type
-psct_scattering_dim_for_loop_depth (poly_bb_p pbb, graphite_dim_t loop_depth)
+extern isl_ctx *the_isl_ctx;
+void
+print_isl_set (FILE *f, isl_set *set)
 {
-  ppl_const_Constraint_System_t pcs;
-  ppl_Constraint_System_const_iterator_t cit, cend;
-  ppl_const_Constraint_t cstr;
-  ppl_Polyhedron_t ph = PBB_TRANSFORMED_SCATTERING (pbb);
-  ppl_dimension_type iter = psct_iterator_dim (pbb, loop_depth);
-  ppl_Linear_Expression_t expr;
-  ppl_Coefficient_t coef;
-  mpz_t val;
-  graphite_dim_t i;
-
-  mpz_init (val);
-  ppl_new_Coefficient (&coef);
-  ppl_Polyhedron_get_constraints (ph, &pcs);
-  ppl_new_Constraint_System_const_iterator (&cit);
-  ppl_new_Constraint_System_const_iterator (&cend);
+  isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
+  p = isl_printer_print_set (p, set);
+  isl_printer_free (p);
+}
 
-  for (ppl_Constraint_System_begin (pcs, cit),
-	 ppl_Constraint_System_end (pcs, cend);
-       !ppl_Constraint_System_const_iterator_equal_test (cit, cend);
-       ppl_Constraint_System_const_iterator_increment (cit))
-    {
-      ppl_Constraint_System_const_iterator_dereference (cit, &cstr);
-      ppl_new_Linear_Expression_from_Constraint (&expr, cstr);
-      ppl_Linear_Expression_coefficient (expr, iter, coef);
-      ppl_Coefficient_to_mpz_t (coef, val);
+DEBUG_FUNCTION void
+debug_isl_set (isl_set *set)
+{
+  print_isl_set (stderr, set);
+}
 
-      if (mpz_sgn (val) == 0)
-	{
-	  ppl_delete_Linear_Expression (expr);
-	  continue;
-	}
+void
+print_isl_map (FILE *f, isl_map *map)
+{
+  isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
+  p = isl_printer_print_map (p, map);
+  isl_printer_free (p);
+}
 
-      for (i = 0; i < pbb_nb_scattering_transform (pbb); i++)
-	{
-	  ppl_dimension_type scatter = psct_scattering_dim (pbb, i);
+DEBUG_FUNCTION void
+debug_isl_map (isl_map *map)
+{
+  print_isl_map (stderr, map);
+}
 
-	  ppl_Linear_Expression_coefficient (expr, scatter, coef);
-	  ppl_Coefficient_to_mpz_t (coef, val);
+void
+print_isl_aff (FILE *f, isl_aff *aff)
+{
+  isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
+  p = isl_printer_print_aff (p, aff);
+  isl_printer_free (p);
+}
 
-	  if (mpz_sgn (val) != 0)
-	    {
-	      mpz_clear (val);
-	      ppl_delete_Linear_Expression (expr);
-	      ppl_delete_Coefficient (coef);
-	      ppl_delete_Constraint_System_const_iterator (cit);
-	      ppl_delete_Constraint_System_const_iterator (cend);
+DEBUG_FUNCTION void
+debug_isl_aff (isl_aff *aff)
+{
+  print_isl_aff (stderr, aff);
+}
 
-	      return scatter;
-	    }
-	}
-    }
+void
+print_isl_constraint (FILE *f, isl_constraint *c)
+{
+  isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
+  p = isl_printer_print_constraint (p, c);
+  isl_printer_free (p);
+}
 
-  gcc_unreachable ();
+DEBUG_FUNCTION void
+debug_isl_constraint (isl_constraint *c)
+{
+  print_isl_constraint (stderr, c);
 }
 
 /* Returns the number of iterations RES of the loop around PBB at
@@ -1624,112 +1018,37 @@  pbb_number_of_iterations_at_time (poly_bb_p pbb,
 				  graphite_dim_t time_depth,
 				  mpz_t res)
 {
-  ppl_Pointset_Powerset_C_Polyhedron_t domain, sctr_lb, sctr_ub;
-  ppl_dimension_type domain_dim, sctr_dim;
-  graphite_dim_t dim_iter_domain = pbb_dim_iter_domain (pbb);
-  ppl_Linear_Expression_t le;
-  mpz_t lb, ub, diff, one;
-  int i;
-
-  ppl_Polyhedron_space_dimension (PBB_TRANSFORMED_SCATTERING (pbb), &sctr_dim);
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-    (&domain, PBB_DOMAIN (pbb));
-
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (domain, &domain_dim);
-
-  mpz_init (diff);
-  mpz_init (lb);
-  mpz_init (ub);
-  mpz_init (one);
-  mpz_set_si (one, 1);
-
-  /* Compute the upper bound on the original iteration domain and add
-     that upper bound to the scattering.  */
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
-    (&sctr_ub, PBB_TRANSFORMED_SCATTERING (pbb));
-  for (i = 0; i < (int) dim_iter_domain; i++)
-    {
-      ppl_Linear_Expression_t eq;
-      ppl_Constraint_t pc;
-      ppl_Constraint_System_t cs;
-      ppl_Polyhedron_t ph;
-      ppl_Pointset_Powerset_C_Polyhedron_t pph;
-
-      ppl_new_Linear_Expression_with_dimension (&le, domain_dim);
-      ppl_set_coef (le, i, 1);
-      ppl_min_for_le_pointset (domain, le, lb);
-      ppl_max_for_le_pointset (domain, le, ub);
-      mpz_sub (diff, ub, lb);
-      mpz_add (diff, diff, one);
-
-      ppl_new_Linear_Expression_with_dimension (&eq, sctr_dim);
-      ppl_set_coef (eq, psct_iterator_dim (pbb, i), -1);
-      ppl_set_inhomogeneous_gmp (eq, diff);
-
-      ppl_new_Constraint (&pc, eq, PPL_CONSTRAINT_TYPE_EQUAL);
-      ppl_new_Constraint_System_from_Constraint (&cs, pc);
-      ppl_new_C_Polyhedron_from_Constraint_System (&ph, cs);
-      ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&pph, ph);
-      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (sctr_ub, pph);
-
-      ppl_delete_Linear_Expression (le);
-      ppl_delete_Linear_Expression (eq);
-      ppl_delete_Polyhedron (ph);
-      ppl_delete_Pointset_Powerset_C_Polyhedron (pph);
-      ppl_delete_Constraint (pc);
-      ppl_delete_Constraint_System (cs);
-    }
-
-  /* Compute the lower bound on the original iteration domain and add
-     it to the scattering.  */
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
-    (&sctr_lb, PBB_TRANSFORMED_SCATTERING (pbb));
-  for (i = 0; i < (int) dim_iter_domain; i++)
-    {
-      ppl_Linear_Expression_t eq;
-      ppl_Constraint_t pc;
-      ppl_Constraint_System_t cs;
-      ppl_Polyhedron_t ph;
-      ppl_Pointset_Powerset_C_Polyhedron_t pph;
+  isl_set *transdomain;
+  isl_space *dc;
+  isl_aff *aff;
+  isl_int isllb, islub;
 
-      ppl_new_Linear_Expression_with_dimension (&le, domain_dim);
-      ppl_set_coef (le, i, 1);
-      ppl_min_for_le_pointset (domain, le, lb);
+  isl_int_init (isllb);
+  isl_int_init (islub);
 
-      ppl_new_Linear_Expression_with_dimension (&eq, sctr_dim);
-      ppl_set_coef (eq, psct_iterator_dim (pbb, i), -1);
-      ppl_set_inhomogeneous_gmp (eq, lb);
+  /* Map the iteration domain through the current scatter, and work
+     on the resulting set.  */
+  transdomain = isl_set_apply (isl_set_copy (pbb->domain),
+			       isl_map_copy (pbb->transformed));
 
-      ppl_new_Constraint (&pc, eq, PPL_CONSTRAINT_TYPE_EQUAL);
-      ppl_new_Constraint_System_from_Constraint (&cs, pc);
-      ppl_new_C_Polyhedron_from_Constraint_System (&ph, cs);
-      ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&pph, ph);
-      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (sctr_lb, pph);
+  /* Select the time_depth' dimension via an affine expression.  */
+  dc = isl_set_get_space (transdomain);
+  aff = isl_aff_zero_on_domain (isl_local_space_from_space (dc));
+  aff = isl_aff_set_coefficient_si (aff, isl_dim_in, time_depth, 1);
 
-      ppl_delete_Linear_Expression (le);
-      ppl_delete_Linear_Expression (eq);
-      ppl_delete_Polyhedron (ph);
-      ppl_delete_Pointset_Powerset_C_Polyhedron (pph);
-      ppl_delete_Constraint (pc);
-      ppl_delete_Constraint_System (cs);
-    }
+  /* And find the min/max for that function.  */
+  /* XXX isl check results?  */
+  isl_set_min (transdomain, aff, &isllb);
+  isl_set_max (transdomain, aff, &islub);
 
-  /* Extract the number of iterations.  */
-  ppl_new_Linear_Expression_with_dimension (&le, sctr_dim);
-  ppl_set_coef (le, time_depth, 1);
-  ppl_min_for_le_pointset (sctr_lb, le, lb);
-  ppl_max_for_le_pointset (sctr_ub, le, ub);
-  mpz_sub (res, ub, lb);
+  isl_int_sub (islub, islub, isllb);
+  isl_int_add_ui (islub, islub, 1);
+  isl_int_get_gmp (islub, res);
 
-  mpz_clear (one);
-  mpz_clear (diff);
-  mpz_clear (lb);
-  mpz_clear (ub);
-  ppl_delete_Linear_Expression (le);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (sctr_ub);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (sctr_lb);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (domain);
+  isl_int_clear (isllb);
+  isl_int_clear (islub);
+  isl_aff_free (aff);
+  isl_set_free (transdomain);
 }
 
 /* Translates LOOP to LST.  */
@@ -1927,5 +1246,45 @@  cloog_checksum (scop_p scop ATTRIBUTE_UNUSED)
 #endif
 }
 
+/* Reverse the loop around PBB at level DEPTH.  */
+
+isl_map *
+reverse_loop_at_level (poly_bb_p pbb, int depth)
+{
+  unsigned i, depth_dim = psct_dynamic_dim (pbb, depth);
+  isl_space *d = isl_map_get_space (pbb->transformed);
+  isl_space *d1 = isl_space_range (d);
+  unsigned n = isl_space_dim (d1, isl_dim_out);
+  isl_space *d2 = isl_space_add_dims (d1, isl_dim_in, n);
+  isl_map *x = isl_map_universe (isl_space_copy (d2));
+  isl_constraint *c = isl_equality_alloc (isl_local_space_from_space (d2));
+
+  for (i = 0; i < n; i++)
+    if (i != depth_dim)
+      x = isl_map_equate (x, isl_dim_in, i, isl_dim_out, i);
+
+  c = isl_constraint_set_coefficient_si (c, isl_dim_in, depth_dim, 1);
+  c = isl_constraint_set_coefficient_si (c, isl_dim_out, depth_dim, 1);
+  x = isl_map_add_constraint (x, c);
+  return x;
+}
+
+/* Reverse the loop at level DEPTH for all the PBBS.  */
+
+isl_union_map *
+reverse_loop_for_pbbs (scop_p scop, VEC (poly_bb_p, heap) *pbbs, int depth)
+{
+  poly_bb_p pbb;
+  int i;
+  isl_space *space = isl_space_from_domain (isl_set_get_space (scop->context));
+  isl_union_map *res = isl_union_map_empty (space);
+
+  for (i = 0; VEC_iterate (poly_bb_p, pbbs, i, pbb); i++)
+    res = isl_union_map_add_map (res, reverse_loop_at_level (pbb, depth));
+
+  return res;
+}
+
+
 #endif
 
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index 417e99e..0b95662 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -1,5 +1,5 @@ 
 /* Graphite polyhedral representation.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Tobias Grosser <grosser@fim.uni-passau.de>.
 
@@ -34,7 +34,7 @@  typedef struct scop *scop_p;
 DEF_VEC_P(scop_p);
 DEF_VEC_ALLOC_P (scop_p, heap);
 
-typedef ppl_dimension_type graphite_dim_t;
+typedef unsigned graphite_dim_t;
 
 static inline graphite_dim_t pbb_dim_iter_domain (const struct poly_bb *);
 static inline graphite_dim_t pbb_nb_params (const struct poly_bb *);
@@ -180,7 +180,8 @@  struct poly_dr
      - P: Number of parameters.
 
      In the example, the vector "R C O I L P" is "7 7 3 2 0 1".  */
-  ppl_Pointset_Powerset_C_Polyhedron_t accesses;
+  isl_map *accesses;
+  isl_set *extent;
 
   /* Data reference's base object set number, we must assure 2 pdrs are in the
      same base object set before dependency checking.  */
@@ -195,31 +196,20 @@  struct poly_dr
 #define PDR_CDR(PDR) (PDR->compiler_dr)
 #define PDR_PBB(PDR) (PDR->pbb)
 #define PDR_TYPE(PDR) (PDR->type)
-#define PDR_ACCESSES(PDR) (PDR->accesses)
+#define PDR_ACCESSES(PDR) (NULL)
 #define PDR_BASE_OBJECT_SET(PDR) (PDR->dr_base_object_set)
 #define PDR_NB_SUBSCRIPTS(PDR) (PDR->nb_subscripts)
 
-void new_poly_dr (poly_bb_p, int, ppl_Pointset_Powerset_C_Polyhedron_t,
-		  enum poly_dr_type, void *, graphite_dim_t);
+void new_poly_dr (poly_bb_p, int, enum poly_dr_type, void *,
+		  graphite_dim_t, isl_map *, isl_set *);
 void free_poly_dr (poly_dr_p);
 void debug_pdr (poly_dr_p, int);
 void print_pdr (FILE *, poly_dr_p, int);
 static inline scop_p pdr_scop (poly_dr_p pdr);
 
-/* The dimension of the PDR_ACCESSES polyhedron of PDR.  */
-
-static inline ppl_dimension_type
-pdr_dim (poly_dr_p pdr)
-{
-  ppl_dimension_type dim;
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PDR_ACCESSES (pdr),
-						      &dim);
-  return dim;
-}
-
 /* The dimension of the iteration domain of the scop of PDR.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 pdr_dim_iter_domain (poly_dr_p pdr)
 {
   return pbb_dim_iter_domain (PDR_PBB (pdr));
@@ -227,7 +217,7 @@  pdr_dim_iter_domain (poly_dr_p pdr)
 
 /* The number of parameters of the scop of PDR.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 pdr_nb_params (poly_dr_p pdr)
 {
   return scop_nb_params (pdr_scop (pdr));
@@ -235,7 +225,7 @@  pdr_nb_params (poly_dr_p pdr)
 
 /* The dimension of the alias set in PDR.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 pdr_alias_set_dim (poly_dr_p pdr)
 {
   poly_bb_p pbb = PDR_PBB (pdr);
@@ -245,7 +235,7 @@  pdr_alias_set_dim (poly_dr_p pdr)
 
 /* The dimension in PDR containing subscript S.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 pdr_subscript_dim (poly_dr_p pdr, graphite_dim_t s)
 {
   poly_bb_p pbb = PDR_PBB (pdr);
@@ -255,7 +245,7 @@  pdr_subscript_dim (poly_dr_p pdr, graphite_dim_t s)
 
 /* The dimension in PDR containing the loop iterator ITER.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 pdr_iterator_dim (poly_dr_p pdr ATTRIBUTE_UNUSED, graphite_dim_t iter)
 {
   return iter;
@@ -263,7 +253,7 @@  pdr_iterator_dim (poly_dr_p pdr ATTRIBUTE_UNUSED, graphite_dim_t iter)
 
 /* The dimension in PDR containing parameter PARAM.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 pdr_parameter_dim (poly_dr_p pdr, graphite_dim_t param)
 {
   poly_bb_p pbb = PDR_PBB (pdr);
@@ -309,11 +299,6 @@  typedef struct poly_scattering *poly_scattering_p;
 
 struct poly_scattering
 {
-  /* The scattering function containing the transformations: the
-     layout of this polyhedron is: T|I|G with T the transform
-     scattering, I the iteration domain, G the context parameters.  */
-  ppl_Polyhedron_t scattering;
-
   /* The number of local variables.  */
   int nb_local_variables;
 
@@ -353,22 +338,22 @@  struct poly_bb
 
      The number of variables in the DOMAIN may change and is not
      related to the number of loops in the original code.  */
-  ppl_Pointset_Powerset_C_Polyhedron_t domain;
+  isl_set *domain;
 
   /* The data references we access.  */
   VEC (poly_dr_p, heap) *drs;
 
   /* The original scattering.  */
-  poly_scattering_p original;
+  poly_scattering_p _original;
+  isl_map *schedule;
 
   /* The transformed scattering.  */
-  poly_scattering_p transformed;
+  poly_scattering_p _transformed;
+  isl_map *transformed;
 
   /* A copy of the transformed scattering.  */
-  poly_scattering_p saved;
-
-  /* True when the PDR duplicates have already been removed.  */
-  bool pdr_duplicates_removed;
+  poly_scattering_p _saved;
+  isl_map *saved;
 
   /* True when this PBB contains only a reduction statement.  */
   bool is_reduction;
@@ -376,16 +361,18 @@  struct poly_bb
 
 #define PBB_BLACK_BOX(PBB) ((gimple_bb_p) PBB->black_box)
 #define PBB_SCOP(PBB) (PBB->scop)
-#define PBB_DOMAIN(PBB) (PBB->domain)
+#define PBB_DOMAIN(PBB) (NULL)
 #define PBB_DRS(PBB) (PBB->drs)
-#define PBB_ORIGINAL(PBB) (PBB->original)
-#define PBB_ORIGINAL_SCATTERING(PBB) (PBB->original->scattering)
-#define PBB_TRANSFORMED(PBB) (PBB->transformed)
-#define PBB_TRANSFORMED_SCATTERING(PBB) (PBB->transformed->scattering)
-#define PBB_SAVED(PBB) (PBB->saved)
-#define PBB_NB_LOCAL_VARIABLES(PBB) (PBB->transformed->nb_local_variables)
-#define PBB_NB_SCATTERING_TRANSFORM(PBB) (PBB->transformed->nb_scattering)
-#define PBB_PDR_DUPLICATES_REMOVED(PBB) (PBB->pdr_duplicates_removed)
+#define PBB_ORIGINAL(PBB) (PBB->_original)
+#define PBB_ORIGINAL_SCATTERING(PBB) (NULL)
+#define PBB_TRANSFORMED(PBB) (PBB->_transformed)
+#define PBB_TRANSFORMED_SCATTERING(PBB) (NULL)
+#define PBB_SAVED(PBB) (PBB->_saved)
+/* XXX isl if we ever need local vars in the scatter, we can't use the
+   out dimension of transformed to count the scatterting transform dimension.
+   */
+#define PBB_NB_LOCAL_VARIABLES(PBB) (0)
+#define PBB_NB_SCATTERING_TRANSFORM(PBB) (isl_map_n_out (PBB->transformed))
 #define PBB_IS_REDUCTION(PBB) (PBB->is_reduction)
 
 extern poly_bb_p new_poly_bb (scop_p, void *);
@@ -410,12 +397,20 @@  extern void print_iteration_domain (FILE *, poly_bb_p, int);
 extern void print_iteration_domains (FILE *, scop_p, int);
 extern void debug_iteration_domain (poly_bb_p, int);
 extern void debug_iteration_domains (scop_p, int);
+extern void print_isl_set (FILE *, isl_set *);
+extern void print_isl_map (FILE *, isl_map *);
+extern void print_isl_aff (FILE *, isl_aff *);
+extern void print_isl_constraint (FILE *, isl_constraint *);
+extern void debug_isl_set (isl_set *);
+extern void debug_isl_map (isl_map *);
+extern void debug_isl_aff (isl_aff *);
+extern void debug_isl_constraint (isl_constraint *);
 extern int scop_do_interchange (scop_p);
 extern int scop_do_strip_mine (scop_p, int);
 extern bool scop_do_block (scop_p);
 extern bool flatten_all_loops (scop_p);
 extern void pbb_number_of_iterations_at_time (poly_bb_p, graphite_dim_t, mpz_t);
-extern void pbb_remove_duplicate_pdrs (poly_bb_p);
+extern void debug_gmp_value (mpz_t);
 
 /* Return the number of write data references in PBB.  */
 
@@ -495,11 +490,7 @@  pbb_set_black_box (poly_bb_p pbb, void *black_box)
 static inline graphite_dim_t
 pbb_dim_iter_domain (const struct poly_bb *pbb)
 {
-  scop_p scop = PBB_SCOP (pbb);
-  ppl_dimension_type dim;
-
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb), &dim);
-  return dim - scop_nb_params (scop);
+  return isl_set_dim (pbb->domain, isl_dim_set);
 }
 
 /* The number of params defined in PBB.  */
@@ -544,7 +535,7 @@  pbb_nb_dynamic_scattering_transform (const struct poly_bb *pbb)
    scattering polyhedron of PBB.  */
 
 static inline graphite_dim_t
-pbb_nb_local_vars (const struct poly_bb *pbb)
+pbb_nb_local_vars (const struct poly_bb *pbb ATTRIBUTE_UNUSED)
 {
   /* For now we do not have any local variables, as we do not do strip
      mining for example.  */
@@ -553,7 +544,7 @@  pbb_nb_local_vars (const struct poly_bb *pbb)
 
 /* The dimension in the domain of PBB containing the iterator ITER.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 pbb_iterator_dim (poly_bb_p pbb ATTRIBUTE_UNUSED, graphite_dim_t iter)
 {
   return iter;
@@ -561,7 +552,7 @@  pbb_iterator_dim (poly_bb_p pbb ATTRIBUTE_UNUSED, graphite_dim_t iter)
 
 /* The dimension in the domain of PBB containing the iterator ITER.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 pbb_parameter_dim (poly_bb_p pbb, graphite_dim_t param)
 {
   return param
@@ -571,7 +562,7 @@  pbb_parameter_dim (poly_bb_p pbb, graphite_dim_t param)
 /* The dimension in the original scattering polyhedron of PBB
    containing the scattering iterator SCATTER.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 psco_scattering_dim (poly_bb_p pbb ATTRIBUTE_UNUSED, graphite_dim_t scatter)
 {
   gcc_assert (scatter < pbb_nb_scattering_orig (pbb));
@@ -581,20 +572,17 @@  psco_scattering_dim (poly_bb_p pbb ATTRIBUTE_UNUSED, graphite_dim_t scatter)
 /* The dimension in the transformed scattering polyhedron of PBB
    containing the scattering iterator SCATTER.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 psct_scattering_dim (poly_bb_p pbb ATTRIBUTE_UNUSED, graphite_dim_t scatter)
 {
   gcc_assert (scatter <= pbb_nb_scattering_transform (pbb));
   return scatter;
 }
 
-ppl_dimension_type psct_scattering_dim_for_loop_depth (poly_bb_p,
-						       graphite_dim_t);
-
 /* The dimension in the transformed scattering polyhedron of PBB of
    the local variable LV.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 psct_local_var_dim (poly_bb_p pbb, graphite_dim_t lv)
 {
   gcc_assert (lv <= pbb_nb_local_vars (pbb));
@@ -604,7 +592,7 @@  psct_local_var_dim (poly_bb_p pbb, graphite_dim_t lv)
 /* The dimension in the original scattering polyhedron of PBB
    containing the loop iterator ITER.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 psco_iterator_dim (poly_bb_p pbb, graphite_dim_t iter)
 {
   gcc_assert (iter < pbb_dim_iter_domain (pbb));
@@ -614,7 +602,7 @@  psco_iterator_dim (poly_bb_p pbb, graphite_dim_t iter)
 /* The dimension in the transformed scattering polyhedron of PBB
    containing the loop iterator ITER.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 psct_iterator_dim (poly_bb_p pbb, graphite_dim_t iter)
 {
   gcc_assert (iter < pbb_dim_iter_domain (pbb));
@@ -626,7 +614,7 @@  psct_iterator_dim (poly_bb_p pbb, graphite_dim_t iter)
 /* The dimension in the original scattering polyhedron of PBB
    containing parameter PARAM.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 psco_parameter_dim (poly_bb_p pbb, graphite_dim_t param)
 {
   gcc_assert (param < pbb_nb_params (pbb));
@@ -638,7 +626,7 @@  psco_parameter_dim (poly_bb_p pbb, graphite_dim_t param)
 /* The dimension in the transformed scattering polyhedron of PBB
    containing parameter PARAM.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 psct_parameter_dim (poly_bb_p pbb, graphite_dim_t param)
 {
   gcc_assert (param < pbb_nb_params (pbb));
@@ -651,7 +639,7 @@  psct_parameter_dim (poly_bb_p pbb, graphite_dim_t param)
 /* The scattering dimension of PBB corresponding to the dynamic level
    LEVEL.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 psct_dynamic_dim (poly_bb_p pbb, graphite_dim_t level)
 {
   graphite_dim_t result = 1 + 2 * level;
@@ -663,7 +651,7 @@  psct_dynamic_dim (poly_bb_p pbb, graphite_dim_t level)
 /* The scattering dimension of PBB corresponding to the static
    sequence of the loop level LEVEL.  */
 
-static inline ppl_dimension_type
+static inline graphite_dim_t
 psct_static_dim (poly_bb_p pbb, graphite_dim_t level)
 {
   graphite_dim_t result = 2 * level;
@@ -676,25 +664,10 @@  psct_static_dim (poly_bb_p pbb, graphite_dim_t level)
    variable and returns its index.  */
 
 static inline graphite_dim_t
-psct_add_local_variable (poly_bb_p pbb)
+psct_add_local_variable (poly_bb_p pbb ATTRIBUTE_UNUSED)
 {
-  graphite_dim_t nlv = pbb_nb_local_vars (pbb);
-  ppl_dimension_type lv_column = psct_local_var_dim (pbb, nlv);
-  ppl_insert_dimensions (PBB_TRANSFORMED_SCATTERING (pbb), lv_column, 1);
-  PBB_NB_LOCAL_VARIABLES (pbb) += 1;
-  return nlv;
-}
-
-/* Adds a dimension to the transformed scattering polyhedron of PBB at
-   INDEX.  */
-
-static inline void
-psct_add_scattering_dimension (poly_bb_p pbb, ppl_dimension_type index)
-{
-  gcc_assert (index < pbb_nb_scattering_transform (pbb));
-
-  ppl_insert_dimensions (PBB_TRANSFORMED_SCATTERING (pbb), index, 1);
-  PBB_NB_SCATTERING_TRANSFORM (pbb) += 1;
+  gcc_unreachable ();
+  return 0;
 }
 
 typedef struct lst *lst_p;
@@ -1116,25 +1089,20 @@  lst_niter_for_loop (lst_p lst, mpz_t niter)
 static inline void
 pbb_update_scattering (poly_bb_p pbb, graphite_dim_t level, int dewey)
 {
-  ppl_Polyhedron_t ph = PBB_TRANSFORMED_SCATTERING (pbb);
-  ppl_dimension_type sched = psct_static_dim (pbb, level);
-  ppl_dimension_type ds[1];
-  ppl_Constraint_t new_cstr;
-  ppl_Linear_Expression_t expr;
-  ppl_dimension_type dim;
+  graphite_dim_t sched = psct_static_dim (pbb, level);
+  isl_space *d = isl_map_get_space (pbb->transformed);
+  isl_space *d1 = isl_space_range (d);
+  unsigned i, n = isl_space_dim (d1, isl_dim_out);
+  isl_space *d2 = isl_space_add_dims (d1, isl_dim_in, n);
+  isl_map *x = isl_map_universe (d2);
+
+  x = isl_map_fix_si (x, isl_dim_out, sched, dewey);
 
-  ppl_Polyhedron_space_dimension (ph, &dim);
-  ds[0] = sched;
-  ppl_Polyhedron_remove_space_dimensions (ph, ds, 1);
-  ppl_insert_dimensions (ph, sched, 1);
+  for (i = 0; i < n; i++)
+    if (i != sched)
+      x = isl_map_equate (x, isl_dim_in, i, isl_dim_out, i);
 
-  ppl_new_Linear_Expression_with_dimension (&expr, dim);
-  ppl_set_coef (expr, sched, -1);
-  ppl_set_inhomogeneous (expr, dewey);
-  ppl_new_Constraint (&new_cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
-  ppl_delete_Linear_Expression (expr);
-  ppl_Polyhedron_add_constraint (ph, new_cstr);
-  ppl_delete_Constraint (new_cstr);
+  pbb->transformed = isl_map_apply_range (pbb->transformed, x);
 }
 
 /* Updates the scattering of all the PBBs under LST to be at the DEWEY
@@ -1401,7 +1369,18 @@  struct scop
   -128 >= a >= 127
      0 >= b >= 65,535
      c = 2a + b  */
-  ppl_Pointset_Powerset_C_Polyhedron_t context;
+  isl_set *context;
+
+  /* The context used internally by ISL.  */
+  isl_ctx *ctx;
+
+  /* The original dependence relations:
+     RAW are read after write dependences,
+     WAR are write after read dependences,
+     WAW are write after write dependences.  */
+  isl_union_map *must_raw, *may_raw, *must_raw_no_source, *may_raw_no_source,
+    *must_war, *may_war, *must_war_no_source, *may_war_no_source,
+    *must_waw, *may_waw, *must_waw_no_source, *may_waw_no_source;
 
   /* A hashtable of the data dependence relations for the original
      scattering.  */
@@ -1414,7 +1393,7 @@  struct scop
 
 #define SCOP_BBS(S) (S->bbs)
 #define SCOP_REGION(S) ((sese) S->region)
-#define SCOP_CONTEXT(S) (S->context)
+#define SCOP_CONTEXT(S) (NULL)
 #define SCOP_ORIGINAL_PDDRS(S) (S->original_pddrs)
 #define SCOP_ORIGINAL_SCHEDULE(S) (S->original_schedule)
 #define SCOP_TRANSFORMED_SCHEDULE(S) (S->transformed_schedule)
@@ -1467,7 +1446,6 @@  poly_scattering_new (void)
 {
   poly_scattering_p res = XNEW (struct poly_scattering);
 
-  res->scattering = NULL;
   res->nb_local_variables = 0;
   res->nb_scattering = 0;
   return res;
@@ -1478,7 +1456,6 @@  poly_scattering_new (void)
 static inline void
 poly_scattering_free (poly_scattering_p s)
 {
-  ppl_delete_Polyhedron (s->scattering);
   free (s);
 }
 
@@ -1489,7 +1466,6 @@  poly_scattering_copy (poly_scattering_p s)
 {
   poly_scattering_p res = poly_scattering_new ();
 
-  ppl_new_C_Polyhedron_from_C_Polyhedron (&(res->scattering), s->scattering);
   res->nb_local_variables = s->nb_local_variables;
   res->nb_scattering = s->nb_scattering;
   return res;
@@ -1500,12 +1476,8 @@  poly_scattering_copy (poly_scattering_p s)
 static inline void
 store_scattering_pbb (poly_bb_p pbb)
 {
-  gcc_assert (PBB_TRANSFORMED (pbb));
-
-  if (PBB_SAVED (pbb))
-    poly_scattering_free (PBB_SAVED (pbb));
-
-  PBB_SAVED (pbb) = poly_scattering_copy (PBB_TRANSFORMED (pbb));
+  isl_map_free (pbb->saved);
+  pbb->saved = isl_map_copy (pbb->transformed);
 }
 
 /* Stores the SCOP_TRANSFORMED_SCHEDULE to SCOP_SAVED_SCHEDULE.  */
@@ -1549,10 +1521,10 @@  store_scattering (scop_p scop)
 static inline void
 restore_scattering_pbb (poly_bb_p pbb)
 {
-  gcc_assert (PBB_SAVED (pbb));
+  gcc_assert (pbb->saved);
 
-  poly_scattering_free (PBB_TRANSFORMED (pbb));
-  PBB_TRANSFORMED (pbb) = poly_scattering_copy (PBB_SAVED (pbb));
+  isl_map_free (pbb->transformed);
+  pbb->transformed = isl_map_copy (pbb->saved);
 }
 
 /* Restores the scattering for all the pbbs in the SCOP.  */
@@ -1569,49 +1541,12 @@  restore_scattering (scop_p scop)
   restore_lst_schedule (scop);
 }
 
-/* For a given PBB, add to RES the scop context, the iteration domain,
-   the original scattering when ORIGINAL_P is true, otherwise add the
-   transformed scattering.  */
-
-static inline void
-combine_context_id_scat (ppl_Pointset_Powerset_C_Polyhedron_t *res,
-			 poly_bb_p pbb, bool original_p)
-{
-  ppl_Pointset_Powerset_C_Polyhedron_t context;
-  ppl_Pointset_Powerset_C_Polyhedron_t id;
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
-    (res, original_p ?
-     PBB_ORIGINAL_SCATTERING (pbb) : PBB_TRANSFORMED_SCATTERING (pbb));
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-    (&context, SCOP_CONTEXT (PBB_SCOP (pbb)));
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-    (&id, PBB_DOMAIN (pbb));
-
-  /* Extend the context and the iteration domain to the dimension of
-     the scattering: T|I|G.  */
-  {
-    ppl_dimension_type gdim, tdim, idim;
-
-    ppl_Pointset_Powerset_C_Polyhedron_space_dimension (*res, &tdim);
-    ppl_Pointset_Powerset_C_Polyhedron_space_dimension (context, &gdim);
-    ppl_Pointset_Powerset_C_Polyhedron_space_dimension (id, &idim);
-
-    if (tdim > gdim)
-      ppl_insert_dimensions_pointset (context, 0, tdim - gdim);
-
-    if (tdim > idim)
-      ppl_insert_dimensions_pointset (id, 0, tdim - idim);
-  }
-
-  /* Add the context and the iteration domain to the result.  */
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, context);
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, id);
-
-  ppl_delete_Pointset_Powerset_C_Polyhedron (context);
-  ppl_delete_Pointset_Powerset_C_Polyhedron (id);
-}
+bool graphite_legal_transform (scop_p);
+poly_bb_p find_pbb_via_hash (htab_t, basic_block);
+bool loop_is_parallel_p (loop_p, htab_t, int);
+scop_p get_loop_body_pbbs (loop_p, htab_t, VEC (poly_bb_p, heap) **);
+isl_map *reverse_loop_at_level (poly_bb_p, int);
+isl_union_map *reverse_loop_for_pbbs (scop_p, VEC (poly_bb_p, heap) *, int);
+__isl_give isl_union_map *extend_schedule (__isl_take isl_union_map *);
 
 #endif
diff --git a/gcc/graphite-ppl.c b/gcc/graphite-ppl.c
deleted file mode 100644
index 9762ca4..0000000
--- a/gcc/graphite-ppl.c
+++ /dev/null
@@ -1,566 +0,0 @@ 
-/* Gimple Represented as Polyhedra.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
-   Contributed by Sebastian Pop <sebastian.pop@amd.com>
-   and Tobias Grosser <grosser@fim.uni-passau.de>
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-
-#ifdef HAVE_cloog
-
-#include "ppl_c.h"
-#include "graphite-cloog-util.h"
-#include "graphite-ppl.h"
-
-/* Set the inhomogeneous term of E to X.  */
-
-void
-ppl_set_inhomogeneous_gmp (ppl_Linear_Expression_t e, mpz_t x)
-{
-  mpz_t v0, v1;
-  ppl_Coefficient_t c;
-
-  mpz_init (v0);
-  mpz_init (v1);
-  ppl_new_Coefficient (&c);
-
-  ppl_Linear_Expression_inhomogeneous_term (e, c);
-  ppl_Coefficient_to_mpz_t (c, v1);
-  mpz_neg (v1, v1);
-  mpz_set (v0, x);
-  mpz_add (v0, v0, v1);
-  ppl_assign_Coefficient_from_mpz_t (c, v0);
-  ppl_Linear_Expression_add_to_inhomogeneous (e, c);
-
-  mpz_clear (v0);
-  mpz_clear (v1);
-  ppl_delete_Coefficient (c);
-}
-
-/* Set E[I] to X.  */
-
-void
-ppl_set_coef_gmp (ppl_Linear_Expression_t e, ppl_dimension_type i, mpz_t x)
-{
-  mpz_t v0, v1;
-  ppl_Coefficient_t c;
-
-  mpz_init (v0);
-  mpz_init (v1);
-  ppl_new_Coefficient (&c);
-
-  ppl_Linear_Expression_coefficient (e, i, c);
-  ppl_Coefficient_to_mpz_t (c, v1);
-  mpz_neg (v1, v1);
-  mpz_set (v0, x);
-  mpz_add (v0, v0, v1);
-  ppl_assign_Coefficient_from_mpz_t (c, v0);
-  ppl_Linear_Expression_add_to_coefficient (e, i, c);
-
-  mpz_clear (v0);
-  mpz_clear (v1);
-  ppl_delete_Coefficient (c);
-}
-
-/* Insert after X NB_NEW_DIMS empty dimensions into PH.
-
-   With x = 3 and nb_new_dims = 4
-
-   |  d0 d1 d2 d3 d4
-
-   is transformed to
-
-   |  d0 d1 d2 x0 x1 x2 x3 d3 d4
-
-   | map = {0, 1, 2, 7, 8, 3, 4, 5, 6}
-*/
-
-void
-ppl_insert_dimensions_pointset (ppl_Pointset_Powerset_C_Polyhedron_t ph, int x,
-				int nb_new_dims)
-{
-  ppl_dimension_type i, dim;
-  ppl_dimension_type *map;
-  ppl_dimension_type x_ppl, nb_new_dims_ppl;
-
-  x_ppl = (ppl_dimension_type) x;
-  nb_new_dims_ppl = (ppl_dimension_type) nb_new_dims;
-
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (ph, &dim);
-  ppl_Pointset_Powerset_C_Polyhedron_add_space_dimensions_and_embed (ph, nb_new_dims);
-
-  map = (ppl_dimension_type *) XNEWVEC (ppl_dimension_type, dim + nb_new_dims);
-
-  for (i = 0; i < x_ppl; i++)
-    map[i] = i;
-
-  for (i = x_ppl; i < x_ppl + nb_new_dims_ppl; i++)
-    map[dim + i - x_ppl] = i;
-
-  for (i = x_ppl + nb_new_dims_ppl; i < dim + nb_new_dims_ppl; i++)
-    map[i - nb_new_dims_ppl] = i;
-
-  ppl_Pointset_Powerset_C_Polyhedron_map_space_dimensions (ph, map, dim + nb_new_dims);
-  free (map);
-}
-
-/* Insert after X NB_NEW_DIMS empty dimensions into PH.
-
-   With x = 3 and nb_new_dims = 4
-
-   |  d0 d1 d2 d3 d4
-
-   is transformed to
-
-   |  d0 d1 d2 x0 x1 x2 x3 d3 d4
-
-   | map = {0, 1, 2, 7, 8, 3, 4, 5, 6}
-*/
-
-void
-ppl_insert_dimensions (ppl_Polyhedron_t ph, int x,
-		       int nb_new_dims)
-{
-  ppl_dimension_type i, dim;
-  ppl_dimension_type *map;
-  ppl_dimension_type x_ppl, nb_new_dims_ppl;
-
-  x_ppl = (ppl_dimension_type) x;
-  nb_new_dims_ppl = (ppl_dimension_type) nb_new_dims;
-
-  ppl_Polyhedron_space_dimension (ph, &dim);
-  ppl_Polyhedron_add_space_dimensions_and_embed (ph, nb_new_dims);
-
-  map = (ppl_dimension_type *) XNEWVEC (ppl_dimension_type, dim + nb_new_dims);
-
-  for (i = 0; i < x_ppl; i++)
-    map[i] = i;
-
-  for (i = x_ppl; i < x_ppl + nb_new_dims_ppl; i++)
-    map[dim + i - x_ppl] = i;
-
-  for (i = x_ppl + nb_new_dims_ppl; i < dim + nb_new_dims_ppl; i++)
-    map[i - nb_new_dims_ppl] = i;
-
-  ppl_Polyhedron_map_space_dimensions (ph, map, dim + nb_new_dims);
-  free (map);
-}
-
-/* Based on the original polyhedron PH, returns a new polyhedron with
-   an extra dimension placed at position LOOP + 1 that slices the
-   dimension LOOP into strips of size STRIDE.  */
-
-ppl_Polyhedron_t
-ppl_strip_loop (ppl_Polyhedron_t ph, ppl_dimension_type loop, int stride)
-{
-  ppl_const_Constraint_System_t pcs;
-  ppl_Constraint_System_const_iterator_t cit, end;
-  ppl_const_Constraint_t cstr;
-  ppl_Linear_Expression_t expr;
-  int v;
-  ppl_dimension_type dim;
-  ppl_Polyhedron_t res;
-  ppl_Coefficient_t c;
-  mpz_t val;
-
-  mpz_init (val);
-  ppl_new_Coefficient (&c);
-
-  ppl_Polyhedron_space_dimension (ph, &dim);
-  ppl_Polyhedron_get_constraints (ph, &pcs);
-
-  /* Start from a copy of the constraints.  */
-  ppl_new_C_Polyhedron_from_space_dimension (&res, dim + 1, 0);
-  ppl_Polyhedron_add_constraints (res, pcs);
-
-  /* Add an empty dimension for the strip loop.  */
-  ppl_insert_dimensions (res, loop, 1);
-
-  /* Identify the constraints that define the lower and upper bounds
-     of the strip-mined loop, and add them to the strip loop.  */
-  {
-    ppl_Polyhedron_t tmp;
-
-    ppl_new_C_Polyhedron_from_space_dimension (&tmp, dim + 1, 0);
-    ppl_new_Constraint_System_const_iterator (&cit);
-    ppl_new_Constraint_System_const_iterator (&end);
-
-    for (ppl_Constraint_System_begin (pcs, cit),
-	   ppl_Constraint_System_end (pcs, end);
-	 !ppl_Constraint_System_const_iterator_equal_test (cit, end);
-	 ppl_Constraint_System_const_iterator_increment (cit))
-      {
-	ppl_Constraint_System_const_iterator_dereference (cit, &cstr);
-	ppl_new_Linear_Expression_from_Constraint (&expr, cstr);
-	ppl_Linear_Expression_coefficient (expr, loop, c);
-	ppl_delete_Linear_Expression (expr);
-	ppl_Coefficient_to_mpz_t (c, val);
-	v = mpz_get_si (val);
-
-	if (0 < v || v < 0)
-	  ppl_Polyhedron_add_constraint (tmp, cstr);
-      }
-    ppl_delete_Constraint_System_const_iterator (cit);
-    ppl_delete_Constraint_System_const_iterator (end);
-
-    ppl_insert_dimensions (tmp, loop + 1, 1);
-    ppl_Polyhedron_get_constraints (tmp, &pcs);
-    ppl_Polyhedron_add_constraints (res, pcs);
-    ppl_delete_Polyhedron (tmp);
-  }
-
-  /* Lower bound of a tile starts at "stride * outer_iv".  */
-  {
-    ppl_Constraint_t new_cstr;
-    ppl_new_Linear_Expression_with_dimension (&expr, dim + 1);
-
-    ppl_set_coef (expr, loop + 1, 1);
-    ppl_set_coef (expr, loop, -1 * stride);
-
-    ppl_new_Constraint (&new_cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-    ppl_delete_Linear_Expression (expr);
-    ppl_Polyhedron_add_constraint (res, new_cstr);
-    ppl_delete_Constraint (new_cstr);
-  }
-
-  /* Upper bound of a tile stops at "stride * outer_iv + stride - 1",
-     or at the old upper bound that is not modified.  */
-  {
-    ppl_Constraint_t new_cstr;
-    ppl_new_Linear_Expression_with_dimension (&expr, dim + 1);
-
-    ppl_set_coef (expr, loop + 1, -1);
-    ppl_set_coef (expr, loop, stride);
-    ppl_set_inhomogeneous (expr, stride - 1);
-
-    ppl_new_Constraint (&new_cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-    ppl_delete_Linear_Expression (expr);
-    ppl_Polyhedron_add_constraint (res, new_cstr);
-    ppl_delete_Constraint (new_cstr);
-  }
-
-  mpz_clear (val);
-  ppl_delete_Coefficient (c);
-  return res;
-}
-
-/* Lexicographically compares two linear expressions A and B and
-   returns negative when A < B, 0 when A == B and positive when A > B.  */
-
-int
-ppl_lexico_compare_linear_expressions (ppl_Linear_Expression_t a,
-				       ppl_Linear_Expression_t b)
-{
-  ppl_dimension_type min_length, length1, length2;
-  ppl_dimension_type i;
-  ppl_Coefficient_t c;
-  int res;
-  mpz_t va, vb;
-
-  ppl_Linear_Expression_space_dimension (a, &length1);
-  ppl_Linear_Expression_space_dimension (b, &length2);
-  ppl_new_Coefficient (&c);
-  mpz_init (va);
-  mpz_init (vb);
-
-  if (length1 < length2)
-    min_length = length1;
-  else
-    min_length = length2;
-
-  for (i = 0; i < min_length; i++)
-    {
-      ppl_Linear_Expression_coefficient (a, i, c);
-      ppl_Coefficient_to_mpz_t (c, va);
-      ppl_Linear_Expression_coefficient (b, i, c);
-      ppl_Coefficient_to_mpz_t (c, vb);
-      res = mpz_cmp (va, vb);
-
-      if (res == 0)
-	continue;
-
-      mpz_clear (va);
-      mpz_clear (vb);
-      ppl_delete_Coefficient (c);
-      return res;
-    }
-
-  mpz_clear (va);
-  mpz_clear (vb);
-  ppl_delete_Coefficient (c);
-  return length1 - length2;
-}
-
-/* Print to FILE the polyhedron PH under its PolyLib matrix form.  */
-
-void
-ppl_print_polyhedron_matrix (FILE *file, ppl_const_Polyhedron_t ph)
-{
-  CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
-  cloog_matrix_print (file, mat);
-  cloog_matrix_free (mat);
-}
-
-/* Print to FILE the linear expression LE.  */
-
-void
-ppl_print_linear_expr (FILE *file, ppl_Linear_Expression_t le)
-{
-  ppl_Constraint_t c;
-  ppl_Polyhedron_t pol;
-  ppl_dimension_type dim;
-
-  ppl_Linear_Expression_space_dimension (le, &dim);
-  ppl_new_C_Polyhedron_from_space_dimension (&pol, dim, 0);
-  ppl_new_Constraint (&c, le, PPL_CONSTRAINT_TYPE_EQUAL);
-  ppl_Polyhedron_add_constraint (pol, c);
-  ppl_print_polyhedron_matrix (file, pol);
-}
-
-/* Print to STDERR the linear expression LE.  */
-
-DEBUG_FUNCTION void
-debug_ppl_linear_expr (ppl_Linear_Expression_t le)
-{
-  ppl_print_linear_expr (stderr, le);
-}
-
-/* Print to FILE the powerset PS in its PolyLib matrix form.  */
-
-void
-ppl_print_powerset_matrix (FILE *file,
-			   ppl_Pointset_Powerset_C_Polyhedron_t ps)
-{
-  size_t nb_disjuncts;
-  ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end;
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&it);
-  ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&end);
-
-  ppl_Pointset_Powerset_C_Polyhedron_size (ps, &nb_disjuncts);
-  fprintf (file, "%d\n", (int) nb_disjuncts);
-
-  for (ppl_Pointset_Powerset_C_Polyhedron_iterator_begin (ps, it),
-       ppl_Pointset_Powerset_C_Polyhedron_iterator_end (ps, end);
-       !ppl_Pointset_Powerset_C_Polyhedron_iterator_equal_test (it, end);
-       ppl_Pointset_Powerset_C_Polyhedron_iterator_increment (it))
-    {
-      ppl_const_Polyhedron_t ph;
-
-      ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph);
-      ppl_print_polyhedron_matrix (file, ph);
-    }
-
-  ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (it);
-  ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (end);
-}
-
-/* Print to STDERR the polyhedron PH under its PolyLib matrix form.  */
-
-DEBUG_FUNCTION void
-debug_ppl_polyhedron_matrix (ppl_Polyhedron_t ph)
-{
-  ppl_print_polyhedron_matrix (stderr, ph);
-}
-
-/* Print to STDERR the powerset PS in its PolyLib matrix form.  */
-
-DEBUG_FUNCTION void
-debug_ppl_powerset_matrix (ppl_Pointset_Powerset_C_Polyhedron_t ps)
-{
-  ppl_print_powerset_matrix (stderr, ps);
-}
-
-/* Read from FILE a polyhedron under PolyLib matrix form and return a
-   PPL polyhedron object.  */
-
-void
-ppl_read_polyhedron_matrix (ppl_Polyhedron_t *ph, FILE *file)
-{
-  CloogMatrix *mat = cloog_matrix_read (file);
-  new_C_Polyhedron_from_Cloog_Matrix (ph, mat);
-  cloog_matrix_free (mat);
-}
-
-/* Return in RES the maximum of the linear expression LE on the
-   pointset powerset of polyhedra PS.  */
-
-void
-ppl_max_for_le_pointset (ppl_Pointset_Powerset_C_Polyhedron_t ps,
-                         ppl_Linear_Expression_t le, mpz_t res)
-{
-  ppl_Coefficient_t num, denom;
-  mpz_t dv, nv;
-  int maximum, err;
-
-  mpz_init (nv);
-  mpz_init (dv);
-  ppl_new_Coefficient (&num);
-  ppl_new_Coefficient (&denom);
-  err = ppl_Pointset_Powerset_C_Polyhedron_maximize (ps, le, num, denom, &maximum);
-
-  if (err > 0)
-    {
-      ppl_Coefficient_to_mpz_t (num, nv);
-      ppl_Coefficient_to_mpz_t (denom, dv);
-      gcc_assert (mpz_sgn (dv) != 0);
-      mpz_tdiv_q (res, nv, dv);
-    }
-
-  mpz_clear (nv);
-  mpz_clear (dv);
-  ppl_delete_Coefficient (num);
-  ppl_delete_Coefficient (denom);
-}
-
-/* Return in RES the maximum of the linear expression LE on the
-   polyhedron POL.  */
-
-void
-ppl_min_for_le_pointset (ppl_Pointset_Powerset_C_Polyhedron_t ps,
-			 ppl_Linear_Expression_t le, mpz_t res)
-{
-  ppl_Coefficient_t num, denom;
-  mpz_t dv, nv;
-  int minimum, err;
-
-  mpz_init (nv);
-  mpz_init (dv);
-  ppl_new_Coefficient (&num);
-  ppl_new_Coefficient (&denom);
-  err = ppl_Pointset_Powerset_C_Polyhedron_minimize (ps, le, num, denom, &minimum);
-
-  if (err > 0)
-    {
-      ppl_Coefficient_to_mpz_t (num, nv);
-      ppl_Coefficient_to_mpz_t (denom, dv);
-      gcc_assert (mpz_sgn (dv) != 0);
-      mpz_tdiv_q (res, nv, dv);
-    }
-
-  mpz_clear (nv);
-  mpz_clear (dv);
-  ppl_delete_Coefficient (num);
-  ppl_delete_Coefficient (denom);
-}
-
-/* Builds a constraint in dimension DIM relating dimensions POS1 to
-   POS2 as "POS1 - POS2 + C CSTR_TYPE 0" */
-
-ppl_Constraint_t
-ppl_build_relation (int dim, int pos1, int pos2, int c,
-		    enum ppl_enum_Constraint_Type cstr_type)
-{
-  ppl_Linear_Expression_t expr;
-  ppl_Constraint_t cstr;
-  ppl_Coefficient_t coef;
-  mpz_t v, v_op, v_c;
-
-  mpz_init (v);
-  mpz_init (v_op);
-  mpz_init (v_c);
-
-  mpz_set_si (v, 1);
-  mpz_set_si (v_op, -1);
-  mpz_set_si (v_c, c);
-
-  ppl_new_Coefficient (&coef);
-  ppl_new_Linear_Expression_with_dimension (&expr, dim);
-
-  ppl_assign_Coefficient_from_mpz_t (coef, v);
-  ppl_Linear_Expression_add_to_coefficient (expr, pos1, coef);
-  ppl_assign_Coefficient_from_mpz_t (coef, v_op);
-  ppl_Linear_Expression_add_to_coefficient (expr, pos2, coef);
-  ppl_assign_Coefficient_from_mpz_t (coef, v_c);
-  ppl_Linear_Expression_add_to_inhomogeneous (expr, coef);
-
-  ppl_new_Constraint (&cstr, expr, cstr_type);
-
-  ppl_delete_Linear_Expression (expr);
-  ppl_delete_Coefficient (coef);
-  mpz_clear (v);
-  mpz_clear (v_op);
-  mpz_clear (v_c);
-
-  return cstr;
-}
-
-/* Print to STDERR the GMP value VAL.  */
-
-DEBUG_FUNCTION void
-debug_gmp_value (mpz_t val)
-{
-  char *str = mpz_get_str (0, 10, val);
-  void (*gmp_free) (void *, size_t);
-
-  fprintf (stderr, "%s", str);
-  mp_get_memory_functions (NULL, NULL, &gmp_free);
-  (*gmp_free) (str, strlen (str) + 1);
-}
-
-/* Checks for integer feasibility: returns true when the powerset
-   polyhedron PS has no integer solutions.  */
-
-bool
-ppl_powerset_is_empty (ppl_Pointset_Powerset_C_Polyhedron_t ps)
-{
-  ppl_PIP_Problem_t pip;
-  ppl_dimension_type d;
-  ppl_const_Constraint_System_t pcs;
-  ppl_Constraint_System_const_iterator_t first, last;
-  ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end;
-  bool has_integer_solutions = false;
-
-  if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (ps))
-    return true;
-
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (ps, &d);
-  ppl_new_Constraint_System_const_iterator (&first);
-  ppl_new_Constraint_System_const_iterator (&last);
-  ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&it);
-  ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&end);
-
-  for (ppl_Pointset_Powerset_C_Polyhedron_iterator_begin (ps, it),
-       ppl_Pointset_Powerset_C_Polyhedron_iterator_end (ps, end);
-       !ppl_Pointset_Powerset_C_Polyhedron_iterator_equal_test (it, end);
-       ppl_Pointset_Powerset_C_Polyhedron_iterator_increment (it))
-    {
-      ppl_const_Polyhedron_t ph;
-      ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph);
-
-      ppl_Polyhedron_get_constraints (ph, &pcs);
-      ppl_Constraint_System_begin (pcs, first);
-      ppl_Constraint_System_end (pcs, last);
-
-      ppl_new_PIP_Problem_from_constraints (&pip, d, first, last, 0, NULL);
-      has_integer_solutions |= ppl_PIP_Problem_is_satisfiable (pip);
-
-      ppl_delete_PIP_Problem (pip);
-    }
-
-  ppl_delete_Constraint_System_const_iterator (first);
-  ppl_delete_Constraint_System_const_iterator (last);
-  ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (it);
-  ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (end);
-
-  return !has_integer_solutions;
-}
-
-#endif
diff --git a/gcc/graphite-ppl.h b/gcc/graphite-ppl.h
deleted file mode 100644
index 5820e19..0000000
--- a/gcc/graphite-ppl.h
+++ /dev/null
@@ -1,176 +0,0 @@ 
-/* Gimple Represented as Polyhedra.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
-   Contributed by Sebastian Pop <sebastian.pop@inria.fr>
-   and Tobias Grosser <grosser@fim.uni-passau.de>.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-#ifndef GCC_GRAPHITE_PPL_H
-#define GCC_GRAPHITE_PPL_H
-
-#include "double-int.h"
-#include "tree.h"
-
-ppl_Polyhedron_t ppl_strip_loop (ppl_Polyhedron_t, ppl_dimension_type, int);
-int ppl_lexico_compare_linear_expressions (ppl_Linear_Expression_t,
-					   ppl_Linear_Expression_t);
-
-void ppl_print_polyhedron_matrix (FILE *, ppl_const_Polyhedron_t);
-void ppl_print_powerset_matrix (FILE *, ppl_Pointset_Powerset_C_Polyhedron_t);
-void debug_ppl_polyhedron_matrix (ppl_Polyhedron_t);
-void debug_ppl_powerset_matrix (ppl_Pointset_Powerset_C_Polyhedron_t);
-void ppl_print_linear_expr (FILE *, ppl_Linear_Expression_t);
-void debug_ppl_linear_expr (ppl_Linear_Expression_t);
-void ppl_read_polyhedron_matrix (ppl_Polyhedron_t *, FILE *);
-void ppl_insert_dimensions (ppl_Polyhedron_t, int, int);
-void ppl_insert_dimensions_pointset (ppl_Pointset_Powerset_C_Polyhedron_t, int,
-				     int);
-void ppl_set_inhomogeneous_gmp (ppl_Linear_Expression_t, mpz_t);
-void ppl_set_coef_gmp (ppl_Linear_Expression_t, ppl_dimension_type, mpz_t);
-void ppl_max_for_le_pointset (ppl_Pointset_Powerset_C_Polyhedron_t,
-                              ppl_Linear_Expression_t, mpz_t);
-void ppl_min_for_le_pointset (ppl_Pointset_Powerset_C_Polyhedron_t,
-			      ppl_Linear_Expression_t, mpz_t);
-ppl_Constraint_t ppl_build_relation (int, int, int, int,
-				     enum ppl_enum_Constraint_Type);
-void debug_gmp_value (mpz_t);
-bool ppl_powerset_is_empty (ppl_Pointset_Powerset_C_Polyhedron_t);
-
-
-/* Assigns to RES the value of the INTEGER_CST T.  */
-
-static inline void
-tree_int_to_gmp (tree t, mpz_t res)
-{
-  double_int di = tree_to_double_int (t);
-  mpz_set_double_int (res, di, TYPE_UNSIGNED (TREE_TYPE (t)));
-}
-
-/* Converts a GMP constant VAL to a tree and returns it.  */
-
-static inline tree
-gmp_cst_to_tree (tree type, mpz_t val)
-{
-  tree t = type ? type : integer_type_node;
-  mpz_t tmp;
-  double_int di;
-
-  mpz_init (tmp);
-  mpz_set (tmp, val);
-  di = mpz_get_double_int (t, tmp, true);
-  mpz_clear (tmp);
-
-  return double_int_to_tree (t, di);
-}
-
-/* Set the inhomogeneous term of E to the integer X.  */
-
-static inline void
-ppl_set_inhomogeneous (ppl_Linear_Expression_t e, int x)
-{
-  mpz_t v;
-  mpz_init (v);
-  mpz_set_si (v, x);
-  ppl_set_inhomogeneous_gmp (e, v);
-  mpz_clear (v);
-}
-
-/* Set the inhomogeneous term of E to the tree X.  */
-
-static inline void
-ppl_set_inhomogeneous_tree (ppl_Linear_Expression_t e, tree x)
-{
-  mpz_t v;
-  mpz_init (v);
-  tree_int_to_gmp (x, v);
-  ppl_set_inhomogeneous_gmp (e, v);
-  mpz_clear (v);
-}
-
-/* Set E[I] to integer X.  */
-
-static inline void
-ppl_set_coef (ppl_Linear_Expression_t e, ppl_dimension_type i, int x)
-{
-  mpz_t v;
-  mpz_init (v);
-  mpz_set_si (v, x);
-  ppl_set_coef_gmp (e, i, v);
-  mpz_clear (v);
-}
-
-/* Set E[I] to tree X.  */
-
-static inline void
-ppl_set_coef_tree (ppl_Linear_Expression_t e, ppl_dimension_type i, tree x)
-{
-  mpz_t v;
-  mpz_init (v);
-  tree_int_to_gmp (x, v);
-  ppl_set_coef_gmp (e, i, v);
-  mpz_clear (v);
-}
-
-/* Sets RES to the min of V1 and V2.  */
-
-static inline void
-value_min (mpz_t res, mpz_t v1, mpz_t v2)
-{
-  if (mpz_cmp (v1, v2) < 0)
-    mpz_set (res, v1);
-  else
-    mpz_set (res, v2);
-}
-
-/* Sets RES to the max of V1 and V2.  */
-
-static inline void
-value_max (mpz_t res, mpz_t v1, mpz_t v2)
-{
-  if (mpz_cmp (v1, v2) < 0)
-    mpz_set (res, v2);
-  else
-    mpz_set (res, v1);
-}
-
-/* Builds a new identity map for dimension DIM.  */
-
-static inline ppl_dimension_type *
-ppl_new_id_map (ppl_dimension_type dim)
-{
-  ppl_dimension_type *map, i;
-
-  map = (ppl_dimension_type *) XNEWVEC (ppl_dimension_type, dim);
-
-  for (i = 0; i < dim; i++)
-    map[i] = i;
-
-  return map;
-}
-
-/* Builds an interchange of dimensions A and B in MAP.  */
-
-static inline void
-ppl_interchange (ppl_dimension_type *map,
-		 ppl_dimension_type a,
-		 ppl_dimension_type b)
-{
-  map[a] = b;
-  map[b] = a;
-}
-
-#endif
-
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 3f4d7d8..cfa06ab 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1,5 +1,5 @@ 
 /* Detection of Static Control Parts (SCoP) for Graphite.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@amd.com> and
    Tobias Grosser <grosser@fim.uni-passau.de>.
 
@@ -20,6 +20,15 @@  along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
@@ -31,8 +40,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "sese.h"
 
 #ifdef HAVE_cloog
-#include "ppl_c.h"
-#include "graphite-ppl.h"
 #include "graphite-poly.h"
 #include "graphite-scop-detection.h"
 
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 31e5218..eacfcf1 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -19,6 +19,18 @@  along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <isl/constraint.h>
+#include <isl/aff.h>
+#include <cloog/cloog.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
@@ -31,11 +43,19 @@  along with GCC; see the file COPYING3.  If not see
 #include "sese.h"
 
 #ifdef HAVE_cloog
-#include "ppl_c.h"
-#include "graphite-ppl.h"
 #include "graphite-poly.h"
 #include "graphite-sese-to-poly.h"
 
+
+/* Assigns to RES the value of the INTEGER_CST T.  */
+
+static inline void
+tree_int_to_gmp (tree t, mpz_t res)
+{
+  double_int di = tree_to_double_int (t);
+  mpz_set_double_int (res, di, TYPE_UNSIGNED (TREE_TYPE (t)));
+}
+
 /* Returns the index of the PHI argument defined in the outermost
    loop.  */
 
@@ -390,6 +410,16 @@  build_scop_bbs (scop_p scop)
   sbitmap_free (visited);
 }
 
+/* Return an ISL identifier for the polyhedral basic block PBB.  */
+
+static isl_id *
+isl_id_for_pbb (scop_p s, poly_bb_p pbb)
+{
+  char name[50];
+  snprintf (name, sizeof (name), "S_%d", pbb_index (pbb));
+  return isl_id_alloc (s->ctx, name, pbb);
+}
+
 /* Converts the STATIC_SCHEDULE of PBB into a scattering polyhedron.
    We generate SCATTERING_DIMENSIONS scattering dimensions.
 
@@ -424,69 +454,54 @@  build_scop_bbs (scop_p scop)
    | 0   0   1   0   0   0   0   0  -5  = 0  */
 
 static void
-build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
+build_pbb_scattering_polyhedrons (isl_aff *static_sched,
 				  poly_bb_p pbb, int scattering_dimensions)
 {
   int i;
-  scop_p scop = PBB_SCOP (pbb);
   int nb_iterators = pbb_dim_iter_domain (pbb);
   int used_scattering_dimensions = nb_iterators * 2 + 1;
-  int nb_params = scop_nb_params (scop);
-  ppl_Coefficient_t c;
-  ppl_dimension_type dim = scattering_dimensions + nb_iterators + nb_params;
-  mpz_t v;
+  isl_int val;
+  isl_space *dc, *dm;
 
   gcc_assert (scattering_dimensions >= used_scattering_dimensions);
 
-  mpz_init (v);
-  ppl_new_Coefficient (&c);
-  PBB_TRANSFORMED (pbb) = poly_scattering_new ();
-  ppl_new_C_Polyhedron_from_space_dimension
-    (&PBB_TRANSFORMED_SCATTERING (pbb), dim, 0);
+  isl_int_init (val);
 
-  PBB_NB_SCATTERING_TRANSFORM (pbb) = scattering_dimensions;
+  dc = isl_set_get_space (pbb->domain);
+  dm = isl_space_add_dims (isl_space_from_domain (dc),
+			   isl_dim_out, scattering_dimensions);
+  pbb->schedule = isl_map_universe (dm);
 
   for (i = 0; i < scattering_dimensions; i++)
     {
-      ppl_Constraint_t cstr;
-      ppl_Linear_Expression_t expr;
-
-      ppl_new_Linear_Expression_with_dimension (&expr, dim);
-      mpz_set_si (v, 1);
-      ppl_assign_Coefficient_from_mpz_t (c, v);
-      ppl_Linear_Expression_add_to_coefficient (expr, i, c);
-
       /* Textual order inside this loop.  */
       if ((i % 2) == 0)
 	{
-	  ppl_Linear_Expression_coefficient (static_schedule, i / 2, c);
-	  ppl_Coefficient_to_mpz_t (c, v);
-	  mpz_neg (v, v);
-	  ppl_assign_Coefficient_from_mpz_t (c, v);
-	  ppl_Linear_Expression_add_to_inhomogeneous (expr, c);
+	  isl_constraint *c = isl_equality_alloc
+	      (isl_local_space_from_space (isl_map_get_space (pbb->schedule)));
+
+	  if (0 != isl_aff_get_coefficient (static_sched, isl_dim_in,
+					    i / 2, &val))
+	    gcc_unreachable ();
+
+	  isl_int_neg (val, val);
+	  c = isl_constraint_set_constant (c, val);
+	  c = isl_constraint_set_coefficient_si (c, isl_dim_out, i, 1);
+	  pbb->schedule = isl_map_add_constraint (pbb->schedule, c);
 	}
 
       /* Iterations of this loop.  */
       else /* if ((i % 2) == 1) */
 	{
 	  int loop = (i - 1) / 2;
-
-	  mpz_set_si (v, -1);
-	  ppl_assign_Coefficient_from_mpz_t (c, v);
-	  ppl_Linear_Expression_add_to_coefficient
-	    (expr, scattering_dimensions + loop, c);
+	  pbb->schedule = isl_map_equate (pbb->schedule, isl_dim_in, loop,
+					  isl_dim_out, i);
 	}
-
-      ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
-      ppl_Polyhedron_add_constraint (PBB_TRANSFORMED_SCATTERING (pbb), cstr);
-      ppl_delete_Linear_Expression (expr);
-      ppl_delete_Constraint (cstr);
     }
 
-  mpz_clear (v);
-  ppl_delete_Coefficient (c);
+  isl_int_clear (val);
 
-  PBB_ORIGINAL (pbb) = poly_scattering_copy (PBB_TRANSFORMED (pbb));
+  pbb->transformed = isl_map_copy (pbb->schedule);
 }
 
 /* Build for BB the static schedule.
@@ -531,26 +546,21 @@  build_scop_scattering (scop_p scop)
   int i;
   poly_bb_p pbb;
   gimple_bb_p previous_gbb = NULL;
-  ppl_Linear_Expression_t static_schedule;
-  ppl_Coefficient_t c;
-  mpz_t v;
+  isl_space *dc = isl_set_get_space (scop->context);
+  isl_aff *static_sched;
 
-  mpz_init (v);
-  ppl_new_Coefficient (&c);
-  ppl_new_Linear_Expression (&static_schedule);
+  dc = isl_space_add_dims (dc, isl_dim_set, number_of_loops());
+  static_sched = isl_aff_zero_on_domain (isl_local_space_from_space (dc));
 
   /* We have to start schedules at 0 on the first component and
      because we cannot compare_prefix_loops against a previous loop,
      prefix will be equal to zero, and that index will be
      incremented before copying.  */
-  mpz_set_si (v, -1);
-  ppl_assign_Coefficient_from_mpz_t (c, v);
-  ppl_Linear_Expression_add_to_coefficient (static_schedule, 0, c);
+  static_sched = isl_aff_add_coefficient_si (static_sched, isl_dim_in, 0, -1);
 
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
     {
       gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
-      ppl_Linear_Expression_t common;
       int prefix;
       int nb_scat_dims = pbb_dim_iter_domain (pbb) * 2 + 1;
 
@@ -560,102 +570,158 @@  build_scop_scattering (scop_p scop)
 	prefix = 0;
 
       previous_gbb = gbb;
-      ppl_new_Linear_Expression_with_dimension (&common, prefix + 1);
-      ppl_assign_Linear_Expression_from_Linear_Expression (common,
-							   static_schedule);
 
-      mpz_set_si (v, 1);
-      ppl_assign_Coefficient_from_mpz_t (c, v);
-      ppl_Linear_Expression_add_to_coefficient (common, prefix, c);
-      ppl_assign_Linear_Expression_from_Linear_Expression (static_schedule,
-							   common);
+      static_sched = isl_aff_add_coefficient_si (static_sched, isl_dim_in,
+						 prefix, 1);
+      build_pbb_scattering_polyhedrons (static_sched, pbb, nb_scat_dims);
+    }
+
+  isl_aff_free (static_sched);
+}
+
+static isl_pw_aff *extract_affine (scop_p, tree, __isl_take isl_space *space);
+
+/* Extract an affine expression from the chain of recurrence E.  */
+
+static isl_pw_aff *
+extract_affine_chrec (scop_p s, tree e, __isl_take isl_space *space)
+{
+  isl_pw_aff *lhs = extract_affine (s, CHREC_LEFT (e), isl_space_copy (space));
+  isl_pw_aff *rhs = extract_affine (s, CHREC_RIGHT (e), isl_space_copy (space));
+  isl_local_space *ls = isl_local_space_from_space (space);
+  unsigned pos = sese_loop_depth ((sese) s->region,
+				  get_loop (CHREC_VARIABLE (e))) - 1;
+  isl_aff *loop = isl_aff_set_coefficient_si
+    (isl_aff_zero_on_domain (ls), isl_dim_in, pos, 1);
+  isl_pw_aff *l = isl_pw_aff_from_aff (loop);
 
-      build_pbb_scattering_polyhedrons (common, pbb, nb_scat_dims);
+  /* Before multiplying, make sure that the result is affine.  */
+  gcc_assert (isl_pw_aff_is_cst (rhs)
+	      || isl_pw_aff_is_cst (l));
 
-      ppl_delete_Linear_Expression (common);
+  return isl_pw_aff_add (lhs, isl_pw_aff_mul (rhs, l));
+}
+
+/* Extract an affine expression from the mult_expr E.  */
+
+static isl_pw_aff *
+extract_affine_mul (scop_p s, tree e, __isl_take isl_space *space)
+{
+  isl_pw_aff *lhs = extract_affine (s, TREE_OPERAND (e, 0),
+				    isl_space_copy (space));
+  isl_pw_aff *rhs = extract_affine (s, TREE_OPERAND (e, 1), space);
+
+  if (!isl_pw_aff_is_cst (lhs)
+      && !isl_pw_aff_is_cst (rhs))
+    {
+      isl_pw_aff_free (lhs);
+      isl_pw_aff_free (rhs);
+      return NULL;
     }
 
-  mpz_clear (v);
-  ppl_delete_Coefficient (c);
-  ppl_delete_Linear_Expression (static_schedule);
+  return isl_pw_aff_mul (lhs, rhs);
 }
 
-/* Add the value K to the dimension D of the linear expression EXPR.  */
+/* Return an ISL identifier from the name of the ssa_name E.  */
 
-static void
-add_value_to_dim (ppl_dimension_type d, ppl_Linear_Expression_t expr,
-		  mpz_t k)
+static isl_id *
+isl_id_for_ssa_name (scop_p s, tree e)
 {
-  mpz_t val;
-  ppl_Coefficient_t coef;
+  const char *name = get_name (e);
+  isl_id *id;
 
-  ppl_new_Coefficient (&coef);
-  ppl_Linear_Expression_coefficient (expr, d, coef);
-  mpz_init (val);
-  ppl_Coefficient_to_mpz_t (coef, val);
+  if (name)
+    id = isl_id_alloc (s->ctx, name, e);
+  else
+    {
+      char name1[50];
+      snprintf (name1, sizeof (name1), "P_%d", SSA_NAME_VERSION (e));
+      id = isl_id_alloc (s->ctx, name1, e);
+    }
+
+  return id;
+}
 
-  mpz_add (val, val, k);
+/* Return an ISL identifier for the data reference DR.  */
 
-  ppl_assign_Coefficient_from_mpz_t (coef, val);
-  ppl_Linear_Expression_add_to_coefficient (expr, d, coef);
-  mpz_clear (val);
-  ppl_delete_Coefficient (coef);
+static isl_id *
+isl_id_for_dr (scop_p s, data_reference_p dr ATTRIBUTE_UNUSED)
+{
+  /* Data references all get the same isl_id.  They need to be comparable
+     and are distinguished through the first dimension, which contains the
+     alias set number.  */
+  return isl_id_alloc (s->ctx, "", 0);
 }
 
-/* In the context of scop S, scan E, the right hand side of a scalar
-   evolution function in loop VAR, and translate it to a linear
-   expression EXPR.  */
+/* Extract an affine expression from the ssa_name E.  */
 
-static void
-scan_tree_for_params_right_scev (sese s, tree e, int var,
-				 ppl_Linear_Expression_t expr)
+static isl_pw_aff *
+extract_affine_name (scop_p s, tree e, __isl_take isl_space *space)
 {
-  if (expr)
-    {
-      loop_p loop = get_loop (var);
-      ppl_dimension_type l = sese_loop_depth (s, loop) - 1;
-      mpz_t val;
+  isl_aff *aff;
+  isl_set *dom;
+  isl_id *id;
+  int dimension;
+
+  id = isl_id_for_ssa_name (s, e);
+  dimension = isl_space_find_dim_by_id (space, isl_dim_param, id);
+  isl_id_free(id);
+  dom = isl_set_universe (isl_space_copy (space));
+  aff = isl_aff_zero_on_domain (isl_local_space_from_space (space));
+  aff = isl_aff_add_coefficient_si (aff, isl_dim_param, dimension, 1);
+  return isl_pw_aff_alloc (dom, aff);
+}
 
-      /* Scalar evolutions should happen in the sese region.  */
-      gcc_assert (sese_loop_depth (s, loop) > 0);
+/* Extract an affine expression from the gmp constant G.  */
 
-      /* We can not deal with parametric strides like:
+static isl_pw_aff *
+extract_affine_gmp (mpz_t g, __isl_take isl_space *space)
+{
+  isl_local_space *ls = isl_local_space_from_space (isl_space_copy (space));
+  isl_aff *aff = isl_aff_zero_on_domain (ls);
+  isl_set *dom = isl_set_universe (space);
+  isl_int v;
 
-      | p = parameter;
-      |
-      | for i:
-      |   a [i * p] = ...   */
-      gcc_assert (TREE_CODE (e) == INTEGER_CST);
+  isl_int_init (v);
+  isl_int_set_gmp (v, g);
+  aff = isl_aff_add_constant (aff, v);
+  isl_int_clear (v);
 
-      mpz_init (val);
-      tree_int_to_gmp (e, val);
-      add_value_to_dim (l, expr, val);
-      mpz_clear (val);
-    }
+  return isl_pw_aff_alloc (dom, aff);
 }
 
-/* Scan the integer constant CST, and add it to the inhomogeneous part of the
-   linear expression EXPR.  K is the multiplier of the constant.  */
+/* Extract an affine expression from the integer_cst E.  */
 
-static void
-scan_tree_for_params_int (tree cst, ppl_Linear_Expression_t expr, mpz_t k)
+static isl_pw_aff *
+extract_affine_int (tree e, __isl_take isl_space *space)
 {
-  mpz_t val;
-  ppl_Coefficient_t coef;
-  tree type = TREE_TYPE (cst);
+  isl_pw_aff *res;
+  mpz_t g;
 
-  mpz_init (val);
+  mpz_init (g);
+  tree_int_to_gmp (e, g);
+  res = extract_affine_gmp (g, space);
+  mpz_clear (g);
 
-  /* Necessary to not get "-1 = 2^n - 1". */
-  mpz_set_double_int (val, double_int_sext (tree_to_double_int (cst),
-					    TYPE_PRECISION (type)), false);
+  return res;
+}
+
+/* Compute pwaff mod 2^width.  */
+
+static isl_pw_aff *
+wrap (isl_pw_aff *pwaff, unsigned width)
+{
+  isl_int mod;
 
-  mpz_mul (val, val, k);
-  ppl_new_Coefficient (&coef);
-  ppl_assign_Coefficient_from_mpz_t (coef, val);
-  ppl_Linear_Expression_add_to_inhomogeneous (expr, coef);
-  mpz_clear (val);
-  ppl_delete_Coefficient (coef);
+  isl_int_init (mod);
+  isl_int_set_si (mod, 1);
+  isl_int_mul_2exp (mod, mod, width);
+
+  pwaff = isl_pw_aff_mod (pwaff, mod);
+
+  isl_int_clear (mod);
+
+  return pwaff;
 }
 
 /* When parameter NAME is in REGION, returns its index in SESE_PARAMS.
@@ -698,168 +764,119 @@  parameter_index_in_region (tree name, sese region)
   return i;
 }
 
-/* In the context of sese S, scan the expression E and translate it to
-   a linear expression C.  When parsing a symbolic multiplication, K
-   represents the constant multiplier of an expression containing
-   parameters.  */
+/* Extract an affine expression from the tree E in the scop S.  */
 
-static void
-scan_tree_for_params (sese s, tree e, ppl_Linear_Expression_t c,
-		      mpz_t k)
+static isl_pw_aff *
+extract_affine (scop_p s, tree e, __isl_take isl_space *space)
 {
-  if (e == chrec_dont_know)
-    return;
+  isl_pw_aff *lhs, *rhs, *res;
+  tree type;
+
+  if (e == chrec_dont_know) {
+    isl_space_free (space);
+    return NULL;
+  }
 
   switch (TREE_CODE (e))
     {
     case POLYNOMIAL_CHREC:
-      scan_tree_for_params_right_scev (s, CHREC_RIGHT (e),
-				       CHREC_VARIABLE (e), c);
-      scan_tree_for_params (s, CHREC_LEFT (e), c, k);
+      res = extract_affine_chrec (s, e, space);
       break;
 
     case MULT_EXPR:
-      if (chrec_contains_symbols (TREE_OPERAND (e, 0)))
-	{
-	  if (c)
-	    {
-	      mpz_t val;
-	      gcc_assert (host_integerp (TREE_OPERAND (e, 1), 0));
-	      mpz_init (val);
-	      tree_int_to_gmp (TREE_OPERAND (e, 1), val);
-	      mpz_mul (val, val, k);
-	      scan_tree_for_params (s, TREE_OPERAND (e, 0), c, val);
-	      mpz_clear (val);
-	    }
-	  else
-	    scan_tree_for_params (s, TREE_OPERAND (e, 0), c, k);
-	}
-      else
-	{
-	  if (c)
-	    {
-	      mpz_t val;
-	      gcc_assert (host_integerp (TREE_OPERAND (e, 0), 0));
-	      mpz_init (val);
-	      tree_int_to_gmp (TREE_OPERAND (e, 0), val);
-	      mpz_mul (val, val, k);
-	      scan_tree_for_params (s, TREE_OPERAND (e, 1), c, val);
-	      mpz_clear (val);
-	    }
-	  else
-	    scan_tree_for_params (s, TREE_OPERAND (e, 1), c, k);
-	}
+      res = extract_affine_mul (s, e, space);
       break;
 
     case PLUS_EXPR:
     case POINTER_PLUS_EXPR:
-      scan_tree_for_params (s, TREE_OPERAND (e, 0), c, k);
-      scan_tree_for_params (s, TREE_OPERAND (e, 1), c, k);
+      lhs = extract_affine (s, TREE_OPERAND (e, 0), isl_space_copy (space));
+      rhs = extract_affine (s, TREE_OPERAND (e, 1), space);
+      res = isl_pw_aff_add (lhs, rhs);
       break;
 
     case MINUS_EXPR:
-      {
-	ppl_Linear_Expression_t tmp_expr = NULL;
-
-        if (c)
-	  {
-	    ppl_dimension_type dim;
-	    ppl_Linear_Expression_space_dimension (c, &dim);
-	    ppl_new_Linear_Expression_with_dimension (&tmp_expr, dim);
-	  }
-
-	scan_tree_for_params (s, TREE_OPERAND (e, 0), c, k);
-	scan_tree_for_params (s, TREE_OPERAND (e, 1), tmp_expr, k);
-
-	if (c)
-	  {
-	    ppl_subtract_Linear_Expression_from_Linear_Expression (c,
-								   tmp_expr);
-	    ppl_delete_Linear_Expression (tmp_expr);
-	  }
-
-	break;
-      }
+      lhs = extract_affine (s, TREE_OPERAND (e, 0), isl_space_copy (space));
+      rhs = extract_affine (s, TREE_OPERAND (e, 1), space);
+      res = isl_pw_aff_sub (lhs, rhs);
+      break;
 
     case NEGATE_EXPR:
-      {
-	ppl_Linear_Expression_t tmp_expr = NULL;
-
-	if (c)
-	  {
-	    ppl_dimension_type dim;
-	    ppl_Linear_Expression_space_dimension (c, &dim);
-	    ppl_new_Linear_Expression_with_dimension (&tmp_expr, dim);
-	  }
-
-	scan_tree_for_params (s, TREE_OPERAND (e, 0), tmp_expr, k);
+    case BIT_NOT_EXPR:
+      lhs = extract_affine (s, TREE_OPERAND (e, 0), isl_space_copy (space));
+      rhs = extract_affine (s, integer_minus_one_node, space);
+      res = isl_pw_aff_mul (lhs, rhs);
+      break;
 
-	if (c)
-	  {
-	    ppl_subtract_Linear_Expression_from_Linear_Expression (c,
-								   tmp_expr);
-	    ppl_delete_Linear_Expression (tmp_expr);
-	  }
+    case SSA_NAME:
+      gcc_assert (-1 != parameter_index_in_region_1 (e, SCOP_REGION (s)));
+      res = extract_affine_name (s, e, space);
+      break;
 
-	break;
-      }
+    case INTEGER_CST:
+      res = extract_affine_int (e, space);
+      /* No need to wrap a single integer.  */
+      return res;
 
-    case BIT_NOT_EXPR:
-      {
-	ppl_Linear_Expression_t tmp_expr = NULL;
+    CASE_CONVERT:
+    case NON_LVALUE_EXPR:
+      res = extract_affine (s, TREE_OPERAND (e, 0), space);
+      break;
 
-	if (c)
-	  {
-	    ppl_dimension_type dim;
-	    ppl_Linear_Expression_space_dimension (c, &dim);
-	    ppl_new_Linear_Expression_with_dimension (&tmp_expr, dim);
-	  }
+    default:
+      gcc_unreachable ();
+      break;
+    }
 
-	scan_tree_for_params (s, TREE_OPERAND (e, 0), tmp_expr, k);
+  type = TREE_TYPE (e);
+  if (TYPE_UNSIGNED (type))
+    res = wrap (res, TYPE_PRECISION (type));
 
-	if (c)
-	  {
-	    ppl_Coefficient_t coef;
-	    mpz_t minus_one;
+  return res;
+}
 
-	    ppl_subtract_Linear_Expression_from_Linear_Expression (c,
-								   tmp_expr);
-	    ppl_delete_Linear_Expression (tmp_expr);
-	    mpz_init (minus_one);
-	    mpz_set_si (minus_one, -1);
-	    ppl_new_Coefficient_from_mpz_t (&coef, minus_one);
-	    ppl_Linear_Expression_add_to_inhomogeneous (c, coef);
-	    mpz_clear (minus_one);
-	    ppl_delete_Coefficient (coef);
-	  }
+/* In the context of sese S, scan the expression E and translate it to
+   a linear expression C.  When parsing a symbolic multiplication, K
+   represents the constant multiplier of an expression containing
+   parameters.  */
 
-	break;
-      }
+static void
+scan_tree_for_params (sese s, tree e)
+{
+  if (e == chrec_dont_know)
+    return;
 
-    case SSA_NAME:
-      {
-	ppl_dimension_type p = parameter_index_in_region (e, s);
+  switch (TREE_CODE (e))
+    {
+    case POLYNOMIAL_CHREC:
+      scan_tree_for_params (s, CHREC_LEFT (e));
+      break;
 
-	if (c)
-	  {
-	    ppl_dimension_type dim;
-	    ppl_Linear_Expression_space_dimension (c, &dim);
-	    p += dim - sese_nb_params (s);
-	    add_value_to_dim (p, c, k);
-	  }
-	break;
-      }
+    case MULT_EXPR:
+      if (chrec_contains_symbols (TREE_OPERAND (e, 0)))
+	scan_tree_for_params (s, TREE_OPERAND (e, 0));
+      else
+	scan_tree_for_params (s, TREE_OPERAND (e, 1));
+      break;
 
-    case INTEGER_CST:
-      if (c)
-	scan_tree_for_params_int (e, c, k);
+    case PLUS_EXPR:
+    case POINTER_PLUS_EXPR:
+    case MINUS_EXPR:
+      scan_tree_for_params (s, TREE_OPERAND (e, 0));
+      scan_tree_for_params (s, TREE_OPERAND (e, 1));
       break;
 
+    case NEGATE_EXPR:
+    case BIT_NOT_EXPR:
     CASE_CONVERT:
     case NON_LVALUE_EXPR:
-      scan_tree_for_params (s, TREE_OPERAND (e, 0), c, k);
+      scan_tree_for_params (s, TREE_OPERAND (e, 0));
+      break;
+
+    case SSA_NAME:
+      parameter_index_in_region (e, s);
       break;
 
+    case INTEGER_CST:
     case ADDR_EXPR:
       break;
 
@@ -880,15 +897,11 @@  find_params_in_bb (sese region, gimple_bb_p gbb)
   data_reference_p dr;
   gimple stmt;
   loop_p loop = GBB_BB (gbb)->loop_father;
-  mpz_t one;
-
-  mpz_init (one);
-  mpz_set_si (one, 1);
 
   /* Find parameters in the access functions of data references.  */
   FOR_EACH_VEC_ELT (data_reference_p, GBB_DATA_REFS (gbb), i, dr)
     for (j = 0; j < DR_NUM_DIMENSIONS (dr); j++)
-      scan_tree_for_params (region, DR_ACCESS_FN (dr, j), NULL, one);
+      scan_tree_for_params (region, DR_ACCESS_FN (dr, j));
 
   /* Find parameters in conditional statements.  */
   FOR_EACH_VEC_ELT (gimple, GBB_CONDITIONS (gbb), i, stmt)
@@ -898,11 +911,9 @@  find_params_in_bb (sese region, gimple_bb_p gbb)
       tree rhs = scalar_evolution_in_region (region, loop,
 					     gimple_cond_rhs (stmt));
 
-      scan_tree_for_params (region, lhs, NULL, one);
-      scan_tree_for_params (region, rhs, NULL, one);
+      scan_tree_for_params (region, lhs);
+      scan_tree_for_params (region, rhs);
     }
-
-  mpz_clear (one);
 }
 
 /* Record the parameters used in the SCOP.  A variable is a parameter
@@ -915,10 +926,7 @@  find_scop_parameters (scop_p scop)
   unsigned i;
   sese region = SCOP_REGION (scop);
   struct loop *loop;
-  mpz_t one;
-
-  mpz_init (one);
-  mpz_set_si (one, 1);
+  int nbp;
 
   /* Find the parameters used in the loop bounds.  */
   FOR_EACH_VEC_ELT (loop_p, SESE_LOOP_NEST (region), i, loop)
@@ -929,87 +937,27 @@  find_scop_parameters (scop_p scop)
 	continue;
 
       nb_iters = scalar_evolution_in_region (region, loop, nb_iters);
-      scan_tree_for_params (region, nb_iters, NULL, one);
+      scan_tree_for_params (region, nb_iters);
     }
 
-  mpz_clear (one);
-
   /* Find the parameters used in data accesses.  */
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
     find_params_in_bb (region, PBB_BLACK_BOX (pbb));
 
-  scop_set_nb_params (scop, sese_nb_params (region));
+  nbp = sese_nb_params (region);
+  scop_set_nb_params (scop, nbp);
   SESE_ADD_PARAMS (region) = false;
 
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension
-    (&SCOP_CONTEXT (scop), scop_nb_params (scop), 0);
-}
-
-/* Insert in the SCOP context constraints from the estimation of the
-   number of iterations.  UB_EXPR is a linear expression describing
-   the number of iterations in a loop.  This expression is bounded by
-   the estimation NIT.  */
-
-static void
-add_upper_bounds_from_estimated_nit (scop_p scop, double_int nit,
-				     ppl_dimension_type dim,
-				     ppl_Linear_Expression_t ub_expr)
-{
-  mpz_t val;
-  ppl_Linear_Expression_t nb_iters_le;
-  ppl_Polyhedron_t pol;
-  ppl_Coefficient_t coef;
-  ppl_Constraint_t ub;
-
-  ppl_new_C_Polyhedron_from_space_dimension (&pol, dim, 0);
-  ppl_new_Linear_Expression_from_Linear_Expression (&nb_iters_le,
-						    ub_expr);
-
-  /* Construct the negated number of last iteration in VAL.  */
-  mpz_init (val);
-  mpz_set_double_int (val, nit, false);
-  mpz_sub_ui (val, val, 1);
-  mpz_neg (val, val);
-
-  /* NB_ITERS_LE holds the number of last iteration in
-     parametrical form.  Subtract estimated number of last
-     iteration and assert that result is not positive.  */
-  ppl_new_Coefficient_from_mpz_t (&coef, val);
-  ppl_Linear_Expression_add_to_inhomogeneous (nb_iters_le, coef);
-  ppl_delete_Coefficient (coef);
-  ppl_new_Constraint (&ub, nb_iters_le,
-		      PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL);
-  ppl_Polyhedron_add_constraint (pol, ub);
-
-  /* Remove all but last GDIM dimensions from POL to obtain
-     only the constraints on the parameters.  */
   {
-    graphite_dim_t gdim = scop_nb_params (scop);
-    ppl_dimension_type *dims = XNEWVEC (ppl_dimension_type, dim - gdim);
-    graphite_dim_t i;
+    tree e;
+    isl_space *space = isl_space_set_alloc (scop->ctx, nbp, 0);
 
-    for (i = 0; i < dim - gdim; i++)
-      dims[i] = i;
+    FOR_EACH_VEC_ELT (tree, SESE_PARAMS (region), i, e)
+      space = isl_space_set_dim_id (space, isl_dim_param, i,
+				    isl_id_for_ssa_name (scop, e));
 
-    ppl_Polyhedron_remove_space_dimensions (pol, dims, dim - gdim);
-    XDELETEVEC (dims);
+    scop->context = isl_set_universe (space);
   }
-
-  /* Add the constraints on the parameters to the SCoP context.  */
-  {
-    ppl_Pointset_Powerset_C_Polyhedron_t constraints_ps;
-
-    ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
-      (&constraints_ps, pol);
-    ppl_Pointset_Powerset_C_Polyhedron_intersection_assign
-      (SCOP_CONTEXT (scop), constraints_ps);
-    ppl_delete_Pointset_Powerset_C_Polyhedron (constraints_ps);
-  }
-
-  ppl_delete_Polyhedron (pol);
-  ppl_delete_Linear_Expression (nb_iters_le);
-  ppl_delete_Constraint (ub);
-  mpz_clear (val);
 }
 
 /* Builds the constraint polyhedra for LOOP in SCOP.  OUTER_PH gives
@@ -1017,232 +965,179 @@  add_upper_bounds_from_estimated_nit (scop_p scop, double_int nit,
 
 static void
 build_loop_iteration_domains (scop_p scop, struct loop *loop,
-                              ppl_Polyhedron_t outer_ph, int nb,
-			      ppl_Pointset_Powerset_C_Polyhedron_t *domains)
+                              int nb,
+			      isl_set *outer, isl_set **doms)
 {
-  int i;
-  ppl_Polyhedron_t ph;
   tree nb_iters = number_of_latch_executions (loop);
-  ppl_dimension_type dim = nb + 1 + scop_nb_params (scop);
   sese region = SCOP_REGION (scop);
 
-  {
-    ppl_const_Constraint_System_t pcs;
-    ppl_dimension_type *map
-      = (ppl_dimension_type *) XNEWVEC (ppl_dimension_type, dim);
-
-    ppl_new_C_Polyhedron_from_space_dimension (&ph, dim, 0);
-    ppl_Polyhedron_get_constraints (outer_ph, &pcs);
-    ppl_Polyhedron_add_constraints (ph, pcs);
+  isl_set *inner = isl_set_copy (outer);
+  isl_space *space;
+  isl_constraint *c;
+  int pos = isl_set_dim (outer, isl_dim_set);
+  isl_int v;
+  mpz_t g;
 
-    for (i = 0; i < (int) nb; i++)
-      map[i] = i;
-    for (i = (int) nb; i < (int) dim - 1; i++)
-      map[i] = i + 1;
-    map[dim - 1] = nb;
+  mpz_init (g);
+  isl_int_init (v);
 
-    ppl_Polyhedron_map_space_dimensions (ph, map, dim);
-    free (map);
-  }
+  inner = isl_set_add_dims (inner, isl_dim_set, 1);
+  space = isl_set_get_space (inner);
 
   /* 0 <= loop_i */
-  {
-    ppl_Constraint_t lb;
-    ppl_Linear_Expression_t lb_expr;
-
-    ppl_new_Linear_Expression_with_dimension (&lb_expr, dim);
-    ppl_set_coef (lb_expr, nb, 1);
-    ppl_new_Constraint (&lb, lb_expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-    ppl_delete_Linear_Expression (lb_expr);
-    ppl_Polyhedron_add_constraint (ph, lb);
-    ppl_delete_Constraint (lb);
-  }
+  c = isl_inequality_alloc
+      (isl_local_space_from_space (isl_space_copy (space)));
+  c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, 1);
+  inner = isl_set_add_constraint (inner, c);
 
+  /* loop_i <= cst_nb_iters */
   if (TREE_CODE (nb_iters) == INTEGER_CST)
     {
-      ppl_Constraint_t ub;
-      ppl_Linear_Expression_t ub_expr;
-
-      ppl_new_Linear_Expression_with_dimension (&ub_expr, dim);
-
-      /* loop_i <= cst_nb_iters */
-      ppl_set_coef (ub_expr, nb, -1);
-      ppl_set_inhomogeneous_tree (ub_expr, nb_iters);
-      ppl_new_Constraint (&ub, ub_expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-      ppl_Polyhedron_add_constraint (ph, ub);
-      ppl_delete_Linear_Expression (ub_expr);
-      ppl_delete_Constraint (ub);
+      c = isl_inequality_alloc
+	  (isl_local_space_from_space(isl_space_copy (space)));
+      c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, -1);
+      tree_int_to_gmp (nb_iters, g);
+      isl_int_set_gmp (v, g);
+      c = isl_constraint_set_constant (c, v);
+      inner = isl_set_add_constraint (inner, c);
     }
+
+  /* loop_i <= expr_nb_iters */
   else if (!chrec_contains_undetermined (nb_iters))
     {
-      mpz_t one;
-      ppl_Constraint_t ub;
-      ppl_Linear_Expression_t ub_expr;
       double_int nit;
+      isl_pw_aff *aff;
+      isl_set *valid;
+      isl_local_space *ls;
+      isl_aff *al;
+      isl_set *le;
 
-      mpz_init (one);
-      mpz_set_si (one, 1);
-      ppl_new_Linear_Expression_with_dimension (&ub_expr, dim);
       nb_iters = scalar_evolution_in_region (region, loop, nb_iters);
-      scan_tree_for_params (SCOP_REGION (scop), nb_iters, ub_expr, one);
-      mpz_clear (one);
+
+      aff = extract_affine (scop, nb_iters, isl_set_get_space (inner));
+      valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (aff));
+      valid = isl_set_project_out (valid, isl_dim_set, 0,
+				   isl_set_dim (valid, isl_dim_set));
+      scop->context = isl_set_intersect (scop->context, valid);
+
+      ls = isl_local_space_from_space (isl_space_copy (space));
+      al = isl_aff_set_coefficient_si (isl_aff_zero_on_domain (ls),
+				       isl_dim_in, pos, 1);
+      le = isl_pw_aff_le_set (isl_pw_aff_from_aff (al),
+			      isl_pw_aff_copy (aff));
+      inner = isl_set_intersect (inner, le);
 
       if (max_stmt_executions (loop, &nit))
-	add_upper_bounds_from_estimated_nit (scop, nit, dim, ub_expr);
+	{
+	  /* Insert in the context the constraints from the
+	     estimation of the number of iterations NIT and the
+	     symbolic number of iterations (involving parameter
+	     names) NB_ITERS.  First, build the affine expression
+	     "NIT - NB_ITERS" and then say that it is positive,
+	     i.e., NIT approximates NB_ITERS: "NIT >= NB_ITERS".  */
+	  isl_pw_aff *approx;
+	  mpz_t g;
+	  isl_set *x;
+	  isl_constraint *c;
 
-      /* loop_i <= expr_nb_iters */
-      ppl_set_coef (ub_expr, nb, -1);
-      ppl_new_Constraint (&ub, ub_expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-      ppl_Polyhedron_add_constraint (ph, ub);
-      ppl_delete_Linear_Expression (ub_expr);
-      ppl_delete_Constraint (ub);
+	  mpz_init (g);
+	  mpz_set_double_int (g, nit, false);
+	  mpz_sub_ui (g, g, 1);
+	  approx = extract_affine_gmp (g, isl_set_get_space (inner));
+	  x = isl_pw_aff_ge_set (approx, aff);
+	  x = isl_set_project_out (x, isl_dim_set, 0,
+				   isl_set_dim (x, isl_dim_set));
+	  scop->context = isl_set_intersect (scop->context, x);
+
+	  c = isl_inequality_alloc
+	      (isl_local_space_from_space (isl_space_copy (space)));
+	  c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, -1);
+	  isl_int_set_gmp (v, g);
+	  mpz_clear (g);
+	  c = isl_constraint_set_constant (c, v);
+	  inner = isl_set_add_constraint (inner, c);
+	}
     }
   else
     gcc_unreachable ();
 
   if (loop->inner && loop_in_sese_p (loop->inner, region))
-    build_loop_iteration_domains (scop, loop->inner, ph, nb + 1, domains);
+    build_loop_iteration_domains (scop, loop->inner, nb + 1,
+				  isl_set_copy (inner), doms);
 
   if (nb != 0
       && loop->next
       && loop_in_sese_p (loop->next, region))
-    build_loop_iteration_domains (scop, loop->next, outer_ph, nb, domains);
+    build_loop_iteration_domains (scop, loop->next, nb,
+				  isl_set_copy (outer), doms);
 
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
-    (&domains[loop->num], ph);
+  doms[loop->num] = inner;
 
-  ppl_delete_Polyhedron (ph);
+  isl_set_free (outer);
+  isl_space_free (space);
+  isl_int_clear (v);
+  mpz_clear (g);
 }
 
 /* Returns a linear expression for tree T evaluated in PBB.  */
 
-static ppl_Linear_Expression_t
-create_linear_expr_from_tree (poly_bb_p pbb, tree t)
+static isl_pw_aff *
+create_pw_aff_from_tree (poly_bb_p pbb, tree t)
 {
-  mpz_t one;
-  ppl_Linear_Expression_t res;
-  ppl_dimension_type dim;
-  sese region = SCOP_REGION (PBB_SCOP (pbb));
-  loop_p loop = pbb_loop (pbb);
-
-  dim = pbb_dim_iter_domain (pbb) + pbb_nb_params (pbb);
-  ppl_new_Linear_Expression_with_dimension (&res, dim);
+  scop_p scop = PBB_SCOP (pbb);
 
-  t = scalar_evolution_in_region (region, loop, t);
+  t = scalar_evolution_in_region (SCOP_REGION (scop), pbb_loop (pbb), t);
   gcc_assert (!automatically_generated_chrec_p (t));
 
-  mpz_init (one);
-  mpz_set_si (one, 1);
-  scan_tree_for_params (region, t, res, one);
-  mpz_clear (one);
-
-  return res;
+  return extract_affine (scop, t, isl_set_get_space (pbb->domain));
 }
 
-/* Returns the ppl constraint type from the gimple tree code CODE.  */
-
-static enum ppl_enum_Constraint_Type
-ppl_constraint_type_from_tree_code (enum tree_code code)
-{
-  switch (code)
-    {
-    /* We do not support LT and GT to be able to work with C_Polyhedron.
-       As we work on integer polyhedron "a < b" can be expressed by
-       "a + 1 <= b".  */
-    case LT_EXPR:
-    case GT_EXPR:
-      gcc_unreachable ();
-
-    case LE_EXPR:
-      return PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL;
-
-    case GE_EXPR:
-      return PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL;
-
-    case EQ_EXPR:
-      return PPL_CONSTRAINT_TYPE_EQUAL;
-
-    default:
-      gcc_unreachable ();
-    }
-}
-
-/* Add conditional statement STMT to PS.  It is evaluated in PBB and
-   CODE is used as the comparison operator.  This allows us to invert the
-   condition or to handle inequalities.  */
+/* Add conditional statement STMT to pbb.  CODE is used as the comparison
+   operator.  This allows us to invert the condition or to handle
+   inequalities.  */
 
 static void
-add_condition_to_domain (ppl_Pointset_Powerset_C_Polyhedron_t ps, gimple stmt,
-			 poly_bb_p pbb, enum tree_code code)
+add_condition_to_pbb (poly_bb_p pbb, gimple stmt, enum tree_code code)
 {
-  mpz_t v;
-  ppl_Coefficient_t c;
-  ppl_Linear_Expression_t left, right;
-  ppl_Constraint_t cstr;
-  enum ppl_enum_Constraint_Type type;
+  isl_pw_aff *lhs = create_pw_aff_from_tree (pbb, gimple_cond_lhs (stmt));
+  isl_pw_aff *rhs = create_pw_aff_from_tree (pbb, gimple_cond_rhs (stmt));
+  isl_set *cond;
 
-  left = create_linear_expr_from_tree (pbb, gimple_cond_lhs (stmt));
-  right = create_linear_expr_from_tree (pbb, gimple_cond_rhs (stmt));
-
-  /* If we have < or > expressions convert them to <= or >= by adding 1 to
-     the left or the right side of the expression. */
-  if (code == LT_EXPR)
-    {
-      mpz_init (v);
-      mpz_set_si (v, 1);
-      ppl_new_Coefficient (&c);
-      ppl_assign_Coefficient_from_mpz_t (c, v);
-      ppl_Linear_Expression_add_to_inhomogeneous (left, c);
-      ppl_delete_Coefficient (c);
-      mpz_clear (v);
-
-      code = LE_EXPR;
-    }
-  else if (code == GT_EXPR)
+  switch (code)
     {
-      mpz_init (v);
-      mpz_set_si (v, 1);
-      ppl_new_Coefficient (&c);
-      ppl_assign_Coefficient_from_mpz_t (c, v);
-      ppl_Linear_Expression_add_to_inhomogeneous (right, c);
-      ppl_delete_Coefficient (c);
-      mpz_clear (v);
-
-      code = GE_EXPR;
-    }
+      case LT_EXPR:
+	cond = isl_pw_aff_lt_set (lhs, rhs);
+	break;
 
-  type = ppl_constraint_type_from_tree_code (code);
+      case GT_EXPR:
+	cond = isl_pw_aff_gt_set (lhs, rhs);
+	break;
 
-  ppl_subtract_Linear_Expression_from_Linear_Expression (left, right);
+      case LE_EXPR:
+	cond = isl_pw_aff_le_set (lhs, rhs);
+	break;
 
-  ppl_new_Constraint (&cstr, left, type);
-  ppl_Pointset_Powerset_C_Polyhedron_add_constraint (ps, cstr);
+      case GE_EXPR:
+	cond = isl_pw_aff_ge_set (lhs, rhs);
+	break;
 
-  ppl_delete_Constraint (cstr);
-  ppl_delete_Linear_Expression (left);
-  ppl_delete_Linear_Expression (right);
-}
+      case EQ_EXPR:
+	cond = isl_pw_aff_eq_set (lhs, rhs);
+	break;
 
-/* Add conditional statement STMT to pbb.  CODE is used as the comparison
-   operator.  This allows us to invert the condition or to handle
-   inequalities.  */
+      case NE_EXPR:
+	cond = isl_pw_aff_ne_set (lhs, rhs);
+	break;
 
-static void
-add_condition_to_pbb (poly_bb_p pbb, gimple stmt, enum tree_code code)
-{
-  if (code == NE_EXPR)
-    {
-      ppl_Pointset_Powerset_C_Polyhedron_t left = PBB_DOMAIN (pbb);
-      ppl_Pointset_Powerset_C_Polyhedron_t right;
-      ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-	(&right, left);
-      add_condition_to_domain (left, stmt, pbb, LT_EXPR);
-      add_condition_to_domain (right, stmt, pbb, GT_EXPR);
-      ppl_Pointset_Powerset_C_Polyhedron_upper_bound_assign (left, right);
-      ppl_delete_Pointset_Powerset_C_Polyhedron (right);
+      default:
+	isl_pw_aff_free(lhs);
+	isl_pw_aff_free(rhs);
+	return;
     }
-  else
-    add_condition_to_domain (PBB_DOMAIN (pbb), stmt, pbb, code);
+
+  cond = isl_set_coalesce (cond);
+  cond = isl_set_set_tuple_id (cond, isl_set_get_tuple_id (pbb->domain));
+  pbb->domain = isl_set_intersect (pbb->domain, cond);
 }
 
 /* Add conditions to the domain of PBB.  */
@@ -1273,7 +1168,7 @@  add_conditions_to_domain (poly_bb_p pbb)
 	  }
 
       case GIMPLE_SWITCH:
-	/* Switch statements are not supported right now - fall throught.  */
+	/* Switch statements are not supported right now - fall through.  */
 
       default:
 	gcc_unreachable ();
@@ -1420,10 +1315,8 @@  build_sese_conditions (sese region)
    of P.  */
 
 static void
-add_param_constraints (scop_p scop, ppl_Polyhedron_t context, graphite_dim_t p)
+add_param_constraints (scop_p scop, graphite_dim_t p)
 {
-  ppl_Constraint_t cstr;
-  ppl_Linear_Expression_t le;
   tree parameter = VEC_index (tree, SESE_PARAMS (SCOP_REGION (scop)), p);
   tree type = TREE_TYPE (parameter);
   tree lb = NULL_TREE;
@@ -1441,24 +1334,44 @@  add_param_constraints (scop_p scop, ppl_Polyhedron_t context, graphite_dim_t p)
 
   if (lb)
     {
-      ppl_new_Linear_Expression_with_dimension (&le, scop_nb_params (scop));
-      ppl_set_coef (le, p, -1);
-      ppl_set_inhomogeneous_tree (le, lb);
-      ppl_new_Constraint (&cstr, le, PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL);
-      ppl_Polyhedron_add_constraint (context, cstr);
-      ppl_delete_Linear_Expression (le);
-      ppl_delete_Constraint (cstr);
+      isl_space *space = isl_set_get_space (scop->context);
+      isl_constraint *c;
+      mpz_t g;
+      isl_int v;
+
+      c = isl_inequality_alloc (isl_local_space_from_space (space));
+      mpz_init (g);
+      isl_int_init (v);
+      tree_int_to_gmp (lb, g);
+      isl_int_set_gmp (v, g);
+      isl_int_neg (v, v);
+      mpz_clear (g);
+      c = isl_constraint_set_constant (c, v);
+      isl_int_clear (v);
+      c = isl_constraint_set_coefficient_si (c, isl_dim_param, p, 1);
+
+      scop->context = isl_set_add_constraint (scop->context, c);
     }
 
   if (ub)
     {
-      ppl_new_Linear_Expression_with_dimension (&le, scop_nb_params (scop));
-      ppl_set_coef (le, p, -1);
-      ppl_set_inhomogeneous_tree (le, ub);
-      ppl_new_Constraint (&cstr, le, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-      ppl_Polyhedron_add_constraint (context, cstr);
-      ppl_delete_Linear_Expression (le);
-      ppl_delete_Constraint (cstr);
+      isl_space *space = isl_set_get_space (scop->context);
+      isl_constraint *c;
+      mpz_t g;
+      isl_int v;
+
+      c = isl_inequality_alloc (isl_local_space_from_space (space));
+
+      mpz_init (g);
+      isl_int_init (v);
+      tree_int_to_gmp (ub, g);
+      isl_int_set_gmp (v, g);
+      mpz_clear (g);
+      c = isl_constraint_set_constant (c, v);
+      isl_int_clear (v);
+      c = isl_constraint_set_coefficient_si (c, isl_dim_param, p, -1);
+
+      scop->context = isl_set_add_constraint (scop->context, c);
     }
 }
 
@@ -1469,22 +1382,10 @@  add_param_constraints (scop_p scop, ppl_Polyhedron_t context, graphite_dim_t p)
 static void
 build_scop_context (scop_p scop)
 {
-  ppl_Polyhedron_t context;
-  ppl_Pointset_Powerset_C_Polyhedron_t ps;
   graphite_dim_t p, n = scop_nb_params (scop);
 
-  ppl_new_C_Polyhedron_from_space_dimension (&context, n, 0);
-
   for (p = 0; p < n; p++)
-    add_param_constraints (scop, context, p);
-
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
-    (&ps, context);
-  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign
-    (SCOP_CONTEXT (scop), ps);
-
-  ppl_delete_Pointset_Powerset_C_Polyhedron (ps);
-  ppl_delete_Polyhedron (context);
+    add_param_constraints (scop, p);
 }
 
 /* Build the iteration domains: the loops belonging to the current
@@ -1497,36 +1398,33 @@  build_scop_iteration_domain (scop_p scop)
   struct loop *loop;
   sese region = SCOP_REGION (scop);
   int i;
-  ppl_Polyhedron_t ph;
   poly_bb_p pbb;
   int nb_loops = number_of_loops ();
-  ppl_Pointset_Powerset_C_Polyhedron_t *domains
-    = XNEWVEC (ppl_Pointset_Powerset_C_Polyhedron_t, nb_loops);
-
-  for (i = 0; i < nb_loops; i++)
-    domains[i] = NULL;
-
-  ppl_new_C_Polyhedron_from_space_dimension (&ph, scop_nb_params (scop), 0);
+  isl_set **doms = XCNEWVEC (isl_set *, nb_loops);
 
   FOR_EACH_VEC_ELT (loop_p, SESE_LOOP_NEST (region), i, loop)
     if (!loop_in_sese_p (loop_outer (loop), region))
-      build_loop_iteration_domains (scop, loop, ph, 0, domains);
+      build_loop_iteration_domains (scop, loop, 0,
+				    isl_set_copy (scop->context), doms);
 
   FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
-    if (domains[gbb_loop (PBB_BLACK_BOX (pbb))->num])
-      ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-	(&PBB_DOMAIN (pbb), (ppl_const_Pointset_Powerset_C_Polyhedron_t)
-	 domains[gbb_loop (PBB_BLACK_BOX (pbb))->num]);
-    else
-      ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron
-	(&PBB_DOMAIN (pbb), ph);
+    {
+      loop = pbb_loop (pbb);
+
+      if (doms[loop->num])
+	pbb->domain = isl_set_copy (doms[loop->num]);
+      else
+	pbb->domain = isl_set_copy (scop->context);
+
+      pbb->domain = isl_set_set_tuple_id (pbb->domain,
+					  isl_id_for_pbb (scop, pbb));
+    }
 
   for (i = 0; i < nb_loops; i++)
-    if (domains[i])
-      ppl_delete_Pointset_Powerset_C_Polyhedron (domains[i]);
+    if (doms[i])
+      isl_set_free (doms[i]);
 
-  ppl_delete_Polyhedron (ph);
-  free (domains);
+  free (doms);
 }
 
 /* Add a constrain to the ACCESSES polyhedron for the alias set of
@@ -1534,28 +1432,44 @@  build_scop_iteration_domain (scop_p scop)
    ACCESSES polyhedron, DOM_NB_DIMS is the dimension of the iteration
    domain.  */
 
-static void
-pdr_add_alias_set (ppl_Polyhedron_t accesses, data_reference_p dr,
-		   ppl_dimension_type accessp_nb_dims,
-		   ppl_dimension_type dom_nb_dims)
+static isl_map *
+pdr_add_alias_set (isl_map *acc, data_reference_p dr)
 {
-  ppl_Linear_Expression_t alias;
-  ppl_Constraint_t cstr;
+  isl_constraint *c;
   int alias_set_num = 0;
   base_alias_pair *bap = (base_alias_pair *)(dr->aux);
 
   if (bap && bap->alias_set)
     alias_set_num = *(bap->alias_set);
 
-  ppl_new_Linear_Expression_with_dimension (&alias, accessp_nb_dims);
+  c = isl_equality_alloc
+      (isl_local_space_from_space (isl_map_get_space (acc)));
+  c = isl_constraint_set_constant_si (c, -alias_set_num);
+  c = isl_constraint_set_coefficient_si (c, isl_dim_out, 0, 1);
+
+  return isl_map_add_constraint (acc, c);
+}
+
+/* Assign the affine expression INDEX to the output dimension POS of
+   MAP and return the result.  */
+
+static isl_map *
+set_index (isl_map *map, int pos, isl_pw_aff *index)
+{
+  isl_map *index_map;
+  int len = isl_map_dim (map, isl_dim_out);
+  isl_id *id;
+
+  index_map = isl_map_from_pw_aff (index);
+  index_map = isl_map_insert_dims (index_map, isl_dim_out, 0, pos);
+  index_map = isl_map_add_dims (index_map, isl_dim_out, len - pos - 1);
 
-  ppl_set_coef (alias, dom_nb_dims, 1);
-  ppl_set_inhomogeneous (alias, -alias_set_num);
-  ppl_new_Constraint (&cstr, alias, PPL_CONSTRAINT_TYPE_EQUAL);
-  ppl_Polyhedron_add_constraint (accesses, cstr);
+  id = isl_map_get_tuple_id (map, isl_dim_out);
+  index_map = isl_map_set_tuple_id (index_map, isl_dim_out, id);
+  id = isl_map_get_tuple_id (map, isl_dim_in);
+  index_map = isl_map_set_tuple_id (index_map, isl_dim_in, id);
 
-  ppl_delete_Linear_Expression (alias);
-  ppl_delete_Constraint (cstr);
+  return isl_map_intersect (map, index_map);
 }
 
 /* Add to ACCESSES polyhedron equalities defining the access functions
@@ -1563,43 +1477,23 @@  pdr_add_alias_set (ppl_Polyhedron_t accesses, data_reference_p dr,
    polyhedron, DOM_NB_DIMS is the dimension of the iteration domain.
    PBB is the poly_bb_p that contains the data reference DR.  */
 
-static void
-pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
-			 ppl_dimension_type accessp_nb_dims,
-			 ppl_dimension_type dom_nb_dims,
-			 poly_bb_p pbb)
+static isl_map *
+pdr_add_memory_accesses (isl_map *acc, data_reference_p dr, poly_bb_p pbb)
 {
   int i, nb_subscripts = DR_NUM_DIMENSIONS (dr);
-  mpz_t v;
   scop_p scop = PBB_SCOP (pbb);
-  sese region = SCOP_REGION (scop);
-
-  mpz_init (v);
 
   for (i = 0; i < nb_subscripts; i++)
     {
-      ppl_Linear_Expression_t fn, access;
-      ppl_Constraint_t cstr;
-      ppl_dimension_type subscript = dom_nb_dims + 1 + i;
+      isl_pw_aff *aff;
       tree afn = DR_ACCESS_FN (dr, nb_subscripts - 1 - i);
 
-      ppl_new_Linear_Expression_with_dimension (&fn, dom_nb_dims);
-      ppl_new_Linear_Expression_with_dimension (&access, accessp_nb_dims);
-
-      mpz_set_si (v, 1);
-      scan_tree_for_params (region, afn, fn, v);
-      ppl_assign_Linear_Expression_from_Linear_Expression (access, fn);
-
-      ppl_set_coef (access, subscript, -1);
-      ppl_new_Constraint (&cstr, access, PPL_CONSTRAINT_TYPE_EQUAL);
-      ppl_Polyhedron_add_constraint (accesses, cstr);
-
-      ppl_delete_Linear_Expression (fn);
-      ppl_delete_Linear_Expression (access);
-      ppl_delete_Constraint (cstr);
+      aff = extract_affine (scop, afn,
+			    isl_space_domain (isl_map_get_space (acc)));
+      acc = set_index (acc, i + 1, aff);
     }
 
-  mpz_clear (v);
+  return acc;
 }
 
 /* Add constrains representing the size of the accessed data to the
@@ -1607,63 +1501,68 @@  pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
    ACCESSES polyhedron, DOM_NB_DIMS is the dimension of the iteration
    domain.  */
 
-static void
-pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
-			 ppl_dimension_type accessp_nb_dims,
-			 ppl_dimension_type dom_nb_dims)
+static isl_set *
+pdr_add_data_dimensions (isl_set *extent, scop_p scop, data_reference_p dr)
 {
   tree ref = DR_REF (dr);
   int i, nb_subscripts = DR_NUM_DIMENSIONS (dr);
 
   for (i = nb_subscripts - 1; i >= 0; i--, ref = TREE_OPERAND (ref, 0))
     {
-      ppl_Linear_Expression_t expr;
-      ppl_Constraint_t cstr;
-      ppl_dimension_type subscript = dom_nb_dims + 1 + i;
       tree low, high;
 
       if (TREE_CODE (ref) != ARRAY_REF)
 	break;
 
       low = array_ref_low_bound (ref);
-
-      /* subscript - low >= 0 */
-      if (host_integerp (low, 0))
-	{
-	  tree minus_low;
-
-	  ppl_new_Linear_Expression_with_dimension (&expr, accessp_nb_dims);
-	  ppl_set_coef (expr, subscript, 1);
-
-	  minus_low = fold_build1 (NEGATE_EXPR, TREE_TYPE (low), low);
-	  ppl_set_inhomogeneous_tree (expr, minus_low);
-
-	  ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-	  ppl_Polyhedron_add_constraint (accesses, cstr);
-	  ppl_delete_Linear_Expression (expr);
-	  ppl_delete_Constraint (cstr);
-	}
-
       high = array_ref_up_bound (ref);
 
-      /* high - subscript >= 0 */
-      if (high && host_integerp (high, 0)
+      /* XXX The PPL code dealt separately with
+         subscript - low >= 0 and high - subscript >= 0 in case one of
+	 the two bounds isn't known.  Do the same here?  */
+
+      if (host_integerp (low, 0)
+	  && high
+	  && host_integerp (high, 0)
 	  /* 1-element arrays at end of structures may extend over
 	     their declared size.  */
 	  && !(array_at_struct_end_p (ref)
 	       && operand_equal_p (low, high, 0)))
 	{
-	  ppl_new_Linear_Expression_with_dimension (&expr, accessp_nb_dims);
-	  ppl_set_coef (expr, subscript, -1);
+	  isl_id *id;
+	  isl_aff *aff;
+	  isl_set *univ, *lbs, *ubs;
+	  isl_pw_aff *index;
+	  isl_space *space;
+	  isl_set *valid;
+	  isl_pw_aff *lb = extract_affine_int (low, isl_set_get_space (extent));
+	  isl_pw_aff *ub = extract_affine_int (high, isl_set_get_space (extent));
+
+	  /* high >= 0 */
+	  valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (ub));
+	  valid = isl_set_project_out (valid, isl_dim_set, 0,
+				       isl_set_dim (valid, isl_dim_set));
+	  scop->context = isl_set_intersect (scop->context, valid);
+
+	  space = isl_set_get_space (extent);
+	  aff = isl_aff_zero_on_domain (isl_local_space_from_space (space));
+	  aff = isl_aff_add_coefficient_si (aff, isl_dim_in, i + 1, 1);
+	  univ = isl_set_universe (isl_space_domain (isl_aff_get_space (aff)));
+	  index = isl_pw_aff_alloc (univ, aff);
 
-	  ppl_set_inhomogeneous_tree (expr, high);
+	  id = isl_set_get_tuple_id (extent);
+	  lb = isl_pw_aff_set_tuple_id (lb, isl_dim_in, isl_id_copy (id));
+	  ub = isl_pw_aff_set_tuple_id (ub, isl_dim_in, id);
 
-	  ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
-	  ppl_Polyhedron_add_constraint (accesses, cstr);
-	  ppl_delete_Linear_Expression (expr);
-	  ppl_delete_Constraint (cstr);
+	  /* low <= sub_i <= high */
+	  lbs = isl_pw_aff_ge_set (isl_pw_aff_copy (index), lb);
+	  ubs = isl_pw_aff_le_set (index, ub);
+	  extent = isl_set_intersect (extent, lbs);
+	  extent = isl_set_intersect (extent, ubs);
 	}
     }
+
+  return extent;
 }
 
 /* Build data accesses for DR in PBB.  */
@@ -1671,32 +1570,46 @@  pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
 static void
 build_poly_dr (data_reference_p dr, poly_bb_p pbb)
 {
-  ppl_Polyhedron_t accesses;
-  ppl_Pointset_Powerset_C_Polyhedron_t accesses_ps;
-  ppl_dimension_type dom_nb_dims;
-  ppl_dimension_type accessp_nb_dims;
   int dr_base_object_set;
+  isl_map *acc;
+  isl_set *extent;
+  scop_p scop = PBB_SCOP (pbb);
+
+  {
+    isl_space *dc = isl_set_get_space (pbb->domain);
+    int nb_out = 1 + DR_NUM_DIMENSIONS (dr);
+    isl_space *space = isl_space_add_dims (isl_space_from_domain (dc),
+					   isl_dim_out, nb_out);
 
-  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb),
-						      &dom_nb_dims);
-  accessp_nb_dims = dom_nb_dims + 1 + DR_NUM_DIMENSIONS (dr);
+    acc = isl_map_universe (space);
+    acc = isl_map_set_tuple_id (acc, isl_dim_out, isl_id_for_dr (scop, dr));
+  }
+
+  acc = pdr_add_alias_set (acc, dr);
+  acc = pdr_add_memory_accesses (acc, dr, pbb);
 
-  ppl_new_C_Polyhedron_from_space_dimension (&accesses, accessp_nb_dims, 0);
+  {
+    isl_id *id = isl_id_for_dr (scop, dr);
+    int nb = 1 + DR_NUM_DIMENSIONS (dr);
+    isl_space *space = isl_space_set_alloc (scop->ctx, 0, nb);
+    int alias_set_num = 0;
+    base_alias_pair *bap = (base_alias_pair *)(dr->aux);
 
-  pdr_add_alias_set (accesses, dr, accessp_nb_dims, dom_nb_dims);
-  pdr_add_memory_accesses (accesses, dr, accessp_nb_dims, dom_nb_dims, pbb);
-  pdr_add_data_dimensions (accesses, dr, accessp_nb_dims, dom_nb_dims);
+    if (bap && bap->alias_set)
+      alias_set_num = *(bap->alias_set);
 
-  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&accesses_ps,
-							    accesses);
-  ppl_delete_Polyhedron (accesses);
+    space = isl_space_set_tuple_id (space, isl_dim_set, id);
+    extent = isl_set_nat_universe (space);
+    extent = isl_set_fix_si (extent, isl_dim_set, 0, alias_set_num);
+    extent = pdr_add_data_dimensions (extent, scop, dr);
+  }
 
   gcc_assert (dr->aux);
   dr_base_object_set = ((base_alias_pair *)(dr->aux))->base_obj_set;
 
-  new_poly_dr (pbb, dr_base_object_set, accesses_ps,
+  new_poly_dr (pbb, dr_base_object_set,
 	       DR_IS_READ (dr) ? PDR_READ : PDR_WRITE,
-	       dr, DR_NUM_DIMENSIONS (dr));
+	       dr, DR_NUM_DIMENSIONS (dr), acc, extent);
 }
 
 /* Write to FILE the alias graph of data references in DIMACS format.  */
@@ -2139,9 +2052,7 @@  new_pbb_from_pbb (scop_p scop, poly_bb_p pbb, basic_block bb)
     if (VEC_index (poly_bb_p, SCOP_BBS (scop), index) == pbb)
       break;
 
-  if (PBB_DOMAIN (pbb))
-    ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
-      (&PBB_DOMAIN (pbb1), PBB_DOMAIN (pbb));
+  pbb1->domain = isl_set_copy (pbb->domain);
 
   GBB_PBB (gbb1) = pbb1;
   GBB_CONDITIONS (gbb1) = VEC_copy (gimple, heap, GBB_CONDITIONS (gbb));
diff --git a/gcc/graphite.c b/gcc/graphite.c
index 1ad39ba..50830b5 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -1,5 +1,6 @@ 
 /* Gimple Represented as Polyhedra.
-   Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
    Contributed by Sebastian Pop <sebastian.pop@inria.fr>.
 
 This file is part of GCC.
@@ -33,6 +34,17 @@  along with GCC; see the file COPYING3.  If not see
    the functions that are used for transforming the code.  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/options.h>
+#include <isl/union_map.h>
+#include <cloog/cloog.h>
+#include <cloog/isl/domain.h>
+#include <cloog/isl/cloog.h>
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h"
@@ -48,8 +60,6 @@  along with GCC; see the file COPYING3.  If not see
 
 #ifdef HAVE_cloog
 
-#include "ppl_c.h"
-#include "graphite-ppl.h"
 #include "graphite-poly.h"
 #include "graphite-scop-detection.h"
 #include "graphite-clast-to-gimple.h"
@@ -187,10 +197,8 @@  print_graphite_statistics (FILE* file, VEC (scop_p, heap) *scops)
 /* Initialize graphite: when there are no loops returns false.  */
 
 static bool
-graphite_initialize (void)
+graphite_initialize (isl_ctx *ctx)
 {
-  int ppl_initialized;
-
   if (number_of_loops () <= 1
       /* FIXME: This limit on the number of basic blocks of a function
 	 should be removed when the SCOP detection is faster.  */
@@ -199,6 +207,7 @@  graphite_initialize (void)
       if (dump_file && (dump_flags & TDF_DETAILS))
 	print_global_statistics (dump_file);
 
+      isl_ctx_free (ctx);
       return false;
     }
 
@@ -206,10 +215,7 @@  graphite_initialize (void)
   recompute_all_dominators ();
   initialize_original_copy_tables ();
 
-  ppl_initialized = ppl_initialize ();
-  gcc_assert (ppl_initialized == 0);
-
-  cloog_state = cloog_state_malloc ();
+  cloog_state = cloog_isl_state_malloc (ctx);
 
   if (dump_file && dump_flags)
     dump_function_to_file (current_function_decl, dump_file, dump_flags);
@@ -233,13 +239,14 @@  graphite_finalize (bool need_cfg_cleanup_p)
     }
 
   cloog_state_free (cloog_state);
-  ppl_finalize ();
   free_original_copy_tables ();
 
   if (dump_file && dump_flags)
     print_loops (dump_file, 3);
 }
 
+isl_ctx *the_isl_ctx;
+
 /* Perform a set of linear transforms on the loops of the current
    function.  */
 
@@ -251,15 +258,19 @@  graphite_transform_loops (void)
   bool need_cfg_cleanup_p = false;
   VEC (scop_p, heap) *scops = NULL;
   htab_t bb_pbb_mapping;
+  isl_ctx *ctx;
 
   /* If a function is parallel it was most probably already run through graphite
      once. No need to run again.  */
   if (parallelized_function_p (cfun->decl))
     return;
 
-  if (!graphite_initialize ())
+  ctx = isl_ctx_alloc ();
+  isl_options_set_on_error(ctx, ISL_ON_ERROR_ABORT);
+  if (!graphite_initialize (ctx))
     return;
 
+  the_isl_ctx = ctx;
   build_scops (&scops);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -273,6 +284,7 @@  graphite_transform_loops (void)
   FOR_EACH_VEC_ELT (scop_p, scops, i, scop)
     if (dbg_cnt (graphite_scop))
       {
+	scop->ctx = ctx;
 	build_poly_scop (scop);
 
 	if (POLY_SCOP_P (scop)
@@ -284,6 +296,8 @@  graphite_transform_loops (void)
   htab_delete (bb_pbb_mapping);
   free_scops (scops);
   graphite_finalize (need_cfg_cleanup_p);
+  the_isl_ctx = NULL;
+  isl_ctx_free (ctx);
 }
 
 #else /* If Cloog is not available: #ifndef HAVE_cloog.  */
diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-4.c b/libgomp/testsuite/libgomp.graphite/force-parallel-4.c
index c0c6b1c..825bda5 100644
--- a/libgomp/testsuite/libgomp.graphite/force-parallel-4.c
+++ b/libgomp/testsuite/libgomp.graphite/force-parallel-4.c
@@ -47,6 +47,7 @@  int main(void)
 }
 
 /* Check that parallel code generation part make the right answer.  */
+/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 1 "graphite" } } */
 /* { dg-final { scan-tree-dump-times "2 loops carried no dependency" 1 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
 /* { dg-final { scan-tree-dump-times "loopfn.0" 5 "optimized" } } */
diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-5.c b/libgomp/testsuite/libgomp.graphite/force-parallel-5.c
index b72b021..5c944dc 100644
--- a/libgomp/testsuite/libgomp.graphite/force-parallel-5.c
+++ b/libgomp/testsuite/libgomp.graphite/force-parallel-5.c
@@ -31,7 +31,7 @@  int main(void)
 }
 
 /* Check that parallel code generation part make the right answer.  */
-/* { dg-final { scan-tree-dump-times "2 loops carried no dependency" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 1 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
 /* { dg-final { scan-tree-dump-times "loopfn.0" 5 "optimized" } } */
 /* { dg-final { scan-tree-dump-times "loopfn.1" 5 "optimized" } } */
diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-7.c b/libgomp/testsuite/libgomp.graphite/force-parallel-7.c
index 0191af0..2fbe10a 100644
--- a/libgomp/testsuite/libgomp.graphite/force-parallel-7.c
+++ b/libgomp/testsuite/libgomp.graphite/force-parallel-7.c
@@ -2,29 +2,30 @@ 
 
 int A[N+5][N+5][N+5];
 
-int foo(void)
+void abort (void);
+
+int foo (void)
 {
   int i, j, k;
 
+  for (i = 0; i < N + 5; i++)
+    for (j = 0; j < N + 5; j++)
+      for (k = 0; k < N + 5; k++)
+	A[i][j][k] = i + j + k;
+
   /* Loop i: carried no dependency.  */
   for (i = 0; i < N; i++)
     for (j = 0; j < N; j++)
       for (k = 0; k < N; k++)
 	A[k+1][j+2][i+1] = A[k][j][i+1];
 
-  for (i = 0; i < N; i++)
-    /* Loop j: carried no dependency.  */
-    for (j = 0; j < N; j++)
-      /* Loop k: carreid no dependency.  */
-      for (k = 0; k < N; k++)
-	A[i+1][j][k] = A[i][j][k+1];
-
   return A[1][5][2];
 }
 
-int main(void)
+int main (void)
 {
-  foo();
+  if (5 != foo ())
+    abort ();
 
   return 0;
 }
diff --git a/libgomp/testsuite/libgomp.graphite/force-parallel-8.c b/libgomp/testsuite/libgomp.graphite/force-parallel-8.c
index dc553f5..f9ce968 100644
--- a/libgomp/testsuite/libgomp.graphite/force-parallel-8.c
+++ b/libgomp/testsuite/libgomp.graphite/force-parallel-8.c
@@ -2,11 +2,20 @@ 
 
 int x[N][N], y[N];
 
+void abort (void);
+
 int foo(void)
 {
   int i, j;
 
   for (i = 0; i < N; i++)
+    y[i] = i;
+
+  for (i = 0; i < N; i++)
+    for (j = 0; j < N; j++)
+      x[i][j] = i + j;
+
+  for (i = 0; i < N; i++)
     {
       y[i] = i;
 
@@ -27,13 +36,16 @@  int foo(void)
 
 int main(void)
 {
-  foo();
+  if (168 != foo())
+    abort ();
 
   return 0;
 }
 
 /* Check that parallel code generation part make the right answer.  */
-/* { dg-final { scan-tree-dump-times "2 loops carried no dependency" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "3 loops carried no dependency" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "5 loops carried no dependency" 1 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
 /* { dg-final { scan-tree-dump-times "loopfn.0" 5 "optimized" } } */
 /* { dg-final { scan-tree-dump-times "loopfn.1" 5 "optimized" } } */