[PATCH 01/20] Make CLooG-ISL the only supported CLooG version.

2011-08-15 Thread Sebastian Pop
2011-07-21  Tobias Grosser  

* configure: Regenerated.
* config/cloog.m4: Remove support for CLooG-ppl and CLooG-parma,
both cloog.org and legacy versions. The only supported version will
be CLooG with the isl backend.
---
 ChangeLog   |7 ++
 config/cloog.m4 |  107 +++---
 configure   |  170 +++
 3 files changed, 26 insertions(+), 258 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2b062cc..aeb3f14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-07-21  Tobias Grosser  
+
+   * configure: Regenerated.
+   * config/cloog.m4: Remove support for CLooG-ppl and CLooG-parma,
+   both cloog.org and legacy versions. The only supported version will
+   be CLooG with the isl backend.
+
 2011-07-26  Ian Lance Taylor  
 
* configure.ac: Set have_compiler based on whether gcc directory
diff --git a/config/cloog.m4 b/config/cloog.m4
index e95b98d..8662acd 100644
--- a/config/cloog.m4
+++ b/config/cloog.m4
@@ -37,17 +37,6 @@ AC_DEFUN([CLOOG_INIT_FLAGS],
   [--with-cloog-lib=PATH],
   [Specify the directory for the installed CLooG library])])
 
-  AC_ARG_ENABLE(cloog-backend,
-[AS_HELP_STRING(
-  [--enable-cloog-backend[[=BACKEND]]],
-  [set the CLooG BACKEND used to either isl, ppl or ppl-legacy 
(default)])],
-[ if   test "x${enableval}" = "xisl"; then
-   cloog_backend=isl
-  elif test "x${enableval}" = "xppl"; then
-   cloog_backend=ppl
-  else
-   cloog_backend=ppl-legacy
-  fi], cloog_backend=ppl-legacy)
   AC_ARG_ENABLE(cloog-version-check,
 [AS_HELP_STRING(
   [--disable-cloog-version-check],
@@ -107,23 +96,6 @@ m4_define([_CLOOG_ORG_PROG_ISL],[AC_LANG_PROGRAM(
   [#include "cloog/cloog.h" ],
   [cloog_version ()])])
 
-# _CLOOG_ORG_PROG_PPL ()
-# --
-# Helper for detecting CLooG.org's PPL backend.
-m4_define([_CLOOG_ORG_PROG_PPL],[AC_LANG_PROGRAM(
-  [#include "cloog/cloog.h"
-   #include "cloog/ppl/cloog.h"],
-  [cloog_version ()])])
-
-# _CLOOG_PPL_LEGACY_PROG ()
-# -
-# Helper for detecting CLooG-Legacy (CLooG-PPL).
-m4_define([_CLOOG_PPL_LEGACY_PROG], [AC_LANG_PROGRAM(
-  [#include "cloog/cloog.h"],
-  [#ifndef CLOOG_PPL_BACKEND
-choke me
-   #endif ])])
-
 # CLOOG_FIND_FLAGS ()
 # --
 # Detect the used CLooG-backend and set clooginc/clooglibs/cloog_org.
@@ -144,49 +116,17 @@ AC_DEFUN([CLOOG_FIND_FLAGS],
   CPPFLAGS="${CPPFLAGS} ${_cloogorginc}"
   LDFLAGS="${LDFLAGS} ${clooglibs}"
 
-  case $cloog_backend in
-"ppl-legacy")
-CFLAGS="${CFLAGS} ${pplinc}"
-LDFLAGS="${LDFLAGS} ${ppllibs}"
-AC_CACHE_CHECK([for installed CLooG PPL Legacy], [gcc_cv_cloog_type],
-  [LIBS="-lcloog ${_cloog_saved_LIBS}"
-  AC_LINK_IFELSE([_CLOOG_PPL_LEGACY_PROG], [gcc_cv_cloog_type="PPL 
Legacy"],
-[gcc_cv_cloog_type=no])])
-;;
-"isl")
-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])])
-;;
-"ppl")
-CFLAGS="${CFLAGS} ${pplinc}"
-LDFLAGS="${LDFLAGS} ${ppllibs}"
-AC_CACHE_CHECK([for installed CLooG PPL], [gcc_cv_cloog_type],
-  [LIBS="-lcloog-ppl ${_cloog_saved_LIBS}"
-  AC_LINK_IFELSE([_CLOOG_ORG_PROG_PPL], [gcc_cv_cloog_type="PPL"],
-[gcc_cv_cloog_type=no])])
-;;
-*)
-  gcc_cv_cloog_type=""
-  esac
+  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
-"PPL Legacy")
-  clooginc="${clooginc}"
-  clooglibs="${clooglibs} -lcloog"
-  cloog_org=no
-  ;;
 "ISL")
   clooginc="${clooginc} ${_cloogorginc}"
   clooglibs="${clooglibs} -lcloog-isl -lisl"
   cloog_org=yes
   ;;
-"PPL")
-  clooginc="${clooginc} ${_cloogorginc}"
-  clooglibs="${clooglibs} -lcloog-ppl"
-  cloog_org=yes
-  ;;
 *)
   clooglibs=
   clooginc=
@@ -212,25 +152,10 @@ m4_define([_CLOOG_CHECK_CT_PROG],[AC_LANG_PROGRAM(
 choke me
#endif])])
 
-# _CLOOG_CHECK_RT_PROG ()
-# ---
-# Helper for verifying that CLooG's compile time version
-# matches the run time version.
-m4_define([_CLOOG_CHECK_RT_PROG],[AC_LANG_PROGRAM(
-  [#include "cloog/cloog.h"],
-  [if ((cloog_version_major () != CLOOG_VERSION_MAJOR)
-&& (cloog_version_minor () != CLOOG_VERSION_MINOR)
-&& (cloog_version_revision () != CLOOG_VERSION_REVISION))
-{
-  return 1;
-}])])
-
 # CLOOG_CHECK_VERSION CLOOG_CHECK_VERSION (MAJOR, MINOR, REVISION)
 # 
 # Test the found CLo

[PATCH 07/20] fix memory leak

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-sese-to-poly.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 7e23c9d..05280e7 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -1996,6 +1996,7 @@ build_scop_drs (scop_p scop)
 if (VEC_empty (data_reference_p, GBB_DATA_REFS (PBB_BLACK_BOX (pbb
   {
free_gimple_bb (PBB_BLACK_BOX (pbb));
+   free_poly_bb (pbb);
VEC_ordered_remove (poly_bb_p, SCOP_BBS (scop), i);
i--;
   }
-- 
1.7.4.1



[PATCH 06/20] Remove ATTRIBUTE_UNUSED

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-cloog-util.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index 9bc24a0..83cfb54 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -236,7 +236,7 @@ new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *ph,
 
 CloogDomain *
 new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph, int nb_params,
-  CloogState *state ATTRIBUTE_UNUSED)
+  CloogState *state)
 {
   CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph);
   CloogDomain *res = cloog_domain_from_cloog_matrix (state, mat, nb_params);
@@ -248,9 +248,9 @@ new_Cloog_Domain_from_ppl_Polyhedron 
(ppl_const_Polyhedron_t ph, int nb_params,
 
 CloogScattering *
 new_Cloog_Scattering_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph,
-  int nb_params ATTRIBUTE_UNUSED,
-  int nb_scatt ATTRIBUTE_UNUSED,
-  CloogState *state ATTRIBUTE_UNUSED)
+  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,
@@ -266,7 +266,7 @@ new_Cloog_Scattering_from_ppl_Polyhedron 
(ppl_const_Polyhedron_t ph,
 CloogDomain *
 new_Cloog_Domain_from_ppl_Pointset_Powerset
   (ppl_Pointset_Powerset_C_Polyhedron_t ps, int nb_params,
-   CloogState *state ATTRIBUTE_UNUSED)
+   CloogState *state)
 {
   CloogDomain *res = NULL;
   ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end;
-- 
1.7.4.1



[PATCH 04/20] Document CLooG-ISL requirement for Graphite

2011-08-15 Thread Sebastian Pop
2011-07-26  Sebastian Pop  

* doc/invoke.texi: Document CLooG-ISL requirement for Graphite.
---
 gcc/doc/install.texi |   24 
 1 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 9b1b037..368221f 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -365,26 +365,18 @@ distribution is found in a subdirectory of your GCC 
sources named
 Necessary to build GCC with the Graphite loop optimizations.
 It can be downloaded from @uref{http://www.cs.unipr.it/ppl/Download/}.
 
-The @option{--with-ppl} configure option should be used if PPL is not
+The configure option @option{--with-ppl} should be used if PPL is not
 installed in your default library search path.
 
-@item CLooG-PPL version 0.15 or CLooG 0.16
+@item CLooG-ISL 0.16
 
-Necessary to build GCC with the Graphite loop optimizations.  There
-are two versions available.  CLooG-PPL 0.15 as well as CLooG 0.16.
-The former is the default right now.  It can be downloaded from
-@uref{ftp://gcc.gnu.org/pub/gcc/infrastructure/} as
-@file{cloog-ppl-0.15.tar.gz}.
+Necessary to build GCC with the Graphite loop optimizations.  It is
+available from @uref{ftp://gcc.gnu.org/pub/gcc/infrastructure/} as
+@file{cloog-0.16.3.tar.gz}.  Even if CLooG 0.16 does not use PPL, PPL
+is still required for Graphite.
 
-CLooG 0.16 support is still in testing stage, but will be the
-default in future GCC releases.  It is also available at
-@uref{ftp://gcc.gnu.org/pub/gcc/infrastructure/} as
-@file{cloog-0.16.1.tar.gz}.  To use it add the additional configure
-option @option{--enable-cloog-backend=isl}.  Even if CLooG 0.16
-does not use PPL, PPL is still required for Graphite.
-
-In both cases @option{--with-cloog} configure option should be used
-if CLooG is not installed in your default library search path.
+The configure option @option{--with-cloog} should be used if CLooG is
+not installed in your default library search path.
 
 @end table
 
-- 
1.7.4.1



[PATCH 02/20] Require cloog 0.16.3

2011-08-15 Thread Sebastian Pop
2011-07-21  Tobias Grosser  

* configure: Regenerated.
* configure.ac: Require cloog isl 0.16.3
---
 ChangeLog|5 +
 configure|6 +++---
 configure.ac |2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aeb3f14..0c721d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 2011-07-21  Tobias Grosser  
 
* configure: Regenerated.
+   * configure.ac: Require cloog isl 0.16.3
+
+2011-07-21  Tobias Grosser  
+
+   * configure: Regenerated.
* config/cloog.m4: Remove support for CLooG-ppl and CLooG-parma,
both cloog.org and legacy versions. The only supported version will
be CLooG with the isl backend.
diff --git a/configure b/configure
index fbb29e0..86aa457 100755
--- a/configure
+++ b/configure
@@ -5835,8 +5835,8 @@ $as_echo "$gcc_cv_cloog_type" >&6; }
 CFLAGS="${_cloog_saved_CFLAGS} ${clooginc} ${pplinc} ${gmpinc}"
 LDFLAGS="${_cloog_saved_LDFLAGS} ${clooglibs} ${ppllibs}"
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.16.1 of 
CLooG" >&5
-$as_echo_n "checking for version 0.16.1 of CLooG... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for version 0.16.3 of 
CLooG" >&5
+$as_echo_n "checking for version 0.16.3 of CLooG... " >&6; }
 if test "${gcc_cv_cloog+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
@@ -5848,7 +5848,7 @@ main ()
 {
 #if CLOOG_VERSION_MAJOR != 0 \
 || CLOOG_VERSION_MINOR != 16 \
-|| CLOOG_VERSION_REVISION < 1
+|| CLOOG_VERSION_REVISION < 3
 choke me
#endif
   ;
diff --git a/configure.ac b/configure.ac
index 4cf1160..0ef2180 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1589,7 +1589,7 @@ if test "x$with_cloog" != "xno"; then
   dnl
   dnl If we use CLooG-Legacy, the provided version information is
   dnl ignored.
-  CLOOG_CHECK_VERSION(0,16,1)
+  CLOOG_CHECK_VERSION(0,16,3)
 
   dnl Only execute fail-action, if CLooG has been requested.
   CLOOG_IF_FAILED([
-- 
1.7.4.1



[PATCH 03/20] Remove code that supported legacy CLooG.

2011-08-15 Thread Sebastian Pop
2011-07-21  Tobias Grosser  

* configure: Regenerated.
* config/cloog.m4: Do not define CLOOG_ORG

and in gcc/

2011-07-21  Tobias Grosser  

* Makefile.in (graphite-clast-to-gimple.o, graphite-cloog-util.o):
Remove graphite-cloog-util.h.
* graphite-clast-to-gimple.c (gcc_type_for_iv_of_clast_loop,
build_iv_mapping, translate_clast_user, translate_clast,
free_scattering, initialize_cloog_names, build_cloog_prog,
create_params_index): Do not use old compatibility functions.
(clast_name_to_index, set_cloog_options): Remove code for legacy cloog.
* graphite-cloog-util.c (openscop_print_cloog_matrix): Do not use old
compatibility functions.
(new_Cloog_Scattering_from_ppl_Polyhedron): Remove code for legacy
cloog.
* graphite-cloog-util.h: Remove include of graphite-cloog-util.h.
* graphite.c (graphite.c): Do not call outdated cloog_initialize() and
cloog_finalize().
* graphite-cloog-compat.h: Remove.
---
 ChangeLog  |5 +
 config/cloog.m4|2 +-
 configure  |2 +-
 gcc/ChangeLog  |   18 +++
 gcc/Makefile.in|4 +-
 gcc/graphite-clast-to-gimple.c |   96 ++
 gcc/graphite-cloog-compat.h|  275 
 gcc/graphite-cloog-util.c  |   15 +--
 gcc/graphite-cloog-util.h  |1 -
 gcc/graphite.c |2 -
 10 files changed, 74 insertions(+), 346 deletions(-)
 delete mode 100644 gcc/graphite-cloog-compat.h

diff --git a/ChangeLog b/ChangeLog
index 0c721d3..6980618 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 2011-07-21  Tobias Grosser  
 
* configure: Regenerated.
+   * config/cloog.m4: Do not define CLOOG_ORGt 
+
+2011-07-21  Tobias Grosser  
+
+   * configure: Regenerated.
* configure.ac: Require cloog isl 0.16.3
 
 2011-07-21  Tobias Grosser  
diff --git a/config/cloog.m4 b/config/cloog.m4
index 8662acd..9c42445 100644
--- a/config/cloog.m4
+++ b/config/cloog.m4
@@ -109,7 +109,7 @@ AC_DEFUN([CLOOG_FIND_FLAGS],
   _cloog_saved_LDFLAGS=$LDFLAGS
   _cloog_saved_LIBS=$LIBS
 
-  _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
+  _cloogorginc="-DCLOOG_INT_GMP"
  
   dnl clooglibs & clooginc may have been initialized by CLOOG_INIT_FLAGS.
   CFLAGS="${CFLAGS} ${clooginc} ${gmpinc}"
diff --git a/configure b/configure
index 86aa457..59644c2 100755
--- a/configure
+++ b/configure
@@ -5772,7 +5772,7 @@ if test "x$with_cloog" != "xno"; then
   _cloog_saved_LDFLAGS=$LDFLAGS
   _cloog_saved_LIBS=$LIBS
 
-  _cloogorginc="-DCLOOG_INT_GMP -DCLOOG_ORG"
+  _cloogorginc="-DCLOOG_INT_GMP"
 
 CFLAGS="${CFLAGS} ${clooginc} ${gmpinc}"
   CPPFLAGS="${CPPFLAGS} ${_cloogorginc}"
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 580c12f..fb298d2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,21 @@
+2011-07-21  Tobias Grosser  
+
+   * Makefile.in (graphite-clast-to-gimple.o, graphite-cloog-util.o):
+   Remove graphite-cloog-util.h.
+   * graphite-clast-to-gimple.c (gcc_type_for_iv_of_clast_loop,
+   build_iv_mapping, translate_clast_user, translate_clast,
+   free_scattering, initialize_cloog_names, build_cloog_prog,
+   create_params_index): Do not use old compatibility functions.
+   (clast_name_to_index, set_cloog_options): Remove code for legacy cloog.
+   * graphite-cloog-util.c (openscop_print_cloog_matrix): Do not use old
+   compatibility functions.
+   (new_Cloog_Scattering_from_ppl_Polyhedron): Remove code for legacy
+   cloog.
+   * graphite-cloog-util.h: Remove include of graphite-cloog-util.h.
+   * graphite.c (graphite.c): Do not call outdated cloog_initialize() and
+   cloog_finalize().
+   * graphite-cloog-compat.h: Remove.
+
 2011-08-01  Richard Henderson  
 
PR target/49881
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 593c951..2a9e877 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2690,9 +2690,9 @@ 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-dependences.h
 graphite-cloog-util.o : graphite-cloog-util.c $(CONFIG_H) $(SYSTEM_H) \
-   coretypes.h graphite-cloog-util.h graphite-cloog-compat.h
+   coretypes.h graphite-cloog-util.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 \
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 5f7a747..a76b01d 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-

[PATCH 05/20] Move to new Cloog interface.

2011-08-15 Thread Sebastian Pop
  * graphite-clast-to-gimple.c (new_clast_name_index): Store a copy
  of the string, no just a reference.
  (clast_name_index): Add a new field, that specifies if we need to free the
  name.
  (free_clast_name_index): If necessary, free the name string.
  (clast_name_index_elt_info): Calculate the hash based on the string content,
  not the memory location it is stored in.
  (clast_name_to_level): Specify that we do not need to free the name.
  (clast_name_to_index): Dito.
  (clast_name_to_lb_ub): Dito.
  (eq_clast_name_indexes): Compare the strings, not their base pointers.
  (free_scattering): Removed.
  (initialize_cloog_names): Renamed to add_names_to_union_domain().
  (add_names_to_union_domain): Changed to work on a union_domain, instead of a
  CloogNames structure.
  (build_cloog_prog): Removed.
  (build_cloog_union_domain): New.
  (generate_cloog_input): New.
  (scop_to_clast): Use CloogInput instead of CloogProgram.
  (print_generated_program): Adapt to new scop_to_clast() and do not
  print the CloogProgram any more.
  (create_params_index): Removed, functionality integrated in
  add_names_to_union_domain().
  (gloog): Adapt to new scop_to_clast().
  * graphite-clast-to-gimple.h (scop_to_clast): Remove.
---
 gcc/graphite-clast-to-gimple.c |  334 +++-
 gcc/graphite-clast-to-gimple.h |1 -
 2 files changed, 125 insertions(+), 210 deletions(-)

diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index a76b01d..a7d0ddc 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -70,6 +70,9 @@ typedef struct clast_name_index {
   int level;
   mpz_t bound_one, bound_two;
   const char *name;
+  /* If free_name is set, the content of name was allocated by us and needs
+ to be freed.  */
+  char *free_name;
 } *clast_name_index_p;
 
 /* Returns a pointer to a new element of type clast_name_index_p built
@@ -80,8 +83,11 @@ new_clast_name_index (const char *name, int index, int level,
  mpz_t bound_one, mpz_t bound_two)
 {
   clast_name_index_p res = XNEW (struct clast_name_index);
+  char *new_name = XNEWVEC (char, strlen (name) + 1);
+  strcpy (new_name, name);
 
-  res->name = name;
+  res->name = new_name;
+  res->free_name = new_name;
   res->level = level;
   res->index = index;
   mpz_init (res->bound_one);
@@ -97,6 +103,8 @@ static void
 free_clast_name_index (void *ptr)
 {
   struct clast_name_index *c = (struct clast_name_index *) ptr;
+  if (c->free_name)
+free (c->free_name);
   mpz_clear (c->bound_one);
   mpz_clear (c->bound_two);
   free (ptr);
@@ -115,6 +123,7 @@ clast_name_to_level (clast_name_p name, htab_t index_table)
 
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -134,12 +143,9 @@ clast_name_to_index (clast_name_p name, htab_t index_table)
   struct clast_name_index tmp;
   PTR *slot;
 
-#ifdef CLOOG_ORG
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
-#else
-  tmp.name = name;
-#endif
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -160,12 +166,9 @@ clast_name_to_lb_ub (clast_name_p name, htab_t 
index_table, mpz_t bound_one,
   struct clast_name_index tmp;
   PTR *slot;
 
-#ifdef CLOOG_ORG
   gcc_assert (name->type == clast_expr_name);
   tmp.name = ((const struct clast_name *) name)->name;
-#else
-  tmp.name = name;
-#endif
+  tmp.free_name = NULL;
 
   slot = htab_find_slot (index_table, &tmp, NO_INSERT);
 
@@ -189,6 +192,7 @@ save_clast_name_index (htab_t index_table, const char *name,
   PTR *slot;
 
   tmp.name = name;
+  tmp.free_name = NULL;
   slot = htab_find_slot (index_table, &tmp, INSERT);
 
   if (slot)
@@ -204,7 +208,16 @@ save_clast_name_index (htab_t index_table, const char 
*name,
 static inline hashval_t
 clast_name_index_elt_info (const void *elt)
 {
-  return htab_hash_pointer (((const struct clast_name_index *) elt)->name);
+  const struct clast_name_index *e = ((const struct clast_name_index *) elt);
+  hashval_t hash = 0;
+
+  int length = strlen (e->name);
+  int i;
+
+  for (i = 0; i < length; ++i)
+hash = hash | (e->name[i] << (i % 4));
+
+  return hash;
 }
 
 /* Compares database elements E1 and E2.  */
@@ -215,7 +228,7 @@ eq_clast_name_indexes (const void *e1, const void *e2)
   const struct clast_name_index *elt1 = (const struct clast_name_index *) e1;
   const struct clast_name_index *elt2 = (const struct clast_name_index *) e2;
 
-  return (elt1->name == elt2->name);
+  return strcmp (elt1->name, elt2->name) == 0;
 }
 
 
@@ -1238,77 +1251,69 @@ translate_clast (loop_p context_loop, struct clast_stmt 
*stmt, edge next_e,
  level, ip);
 }
 
-/* Free the SCATTERING domain list.  */
-
-static void
-free_scattering (CloogScatteringList *scattering)
-{
-  while (scattering)
-  

[PATCH 11/20] document ISL requirement for GCC installation

2011-08-15 Thread Sebastian Pop
---
 gcc/doc/install.texi |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 368221f..f2b2fd9 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -368,6 +368,11 @@ It can be downloaded from 
@uref{http://www.cs.unipr.it/ppl/Download/}.
 The configure option @option{--with-ppl} should be used if PPL is not
 installed in your default library search path.
 
+@item Integer Set Library (ISL) version 0.08
+
+Necessary to build GCC with the Graphite loop optimizations.
+It can be downloaded from @uref{http://www.kotnet.org/~skimo/isl/}.
+
 @item CLooG-ISL 0.16
 
 Necessary to build GCC with the Graphite loop optimizations.  It is
@@ -1620,7 +1625,8 @@ 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 (the Integer Set Library),
+PPL (the Parma Polyhedra Library), and the CLooG (the Chunky Loop Generator)
 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}},
-- 
1.7.4.1



[PATCH 10/20] use cloog_isl_state_malloc

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gcc/graphite.c b/gcc/graphite.c
index b2cf7c6..7d124c7 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3.  If not see
 #include 
 #include 
 #include 
+#include 
 #endif
 
 #include "system.h"
@@ -196,7 +197,7 @@ 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;
 
@@ -208,6 +209,7 @@ graphite_initialize (void)
   if (dump_file && (dump_flags & TDF_DETAILS))
print_global_statistics (dump_file);
 
+  isl_ctx_free (ctx);
   return false;
 }
 
@@ -218,7 +220,7 @@ graphite_initialize (void)
   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);
@@ -260,12 +262,11 @@ graphite_transform_loops (void)
   bool need_cfg_cleanup_p = false;
   VEC (scop_p, heap) *scops = NULL;
   htab_t bb_pbb_mapping;
-  isl_ctx *ctx;
+  isl_ctx *ctx = isl_ctx_alloc ();
 
-  if (!graphite_initialize ())
+  if (!graphite_initialize (ctx))
 return;
 
-  ctx = isl_ctx_alloc ();
   build_scops (&scops);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
-- 
1.7.4.1



[PATCH 13/20] add pbb->schedule

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-poly.c |6 
 gcc/graphite-poly.h |6 
 gcc/graphite-sese-to-poly.c |   55 --
 3 files changed, 64 insertions(+), 3 deletions(-)

diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index ce0649b..3d81372 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -881,6 +881,9 @@ new_poly_bb (scop_p scop, void *black_box)
 
   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;
@@ -906,6 +909,9 @@ free_poly_bb (poly_bb_p pbb)
 ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
 
   isl_set_free (pbb->domain);
+  isl_map_free (pbb->schedule);
+  isl_map_free (pbb->transformed);
+  isl_map_free (pbb->saved);
 
   if (PBB_TRANSFORMED (pbb))
 poly_scattering_free (PBB_TRANSFORMED (pbb));
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index 3483ef0..b6e5277 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -1521,6 +1521,9 @@ store_scattering_pbb (poly_bb_p 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.  */
@@ -1568,6 +1571,9 @@ restore_scattering_pbb (poly_bb_p pbb)
 
   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.  */
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 20bcf1f..9407a8d 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -407,6 +407,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.
 
@@ -441,7 +451,8 @@ 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,
+ ppl_Linear_Expression_t static_schedule,
  poly_bb_p pbb, int scattering_dimensions)
 {
   int i;
@@ -452,9 +463,11 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t 
static_schedule,
   ppl_Coefficient_t c;
   ppl_dimension_type dim = scattering_dimensions + nb_iterators + nb_params;
   mpz_t v;
+  isl_int val;
 
   gcc_assert (scattering_dimensions >= used_scattering_dimensions);
 
+  isl_int_init (val);
   mpz_init (v);
   ppl_new_Coefficient (&c);
   PBB_TRANSFORMED (pbb) = poly_scattering_new ();
@@ -463,6 +476,15 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t 
static_schedule,
 
   PBB_NB_SCATTERING_TRANSFORM (pbb) = scattering_dimensions;
 
+  {
+isl_dim *dc = isl_set_get_dim (pbb->domain);
+isl_dim *dm = isl_dim_add (isl_dim_from_domain (dc),
+  isl_dim_out, scattering_dimensions);
+pbb->schedule = isl_map_universe (dm);
+pbb->schedule = isl_map_set_tuple_id (pbb->schedule, isl_dim_in,
+ isl_id_for_pbb (scop, pbb));
+  }
+
   for (i = 0; i < scattering_dimensions; i++)
 {
   ppl_Constraint_t cstr;
@@ -481,6 +503,20 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t 
static_schedule,
  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_map_get_dim (pbb->schedule));
+
+   if (0 != isl_aff_get_coefficient (static_sched, isl_dim_set,
+ 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.  */
@@ -492,6 +528,10 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t 
static_schedule,
  ppl_assign_Coefficient_from_mpz_t (c, v);
  ppl_Linear_Expression_add_to_coefficient
(expr, scattering_dimensions + loop, c);
+
+ loop = (i + 1) / 2;
+ pbb->schedule =

[PATCH 15/20] strip-mine with isl

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-blocking.c |   32 +++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/gcc/graphite-blocking.c b/gcc/graphite-blocking.c
index 429b405..0741f82 100644
--- a/gcc/graphite-blocking.c
+++ b/gcc/graphite-blocking.c
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.  If not see
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #endif
@@ -112,9 +113,11 @@ pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, 
int stride)
 
   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;
@@ -128,6 +131,15 @@ pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, 
int stride)
 ppl_delete_Linear_Expression (expr);
 ppl_Polyhedron_add_constraint (res, new_cstr);
 ppl_delete_Constraint (new_cstr);
+
+{
+  isl_dim *d = isl_map_get_dim (pbb->transformed);
+  isl_constraint *c = isl_inequality_alloc (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.  */
@@ -144,6 +156,16 @@ pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, 
int stride)
 ppl_delete_Linear_Expression (expr);
 ppl_Polyhedron_add_constraint (res, new_cstr);
 ppl_delete_Constraint (new_cstr);
+
+{
+  isl_dim *d = isl_map_get_dim (pbb->transformed);
+  isl_constraint *c = isl_inequality_alloc (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.
@@ -160,6 +182,14 @@ pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, 
int stride)
 ppl_delete_Linear_Expression (expr);
 ppl_Polyhedron_add_constraint (res, new_cstr);
 ppl_delete_Constraint (new_cstr);
+
+{
+  isl_dim *d = isl_map_get_dim (pbb->transformed);
+  isl_constraint *c = isl_equality_alloc (d);
+
+  c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip + 1, 1);
+  pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
+}
   }
 }
 
-- 
1.7.4.1



[PATCH 16/20] interchange with isl

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-interchange.c |   17 +
 gcc/graphite-poly.h|   16 
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/gcc/graphite-interchange.c b/gcc/graphite-interchange.c
index b819ece..68b9c1e 100644
--- a/gcc/graphite-interchange.c
+++ b/gcc/graphite-interchange.c
@@ -502,6 +502,23 @@ pbb_interchange_loop_depths (graphite_dim_t depth1, 
graphite_dim_t depth2,
 
   ppl_Polyhedron_map_space_dimensions (poly, map, dim);
   free (map);
+
+  {
+isl_dim *d = isl_map_get_dim (pbb->transformed);
+isl_dim *d1 = isl_dim_range (d);
+unsigned n = isl_dim_size (d1, isl_dim_out);
+isl_dim *d2 = isl_dim_add (d1, isl_dim_in, n);
+isl_map *x = isl_map_universe (d2);
+
+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);
+
+for (i = 0; i < n; i++)
+  if (i != dim1 && i != dim2)
+   x = isl_map_equate (x, isl_dim_in, i, isl_dim_out, i);
+
+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.h b/gcc/graphite-poly.h
index b05e2e7..bf537b1 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -1148,6 +1148,22 @@ pbb_update_scattering (poly_bb_p pbb, graphite_dim_t 
level, int dewey)
   ppl_delete_Linear_Expression (expr);
   ppl_Polyhedron_add_constraint (ph, new_cstr);
   ppl_delete_Constraint (new_cstr);
+
+  {
+isl_dim *d = isl_map_get_dim (pbb->transformed);
+isl_dim *d1 = isl_dim_range (d);
+unsigned i, n = isl_dim_size (d1, isl_dim_out);
+isl_dim *d2 = isl_dim_add (d1, isl_dim_in, n);
+isl_map *x = isl_map_universe (d2);
+
+x = isl_map_fix_si (x, isl_dim_out, sched, dewey);
+
+for (i = 0; i < n; i++)
+  if (i != sched)
+   x = isl_map_equate (x, isl_dim_in, i, isl_dim_out, i);
+
+pbb->transformed = isl_map_apply_range (pbb->transformed, x);
+  }
 }
 
 /* Updates the scattering of all the PBBs under LST to be at the DEWEY
-- 
1.7.4.1



[PATCH 12/20] add pbb->domain

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-poly.c |   12 +++-
 gcc/graphite-poly.h |6 ++
 gcc/graphite-sese-to-poly.c |  205 +++
 3 files changed, 187 insertions(+), 36 deletions(-)

diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index fd2703b..ce0649b 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -880,6 +880,7 @@ 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_SCOP (pbb) = scop;
   pbb_set_black_box (pbb, black_box);
   PBB_TRANSFORMED (pbb) = NULL;
@@ -901,7 +902,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_DOMAIN (pbb))
+ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
+
+  isl_set_free (pbb->domain);
 
   if (PBB_TRANSFORMED (pbb))
 poly_scattering_free (PBB_TRANSFORMED (pbb));
@@ -1096,6 +1100,12 @@ print_pbb_domain (FILE *file, poly_bb_p pbb, int 
verbosity)
   graphite_dim_t i;
   gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
 
+  {
+isl_printer *pp = isl_printer_to_file (PBB_SCOP (pbb)->ctx, file);
+pp = isl_printer_print_set (pp, pbb->domain);
+isl_printer_free (pp);
+  }
+
   if (!PBB_DOMAIN (pbb))
 return;
 
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index bb8771d..3483ef0 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -502,6 +502,12 @@ pbb_dim_iter_domain (const struct poly_bb *pbb)
 {
   scop_p scop = PBB_SCOP (pbb);
   ppl_dimension_type dim;
+  isl_dim *d = isl_set_get_dim (pbb->domain);
+  graphite_dim_t res = isl_dim_size (d, isl_dim_set);
+
+  isl_dim_free (d);
+  if (0)
+return res;
 
   ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb), &dim);
   return dim - scop_nb_params (scop);
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 9723427..20bcf1f 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -658,20 +658,6 @@ isl_id_for_ssa_name (scop_p s, tree e)
   return id;
 }
 
-/* Return an ISL identifier from the loop L.  */
-
-static isl_id *
-isl_id_for_loop (scop_p s, loop_p l)
-{
-  isl_id *id;
-  char name[50];
-
-  snprintf (name, sizeof (name), "L_%d", l ? l->num : -1);
-  id = isl_id_alloc (s->ctx, name, l);
-
-  return id;
-}
-
 /* Extract an affine expression from the ssa_name E.  */
 
 static isl_pw_aff *
@@ -1182,10 +1168,6 @@ find_scop_parameters (scop_p scop)
   dim = isl_dim_set_dim_id (dim, isl_dim_param, i,
isl_id_for_ssa_name (scop, e));
 
-for (i = 0; i < nbl; i++)
-  dim = isl_dim_set_dim_id (dim, isl_dim_set, i,
-   isl_id_for_loop (scop, get_loop (i)));
-
 scop->context = isl_set_universe (dim);
   }
 }
@@ -1263,7 +1245,8 @@ 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)
+ ppl_Pointset_Powerset_C_Polyhedron_t *domains,
+ isl_set *outer, isl_set **doms)
 {
   int i;
   ppl_Polyhedron_t ph;
@@ -1271,6 +1254,15 @@ build_loop_iteration_domains (scop_p scop, struct loop 
*loop,
   ppl_dimension_type dim = nb + 1 + scop_nb_params (scop);
   sese region = SCOP_REGION (scop);
 
+  isl_set *inner = isl_set_copy (outer);
+  isl_dim *dimension = isl_set_get_dim (scop->context);
+  int pos = loop->num;
+  isl_int v;
+  mpz_t g;
+
+  mpz_init (g);
+  isl_int_init (v);
+
   {
 ppl_const_Constraint_System_t pcs;
 ppl_dimension_type *map
@@ -1301,8 +1293,16 @@ build_loop_iteration_domains (scop_p scop, struct loop 
*loop,
 ppl_delete_Linear_Expression (lb_expr);
 ppl_Polyhedron_add_constraint (ph, lb);
 ppl_delete_Constraint (lb);
+
+{
+  isl_constraint *c = isl_inequality_alloc (isl_dim_copy (dimension));
+
+  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;
@@ -1310,14 +1310,25 @@ build_loop_iteration_domains (scop_p scop, struct loop 
*loop,
 
   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);
+
+  {
+   isl_constraint *c = isl_inequality_alloc (isl_dim_copy (dimension));
+
+   c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, -1);
+   tree_int_to_

[PATCH 17/20] use isl's datadep analysis

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-dependences.c  |  169 ++-
 gcc/graphite-poly.c |8 +
 gcc/graphite-poly.h |3 +
 gcc/testsuite/gcc.dg/graphite/interchange-14.c  |3 +-
 gcc/testsuite/gcc.dg/graphite/interchange-15.c  |3 +-
 gcc/testsuite/gcc.dg/graphite/interchange-8.c   |2 +-
 gcc/testsuite/gcc.dg/graphite/interchange-mvt.c |3 +-
 7 files changed, 183 insertions(+), 8 deletions(-)

diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index 9ba2731..eb8d40f 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #endif
@@ -722,6 +723,151 @@ graphite_legal_transform_bb (poly_bb_p pbb1, poly_bb_p 
pbb2)
   return true;
 }
 
+/* Add the constraints from the set S to the domain of MAP.  */
+
+static isl_map *
+constrain_domain (isl_map *map, isl_set *s)
+{
+  isl_dim *d = isl_map_get_dim (map);
+  isl_id *id = isl_dim_get_tuple_id (d, isl_dim_in);
+
+  s = isl_set_set_tuple_id (s, id);
+  isl_dim_free (d);
+  return isl_map_intersect_domain (map, s);
+}
+
+/* Constrain pdr->accesses with pdr->extent and pbb->domain.  */
+
+static isl_map *
+add_pdr_constraints (poly_dr_p pdr, poly_bb_p pbb)
+{
+  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 all the memory reads in SCOP.  */
+
+static isl_union_map *
+scop_get_sink (scop_p scop)
+{
+  int i, j;
+  poly_bb_p pbb;
+  poly_dr_p pdr;
+  isl_dim *dim = isl_dim_from_domain (isl_set_get_dim (scop->context));
+  isl_union_map *res = isl_union_map_empty (dim);
+
+  FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
+{
+  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));
+}
+
+  return res;
+}
+
+/* Returns all the memory must writes in SCOP.  */
+
+static isl_union_map *
+scop_get_must_source (scop_p scop)
+{
+  int i, j;
+  poly_bb_p pbb;
+  poly_dr_p pdr;
+  isl_dim *dim = isl_dim_from_domain (isl_set_get_dim (scop->context));
+  isl_union_map *res = isl_union_map_empty (dim);
+
+  FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), 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;
+}
+
+/* Returns all the memory may writes in SCOP.  */
+
+static isl_union_map *
+scop_get_may_source (scop_p scop)
+{
+  int i, j;
+  poly_bb_p pbb;
+  poly_dr_p pdr;
+  isl_dim *dim = isl_dim_from_domain (isl_set_get_dim (scop->context));
+  isl_union_map *res = isl_union_map_empty (dim);
+
+  FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
+{
+  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));
+}
+
+  return res;
+}
+
+/* Returns all the original schedules in SCOP.  */
+
+static isl_union_map *
+scop_get_original_schedule (scop_p scop)
+{
+  int i;
+  poly_bb_p pbb;
+  isl_dim *dim = isl_dim_from_domain (isl_set_get_dim (scop->context));
+  isl_union_map *res = isl_union_map_empty (dim);
+
+  FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
+{
+  res = isl_union_map_add_map
+   (res, constrain_domain (isl_map_copy (pbb->schedule),
+   isl_set_copy (pbb->domain)));
+}
+
+  return res;
+}
+
+/* Returns all the transformed schedules in SCOP.  */
+
+static isl_union_map *
+scop_get_transformed_schedule (scop_p scop)
+{
+  int i;
+  poly_bb_p pbb;
+  isl_dim *dim = isl_dim_from_domain (isl_set_get_dim (scop->context));
+  isl_union_map *res = isl_union_map_empty (dim);
+
+  FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb)
+{
+  res = isl_union_map_add_map
+   (res, constrain_domain (isl_map_copy (pbb->transformed),
+   isl_set_copy (pbb->domain)));
+}
+
+  return res;
+}
+
+/* Return true when SCHEDULE does not violate the data dependences DEPS.  */
+
+static bool
+no_violations (isl_union_map *schedule, isl_union_map *deps)
+{
+  bool res;
+  isl_dim *dim = isl_dim_reverse (isl_union_map_get_dim (schedule));
+  isl_map *lex = isl_map_lex_ge (dim);
+
+  deps = isl_union_map_apply_domain (deps, isl_union_map_copy (schedule));
+  deps = isl_union_map_apply_range (deps, schedule);
+  deps = isl_union_map_intersect (deps, isl_union_map_from_map (lex));
+  res = isl_union_map_is_empty (deps);
+
+  isl_union_map_free (deps);
+  return res;
+}
+
 /* Iterates over the SCOP and detect whether the transformed schedule
is correct.  */
 
@@ -730,9 +876,31 @@ gra

[PATCH 14/20] add pdr->accesses and pdr->extent

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-poly.c |7 ++-
 gcc/graphite-poly.h |4 +-
 gcc/graphite-sese-to-poly.c |  149 ---
 3 files changed, 148 insertions(+), 12 deletions(-)

diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index 3d81372..2835311 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -847,7 +847,8 @@ pbb_remove_duplicate_pdrs (poly_bb_p pbb)
 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);
@@ -857,6 +858,8 @@ new_poly_dr (poly_bb_p pbb, int 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;
@@ -869,6 +872,8 @@ 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);
 }
 
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index b6e5277..b05e2e7 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -182,6 +182,7 @@ struct poly_dr
  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.  */
@@ -201,7 +202,8 @@ struct poly_dr
 #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);
+ 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);
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 9407a8d..bc1fd21 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -707,6 +707,27 @@ isl_id_for_ssa_name (scop_p s, tree e)
   return id;
 }
 
+/* Return an ISL identifier for the data reference DR.  */
+
+static isl_id *
+isl_id_for_dr (scop_p s, data_reference_p dr)
+{
+  isl_id *id;
+  tree e = DR_BASE_ADDRESS (dr) ? DR_BASE_ADDRESS (dr) : DR_BASE_OBJECT (dr);
+  const char *name = get_name (e);
+
+  if (name)
+id = isl_id_alloc (s->ctx, name, dr);
+  else
+{
+  char name1[1];
+  snprintf (name1, sizeof (name1), "A");
+  id = isl_id_alloc (s->ctx, name1, e);
+}
+
+  return id;
+}
+
 /* Extract an affine expression from the ssa_name E.  */
 
 static isl_pw_aff *
@@ -2024,8 +2045,9 @@ 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,
+static isl_map *
+pdr_add_alias_set (isl_map *acc,
+  ppl_Polyhedron_t accesses, data_reference_p dr,
   ppl_dimension_type accessp_nb_dims,
   ppl_dimension_type dom_nb_dims)
 {
@@ -2046,6 +2068,36 @@ pdr_add_alias_set (ppl_Polyhedron_t accesses, 
data_reference_p dr,
 
   ppl_delete_Linear_Expression (alias);
   ppl_delete_Constraint (cstr);
+
+  {
+isl_constraint *c = isl_equality_alloc (isl_map_get_dim (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);
+
+  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);
+
+  return isl_map_intersect (map, index_map);
 }
 
 /* Add to ACCESSES polyhedron equalities defining the access functions
@@ -2053,8 +2105,9 @@ 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_Polyh

[PATCH 18/20] remove dead code

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-dependences.c  |  298 ---
 gcc/graphite-poly.c |   47 ---
 gcc/graphite-poly.h |9 --
 gcc/graphite-sese-to-poly.c |8 +-
 4 files changed, 2 insertions(+), 360 deletions(-)

diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index eb8d40f..02ed21f 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -567,162 +567,6 @@ free_poly_ddr (void *p)
   free (pddr);
 }
 
-/* Return true when the data dependence relation between the data
-   references PDR1 belonging to PBB1 and PDR2 is part of a
-   reduction.  */
-
-static inline bool
-reduction_dr_1 (poly_bb_p pbb1, poly_dr_p pdr1, poly_dr_p pdr2)
-{
-  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;
-}
-
-/* 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.  */
-
-static inline bool
-reduction_dr_p (poly_dr_p pdr1, poly_dr_p pdr2)
-{
-  poly_bb_p pbb1 = PDR_PBB (pdr1);
-  poly_bb_p pbb2 = PDR_PBB (pdr2);
-
-  if (PBB_IS_REDUCTION (pbb1))
-return reduction_dr_1 (pbb1, pdr1, pdr2);
-
-  if (PBB_IS_REDUCTION (pbb2))
-return reduction_dr_1 (pbb2, pdr2, pdr1);
-
-  return false;
-}
-
-/* Returns true when the PBB_TRANSFORMED_SCATTERING functions of PBB1
-   and PBB2 respect the data dependences of PBB_ORIGINAL_SCATTERING
-   functions.  */
-
-static bool
-graphite_legal_transform_dr (poly_dr_p pdr1, poly_dr_p pdr2)
-{
-  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;
-
-  /* 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);
-
-  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);
-}
-
-/* Iterates over the data references of PBB1 and PBB2 and detect
-   whether the transformed schedule is correct.  */
-
-static bool
-graphite_legal_transform_bb (poly_bb_p pbb1, poly_bb_p pbb2)
-{
-  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))
-   

[PATCH 20/20] disable loop flattening

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-flattening.c |  289 +
 1 files changed, 4 insertions(+), 285 deletions(-)

diff --git a/gcc/graphite-flattening.c b/gcc/graphite-flattening.c
index c58d8a3..c8c8531 100644
--- a/gcc/graphite-flattening.c
+++ b/gcc/graphite-flattening.c
@@ -145,297 +145,16 @@ along with GCC; see the file COPYING3.  If not see
At each step, the iteration domain of the outer loop is enlarged to
contain enough points to iterate over the inner loop domain.  */
 
-/* Initializes RES to the number of iterations of the linearized loop
-   LST.  RES is the cardinal of the iteration domain of LST.  */
-
-static void
-lst_linearized_niter (lst_p lst, mpz_t res)
-{
-  int i;
-  lst_p l;
-  mpz_t n;
-
-  mpz_init (n);
-  mpz_set_si (res, 0);
-
-  FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
-if (LST_LOOP_P (l))
-  {
-   lst_linearized_niter (l, n);
-   mpz_add (res, res, n);
-  }
-
-  if (LST_LOOP_P (lst))
-{
-  lst_niter_for_loop (lst, n);
-
-  if (mpz_cmp_si (res, 0) != 0)
-   mpz_mul (res, res, n);
-  else
-   mpz_set (res, n);
-}
-
-  mpz_clear (n);
-}
-
-/* Applies the translation "f (x) = x + OFFSET" to the loop containing
-   STMT.  */
-
-static void
-lst_offset (lst_p stmt, mpz_t offset)
-{
-  lst_p inner = LST_LOOP_FATHER (stmt);
-  poly_bb_p pbb = LST_PBB (stmt);
-  ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb);
-  int inner_depth = lst_depth (inner);
-  ppl_dimension_type inner_dim = psct_dynamic_dim (pbb, inner_depth);
-  ppl_Linear_Expression_t expr;
-  ppl_dimension_type dim;
-  ppl_Coefficient_t one;
-  mpz_t x;
-
-  mpz_init (x);
-  mpz_set_si (x, 1);
-  ppl_new_Coefficient (&one);
-  ppl_assign_Coefficient_from_mpz_t (one, x);
-
-  ppl_Polyhedron_space_dimension (poly, &dim);
-  ppl_new_Linear_Expression_with_dimension (&expr, dim);
-
-  ppl_set_coef (expr, inner_dim, 1);
-  ppl_set_inhomogeneous_gmp (expr, offset);
-  ppl_Polyhedron_affine_image (poly, inner_dim, expr, one);
-  ppl_delete_Linear_Expression (expr);
-  ppl_delete_Coefficient (one);
-}
-
-/* Scale by FACTOR the loop LST containing STMT.  */
-
-static void
-lst_scale (lst_p lst, lst_p stmt, mpz_t factor)
-{
-  mpz_t x;
-  ppl_Coefficient_t one;
-  int outer_depth = lst_depth (lst);
-  poly_bb_p pbb = LST_PBB (stmt);
-  ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb);
-  ppl_dimension_type outer_dim = psct_dynamic_dim (pbb, outer_depth);
-  ppl_Linear_Expression_t expr;
-  ppl_dimension_type dim;
-
-  mpz_init (x);
-  mpz_set_si (x, 1);
-  ppl_new_Coefficient (&one);
-  ppl_assign_Coefficient_from_mpz_t (one, x);
-
-  ppl_Polyhedron_space_dimension (poly, &dim);
-  ppl_new_Linear_Expression_with_dimension (&expr, dim);
-
-  /* outer_dim = factor * outer_dim.  */
-  ppl_set_coef_gmp (expr, outer_dim, factor);
-  ppl_Polyhedron_affine_image (poly, outer_dim, expr, one);
-  ppl_delete_Linear_Expression (expr);
-
-  mpz_clear (x);
-  ppl_delete_Coefficient (one);
-}
-
-/* Project the INNER loop into the iteration domain of the OUTER loop.
-   STRIDE is the number of iterations between two iterations of the
-   outer loop.  */
-
-static void
-lst_project_loop (lst_p outer, lst_p inner, mpz_t stride)
-{
-  int i;
-  lst_p stmt;
-  mpz_t x;
-  ppl_Coefficient_t one;
-  int outer_depth = lst_depth (outer);
-  int inner_depth = lst_depth (inner);
-
-  mpz_init (x);
-  mpz_set_si (x, 1);
-  ppl_new_Coefficient (&one);
-  ppl_assign_Coefficient_from_mpz_t (one, x);
-
-  FOR_EACH_VEC_ELT (lst_p, LST_SEQ (inner), i, stmt)
-{
-  poly_bb_p pbb = LST_PBB (stmt);
-  ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb);
-  ppl_dimension_type outer_dim = psct_dynamic_dim (pbb, outer_depth);
-  ppl_dimension_type inner_dim = psct_dynamic_dim (pbb, inner_depth);
-  ppl_Linear_Expression_t expr;
-  ppl_dimension_type dim;
-  ppl_dimension_type *ds;
-
-  /* There should be no loops under INNER.  */
-  gcc_assert (!LST_LOOP_P (stmt));
-  ppl_Polyhedron_space_dimension (poly, &dim);
-  ppl_new_Linear_Expression_with_dimension (&expr, dim);
-
-  /* outer_dim = outer_dim * stride + inner_dim.  */
-  ppl_set_coef (expr, inner_dim, 1);
-  ppl_set_coef_gmp (expr, outer_dim, stride);
-  ppl_Polyhedron_affine_image (poly, outer_dim, expr, one);
-  ppl_delete_Linear_Expression (expr);
-
-  /* Project on inner_dim.  */
-  ppl_new_Linear_Expression_with_dimension (&expr, dim - 1);
-  ppl_Polyhedron_affine_image (poly, inner_dim, expr, one);
-  ppl_delete_Linear_Expression (expr);
-
-  /* Remove inner loop and the static schedule of its body.  */
-  ds = XNEWVEC (ppl_dimension_type, 2);
-  ds[0] = inner_dim;
-  ds[1] = inner_dim + 1;
-  ppl_Polyhedron_remove_space_dimensions (poly, ds, 2);
-  PBB_NB_SCATTERING_TRANSFORM (pbb) -= 2;
-  free (ds);
-}
-
-  mpz_clear (x);
-  ppl_delete_Coefficient (one);
-}
-
-/* Flattens the loop nest LST. 

[PATCH 08/20] Add ISL data structures

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-blocking.c|   12 +++-
 gcc/graphite-clast-to-gimple.c |9 +
 gcc/graphite-cloog-util.c  |   11 ++-
 gcc/graphite-cloog-util.h  |2 --
 gcc/graphite-dependences.c |   11 ++-
 gcc/graphite-flattening.c  |   11 ++-
 gcc/graphite-interchange.c |   12 +++-
 gcc/graphite-poly.c|   12 +++-
 gcc/graphite-poly.h|   40 +++-
 gcc/graphite-ppl.c |   11 ++-
 gcc/graphite-scop-detection.c  |   11 ++-
 gcc/graphite-sese-to-poly.c|   10 ++
 gcc/graphite.c |   12 +++-
 13 files changed, 136 insertions(+), 28 deletions(-)

diff --git a/gcc/graphite-blocking.c b/gcc/graphite-blocking.c
index 967de9d..429b405 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  and
Pranav Garg  .
 
@@ -20,7 +20,17 @@ 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
 .  */
+
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index a7d0ddc..bb0f4c8 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -19,6 +19,15 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic-core.h"
diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index 83cfb54..82a49a1 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -1,5 +1,5 @@
 /* Gimple Represented as Polyhedra.
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
Contributed by Sebastian Pop 
and Tobias Grosser .
 
@@ -20,6 +20,15 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 
diff --git a/gcc/graphite-cloog-util.h b/gcc/graphite-cloog-util.h
index da26ee9..07894ea 100644
--- a/gcc/graphite-cloog-util.h
+++ b/gcc/graphite-cloog-util.h
@@ -21,8 +21,6 @@ along with GCC; see the file COPYING3.  If not see
 #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 *);
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index fb49f16..9ba2731 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  and
Konrad Trifunovic .
 
@@ -20,6 +20,15 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-flattening.c b/gcc/graphite-flattening.c
index ccd0f5f..c58d8a3 100644
--- a/gcc/graphite-flattening.c
+++ b/gcc/graphite-flattening.c
@@ -1,5 +1,5 @@
 /* Loop flattening for Graphite.
-   Copyright (C) 2010 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
Contributed by Sebastian Pop .
 
 This file is part of GCC.
@@ -19,6 +19,15 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+
+#ifdef HAVE_cloog
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
 #include "system.h"
 #include "coretypes.h"
 #include "tree-flow.h"
diff --git a/gcc/graphite-interchange.c b/gcc/graphite-interchange.c
index cb4d32c..b819ece 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.
+   Copyri

[PATCH 09/20] Add scop->context

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-clast-to-gimple.c |   55 ++--
 gcc/graphite-cloog-util.c  |1 +
 gcc/graphite-poly.c|8 +
 gcc/graphite-poly.h|3 +
 gcc/graphite-sese-to-poly.c|  299 +++-
 gcc/graphite.c |4 +
 6 files changed, 354 insertions(+), 16 deletions(-)

diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index bb0f4c8..9a9effa 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -24,6 +24,11 @@ along with GCC; see the file COPYING3.  If not see
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #endif
@@ -768,16 +773,19 @@ 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;
-
-  /* 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);
-
-  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 v;
+  isl_aff *aff = isl_aff_zero
+(isl_local_space_from_dim (isl_set_get_dim (scop->context)));
+
+  aff = isl_aff_add_coefficient_si (aff, isl_dim_param, param, 1);
+
+  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
@@ -1357,7 +1365,6 @@ build_cloog_union_domain (scop_p scop)
 {
   int i;
   poly_bb_p pbb;
-
   CloogUnionDomain *union_domain =
 cloog_union_domain_alloc (scop_nb_params (scop));
 
@@ -1460,8 +1467,30 @@ generate_cloog_input (scop_p scop, htab_t params_index)
   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);
+
+  if (1)
+{
+  /* For now remove the isl_id's from the context before
+translating to CLooG: this code will be removed when the
+domain will also contain isl_id's.  */
+  isl_set *ct = isl_set_project_out (isl_set_copy (scop->context),
+isl_dim_set, 0, number_of_loops ());
+  isl_printer *p = isl_printer_to_str (scop->ctx);
+  char *str;
+
+  p = isl_printer_set_output_format (p, ISL_FORMAT_EXT_POLYLIB);
+  p = isl_printer_print_set (p, ct);
+  isl_set_free (ct);
+
+  str = isl_printer_get_str (p);
+  ct = isl_set_read_from_str (scop->ctx, str,
+ scop_nb_params (scop));
+  free (str);
+  isl_printer_free (p);
+  context = cloog_domain_from_isl_set (ct);
+}
+  else
+context = cloog_domain_from_isl_set (isl_set_copy (scop->context));
 
   cloog_input = cloog_input_alloc (context, union_domain);
 
diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c
index 82a49a1..6086864 100644
--- a/gcc/graphite-cloog-util.c
+++ b/gcc/graphite-cloog-util.c
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #endif
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index af40d20..fd2703b 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -1012,6 +1012,7 @@ new_scop (void *region)
   scop_p scop = XNEW (struct scop);
 
   SCOP_CONTEXT (scop) = NULL;
+  scop->context = 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,
@@ -1040,6 +1041,7 @@ free_scop (scop_p scop)
   if (SCOP_CONTEXT (scop))
 ppl_delete_Pointset_Powerset_C_Polyhedron (SCOP_CONTEXT (scop));
 
+  isl_set_free (scop->context);
   htab_delete (SCOP_ORIGINAL_PDDRS (scop));
   free_lst (SCOP_ORIGINAL_SCHEDULE (scop));
   free_lst (SCOP_TRANSFORMED_SCHEDULE (scop));
@@ -1401,6 +1403,12 @@ print_scop_context (FILE *file, scop_p scop, int 
verbosity)
   else
 fprintf (file, "0 %d\n", (int) scop_nb_params (scop) + 2);
 
+  if (scop->context)
+{
+  isl_printer *p = isl_printer_to_file (scop->ctx, file);
+  isl_printer_print_set (p, scop->context);
+}
+
   if (verbosity > 0)
 fprintf (file, "# )\n");
 }
diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h
index 72e9530..bb8771d 100644
--- a/gcc/graphite-poly.h
+++ b/gcc/graphite-poly.h
@@ -1409,6 +1409,9 @@ struct scop
   ppl_Pointset_Powerset_C_Polyhedron_t _context;
   isl_set *context;
 
+  /* The context used internally by

[PATCH 19/20] remove old data dependence analysis, xfail graphite-force-parallel

2011-08-15 Thread Sebastian Pop
---
 gcc/graphite-dependences.c |  585 +---
 gcc/graphite-dependences.h |   39 +--
 gcc/graphite-poly.c|3 -
 .../testsuite/libgomp.graphite/force-parallel-1.c  |4 +-
 .../testsuite/libgomp.graphite/force-parallel-2.c  |4 +-
 .../testsuite/libgomp.graphite/force-parallel-3.c  |6 +-
 .../testsuite/libgomp.graphite/force-parallel-4.c  |6 +-
 .../testsuite/libgomp.graphite/force-parallel-5.c  |6 +-
 .../testsuite/libgomp.graphite/force-parallel-6.c  |4 +-
 .../testsuite/libgomp.graphite/force-parallel-7.c  |4 +-
 .../testsuite/libgomp.graphite/force-parallel-8.c  |6 +-
 .../testsuite/libgomp.graphite/force-parallel-9.c  |6 +-
 12 files changed, 30 insertions(+), 643 deletions(-)

diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index 02ed21f..5b7ffd6 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -47,526 +47,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "graphite-dependences.h"
 #include "graphite-cloog-util.h"
 
-/* Comparison function for poly_ddr hash table.  */
-
-int
-eq_poly_ddr_p (const void *pddr1, const void *pddr2)
-{
-  const struct poly_ddr *p1 = (const struct poly_ddr *) pddr1;
-  const struct poly_ddr *p2 = (const struct poly_ddr *) pddr2;
-
-  return (PDDR_SOURCE (p1) == PDDR_SOURCE (p2)
-  && PDDR_SINK (p1) == PDDR_SINK (p2));
-}
-
-/* Hash function for poly_ddr hashtable.  */
-
-hashval_t
-hash_poly_ddr_p (const void *pddr)
-{
-  const struct poly_ddr *p = (const struct poly_ddr *) pddr;
-
-  return (hashval_t) ((long) PDDR_SOURCE (p) + (long) PDDR_SINK (p));
-}
-
-/* Returns true when PDDR has no dependence.  */
-
-static bool
-pddr_is_empty (poly_ddr_p pddr)
-{
-  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);
-
-  if (PDDR_KIND (pddr) == has_dependence)
-{
-  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");
-}
-
-  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_d

[PATCH] add configure --with-isl

2011-08-15 Thread Sebastian Pop
Hi,

This patch still needs some changes to ISL for the compile time
version check to work:

  [#if ISL_VERSION_MAJOR != $1 \
|| ISL_VERSION_MINOR != $2 \
|| ISL_VERSION_REVISION < $3

I am providing this patch for reference, just in case ISL 0.08 will
contain these defines.  I have not tested this patch at all: I just
followed what cloog was doing.

Sebastian


---
 Makefile.tpl |6 ++
 config/isl.m4|  149 ++
 configure.ac |   26 +-
 gcc/Makefile.in  |8 ++-
 gcc/configure.ac |3 +
 5 files changed, 188 insertions(+), 4 deletions(-)
 create mode 100644 config/isl.m4

diff --git a/Makefile.tpl b/Makefile.tpl
index 4dd2391..f99c79f 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -222,6 +222,8 @@ HOST_EXPORTS = \
GMPINC="$(HOST_GMPINC)"; export GMPINC; \
PPLLIBS="$(HOST_PPLLIBS)"; export PPLLIBS; \
PPLINC="$(HOST_PPLINC)"; export PPLINC; \
+   ISLLIBS="$(HOST_ISLLIBS)"; export ISLLIBS; \
+   ISLINC="$(HOST_ISLINC)"; export ISLINC; \
CLOOGLIBS="$(HOST_CLOOGLIBS)"; export CLOOGLIBS; \
CLOOGINC="$(HOST_CLOOGINC)"; export CLOOGINC; \
LIBELFLIBS="$(HOST_LIBELFLIBS)" ; export LIBELFLIBS; \
@@ -314,6 +316,10 @@ HOST_GMPINC = @gmpinc@
 HOST_PPLLIBS = @ppllibs@
 HOST_PPLINC = @pplinc@
 
+# Where to find ISL
+HOST_ISLLIBS = @isllibs@
+HOST_ISLINC = @islinc@
+
 # Where to find CLOOG
 HOST_CLOOGLIBS = @clooglibs@
 HOST_CLOOGINC = @clooginc@
diff --git a/config/isl.m4 b/config/isl.m4
new file mode 100644
index 000..00ea0b2
--- /dev/null
+++ b/config/isl.m4
@@ -0,0 +1,149 @@
+# 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
+# .
+#
+# Contributed by Sebastian Pop 
+
+# 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 Flags needed for ISL
+  AC_SUBST(isllibs)
+  AC_SUBST(islinc)
+]
+)
+
+# ISL_REQUESTED (ACTION-IF-REQUESTED, ACTION-IF-NOT)
+# 
+# Provide actions for failed ISL 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, REVISION)
+# 
+# Helper for verifying ISL's compile time version.
+m4_define([_ISL_CHECK_CT_PROG],[AC_LANG_PROGRAM(
+  [#include "isl/version.h"],
+  [#if ISL_VERSION_MAJOR != $1 \
+|| ISL_VERSION_MINOR != $2 \
+|| ISL_VERSION_REVISION < $3
+choke me
+   #endif])])
+
+# ISL_CHECK_VERSION ISL_CHECK_VERSION (MAJOR, MINOR, REVISION)
+# 
+# Test the found ISL to be exact of version MAJOR.MINOR and at least
+# REVISION.
+AC_DEFUN([ISL_CHECK_VERSION],
+[
+  AC_REQUIRE([ISL_FIND_FLAGS])
+
+  if test "${ENABLE_ISL_CHECK}" = yes ; then
+_isl_saved_CFLAGS=$CFLAGS
+_isl_saved_LDFLAGS=$LDFLAGS
+
+CFLAGS="${_isl_saved_CFLAGS} ${islinc} ${pplinc} ${gmpinc}"
+LDFLAGS="${_isl_saved_LDFLAGS} ${isllib

Re: [PATCH] add configure --with-isl

2011-08-15 Thread Tobias Grosser

On 08/15/2011 08:19 AM, Sebastian Pop wrote:

Hi,

This patch still needs some changes to ISL for the compile time
version check to work:

   [#if ISL_VERSION_MAJOR != $1 \
 || ISL_VERSION_MINOR != $2 \
 || ISL_VERSION_REVISION<  $3

I am providing this patch for reference, just in case ISL 0.08 will
contain these defines.  I have not tested this patch at all: I just
followed what cloog was doing.

Sebastian


Hey Sebastian,

thanks a lot.


  # Check for CLOOG

  dnl Provide configure switches and initialize clooginc&  clooglibs
  dnl with user input.
  CLOOG_INIT_FLAGS
+if test "x$with_isl" = "xno"; then
+  dnl Only execute fail-action, if CLooG has been requested.

This should be, "if isl has been requested", no?

Cheers
Tobi


Re: [PATCH 15/20] strip-mine with isl

2011-08-15 Thread Sven Verdoolaege
On Mon, Aug 15, 2011 at 02:12:54AM -0500, Sebastian Pop wrote:
> @@ -160,6 +182,14 @@ pbb_strip_mine_time_depth (poly_bb_p pbb, int 
> time_depth, int stride)
>  ppl_delete_Linear_Expression (expr);
>  ppl_Polyhedron_add_constraint (res, new_cstr);
>  ppl_delete_Constraint (new_cstr);
> +
> +{
> +  isl_dim *d = isl_map_get_dim (pbb->transformed);
> +  isl_constraint *c = isl_equality_alloc (d);
> +
> +  c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip + 1, 1);
> +  pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
> +}
>}
>  }

I'm not sure what the point is of introducing an extra dimension
fixed to zero, but it can be accomplished more easily using isl_map_fix_si.
Also, it may clarify the code if you first construct the transformation
and then apply it, like you do in the interchange.

skimo


RE: [wwwdocs] Announce new ARM/embedded-4_6-branch branch

2011-08-15 Thread Terry Guo
Hello Gerald,

Could you please review my updated patch?

BR,
Terry

> -Original Message-
> From: Terry Guo [mailto:terry@arm.com]
> Sent: Sunday, August 14, 2011 10:27 AM
> To: 'Gerald Pfeifer'
> Cc: 'gcc-patches@gcc.gnu.org'; Richard Earnshaw; Matthew Gretton-Dann
> Subject: RE: [wwwdocs] Announce new ARM/embedded-4_6-branch branch
> 
> Ping.
> 
> BR,
> Terry
> 
> 
> > -Original Message-
> > From: Terry Guo [mailto:terry@arm.com]
> > Sent: Thursday, August 11, 2011 3:13 PM
> > To: 'Gerald Pfeifer'
> > Cc: gcc-patches@gcc.gnu.org; Richard Earnshaw; Matthew Gretton-Dann
> > Subject: RE: [wwwdocs] Announce new ARM/embedded-4_6-branch branch
> >
> > Hi Gerald,
> >
> > Thanks for your review. Here I attached the updated one. Is it ok to
> > commit?
> >
> > BR,
> > Terry
> >
> > > -Original Message-
> > > From: Gerald Pfeifer [mailto:ger...@pfeifer.com]
> > > Sent: Monday, August 08, 2011 5:43 PM
> > > To: Terry Guo
> > > Cc: gcc-patches@gcc.gnu.org; Richard Earnshaw; Matthew Gretton-Dann
> > > Subject: Re: [wwwdocs] Announce new ARM/embedded-4_6-branch branch
> > >
> > > Hi Terry,
> > >
> > > On Mon, 8 Aug 2011, Terry Guo wrote:
> > > > This new branch intends to provide fixes and enhancements for GCC
> > 4.6
> > > > when used with ARM embedded cores.
> > > >
> > > > The attached patch adds documentation for this branch.
> > >
> > > thanks for thinking to document this!  This looks good modulo two
> > > notes.
> > >
> > > +  This branch provides bug-fixes, minor enhancements and
> > stability
> > > +  fixes for GCC-4.6 when used with ARM's embedded cores, such as
> the
> > > +  Cortex-R and Cortex-M processors.  Most patches will be back-
> ports
> > > +  of changes already made on trunk.  Patches should be marked with
> > the
> > > +  tag [arm-embedded] in the subject line.  The branch
> > is
> > > +  maintained by ARM.
> > >
> > > Would you mind making ths GCC 4.6 (without the dash), and perhaps
> > > noting which version of GCC 4.6 this is based on (or whether it
> > > tracks the general GCC 4.6 branch)?
> > >
> > > As for maintainership, we usually have individuals, not companies
> > > there.  Could you name one or two (or three)?  You can always
> adjust
> > > the list an any time later on, without any form of approval.
> > >
> > > Gerald
> > >






Re: Fix spurious match testsuite regressions from "[PATCH, middle end]: Introduce BUILT_IN_I{CEIL_FLOOR_ROUND_RINT} FP-to-int conversion functions"

2011-08-15 Thread Richard Guenther
On Mon, 15 Aug 2011, Hans-Peter Nilsson wrote:

> This patch:
> 
> > 2011-08-11  Uros Bizjak  
> > 
> > * builtins.def (BUILT_IN_ICEIL{,F,L}, BUILT_IN_IFLOOR{,F,L},
> > BUILT_IN_IRINT{,F,L}, BUILT_IN_IROUND{,F,L}: New builtin definitions.
> > * convert.c (convert_to_integer): Convert to BUILT_IN_ICEIL,
> > BUILT_IN_IFLOOR, BUILT_IN_IRINT or BUILT_INT_IROUND when converting
> > to integer_type_node.
> > * fold-const.c (tree_call_nonnegative_warnv_p): Handle BUILT_IN_ICEIL,
> > BUILT_IN_IFLOOR, BUILT_IN_IRINT and BUILT_INT_IROUND.
> > * builtins.c (expand_builtin_in): Ditto.
> > (mathfn_built_in_1): Ditto.
> > (expand_builtin_int_roundingfn): Handle BUILT_IN_ICEIL and
> > BUILT_IN_IFLOOR.
> > (expand_builtin_int_roundingfn_2): Handle BUILT_IN_IRINT and
> > BUILT_IN_IROUND.
> > (fold_fixed_mathfn): Canonicalize BUILT_IN_ICEIL, BUILTIN_IN_IFLOOR,
> > BUILT_IN_IRINT and BUILT_IN_IROUND to BUILT_IN_LCEIL,
> > BUILTIN_IN_LFLOOR, BUILT_IN_LRINT and BUILT_IN_LROUND on ILP32 targets.
> 
> "caused" this regression for cris-elf:
> 
> Running /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/tree-ssa/tree-ssa.exp 
> ...
> ...
> FAIL: gcc.dg/tree-ssa/vrp61.c scan-tree-dump-not vrp1 "1234"
> 
> Looking at vrp61.c only yields a big WTF, but when looking at
> the vrp61.c.067t.vrp1 dump file all is explained, because there,
> at the top is:
> 
> ;; Function f (f, funcdef_no=0, decl_uid=1234, cgraph_uid=0)
> 
> Hilarious.  Probably not the instance intended to not-look for.
> Anyway, I decided not to try and do anything else but a
> brain-dead tweak, hoping that someone used to writing such
> test-cases would jump in with a better solution (like, not
> dumping the decl_uid unless the dump verbosity-level is
> higher)... doh!  Anyhow, the following should fit nicely with
> 16-bitters and allow for another ten-fold of built-in functions...
> 
> So, ok as is?
> If not, would you preapprove tree-dumping decl_uids only at a
> higher dump verbosity level?

Ok.  Yes, definitely, a patch to do decl_uids dumping only at
TDF_UID is pre-approved (you'd need to adjust some testcases
I guess).

Thanks,
Richard.

> gcc/testsuite:
>   * gcc.dg/tree-ssa/vrp61.c: Increase magic number from 1234 to
>   12345.
> 
> Index: gcc.dg/tree-ssa/vrp61.c
> ===
> --- gcc.dg/tree-ssa/vrp61.c   (revision 177757)
> +++ gcc.dg/tree-ssa/vrp61.c   (working copy)
> @@ -7,10 +7,10 @@ int f (int x, int y)
>  {
>x = x ^ y;
>if (x < 0 || x > 1023)
> - return 1234;
> + return 12345;
>  }
>return x;
>  }
>  
> -/* { dg-final { scan-tree-dump-not "1234" "vrp1" } } */
> +/* { dg-final { scan-tree-dump-not "12345" "vrp1" } } */
>  /* { dg-final { cleanup-tree-dump "vrp1" } } */
> 
> brgds, H-P
> 
> 

-- 
Richard Guenther 
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer

Re: [google] Backport r174965 from trunk to google/gcc-4_6 (issue4852046)

2011-08-15 Thread Carrot Wei
ping

On Mon, Aug 8, 2011 at 11:00 AM, Guozhi Wei  wrote:
>
> Hi
>
> I want to backport r174965 from trunk to google/gcc-4_6, which fixed vect-72.c
> failure in target arm, as described in
> http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00927.html
>
> Tested with buildit and regression test on arm qemu.
>
> OK for google/gcc-4_6 ?
>
> thanks
> Carrot
>
>
> 2011-08-08  Guozhi Wei  
>
>        Backport r174965 from trunk.
>
>        2011-06-12  Ira Rosen  
>
>                * tree-vect-data-refs.c (vect_peeling_hash_get_most_frequent):
>                Take number of iterations to peel into account for equally 
> frequent
>                misalignment values.
>
>
> Index: tree-vect-data-refs.c
> ===
> --- tree-vect-data-refs.c       (revision 177320)
> +++ tree-vect-data-refs.c       (working copy)
> @@ -1250,7 +1250,9 @@ vect_peeling_hash_get_most_frequent (voi
>   vect_peel_info elem = (vect_peel_info) *slot;
>   vect_peel_extended_info max = (vect_peel_extended_info) data;
>
> -  if (elem->count > max->peel_info.count)
> +  if (elem->count > max->peel_info.count
> +      || (elem->count == max->peel_info.count
> +          && max->peel_info.npeel > elem->npeel))
>     {
>       max->peel_info.npeel = elem->npeel;
>       max->peel_info.count = elem->count;
>
>
> --
> This patch is available for review at http://codereview.appspot.com/4852046


[PATCH, testsuite, ARM] Divide by zero test no necessarily trap

2011-08-15 Thread Joey Ye
gcc.c/torture/execute/20101011-1.c always fails on ARM, because 
it needs the target architecture trap in division by zero. It is 
implementation defined on ARM to trap division by zero. So this 
case should be skipped on ARM.

There are two ways to skip this test. One is using standard 
dejagnu options. Another is architecture macro check in test 
code, which is this case is using for other targets.

Suggest fix: follow the later solution:
ChangeLog:

* gcc.c-torture/execute/20101011-1.c (DO_TEST):
  Skip this test on ARM.

diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
index 7180e68..40c367b 100644
- a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
@@ -12,6 +12,9 @@
#elif defined (_sh_)
/* On SH division by zero does not trap. */

define DO_TEST 0
+#elif defined (_arm_)
+ /* We cannot rely on division by zero generating a trap. */
+# define DO_TEST 0
#elif defined (_mips) && !defined(linux_)
/* MIPS divisions do trap by default, but libgloss targets do not
intercept the trap and raise a SIGFPE. The same is probably





Re: [PATCH] [JAVA] patch for Java on RTEMS

2011-08-15 Thread Andrew Haley
On 08/10/2011 06:00 PM, Jie Liu wrote:

> For the previous analysis "libjava patches for RTEMS"[1], there are 6
> cases need to pay more attention. PR18699, TLtest, Thread_Interrupt,
> Thread_Sleep_2, Throw_2 and bclink.
>
> After add patch to bdwgc for RTEMS pthread support[2]:
> PR18699PASS after Modify   [A bug in boehm-gc on
> RTEMS, not related to libjava]
> TLtestPASS
> Thread_Interrupt  PASS
>
> For the other 3 cases:
> Thread_Sleep_2  PASS   [After add patch to rtems]
> Throw_2 PASS   [After add patch to
> libjava, still need some work][3]
> bclinkUnSupport
> [-findirect-dispatch do not support in this case]
>
> I think it's time to send out the patch for review, because it may
> need much time to modify. The patch is attached.

Looks OK, but there is no ChangeLog.  Do you have copyright
assignment?

Andrew.


Re: [x86] Use match_test for .md attributes

2011-08-15 Thread Richard Sandiford
Uros Bizjak  writes:
> Hello!
>> Following on from the two patches I've just posted, this one makes
>> config/i386/*.md use match_test for .md attributes.  Tested as
>> described here:
>
>> http://gcc.gnu.org/ml/gcc-patches/2011-08/msg01182.html
>
>>  * config/i386/i386.md: Use (match_test ...) for attribute tests.
>>  * config/i386/mmx.md: Likewise.
>>  * config/i386/sse.md: Likewise.
>
> -  (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
> +  (not (match_test "TARGET_SSE2")))
>
> Jus a question - in predicates.md, i.e. (match_test "!TARGET_SSE2") is
> used. Do we want to standardize on (not (match_test "...")) form
> everywhere?

Yeah, good question.  I'd used (not (match_test ...)) so that genattrtab
could better optimise combinations of expressions.  I suppose we don't
yet combine predicate expressions in the same way, so it probably makes
no difference there.  We might use predicate expressions more in future
though.

I'm happy to convert predicate match_tests at the same time.

Richard


Re: Fix spurious match testsuite regressions from "[PATCH, middle end]: Introduce BUILT_IN_I{CEIL_FLOOR_ROUND_RINT} FP-to-int conversion functions"

2011-08-15 Thread Hans-Peter Nilsson
> Date: Mon, 15 Aug 2011 10:43:35 +0200 (CEST)
> From: Richard Guenther 

> On Mon, 15 Aug 2011, Hans-Peter Nilsson wrote:
> > So, ok as is?
> > If not, would you preapprove tree-dumping decl_uids only at a
> > higher dump verbosity level?
> 
> Ok.  Yes, definitely, a patch to do decl_uids dumping only at
> TDF_UID is pre-approved (you'd need to adjust some testcases
> I guess).

Bah, should've looked closer; there already was a TDF_NUID gate
there...  Looks like this is a problem that is supposed to be
handled by appending -nouid to the dump option.  See asm-1.c
which is the only other tree-ssa instance grepping for a number.
So, the following is therefore committed as obvious:

testsuite:
* gcc.dg/tree-ssa/vrp61.c: : Use -fdump-tree-vrp1-nouid instead of
-fdump-tree-vrp1.

Index: gcc.dg/tree-ssa/vrp61.c
===
--- gcc.dg/tree-ssa/vrp61.c (revision 177757)
+++ gcc.dg/tree-ssa/vrp61.c (working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-vrp1-nouid" } */
 
 int f (int x, int y)
 {

brgds, H-P


Re: [PATCH, i386]: Expand round(a) = sgn(a) * floor(fabs(a) + 0.5) using SSE4 ROUND insn

2011-08-15 Thread Richard Guenther
On Sun, Aug 14, 2011 at 7:24 PM, Uros Bizjak  wrote:
> Hello!
>
> We can use ROUNDSP/ROUNDSD in round(a) expansion. Currently, we expand
> round(a) as (-O2 -ffast-math):
>
> .LFB0:
>        .cfi_startproc
>        movsd   .LC1(%rip), %xmm1
>        movapd  %xmm0, %xmm2
>        movsd   .LC0(%rip), %xmm3
>        andpd   %xmm1, %xmm2
>        ucomisd %xmm2, %xmm3
>        jbe     .L2
>        addsd   .LC2(%rip), %xmm2
>        andnpd  %xmm0, %xmm1
>        movapd  %xmm1, %xmm0
>        cvttsd2siq      %xmm2, %rax
>        cvtsi2sdq       %rax, %xmm2
>        orpd    %xmm2, %xmm0
> .L2:
>        rep
>        ret
>
> Adding -msse4, we now generate branchless code using roundsd:
>
> .LFB0:
>        .cfi_startproc
>        movsd   .LC0(%rip), %xmm2
>        movapd  %xmm0, %xmm1
>        andpd   %xmm2, %xmm1
>        andnpd  %xmm0, %xmm2
>        addsd   .LC1(%rip), %xmm1
>        roundsd $1, %xmm1, %xmm1
>        orpd    %xmm2, %xmm1
>        movapd  %xmm1, %xmm0
>        ret

Hm, why do we need the sign-copy?  If I read the docs correctly
we can simply use roundsd directly, no?

> The patch also simplifies a couple of checks in related patterns.
>
> 2011-08-14  Uros Bizjak  
>
>        * config/i386/i386.c (ix86_expand_round_sse4): New function.
>        * config/i386/i386-protos.h (ix86_expand_round_sse4): New prototype.
>        * config/i386/i386.md (round2): Use ix86_expand_round_sse4
>        for TARGET_ROUND.
>
>        (rint2): Simplify TARGET_ROUND check.
>        (floor2): Ditto.
>        (ceil2): Ditto.
>        (btrunc2): Ditto.
>
> Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32},
> will be committed to mainline soon.
>
> Uros.
>


[PATCH] Fix PR50058

2011-08-15 Thread Richard Guenther

This fixes the FAIL of PR50058 - I tightened the struct copy matching
too much and somehow the FAIL got lost during testing.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-08-15  Richard Guenther  

PR tree-optimization/50058
* tree-ssa-sccvn.c (vn_reference_lookup_3): Relax aggregate
copy matching.

Index: gcc/tree-ssa-sccvn.c
===
*** gcc/tree-ssa-sccvn.c(revision 177757)
--- gcc/tree-ssa-sccvn.c(working copy)
*** vn_reference_lookup_3 (ao_ref *ref, tree
*** 1485,1496 
 may fail when comparing types for compatibility.  But we really
 don't care here - further lookups with the rewritten operands
 will simply fail if we messed up types too badly.  */
!   if (j == 0 && i == 0
  && VEC_index (vn_reference_op_s, lhs_ops, 0)->opcode == MEM_REF
! && VEC_index (vn_reference_op_s, vr->operands, i)->opcode == MEM_REF
! && tree_int_cst_equal
!  (VEC_index (vn_reference_op_s, lhs_ops, 0)->op0,
!   VEC_index (vn_reference_op_s, vr->operands, i)->op0))
i--, j--;
  
/* i now points to the first additional op.
--- 1485,1495 
 may fail when comparing types for compatibility.  But we really
 don't care here - further lookups with the rewritten operands
 will simply fail if we messed up types too badly.  */
!   if (j == 0 && i >= 0
  && VEC_index (vn_reference_op_s, lhs_ops, 0)->opcode == MEM_REF
! && VEC_index (vn_reference_op_s, lhs_ops, 0)->off != -1
! && (VEC_index (vn_reference_op_s, lhs_ops, 0)->off
! == VEC_index (vn_reference_op_s, vr->operands, i)->off))
i--, j--;
  
/* i now points to the first additional op.


Re: [Patch ARM] Fix PR50022

2011-08-15 Thread Ramana Radhakrishnan
>
> fails to build, rename it everywhere if needed.

Yes - sorry . I had fixed this up on Friday after accidentally sending
a wrong version. The final version is attached.

Bootstrap with C and Ada completed ok with this patch. Regression
tests on a cross-compiler showed no new failures.

Committed.

Ramana

2011-08-15  Ramana Radhakrishnan  

PR target/50022
* config/arm/arm.c (output_move_double): Add 2 parameters
to count the number of insns emitted and whether to emit or not.
Use the flag to decide when to emit and count number of instructions
that will be emitted.
Handle case where output_move_double might be called for calculating
lengths with an invalid constant.
(arm_count_output_move_double_insns): Define.
* config/arm/arm-protos.h (arm_count_output_move_double_insns): Declare.
(output_move_double): Adjust prototype.
* config/arm/vfp.md ("*movdi_vfp"): Adjust call to
output_move_double.
("*movdi_vfp_cortexa8"): Likewise and add attribute
for ce_count.
* config/arm/arm.md ("*arm_movdi"): Adjust call to output_move_double.
("*movdf_soft_insn"): Likewise.
* config/arm/cirrus.md ("*cirrus_arm_movdi"): Likewise.
("*cirrus_thumb2_movdi"): Likewise.
("*thumb2_cirrus_movdf_hard_insn"): Likewise.
("*cirrus_movdf_hard_insn"): Likewise.
* config/arm/neon.md (*neon_mov VD): Likewise.
* config/arm/iwmmxt.md ("*iwmmxt_arm_movdi"): Likewise.
("mov_internal VMMX"): Likewise.
Index: gcc/config/arm/arm.c
===
--- gcc/config/arm/arm.c(revision 177758)
+++ gcc/config/arm/arm.c(working copy)
@@ -13284,12 +13284,25 @@
 /* Output a move between double words.  It must be REG<-MEM
or MEM<-REG.  */
 const char *
-output_move_double (rtx *operands)
+output_move_double (rtx *operands, bool emit, int *count)
 {
   enum rtx_code code0 = GET_CODE (operands[0]);
   enum rtx_code code1 = GET_CODE (operands[1]);
   rtx otherops[3];
+  if (count)
+*count = 1;
 
+  /* The only case when this might happen is when 
+ you are looking at the length of a DImode instruction
+ that has an invalid constant in it.  */
+  if (code0 == REG && code1 != MEM)
+{
+  gcc_assert (!emit);
+  *count = 2;
+  return "";
+}
+  
+
   if (code0 == REG)
 {
   unsigned int reg0 = REGNO (operands[0]);
@@ -13301,35 +13314,49 @@
   switch (GET_CODE (XEXP (operands[1], 0)))
{
case REG:
- if (TARGET_LDRD
- && !(fix_cm3_ldrd && reg0 == REGNO(XEXP (operands[1], 0
-   output_asm_insn ("ldr%(d%)\t%0, [%m1]", operands);
- else
-   output_asm_insn ("ldm%(ia%)\t%m1, %M0", operands);
+
+ if (emit)
+   {
+ if (TARGET_LDRD
+ && !(fix_cm3_ldrd && reg0 == REGNO(XEXP (operands[1], 0
+   output_asm_insn ("ldr%(d%)\t%0, [%m1]", operands);
+ else
+   output_asm_insn ("ldm%(ia%)\t%m1, %M0", operands);
+   }
  break;
 
case PRE_INC:
  gcc_assert (TARGET_LDRD);
- output_asm_insn ("ldr%(d%)\t%0, [%m1, #8]!", operands);
+ if (emit)
+   output_asm_insn ("ldr%(d%)\t%0, [%m1, #8]!", operands);
+ 
  break;
 
case PRE_DEC:
- if (TARGET_LDRD)
-   output_asm_insn ("ldr%(d%)\t%0, [%m1, #-8]!", operands);
- else
-   output_asm_insn ("ldm%(db%)\t%m1!, %M0", operands);
+ if (emit)
+   {
+ if (TARGET_LDRD)
+   output_asm_insn ("ldr%(d%)\t%0, [%m1, #-8]!", operands);
+ else
+   output_asm_insn ("ldm%(db%)\t%m1!, %M0", operands);
+   }
  break;
 
case POST_INC:
- if (TARGET_LDRD)
-   output_asm_insn ("ldr%(d%)\t%0, [%m1], #8", operands);
- else
-   output_asm_insn ("ldm%(ia%)\t%m1!, %M0", operands);
+ 
+ if (emit)
+   {
+ if (TARGET_LDRD)
+   output_asm_insn ("ldr%(d%)\t%0, [%m1], #8", operands);
+ else
+   output_asm_insn ("ldm%(ia%)\t%m1!, %M0", operands);
+   }
  break;
 
case POST_DEC:
  gcc_assert (TARGET_LDRD);
- output_asm_insn ("ldr%(d%)\t%0, [%m1], #-8", operands);
+ if (emit)
+   output_asm_insn ("ldr%(d%)\t%0, [%m1], #-8", operands);
  break;
 
case PRE_MODIFY:
@@ -13347,8 +13374,13 @@
  if (reg_overlap_mentioned_p (otherops[0], otherops[2]))
{
  /* Registers overlap so split out the increment.  */
- output_asm_insn ("add%?\t%1, %1, %2", otherops);
- output_asm_insn ("ldr%(d%)\t%0, [%1] @split", otherops);
+ if (emit)
+   {
+ output_asm_i

Re: [PATCH 01/20] Make CLooG-ISL the only supported CLooG version.

2011-08-15 Thread Joseph S. Myers
I can't tell if this is meant to be a trunk submission or a branch 
submission.  But if it's a trunk submission, my previous comments still 
apply: changes to prerequisites need raising on the gcc list for the 
benefit of the wider audience there, and with as much detail (about what 
hosts and configurations have been tested, any possible dependence of code 
generation on library versions and how that has been avoided, etc.) as for 
the original addition of Graphite to trunk.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH 01/20] Make CLooG-ISL the only supported CLooG version.

2011-08-15 Thread Joseph S. Myers
I'd also like to point out that this is simply not a proper patch 
submission at all, independent of the specific issues about changes to 
prerequisites that require things to be raised and explained in a 
self-contained way on the gcc list.  Every patch submission needs an 
explanation of the purpose of the patch - not just the ChangeLog entry 
saying at a low level what changed, but the higher-level motivation for 
why the patch was implemented and why it was implemented the way it was.  
It also needs to say how the patch was tested.  And a multi-patch series 
should contain such an overview for the whole series (which might also 
make clear whether the patches were tested individually or only in 
combination), typically as patch 00/nn.  Note that as stated in 
contribute.html this all applies even when the patch is being sent by a 
maintainer of the relevant part of the compiler.

-- 
Joseph S. Myers
jos...@codesourcery.com


[PATCH] Remove "bogus" g++.dg/init/copy7.C testcase

2011-08-15 Thread Richard Guenther

The g++.dg/init/copy7.C testcase checks whether the C++ frontend
guards memcpy it emits via a conditional verifying that src != dst
because calling memcpy with overlapping source / destination is
not supported.

The testcase is misguided though (and the C++ frontend was, until
recently) - the middle-end itself will replace aggregate copies
with memcpy libcalls if it suits - without such conditional.
As PR39480 shows (the bug that prompted to "fixing" the C++ frontend),
the "error" was diagnosed by valgrind, not any real memcpy implemenation.

The argument still holds that no reasonable memcpy implementation
will reject the src == dest case.  Arguing about explicit cache
write-allocation is moot, as you'd still have to handle the
case of memcpy (&a, &a+1, 1) correctly - and thus any reasonable
implementation would handle the src == dest case explicitly if
that is necessary.

Thus, the following simply removes the now FAILing testcase on
the basis that it never was PASSing really (as my modified
C testcases in PR50079 show).  If we ever encounter a platform
that fails for memcpy (&a, &a, ...) and we decide it's not the
platform that is broken we have to invent a fix in the middle-end
and (conditionally) guard any libcall block moves.

Comments?  Ok to commit?

Thanks,
Richard.

2011-08-15  Richard Guenther  

PR middle-end/50079
* g++.dg/init/copy7.C: Remove testcase.

Index: gcc/testsuite/g++.dg/init/copy7.C
===
--- gcc/testsuite/g++.dg/init/copy7.C   (revision 177759)
+++ gcc/testsuite/g++.dg/init/copy7.C   (working copy)
@@ -1,39 +0,0 @@
-// PR c++/39480
-// It isn't always safe to call memcpy with identical arguments.
-// { dg-do run }
-
-extern "C" void abort();
-extern "C" void *
-memcpy(void *dest, void *src, __SIZE_TYPE__ n)
-{
-  if (dest == src)
-abort();
-  else
-{
-  __SIZE_TYPE__ i;
-  for (i = 0; i < n; i++)
-((char *)dest)[i] = ((const char*)src)[i];
-}
-}
-
-struct A
-{
-  double d[10];
-};
-
-struct B: public A
-{
-  char bc;
-};
-
-B b;
-
-void f(B *a1, B* a2)
-{
-  *a1 = *a2;
-}
-
-int main()
-{
-  f(&b,&b);
-}


Re: [PATCH 11/20] document ISL requirement for GCC installation

2011-08-15 Thread Sebastian Pop
On Mon, Aug 15, 2011 at 02:36, Sven Verdoolaege  wrote:
>> +It can be downloaded from @uref{http://www.kotnet.org/~skimo/isl/}.
>
> Why don't you want to use the official URL?

Changed now.
From 93d892edaa303736cd0ca89662bec979aec0485c Mon Sep 17 00:00:00 2001
From: Sebastian Pop 
Date: Fri, 12 Aug 2011 10:14:34 -0500
Subject: [PATCH] document ISL requirement for GCC installation

---
 gcc/doc/install.texi |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 368221f..fa561ff 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -368,6 +368,11 @@ It can be downloaded from @uref{http://www.cs.unipr.it/ppl/Download/}.
 The configure option @option{--with-ppl} should be used if PPL is not
 installed in your default library search path.
 
+@item Integer Set Library (ISL) version 0.08
+
+Necessary to build GCC with the Graphite loop optimizations.
+It can be downloaded from @uref{http://freshmeat.net/projects/isl/}.
+
 @item CLooG-ISL 0.16
 
 Necessary to build GCC with the Graphite loop optimizations.  It is
@@ -1620,7 +1625,8 @@ 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 (the Integer Set Library),
+PPL (the Parma Polyhedra Library), and the CLooG (the Chunky Loop Generator)
 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}},
-- 
1.7.4.1



Re: [PATCH] add configure --with-isl

2011-08-15 Thread Sebastian Pop
On Mon, Aug 15, 2011 at 02:23, Tobias Grosser  wrote:
>>  # Check for CLOOG
>>
>>  dnl Provide configure switches and initialize clooginc&  clooglibs
>>  dnl with user input.
>>  CLOOG_INIT_FLAGS
>> +if test "x$with_isl" = "xno"; then
>> +  dnl Only execute fail-action, if CLooG has been requested.
>
> This should be, "if isl has been requested", no?

I think that this should be "if graphite has been requested" and that
implies that both isl and cloog are available.

Sebastian


Re: [PATCH 01/20] Make CLooG-ISL the only supported CLooG version.

2011-08-15 Thread Sebastian Pop
On Mon, Aug 15, 2011 at 07:40, Joseph S. Myers  wrote:
> I'd also like to point out that this is simply not a proper patch
> submission at all, independent of the specific issues about changes to
> prerequisites that require things to be raised and explained in a
> self-contained way on the gcc list.  Every patch submission needs an
> explanation of the purpose of the patch - not just the ChangeLog entry
> saying at a low level what changed, but the higher-level motivation for
> why the patch was implemented and why it was implemented the way it was.
> It also needs to say how the patch was tested.  And a multi-patch series
> should contain such an overview for the whole series (which might also
> make clear whether the patches were tested individually or only in
> combination), typically as patch 00/nn.  Note that as stated in
> contribute.html this all applies even when the patch is being sent by a
> maintainer of the relevant part of the compiler.

Sorry I haven't had time to write all that is required.
All the patches that I submitted are completely untested, except the
make -k check RUNTESTFLAGS=graphite.exp

The following fails are to be expected on amd64-linux,
after the change to the data dependence using ISL:

FAIL: gcc.dg/graphite/block-0.c execution test
FAIL: gcc.dg/graphite/block-0.c scan-tree-dump-not graphite "will be
loop blocked"

FAIL: gfortran.dg/graphite/pr29581.f90  -O0  execution test
FAIL: gfortran.dg/graphite/pr29581.f90  -O1  execution test
FAIL: gfortran.dg/graphite/pr29581.f90  -O2  execution test
FAIL: gfortran.dg/graphite/pr29581.f90  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/graphite/pr29581.f90  -O3 -fomit-frame-pointer
-funroll-loops  execution test
FAIL: gfortran.dg/graphite/pr29581.f90  -O3 -fomit-frame-pointer
-funroll-all-loops -finline-functions  execution test
FAIL: gfortran.dg/graphite/pr29581.f90  -O3 -g  execution test
FAIL: gfortran.dg/graphite/pr29581.f90  -Os  execution test
FAIL: gfortran.dg/graphite/pr29832.f90  -O0  execution test
FAIL: gfortran.dg/graphite/pr29832.f90  -O1  execution test
FAIL: gfortran.dg/graphite/pr29832.f90  -O2  execution test
FAIL: gfortran.dg/graphite/pr29832.f90  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/graphite/pr29832.f90  -O3 -fomit-frame-pointer
-funroll-loops  execution test
FAIL: gfortran.dg/graphite/pr29832.f90  -O3 -fomit-frame-pointer
-funroll-all-loops -finline-functions  execution test
FAIL: gfortran.dg/graphite/pr29832.f90  -O3 -g  execution test
FAIL: gfortran.dg/graphite/pr29832.f90  -Os  execution test

I suspect that these are problems in the code generation part,
now that the dependence test is validating more transforms.

Sebastian


Re: [PATCH] [JAVA] patch for Java on RTEMS

2011-08-15 Thread Jie Liu
> Looks OK, but there is no ChangeLog.  Do you have copyright
> assignment?

Have added ChangeLog to the patch, please see the attachment. And I
think I have copyright assignment, because I have Free Software
Foundation paperwork, as "ASSIGNMENT - GNU GCC ... JIE RT688742"

Best Regards,
Jie


gcj-rtems.patch
Description: Binary data


Re: [PATCH] [JAVA] patch for Java on RTEMS

2011-08-15 Thread Andrew Haley
On 08/15/2011 03:07 PM, Jie Liu wrote:
>> Looks OK, but there is no ChangeLog.  Do you have copyright
>> assignment?
> 
> Have added ChangeLog to the patch, please see the attachment. And I
> think I have copyright assignment, because I have Free Software
> Foundation paperwork, as "ASSIGNMENT - GNU GCC ... JIE RT688742"

Good.  The libjava parts are OK; I can't approve the top-level part,
but it looks fine.

Andrew.


Re: [PATCH 2/2] document ISL requirement for GCC installation

2011-08-15 Thread Michael Matz
Hi,

On Sun, 14 Aug 2011, Richard Guenther wrote:

> > which would be exactly the way no distribution would use it. So please 
> > just don't bundle ISL with CLoog.
> 
> Well, I would simply have linked the bundled ISL statically into 
> libcloog.

Which would still require not exporting the (bundled) libisl symbols from 
libcloog.  Looking at the cloog git repo it doesn't seem that it knows 
anything about symbol versions (and it wouldn't help static libs anyway).

No, the only even barely sane way is for the cloog version GCC should use 
to not include a builtin copy of some stale version of isl at all.


Ciao,
Michael.


Re: Vector Comparison patch

2011-08-15 Thread Richard Guenther
On Fri, Aug 12, 2011 at 4:03 AM, Artem Shinkarov
 wrote:
> Hi
>
> Here is a completed version of the vector comparison patch we
> discussed a long time ago here:
> http://gcc.gnu.org/ml/gcc-patches/2010-08/msg01184.html
>
> The patch implements vector comparison according to the OpenCL
> standard, when the result of the comparison of two vectors is vector
> of signed integers, where -1 represents true and 0 false.
>
> The patch implements vector conditional res = VCOND
> which is expanded into:
> foreach (i in length (V1)) res[i] = V1 == 0 ? V3[i] : V2[i].

Some comments on the patch below.  First, in general I don't see
why you need a new target hook to specify whether to "vectorize"
a comparison.  Why are the existing hooks used by the vectorizer
not enough?

Index: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 177665)
+++ gcc/fold-const.c(working copy)
@@ -9073,34 +9073,61 @@ fold_comparison (location_t loc, enum tr
  floating-point, we can only do some of these simplifications.)  */
   if (operand_equal_p (arg0, arg1, 0))
 {
-  switch (code)
+  if (TREE_CODE (TREE_TYPE (arg0)) == VECTOR_TYPE)
{
-   case EQ_EXPR:
- if (! FLOAT_TYPE_P (TREE_TYPE (arg0))
- || ! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0
-   return constant_boolean_node (1, type);

I think this change should go in a separate patch for improved
constant folding.  It shouldn't be necessary for enabling vector compares, no?

+  if (TYPE_UNSIGNED (TREE_TYPE (TREE_TYPE (ifexp
+{
+  error_at (colon_loc, "vector comparison must be of signed "
+  "integer vector type");
+  return error_mark_node;
+}

why that?

+  if (TYPE_VECTOR_SUBPARTS (type1) != TYPE_VECTOR_SUBPARTS (type2)
+  || TYPE_VECTOR_SUBPARTS (TREE_TYPE (ifexp))
+ != TYPE_VECTOR_SUBPARTS (type1))
+{
+  error_at (colon_loc, "vectors of different length found in "
+   "vector comparison");
+  return error_mark_node;
+}

I miss verification that type1 and type2 are vector types, or is that done
elsewhere?  I think type1 and type2 are already verified to be
compatible (but you might double-check).  At least the above would be
redundant with

+  if (type1 != type2)
+{
+  error_at (colon_loc, "vectors of different types involved in "
+   "vector comparison");
+  return error_mark_node;
+}

Joseph may have comments about the fully-fold stuff that follows.

+  /* Currently the expansion of VEC_COND_EXPR does not allow
+expessions where the type of vectors you compare differs
+form the type of vectors you select from. For the time
+being we insert implicit conversions.  */
+  if ((COMPARISON_CLASS_P (ifexp)

Why only for comparison-class?

+  && TREE_TYPE (TREE_OPERAND (ifexp, 0)) != type1)
+ || TREE_TYPE (ifexp) != type1)
+   {
+ tree comp_type = COMPARISON_CLASS_P (ifexp)
+  ? TREE_TYPE (TREE_OPERAND (ifexp, 0))
+  : TREE_TYPE (ifexp);
+ tree vcond;
+
+ op1 = convert (comp_type, op1);
+ op2 = convert (comp_type, op2);
+ vcond = build3 (VEC_COND_EXPR, comp_type, ifexp, op1, op2);
+ vcond = convert (type1, vcond);
+ return vcond;
+   }
+  else
+   return build3 (VEC_COND_EXPR, type1, ifexp, op1, op2);

In the end we of course will try to fix the middle-end/backends to
allow mixed types here as the current restriction doesn't really make sense.

 case EQ_EXPR:
 case NE_EXPR:
+  if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE)
+{
+  tree intt;
+  if (TREE_TYPE (type0) != TREE_TYPE (type1))
+{
+  error_at (location, "comparing vectors with different "
+  "element types");
+  return error_mark_node;
+}
+
+  if (TYPE_VECTOR_SUBPARTS (type0) != TYPE_VECTOR_SUBPARTS (type1))
+{
+  error_at (location, "comparing vectors with different "
+  "number of elements");
+  return error_mark_node;
+}

as above - compatibility should already be ensured, thus type0 == type1
here?

+/* Try a hardware hook for vector comparison or
+   extract comparison piecewise.  */
+static tree
+expand_vector_comparison (gimple_stmt_iterator *gsi, tree type, tree op0,
+  tree op1, enum tree_code code)

comments should mention and describe all function arguments.

+/* Expand vector condition EXP which should have the form
+   VEC_COND_EXPR into the following
+   vector:
+ {cond[i] != 0 ? vec0[i] : vec1[i], ... }
+   i changes from 0 to TYPE_VECTOR_SUBPARTS (TREE_TYPE (vec0)).  */
+static tree
+

[PATCH] VRP TLC

2011-08-15 Thread Richard Guenther

This restructures extract_range_from_unary_expr_1 so it is easier
to follow.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2011-08-15  Richard Guenther  

* tree-vrp.c (value_range_nonnegative_p): Fix anti-range case.
(extract_range_from_unary_expr_1): Restructure.

Index: gcc/tree-vrp.c
===
--- gcc/tree-vrp.c  (revision 177759)
+++ gcc/tree-vrp.c  (working copy)
@@ -1398,16 +1398,14 @@ range_includes_zero_p (value_range_t *vr
 static inline bool
 value_range_nonnegative_p (value_range_t *vr)
 {
+  /* Testing for VR_ANTI_RANGE is not useful here as any anti-range
+ which would return a useful value should be encoded as a 
+ VR_RANGE.  */
   if (vr->type == VR_RANGE)
 {
   int result = compare_values (vr->min, integer_zero_node);
   return (result == 0 || result == 1);
 }
-  else if (vr->type == VR_ANTI_RANGE)
-{
-  int result = compare_values (vr->max, integer_zero_node);
-  return result == -1;
-}
 
   return false;
 }
@@ -2826,61 +2886,51 @@ extract_range_from_unary_expr_1 (value_r
 value_range_t *vr0_, tree op0_type)
 {
   value_range_t vr0 = *vr0_;
-  tree min, max;
-  int cmp;
-
-  /* If VR0 is UNDEFINED, so is the result.  */
-  if (vr0.type == VR_UNDEFINED)
-{
-  set_value_range_to_undefined (vr);
-  return;
-}
 
-  /* Refuse to operate on certain unary expressions for which we
- cannot easily determine a resulting range.  */
-  if (code == FIX_TRUNC_EXPR
-  || code == FLOAT_EXPR
-  || code == CONJ_EXPR)
+  /* VRP only operates on integral and pointer types.  */
+  if (!(INTEGRAL_TYPE_P (op0_type)
+   || POINTER_TYPE_P (op0_type))
+  || !(INTEGRAL_TYPE_P (type)
+  || POINTER_TYPE_P (type)))
 {
   set_value_range_to_varying (vr);
   return;
 }
 
-  /* Refuse to operate on symbolic ranges, or if neither operand is
- a pointer or integral type.  */
-  if ((!INTEGRAL_TYPE_P (op0_type)
-   && !POINTER_TYPE_P (op0_type))
-  || (vr0.type != VR_VARYING
- && symbolic_range_p (&vr0)))
+  /* If VR0 is UNDEFINED, so is the result.  */
+  if (vr0.type == VR_UNDEFINED)
 {
-  set_value_range_to_varying (vr);
-  return;
-}
-
-  /* If the expression involves pointers, we are only interested in
- determining if it evaluates to NULL [0, 0] or non-NULL (~[0, 0]).  */
-  if (POINTER_TYPE_P (type) || POINTER_TYPE_P (op0_type))
-{
-  if (range_is_nonnull (&vr0))
-   set_value_range_to_nonnull (vr, type);
-  else if (range_is_null (&vr0))
-   set_value_range_to_null (vr, type);
-  else
-   set_value_range_to_varying (vr);
+  set_value_range_to_undefined (vr);
   return;
 }
 
-  /* Handle unary expressions on integer ranges.  */
-  if (CONVERT_EXPR_CODE_P (code)
-  && INTEGRAL_TYPE_P (type)
-  && INTEGRAL_TYPE_P (op0_type))
+  if (CONVERT_EXPR_CODE_P (code))
 {
   tree inner_type = op0_type;
   tree outer_type = type;
 
+  /* If the expression evaluates to a pointer, we are only interested in
+determining if it evaluates to NULL [0, 0] or non-NULL (~[0, 0]).  */
+  if (POINTER_TYPE_P (type))
+   {
+ if (CONVERT_EXPR_CODE_P (code))
+   {
+ if (range_is_nonnull (&vr0))
+   set_value_range_to_nonnull (vr, type);
+ else if (range_is_null (&vr0))
+   set_value_range_to_null (vr, type);
+ else
+   set_value_range_to_varying (vr);
+   }
+ else
+   set_value_range_to_varying (vr);
+ return;
+   }
+
   /* If VR0 is varying and we increase the type precision, assume
 a full range for the following transformation.  */
   if (vr0.type == VR_VARYING
+ && INTEGRAL_TYPE_P (inner_type)
  && TYPE_PRECISION (inner_type) < TYPE_PRECISION (outer_type))
{
  vr0.type = VR_RANGE;
@@ -2933,20 +2983,7 @@ extract_range_from_unary_expr_1 (value_r
   set_value_range_to_varying (vr);
   return;
 }
-
-  /* Conversion of a VR_VARYING value to a wider type can result
- in a usable range.  So wait until after we've handled conversions
- before dropping the result to VR_VARYING if we had a source
- operand that is VR_VARYING.  */
-  if (vr0.type == VR_VARYING)
-{
-  set_value_range_to_varying (vr);
-  return;
-}
-
-  /* Apply the operation to each end of the range and see what we end
- up with.  */
-  if (code == NEGATE_EXPR)
+  else if (code == NEGATE_EXPR)
 {
   /* -X is simply 0 - X, so re-use existing code that also handles
  anti-ranges fine.  */
@@ -2955,17 +2992,35 @@ extract_range_from_unary_expr_1 (value_r
   extract_range_from_binary_expr_1 (vr, MINUS_EXPR, type, &zero, &vr0);
   return;
 }
-  else if (code == ABS_EXPR
-   && !TYPE_UNSIGN

Re: [PATCH, i386]: Expand round(a) = sgn(a) * floor(fabs(a) + 0.5) using SSE4 ROUND insn

2011-08-15 Thread Michael Matz
Hi,

On Mon, 15 Aug 2011, Richard Guenther wrote:

> > Adding -msse4, we now generate branchless code using roundsd:
> >
> > .LFB0:
> >        .cfi_startproc
> >        movsd   .LC0(%rip), %xmm2
> >        movapd  %xmm0, %xmm1
> >        andpd   %xmm2, %xmm1
> >        andnpd  %xmm0, %xmm2
> >        addsd   .LC1(%rip), %xmm1
> >        roundsd $1, %xmm1, %xmm1
> >        orpd    %xmm2, %xmm1
> >        movapd  %xmm1, %xmm0
> >        ret
> 
> Hm, why do we need the sign-copy?  If I read the docs correctly
> we can simply use roundsd directly, no?

round-half-away-from-zero breaks your neck.  round[ps][sd] only supports 
the usual four IEEE rounding modes.


Ciao,
Michael.

Add a set_src_cost wrapper function

2011-08-15 Thread Richard Sandiford
I'm about to post a patch that adds an extra parameter to rtx_cost.
Since most callers to rtx_cost are for SET_SRCs, it seemed a shame to
have to add an extra boiler-plate parameter to each of them.  The patch
below therefore adds a set_src_cost wrapper for this common case.

Tested on x86_64-linux-gnu.  Also tested by compiling cc1 for:

avr-rtems bfin-elf mips64-linux-gnu x86_64-linux-gnu

and making sure that there were (a) no new warnings and (b) no differences
in -Os or -O2 output for gcc.c-torture and gcc.dg.  OK to install?

Richard


gcc/
* rtl.h (set_src_cost, get_full_set_src_cost): New functions.
* auto-inc-dec.c (attempt_change): Use set_src_cost instead of
rtx_cost.
* calls.c (precompute_register_parameters): Likewise.
* cfgloopanal.c (seq_cost): Likewise.
* combine.c (expand_compound_operation, make_extraction): Likewise.
(force_to_mode, distribute_and_simplify_rtx): Likewise.
* dse.c (find_shift_sequence): Likewise.
* expmed.c (init_expmed, expand_mult, expand_smod_pow2): Likewise.
* expr.c (compress_float_constant): Likewise.
* fwprop.c (should_replace_address, try_fwprop_subst): Likewise.
* gcse.c (want_to_gcse_p): Likewise.
* ifcvt.c (noce_try_sign_mask): Likewise.
* loop-doloop.c (doloop_optimize): Likewise.
* loop-invariant.c (create_new_invariant): Likewise.
* optabs.c (avoid_expensive_constant): Likewise.
* postreload.c (reload_cse_simplify_set, try_replace_in_use): Likewise.
(move2add_use_add2_insn, move2add_use_add3_insn): Likewise.
(reload_cse_move2add): Likewise.
* reload1.c (calculate_elim_costs_all_insns): Likewise.
(note_reg_elim_costly): Likewise.
* rtlanal.c (insn_rtx_cost): Likewise.
* simplify-rtx.c (simplify_binary_operation_1): Likewise.
* stmt.c (lshift_cheap_p): Likewise.
* tree-ssa-loop-ivopts.c (seq_cost, computation_cost): Likewise.
* config/avr/avr.c (final_prescan_insn): Likewise.
* config/bfin/bfin.c (bfin_rtx_costs): Likewise.
* config/mips/mips.c (mips_binary_cost, mips_rtx_costs): Likewise.

Index: gcc/rtl.h
===
--- gcc/rtl.h   2011-08-15 11:20:37.819148672 +0100
+++ gcc/rtl.h   2011-08-15 11:54:58.173568083 +0100
@@ -1217,6 +1217,25 @@ extern bool constant_pool_constant_p (rt
 extern bool truncated_to_mode (enum machine_mode, const_rtx);
 extern int low_bitmask_len (enum machine_mode, unsigned HOST_WIDE_INT);
 
+#ifndef GENERATOR_FILE
+/* Return the cost of moving X into a register, relative to the cost
+   of a register move.  SPEED_P is true if optimizing for speed rather
+   than size.  */
+
+static inline int
+set_src_cost (rtx x, bool speed_p)
+{
+  return rtx_cost (x, SET, speed_p);
+}
+
+/* Like set_src_cost, but return both the speed and size costs in C.  */
+
+static inline void
+get_full_set_src_cost (rtx x, struct full_rtx_costs *c)
+{
+  get_full_rtx_cost (x, SET, c);
+}
+#endif
 
 /* 1 if RTX is a subreg containing a reg that is already known to be
sign- or zero-extended from the mode of the subreg to the mode of
Index: gcc/auto-inc-dec.c
===
--- gcc/auto-inc-dec.c  2011-08-15 11:20:37.849148590 +0100
+++ gcc/auto-inc-dec.c  2011-08-15 11:53:01.377886222 +0100
@@ -483,9 +483,9 @@ attempt_change (rtx new_addr, rtx inc_re
   PUT_MODE (mem_tmp, mode);
   XEXP (mem_tmp, 0) = new_addr;
 
-  old_cost = (rtx_cost (mem, SET, speed)
- + rtx_cost (PATTERN (inc_insn.insn), SET, speed));
-  new_cost = rtx_cost (mem_tmp, SET, speed);
+  old_cost = (set_src_cost (mem, speed)
+ + set_src_cost (PATTERN (inc_insn.insn), speed));
+  new_cost = set_src_cost (mem_tmp, speed);
 
   /* The first item of business is to see if this is profitable.  */
   if (old_cost < new_cost)
Index: gcc/calls.c
===
--- gcc/calls.c 2011-08-15 11:20:37.849148590 +0100
+++ gcc/calls.c 2011-08-15 11:53:01.379886217 +0100
@@ -742,7 +742,7 @@ precompute_register_parameters (int num_
 || (GET_CODE (args[i].value) == SUBREG
 && REG_P (SUBREG_REG (args[i].value)
 && args[i].mode != BLKmode
-&& rtx_cost (args[i].value, SET, optimize_insn_for_speed_p ())
+&& set_src_cost (args[i].value, optimize_insn_for_speed_p ())
> COSTS_N_INSNS (1)
 && ((*reg_parm_seen
  && targetm.small_register_classes_for_mode_p 
(args[i].mode))
Index: gcc/cfgloopanal.c
===
--- gcc/cfgloopanal.c   2011-08-15 11:20:37.850148588 +0100
+++ gcc/cfgloopanal.c   2011-08-15 11:53:01.383886206 +0100
@@ -314,7 +314,7 @@ seq_cost (const_rtx seq, bool speed)
 {
   set = sing

[PATCH] Fix PR50082

2011-08-15 Thread Richard Guenther

This "fixes" PR50082 by passing comparison operands stripped off
useless conversions to the canonicalization routine.  This makes
sure to fold the testcase early from a point where emitting
a overflow warning is properly constrained.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-08-15  Richard Guenther  

PR middle-end/50082
* fold-const.c (maybe_canonicalize_comparison_1): Properly
convert the modified operand to the other operand type.
(fold_comparison): Call maybe_canonicalize_comparison_1 with
useless conversions stripped from comparison operands.

Index: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 177757)
+++ gcc/fold-const.c(working copy)
@@ -8446,6 +8446,7 @@ maybe_canonicalize_comparison_1 (locatio
   cst0, build_int_cst (TREE_TYPE (cst0), 1));
   if (code0 != INTEGER_CST)
 t = fold_build2_loc (loc, code0, TREE_TYPE (arg0), TREE_OPERAND (arg0, 0), 
t);
+  t = fold_convert (TREE_TYPE (arg1), t);
 
   /* If swapping might yield to a more canonical form, do so.  */
   if (swap)
@@ -8935,7 +8936,7 @@ fold_comparison (location_t loc, enum tr
   return fold_build2_loc (loc, cmp_code, type, variable1, const2);
 }
 
-  tem = maybe_canonicalize_comparison (loc, code, type, op0, op1);
+  tem = maybe_canonicalize_comparison (loc, code, type, arg0, arg1);
   if (tem)
 return tem;
 


Re: Add a set_src_cost wrapper function

2011-08-15 Thread Richard Guenther
On Mon, Aug 15, 2011 at 4:56 PM, Richard Sandiford
 wrote:
> I'm about to post a patch that adds an extra parameter to rtx_cost.
> Since most callers to rtx_cost are for SET_SRCs, it seemed a shame to
> have to add an extra boiler-plate parameter to each of them.  The patch
> below therefore adds a set_src_cost wrapper for this common case.
>
> Tested on x86_64-linux-gnu.  Also tested by compiling cc1 for:
>
>    avr-rtems bfin-elf mips64-linux-gnu x86_64-linux-gnu
>
> and making sure that there were (a) no new warnings and (b) no differences
> in -Os or -O2 output for gcc.c-torture and gcc.dg.  OK to install?

Ok.

Thanks,
Richard.

> Richard
>
>
> gcc/
>        * rtl.h (set_src_cost, get_full_set_src_cost): New functions.
>        * auto-inc-dec.c (attempt_change): Use set_src_cost instead of
>        rtx_cost.
>        * calls.c (precompute_register_parameters): Likewise.
>        * cfgloopanal.c (seq_cost): Likewise.
>        * combine.c (expand_compound_operation, make_extraction): Likewise.
>        (force_to_mode, distribute_and_simplify_rtx): Likewise.
>        * dse.c (find_shift_sequence): Likewise.
>        * expmed.c (init_expmed, expand_mult, expand_smod_pow2): Likewise.
>        * expr.c (compress_float_constant): Likewise.
>        * fwprop.c (should_replace_address, try_fwprop_subst): Likewise.
>        * gcse.c (want_to_gcse_p): Likewise.
>        * ifcvt.c (noce_try_sign_mask): Likewise.
>        * loop-doloop.c (doloop_optimize): Likewise.
>        * loop-invariant.c (create_new_invariant): Likewise.
>        * optabs.c (avoid_expensive_constant): Likewise.
>        * postreload.c (reload_cse_simplify_set, try_replace_in_use): Likewise.
>        (move2add_use_add2_insn, move2add_use_add3_insn): Likewise.
>        (reload_cse_move2add): Likewise.
>        * reload1.c (calculate_elim_costs_all_insns): Likewise.
>        (note_reg_elim_costly): Likewise.
>        * rtlanal.c (insn_rtx_cost): Likewise.
>        * simplify-rtx.c (simplify_binary_operation_1): Likewise.
>        * stmt.c (lshift_cheap_p): Likewise.
>        * tree-ssa-loop-ivopts.c (seq_cost, computation_cost): Likewise.
>        * config/avr/avr.c (final_prescan_insn): Likewise.
>        * config/bfin/bfin.c (bfin_rtx_costs): Likewise.
>        * config/mips/mips.c (mips_binary_cost, mips_rtx_costs): Likewise.
>
> Index: gcc/rtl.h
> ===
> --- gcc/rtl.h   2011-08-15 11:20:37.819148672 +0100
> +++ gcc/rtl.h   2011-08-15 11:54:58.173568083 +0100
> @@ -1217,6 +1217,25 @@ extern bool constant_pool_constant_p (rt
>  extern bool truncated_to_mode (enum machine_mode, const_rtx);
>  extern int low_bitmask_len (enum machine_mode, unsigned HOST_WIDE_INT);
>
> +#ifndef GENERATOR_FILE
> +/* Return the cost of moving X into a register, relative to the cost
> +   of a register move.  SPEED_P is true if optimizing for speed rather
> +   than size.  */
> +
> +static inline int
> +set_src_cost (rtx x, bool speed_p)
> +{
> +  return rtx_cost (x, SET, speed_p);
> +}
> +
> +/* Like set_src_cost, but return both the speed and size costs in C.  */
> +
> +static inline void
> +get_full_set_src_cost (rtx x, struct full_rtx_costs *c)
> +{
> +  get_full_rtx_cost (x, SET, c);
> +}
> +#endif
>
>  /* 1 if RTX is a subreg containing a reg that is already known to be
>    sign- or zero-extended from the mode of the subreg to the mode of
> Index: gcc/auto-inc-dec.c
> ===
> --- gcc/auto-inc-dec.c  2011-08-15 11:20:37.849148590 +0100
> +++ gcc/auto-inc-dec.c  2011-08-15 11:53:01.377886222 +0100
> @@ -483,9 +483,9 @@ attempt_change (rtx new_addr, rtx inc_re
>   PUT_MODE (mem_tmp, mode);
>   XEXP (mem_tmp, 0) = new_addr;
>
> -  old_cost = (rtx_cost (mem, SET, speed)
> -             + rtx_cost (PATTERN (inc_insn.insn), SET, speed));
> -  new_cost = rtx_cost (mem_tmp, SET, speed);
> +  old_cost = (set_src_cost (mem, speed)
> +             + set_src_cost (PATTERN (inc_insn.insn), speed));
> +  new_cost = set_src_cost (mem_tmp, speed);
>
>   /* The first item of business is to see if this is profitable.  */
>   if (old_cost < new_cost)
> Index: gcc/calls.c
> ===
> --- gcc/calls.c 2011-08-15 11:20:37.849148590 +0100
> +++ gcc/calls.c 2011-08-15 11:53:01.379886217 +0100
> @@ -742,7 +742,7 @@ precompute_register_parameters (int num_
>                     || (GET_CODE (args[i].value) == SUBREG
>                         && REG_P (SUBREG_REG (args[i].value)
>                 && args[i].mode != BLKmode
> -                && rtx_cost (args[i].value, SET, optimize_insn_for_speed_p 
> ())
> +                && set_src_cost (args[i].value, optimize_insn_for_speed_p ())
>                    > COSTS_N_INSNS (1)
>                 && ((*reg_parm_seen
>                      && targetm.small_register_classes_for_mode_p 
> (args[i].mode))
> Index: gcc/cfgloopanal.c
> 

Re: [PATCH, i386]: Expand round(a) = sgn(a) * floor(fabs(a) + 0.5) using SSE4 ROUND insn

2011-08-15 Thread Michael Matz
Hi,

On Mon, 15 Aug 2011, Michael Matz wrote:

> > > .LFB0:
> > >        .cfi_startproc
> > >        movsd   .LC0(%rip), %xmm2
> > >        movapd  %xmm0, %xmm1
> > >        andpd   %xmm2, %xmm1
> > >        andnpd  %xmm0, %xmm2
> > >        addsd   .LC1(%rip), %xmm1
> > >        roundsd $1, %xmm1, %xmm1
> > >        orpd    %xmm2, %xmm1
> > >        movapd  %xmm1, %xmm0
> > >        ret
> > 
> > Hm, why do we need the sign-copy?  If I read the docs correctly
> > we can simply use roundsd directly, no?
> 
> round-half-away-from-zero breaks your neck.  round[ps][sd] only supports 
> the usual four IEEE rounding modes.

But, you should be able to apply the sign to the 0.5, which wouldn't 
require building the absolute value of input:

round(x) = trunc(x + (copysign (0.5, x)))

which should roughly be expanded to:

       movsd   signbits(%rip), %xmm1
       andpd   %xmm0, %xmm1
       movsd   nextof0.5(%rip), %xmm2
   orpd%xmm1, %xmm2
   addpd   %xmm2, %xmm0
       roundsd $1, %xmm0, %xmm0
       ret

Which has one logical operation less (and one move because I chose a more 
optimal register assignment).


Ciao,
Michael.

Re: [google] Backport r174965 from trunk to google/gcc-4_6 (issue4852046)

2011-08-15 Thread Diego Novillo
On Sun, Aug 7, 2011 at 23:00, Guozhi Wei  wrote:

> 2011-08-08  Guozhi Wei  
>
>        Backport r174965 from trunk.
>
>        2011-06-12  Ira Rosen  
>
>                * tree-vect-data-refs.c (vect_peeling_hash_get_most_frequent):
>                Take number of iterations to peel into account for equally 
> frequent
>                misalignment values.

OK.

Diego.


Re: Add an operand number argument to rtx_cost

2011-08-15 Thread Richard Sandiford
Richard Guenther  writes:
> On Mon, Aug 15, 2011 at 5:15 PM, Richard Sandiford
>  wrote:
>> rtx_cost knows that the expression under test (X) is an operand to an
>> expression of a particular code (OUTER_CODE).  However, nothing says
>> which operand it actually is.  This can make a difference for
>> non-commutative binary operations.  E.g. shifts by 1 are often
>> cheaper than shifts of 1.
>>
>> The patch below makes this information available.  I'm planning on
>> using this parameter to provide costs of lvalues as well as rvalues,
>> but that's a separate patch.
>>
>> In the backend patches, I've avoided propagating the extra parameter
>> to subroutines unless it would be used.  I've also passed the original
>> operand number to recursive calls wherever the original code is passed
>> to recursive calls.  This includes expressions of the form:
>>
>>   rtx_cost (A, outer_code, speed_p) + rtx_cost (B, outer_code, speed_p)
>>
>> where A and B are subrtxes of X.  Since X is exactly one operand,
>> it seems odd to sum two costs with the same outer code like this,
>> but I left it be.
>>
>> I notice that score defines an rtx cost function but doesn't
>> actually use it.  Again, I've not fixed that here.
>>
>> avr.c:final_prescan_insn passes a SET rtx to rtx_cost (with an
>> outer code of INSN).  This is only used for debugging, so I passed
>> an arbitrary opno here.  (I didn't pass the opno of PATTERN because
>> that could easily change in future.)
>>
>> Tested on x86_64-linux-gnu.  Also tested by compiling cc1 for:
>>
>>        alpha-linux-gnu arm-linux-gnueabi avr-rtems bfin-elf cris-elf
>>        fr30-elf frv-linux-gnu h8300-elf ia64-linux-gnu iq2000-elf
>>        lm32-elf m32c-elf m32r-elf m68k-linux-gnu mcore-elf mep-elf
>>        microblaze-elf mips-linux-gnu mmix mn10300-elf moxie-elf
>>        hppa64-hp-hpux11.23 pdp11 picochip-elf powerpc-linux-gnu
>>        powerpc-eabispe rx-elf s390-linux-gnu score-elf sh-linux-gnu
>>        sparc-linux-gnu spu-elf xstormy16-elf v850-elf vax-netbsdelf
>>        xtensa-elf
>>
>> and checking that (a) there were no new warnings and (b) that the
>> -O2 and -Os output for gcc.dg and gcc.c-torture didn't change.
>> OK to install?
>
> Can you add to the documentation that operands are counted from zero?

Sure.  How about:

  The cost may depend on the precise form of the expression, which is
  available for examination in @var{x}, and the fact that @var{x} appears
  as operand @var{opno} of an expression with rtx code @var{outer_code}.
  That is, the hook can assume that there is some rtx @var{y} such
  that @samp{GET_CODE (@var{y}) == @var{outer_code}) and such that
  either (a) @samp{XEXP (@var{y}, @var{opno}) == @var{x}} or
  (b) @samp{XVEC (@var{y}, @var{opno})} contains @var{x}.

  @var{code} is @var{x}'s expression code---redundant, since it can be
  obtained with @code{GET_CODE (@var{x})}.

> I suppose lvalues will be SET, 0 then, right?

I think it'd be easier to have negative opno mean "lvalue".  The problem
is that things like zero_extend can be used as either lvalues or rvalues,
so if you're taking the cost of the operand of a zero_extend, you need to
know more than the operand number itself (which is always 0).

But that's for another day...

> THe patch looks ok to me but please leave others (esp. target maintainers)
> time to comment.

Thanks.  I'll hold off till Thursday morning UK time.

Richard


Re: Add an operand number argument to rtx_cost

2011-08-15 Thread Richard Guenther
On Mon, Aug 15, 2011 at 5:34 PM, Richard Sandiford
 wrote:
> Richard Guenther  writes:
>> On Mon, Aug 15, 2011 at 5:15 PM, Richard Sandiford
>>  wrote:
>>> rtx_cost knows that the expression under test (X) is an operand to an
>>> expression of a particular code (OUTER_CODE).  However, nothing says
>>> which operand it actually is.  This can make a difference for
>>> non-commutative binary operations.  E.g. shifts by 1 are often
>>> cheaper than shifts of 1.
>>>
>>> The patch below makes this information available.  I'm planning on
>>> using this parameter to provide costs of lvalues as well as rvalues,
>>> but that's a separate patch.
>>>
>>> In the backend patches, I've avoided propagating the extra parameter
>>> to subroutines unless it would be used.  I've also passed the original
>>> operand number to recursive calls wherever the original code is passed
>>> to recursive calls.  This includes expressions of the form:
>>>
>>>   rtx_cost (A, outer_code, speed_p) + rtx_cost (B, outer_code, speed_p)
>>>
>>> where A and B are subrtxes of X.  Since X is exactly one operand,
>>> it seems odd to sum two costs with the same outer code like this,
>>> but I left it be.
>>>
>>> I notice that score defines an rtx cost function but doesn't
>>> actually use it.  Again, I've not fixed that here.
>>>
>>> avr.c:final_prescan_insn passes a SET rtx to rtx_cost (with an
>>> outer code of INSN).  This is only used for debugging, so I passed
>>> an arbitrary opno here.  (I didn't pass the opno of PATTERN because
>>> that could easily change in future.)
>>>
>>> Tested on x86_64-linux-gnu.  Also tested by compiling cc1 for:
>>>
>>>        alpha-linux-gnu arm-linux-gnueabi avr-rtems bfin-elf cris-elf
>>>        fr30-elf frv-linux-gnu h8300-elf ia64-linux-gnu iq2000-elf
>>>        lm32-elf m32c-elf m32r-elf m68k-linux-gnu mcore-elf mep-elf
>>>        microblaze-elf mips-linux-gnu mmix mn10300-elf moxie-elf
>>>        hppa64-hp-hpux11.23 pdp11 picochip-elf powerpc-linux-gnu
>>>        powerpc-eabispe rx-elf s390-linux-gnu score-elf sh-linux-gnu
>>>        sparc-linux-gnu spu-elf xstormy16-elf v850-elf vax-netbsdelf
>>>        xtensa-elf
>>>
>>> and checking that (a) there were no new warnings and (b) that the
>>> -O2 and -Os output for gcc.dg and gcc.c-torture didn't change.
>>> OK to install?
>>
>> Can you add to the documentation that operands are counted from zero?
>
> Sure.  How about:
>
>  The cost may depend on the precise form of the expression, which is
>  available for examination in @var{x}, and the fact that @var{x} appears
>  as operand @var{opno} of an expression with rtx code @var{outer_code}.
>  That is, the hook can assume that there is some rtx @var{y} such
>  that @samp{GET_CODE (@var{y}) == @var{outer_code}) and such that
>  either (a) @samp{XEXP (@var{y}, @var{opno}) == @var{x}} or
>  (b) @samp{XVEC (@var{y}, @var{opno})} contains @var{x}.
>
>  @var{code} is @var{x}'s expression code---redundant, since it can be
>  obtained with @code{GET_CODE (@var{x})}.

Yes, that looks good to me.

Thanks,
Richard.


Re: [PATCH] Remove "bogus" g++.dg/init/copy7.C testcase

2011-08-15 Thread Mike Stump
On Aug 15, 2011, at 5:42 AM, Richard Guenther wrote:
> The argument still holds that no reasonable memcpy implementation
> will reject the src == dest case.

Hum...  Sounds like if that's the case that we should document it in the manual 
as something we expect (requirement) of the memcpy implementation.  I'll let a 
frontend or optimization person review this.


Re: Vector Comparison patch

2011-08-15 Thread Artem Shinkarov
On Mon, Aug 15, 2011 at 3:24 PM, Richard Guenther
 wrote:
> On Fri, Aug 12, 2011 at 4:03 AM, Artem Shinkarov
>  wrote:
>> Hi
>>
>> Here is a completed version of the vector comparison patch we
>> discussed a long time ago here:
>> http://gcc.gnu.org/ml/gcc-patches/2010-08/msg01184.html
>>
>> The patch implements vector comparison according to the OpenCL
>> standard, when the result of the comparison of two vectors is vector
>> of signed integers, where -1 represents true and 0 false.
>>
>> The patch implements vector conditional res = VCOND
>> which is expanded into:
>> foreach (i in length (V1)) res[i] = V1 == 0 ? V3[i] : V2[i].
>
> Some comments on the patch below.  First, in general I don't see
> why you need a new target hook to specify whether to "vectorize"
> a comparison.  Why are the existing hooks used by the vectorizer
> not enough?
>
> Index: gcc/fold-const.c
> ===
> --- gcc/fold-const.c    (revision 177665)
> +++ gcc/fold-const.c    (working copy)
> @@ -9073,34 +9073,61 @@ fold_comparison (location_t loc, enum tr
>      floating-point, we can only do some of these simplifications.)  */
>   if (operand_equal_p (arg0, arg1, 0))
>     {
> -      switch (code)
> +      if (TREE_CODE (TREE_TYPE (arg0)) == VECTOR_TYPE)
>        {
> -       case EQ_EXPR:
> -         if (! FLOAT_TYPE_P (TREE_TYPE (arg0))
> -             || ! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0
> -           return constant_boolean_node (1, type);
>
> I think this change should go in a separate patch for improved
> constant folding.  It shouldn't be necessary for enabling vector compares, no?

Unfortunately no, this case must be covered here, otherwise x != x
condition fails.

>
> +      if (TYPE_UNSIGNED (TREE_TYPE (TREE_TYPE (ifexp
> +        {
> +          error_at (colon_loc, "vector comparison must be of signed "
> +                              "integer vector type");
> +          return error_mark_node;
> +        }
>
> why that?

Well, later on I rely on this fact. I mean OpenCL says that it should
return -1 in the sense that all bits set. I don't really know, I can
support unsigned masks as well, but wouldn't it just introduce a
source for possible errors. I mean that natural choice for true and
flase is 0 and 1, not 0 and -1. Anyway I don't have a strong opinion
there, and I could easily adjust it if we decide that we want it.

>
> +      if (TYPE_VECTOR_SUBPARTS (type1) != TYPE_VECTOR_SUBPARTS (type2)
> +          || TYPE_VECTOR_SUBPARTS (TREE_TYPE (ifexp))
> +             != TYPE_VECTOR_SUBPARTS (type1))
> +        {
> +          error_at (colon_loc, "vectors of different length found in "
> +                               "vector comparison");
> +          return error_mark_node;
> +        }
>
> I miss verification that type1 and type2 are vector types, or is that done
> elsewhere?  I think type1 and type2 are already verified to be
> compatible (but you might double-check).  At least the above would be
> redundant with

Thanks, type1 and type2 both vectors comparison is missing, going to
be added in the new version of the patch.
>
> +      if (type1 != type2)
> +        {
> +          error_at (colon_loc, "vectors of different types involved in "
> +                               "vector comparison");
> +          return error_mark_node;
> +        }

You are right, what I meant here is TREE_TYPE (type1) != TREE_TYPE
(type2), because vector (4, int) have the same number of elements as
vector (4, float). This would be fixed in the new version.

>
> Joseph may have comments about the fully-fold stuff that follows.
>
> +      /* Currently the expansion of VEC_COND_EXPR does not allow
> +        expessions where the type of vectors you compare differs
> +        form the type of vectors you select from. For the time
> +        being we insert implicit conversions.  */
> +      if ((COMPARISON_CLASS_P (ifexp)
>
> Why only for comparison-class?
Not only, there is || involved:
(COMPARISON_CLASS_P (ifexp)  && TREE_TYPE (TREE_OPERAND (ifexp, 0)) != type1)
|| TREE_TYPE (ifexp) != type1

So if this is a comparison class, we check the first operand, because
the result of the comparison fits, however the operands could not. In
case we have an expression of signed vector, we know that we would
transform it into exp != {0,0,...} in tree-vect-generic.c, but if the
types of operands do not match we convert them.

>
> +          && TREE_TYPE (TREE_OPERAND (ifexp, 0)) != type1)
> +         || TREE_TYPE (ifexp) != type1)
> +       {
> +         tree comp_type = COMPARISON_CLASS_P (ifexp)
> +                          ? TREE_TYPE (TREE_OPERAND (ifexp, 0))
> +                          : TREE_TYPE (ifexp);
> +         tree vcond;
> +
> +         op1 = convert (comp_type, op1);
> +         op2 = convert (comp_type, op2);
> +         vcond = build3 (VEC_COND_EXPR, comp_type, ifexp, op1, op2);
> +         vcond = convert (type1, vcond);
> +         return vcond;
> +       }

CFT: [build] Move libgcc_tm_file to toplevel libgcc

2011-08-15 Thread Rainer Orth
This patch almost completes the build side of the libgcc moves.  It
moves the libgcc_tm_file support to libgcc/config.host (tm_file), where
it belongs.  It builds on a patch Paolo posted some time ago, with some
minor corrections (introducing the required dependencies on the
generated libgcc_tm.h).  I've removed libgcc_tm.h from tm.h and include
the file directly in all libgcc sources that currently include tm.h.

Everything else is pretty mechanical, I believe.

Tested as described in the previous submissions.

Rainer


2011-08-06  Rainer Orth  
Paolo Bonzini  

gcc:
* configure.ac (libgcc_tm_file_list, libgcc_tm_include_list):
Remove.
* configure: Regenerate.
* Makefile.in (libgcc_tm_file_list, libgcc_tm_include_list): Remove.
(TM_H): Remove libgcc_tm.h, $(libgcc_tm_file_list).
(libgcc_tm.h, cs-libgcc_tm.h): Remove.
(clean): Remove libgcc_tm.h
* mkconfig.sh: Don't include libgcc_tm.h in tm.h.
* config.gcc (libgcc_tm_file): Remove.
(arm*-*-linux*): Remove libgcc_tm_file for arm*-*-linux-*eabi.
(arm*-*-uclinux*): Remove libgcc_tm_file for arm*-*-uclinux*eabi.
(arm*-*-eabi*, arm*-*-symbianelf*): Remove libgcc_tm_file.
(avr-*-rtems*): Likewise.
(avr-*-*): Likewise.
(frv-*-elf): Likewise.
(frv-*-*linux*): Likewise.
(h8300-*-rtems*): Likewise.
(h8300-*-elf*): Likewise.
(i[34567]86-*-darwin*): Likewise.
(x86_64-*-darwin*): Likewise.
(rx-*-elf*): Likewise.
(tic6x-*-elf): Likewise.
(tic6x-*-uclinux): Likewise.

libgcc:
* configure.ac (tm_file_): New variable.
Determine from tm_file.
(tm_file, tm_defines): Substitute.
* configure: Regenerate.
* mkheader.sh: New file.
* Makefile.in (clean): Remove libgcc_tm.h.
($(objects)): Depend on libgcc_tm.h.
(libgcc_tm_defines, libgcc_tm_file): New variables.
(libgcc_tm.h, libgcc_tm.stamp): New targets.
($(libgcc-objects), $(libgcc-s-objects), $(libgcc-eh-objects))
($(libgcov-objects), $(libunwind-objects), $(libunwind-s-objects))
($(extra-parts)): Depend on libgcc_tm.h.
* config.host (tm_defines, tm_file): New variable.
(arm*-*-linux*): Set tm_file for arm*-*-linux-*eabi.
(arm*-*-uclinux*): Set tm_file for arm*-*-uclinux*eabi.
(arm*-*-eabi*, arm*-*-symbianelf*): Set tm_file.
(avr-*-rtems*): Likewise.
(avr-*-*): Likewise.
(frv-*-elf): Likewise.
(frv-*-*linux*): Likewise.
(h8300-*-rtems*): Likewise.
(h8300-*-elf*): Likewise.
(i[34567]86-*-darwin*): Likewise.
(x86_64-*-darwin*): Likewise.
(rx-*-elf): Likewise.
(tic6x-*-uclinux): Likewise.
(tic6x-*-elf): Likewise.
* config/alpha/gthr-posix.c: Include libgcc_tm.h.
* config/i386/cygming-crtbegin.c: Likewise.
* config/i386/cygming-crtend.c: Likewise.
* config/ia64/fde-vms.c: Likewise.
* config/ia64/unwind-ia64.c: Likewise.
* config/libbid/bid_gcc_intrinsics.h: Likewise.
* config/rs6000/darwin-fallback.c: Likewise.
* config/stormy16/lib2funcs.c: Likewise.
* config/xtensa/unwind-dw2-xtensa.c: Likewise.
* crtstuff.c: Likewise.
* dfp-bit.h: Likewise.
* emutls.c: Likewise.
* fixed-bit.c: Likewise.
* fp-bit.c: Likewise.
* generic-morestack-thread.c: Likewise.
* generic-morestack.c: Likewise.
* libgcc2.c: Likewise.
* libgcov.c: Likewise.
* unwind-dw2-fde-dip.c: Likewise.
* unwind-dw2-fde.c: Likewise.
* unwind-dw2.c: Likewise.
* unwind-sjlj.c: Likewise.

# HG changeset patch
# Parent fe692d8e27093b36a9342ef937f5f9891af8fa60
Move libgcc_tm_file to toplevel libgcc

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -486,8 +486,6 @@ md_file=$(srcdir)/config/@md_file@
 tm_file_list=@tm_file_list@
 tm_include_list=@tm_include_list@
 tm_defines=@tm_defines@
-libgcc_tm_file_list=@libgcc_tm_file_list@
-libgcc_tm_include_list=@libgcc_tm_include_list@
 tm_p_file_list=@tm_p_file_list@
 tm_p_include_list=@tm_p_include_list@
 build_xm_file_list=@build_xm_file_list@
@@ -786,8 +784,7 @@ CONFIG_H  = config.h  $(host_xm_file_lis
 TCONFIG_H = tconfig.h $(xm_file_list)
 TM_P_H= tm_p.h$(tm_p_file_list)
 GTM_H = tm.h  $(tm_file_list) insn-constants.h
-TM_H  = $(GTM_H) libgcc_tm.h $(libgcc_tm_file_list) insn-flags.h \
-	$(OPTIONS_H)
+TM_H  = $(GTM_H) insn-flags.h $(OPTIONS_H)
 
 # Variables for version information.
 BASEVER := $(srcdir)/BASE-VER  # 4.x.y
@@ -1592,7 +1589,6 @@ config.h: cs-config.h ; @true
 bconfig.h: cs-bconfig.h ; @true
 tconfig.h: cs-tconfig.h ; @true
 tm.h: cs-tm.h ; @true
-libgcc_tm.h: cs-libgcc_tm.h ; @true
 tm_p.h: cs-tm_p.h ; @true
 
 cs-config.h: Makefile
@@ -1615,11 

Re: [patch, fortran] PR 46659 - extend conversion warnings to assignments

2011-08-15 Thread Thomas Koenig

Am 14.08.2011 22:54, schrieb Tobias Burnus:

Thomas Koenig wrote:

the attached patch extends conversion warnings to assignments.
OK for trunk?


I get now two warnings for:

complex(8), parameter :: z = cmplx (0.5, 0.5)
r = z
end


The problem is that gfc_check_assign is called twice for this, from
different code paths:


Breakpoint 1, gfc_check_assign (lvalue=0x7fffd8d0, rvalue=0x15bb020, 
conform=1)
at ../../trunk/gcc/fortran/expr.c:3045 

3045{ 

(gdb) bt 

#0  gfc_check_assign (lvalue=0x7fffd8d0, rvalue=0x15bb020, 
conform=1)
at ../../trunk/gcc/fortran/expr.c:3045 

#1  0x004f70bb in gfc_check_assign_symbol (sym=0x15bb680, 
rvalue=0x15bb020)
at ../../trunk/gcc/fortran/expr.c:3649 

#2  0x004e0670 in add_init_expr_to_sym (name=Unhandled dwarf 
expression opcode 0xf3
) at ../../trunk/gcc/fortran/decl.c:1346 

#3  0x004e87d0 in variable_decl (elem=) 

at ../../trunk/gcc/fortran/decl.c:2047 

#4  gfc_match_data_decl (elem=) at 
../../trunk/gcc/fortran/decl.c:4124
#5  0x0052cb8a in match_word (subr=Unhandled dwarf expression 
opcode 0xf3
) at ../../trunk/gcc/fortran/parse.c:65 

#6  0x0052d3a0 in decode_statement () at 
../../trunk/gcc/fortran/parse.c:283
#7  decode_statement () at ../../trunk/gcc/fortran/parse.c:232 

#8  0x0052ea05 in next_free () at 
../../trunk/gcc/fortran/parse.c:731
#9  next_statement () at ../../trunk/gcc/fortran/parse.c:923 

#10 0x005320de in gfc_parse_file () at 
../../trunk/gcc/fortran/parse.c:4382
#11 0x0056b486 in gfc_be_parse_file () at 
../../trunk/gcc/fortran/f95-lang.c:250

#12 0x008fa978 in compile_file () at ../../trunk/gcc/toplev.c:548
#13 do_compile () at ../../trunk/gcc/toplev.c:1886
#14 toplev_main () at ../../trunk/gcc/toplev.c:1962
#15 0x76f8aa7d in __libc_start_main () from /lib64/libc.so.6
#16 0x004cade9 in _start () at ../sysdeps/x86_64/elf/start.S:113
(gdb) c
Continuing.

Breakpoint 1, gfc_check_assign (lvalue=0x7fffd9e0, rvalue=0x15bb020, 
conform=1)

at ../../trunk/gcc/fortran/expr.c:3045
3045{
(gdb) bt
#0  gfc_check_assign (lvalue=0x7fffd9e0, rvalue=0x15bb020, conform=1)
at ../../trunk/gcc/fortran/expr.c:3045
#1  0x004f70bb in gfc_check_assign_symbol (sym=0x15bb680, 
rvalue=0x15bb020)

at ../../trunk/gcc/fortran/expr.c:3649
#2  0x0055a697 in traverse_ns (st=Unhandled dwarf expression 
opcode 0xf3

) at ../../trunk/gcc/fortran/symbol.c:
#3  0x0055fd8c in gfc_traverse_ns (ns=0x15ba590,
func=0x548200 ) at 
../../trunk/gcc/fortran/symbol.c:3349
#4  0x005475e1 in resolve_types (ns=0x15ba590) at 
../../trunk/gcc/fortran/resolve.c:13511
#5  0x0053c4e4 in gfc_resolve (ns=0x15ba590) at 
../../trunk/gcc/fortran/resolve.c:13593

#6  gfc_resolve (ns=0x15ba590) at ../../trunk/gcc/fortran/resolve.c:13581
#7  0x005325cb in resolve_all_program_units 
(gfc_global_ns_list=)

at ../../trunk/gcc/fortran/parse.c:4247
#8  gfc_parse_file (gfc_global_ns_list=)
at ../../trunk/gcc/fortran/parse.c:4513
#9  0x0056b486 in gfc_be_parse_file () at 
../../trunk/gcc/fortran/f95-lang.c:250

#10 0x008fa978 in compile_file () at ../../trunk/gcc/toplev.c:548
#11 do_compile () at ../../trunk/gcc/toplev.c:1886
#12 toplev_main () at ../../trunk/gcc/toplev.c:1962
#13 0x76f8aa7d in __libc_start_main () from /lib64/libc.so.6
#14 0x004cade9 in _start () at ../sysdeps/x86_64/elf/start.S:113


What's the best way here?  Add an "already checked" flag?  I don't want
to disable the test for complex.



Fixes for debug/50006

2011-08-15 Thread Richard Henderson
Ada on PA-RISC turned up two different problems with my
patches for REG_ARGS_SIZE.

(1) When we emit_stack_restore, that also zaps any 
accumulated args_size.  Emit the proper notes.

(2) The code at the bottom of alloca was suppressing
the creation of args_size notes, except when the target
provided an allocate_stack named pattern.  Oops.


Sanity checked on x86_64-linux, though the changes really
shouldn't have any effect on that target.

Still waiting to hear if these two are sufficient to return
hppa64-hpux to bootstrap status with Ada, but I've committed
them anyway as I think they're sufficiently obvious.  This
should have affected s390x-linux as well; no one is testing
Ada on that platform?


r~
PR middle-end/50006
* explow.c (allocate_dynamic_stack_space): Move suppress_reg_args_size
setting out to include allocate_stack named pattern as well.
* builtins.c (expand_builtin_apply): Add ARG_SIZE 0 note.
* stmt.c (expand_stack_restore): Likewise.



diff --git a/gcc/builtins.c b/gcc/builtins.c
index e0afc90..da86b8c 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -1680,6 +1680,7 @@ expand_builtin_apply (rtx function, rtx arguments, rtx 
argsize)
   else
 #endif
 emit_stack_restore (SAVE_BLOCK, old_stack_level);
+  fixup_args_size_notes (call_insn, get_last_insn(), 0);
 
   OK_DEFER_POP;
 
diff --git a/gcc/explow.c b/gcc/explow.c
index f8262db..beeab44 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -1375,6 +1375,9 @@ allocate_dynamic_stack_space (rtx size, unsigned 
size_align,
   else if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
 probe_stack_range (STACK_CHECK_PROTECT, size);
 
+  /* Don't let anti_adjust_stack emit notes.  */
+  suppress_reg_args_size = true;
+
   /* Perform the required allocation from the stack.  Some systems do
  this differently than simply incrementing/decrementing from the
  stack pointer, such as acquiring the space by calling malloc().  */
@@ -1425,7 +1428,6 @@ allocate_dynamic_stack_space (rtx size, unsigned 
size_align,
}
 
   saved_stack_pointer_delta = stack_pointer_delta;
-  suppress_reg_args_size = true;
 
   if (flag_stack_check && STACK_CHECK_MOVING_SP)
anti_adjust_stack_and_probe (size, false);
@@ -1436,13 +1438,14 @@ allocate_dynamic_stack_space (rtx size, unsigned 
size_align,
 The constant size alloca should preserve
 crtl->preferred_stack_boundary alignment.  */
   stack_pointer_delta = saved_stack_pointer_delta;
-  suppress_reg_args_size = false;
 
 #ifdef STACK_GROWS_DOWNWARD
   emit_move_insn (target, virtual_stack_dynamic_rtx);
 #endif
 }
 
+  suppress_reg_args_size = false;
+
   /* Finish up the split stack handling.  */
   if (final_label != NULL_RTX)
 {
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 2fb4b18..be21a57 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -2016,10 +2016,13 @@ expand_stack_save (void)
 void
 expand_stack_restore (tree var)
 {
-  rtx sa = expand_normal (var);
+  rtx prev, sa = expand_normal (var);
 
   sa = convert_memory_address (Pmode, sa);
+
+  prev = get_last_insn ();
   emit_stack_restore (SAVE_BLOCK, sa);
+  fixup_args_size_notes (prev, get_last_insn (), 0);
 }
 
 /* Do the insertion of a case label into case_list.  The labels are


Re: [C++0x] contiguous bitfields race implementation

2011-08-15 Thread Aldy Hernandez



Some comments.

   /* If we have a bit-field with a bitsize>  0... */
   if (DECL_BIT_FIELD_TYPE (fld)
&&  tree_low_cst (DECL_SIZE (fld), 1)>  0)

I think we can check bitsize != 0, thus

&&  !integer_zerop (DECL_SIZE (fld))


Done


  /* Short-circuit out if we have the max bits allowed.  */
  if (cumulative_bitsize>= MAX_FIXED_MODE_SIZE)
{
  *maxbits = MAX_FIXED_MODE_SIZE;
  /* Calculate byte offset to the beginning of the bit region.  */
  gcc_assert (start_bitpos % BITS_PER_UNIT == 0);
  *offset = fold_build2 (PLUS_EXPR, TREE_TYPE (start_offset),
 start_offset,
 build_int_cst (integer_type_node,
start_bitpos / 
BITS_PER_UNIT));
  return;

apart from the *offset calculation being redundant, *offset + maxbits
may not include the referenced field.  How do you plan to find
an "optimal" window for such access? (*)


Actually offset is always needed because we use it in store_bit_field() 
to adjust the memory reference up to the bit region.  However... I have 
removed the MAX_FIXED_MODE_SIZE constrain all throughout.  See 
explanation below.



   if (!DECL_BIT_FIELD_TYPE (fld)
  || integer_zerop (DECL_SIZE (fld)))
 break;

we know that we'll eventually find field.


Good catch.  Done.


   /* If we found the end of the bit field sequence, include the
  padding up to the next field...  */
   if (fld)
 {

could be a non-FIELD_DECL, you have to skip those first.


I can't find an example of a non-FIELD_DECL here for the life of me. 
I've run numerous tests and can't trigger one.  Do you have one in mind 
so I can handle it?



Note that another complication comes to my mind now - the offset
field of a COMPONENT_REF is used to specify a variable offset
and has to be used, if present, instead of DECL_FIELD_OFFSET.
Thus your building of COMPONENT_REFs to then pass them to
get_inner_reference is broken.  As you are in generic code and not
in the C++ frontend I believe you have to properly handle this case
(may I suggest to, at the start of the function, simply return a
minimum byte-aligned blob for the case that there is a variable
offset to the bitfield?)


Done.

BTW, where would this happen?  I'd like an actual test to stick in 
there.  Is this for non C/C++?



   /* ...otherwise, this is the last element in the structure.  */
   else
 {
   /* Include the padding at the end of structure.  */
   *maxbits = TREE_INT_CST_LOW (TYPE_SIZE (record_type))
- TREE_INT_CST_LOW (start_bitpos_direct_parent);
   if (*maxbits>  MAX_FIXED_MODE_SIZE)
*maxbits = MAX_FIXED_MODE_SIZE;
 }

with Andrews answer this is invalid.  You can (and should) at most do

   else
 *maxbits = (*maxbits + BITS_PER_UNIT - 1)&  ~(BITS_PER_UNIT - 1);


I have done this, but I have also removed the constraint to 
MAX_FIXED_MODE_SIZE.  See below.



There is still the general issue of packed bitfields which will probably
make the issue of the computed group not covering all of field more
prominent (esp. if you limit to MAX_FIXED_MODE_SIZE - consider
struct __attribute__((packed)) { long long : 1; long long a : 64; char
c; } where
a does not fit in a DImode mem but crosses it.  Why constrain
*maxbits to MAX_FIXED_MODE_SIZE at all?  Shoudln't the *offset,
*maxbits pair just constrain what the caller does, not force it to actually
use an access covering that full range (does it?)?


Well, I have removed the MAX_FIXED_MODE_SIZE restriction, since every 
offset adjustment in the bit field machinery will need a corresponding 
MAXBITS adjustment.  We can end up reducing MAXBITS into negative 
territory.  So we really have to keep track of the actual number of 
bits.  So, we've converged, just for different reasons :).


I have bootstrapped the compiler with the bitfield restrictions in 
place.  This unearthed a few corner cases, which we are now handling 
correctly with this revision.  So, please take a look at the entire 
patch, as there are small changes throughout.


I am including both the entire patch, and the get_bit_range() function 
separately, to make it easier to review.


Thanks.
/* In the C++ memory model, consecutive non-zero bit fields in a
   structure are considered one memory location.

   Given a COMPONENT_REF, this function calculates the byte offset
   from the containing object to the start of the contiguous bit
   region containing the field in question.  This byte offset is
   returned in *OFFSET.

   The maximum number of bits that can be addressed while storing into
   the COMPONENT_REF is returned in *MAXBITS.  This number is the
   number of bits in the contiguous bit region, including any
   padding.  */

static void
get_bit_range (tree exp, tree *offset, HOST_WIDE_INT *maxbits)
{
  tree field, record_type, fld;
  bool prev_field_is_bit

Re: RFC: [build, ada] Centralize PICFLAG configuration

2011-08-15 Thread Rainer Orth
Paolo,

> On 08/10/2011 01:42 PM, Rainer Orth wrote:
>> * Centralize the determination of PICFLAG.  Currently, three libraries
>>inside the gcc tree are built PIC without libtool: libgcc, libiberty,
>>and libgnat/libgnarl.
>>
>>libiberty/configure.ac has a hardcoded list of PICFLAG that could be
>>moved to a toplevel config/picflag.m4.
>
> That's the simplest alternative.  It would need however a pass through the
> config/ directory for targets that are never used as hosts for GCC (and
> thus libiberty).
>
> Alternatively, the libtool code could be extracted to config/picflag.m4.

I've merged all three, and (as expected) found a couple of
inconsistencies.

* The general approach between libtool and libiberty differs.  Unless
  otherwise specified (PIC is the default or doesn't work for some
  reason), libtool defaults to -fPIC, while libiberty has a strange
  mixture of -fPIC/-fpic and nothing, without explanation and without a
  default.

* git libtool.m4 uses -fno-common on *-*-darwin.  No idea if this is
  required.

* For QNX, it uses -fPIC -shared, which may no longer be necessary and
  is claimed as a g++ workaround.

* For IA64 HP-UX, there's a claim that -fPIC is necessary despite PIC
  code being the default.  I could find no hint in trunk that this is
  true any longer.

* On a few targets (called out in config/picflag.m4), -fpic and -fPIC
  differ.  While libtool always uses -fPIC, libiberty/configure.ac
  preferred -fpic in a few cases.  No idea why.

* For sh*-*-linux* and sh*-*-netbsd*, -fpic is used in
  HOST_LIBGCC2_CFLAGS.  Again, no explanation.  Perhaps this
  could/should be done as a local override in libgcc instead?

* For SPARC, libiberty/configure.ac has

case "${CFLAGS}" in
*-fpic*)
PICFLAG=-fpic
;;
*)
PICFLAG=-fPIC
;;
esac ;;

  Why is this SPARC-specific?

* There are two platforms that specify -fpic where this doesn't make a
  difference from -fPIC: arm*-*-netbsdelf* and bfin*-elf*,
  bfin*-uclinux*, bfin*-linux-uclibc*.  I've omitted that setting.

>>Alternatively, one could think about using libtool --config | grep
>>pic_flag to determine the flag without actually using libtool.
>>
>>Last, one completely could go for libtool, but I very much doubt such
>>a suggestion would get much traction.
>>
>> My current plan is to merge the PICFLAG information from libiberty and
>> libgcc into picflag.m4 and use that.
>
> Yes, that needs to be done of course.  I'm not sure if we still support
> gnatlib_and_tools to build libada/gnattools.  If so, we would need the
> PICFLAG to be available somehow in the gcc Makefile (perhaps by providing
> GCC_TARGET_PICFLAG in addition to GCC_PICFLAG in picflag.m4).

The only trace I could find is in a install.texi reference to historical
practice.

The patch below has been tested as the previous submissions.

Rainer


2011-07-31  Rainer Orth  

config:
* picflag.m4: New file.

gcc/ada:
* gcc-interface/Makefile.in (GNATLIBCFLAGS_FOR_C): Replace
TARGET_LIBGCC2_CFLAGS by PICFLAG.
(gnatlib-shared-default, gnatlib-shared-dual-win32,
gnatlib-shared-win32, gnatlib-shared-darwin, gnatlib-shared,
gnatlib-sjlj, gnatlib-zcx): Likewise.

libada:
* configure.ac: Include ../config/picflag.m4.
(GCC_PICFLAG): Call it.
Substitute.
* configure: Regenerate.
* Makefile.in (TARGET_LIBGCC2_CFLAGS): Replace by PICFLAG.
(GNATLIBCFLAGS_FOR_C): Replace TARGET_LIBGCC2_CFLAGS by PICFLAG.
(LIBADA_FLAGS_TO_PASS): Likewise.
Don't include $(GCC_DIR)/libgcc.mvars.

libiberty:
* aclocal.m4: Include ../config/picflag.m4.
* configure.ac (GCC_PICFLAG): Call it.
(enable_shared): Clear PICFLAG unless shared.
* configure: Regenerate.

# HG changeset patch
# Parent feb70952e84eb1f718614d90985c3291dd565baa
Centralize PICFLAG configuration

diff --git a/config/picflag.m4 b/config/picflag.m4
new file mode 100644
--- /dev/null
+++ b/config/picflag.m4
@@ -0,0 +1,80 @@
+AC_DEFUN([GCC_PICFLAG], [
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  # FIXME: Do we need something for CFLAGS below?
+
+case "${host}" in
+# PIC is the default on some targets or must not be used.
+*-*-darwin*)
+	# PIC is the default on this platform
+	# Common symbols not allowed in MH_DYLIB files
+	PICFLAG=-fno-common
+	;;
+alpha*-dec-osf5*)
+	# PIC is the default.
+	;;
+hppa*64*-*-hpux*)
+	# PIC is the default for 64-bit PA HP-UX.
+	;;
+i[34567]86-*-cygwin* | i[34567]86-*-mingw* | x86_64-*-mingw*)
+	;;
+i[34567]86-*-interix3*)
+	# Interix 3.x gcc -fpic/-fPIC options generate broken code.
+	# Instead, we relocate shared libraries at runtime.
+	;;
+i[34567]86-*-nto-qnx*)
+	# QNX uses GNU C++, but need to define -shared option too, otherwise
+	# it will coredump.
+	PICFLAG='-fPIC -shared'
+	;;
+ 

Re: CFT: [build] Move libgcc_tm_file to toplevel libgcc

2011-08-15 Thread Paolo Bonzini

On 08/15/2011 10:30 AM, Rainer Orth wrote:

This patch almost completes the build side of the libgcc moves.  It
moves the libgcc_tm_file support to libgcc/config.host (tm_file), where
it belongs.  It builds on a patch Paolo posted some time ago, with some
minor corrections (introducing the required dependencies on the
generated libgcc_tm.h).  I've removed libgcc_tm.h from tm.h and include
the file directly in all libgcc sources that currently include tm.h.

Everything else is pretty mechanical, I believe.

Tested as described in the previous submissions.

Rainer


Ok.

Paolo


Re: RFC: [build, ada] Centralize PICFLAG configuration

2011-08-15 Thread Steve Ellcey
On Mon, 2011-08-15 at 19:53 +0200, Rainer Orth wrote:

> * For IA64 HP-UX, there's a claim that -fPIC is necessary despite PIC
>   code being the default.  I could find no hint in trunk that this is
>   true any longer.

Rainer,  If I recall correctly the issue for -fPIC on IA64 HP-UX is to
turn on flag_shlib.  If you don't use -fPIC, flag_shlib is not set and
function FOO in a shared library may get inlined into function BAR or
function BAR may generate a direct call to FOO that cannot be
overwritten by a definition of function FOO coming from outside the
shared library.  Setting flag_shlib should be the only difference
between using or not using -fPIC on IA64 HP-UX.

Steve Ellcey
s...@cup.hp.com



Re: Remove LINEMAP_POSITION_FOR_COLUMN macro (issue4874043)

2011-08-15 Thread Gabriel Charette
[+iant]

Ian: can you approve the go changes in this patch?

It's a change in the linemap that reflects in functions used by go,
but that shouldn't have any effect on the go compiler's behaviour.

As a side thought, I'm getting random failures in the go test suite,
in my last run the difference was that
go.go-torture/execute/select-1.go failed in the clean build test and
passed in the patched build...

Every full test run I do I get different sets of differences, I've had
identical runs too, I highly doubt this is due to my patch.

On Fri, Aug 12, 2011 at 11:27 AM, Tom Tromey  wrote:
>> "Gabriel" == Gabriel Charette  writes:
>
> Gabriel> Removed LINEMAP_POSITION_FOR_COLUMN, it did the EXACT same
> Gabriel> thing as linemap_position_for_column, so maintaining both in
> Gabriel> parallel seems like overkill to me. The only thing I can think
> Gabriel> of is that it's more optimal as it's inlined (but if that's
> Gabriel> really needed we can always make linemap_position_for_column an
> Gabriel> inline function directly).
>
> I am sympathetic to this, but nobody is likely to do the performance
> tests post-patch.
>
> The libcpp parts are ok if it doesn't cause a noticeable slowdown in the
> GCC bootstrap.
>

I just did performance test and the results were identical before and after.

> I can't approve the changes outside of libcpp.
> Also, you didn't write a ChangeLog entry for those.
>

Here is the ChangeLog including gcc/go changes, added iant to get
approval for the go changes:

2011-08-11  Gabriel Charette  

libcpp/ChangeLog
* include/line-map.h (LINEMAP_POSITION_FOR_COLUMN): Remove.
Update all users to use linemap_position_for_column instead.

gcc/go/ChangeLog
* gofrontend/lex.cc (Lex::location): Update to use
linemap_position_for_column instead.
(Lex::earlier_location): Likewise.


Thanks,
Gabriel


Re: RFC: [build, ada] Centralize PICFLAG configuration

2011-08-15 Thread Paolo Bonzini

On 08/15/2011 10:53 AM, Rainer Orth wrote:

* The general approach between libtool and libiberty differs.  Unless
   otherwise specified (PIC is the default or doesn't work for some
   reason), libtool defaults to -fPIC, while libiberty has a strange
   mixture of -fPIC/-fpic and nothing, without explanation and without a
   default.


I guess it's kind of historic, probably to produce smaller/faster code 
on PPC and SPARC which differentiate between -fPIC/-fpic.


In general I trust libtool more, but -fPIC/-fpic differences should be 
more or less harmless, and this:



* For SPARC, libiberty/configure.ac has

case "${CFLAGS}" in
*-fpic*)
PICFLAG=-fpic
;;
*)
PICFLAG=-fPIC
;;
esac ;;


actually makes some sense---so the general approach in your patch is 
good.  The patch is okay.



Yes, that needs to be done of course.  I'm not sure if we still support
gnatlib_and_tools to build libada/gnattools.  If so, we would need the
PICFLAG to be available somehow in the gcc Makefile (perhaps by providing
GCC_TARGET_PICFLAG in addition to GCC_PICFLAG in picflag.m4).


The only trace I could find is in a install.texi reference to historical
practice.


Yes, but it also matters whether AdaCore is using it.  If so, I'd like 
also to understand why.


Paolo


Re: CFT: [build] Move crtstuff support to toplevel libgcc

2011-08-15 Thread Hans-Peter Nilsson
> From: Rainer Orth 
> Date: Mon, 15 Aug 2011 19:01:39 +0200

> * Unlike any other target, cris has crisv32-*-none and cris-*-none
>   targets which seem to be aliases for their *-elf counterparts.  Do we
>   really need to keep those?  While I can inherit e.g. extra_parts from
>   *-*-elf, there's no such thing for *-*-none.

Feel absolutely free to remove them.  Otherwise fine at a glance.
Thanks for doing this boring work.

BTW, folding crti and crtn into the crtstuff rules had too many
exceptions?  Historically separated from the crtstuff (CRTIN)
rules, but it seems many targets compiled them the same way.
I'd guess the patch would have been a bit shorter.  Even more
boring work! :)

brgds, H-P


Re: CFT: [build] Move libgcc2 to toplevel libgcc

2011-08-15 Thread Hans-Peter Nilsson
> From: Rainer Orth 
> Date: Mon, 15 Aug 2011 19:19:23 +0200

> On top of the crtstuff and libgcc1 patches (and requiring the PICFLAG
> centralization still under discussion), here's the bulk of the remaining
> moves: it moves all LIBGCC2*, LIB2* macros and referenced files.
> 
> Despite its size, the patch should be quite straightforward.
> 
> * libgcc is slowly getting cluttered.  One may consider moving related
>   files to their own subdirectories.
> 
> * Again, I noticed an unused target file,
>   config/cris/cris_abi_symbol.c.  I assume it's a leftover from the
>   cris-aout port and can go.

As obvious from its contents, yes, put it to rest if you please.

> Tested as described in the previous submissions.


>   * config/cris/arit.c, config/cris/cris_abi_symbol.c: Move to
>   ../libgcc/config/cris.
>   * config/cris/cris.h: Remove obsolete comment.

Not so obsolete IMO.  Parentheses are still hard to pass through
shells :) though maybe there's just one layer now?
IIUC, this file *is* still included when building libgcc2?

>   * config/cris/mulsi3.asm: Move to ../libgcc/config/cris/mulsi3.S.
>   * config/cris/t-cris (LIB2FUNCS_EXTRA, CRIS_LIB1CSRC)
>   ($(LIB2FUNCS_EXTRA)): Remove.
>   * config/cris/t-elfmulti (LIB2FUNCS_STATIC_EXTRA, INSTALL_LIBGCC)
>   (LIBGCC): Remove.
>   * config/cris/t-linux (TARGET_LIBGCC2_CFLAGS): Remove.


> @@ -960,8 +952,6 @@ cris-*-elf | cris-*-none)
>   ;;
>  crisv32-*-linux* | cris-*-linux*)
>   tm_file="dbxelf.h elfos.h ${tm_file} gnu-user.h linux.h glibc-stdint.h 
> cris/linux.h"
> - # We need to avoid using t-linux, so override default tmake_file
> - tmake_file="cris/t-cris cris/t-linux t-slibgcc"
>   extra_options="${extra_options} cris/linux.opt"
>   case $target in
> cris-*-*)

Here there was an assignment, not append, to tmake_file.

> diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h
> --- a/gcc/config/cris/cris.h
> +++ b/gcc/config/cris/cris.h
> @@ -84,11 +84,7 @@ extern int cris_cpu_version;
>  /* Changing the order used to be necessary to put the fourth __make_dp
> argument (a DImode parameter) in registers, to fit with the libfunc
> parameter passing scheme used for intrinsic functions.  FIXME: Check
> -   performance and maybe remove definition from TARGET_LIBGCC2_CFLAGS now
> -   that it isn't strictly necessary.  We used to do this through
> -   TARGET_LIBGCC2_CFLAGS, but that became increasingly difficult as the
> -   parenthesis (that needed quoting) travels through several layers of
> -   make and shell invocations.  */
> +   performance.  */
>  #ifdef IN_LIBGCC2
>  #define __make_dp(a,b,c,d) __cris_make_dp(d,a,b,c)
>  #endif

...well, as long as cris.h is still included and it's truly
obsolete due to the libgcc move.


> diff --git a/libgcc/config.host b/libgcc/config.host

>  *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu* 
> | *-*-kopensolaris*-gnu)
> -  tmake_file="$tmake_file t-crtstuff-pic t-eh-dw2-dip t-slibgcc 
> t-slibgcc-gld t-slibgcc-elf-ver t-linux"
> +  tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc 
> t-slibgcc-gld t-slibgcc-elf-ver t-linux"
>extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"

Hm...

>  crisv32-*-elf)
> - tmake_file=t-fdpbit
> + tmake_file="cris/t-cris t-fdpbit"
>   ;;
>  crisv32-*-none)
> - tmake_file=t-fdpbit
> + tmake_file="cris/t-cris t-fdpbit"
>   extra_parts="crtbegin.o crtend.o"
>   ;;
>  cris-*-elf)
> - tmake_file="$tmake_file cris/t-elfmulti"
> + tmake_file="$tmake_file cris/t-cris cris/t-elfmulti"
>   ;;
>  cris-*-none)
> - tmake_file="$tmake_file cris/t-elfmulti"
> + tmake_file="$tmake_file cris/t-cris cris/t-elfmulti"
>   extra_parts="crtbegin.o crtend.o"
>   ;;
>  cris-*-linux* | crisv32-*-linux*)
> - tmake_file="$tmake_file t-fdpbit cris/t-linux"
> + tmake_file="$tmake_file cris/t-cris t-fdpbit cris/t-linux"
>   ;;

But here you append to tmake_file.  Is the new "generic" linux
tmake_file really safe?  What was I was trying to avoid... oh,
the "SHLIB_MAPFILES += $(srcdir)/config/libgcc-glibc.ver"?
Should have been safe all along; none of those symbols were
defined.  Anyway looks like I could need that config/t-linux
so... ok?  But why don't I see a libgcc/config/cris/t-linux at
r177764 so I can check?  It should be pre-existing before your
previous patch.  Is this on top of more than the previous two
patches?

Ok, I'm confused.  I want to wait until the other two patches
are committed, then look again.  (They are independent if
serialized, right?)

brgds, H-P


Re: Remove LINEMAP_POSITION_FOR_COLUMN macro (issue 4874043)

2011-08-15 Thread dnovillo

On 2011/08/15 18:05:51, Gabriel Charette wrote:


2011-08-11  Gabriel Charette  



 libcpp/ChangeLog
* include/line-map.h (LINEMAP_POSITION_FOR_COLUMN): Remove.
Update all users to use linemap_position_for_column instead.



 gcc/go/ChangeLog
* gofrontend/lex.cc (Lex::location): Update to use
linemap_position_for_column instead.
 (Lex::earlier_location): Likewise.


This is OK.  The changes to Go are just a side-effect of the other
changes and they are small enough that they should be easy to rollback.


Diego.

http://codereview.appspot.com/4874043/


Re: [PATCH 04/20] Document CLooG-ISL requirement for Graphite

2011-08-15 Thread Gerald Pfeifer
On Mon, 15 Aug 2011, Sebastian Pop wrote:
> 2011-07-26  Sebastian Pop  
> 
> * doc/invoke.texi: Document CLooG-ISL requirement for Graphite.

That looks like a nice simplification (where in my mind this has
been a bit of a mine field in the past).

This is approved once the code changes are in.

> +Necessary to build GCC with the Graphite loop optimizations.  It is
> +available from @uref{ftp://gcc.gnu.org/pub/gcc/infrastructure/} as
> +@file{cloog-0.16.3.tar.gz}.  Even if CLooG 0.16 does not use PPL, PPL
> +is still required for Graphite.

Where's the primary site?  I am a bit hesitant constantly using 
our own FTP server as the canonical reference.

Gerald


Re: [PATCH 11/20] document ISL requirement for GCC installation

2011-08-15 Thread Gerald Pfeifer
On Mon, 15 Aug 2011, Sebastian Pop wrote:
> ---
>  gcc/doc/install.texi |8 +++-
>  1 files changed, 7 insertions(+), 1 deletions(-)

This needs a ChangeLog entry.  With one, this is fine.

While you are at it...

> -If you do not have PPL (the Parma Polyhedra Library) and the CLooG
> +If you do not have ISL (the Integer Set Library),
> +PPL (the Parma Polyhedra Library), and the CLooG (the Chunky Loop Generator)
>  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}},

...can you make this

  installed via ... 

That is, omit the parenthesis and include the options as part of the
regular sentence.

Gerald


Announcing the Port of Intel(r) Cilk (TM) Plus into GCC

2011-08-15 Thread Iyer, Balaji V
Hello Everyone,
   This letter describes the recently created GCC branch called "cilkplus" that 
ports the Intel(R) Cilk(TM) Plus language extensions to the C and C++ 
front-ends of gcc-4.7. We are looking for collaborators and advice as we 
proceed - both on this open-source gcc project, and on the open language 
specification. The compiler and its associated runtime are available at:  
http://gcc.gnu.org/svn/gcc/branches/cilkplus . The URL for the patch is 
available at: http://software.intel.com/file/38093 .

   Intel Cilk Plus is a set of C and C++ constructs for task-parallel and 
data-parallel programming for improving performance on multicore and vector 
processors. This language extension includes the following features:

1.  Three keywords provide a simple yet powerful model for parallel 
programming: _Cilk_spawn, _Cilk_sync and _Cilk_for. Reducers provide an easy, 
lock-free way to deal with shared data.

2.  Simple array notations including elemental functions allow programmers 
to easily use data-parallelism.

3.  Pragmas communicate SIMD information to the vectorizer to help ensure 
that loops are vectorized correctly.

   The implementation of Intel Cilk Plus language extensions to gcc requires 
the above patches to the C and C++ front-ends, plus a copy of the Intel Cilk 
Plus runtime library (Cilk Plus RTL).  Both of these have been checked into the 
new gcc branch.  The Cilk Plus RTL is being maintained by using an upstream, 
BSD-licensed version available at http://www.cilkplus.org .  Changes to the 
Cilk Plus RTL are welcome and must be contributed to the upstream version via 
this web site.  A contribution process is in place for receiving such changes; 
see http://www.cilkplus.org for details.

   In this release, the C and C++ compiler parsers now accept the three 
keywords _Cilk_spawn, _Cilk_sync, and _Cilk_for, as well as a pragma to adjust 
the grainsize of _Cilk_for. The list below provides a brief explanation of each 
of the keywords. For more details, see the "Intel(r) Cilk(tm) Plus Language 
Specification" at http://www.cilkplus.org .

1.  _Cilk_spawn - Annotates a function-call and indicates that execution 
may (but is not required to) continue without waiting for the function to 
return. The syntax is:
[   = ] _Cilk_spawn  ( 
(optional)) ;

2.  _Cilk_sync - Indicates that all the statements in the current Cilk 
block must finish executing before any statements after the _Cilk_sync begin 
executing. The syntax is:
_Cilk_sync ;

3.  _Cilk_for - Is a variant of a for-statement where any or all iterations 
may (but are not required to) execute in parallel. You can optionally precede 
_Cilk_for with a grainsize-pragma to specify the number of serial iterations 
desired for each chunk of the parallel loop. If there is no grainsize pragma or 
if the grainsize evaluates to '0', then the runtime will pick a grainsize using 
its own internal heuristics. The syntax:
[ #pragma cilk grainsize =  ] _Cilk_for ( ; 
 ; )
 

   The parser will accept these keywords and insert the appropriate functions 
to interact with the runtime library. Along with these keywords, you can use 
#pragma simd directives to communicate loop information to the vectorizer so it 
can generate better vectorized code. The five #pragma simd directives are: 
vectorlength, private, linear, reduction, and assert. The list below summarizes 
the five directives. For a detailed explanation please refer to the "Intel(r) 
Cilk(tm) Plus Language Specification" at http://www.cilkplus.org .

1)  #pragma simd vectorlength (n1, n2 ...): Specify a choice vector width 
that the back-end may use to vectorize the loop.

2)  #pragma simd private (var1, var2, ...): Specify a set of variables for 
which each loop iteration is independent of each other iterations.

3)  #pragma simd linear (var1:stride1, var2:stride2, ...): Specify a set of 
variables that increase monotonically in each iteration of the loop.

4)  #pragma simd reduction (operator: var1, var2...): Specify a set of 
variables whose value is computed by vector reduction using the specified 
operator.

5)  #pragma simd assert: Directs the compiler to halt if the vectorizer is 
unable to vectorize the loop.

   The current implementation of the runtime library has been tested on x86 
(both 32 and 64 bit) architectures. In theory, the runtime library should not 
be too difficult for you to port to other architectures. However, be aware that 
access to shared variables currently assumes sequential consistency, so 
architectures that use a different memory model may require you to insert 
additional memory barriers.

   These language extensions provide a simple, well-structured, and powerful 
model for parallel programming. Intel hopes that you will find these extensions 
to be a useful and significant enhancement to the GCC C and C++ compiler. In 
this initial release, the array notations and elemental functions present in 
the full Int

Re: Remove LINEMAP_POSITION_FOR_COLUMN macro (issue4874043)

2011-08-15 Thread Ian Lance Taylor
Gabriel Charette  writes:

> Ian: can you approve the go changes in this patch?

The changes to the Go frontend are fine, but they need to be applied to
the master repository for the Go frontend.  I can take care of that when
you are ready to commit the patch.  Note that changes to the files in
gcc/go/gofrontend do not get ChangeLog entries.


> As a side thought, I'm getting random failures in the go test suite,
> in my last run the difference was that
> go.go-torture/execute/select-1.go failed in the clean build test and
> passed in the patched build...
>
> Every full test run I do I get different sets of differences, I've had
> identical runs too, I highly doubt this is due to my patch.

I'm sure it has nothing to do with your patch.  I have not seen other
people report this, though.  Some of the tests in the Go testsuite use a
lot of threads, like thousands.  It's possible that that is running into
some limit on your machine.  This would be particularly applicable if
you are running the testsuite with make -j.

Ian


Re: CFT: [build] Move libgcc2 to toplevel libgcc

2011-08-15 Thread Joseph S. Myers
On Mon, 15 Aug 2011, Rainer Orth wrote:

> On top of the crtstuff and libgcc1 patches (and requiring the PICFLAG
> centralization still under discussion), here's the bulk of the remaining
> moves: it moves all LIBGCC2*, LIB2* macros and referenced files.
> 
> Despite its size, the patch should be quite straightforward.
> 
> * libgcc is slowly getting cluttered.  One may consider moving related
>   files to their own subdirectories.

FWIW, I think libgcc2.c could do with being split up into separate files 
for the separate functions (if not one file per function, at least rather 
more than at present) rather than compiling the same source file so many 
times with different defines.  That would of course clutter things even 
more; I think any such split would need to put all those files in a 
subdirectory.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: Remove LINEMAP_POSITION_FOR_COLUMN macro (issue4874043)

2011-08-15 Thread Gabriel Charette
On Mon, Aug 15, 2011 at 1:39 PM, Ian Lance Taylor  wrote:
> Gabriel Charette  writes:
>
>> Ian: can you approve the go changes in this patch?
>
> The changes to the Go frontend are fine, but they need to be applied to
> the master repository for the Go frontend.  I can take care of that when
> you are ready to commit the patch.  Note that changes to the files in
> gcc/go/gofrontend do not get ChangeLog entries.
>

The patch has been committed to trunk.

I did also provide a ChangeLog for the gcc/go/gofrontend change, want
me to remove it?

>
>> As a side thought, I'm getting random failures in the go test suite,
>> in my last run the difference was that
>> go.go-torture/execute/select-1.go failed in the clean build test and
>> passed in the patched build...
>>
>> Every full test run I do I get different sets of differences, I've had
>> identical runs too, I highly doubt this is due to my patch.
>
> I'm sure it has nothing to do with your patch.  I have not seen other
> people report this, though.  Some of the tests in the Go testsuite use a
> lot of threads, like thousands.  It's possible that that is running into
> some limit on your machine.  This would be particularly applicable if
> you are running the testsuite with make -j.
>

Ok (and yes I am using make -j)

Gabriel


Re: CFT: [build] Move libgcc_tm_file to toplevel libgcc

2011-08-15 Thread Joseph S. Myers
On Mon, 15 Aug 2011, Rainer Orth wrote:

> This patch almost completes the build side of the libgcc moves.  It
> moves the libgcc_tm_file support to libgcc/config.host (tm_file), where
> it belongs.  It builds on a patch Paolo posted some time ago, with some
> minor corrections (introducing the required dependencies on the
> generated libgcc_tm.h).  I've removed libgcc_tm.h from tm.h and include
> the file directly in all libgcc sources that currently include tm.h.

What about the Ada files that get built for both the host and the target 
(or maybe just for the target in some cases) and include tm.h?  Might not 
some of them require macros that will end up being moved to libgcc_tm.h?  
What about libobjc files?  I think the target macros in those files need 
checking to make sure that libgcc_tm.h won't be the right solution for 
them, or else it should be included in those files when built for the 
target.

-- 
Joseph S. Myers
jos...@codesourcery.com


[pph] Forwarding trunk linemap changes (issue4898050)

2011-08-15 Thread Gabriel Charette
Forwarding this patch to pph (which was just committed to trunk in 
issue4874043).

Committed to pph branch.

2011-08-11  Gabriel Charette  

libcpp/ChangeLog
* include/line-map.h (LINEMAP_POSITION_FOR_COLUMN): Remove.
Update all users to use linemap_position_for_column instead.

gcc/go/ChangeLog
* gofrontend/lex.cc (Lex::location): Update to use
linemap_position_for_column instead.
(Lex::earlier_location): Likewise.

diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc
index 9f26911..167c7dd 100644
--- a/gcc/go/gofrontend/lex.cc
+++ b/gcc/go/gofrontend/lex.cc
@@ -518,9 +518,7 @@ Lex::require_line()
 source_location
 Lex::location() const
 {
-  source_location location;
-  LINEMAP_POSITION_FOR_COLUMN(location, line_table, this->lineoff_ + 1);
-  return location;
+  return linemap_position_for_column (line_table, this->lineoff_ + 1);
 }
 
 // Get a location slightly before the current one.  This is used for
@@ -529,9 +527,7 @@ Lex::location() const
 source_location
 Lex::earlier_location(int chars) const
 {
-  source_location location;
-  LINEMAP_POSITION_FOR_COLUMN(location, line_table, this->lineoff_ + 1 - 
chars);
-  return location;
+  return linemap_position_for_column (line_table, this->lineoff_ + 1 - chars);
 }
 
 // Get the next token.
diff --git a/libcpp/directives-only.c b/libcpp/directives-only.c
index e19f806..c6772af 100644
--- a/libcpp/directives-only.c
+++ b/libcpp/directives-only.c
@@ -142,7 +142,7 @@ _cpp_preprocess_dir_only (cpp_reader *pfile,
flags |= DO_LINE_COMMENT;
  else if (!(flags & DO_SPECIAL))
/* Mark the position for possible error reporting. */
-   LINEMAP_POSITION_FOR_COLUMN (loc, pfile->line_table, col);
+   loc = linemap_position_for_column (pfile->line_table, col);
 
  break;
 
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index f1d5bee..3c84035 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -165,23 +165,6 @@ extern const struct line_map *linemap_lookup
 /* Nonzero if the map is at the bottom of the include stack.  */
 #define MAIN_FILE_P(MAP) ((MAP)->included_from < 0)
 
-/* Set LOC to a source position that is the same line as the most recent
-   linemap_line_start, but with the specified TO_COLUMN column number.  */
-
-#define LINEMAP_POSITION_FOR_COLUMN(LOC, SET, TO_COLUMN) do { \
-  unsigned int to_column = (TO_COLUMN); \
-  struct line_maps *set = (SET); \
-  if (__builtin_expect (to_column >= set->max_column_hint, 0)) \
-(LOC) = linemap_position_for_column (set, to_column); \
-  else { \
-source_location r = set->highest_line; \
-r = r + to_column; \
-if (r >= set->highest_location) \
-  set->highest_location = r; \
-(LOC) = r;  \
-  }} while (0)
-
-
 extern source_location
 linemap_position_for_column (struct line_maps *set, unsigned int to_column);
 
diff --git a/libcpp/lex.c b/libcpp/lex.c
index d29f36d..d460b98 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -1975,8 +1975,8 @@ _cpp_lex_direct (cpp_reader *pfile)
 }
   c = *buffer->cur++;
 
-  LINEMAP_POSITION_FOR_COLUMN (result->src_loc, pfile->line_table,
-  CPP_BUF_COLUMN (buffer, buffer->cur));
+  result->src_loc = linemap_position_for_column (pfile->line_table,
+   CPP_BUF_COLUMN 
(buffer, buffer->cur));
 
   switch (c)
 {

--
This patch is available for review at http://codereview.appspot.com/4898050


Re: CFT: [build] Move libgcc_tm_file to toplevel libgcc

2011-08-15 Thread Paolo Bonzini

On 08/15/2011 02:05 PM, Joseph S. Myers wrote:

>  This patch almost completes the build side of the libgcc moves.  It
>  moves the libgcc_tm_file support to libgcc/config.host (tm_file), where
>  it belongs.  It builds on a patch Paolo posted some time ago, with some
>  minor corrections (introducing the required dependencies on the
>  generated libgcc_tm.h).  I've removed libgcc_tm.h from tm.h and include
>  the file directly in all libgcc sources that currently include tm.h.

What about the Ada files that get built for both the host and the target
(or maybe just for the target in some cases) and include tm.h?  Might not
some of them require macros that will end up being moved to libgcc_tm.h?
What about libobjc files?  I think the target macros in those files need
checking to make sure that libgcc_tm.h won't be the right solution for
them, or else it should be included in those files when built for the
target.


Right. :(  Rainer, please hold the patch.

Paolo


PATCH: PR testsuite/50085: [4.7 Regression] FAIL: g++.dg/opt/life1.C scan-assembler GLOBAL_OFFSET_TABLE on x86_64-apple-darwin10

2011-08-15 Thread H.J. Lu
Hi,

g++.dg/opt/life1.C is supposed to be run only on Linux.  I checked in
this patch as an obvious fix.

Thanks.


H.J.
---
Index: ChangeLog
===
--- ChangeLog   (revision 11)
+++ ChangeLog   (working copy)
@@ -1,3 +1,8 @@
+2011-08-15  H.J. Lu  
+
+   PR testsuite/50085
+   * g++.dg/opt/life1.C: Only run on Linux.
+
 2011-08-15  Tobias Burnus  
 
* gfortran.dg/coarray_26.f90: New.
Index: g++.dg/opt/life1.C
===
--- g++.dg/opt/life1.C  (revision 11)
+++ g++.dg/opt/life1.C  (working copy)
@@ -1,6 +1,6 @@
 // This testcase did not set up the pic register on IA-32 due
 // to bug in calculate_global_regs_live EH edge handling.
-// { dg-do compile { target { { i?86-*-* x86_64-*-* } && ia32 } } }
+// { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ia32 } } }
 // { dg-require-effective-target fpic }
 // { dg-options "-O2 -fPIC" }
 


Re: [Patch, Fortran] Coarrays: Add/fix check for no coarrays as result value

2011-08-15 Thread H.J. Lu
On Thu, Aug 4, 2011 at 8:00 AM, Tobias Burnus  wrote:
> This patch fixes the result check for coarrays / variables with coarray
> subcomponents. It was working with a separate RESULT() variable - but not if
> the function name was the result variable.
>
> Build and regtested on x86-64-linux.
> OK for the trunk?

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50094

-- 
H.J.


Re: [PATCH, SMS] Support instructions with REG_INC_NOTE (re-submisson)

2011-08-15 Thread Ayal Zaks
Ok, so this extends the infrastructure to support insns which set an
arbitrary number of registers, but currently specifically handles only
REG_INC situations (which set two registers). I'm not against
{0,1,infinity}, but wonder if this case really deserves the
complexity: post/pre-inc/decrementing load insns may need regmoves for
the register loaded, due to the latency of the load and desire to
schedule associated uses farther than ii cycles away (as do regular
loads), but do they also need regmoves for the address register being
post/pre-inc/decremented? Its latency should not be long, and it's
often feeding only itself so regmoves are not needed/won't help. If
not, perhaps a simpler solution is to allow REG_INC insns but disallow
their address register from being regmove'd, dedicating the single
regmove info for the value loaded.

Are there actually cases where you need the address register to regmove?

Ayal.

2011/8/15 Revital Eres 
>
> Hello,
>
> This is a re-submission of the patch to support instructions with 
> REG_INC_NOTE.
> (http://gcc.gnu.org/ml/gcc-patches/2011-04/msg01309.html)
>
> It contains a minor change from the previous submission suggested by
> Richard Sandiford: to use reg_referenced_p instead of
> rtx_referenced_p.
>
> The patch supports instructions with auto inc/dec operations as to
> support such instructions we can not assume that there is only one
> definition in the instruction. This assumption is currently used to
> generate reg-moves information. Because the auto inc/dec instruction
> defines more then one register we need to generate different reg-moves
> for each of the definitions. At some point in the SMS procedure we
> need to find
> the first reg-move generated for a specific definition(*) and if there
> is more than one definition in the instruction (lets call it insn1)
> we can not simply assume it's first reg-move instruction is the first
> instruction right before insn1.
>
> for example, the following instruction defines two variables: x and i:
> x = mem [POST_INC (i)]
>
> lets say both of them need reg-move
>
> insn 1) reg_move_i = i
> insn 2) reg_move_x = x
> insn 3) x = mem [POST_INC (i)]
>
> then in order to reach the first reg-move of i we can not just go to
> insn 2 like in the current implementation, so we need to save for each
> definition in the instruction it's first reg-move instruction.
>
> (*) I'm referring to the generation of prologue and epilogue
> (duplicate_insns_of_cycles) which uses first_reg_move field in
> node_sched_params structure, and SCHED_FIRST_REG_MOVE definition in
> modulo-sched.c.
>
> Reg-tested and bootstrap on ppc64-redhat-linux enabling SMS on loops with SC 
> 1.
>
> OK for mainline?
>
> Thanks,
> Revital
>
>
>        * modulo-sched.c (record_inc_dec_insn_info,
>        free_node_sched_params): New functions.
>        (SCHED_FIRST_REG_MOVE, SCHED_NREG_MOVES): Remove.
>        (struct regmove_info): New.
>        (insn_regmove_info): New field in node_sched_params.
>        (print_node_sched_params): Print information for all the
>        definitions in the instructions.
>        (generate_reg_moves, duplicate_insns_of_cycles,
>        set_node_sched_params): Adjust the code to handle instructions
>        that have multiple definitions.
>        (sms_schedule): Handle loops that contain instructions with
>        FIND_REG_INC_NOTE and call free_node_sched_params.


Linemap force location and remove LINEMAP_POSITION_FOR_COLUMN (issue4801090)

2011-08-15 Thread Gabriel Charette
Here is the updated patch.

It nows exposes two libcpp functions to force the source_location for tokens 
when desired.

The lexer then checks for a value set by these functions in cpp_reader and acts 
accordingly when needing a location for a new token (either using the 
forced_location or calling the linemap as it used to).

It turns out the fortran library made the same mistake of creating a line_table 
entry for builtins, I fixed it as well in this patch.

Tested on x64 for c++,fortran.

(fyi: I moved the removal of LINEMAP_POSITION_FOR_COLUMN to a separate patch 
which is checked-in already; thus it doesn't show up in this updated patch 
obviously.
)

Ok for trunk?

Gabriel

2011-08-15  Gabriel Charette  

gcc/c-family/ChangeLog
* c-opts.c (c_finish_options): Force BUILTINS_LOCATION for tokens
defined in cpp_init_builtins and c_cpp_builtins.

gcc/fortran/ChangeLog
* cpp.c (gfc_cpp_init): Force BUILTINS_LOCATION for tokens
defined in cpp_define_builtins.

libcpp/ChangeLog
* init.c (cpp_create_reader): Inititalize forced_token_location_p.
* internal.h (struct cpp_reader): Add field forced_token_location_p.
* lex.c (_cpp_lex_direct): Use forced_token_location_p.
(cpp_force_token_locations): New.
(cpp_stop_forcing_token_locations): New.

diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 3227f7b..49ff80d 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -1306,12 +1306,17 @@ c_finish_options (void)
 {
   size_t i;
 
-  cb_file_change (parse_in,
- linemap_add (line_table, LC_RENAME, 0,
-  _(""), 0));
+  {
+   /* Make sure all of the builtins about to be declared have
+ BUILTINS_LOCATION has their source_location.  */
+   source_location builtins_loc = BUILTINS_LOCATION;
+   cpp_force_token_locations (parse_in, &builtins_loc);
 
-  cpp_init_builtins (parse_in, flag_hosted);
-  c_cpp_builtins (parse_in);
+   cpp_init_builtins (parse_in, flag_hosted);
+   c_cpp_builtins (parse_in);
+
+   cpp_stop_forcing_token_locations (parse_in);
+  }
 
   /* We're about to send user input to cpplib, so make it warn for
 things that we previously (when we sent it internal definitions)
diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c
index a40442e..9368d89 100644
--- a/gcc/fortran/cpp.c
+++ b/gcc/fortran/cpp.c
@@ -565,9 +565,17 @@ gfc_cpp_init (void)
   if (gfc_option.flag_preprocessed)
 return;
 
-  cpp_change_file (cpp_in, LC_RENAME, _(""));
   if (!gfc_cpp_option.no_predefined)
-cpp_define_builtins (cpp_in);
+{
+  /* Make sure all of the builtins about to be declared have
+   BUILTINS_LOCATION has their source_location.  */
+  source_location builtins_loc = BUILTINS_LOCATION;
+  cpp_force_token_locations (cpp_in, &builtins_loc);
+
+  cpp_define_builtins (cpp_in);
+
+  cpp_stop_forcing_token_locations (cpp_in);
+}
 
   /* Handle deferred options from command-line.  */
   cpp_change_file (cpp_in, LC_RENAME, _(""));
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 55b0f1b..6ad0345 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -985,4 +985,8 @@ extern void cpp_prepare_state (cpp_reader *, struct 
save_macro_data **);
 extern int cpp_read_state (cpp_reader *, const char *, FILE *,
   struct save_macro_data *);
 
+/* In lex.c */
+extern void cpp_force_token_locations (cpp_reader *, source_location *);
+extern void cpp_stop_forcing_token_locations (cpp_reader *);
+
 #endif /* ! LIBCPP_CPPLIB_H */
diff --git a/libcpp/init.c b/libcpp/init.c
index 5ba..b3d4c8c 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -221,6 +221,9 @@ cpp_create_reader (enum c_lang lang, hash_table *table,
   /* Initialize table for push_macro/pop_macro.  */
   pfile->pushed_macros = 0;
 
+  /* Do not force token locations by default.  */
+  pfile->forced_token_location_p = NULL;
+
   /* The expression parser stack.  */
   _cpp_expand_op_stack (pfile);
 
diff --git a/libcpp/internal.h b/libcpp/internal.h
index d2872c4..6c423f0 100644
--- a/libcpp/internal.h
+++ b/libcpp/internal.h
@@ -499,6 +499,10 @@ struct cpp_reader
 
   /* List of saved macros by push_macro.  */
   struct def_pragma_macro *pushed_macros;
+
+  /* If non-null, the lexer will use this location for the next token
+ instead of getting a location from the linemap.  */
+  source_location *forced_token_location_p;
 };
 
 /* Character classes.  Based on the more primitive macros in safe-ctype.h.
diff --git a/libcpp/lex.c b/libcpp/lex.c
index d460b98..244b14d 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -1975,8 +1975,11 @@ _cpp_lex_direct (cpp_reader *pfile)
 }
   c = *buffer->cur++;
 
-  result->src_loc = linemap_position_for_column (pfile->line_table,
-   CPP_BUF_COLUMN 
(b

[pph] Support for references to symbols in other PPH images (issue4873051)

2011-08-15 Thread Diego Novillo
This patch finishes the support for external references to symbols in
other PPH files.

This is used when one PPH image includes another.  The symbols in
the included image should not be emitted from the parent, and references
to them should go to the correct location in the child's pickle cache.

The main change is the addition of two kinds of references.  We used
to mark references to already pickled nodes with PPH_RECORD_SHARED.
We now distinguish internal (PPH_RECORD_IREF) and external
(PPH_RECORD_XREF) references.

In the first variant, only one index is written as reference: the slot
into the pickle cache.  In the second variant, two indices are
written: an index into the include table specifying which child image
contains the data, and an index into the child's pickle cache.

When writing PPH images, we also need to make sure that we do not
write any symbols in the file bindings that belong to included images.
Otherwise, we will emit the same symbol twice.  This is implemented by
a new filter PPHF_NO_XREFS, which is used when writing the current
image's global bindings.

Tested on x86_64.  Committed to branch.


Diego.


cp/ChangeLog.pph
* name-lookup.c (pph_out_binding_table): Call
pph_out_record_marker instead of pph_out_uchar.
(pph_in_binding_table): Call pph_in_record_marker instead of
pph_in_uchar.
* pph-streamer-in.c (pph_read_images): Declare.
(pph_is_reference_marker): New.  Update all previous users of
PPH_RECORD_SHARED.
(pph_in_start_record): Add argument INCLUDE_IX.  Update all
users.
Handle PPH_RECORD_XREF markers.
(pph_in_includes): After reading INCLUDE_NAME, call
pph_add_include.
(pph_read_file_contents): Move debugging output from ...
(pph_read_file): ... here.
Change it to return the opened stream.
Add STREAM to pph_read_images.
(pph_reader_finish): New.
(pph_read_file_1): Rename from pph_read_file_contents.  Update
all users.
* pph-streamer-out.c (pph_out_start_record): Re-write to
handle PPH_RECORD_IREF and PPH_RECORD_XREF.
(pph_write_file_contents): Embed ...
(pph_write_file): ... here.
(pph_add_include): Add new argument INCLUDE.  Update all
users.
(pph_writer_finish): Do nothing if pph_out_stream is NULL.
(pph_tree_matches): New.
(pph_out_tree_vec_filtered): New.
(pph_out_binding_level): Add new argument FILTER.  Update all users.
* pph-streamer.c (pph_stream_close_1): Embed ...
(pph_stream_close): ... here.
Do not traverse the list of includes.
(pph_cache_lookup): Factor out of ...
(pph_cache_add): ... here.
(pph_cache_lookup_in_includes): New.
(pph_cache_get): Add new argument INCLUDE_IX.  Update all users.
* pph-streamer.h (enum pph_record_marker): Add PPH_RECORD_IREF
and PPH_RECORD_XREF.  Remove PPH_RECORD_SHARED.  Update all users.
(struct pph_stream): Remove field open_p and nested_p.  Update
all users.
(enum chain_filter): Remove.  Change values to #define constants.
Update all users.
(PPHF_NO_XREFS): Define.
(pph_out_record_marker): New.
(pph_in_record_marker): New.
* pph.c (pph_finish): Always call pph_writer_finish.
Call pph_reader_finish.

testsuite/ChangeLog.pph
* g++.dg/pph/x1tmplclass2.cc: Update expected ICE.
* g++.dg/pph/x4tmplclass2.cc: Update expected ICE.
* g++.dg/pph/z4tmplclass2.cc: Update expected ICE.

diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 50c6b66..7798f24 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -6002,12 +6002,12 @@ pph_out_binding_table (pph_stream *stream, 
binding_table bt)
 {
   if (bt->chain[i])
{
- pph_out_uchar (stream, PPH_RECORD_START);
+ pph_out_record_marker (stream, PPH_RECORD_START);
  pph_out_tree_or_ref (stream, bt->chain[i]->name);
  pph_out_tree_or_ref (stream, bt->chain[i]->type);
}
   else
-   pph_out_uchar (stream, PPH_RECORD_END);
+   pph_out_record_marker (stream, PPH_RECORD_END);
 }
   pph_out_uint (stream, bt->entry_count);
 }
@@ -6025,13 +6025,15 @@ pph_in_binding_table (pph_stream *stream)
   bt = binding_table_new (chain_count);
   for (i = 0; i < chain_count; i++)
 {
-  unsigned char record_marker = pph_in_uchar (stream);
-  if (record_marker == PPH_RECORD_START)
+  enum pph_record_marker marker = pph_in_record_marker (stream);
+  if (marker == PPH_RECORD_START)
{
  tree name = pph_in_tree (stream);
  tree type = pph_in_tree (stream);
  binding_table_insert (bt, name, type);
}
+  else
+   gcc_assert (marker == PPH_RECORD_END);
 }
   bt->entry_count = pph_in_uint (stream);
 
diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index e6

Re: Remove LINEMAP_POSITION_FOR_COLUMN macro (issue4874043)

2011-08-15 Thread Ian Lance Taylor
Gabriel Charette  writes:

> On Mon, Aug 15, 2011 at 1:39 PM, Ian Lance Taylor  wrote:
>> Gabriel Charette  writes:
>>
>>> Ian: can you approve the go changes in this patch?
>>
>> The changes to the Go frontend are fine, but they need to be applied to
>> the master repository for the Go frontend.  I can take care of that when
>> you are ready to commit the patch.  Note that changes to the files in
>> gcc/go/gofrontend do not get ChangeLog entries.
>>
>
> The patch has been committed to trunk.

I committed the patch to the master repository.

> I did also provide a ChangeLog for the gcc/go/gofrontend change, want
> me to remove it?

I took care of it.

Thanks for updating the frontend.

Ian