[polly] r295419 - Updated isl to isl-0.18-254-g6bc184d

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 21:11:18 PST 2017


Author: grosser
Date: Thu Feb 16 23:11:16 2017
New Revision: 295419

URL: http://llvm.org/viewvc/llvm-project?rev=295419&view=rev
Log:
Updated isl to isl-0.18-254-g6bc184d

This update includes a couple more coalescing changes as well as a large
number of isl-internal code cleanups (dead assigments, ...).

Added:
    polly/trunk/lib/External/isl/m4/ax_detect_clang.m4
    polly/trunk/lib/External/isl/test_inputs/codegen/jacobi_kernel4.c
    polly/trunk/lib/External/isl/test_inputs/codegen/jacobi_kernel4.in
Modified:
    polly/trunk/lib/External/isl/GIT_HEAD_ID
    polly/trunk/lib/External/isl/Makefile.in
    polly/trunk/lib/External/isl/aclocal.m4
    polly/trunk/lib/External/isl/bound.c
    polly/trunk/lib/External/isl/configure
    polly/trunk/lib/External/isl/configure.ac
    polly/trunk/lib/External/isl/doc/Makefile.in
    polly/trunk/lib/External/isl/doc/user.pod
    polly/trunk/lib/External/isl/include/isl/aff.h
    polly/trunk/lib/External/isl/include/isl/constraint.h
    polly/trunk/lib/External/isl/include/isl/deprecated/aff_int.h
    polly/trunk/lib/External/isl/include/isl/deprecated/map_int.h
    polly/trunk/lib/External/isl/include/isl/deprecated/set_int.h
    polly/trunk/lib/External/isl/include/isl/map.h
    polly/trunk/lib/External/isl/include/isl/mat.h
    polly/trunk/lib/External/isl/include/isl/multi.h
    polly/trunk/lib/External/isl/include/isl/polynomial.h
    polly/trunk/lib/External/isl/include/isl/set.h
    polly/trunk/lib/External/isl/include/isl/union_map.h
    polly/trunk/lib/External/isl/include/isl/union_set.h
    polly/trunk/lib/External/isl/isl_aff.c
    polly/trunk/lib/External/isl/isl_aff_private.h
    polly/trunk/lib/External/isl/isl_ast_build.c
    polly/trunk/lib/External/isl/isl_bernstein.c
    polly/trunk/lib/External/isl/isl_bernstein.h
    polly/trunk/lib/External/isl/isl_bound.c
    polly/trunk/lib/External/isl/isl_coalesce.c
    polly/trunk/lib/External/isl/isl_config.h.in
    polly/trunk/lib/External/isl/isl_constraint.c
    polly/trunk/lib/External/isl/isl_convex_hull.c
    polly/trunk/lib/External/isl/isl_equalities.c
    polly/trunk/lib/External/isl/isl_factorization.h
    polly/trunk/lib/External/isl/isl_farkas.c
    polly/trunk/lib/External/isl/isl_fold.c
    polly/trunk/lib/External/isl/isl_ilp.c
    polly/trunk/lib/External/isl/isl_input.c
    polly/trunk/lib/External/isl/isl_local_space.c
    polly/trunk/lib/External/isl/isl_local_space_private.h
    polly/trunk/lib/External/isl/isl_map.c
    polly/trunk/lib/External/isl/isl_map_private.h
    polly/trunk/lib/External/isl/isl_map_simplify.c
    polly/trunk/lib/External/isl/isl_map_subtract.c
    polly/trunk/lib/External/isl/isl_mat.c
    polly/trunk/lib/External/isl/isl_multi_templ.c
    polly/trunk/lib/External/isl/isl_output.c
    polly/trunk/lib/External/isl/isl_point.c
    polly/trunk/lib/External/isl/isl_polynomial.c
    polly/trunk/lib/External/isl/isl_pw_templ.c
    polly/trunk/lib/External/isl/isl_range.c
    polly/trunk/lib/External/isl/isl_range.h
    polly/trunk/lib/External/isl/isl_scan.c
    polly/trunk/lib/External/isl/isl_scan.h
    polly/trunk/lib/External/isl/isl_schedule_band.c
    polly/trunk/lib/External/isl/isl_schedule_node.c
    polly/trunk/lib/External/isl/isl_schedule_read.c
    polly/trunk/lib/External/isl/isl_schedule_tree.c
    polly/trunk/lib/External/isl/isl_scheduler.c
    polly/trunk/lib/External/isl/isl_space.c
    polly/trunk/lib/External/isl/isl_space_private.h
    polly/trunk/lib/External/isl/isl_tab.c
    polly/trunk/lib/External/isl/isl_tab.h
    polly/trunk/lib/External/isl/isl_tab_lexopt_templ.c
    polly/trunk/lib/External/isl/isl_tab_pip.c
    polly/trunk/lib/External/isl/isl_test.c
    polly/trunk/lib/External/isl/isl_transitive_closure.c
    polly/trunk/lib/External/isl/isl_union_map.c
    polly/trunk/lib/External/isl/isl_union_templ.c
    polly/trunk/lib/External/isl/isl_val.c
    polly/trunk/lib/External/isl/isl_val_private.h
    polly/trunk/lib/External/isl/isl_vec.c
    polly/trunk/lib/External/isl/isl_vertices.c
    polly/trunk/lib/External/isl/isl_vertices_private.h
    polly/trunk/lib/External/isl/test_inputs/codegen/cloog/faber.c
    polly/trunk/lib/External/isl/test_inputs/codegen/cloog/jacobi-shared.c
    polly/trunk/lib/External/isl/test_inputs/codegen/cloog/levenshtein-1-2-3.c
    polly/trunk/lib/External/isl/test_inputs/codegen/cloog/reservoir-cholesky2.c
    polly/trunk/lib/External/isl/test_inputs/codegen/cloog/reservoir-pingali1.c
    polly/trunk/lib/External/isl/test_inputs/codegen/cloog/walters.c
    polly/trunk/lib/External/isl/test_inputs/codegen/isolate5.c
    polly/trunk/lib/External/isl/test_inputs/codegen/omega/guard1-0.c
    polly/trunk/lib/External/isl/test_inputs/codegen/omega/guard1-1.c
    polly/trunk/lib/External/isl/test_inputs/codegen/omega/m7-1.c
    polly/trunk/lib/External/isl/test_inputs/codegen/omega/m8-1.c
    polly/trunk/lib/External/isl/test_inputs/codegen/omega/p.delft2-0.c
    polly/trunk/lib/External/isl/test_inputs/codegen/redundant.c
    polly/trunk/lib/External/isl/test_inputs/codegen/sor1d-part.c
    polly/trunk/lib/External/isl/test_inputs/codegen/stride5.c
    polly/trunk/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_4.ll
    polly/trunk/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_5.ll
    polly/trunk/test/Isl/CodeGen/if-conditions-in-vector-code.ll
    polly/trunk/test/ScopInfo/modulo_zext_1.ll
    polly/trunk/test/ScopInfo/modulo_zext_2.ll
    polly/trunk/test/ScopInfo/multidim_fortran_srem.ll
    polly/trunk/test/ScopInfo/multidim_srem.ll
    polly/trunk/test/ScopInfo/switch-1.ll
    polly/trunk/test/ScopInfo/switch-2.ll
    polly/trunk/test/ScopInfo/switch-3.ll
    polly/trunk/test/ScopInfo/switch-4.ll

Modified: polly/trunk/lib/External/isl/GIT_HEAD_ID
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/GIT_HEAD_ID?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/GIT_HEAD_ID (original)
+++ polly/trunk/lib/External/isl/GIT_HEAD_ID Thu Feb 16 23:11:16 2017
@@ -1 +1 @@
-isl-0.18-43-g0b4256f
+isl-0.18-254-g6bc184d

Modified: polly/trunk/lib/External/isl/Makefile.in
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/Makefile.in?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/Makefile.in (original)
+++ polly/trunk/lib/External/isl/Makefile.in Thu Feb 16 23:11:16 2017
@@ -114,6 +114,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/a
 	$(top_srcdir)/m4/ax_compiler_vendor.m4 \
 	$(top_srcdir)/m4/ax_create_pkgconfig_info.m4 \
 	$(top_srcdir)/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/m4/ax_detect_clang.m4 \
 	$(top_srcdir)/m4/ax_detect_git_head.m4 \
 	$(top_srcdir)/m4/ax_detect_gmp.m4 \
 	$(top_srcdir)/m4/ax_detect_imath.m4 \

Modified: polly/trunk/lib/External/isl/aclocal.m4
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/aclocal.m4?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/aclocal.m4 (original)
+++ polly/trunk/lib/External/isl/aclocal.m4 Thu Feb 16 23:11:16 2017
@@ -1156,6 +1156,7 @@ m4_include([m4/ax_check_compiler_flags.m
 m4_include([m4/ax_compiler_vendor.m4])
 m4_include([m4/ax_create_pkgconfig_info.m4])
 m4_include([m4/ax_create_stdint_h.m4])
+m4_include([m4/ax_detect_clang.m4])
 m4_include([m4/ax_detect_git_head.m4])
 m4_include([m4/ax_detect_gmp.m4])
 m4_include([m4/ax_detect_imath.m4])

Modified: polly/trunk/lib/External/isl/bound.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/bound.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/bound.c (original)
+++ polly/trunk/lib/External/isl/bound.c Thu Feb 16 23:11:16 2017
@@ -61,7 +61,6 @@ struct verify_point_bound {
 static isl_stat verify_point(__isl_take isl_point *pnt, void *user)
 {
 	int i;
-	unsigned nvar;
 	unsigned nparam;
 	struct verify_point_bound *vpb = (struct verify_point_bound *) user;
 	isl_int t;
@@ -72,7 +71,7 @@ static isl_stat verify_point(__isl_take
 	isl_set *dom = NULL;
 	isl_printer *p;
 	const char *minmax;
-	int bounded;
+	isl_bool bounded;
 	int sign;
 	int ok;
 	FILE *out = vpb->options->print_all ? stdout : stderr;
@@ -119,7 +118,6 @@ static isl_stat verify_point(__isl_take
 	else
 		opt = isl_pw_qpolynomial_fold_min(isl_pw_qpolynomial_fold_copy(pwf));
 
-	nvar = isl_set_dim(dom, isl_dim_set);
 	if (vpb->exact && bounded)
 		ok = isl_val_eq(opt, bound);
 	else if (sign > 0)

Modified: polly/trunk/lib/External/isl/configure
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/configure?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/configure (original)
+++ polly/trunk/lib/External/isl/configure Thu Feb 16 23:11:16 2017
@@ -18297,9 +18297,6 @@ fi
 
 
 
-
-
-
 # Check whether --with-clang was given.
 if test "${with_clang+set}" = set; then :
   withval=$with_clang;
@@ -18382,7 +18379,12 @@ $as_echo "$with_clang" >&6; }
 
 case "$with_clang" in
 system)
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
 $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
 if ${ac_cv_path_GREP+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -18445,7 +18447,7 @@ $as_echo "$ac_cv_path_GREP" >&6; }
  GREP="$ac_cv_path_GREP"
 
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
 $as_echo_n "checking for a sed that does not truncate output... " >&6; }
 if ${ac_cv_path_SED+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -18514,8 +18516,8 @@ $as_echo "$ac_cv_path_SED" >&6; }
  SED="$ac_cv_path_SED"
   rm -f conftest.sed
 
-	llvm_config="llvm-config"
-	# Extract the first word of ""$llvm_config"", so it can be a program name with args.
+llvm_config="llvm-config"
+# Extract the first word of ""$llvm_config"", so it can be a program name with args.
 set dummy "$llvm_config"; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
@@ -18552,45 +18554,44 @@ $as_echo "no" >&6; }
 fi
 
 
-	if test "x$with_clang_prefix" != "x"; then
-		llvm_config="$with_clang_prefix/bin/llvm-config"
-		if test -x "$llvm_config"; then
-			llvm_config_found=yes
-		fi
-	fi
-	if test "$llvm_config_found" != yes; then
-		as_fn_error $? "llvm-config not found" "$LINENO" 5
-	fi
-	CLANG_CXXFLAGS=`$llvm_config --cxxflags | \
-		$SED -e 's/-Wcovered-switch-default//'`
-	CLANG_LDFLAGS=`$llvm_config --ldflags`
-	targets=`$llvm_config --targets-built`
-	components="$targets asmparser bitreader support mc"
-	$llvm_config --components | $GREP option > /dev/null 2> /dev/null
-	if test $? -eq 0; then
-		components="$components option"
+if test "x$with_clang_prefix" != "x"; then
+	llvm_config="$with_clang_prefix/bin/llvm-config"
+	if test -x "$llvm_config"; then
+		llvm_config_found=yes
 	fi
-	CLANG_LIBS=`$llvm_config --libs $components`
-	systemlibs=`$llvm_config --system-libs 2> /dev/null | tail -1`
-	if test $? -eq 0; then
-		CLANG_LIBS="$CLANG_LIBS $systemlibs"
-	fi
-	CLANG_PREFIX=`$llvm_config --prefix`
+fi
+if test "$llvm_config_found" != yes; then
+	as_fn_error $? "llvm-config not found" "$LINENO" 5
+fi
+CLANG_CXXFLAGS=`$llvm_config --cxxflags | \
+	$SED -e 's/-Wcovered-switch-default//'`
+CLANG_LDFLAGS=`$llvm_config --ldflags`
+targets=`$llvm_config --targets-built`
+components="$targets asmparser bitreader support mc"
+$llvm_config --components | $GREP option > /dev/null 2> /dev/null
+if test $? -eq 0; then
+	components="$components option"
+fi
+CLANG_LIBS=`$llvm_config --libs $components`
+systemlibs=`$llvm_config --system-libs 2> /dev/null | tail -1`
+if test $? -eq 0; then
+	CLANG_LIBS="$CLANG_LIBS $systemlibs"
+fi
+CLANG_PREFIX=`$llvm_config --prefix`
 
 cat >>confdefs.h <<_ACEOF
 #define CLANG_PREFIX "$CLANG_PREFIX"
 _ACEOF
 
 
-	SAVE_CPPFLAGS="$CPPFLAGS"
-	CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
-	ac_ext=cpp
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
+ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
-
 ac_fn_cxx_check_header_mongrel "$LINENO" "clang/Basic/SourceLocation.h" "ac_cv_header_clang_Basic_SourceLocation_h" "$ac_includes_default"
 if test "x$ac_cv_header_clang_Basic_SourceLocation_h" = xyes; then :
 
@@ -18599,7 +18600,7 @@ else
 fi
 
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <llvm/Support/Host.h>
 
@@ -18614,7 +18615,7 @@ $as_echo "#define getDefaultTargetTriple
 fi
 rm -f conftest*
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Basic/SourceLocation.h>
 
@@ -18629,7 +18630,7 @@ $as_echo "#define getExpansionLineNumber
 fi
 rm -f conftest*
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Basic/Diagnostic.h>
 
@@ -18644,7 +18645,7 @@ $as_echo "#define DiagnosticsEngine Diag
 fi
 rm -f conftest*
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Driver/Driver.h>
 
@@ -18657,7 +18658,7 @@ $as_echo "#define USE_ARRAYREF /**/" >>c
 fi
 rm -f conftest*
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Driver/Driver.h>
 
@@ -18670,7 +18671,7 @@ $as_echo "#define HAVE_CXXISPRODUCTION /
 fi
 rm -f conftest*
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Driver/Driver.h>
 
@@ -18683,16 +18684,16 @@ $as_echo "#define HAVE_ISPRODUCTION /**/
 fi
 rm -f conftest*
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Driver/Driver.h>
 int
 main ()
 {
 
-		using namespace clang;
-		DiagnosticsEngine *Diags;
-		new driver::Driver("", "", "", *Diags);
+	using namespace clang;
+	DiagnosticsEngine *Diags;
+	new driver::Driver("", "", "", *Diags);
 
   ;
   return 0;
@@ -18704,7 +18705,7 @@ $as_echo "#define DRIVER_CTOR_TAKES_DEFA
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/AST/ASTConsumer.h>
 
@@ -18727,7 +18728,7 @@ $as_echo "#define HandleTopLevelDeclCont
 fi
 rm -f conftest*
 
-	ac_fn_cxx_check_header_mongrel "$LINENO" "clang/Basic/DiagnosticOptions.h" "ac_cv_header_clang_Basic_DiagnosticOptions_h" "$ac_includes_default"
+ac_fn_cxx_check_header_mongrel "$LINENO" "clang/Basic/DiagnosticOptions.h" "ac_cv_header_clang_Basic_DiagnosticOptions_h" "$ac_includes_default"
 if test "x$ac_cv_header_clang_Basic_DiagnosticOptions_h" = xyes; then :
 
 $as_echo "#define HAVE_BASIC_DIAGNOSTICOPTIONS_H /**/" >>confdefs.h
@@ -18735,7 +18736,7 @@ $as_echo "#define HAVE_BASIC_DIAGNOSTICO
 fi
 
 
-	ac_fn_cxx_check_header_compile "$LINENO" "clang/Lex/PreprocessorOptions.h" "ac_cv_header_clang_Lex_PreprocessorOptions_h" "#include <clang/Basic/LLVM.h>
+ac_fn_cxx_check_header_compile "$LINENO" "clang/Lex/PreprocessorOptions.h" "ac_cv_header_clang_Lex_PreprocessorOptions_h" "#include <clang/Basic/LLVM.h>
 "
 if test "x$ac_cv_header_clang_Lex_PreprocessorOptions_h" = xyes; then :
 
@@ -18744,17 +18745,17 @@ $as_echo "#define HAVE_LEX_PREPROCESSORO
 fi
 
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Basic/TargetInfo.h>
 int
 main ()
 {
 
-		using namespace clang;
-		std::shared_ptr<TargetOptions> TO;
-		DiagnosticsEngine *Diags;
-		TargetInfo::CreateTargetInfo(*Diags, TO);
+	using namespace clang;
+	std::shared_ptr<TargetOptions> TO;
+	DiagnosticsEngine *Diags;
+	TargetInfo::CreateTargetInfo(*Diags, TO);
 
   ;
   return 0;
@@ -18766,17 +18767,17 @@ $as_echo "#define CREATETARGETINFO_TAKES
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Basic/TargetInfo.h>
 int
 main ()
 {
 
-		using namespace clang;
-		TargetOptions *TO;
-		DiagnosticsEngine *Diags;
-		TargetInfo::CreateTargetInfo(*Diags, TO);
+	using namespace clang;
+	TargetOptions *TO;
+	DiagnosticsEngine *Diags;
+	TargetInfo::CreateTargetInfo(*Diags, TO);
 
   ;
   return 0;
@@ -18788,17 +18789,17 @@ $as_echo "#define CREATETARGETINFO_TAKES
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Frontend/CompilerInstance.h>
 int
 main ()
 {
 
-		using namespace clang;
-		DiagnosticConsumer *client;
-		CompilerInstance *Clang;
-		Clang->createDiagnostics(client);
+	using namespace clang;
+	DiagnosticConsumer *client;
+	CompilerInstance *Clang;
+	Clang->createDiagnostics(client);
 
   ;
   return 0;
@@ -18812,16 +18813,16 @@ $as_echo "#define CREATEDIAGNOSTICS_TAKE
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Lex/HeaderSearchOptions.h>
 int
 main ()
 {
 
-		using namespace clang;
-		HeaderSearchOptions HSO;
-		HSO.AddPath("", frontend::Angled, false, false);
+	using namespace clang;
+	HeaderSearchOptions HSO;
+	HSO.AddPath("", frontend::Angled, false, false);
 
   ;
   return 0;
@@ -18833,7 +18834,7 @@ $as_echo "#define ADDPATH_TAKES_4_ARGUME
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/AST/CanonicalType.h>
 
@@ -18849,7 +18850,7 @@ $as_echo "#define getArgType getParamTyp
 fi
 rm -f conftest*
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/AST/CanonicalType.h>
 
@@ -18864,16 +18865,16 @@ $as_echo "#define getReturnType getResul
 fi
 rm -f conftest*
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Frontend/CompilerInstance.h>
 int
 main ()
 {
 
-		using namespace clang;
-		CompilerInstance *Clang;
-		Clang->createPreprocessor(TU_Complete);
+	using namespace clang;
+	CompilerInstance *Clang;
+	Clang->createPreprocessor(TU_Complete);
 
   ;
   return 0;
@@ -18885,7 +18886,7 @@ $as_echo "#define CREATEPREPROCESSOR_TAK
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Basic/SourceManager.h>
 
@@ -18898,7 +18899,7 @@ $as_echo "#define HAVE_SETMAINFILEID /**
 fi
 rm -f conftest*
 
-	ac_fn_cxx_check_header_mongrel "$LINENO" "llvm/ADT/OwningPtr.h" "ac_cv_header_llvm_ADT_OwningPtr_h" "$ac_includes_default"
+ac_fn_cxx_check_header_mongrel "$LINENO" "llvm/ADT/OwningPtr.h" "ac_cv_header_llvm_ADT_OwningPtr_h" "$ac_includes_default"
 if test "x$ac_cv_header_llvm_ADT_OwningPtr_h" = xyes; then :
 
 $as_echo "#define HAVE_ADT_OWNINGPTR_H /**/" >>confdefs.h
@@ -18906,7 +18907,7 @@ $as_echo "#define HAVE_ADT_OWNINGPTR_H /
 fi
 
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <clang/Basic/Builtins.h>
 
@@ -18921,24 +18922,24 @@ $as_echo "#define initializeBuiltins Ini
 fi
 rm -f conftest*
 
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-		#include <clang/Basic/TargetOptions.h>
-		#include <clang/Lex/PreprocessorOptions.h>
-		#include <clang/Frontend/CompilerInstance.h>
+	#include <clang/Basic/TargetOptions.h>
+	#include <clang/Lex/PreprocessorOptions.h>
+	#include <clang/Frontend/CompilerInstance.h>
 
 int
 main ()
 {
 
-		using namespace clang;
-		CompilerInstance *Clang;
-		TargetOptions TO;
-		llvm::Triple T(TO.Triple);
-		PreprocessorOptions PO;
-		CompilerInvocation::setLangDefaults(Clang->getLangOpts(), IK_C,
-				T, PO, LangStandard::lang_unspecified);
+	using namespace clang;
+	CompilerInstance *Clang;
+	TargetOptions TO;
+	llvm::Triple T(TO.Triple);
+	PreprocessorOptions PO;
+	CompilerInvocation::setLangDefaults(Clang->getLangOpts(), IK_C,
+			T, PO, LangStandard::lang_unspecified);
 
   ;
   return 0;
@@ -18950,18 +18951,43 @@ $as_echo "#define SETLANGDEFAULTS_TAKES_
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-	ac_ext=c
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+	#include <clang/Frontend/CompilerInstance.h>
+	#include <clang/Frontend/CompilerInvocation.h>
+
+int
+main ()
+{
+
+	using namespace clang;
+	CompilerInvocation *invocation;
+	CompilerInstance *Clang;
+	Clang->setInvocation(std::make_shared<CompilerInvocation>(*invocation));
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+$as_echo "#define SETINVOCATION_TAKES_SHARED_PTR /**/" >>confdefs.h
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-	CPPFLAGS="$SAVE_CPPFLAGS"
+CPPFLAGS="$SAVE_CPPFLAGS"
 
-	SAVE_LDFLAGS="$LDFLAGS"
-	LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lclangEdit" >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lclangEdit" >&5
 $as_echo_n "checking for main in -lclangEdit... " >&6; }
 if ${ac_cv_lib_clangEdit_main+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -18995,7 +19021,8 @@ if test "x$ac_cv_lib_clangEdit_main" = x
   LIB_CLANG_EDIT=-lclangEdit
 fi
 
-	LDFLAGS="$SAVE_LDFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
 	;;
 esac
  if test $with_clang = system; then

Modified: polly/trunk/lib/External/isl/configure.ac
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/configure.ac?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/configure.ac (original)
+++ polly/trunk/lib/External/isl/configure.ac Thu Feb 16 23:11:16 2017
@@ -95,168 +95,10 @@ if test "x$ac_cv_have_decl_snprintf" = x
 	AC_MSG_ERROR([No snprintf implementation found])
 fi
 
-AC_SUBST(CLANG_CXXFLAGS)
-AC_SUBST(CLANG_LDFLAGS)
-AC_SUBST(CLANG_LIBS)
 AX_SUBMODULE(clang,system|no,no)
 case "$with_clang" in
 system)
-	AC_PROG_GREP
-	AC_PROG_SED
-	llvm_config="llvm-config"
-	AC_CHECK_PROG([llvm_config_found], ["$llvm_config"], [yes])
-	if test "x$with_clang_prefix" != "x"; then
-		llvm_config="$with_clang_prefix/bin/llvm-config"
-		if test -x "$llvm_config"; then
-			llvm_config_found=yes
-		fi
-	fi
-	if test "$llvm_config_found" != yes; then
-		AC_MSG_ERROR([llvm-config not found])
-	fi
-	CLANG_CXXFLAGS=`$llvm_config --cxxflags | \
-		$SED -e 's/-Wcovered-switch-default//'`
-	CLANG_LDFLAGS=`$llvm_config --ldflags`
-	targets=`$llvm_config --targets-built`
-	components="$targets asmparser bitreader support mc"
-	$llvm_config --components | $GREP option > /dev/null 2> /dev/null
-	if test $? -eq 0; then
-		components="$components option"
-	fi
-	CLANG_LIBS=`$llvm_config --libs $components`
-	systemlibs=`$llvm_config --system-libs 2> /dev/null | tail -1`
-	if test $? -eq 0; then
-		CLANG_LIBS="$CLANG_LIBS $systemlibs"
-	fi
-	CLANG_PREFIX=`$llvm_config --prefix`
-	AC_DEFINE_UNQUOTED(CLANG_PREFIX, ["$CLANG_PREFIX"],
-				[Clang installation prefix])
-
-	SAVE_CPPFLAGS="$CPPFLAGS"
-	CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
-	AC_LANG_PUSH(C++)
-	AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [],
-		[AC_ERROR([clang header file not found])])
-	AC_EGREP_HEADER([getDefaultTargetTriple], [llvm/Support/Host.h], [],
-		[AC_DEFINE([getDefaultTargetTriple], [getHostTriple],
-		[Define to getHostTriple for older versions of clang])])
-	AC_EGREP_HEADER([getExpansionLineNumber],
-		[clang/Basic/SourceLocation.h], [],
-		[AC_DEFINE([getExpansionLineNumber],
-			[getInstantiationLineNumber],
-	    [Define to getInstantiationLineNumber for older versions of clang])])
-	AC_EGREP_HEADER([DiagnosticsEngine],
-		[clang/Basic/Diagnostic.h], [],
-		[AC_DEFINE([DiagnosticsEngine],
-			[Diagnostic],
-	    [Define to Diagnostic for older versions of clang])])
-	AC_EGREP_HEADER([ArrayRef], [clang/Driver/Driver.h],
-		[AC_DEFINE([USE_ARRAYREF], [],
-			[Define if Driver::BuildCompilation takes ArrayRef])])
-	AC_EGREP_HEADER([CXXIsProduction], [clang/Driver/Driver.h],
-		[AC_DEFINE([HAVE_CXXISPRODUCTION], [],
-		[Define if Driver constructor takes CXXIsProduction argument])])
-	AC_EGREP_HEADER([ IsProduction], [clang/Driver/Driver.h],
-		[AC_DEFINE([HAVE_ISPRODUCTION], [],
-		[Define if Driver constructor takes IsProduction argument])])
-	AC_TRY_COMPILE([#include <clang/Driver/Driver.h>], [
-		using namespace clang;
-		DiagnosticsEngine *Diags;
-		new driver::Driver("", "", "", *Diags);
-	], [AC_DEFINE([DRIVER_CTOR_TAKES_DEFAULTIMAGENAME], [],
-		      [Define if Driver constructor takes default image name])])
-	AC_EGREP_HEADER([void HandleTopLevelDecl\(], [clang/AST/ASTConsumer.h],
-		[AC_DEFINE([HandleTopLevelDeclReturn], [void],
-			   [Return type of HandleTopLevelDeclReturn])
-		 AC_DEFINE([HandleTopLevelDeclContinue], [],
-			   [Return type of HandleTopLevelDeclReturn])],
-		[AC_DEFINE([HandleTopLevelDeclReturn], [bool],
-			   [Return type of HandleTopLevelDeclReturn])
-		 AC_DEFINE([HandleTopLevelDeclContinue], [true],
-			   [Return type of HandleTopLevelDeclReturn])])
-	AC_CHECK_HEADER([clang/Basic/DiagnosticOptions.h],
-		[AC_DEFINE([HAVE_BASIC_DIAGNOSTICOPTIONS_H], [],
-			   [Define if clang/Basic/DiagnosticOptions.h exists])])
-	AC_CHECK_HEADER([clang/Lex/PreprocessorOptions.h],
-		[AC_DEFINE([HAVE_LEX_PREPROCESSOROPTIONS_H], [],
-			   [Define if clang/Lex/PreprocessorOptions.h exists])],
-		[], [#include <clang/Basic/LLVM.h>])
-	AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
-		using namespace clang;
-		std::shared_ptr<TargetOptions> TO;
-		DiagnosticsEngine *Diags;
-		TargetInfo::CreateTargetInfo(*Diags, TO);
-	], [AC_DEFINE([CREATETARGETINFO_TAKES_SHARED_PTR], [],
-		    [Define if TargetInfo::CreateTargetInfo takes shared_ptr])])
-	AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
-		using namespace clang;
-		TargetOptions *TO;
-		DiagnosticsEngine *Diags;
-		TargetInfo::CreateTargetInfo(*Diags, TO);
-	], [AC_DEFINE([CREATETARGETINFO_TAKES_POINTER], [],
-		      [Define if TargetInfo::CreateTargetInfo takes pointer])])
-	AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
-		using namespace clang;
-		DiagnosticConsumer *client;
-		CompilerInstance *Clang;
-		Clang->createDiagnostics(client);
-	], [], [AC_DEFINE([CREATEDIAGNOSTICS_TAKES_ARG], [],
-	[Define if CompilerInstance::createDiagnostics takes argc and argv])])
-	AC_TRY_COMPILE([#include <clang/Lex/HeaderSearchOptions.h>], [
-		using namespace clang;
-		HeaderSearchOptions HSO;
-		HSO.AddPath("", frontend::Angled, false, false);
-	], [AC_DEFINE([ADDPATH_TAKES_4_ARGUMENTS], [],
-		[Define if HeaderSearchOptions::AddPath takes 4 arguments])])
-	AC_EGREP_HEADER([getNumParams],
-		[clang/AST/CanonicalType.h],
-		[AC_DEFINE([getNumArgs], [getNumParams],
-		    [Define to getNumParams for newer versions of clang])
-		 AC_DEFINE([getArgType], [getParamType],
-		    [Define to getParamType for newer versions of clang])])
-	AC_EGREP_HEADER([getReturnType],
-		[clang/AST/CanonicalType.h], [],
-		[AC_DEFINE([getReturnType], [getResultType],
-		    [Define to getResultType for older versions of clang])])
-	AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
-		using namespace clang;
-		CompilerInstance *Clang;
-		Clang->createPreprocessor(TU_Complete);
-	], [AC_DEFINE([CREATEPREPROCESSOR_TAKES_TUKIND], [],
-	[Define if CompilerInstance::createPreprocessor takes
-	 TranslationUnitKind])])
-	AC_EGREP_HEADER([setMainFileID], [clang/Basic/SourceManager.h],
-		[AC_DEFINE([HAVE_SETMAINFILEID], [],
-		[Define if SourceManager has a setMainFileID method])])
-	AC_CHECK_HEADER([llvm/ADT/OwningPtr.h],
-		[AC_DEFINE([HAVE_ADT_OWNINGPTR_H], [],
-			   [Define if llvm/ADT/OwningPtr.h exists])])
-	AC_EGREP_HEADER([initializeBuiltins],
-		[clang/Basic/Builtins.h], [],
-		[AC_DEFINE([initializeBuiltins], [InitializeBuiltins],
-		[Define to InitializeBuiltins for older versions of clang])])
-	AC_TRY_COMPILE([
-		#include <clang/Basic/TargetOptions.h>
-		#include <clang/Lex/PreprocessorOptions.h>
-		#include <clang/Frontend/CompilerInstance.h>
-	], [
-		using namespace clang;
-		CompilerInstance *Clang;
-		TargetOptions TO;
-		llvm::Triple T(TO.Triple);
-		PreprocessorOptions PO;
-		CompilerInvocation::setLangDefaults(Clang->getLangOpts(), IK_C,
-				T, PO, LangStandard::lang_unspecified);
-	], [AC_DEFINE([SETLANGDEFAULTS_TAKES_5_ARGUMENTS], [],
-	    [Define if CompilerInvocation::setLangDefaults takes 5 arguments])])
-	AC_LANG_POP
-	CPPFLAGS="$SAVE_CPPFLAGS"
-
-	SAVE_LDFLAGS="$LDFLAGS"
-	LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
-	AC_SUBST(LIB_CLANG_EDIT)
-	AC_CHECK_LIB([clangEdit], [main], [LIB_CLANG_EDIT=-lclangEdit], [])
-	LDFLAGS="$SAVE_LDFLAGS"
+	AX_DETECT_CLANG
 	;;
 esac
 AM_CONDITIONAL(HAVE_CLANG, test $with_clang = system)

Modified: polly/trunk/lib/External/isl/doc/Makefile.in
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/doc/Makefile.in?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/doc/Makefile.in (original)
+++ polly/trunk/lib/External/isl/doc/Makefile.in Thu Feb 16 23:11:16 2017
@@ -95,6 +95,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/a
 	$(top_srcdir)/m4/ax_compiler_vendor.m4 \
 	$(top_srcdir)/m4/ax_create_pkgconfig_info.m4 \
 	$(top_srcdir)/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/m4/ax_detect_clang.m4 \
 	$(top_srcdir)/m4/ax_detect_git_head.m4 \
 	$(top_srcdir)/m4/ax_detect_gmp.m4 \
 	$(top_srcdir)/m4/ax_detect_imath.m4 \

Modified: polly/trunk/lib/External/isl/doc/user.pod
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/doc/user.pod?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/doc/user.pod (original)
+++ polly/trunk/lib/External/isl/doc/user.pod Thu Feb 16 23:11:16 2017
@@ -4046,14 +4046,40 @@ the input is itself a wrapped relation.
 
 Check whether the given expression is a constant.
 
+	#include <isl/val.h>
+	isl_bool isl_multi_val_involves_nan(
+		__isl_keep isl_multi_val *mv);
+
 	#include <isl/aff.h>
 	isl_bool isl_aff_is_nan(__isl_keep isl_aff *aff);
+	isl_bool isl_multi_aff_involves_nan(
+		__isl_keep isl_multi_aff *ma);
 	isl_bool isl_pw_aff_involves_nan(
 		__isl_keep isl_pw_aff *pa);
+	isl_bool isl_pw_multi_aff_involves_nan(
+		__isl_keep isl_pw_multi_aff *pma);
+	isl_bool isl_multi_pw_aff_involves_nan(
+		__isl_keep isl_multi_pw_aff *mpa);
+	isl_bool isl_union_pw_aff_involves_nan(
+		__isl_keep isl_union_pw_aff *upa);
+	isl_bool isl_union_pw_multi_aff_involves_nan(
+		__isl_keep isl_union_pw_multi_aff *upma);
+	isl_bool isl_multi_union_pw_aff_involves_nan(
+		__isl_keep isl_multi_union_pw_aff *mupa);
 
 	#include <isl/polynomial.h>
+	isl_bool isl_qpolynomial_is_nan(
+		__isl_keep isl_qpolynomial *qp);
 	isl_bool isl_qpolynomial_fold_is_nan(
 		__isl_keep isl_qpolynomial_fold *fold);
+	isl_bool isl_pw_qpolynomial_involves_nan(
+		__isl_keep isl_pw_qpolynomial *pwqp);
+	isl_bool isl_pw_qpolynomial_fold_involves_nan(
+		__isl_keep isl_pw_qpolynomial_fold *pwf);
+	isl_bool isl_union_pw_qpolynomial_involves_nan(
+		__isl_keep isl_union_pw_qpolynomial *upwqp);
+	isl_bool isl_union_pw_qpolynomial_fold_involves_nan(
+		__isl_keep isl_union_pw_qpolynomial_fold *upwf);
 
 Check whether the given expression is equal to or involves NaN.
 
@@ -4121,9 +4147,15 @@ return true if the objects are not the s
 	isl_bool isl_pw_aff_plain_is_equal(
 		__isl_keep isl_pw_aff *pwaff1,
 		__isl_keep isl_pw_aff *pwaff2);
+	isl_bool isl_pw_aff_is_equal(
+		__isl_keep isl_pw_aff *pa1,
+		__isl_keep isl_pw_aff *pa2);
 	isl_bool isl_pw_multi_aff_plain_is_equal(
 		__isl_keep isl_pw_multi_aff *pma1,
 		__isl_keep isl_pw_multi_aff *pma2);
+	isl_bool isl_pw_multi_aff_is_equal(
+		__isl_keep isl_pw_multi_aff *pma1,
+		__isl_keep isl_pw_multi_aff *pma2);
 	isl_bool isl_multi_pw_aff_plain_is_equal(
 		__isl_keep isl_multi_pw_aff *mpa1,
 		__isl_keep isl_multi_pw_aff *mpa2);

Modified: polly/trunk/lib/External/isl/include/isl/aff.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/aff.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/aff.h (original)
+++ polly/trunk/lib/External/isl/include/isl/aff.h Thu Feb 16 23:11:16 2017
@@ -188,7 +188,8 @@ int isl_pw_aff_plain_cmp(__isl_keep isl_
 	__isl_keep isl_pw_aff *pa2);
 isl_bool isl_pw_aff_plain_is_equal(__isl_keep isl_pw_aff *pwaff1,
 	__isl_keep isl_pw_aff *pwaff2);
-int isl_pw_aff_is_equal(__isl_keep isl_pw_aff *pa1, __isl_keep isl_pw_aff *pa2);
+isl_bool isl_pw_aff_is_equal(__isl_keep isl_pw_aff *pa1,
+	__isl_keep isl_pw_aff *pa2);
 
 __isl_give isl_pw_aff *isl_pw_aff_union_min(__isl_take isl_pw_aff *pwaff1,
 	__isl_take isl_pw_aff *pwaff2);
@@ -477,8 +478,11 @@ __isl_give isl_pw_multi_aff *isl_pw_mult
 	__isl_take isl_pw_multi_aff *pma,
 	enum isl_dim_type type, unsigned pos, __isl_take isl_id *id);
 
+isl_bool isl_pw_multi_aff_involves_nan(__isl_keep isl_pw_multi_aff *pma);
 isl_bool isl_pw_multi_aff_plain_is_equal(__isl_keep isl_pw_multi_aff *pma1,
 	__isl_keep isl_pw_multi_aff *pma2);
+isl_bool isl_pw_multi_aff_is_equal(__isl_keep isl_pw_multi_aff *pma1,
+	__isl_keep isl_pw_multi_aff *pma2);
 
 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_fix_si(
 	__isl_take isl_pw_multi_aff *pma, enum isl_dim_type type,
@@ -645,6 +649,8 @@ isl_stat isl_union_pw_multi_aff_foreach_
 __isl_give isl_pw_multi_aff *isl_union_pw_multi_aff_extract_pw_multi_aff(
 	__isl_keep isl_union_pw_multi_aff *upma, __isl_take isl_space *space);
 
+isl_bool isl_union_pw_multi_aff_involves_nan(
+	__isl_keep isl_union_pw_multi_aff *upma);
 isl_bool isl_union_pw_multi_aff_plain_is_equal(
 	__isl_keep isl_union_pw_multi_aff *upma1,
 	__isl_keep isl_union_pw_multi_aff *upma2);
@@ -819,6 +825,7 @@ isl_stat isl_union_pw_aff_foreach_pw_aff
 __isl_give isl_pw_aff *isl_union_pw_aff_extract_pw_aff(
 	__isl_keep isl_union_pw_aff *upa, __isl_take isl_space *space);
 
+isl_bool isl_union_pw_aff_involves_nan(__isl_keep isl_union_pw_aff *upa);
 isl_bool isl_union_pw_aff_plain_is_equal(__isl_keep isl_union_pw_aff *upa1,
 	__isl_keep isl_union_pw_aff *upa2);
 

Modified: polly/trunk/lib/External/isl/include/isl/constraint.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/constraint.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/constraint.h (original)
+++ polly/trunk/lib/External/isl/include/isl/constraint.h Thu Feb 16 23:11:16 2017
@@ -68,13 +68,13 @@ __isl_give isl_map *isl_map_add_constrai
 __isl_give isl_set *isl_set_add_constraint(__isl_take isl_set *set,
 	__isl_take isl_constraint *constraint);
 
-int isl_basic_map_has_defining_equality(
+isl_bool isl_basic_map_has_defining_equality(
 	__isl_keep isl_basic_map *bmap, enum isl_dim_type type, int pos,
 	__isl_give isl_constraint **c);
-int isl_basic_set_has_defining_equality(
+isl_bool isl_basic_set_has_defining_equality(
 	struct isl_basic_set *bset, enum isl_dim_type type, int pos,
 	struct isl_constraint **constraint);
-int isl_basic_set_has_defining_inequalities(
+isl_bool isl_basic_set_has_defining_inequalities(
 	struct isl_basic_set *bset, enum isl_dim_type type, int pos,
 	struct isl_constraint **lower,
 	struct isl_constraint **upper);

Modified: polly/trunk/lib/External/isl/include/isl/deprecated/aff_int.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/deprecated/aff_int.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/deprecated/aff_int.h (original)
+++ polly/trunk/lib/External/isl/include/isl/deprecated/aff_int.h Thu Feb 16 23:11:16 2017
@@ -11,7 +11,7 @@ extern "C" {
 int isl_aff_get_constant(__isl_keep isl_aff *aff, isl_int *v);
 int isl_aff_get_coefficient(__isl_keep isl_aff *aff,
 	enum isl_dim_type type, int pos, isl_int *v);
-int isl_aff_get_denominator(__isl_keep isl_aff *aff, isl_int *v);
+isl_stat isl_aff_get_denominator(__isl_keep isl_aff *aff, isl_int *v);
 __isl_give isl_aff *isl_aff_set_constant(__isl_take isl_aff *aff, isl_int v);
 __isl_give isl_aff *isl_aff_set_coefficient(__isl_take isl_aff *aff,
 	enum isl_dim_type type, int pos, isl_int v);

Modified: polly/trunk/lib/External/isl/include/isl/deprecated/map_int.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/deprecated/map_int.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/deprecated/map_int.h (original)
+++ polly/trunk/lib/External/isl/include/isl/deprecated/map_int.h Thu Feb 16 23:11:16 2017
@@ -8,12 +8,12 @@
 extern "C" {
 #endif
 
-int isl_basic_map_plain_is_fixed(__isl_keep isl_basic_map *bmap,
+isl_bool isl_basic_map_plain_is_fixed(__isl_keep isl_basic_map *bmap,
 	enum isl_dim_type type, unsigned pos, isl_int *val);
 
 __isl_give isl_map *isl_map_fix(__isl_take isl_map *map,
 	enum isl_dim_type type, unsigned pos, isl_int value);
-int isl_map_plain_is_fixed(__isl_keep isl_map *map,
+isl_bool isl_map_plain_is_fixed(__isl_keep isl_map *map,
 	enum isl_dim_type type, unsigned pos, isl_int *val);
 
 __isl_give isl_map *isl_map_fixed_power(__isl_take isl_map *map, isl_int exp);

Modified: polly/trunk/lib/External/isl/include/isl/deprecated/set_int.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/deprecated/set_int.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/deprecated/set_int.h (original)
+++ polly/trunk/lib/External/isl/include/isl/deprecated/set_int.h Thu Feb 16 23:11:16 2017
@@ -17,7 +17,7 @@ __isl_give isl_set *isl_set_upper_bound(
 __isl_give isl_set *isl_set_fix(__isl_take isl_set *set,
 		enum isl_dim_type type, unsigned pos, isl_int value);
 
-int isl_set_plain_is_fixed(__isl_keep isl_set *set,
+isl_bool isl_set_plain_is_fixed(__isl_keep isl_set *set,
 	enum isl_dim_type type, unsigned pos, isl_int *val);
 
 #if defined(__cplusplus)

Modified: polly/trunk/lib/External/isl/include/isl/map.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/map.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/map.h (original)
+++ polly/trunk/lib/External/isl/include/isl/map.h Thu Feb 16 23:11:16 2017
@@ -115,7 +115,7 @@ int isl_map_find_dim_by_id(__isl_keep is
 int isl_map_find_dim_by_name(__isl_keep isl_map *map, enum isl_dim_type type,
 	const char *name);
 
-int isl_basic_map_is_rational(__isl_keep isl_basic_map *bmap);
+isl_bool isl_basic_map_is_rational(__isl_keep isl_basic_map *bmap);
 
 __isl_give isl_basic_map *isl_basic_map_identity(__isl_take isl_space *dim);
 __isl_null isl_basic_map *isl_basic_map_free(__isl_take isl_basic_map *bmap);
@@ -285,7 +285,7 @@ __isl_give isl_val *isl_basic_map_plain_
 	__isl_keep isl_basic_map *bmap,
 	enum isl_dim_type type, unsigned pos);
 
-int isl_basic_map_image_is_bounded(__isl_keep isl_basic_map *bmap);
+isl_bool isl_basic_map_image_is_bounded(__isl_keep isl_basic_map *bmap);
 isl_bool isl_basic_map_plain_is_universe(__isl_keep isl_basic_map *bmap);
 isl_bool isl_basic_map_is_universe(__isl_keep isl_basic_map *bmap);
 isl_bool isl_basic_map_plain_is_empty(__isl_keep isl_basic_map *bmap);
@@ -550,7 +550,8 @@ __isl_export
 isl_bool isl_map_is_bijective(__isl_keep isl_map *map);
 isl_bool isl_map_is_identity(__isl_keep isl_map *map);
 int isl_map_is_translation(__isl_keep isl_map *map);
-int isl_map_has_equal_space(__isl_keep isl_map *map1, __isl_keep isl_map *map2);
+isl_bool isl_map_has_equal_space(__isl_keep isl_map *map1,
+	__isl_keep isl_map *map2);
 
 isl_bool isl_basic_map_can_zip(__isl_keep isl_basic_map *bmap);
 isl_bool isl_map_can_zip(__isl_keep isl_map *map);

Modified: polly/trunk/lib/External/isl/include/isl/mat.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/mat.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/mat.h (original)
+++ polly/trunk/lib/External/isl/include/isl/mat.h Thu Feb 16 23:11:16 2017
@@ -97,7 +97,7 @@ __isl_give isl_mat *isl_mat_concat(__isl
 __isl_give isl_mat *isl_mat_vec_concat(__isl_take isl_mat *top,
 	__isl_take isl_vec *bot);
 
-int isl_mat_is_equal(__isl_keep isl_mat *mat1, __isl_keep isl_mat *mat2);
+isl_bool isl_mat_is_equal(__isl_keep isl_mat *mat1, __isl_keep isl_mat *mat2);
 
 int isl_mat_initial_non_zero_cols(__isl_keep isl_mat *mat);
 

Modified: polly/trunk/lib/External/isl/include/isl/multi.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/multi.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/multi.h (original)
+++ polly/trunk/lib/External/isl/include/isl/multi.h Thu Feb 16 23:11:16 2017
@@ -32,6 +32,8 @@ __isl_null isl_multi_##BASE *isl_multi_#
 isl_bool isl_multi_##BASE##_plain_is_equal(				\
 	__isl_keep isl_multi_##BASE *multi1,				\
 	__isl_keep isl_multi_##BASE *multi2);				\
+isl_bool isl_multi_##BASE##_involves_nan(				\
+	__isl_keep isl_multi_##BASE *multi);				\
 int isl_multi_##BASE##_find_dim_by_id(					\
 	__isl_keep isl_multi_##BASE *multi, enum isl_dim_type type,	\
 	__isl_keep isl_id *id);						\

Modified: polly/trunk/lib/External/isl/include/isl/polynomial.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/polynomial.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/polynomial.h (original)
+++ polly/trunk/lib/External/isl/include/isl/polynomial.h Thu Feb 16 23:11:16 2017
@@ -87,9 +87,9 @@ __isl_give isl_qpolynomial *isl_qpolynom
 	enum isl_dim_type type, unsigned first, unsigned n,
 	__isl_keep isl_qpolynomial **subs);
 
-int isl_qpolynomial_as_polynomial_on_domain(__isl_keep isl_qpolynomial *qp,
+isl_stat isl_qpolynomial_as_polynomial_on_domain(__isl_keep isl_qpolynomial *qp,
 	__isl_keep isl_basic_set *bset,
-	int (*fn)(__isl_take isl_basic_set *bset,
+	isl_stat (*fn)(__isl_take isl_basic_set *bset,
 		  __isl_take isl_qpolynomial *poly, void *user), void *user);
 
 __isl_give isl_qpolynomial *isl_qpolynomial_homogenize(
@@ -135,6 +135,7 @@ void isl_qpolynomial_dump(__isl_keep isl
 
 isl_ctx *isl_pw_qpolynomial_get_ctx(__isl_keep isl_pw_qpolynomial *pwqp);
 
+isl_bool isl_pw_qpolynomial_involves_nan(__isl_keep isl_pw_qpolynomial *pwqp);
 isl_bool isl_pw_qpolynomial_plain_is_equal(__isl_keep isl_pw_qpolynomial *pwqp1,
 	__isl_keep isl_pw_qpolynomial *pwqp2);
 
@@ -160,7 +161,8 @@ unsigned isl_pw_qpolynomial_dim(__isl_ke
 	enum isl_dim_type type);
 isl_bool isl_pw_qpolynomial_involves_dims(__isl_keep isl_pw_qpolynomial *pwqp,
 	enum isl_dim_type type, unsigned first, unsigned n);
-int isl_pw_qpolynomial_has_equal_space(__isl_keep isl_pw_qpolynomial *pwqp1,
+isl_bool isl_pw_qpolynomial_has_equal_space(
+	__isl_keep isl_pw_qpolynomial *pwqp1,
 	__isl_keep isl_pw_qpolynomial *pwqp2);
 
 __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_set_dim_name(
@@ -331,6 +333,8 @@ void isl_qpolynomial_fold_dump(__isl_kee
 
 isl_ctx *isl_pw_qpolynomial_fold_get_ctx(__isl_keep isl_pw_qpolynomial_fold *pwf);
 
+isl_bool isl_pw_qpolynomial_fold_involves_nan(
+	__isl_keep isl_pw_qpolynomial_fold *pwf);
 isl_bool isl_pw_qpolynomial_fold_plain_is_equal(
 	__isl_keep isl_pw_qpolynomial_fold *pwf1,
 	__isl_keep isl_pw_qpolynomial_fold *pwf2);
@@ -357,7 +361,7 @@ __isl_give isl_pw_qpolynomial_fold *isl_
 	__isl_take isl_pw_qpolynomial_fold *pwf, __isl_take isl_space *dim);
 unsigned isl_pw_qpolynomial_fold_dim(__isl_keep isl_pw_qpolynomial_fold *pwf,
 	enum isl_dim_type type);
-int isl_pw_qpolynomial_fold_has_equal_space(
+isl_bool isl_pw_qpolynomial_fold_has_equal_space(
 	__isl_keep isl_pw_qpolynomial_fold *pwf1,
 	__isl_keep isl_pw_qpolynomial_fold *pwf2);
 
@@ -460,6 +464,8 @@ isl_ctx *isl_union_pw_qpolynomial_get_ct
 unsigned isl_union_pw_qpolynomial_dim(
 	__isl_keep isl_union_pw_qpolynomial *upwqp, enum isl_dim_type type);
 
+isl_bool isl_union_pw_qpolynomial_involves_nan(
+	__isl_keep isl_union_pw_qpolynomial *upwqp);
 isl_bool isl_union_pw_qpolynomial_plain_is_equal(
 	__isl_keep isl_union_pw_qpolynomial *upwqp1,
 	__isl_keep isl_union_pw_qpolynomial *upwqp2);
@@ -563,6 +569,8 @@ isl_ctx *isl_union_pw_qpolynomial_fold_g
 unsigned isl_union_pw_qpolynomial_fold_dim(
 	__isl_keep isl_union_pw_qpolynomial_fold *upwf, enum isl_dim_type type);
 
+isl_bool isl_union_pw_qpolynomial_fold_involves_nan(
+	__isl_keep isl_union_pw_qpolynomial_fold *upwf);
 isl_bool isl_union_pw_qpolynomial_fold_plain_is_equal(
 	__isl_keep isl_union_pw_qpolynomial_fold *upwf1,
 	__isl_keep isl_union_pw_qpolynomial_fold *upwf2);

Modified: polly/trunk/lib/External/isl/include/isl/set.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/set.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/set.h (original)
+++ polly/trunk/lib/External/isl/include/isl/set.h Thu Feb 16 23:11:16 2017
@@ -218,7 +218,7 @@ __isl_give isl_basic_set *isl_basic_set_
 __isl_give isl_set *isl_set_params(__isl_take isl_set *set);
 __isl_give isl_set *isl_set_from_params(__isl_take isl_set *set);
 
-int isl_basic_set_dims_get_sign(__isl_keep isl_basic_set *bset,
+isl_stat isl_basic_set_dims_get_sign(__isl_keep isl_basic_set *bset,
 	enum isl_dim_type type, unsigned pos, unsigned n, int *signs);
 
 isl_bool isl_basic_set_plain_is_universe(__isl_keep isl_basic_set *bset);
@@ -226,7 +226,7 @@ isl_bool isl_basic_set_is_universe(__isl
 isl_bool isl_basic_set_plain_is_empty(__isl_keep isl_basic_set *bset);
 __isl_export
 isl_bool isl_basic_set_is_empty(__isl_keep isl_basic_set *bset);
-int isl_basic_set_is_bounded(__isl_keep isl_basic_set *bset);
+isl_bool isl_basic_set_is_bounded(__isl_keep isl_basic_set *bset);
 __isl_export
 isl_bool isl_basic_set_is_subset(__isl_keep isl_basic_set *bset1,
 	__isl_keep isl_basic_set *bset2);
@@ -376,7 +376,7 @@ isl_bool isl_set_plain_is_universe(__isl
 isl_bool isl_set_is_params(__isl_keep isl_set *set);
 __isl_export
 isl_bool isl_set_is_empty(__isl_keep isl_set *set);
-int isl_set_is_bounded(__isl_keep isl_set *set);
+isl_bool isl_set_is_bounded(__isl_keep isl_set *set);
 __isl_export
 isl_bool isl_set_is_subset(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
 __isl_export
@@ -388,8 +388,9 @@ __isl_export
 isl_bool isl_set_is_disjoint(__isl_keep isl_set *set1,
 	__isl_keep isl_set *set2);
 isl_bool isl_set_is_singleton(__isl_keep isl_set *set);
-int isl_set_is_box(__isl_keep isl_set *set);
-int isl_set_has_equal_space(__isl_keep isl_set *set1, __isl_keep isl_set *set2);
+isl_bool isl_set_is_box(__isl_keep isl_set *set);
+isl_bool isl_set_has_equal_space(__isl_keep isl_set *set1,
+	__isl_keep isl_set *set2);
 
 __isl_give isl_set *isl_set_sum(__isl_take isl_set *set1,
 	__isl_take isl_set *set2);
@@ -409,7 +410,7 @@ struct isl_set *isl_set_drop_basic_set(s
 
 __isl_give isl_val *isl_set_plain_get_val_if_fixed(__isl_keep isl_set *set,
 	enum isl_dim_type type, unsigned pos);
-int isl_set_dim_is_bounded(__isl_keep isl_set *set,
+isl_bool isl_set_dim_is_bounded(__isl_keep isl_set *set,
 	enum isl_dim_type type, unsigned pos);
 isl_bool isl_set_dim_has_lower_bound(__isl_keep isl_set *set,
 	enum isl_dim_type type, unsigned pos);

Modified: polly/trunk/lib/External/isl/include/isl/union_map.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/union_map.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/union_map.h (original)
+++ polly/trunk/lib/External/isl/include/isl/union_map.h Thu Feb 16 23:11:16 2017
@@ -224,8 +224,8 @@ int isl_union_map_n_map(__isl_keep isl_u
 __isl_export
 isl_stat isl_union_map_foreach_map(__isl_keep isl_union_map *umap,
 	isl_stat (*fn)(__isl_take isl_map *map, void *user), void *user);
-__isl_give int isl_union_map_contains(__isl_keep isl_union_map *umap,
-	__isl_keep isl_space *dim);
+isl_bool isl_union_map_contains(__isl_keep isl_union_map *umap,
+	__isl_keep isl_space *space);
 __isl_give isl_map *isl_union_map_extract_map(__isl_keep isl_union_map *umap,
 	__isl_take isl_space *dim);
 __isl_give isl_map *isl_map_from_union_map(__isl_take isl_union_map *umap);

Modified: polly/trunk/lib/External/isl/include/isl/union_set.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/include/isl/union_set.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/include/isl/union_set.h (original)
+++ polly/trunk/lib/External/isl/include/isl/union_set.h Thu Feb 16 23:11:16 2017
@@ -114,8 +114,8 @@ int isl_union_set_n_set(__isl_keep isl_u
 __isl_export
 isl_stat isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
 	isl_stat (*fn)(__isl_take isl_set *set, void *user), void *user);
-__isl_give int isl_union_set_contains(__isl_keep isl_union_set *uset,
-	__isl_keep isl_space *dim);
+isl_bool isl_union_set_contains(__isl_keep isl_union_set *uset,
+	__isl_keep isl_space *space);
 __isl_give isl_set *isl_union_set_extract_set(__isl_keep isl_union_set *uset,
 	__isl_take isl_space *dim);
 __isl_give isl_set *isl_set_from_union_set(__isl_take isl_union_set *uset);

Modified: polly/trunk/lib/External/isl/isl_aff.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_aff.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_aff.c (original)
+++ polly/trunk/lib/External/isl/isl_aff.c Thu Feb 16 23:11:16 2017
@@ -401,7 +401,7 @@ __isl_give isl_aff *isl_aff_reset_space_
 }
 
 /* Reorder the coefficients of the affine expression based
- * on the given reodering.
+ * on the given reordering.
  * The reordering r is assumed to have been extended with the local
  * variables.
  */
@@ -509,26 +509,6 @@ isl_bool isl_aff_is_nan(__isl_keep isl_a
 	return isl_seq_first_non_zero(aff->v->el, 2) < 0;
 }
 
-/* Does "pa" involve any NaNs?
- */
-isl_bool isl_pw_aff_involves_nan(__isl_keep isl_pw_aff *pa)
-{
-	int i;
-
-	if (!pa)
-		return isl_bool_error;
-	if (pa->n == 0)
-		return isl_bool_false;
-
-	for (i = 0; i < pa->n; ++i) {
-		isl_bool is_nan = isl_aff_is_nan(pa->p[i].aff);
-		if (is_nan < 0 || is_nan)
-			return is_nan;
-	}
-
-	return isl_bool_false;
-}
-
 /* Are "aff1" and "aff2" obviously equal?
  *
  * NaN is not equal to anything, not even to another NaN.
@@ -555,15 +535,15 @@ isl_bool isl_aff_plain_is_equal(__isl_ke
  *
  * We cannot return anything meaningful in case of a NaN.
  */
-int isl_aff_get_denominator(__isl_keep isl_aff *aff, isl_int *v)
+isl_stat isl_aff_get_denominator(__isl_keep isl_aff *aff, isl_int *v)
 {
 	if (!aff)
-		return -1;
+		return isl_stat_error;
 	if (isl_aff_is_nan(aff))
 		isl_die(isl_aff_get_ctx(aff), isl_error_invalid,
-			"cannot get denominator of NaN", return -1);
+			"cannot get denominator of NaN", return isl_stat_error);
 	isl_int_set(*v, aff->v->el[0]);
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Return the common denominator of "aff".
@@ -1529,6 +1509,8 @@ __isl_give isl_aff *isl_aff_normalize(__
  * create a new div d = [r/m] and return the expression q + d.
  * The coefficients in r are taken to lie between -m/2 and m/2.
  *
+ * reduce_div_coefficients performs the same normalization.
+ *
  * As a special case, floor(NaN) = NaN.
  */
 __isl_give isl_aff *isl_aff_floor(__isl_take isl_aff *aff)
@@ -2588,6 +2570,8 @@ __isl_give isl_pw_aff *isl_pw_aff_from_a
 	return isl_pw_aff_alloc(dom, aff);
 }
 
+#define isl_aff_involves_nan isl_aff_is_nan
+
 #undef PW
 #define PW isl_pw_aff
 #undef EL
@@ -2803,7 +2787,7 @@ static __isl_give isl_set *pw_aff_locus(
 	for (i = 0; i < pwaff->n; ++i) {
 		isl_basic_set *bset;
 		isl_set *set_i, *locus;
-		int rational;
+		isl_bool rational;
 
 		if (isl_aff_is_nan(pwaff->p[i].aff))
 			continue;
@@ -3677,14 +3661,14 @@ __isl_give isl_pw_aff_list *isl_pw_aff_l
 
 /* Do the parameters of "aff" match those of "space"?
  */
-int isl_aff_matching_params(__isl_keep isl_aff *aff,
+isl_bool isl_aff_matching_params(__isl_keep isl_aff *aff,
 	__isl_keep isl_space *space)
 {
 	isl_space *aff_space;
-	int match;
+	isl_bool match;
 
 	if (!aff || !space)
-		return -1;
+		return isl_bool_error;
 
 	aff_space = isl_aff_get_domain_space(aff);
 
@@ -3695,17 +3679,15 @@ int isl_aff_matching_params(__isl_keep i
 }
 
 /* Check that the domain space of "aff" matches "space".
- *
- * Return 0 on success and -1 on error.
  */
-int isl_aff_check_match_domain_space(__isl_keep isl_aff *aff,
+isl_stat isl_aff_check_match_domain_space(__isl_keep isl_aff *aff,
 	__isl_keep isl_space *space)
 {
 	isl_space *aff_space;
-	int match;
+	isl_bool match;
 
 	if (!aff || !space)
-		return -1;
+		return isl_stat_error;
 
 	aff_space = isl_aff_get_domain_space(aff);
 
@@ -3723,10 +3705,10 @@ int isl_aff_check_match_domain_space(__i
 		isl_die(isl_aff_get_ctx(aff), isl_error_invalid,
 			"domains don't match", goto error);
 	isl_space_free(aff_space);
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_space_free(aff_space);
-	return -1;
+	return isl_stat_error;
 }
 
 #undef BASE
@@ -4649,9 +4631,11 @@ static __isl_give isl_pw_multi_aff *pw_m
 	int n;
 	int n_in;
 	isl_pw_multi_aff *pma;
-	int is_set;
+	isl_bool is_set;
 
 	is_set = isl_map_is_set(map);
+	if (is_set < 0)
+		goto error;
 
 	offset = isl_basic_map_offset(hull, isl_dim_out);
 	ctx = isl_map_get_ctx(map);
@@ -4685,6 +4669,10 @@ static __isl_give isl_pw_multi_aff *pw_m
 	pma = isl_pw_multi_aff_pullback_multi_aff(pma, ma);
 
 	return pma;
+error:
+	isl_map_free(map);
+	isl_basic_map_free(hull);
+	return NULL;
 }
 
 /* Is constraint "c" of the form
@@ -4920,9 +4908,11 @@ static __isl_give isl_pw_multi_aff *pw_m
 	unsigned n_in;
 	unsigned o_out;
 	unsigned n_out;
-	int is_set;
+	isl_bool is_set;
 
 	is_set = isl_map_is_set(map);
+	if (is_set < 0)
+		goto error;
 
 	n_in = isl_basic_map_dim(hull, isl_dim_in);
 	n_out = isl_basic_map_dim(hull, isl_dim_out);
@@ -4968,6 +4958,10 @@ static __isl_give isl_pw_multi_aff *pw_m
 
 	isl_basic_map_free(hull);
 	return pma;
+error:
+	isl_map_free(map);
+	isl_basic_map_free(hull);
+	return NULL;
 }
 
 /* Try and create an isl_pw_multi_aff that is equivalent to the given isl_map.
@@ -6048,14 +6042,14 @@ error:
 
 /* Do the parameters of "pa" match those of "space"?
  */
-int isl_pw_aff_matching_params(__isl_keep isl_pw_aff *pa,
+isl_bool isl_pw_aff_matching_params(__isl_keep isl_pw_aff *pa,
 	__isl_keep isl_space *space)
 {
 	isl_space *pa_space;
-	int match;
+	isl_bool match;
 
 	if (!pa || !space)
-		return -1;
+		return isl_bool_error;
 
 	pa_space = isl_pw_aff_get_space(pa);
 
@@ -6066,17 +6060,15 @@ int isl_pw_aff_matching_params(__isl_kee
 }
 
 /* Check that the domain space of "pa" matches "space".
- *
- * Return 0 on success and -1 on error.
  */
-int isl_pw_aff_check_match_domain_space(__isl_keep isl_pw_aff *pa,
+isl_stat isl_pw_aff_check_match_domain_space(__isl_keep isl_pw_aff *pa,
 	__isl_keep isl_space *space)
 {
 	isl_space *pa_space;
-	int match;
+	isl_bool match;
 
 	if (!pa || !space)
-		return -1;
+		return isl_stat_error;
 
 	pa_space = isl_pw_aff_get_space(pa);
 
@@ -6094,10 +6086,10 @@ int isl_pw_aff_check_match_domain_space(
 		isl_die(isl_pw_aff_get_ctx(pa), isl_error_invalid,
 			"domains don't match", goto error);
 	isl_space_free(pa_space);
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_space_free(pa_space);
-	return -1;
+	return isl_stat_error;
 }
 
 #undef BASE
@@ -6416,14 +6408,15 @@ __isl_give isl_multi_pw_aff *isl_multi_p
  * not to be the same.  A NaN is not equal to anything, not even
  * to another NaN.
  */
-int isl_pw_aff_is_equal(__isl_keep isl_pw_aff *pa1, __isl_keep isl_pw_aff *pa2)
+isl_bool isl_pw_aff_is_equal(__isl_keep isl_pw_aff *pa1,
+	__isl_keep isl_pw_aff *pa2)
 {
-	int equal;
+	isl_bool equal;
 	isl_bool has_nan;
 	isl_map *map1, *map2;
 
 	if (!pa1 || !pa2)
-		return -1;
+		return isl_bool_error;
 
 	equal = isl_pw_aff_plain_is_equal(pa1, pa2);
 	if (equal < 0 || equal)
@@ -6432,9 +6425,9 @@ int isl_pw_aff_is_equal(__isl_keep isl_p
 	if (has_nan >= 0 && !has_nan)
 		has_nan = isl_pw_aff_involves_nan(pa2);
 	if (has_nan < 0)
-		return -1;
+		return isl_bool_error;
 	if (has_nan)
-		return 0;
+		return isl_bool_false;
 
 	map1 = map_from_pw_aff(isl_pw_aff_copy(pa1));
 	map2 = map_from_pw_aff(isl_pw_aff_copy(pa2));
@@ -6491,6 +6484,43 @@ isl_bool isl_multi_pw_aff_is_equal(__isl
 	return isl_bool_true;
 }
 
+/* Do "pma1" and "pma2" represent the same function?
+ *
+ * First check if they are obviously equal.
+ * If not, then convert them to maps and check if those are equal.
+ *
+ * If "pa1" or "pa2" contain any NaNs, then they are considered
+ * not to be the same.  A NaN is not equal to anything, not even
+ * to another NaN.
+ */
+isl_bool isl_pw_multi_aff_is_equal(__isl_keep isl_pw_multi_aff *pma1,
+	__isl_keep isl_pw_multi_aff *pma2)
+{
+	isl_bool equal;
+	isl_bool has_nan;
+	isl_map *map1, *map2;
+
+	if (!pma1 || !pma2)
+		return isl_bool_error;
+
+	equal = isl_pw_multi_aff_plain_is_equal(pma1, pma2);
+	if (equal < 0 || equal)
+		return equal;
+	has_nan = isl_pw_multi_aff_involves_nan(pma1);
+	if (has_nan >= 0 && !has_nan)
+		has_nan = isl_pw_multi_aff_involves_nan(pma2);
+	if (has_nan < 0 || has_nan)
+		return isl_bool_not(has_nan);
+
+	map1 = isl_map_from_pw_multi_aff(isl_pw_multi_aff_copy(pma1));
+	map2 = isl_map_from_pw_multi_aff(isl_pw_multi_aff_copy(pma2));
+	equal = isl_map_is_equal(map1, map2);
+	isl_map_free(map1);
+	isl_map_free(map2);
+
+	return equal;
+}
+
 /* Compute the pullback of "mpa" by the function represented by "ma".
  * In other words, plug in "ma" in "mpa".
  *
@@ -7241,8 +7271,6 @@ isl_union_pw_multi_aff_pullback_union_pw
 
 /* Check that the domain space of "upa" matches "space".
  *
- * Return 0 on success and -1 on error.
- *
  * This function is called from isl_multi_union_pw_aff_set_union_pw_aff and
  * can in principle never fail since the space "space" is that
  * of the isl_multi_union_pw_aff and is a set space such that
@@ -7251,18 +7279,18 @@ isl_union_pw_multi_aff_pullback_union_pw
  * We check the parameters and double-check that "space" is
  * indeed that of a set.
  */
-static int isl_union_pw_aff_check_match_domain_space(
+static isl_stat isl_union_pw_aff_check_match_domain_space(
 	__isl_keep isl_union_pw_aff *upa, __isl_keep isl_space *space)
 {
 	isl_space *upa_space;
-	int match;
+	isl_bool match;
 
 	if (!upa || !space)
-		return -1;
+		return isl_stat_error;
 
 	match = isl_space_is_set(space);
 	if (match < 0)
-		return -1;
+		return isl_stat_error;
 	if (!match)
 		isl_die(isl_space_get_ctx(space), isl_error_invalid,
 			"expecting set space", return -1);
@@ -7276,22 +7304,22 @@ static int isl_union_pw_aff_check_match_
 			"parameters don't match", goto error);
 
 	isl_space_free(upa_space);
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_space_free(upa_space);
-	return -1;
+	return isl_stat_error;
 }
 
 /* Do the parameters of "upa" match those of "space"?
  */
-static int isl_union_pw_aff_matching_params(__isl_keep isl_union_pw_aff *upa,
-	__isl_keep isl_space *space)
+static isl_bool isl_union_pw_aff_matching_params(
+	__isl_keep isl_union_pw_aff *upa, __isl_keep isl_space *space)
 {
 	isl_space *upa_space;
-	int match;
+	isl_bool match;
 
 	if (!upa || !space)
-		return -1;
+		return isl_bool_error;
 
 	upa_space = isl_union_pw_aff_get_space(upa);
 
@@ -7337,7 +7365,7 @@ static __isl_give isl_union_pw_aff *isl_
 	__isl_take isl_union_pw_aff *upa, __isl_take isl_space *space)
 {
 	struct isl_union_pw_aff_reset_params_data data = { space };
-	int match;
+	isl_bool match;
 
 	match = isl_union_pw_aff_matching_params(upa, space);
 	if (match < 0)

Modified: polly/trunk/lib/External/isl/isl_aff_private.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_aff_private.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_aff_private.h (original)
+++ polly/trunk/lib/External/isl/isl_aff_private.h Thu Feb 16 23:11:16 2017
@@ -107,9 +107,9 @@ __isl_give isl_pw_aff *isl_pw_aff_scale(
 __isl_give isl_pw_aff *isl_pw_aff_scale_down(__isl_take isl_pw_aff *pwaff,
 	isl_int f);
 
-int isl_aff_matching_params(__isl_keep isl_aff *aff,
+isl_bool isl_aff_matching_params(__isl_keep isl_aff *aff,
 	__isl_keep isl_space *space);
-int isl_aff_check_match_domain_space(__isl_keep isl_aff *aff,
+isl_stat isl_aff_check_match_domain_space(__isl_keep isl_aff *aff,
 	__isl_keep isl_space *space);
 
 #undef BASE
@@ -149,9 +149,9 @@ __isl_give isl_pw_multi_aff *isl_pw_mult
 	__isl_take isl_pw_multi_aff *pma, enum isl_dim_type type, unsigned pos,
 	__isl_keep isl_pw_aff *subs);
 
-int isl_pw_aff_matching_params(__isl_keep isl_pw_aff *pa,
+isl_bool isl_pw_aff_matching_params(__isl_keep isl_pw_aff *pa,
 	__isl_keep isl_space *space);
-int isl_pw_aff_check_match_domain_space(__isl_keep isl_pw_aff *pa,
+isl_stat isl_pw_aff_check_match_domain_space(__isl_keep isl_pw_aff *pa,
 	__isl_keep isl_space *space);
 
 #undef BASE

Modified: polly/trunk/lib/External/isl/isl_ast_build.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_ast_build.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_ast_build.c (original)
+++ polly/trunk/lib/External/isl/isl_ast_build.c Thu Feb 16 23:11:16 2017
@@ -842,7 +842,7 @@ __isl_give isl_ast_build *isl_ast_build_
 	build = update_values(build, isl_basic_set_copy(bounds));
 	if (!build)
 		goto error;
-	set = isl_set_from_basic_set(bounds);
+	set = isl_set_from_basic_set(isl_basic_set_copy(bounds));
 	if (isl_ast_build_has_affine_value(build, build->depth)) {
 		set = isl_set_eliminate(set, isl_dim_set, build->depth, 1);
 		set = isl_set_compute_divs(set);
@@ -855,6 +855,7 @@ __isl_give isl_ast_build *isl_ast_build_
 		if (!build)
 			goto error;
 	}
+	isl_basic_set_free(bounds);
 
 	if (!build->domain || !build->pending || !build->generated)
 		return isl_ast_build_free(build);

Modified: polly/trunk/lib/External/isl/isl_bernstein.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_bernstein.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_bernstein.c (original)
+++ polly/trunk/lib/External/isl/isl_bernstein.c Thu Feb 16 23:11:16 2017
@@ -242,7 +242,8 @@ error:
  * and the constant "1 = \sum_i \alpha_i" for the homogeneous dimension.
  * Next, we extract the coefficients of the Bernstein base polynomials.
  */
-static int bernstein_coefficients_cell(__isl_take isl_cell *cell, void *user)
+static isl_stat bernstein_coefficients_cell(__isl_take isl_cell *cell,
+	void *user)
 {
 	int i, j;
 	struct bernstein_data *data = (struct bernstein_data *)user;
@@ -319,10 +320,10 @@ static int bernstein_coefficients_cell(_
 	for (i = 0; i < 1 + nvar; ++i)
 		isl_qpolynomial_free(subs[i]);
 	free(subs);
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_cell_free(cell);
-	return -1;
+	return isl_stat_error;
 }
 
 /* Base case of applying bernstein expansion.
@@ -373,8 +374,9 @@ static __isl_give isl_pw_qpolynomial_fol
 	data->pwf_tight = isl_pw_qpolynomial_fold_zero(dim, data->type);
 	data->poly = isl_qpolynomial_homogenize(isl_qpolynomial_copy(poly));
 	vertices = isl_basic_set_compute_vertices(bset);
-	isl_vertices_foreach_disjoint_cell(vertices,
-		&bernstein_coefficients_cell, data);
+	if (isl_vertices_foreach_disjoint_cell(vertices,
+					&bernstein_coefficients_cell, data) < 0)
+		data->pwf = isl_pw_qpolynomial_fold_free(data->pwf);
 	isl_vertices_free(vertices);
 	isl_qpolynomial_free(data->poly);
 
@@ -517,8 +519,9 @@ error:
  * bernstein expansion recursively on each dimension.
  * Otherwise, we apply bernstein expansion on the entire polytope.
  */
-int isl_qpolynomial_bound_on_domain_bernstein(__isl_take isl_basic_set *bset,
-	__isl_take isl_qpolynomial *poly, struct isl_bound *bound)
+isl_stat isl_qpolynomial_bound_on_domain_bernstein(
+	__isl_take isl_basic_set *bset, __isl_take isl_qpolynomial *poly,
+	struct isl_bound *bound)
 {
 	struct bernstein_data data;
 	isl_pw_qpolynomial_fold *pwf;
@@ -547,9 +550,9 @@ int isl_qpolynomial_bound_on_domain_bern
 	else
 		bound->pwf = isl_pw_qpolynomial_fold_fold(bound->pwf, pwf);
 
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_basic_set_free(bset);
 	isl_qpolynomial_free(poly);
-	return -1;
+	return isl_stat_error;
 }

Modified: polly/trunk/lib/External/isl/isl_bernstein.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_bernstein.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_bernstein.h (original)
+++ polly/trunk/lib/External/isl/isl_bernstein.h Thu Feb 16 23:11:16 2017
@@ -1,4 +1,5 @@
 #include <isl_bound.h>
 
-int isl_qpolynomial_bound_on_domain_bernstein(__isl_take isl_basic_set *bset,
-	__isl_take isl_qpolynomial *poly, struct isl_bound *bound);
+isl_stat isl_qpolynomial_bound_on_domain_bernstein(
+	__isl_take isl_basic_set *bset, __isl_take isl_qpolynomial *poly,
+	struct isl_bound *bound);

Modified: polly/trunk/lib/External/isl/isl_bound.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_bound.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_bound.c (original)
+++ polly/trunk/lib/External/isl/isl_bound.c Thu Feb 16 23:11:16 2017
@@ -23,7 +23,7 @@
  * range propagation on unbounded domains.  Otherwise, we respect the choice
  * of the user.
  */
-static int compressed_guarded_poly_bound(__isl_take isl_basic_set *bset,
+static isl_stat compressed_guarded_poly_bound(__isl_take isl_basic_set *bset,
 	__isl_take isl_qpolynomial *poly, void *user)
 {
 	struct isl_bound *bound = (struct isl_bound *)user;
@@ -48,7 +48,7 @@ error:
 	return -1;
 }
 
-static int unwrapped_guarded_poly_bound(__isl_take isl_basic_set *bset,
+static isl_stat unwrapped_guarded_poly_bound(__isl_take isl_basic_set *bset,
 	__isl_take isl_qpolynomial *poly, void *user)
 {
 	struct isl_bound *bound = (struct isl_bound *)user;
@@ -56,7 +56,7 @@ static int unwrapped_guarded_poly_bound(
 	isl_pw_qpolynomial_fold *top_pwf_tight;
 	isl_space *dim;
 	isl_morph *morph;
-	int r;
+	isl_stat r;
 
 	bset = isl_basic_set_detect_equalities(bset);
 
@@ -102,10 +102,10 @@ static int unwrapped_guarded_poly_bound(
 error:
 	isl_basic_set_free(bset);
 	isl_qpolynomial_free(poly);
-	return -1;
+	return isl_stat_error;
 }
 
-static int guarded_poly_bound(__isl_take isl_basic_set *bset,
+static isl_stat guarded_poly_bound(__isl_take isl_basic_set *bset,
 	__isl_take isl_qpolynomial *poly, void *user)
 {
 	struct isl_bound *bound = (struct isl_bound *)user;
@@ -114,7 +114,7 @@ static int guarded_poly_bound(__isl_take
 	isl_pw_qpolynomial_fold *top_pwf_tight;
 	int nparam;
 	int n_in;
-	int r;
+	isl_stat r;
 
 	if (!bound->wrapping)
 		return unwrapped_guarded_poly_bound(bset, poly, user);

Modified: polly/trunk/lib/External/isl/isl_coalesce.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_coalesce.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_coalesce.c (original)
+++ polly/trunk/lib/External/isl/isl_coalesce.c Thu Feb 16 23:11:16 2017
@@ -80,9 +80,6 @@ static int *eq_status_in(__isl_keep isl_
 			if (eq[2 * k + l] == STATUS_ERROR)
 				goto error;
 		}
-		if (eq[2 * k] == STATUS_SEPARATE ||
-		    eq[2 * k + 1] == STATUS_SEPARATE)
-			break;
 	}
 
 	return eq;
@@ -568,7 +565,7 @@ static enum isl_change check_facets(int
  * (as an inequality) and its negation.  Make sure the
  * equality is returned to its original state before returning.
  */
-static int contains(struct isl_coalesce_info *info, struct isl_tab *tab)
+static isl_bool contains(struct isl_coalesce_info *info, struct isl_tab *tab)
 {
 	int k;
 	unsigned dim;
@@ -581,14 +578,14 @@ static int contains(struct isl_coalesce_
 		stat = status_in(bmap->eq[k], tab);
 		isl_seq_neg(bmap->eq[k], bmap->eq[k], 1 + dim);
 		if (stat < 0)
-			return -1;
+			return isl_bool_error;
 		if (stat != STATUS_VALID)
-			return 0;
+			return isl_bool_false;
 		stat = status_in(bmap->eq[k], tab);
 		if (stat < 0)
-			return -1;
+			return isl_bool_error;
 		if (stat != STATUS_VALID)
-			return 0;
+			return isl_bool_false;
 	}
 
 	for (k = 0; k < bmap->n_ineq; ++k) {
@@ -597,11 +594,11 @@ static int contains(struct isl_coalesce_
 			continue;
 		stat = status_in(bmap->ineq[k], tab);
 		if (stat < 0)
-			return -1;
+			return isl_bool_error;
 		if (stat != STATUS_VALID)
-			return 0;
+			return isl_bool_false;
 	}
-	return 1;
+	return isl_bool_true;
 }
 
 /* Basic map "i" has an inequality (say "k") that is adjacent
@@ -651,8 +648,8 @@ static enum isl_change is_adj_ineq_exten
 	struct isl_tab_undo *snap;
 	unsigned n_eq = info[i].bmap->n_eq;
 	unsigned total = isl_basic_map_total_dim(info[i].bmap);
-	int r;
-	int super;
+	isl_stat r;
+	isl_bool super;
 
 	if (isl_tab_extend_cons(info[i].tab, 1 + info[j].bmap->n_ineq) < 0)
 		return isl_change_error;
@@ -797,8 +794,8 @@ static int not_unique_unit_row(__isl_kee
  * "total" is the total number of variables, i.e., the number
  * of entries in "affected".
  */
-static int is_affected(__isl_keep isl_basic_map *bmap, int ineq, int *affected,
-	int total)
+static isl_bool is_affected(__isl_keep isl_basic_map *bmap, int ineq,
+	int *affected, int total)
 {
 	int i;
 
@@ -806,10 +803,10 @@ static int is_affected(__isl_keep isl_ba
 		if (!affected[i])
 			continue;
 		if (!isl_int_is_zero(bmap->ineq[ineq][1 + i]))
-			return 1;
+			return isl_bool_true;
 	}
 
-	return 0;
+	return isl_bool_false;
 }
 
 /* Given the compressed version of inequality constraint "ineq"
@@ -836,7 +833,7 @@ static __isl_give isl_vec *try_tightenin
 	int ineq, __isl_take isl_vec *v)
 {
 	isl_ctx *ctx;
-	int r;
+	isl_stat r;
 
 	if (!v)
 		return NULL;
@@ -941,11 +938,15 @@ static isl_stat tighten_on_relaxed_facet
 		affected[i] = not_unique_unit_row(T, 1 + i);
 
 	for (i = 0; i < info->bmap->n_ineq; ++i) {
+		isl_bool handle;
 		if (any(relaxed, n, i))
 			continue;
 		if (info->ineq[i] == STATUS_REDUNDANT)
 			continue;
-		if (!is_affected(info->bmap, i, affected, total))
+		handle = is_affected(info->bmap, i, affected, total);
+		if (handle < 0)
+			goto error;
+		if (!handle)
 			continue;
 		v = isl_vec_alloc(ctx, 1 + total);
 		if (!v)
@@ -1041,7 +1042,7 @@ static enum isl_change is_relaxed_extens
 	struct isl_coalesce_info *info)
 {
 	int l;
-	int super;
+	isl_bool super;
 	struct isl_tab_undo *snap, *snap2;
 	unsigned n_eq = info[i].bmap->n_eq;
 
@@ -1093,7 +1094,7 @@ struct isl_wraps {
  * in the equalities and inequalities of info->bmap that can be removed
  * if we end up applying wrapping.
  */
-static void wraps_update_max(struct isl_wraps *wraps,
+static isl_stat wraps_update_max(struct isl_wraps *wraps,
 	struct isl_coalesce_info *info)
 {
 	int k;
@@ -1121,6 +1122,8 @@ static void wraps_update_max(struct isl_
 	}
 
 	isl_int_clear(max_k);
+
+	return isl_stat_ok;
 }
 
 /* Initialize the isl_wraps data structure.
@@ -1129,7 +1132,7 @@ static void wraps_update_max(struct isl_
  * in the equalities and inequalities that can be removed if we end up
  * applying wrapping.
  */
-static void wraps_init(struct isl_wraps *wraps, __isl_take isl_mat *mat,
+static isl_stat wraps_init(struct isl_wraps *wraps, __isl_take isl_mat *mat,
 	struct isl_coalesce_info *info, int i, int j)
 {
 	isl_ctx *ctx;
@@ -1137,15 +1140,19 @@ static void wraps_init(struct isl_wraps
 	wraps->bound = 0;
 	wraps->mat = mat;
 	if (!mat)
-		return;
+		return isl_stat_error;
 	ctx = isl_mat_get_ctx(mat);
 	wraps->bound = isl_options_get_coalesce_bounded_wrapping(ctx);
 	if (!wraps->bound)
-		return;
+		return isl_stat_ok;
 	isl_int_init(wraps->max);
 	isl_int_set_si(wraps->max, 0);
-	wraps_update_max(wraps, &info[i]);
-	wraps_update_max(wraps, &info[j]);
+	if (wraps_update_max(wraps, &info[i]) < 0)
+		return isl_stat_error;
+	if (wraps_update_max(wraps, &info[j]) < 0)
+		return isl_stat_error;
+
+	return isl_stat_ok;
 }
 
 /* Free the contents of the isl_wraps data structure.
@@ -1221,8 +1228,8 @@ static int add_wrap(struct isl_wraps *wr
  * constraints and a newly added wrapping constraint does not
  * satisfy the bound, then wraps->n_row is also reset to zero.
  */
-static int add_wraps(struct isl_wraps *wraps, struct isl_coalesce_info *info,
-	isl_int *bound, __isl_keep isl_set *set)
+static isl_stat add_wraps(struct isl_wraps *wraps,
+	struct isl_coalesce_info *info, isl_int *bound, __isl_keep isl_set *set)
 {
 	int l, m;
 	int w;
@@ -1245,7 +1252,7 @@ static int add_wraps(struct isl_wraps *w
 
 		added = add_wrap(wraps, w, bound, bmap->ineq[l], len, set, 0);
 		if (added < 0)
-			return -1;
+			return isl_stat_error;
 		if (!added)
 			goto unbounded;
 		++w;
@@ -1262,7 +1269,7 @@ static int add_wraps(struct isl_wraps *w
 			added = add_wrap(wraps, w, bound, bmap->eq[l], len,
 					set, !m);
 			if (added < 0)
-				return -1;
+				return isl_stat_error;
 			if (!added)
 				goto unbounded;
 			++w;
@@ -1270,10 +1277,10 @@ static int add_wraps(struct isl_wraps *w
 	}
 
 	wraps->mat->n_row = w;
-	return 0;
+	return isl_stat_ok;
 unbounded:
 	wraps->mat->n_row = 0;
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Check if the constraints in "wraps" from "first" until the last
@@ -1335,7 +1342,7 @@ static __isl_give isl_set *set_from_upda
  * If any of the wrapped constraints turn out to be invalid, then
  * check_wraps will reset wrap->n_row to zero.
  */
-static int add_wraps_around_facet(struct isl_wraps *wraps,
+static isl_stat add_wraps_around_facet(struct isl_wraps *wraps,
 	struct isl_coalesce_info *info, int k, isl_int *bound,
 	__isl_keep isl_set *set)
 {
@@ -1346,22 +1353,22 @@ static int add_wraps_around_facet(struct
 	snap = isl_tab_snap(info->tab);
 
 	if (isl_tab_select_facet(info->tab, info->bmap->n_eq + k) < 0)
-		return -1;
+		return isl_stat_error;
 	if (isl_tab_detect_redundant(info->tab) < 0)
-		return -1;
+		return isl_stat_error;
 
 	isl_seq_neg(bound, info->bmap->ineq[k], 1 + total);
 
 	n = wraps->mat->n_row;
 	if (add_wraps(wraps, info, bound, set) < 0)
-		return -1;
+		return isl_stat_error;
 
 	if (isl_tab_rollback(info->tab, snap) < 0)
-		return -1;
+		return isl_stat_error;
 	if (check_wraps(wraps->mat, n, info->tab) < 0)
-		return -1;
+		return isl_stat_error;
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Given a basic set i with a constraint k that is adjacent to
@@ -1403,9 +1410,10 @@ static enum isl_change can_wrap_in_facet
 	mat = isl_mat_alloc(ctx, 2 * (info[i].bmap->n_eq + info[j].bmap->n_eq) +
 				    info[i].bmap->n_ineq + info[j].bmap->n_ineq,
 				    1 + total);
-	wraps_init(&wraps, mat, info, i, j);
+	if (wraps_init(&wraps, mat, info, i, j) < 0)
+		goto error;
 	bound = isl_vec_alloc(ctx, 1 + total);
-	if (!set_i || !set_j || !wraps.mat || !bound)
+	if (!set_i || !set_j || !bound)
 		goto error;
 
 	isl_seq_cpy(bound->el, info[i].bmap->ineq[k], 1 + total);
@@ -1585,8 +1593,9 @@ static enum isl_change wrap_in_facets(in
 	set_i = set_from_updated_bmap(info[i].bmap, info[i].tab);
 	ctx = isl_basic_map_get_ctx(info[i].bmap);
 	mat = isl_mat_alloc(ctx, max_wrap, 1 + total);
-	wraps_init(&wraps, mat, info, i, j);
-	if (!set_i || !wraps.mat)
+	if (wraps_init(&wraps, mat, info, i, j) < 0)
+		goto error;
+	if (!set_i)
 		goto error;
 
 	change = try_wrap_in_facets(i, j, info, &wraps, set_i);
@@ -1909,9 +1918,10 @@ static enum isl_change check_eq_adj_eq(i
 	mat = isl_mat_alloc(ctx, 2 * (info[i].bmap->n_eq + info[j].bmap->n_eq) +
 				    info[i].bmap->n_ineq + info[j].bmap->n_ineq,
 				    1 + total);
-	wraps_init(&wraps, mat, info, i, j);
+	if (wraps_init(&wraps, mat, info, i, j) < 0)
+		goto error;
 	bound = isl_vec_alloc(ctx, 1 + total);
-	if (!set_i || !set_j || !wraps.mat || !bound)
+	if (!set_i || !set_j || !bound)
 		goto error;
 
 	if (k % 2 == 0)
@@ -1996,6 +2006,56 @@ static void clear_status(struct isl_coal
 	free(info->ineq);
 }
 
+/* Are all inequality constraints of the basic map represented by "info"
+ * valid for the other basic map, except for a single constraint
+ * that is adjacent to an inequality constraint of the other basic map?
+ */
+static int all_ineq_valid_or_single_adj_ineq(struct isl_coalesce_info *info)
+{
+	int i;
+	int k = -1;
+
+	for (i = 0; i < info->bmap->n_ineq; ++i) {
+		if (info->ineq[i] == STATUS_REDUNDANT)
+			continue;
+		if (info->ineq[i] == STATUS_VALID)
+			continue;
+		if (info->ineq[i] != STATUS_ADJ_INEQ)
+			return 0;
+		if (k != -1)
+			return 0;
+		k = i;
+	}
+
+	return k != -1;
+}
+
+/* Basic map "i" has one or more equality constraints that separate it
+ * from basic map "j".  Check if it happens to be an extension
+ * of basic map "j".
+ * In particular, check that all constraints of "j" are valid for "i",
+ * except for one inequality constraint that is adjacent
+ * to an inequality constraints of "i".
+ * If so, check for "i" being an extension of "j" by calling
+ * is_adj_ineq_extension.
+ *
+ * Clean up the memory allocated for keeping track of the status
+ * of the constraints before returning.
+ */
+static enum isl_change separating_equality(int i, int j,
+	struct isl_coalesce_info *info)
+{
+	enum isl_change change = isl_change_none;
+
+	if (all(info[j].eq, 2 * info[j].bmap->n_eq, STATUS_VALID) &&
+	    all_ineq_valid_or_single_adj_ineq(&info[j]))
+		change = is_adj_ineq_extension(j, i, info);
+
+	clear_status(&info[i]);
+	clear_status(&info[j]);
+	return change;
+}
+
 /* Check if the union of the given pair of basic maps
  * can be represented by a single basic map.
  * If so, replace the pair by the single basic map and return
@@ -2087,22 +2147,6 @@ static enum isl_change coalesce_local_pa
 {
 	enum isl_change change = isl_change_none;
 
-	set_eq_status_in(&info[i], info[j].tab);
-	if (info[i].bmap->n_eq && !info[i].eq)
-		goto error;
-	if (any(info[i].eq, 2 * info[i].bmap->n_eq, STATUS_ERROR))
-		goto error;
-	if (any(info[i].eq, 2 * info[i].bmap->n_eq, STATUS_SEPARATE))
-		goto done;
-
-	set_eq_status_in(&info[j], info[i].tab);
-	if (info[j].bmap->n_eq && !info[j].eq)
-		goto error;
-	if (any(info[j].eq, 2 * info[j].bmap->n_eq, STATUS_ERROR))
-		goto error;
-	if (any(info[j].eq, 2 * info[j].bmap->n_eq, STATUS_SEPARATE))
-		goto done;
-
 	set_ineq_status_in(&info[i], info[j].tab);
 	if (info[i].bmap->n_ineq && !info[i].ineq)
 		goto error;
@@ -2119,6 +2163,23 @@ static enum isl_change coalesce_local_pa
 	if (any(info[j].ineq, info[j].bmap->n_ineq, STATUS_SEPARATE))
 		goto done;
 
+	set_eq_status_in(&info[i], info[j].tab);
+	if (info[i].bmap->n_eq && !info[i].eq)
+		goto error;
+	if (any(info[i].eq, 2 * info[i].bmap->n_eq, STATUS_ERROR))
+		goto error;
+
+	set_eq_status_in(&info[j], info[i].tab);
+	if (info[j].bmap->n_eq && !info[j].eq)
+		goto error;
+	if (any(info[j].eq, 2 * info[j].bmap->n_eq, STATUS_ERROR))
+		goto error;
+
+	if (any(info[i].eq, 2 * info[i].bmap->n_eq, STATUS_SEPARATE))
+		return separating_equality(i, j, info);
+	if (any(info[j].eq, 2 * info[j].bmap->n_eq, STATUS_SEPARATE))
+		return separating_equality(j, i, info);
+
 	if (all(info[i].eq, 2 * info[i].bmap->n_eq, STATUS_VALID) &&
 	    all(info[i].ineq, info[i].bmap->n_ineq, STATUS_VALID)) {
 		drop(&info[j]);
@@ -2279,9 +2340,7 @@ static isl_stat harmonize_stride_divs(st
 	struct isl_coalesce_info *info2)
 {
 	int i, n;
-	int total;
 
-	total = isl_basic_map_total_dim(info1->bmap);
 	n = isl_basic_map_dim(info1->bmap, isl_dim_div);
 	for (i = 0; i < n; ++i) {
 		isl_bool known, harmonize;
@@ -2446,10 +2505,16 @@ static isl_stat harmonize_divs_with_hull
  *
  * Then, extract the equality constraints and continue with
  * harmonize_divs_with_hulls.
+ *
+ * If the equality constraints of both basic maps are the same,
+ * then there is no need to perform any shifting since
+ * the coefficients of the integer divisions should have been
+ * reduced in the same way.
  */
 static isl_stat harmonize_divs(struct isl_coalesce_info *info1,
 	struct isl_coalesce_info *info2)
 {
+	isl_bool equal;
 	isl_basic_map *bmap1, *bmap2;
 	isl_basic_set *eq1, *eq2;
 	isl_stat r;
@@ -2469,7 +2534,13 @@ static isl_stat harmonize_divs(struct is
 	bmap2 = isl_basic_map_copy(info2->bmap);
 	eq1 = isl_basic_map_wrap(isl_basic_map_plain_affine_hull(bmap1));
 	eq2 = isl_basic_map_wrap(isl_basic_map_plain_affine_hull(bmap2));
-	r = harmonize_divs_with_hulls(info1, info2, eq1, eq2);
+	equal = isl_basic_set_plain_is_equal(eq1, eq2);
+	if (equal < 0)
+		r = isl_stat_error;
+	else if (equal)
+		r = isl_stat_ok;
+	else
+		r = harmonize_divs_with_hulls(info1, info2, eq1, eq2);
 	isl_basic_set_free(eq1);
 	isl_basic_set_free(eq2);
 
@@ -2481,20 +2552,20 @@ static isl_stat harmonize_divs(struct is
  * If either basic map has any unknown divs, then we can only assume
  * that they do not live in the same local space.
  */
-static int same_divs(__isl_keep isl_basic_map *bmap1,
+static isl_bool same_divs(__isl_keep isl_basic_map *bmap1,
 	__isl_keep isl_basic_map *bmap2)
 {
 	int i;
-	int known;
+	isl_bool known;
 	int total;
 
 	if (!bmap1 || !bmap2)
-		return -1;
+		return isl_bool_error;
 	if (bmap1->n_div != bmap2->n_div)
-		return 0;
+		return isl_bool_false;
 
 	if (bmap1->n_div == 0)
-		return 1;
+		return isl_bool_true;
 
 	known = isl_basic_map_divs_known(bmap1);
 	if (known < 0 || !known)
@@ -3093,7 +3164,7 @@ static enum isl_change coalesce_divs(int
 
 /* Does "bmap" involve any divs that themselves refer to divs?
  */
-static int has_nested_div(__isl_keep isl_basic_map *bmap)
+static isl_bool has_nested_div(__isl_keep isl_basic_map *bmap)
 {
 	int i;
 	unsigned total;
@@ -3106,9 +3177,9 @@ static int has_nested_div(__isl_keep isl
 	for (i = 0; i < n_div; ++i)
 		if (isl_seq_first_non_zero(bmap->div[i] + 2 + total,
 					    n_div) != -1)
-			return 1;
+			return isl_bool_true;
 
-	return 0;
+	return isl_bool_false;
 }
 
 /* Return a list of affine expressions, one for each integer division
@@ -3207,7 +3278,7 @@ error:
  * that is added later to result in constraints that do not hold
  * in the original input.
  */
-static int add_sub_vars(struct isl_coalesce_info *info,
+static isl_stat add_sub_vars(struct isl_coalesce_info *info,
 	__isl_keep isl_aff_list *list, int dim, int extra_var)
 {
 	int i, j, n, d;
@@ -3218,7 +3289,7 @@ static int add_sub_vars(struct isl_coale
 	info->bmap = isl_basic_map_extend_space(info->bmap, space,
 						extra_var, 0, 0);
 	if (!info->bmap)
-		return -1;
+		return isl_stat_error;
 	n = isl_aff_list_n_aff(list);
 	for (i = 0; i < n; ++i) {
 		int is_nan;
@@ -3228,23 +3299,23 @@ static int add_sub_vars(struct isl_coale
 		is_nan = isl_aff_is_nan(aff);
 		isl_aff_free(aff);
 		if (is_nan < 0)
-			return -1;
+			return isl_stat_error;
 		if (is_nan)
 			continue;
 
 		if (isl_tab_insert_var(info->tab, dim + i) < 0)
-			return -1;
+			return isl_stat_error;
 		d = isl_basic_map_alloc_div(info->bmap);
 		if (d < 0)
-			return -1;
+			return isl_stat_error;
 		info->bmap = isl_basic_map_mark_div_unknown(info->bmap, d);
 		if (!info->bmap)
-			return -1;
+			return isl_stat_error;
 		for (j = d; j > i; --j)
 			isl_basic_map_swap_div(info->bmap, j - 1, j);
 	}
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* For each element in "list" that is not set to NaN, fix the corresponding
@@ -3444,7 +3515,7 @@ error:
 static enum isl_change check_coalesce_eq(int i, int j,
 	struct isl_coalesce_info *info)
 {
-	int known, nested;
+	isl_bool known, nested;
 	enum isl_change change;
 
 	known = isl_basic_map_divs_known(info[i].bmap);
@@ -3487,7 +3558,7 @@ static enum isl_change check_coalesce_eq
 static enum isl_change coalesce_pair(int i, int j,
 	struct isl_coalesce_info *info)
 {
-	int same;
+	isl_bool same;
 	enum isl_change change;
 
 	if (harmonize_divs(&info[i], &info[j]) < 0)

Modified: polly/trunk/lib/External/isl/isl_config.h.in
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_config.h.in?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_config.h.in (original)
+++ polly/trunk/lib/External/isl/isl_config.h.in Thu Feb 16 23:11:16 2017
@@ -151,6 +151,9 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
+/* Defined if CompilerInstance::setInvocation takes a shared_ptr */
+#undef SETINVOCATION_TAKES_SHARED_PTR
+
 /* Define if CompilerInvocation::setLangDefaults takes 5 arguments */
 #undef SETLANGDEFAULTS_TAKES_5_ARGUMENTS
 

Modified: polly/trunk/lib/External/isl/isl_constraint.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_constraint.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_constraint.c (original)
+++ polly/trunk/lib/External/isl/isl_constraint.c Thu Feb 16 23:11:16 2017
@@ -773,9 +773,11 @@ int isl_constraint_is_div_constraint(__i
 		return 0;
 	n_div = isl_constraint_dim(constraint, isl_dim_div);
 	for (i = 0; i < n_div; ++i) {
-		if (isl_local_space_is_div_constraint(constraint->ls,
-							constraint->v->el, i))
-			return 1;
+		isl_bool is_div;
+		is_div = isl_local_space_is_div_constraint(constraint->ls,
+							constraint->v->el, i);
+		if (is_div < 0 || is_div)
+			return is_div;
 	}
 
 	return 0;
@@ -845,7 +847,7 @@ error:
  *
  * If so, and if c is not NULL, then return a copy of this equality in *c.
  */
-int isl_basic_map_has_defining_equality(
+isl_bool isl_basic_map_has_defining_equality(
 	__isl_keep isl_basic_map *bmap, enum isl_dim_type type, int pos,
 	__isl_give isl_constraint **c)
 {
@@ -854,10 +856,12 @@ int isl_basic_map_has_defining_equality(
 	unsigned total;
 
 	if (!bmap)
-		return -1;
+		return isl_bool_error;
 	offset = basic_map_offset(bmap, type);
 	total = isl_basic_map_total_dim(bmap);
-	isl_assert(bmap->ctx, pos < isl_basic_map_dim(bmap, type), return -1);
+	if (pos >= isl_basic_map_dim(bmap, type))
+		isl_die(isl_basic_map_get_ctx(bmap), isl_error_invalid,
+			"invalid position", return isl_bool_error);
 	for (i = 0; i < bmap->n_eq; ++i) {
 		if (isl_int_is_zero(bmap->eq[i][offset + pos]) ||
 		    isl_seq_first_non_zero(bmap->eq[i]+offset+pos+1,
@@ -866,9 +870,9 @@ int isl_basic_map_has_defining_equality(
 		if (c)
 			*c = isl_basic_map_constraint(isl_basic_map_copy(bmap),
 								&bmap->eq[i]);
-		return 1;
+		return isl_bool_true;
 	}
-	return 0;
+	return isl_bool_false;
 }
 
 /* Is the variable of "type" at position "pos" of "bset" defined
@@ -876,7 +880,7 @@ int isl_basic_map_has_defining_equality(
  *
  * If so, and if c is not NULL, then return a copy of this equality in *c.
  */
-int isl_basic_set_has_defining_equality(
+isl_bool isl_basic_set_has_defining_equality(
 	__isl_keep isl_basic_set *bset, enum isl_dim_type type, int pos,
 	__isl_give isl_constraint **c)
 {
@@ -884,7 +888,7 @@ int isl_basic_set_has_defining_equality(
 						    type, pos, c);
 }
 
-int isl_basic_set_has_defining_inequalities(
+isl_bool isl_basic_set_has_defining_inequalities(
 	struct isl_basic_set *bset, enum isl_dim_type type, int pos,
 	struct isl_constraint **lower,
 	struct isl_constraint **upper)
@@ -896,10 +900,12 @@ int isl_basic_set_has_defining_inequalit
 	isl_int **lower_line, **upper_line;
 
 	if (!bset)
-		return -1;
+		return isl_bool_error;
 	offset = basic_set_offset(bset, type);
 	total = isl_basic_set_total_dim(bset);
-	isl_assert(bset->ctx, pos < isl_basic_set_dim(bset, type), return -1);
+	if (pos >= isl_basic_set_dim(bset, type))
+		isl_die(isl_basic_set_get_ctx(bset), isl_error_invalid,
+			"invalid position", return isl_bool_error);
 	isl_int_init(m);
 	for (i = 0; i < bset->n_ineq; ++i) {
 		if (isl_int_is_zero(bset->ineq[i][offset + pos]))
@@ -931,13 +937,13 @@ int isl_basic_set_has_defining_inequalit
 			*upper = isl_basic_set_constraint(
 					isl_basic_set_copy(bset), upper_line);
 			isl_int_clear(m);
-			return 1;
+			return isl_bool_true;
 		}
 	}
 	*lower = NULL;
 	*upper = NULL;
 	isl_int_clear(m);
-	return 0;
+	return isl_bool_false;
 }
 
 /* Given two constraints "a" and "b" on the variable at position "abs_pos"

Modified: polly/trunk/lib/External/isl/isl_convex_hull.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_convex_hull.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_convex_hull.c (original)
+++ polly/trunk/lib/External/isl/isl_convex_hull.c Thu Feb 16 23:11:16 2017
@@ -922,15 +922,15 @@ error:
 
 /* Is the set bounded for each value of the parameters?
  */
-int isl_basic_set_is_bounded(__isl_keep isl_basic_set *bset)
+isl_bool isl_basic_set_is_bounded(__isl_keep isl_basic_set *bset)
 {
 	struct isl_tab *tab;
-	int bounded;
+	isl_bool bounded;
 
 	if (!bset)
-		return -1;
+		return isl_bool_error;
 	if (isl_basic_set_plain_is_empty(bset))
-		return 1;
+		return isl_bool_true;
 
 	tab = isl_tab_from_recession_cone(bset, 1);
 	bounded = isl_tab_cone_is_bounded(tab);
@@ -941,11 +941,11 @@ int isl_basic_set_is_bounded(__isl_keep
 /* Is the image bounded for each value of the parameters and
  * the domain variables?
  */
-int isl_basic_map_image_is_bounded(__isl_keep isl_basic_map *bmap)
+isl_bool isl_basic_map_image_is_bounded(__isl_keep isl_basic_map *bmap)
 {
 	unsigned nparam = isl_basic_map_dim(bmap, isl_dim_param);
 	unsigned n_in = isl_basic_map_dim(bmap, isl_dim_in);
-	int bounded;
+	isl_bool bounded;
 
 	bmap = isl_basic_map_copy(bmap);
 	bmap = isl_basic_map_cow(bmap);
@@ -959,19 +959,19 @@ int isl_basic_map_image_is_bounded(__isl
 
 /* Is the set bounded for each value of the parameters?
  */
-int isl_set_is_bounded(__isl_keep isl_set *set)
+isl_bool isl_set_is_bounded(__isl_keep isl_set *set)
 {
 	int i;
 
 	if (!set)
-		return -1;
+		return isl_bool_error;
 
 	for (i = 0; i < set->n; ++i) {
-		int bounded = isl_basic_set_is_bounded(set->p[i]);
+		isl_bool bounded = isl_basic_set_is_bounded(set->p[i]);
 		if (!bounded || bounded < 0)
 			return bounded;
 	}
-	return 1;
+	return isl_bool_true;
 }
 
 /* Compute the lineality space of the convex hull of bset1 and bset2.
@@ -1837,6 +1837,7 @@ static struct isl_basic_set *uset_convex
  */
 static struct isl_basic_set *uset_convex_hull(struct isl_set *set)
 {
+	isl_bool bounded;
 	struct isl_basic_set *convex_hull = NULL;
 	struct isl_basic_set *lin;
 
@@ -1858,8 +1859,10 @@ static struct isl_basic_set *uset_convex
 	if (isl_set_n_dim(set) == 1)
 		return convex_hull_1d(set);
 
-	if (isl_set_is_bounded(set) &&
-	    set->ctx->opt->convex == ISL_CONVEX_HULL_WRAP)
+	bounded = isl_set_is_bounded(set);
+	if (bounded < 0)
+		goto error;
+	if (bounded && set->ctx->opt->convex == ISL_CONVEX_HULL_WRAP)
 		return uset_convex_hull_wrap(set);
 
 	lin = uset_combined_lineality_space(isl_set_copy(set));
@@ -3139,5 +3142,6 @@ struct isl_basic_set *isl_set_bounded_si
 	return hull;
 error:
 	isl_set_free(set);
+	isl_basic_set_free(hull);
 	return NULL;
 }

Modified: polly/trunk/lib/External/isl/isl_equalities.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_equalities.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_equalities.c (original)
+++ polly/trunk/lib/External/isl/isl_equalities.c Thu Feb 16 23:11:16 2017
@@ -732,20 +732,24 @@ error:
  * If i_dim does not belong to such a residue class, then *modulo
  * is set to 1 and *residue is set to 0.
  */
-int isl_basic_set_dim_residue_class(struct isl_basic_set *bset,
+isl_stat isl_basic_set_dim_residue_class(__isl_keep isl_basic_set *bset,
 	int pos, isl_int *modulo, isl_int *residue)
 {
+	isl_bool fixed;
 	struct isl_ctx *ctx;
 	struct isl_mat *H = NULL, *U = NULL, *C, *H1, *U1;
 	unsigned total;
 	unsigned nparam;
 
 	if (!bset || !modulo || !residue)
-		return -1;
+		return isl_stat_error;
 
-	if (isl_basic_set_plain_dim_is_fixed(bset, pos, residue)) {
+	fixed = isl_basic_set_plain_dim_is_fixed(bset, pos, residue);
+	if (fixed < 0)
+		return isl_stat_error;
+	if (fixed) {
 		isl_int_set_si(*modulo, 0);
-		return 0;
+		return isl_stat_ok;
 	}
 
 	ctx = isl_basic_set_get_ctx(bset);
@@ -754,7 +758,7 @@ int isl_basic_set_dim_residue_class(stru
 	H = isl_mat_sub_alloc6(ctx, bset->eq, 0, bset->n_eq, 1, total);
 	H = isl_mat_left_hermite(H, 0, &U, NULL);
 	if (!H)
-		return -1;
+		return isl_stat_error;
 
 	isl_seq_gcd(U->row[nparam + pos]+bset->n_eq,
 			total-bset->n_eq, modulo);
@@ -764,7 +768,7 @@ int isl_basic_set_dim_residue_class(stru
 		isl_int_set_si(*residue, 0);
 		isl_mat_free(H);
 		isl_mat_free(U);
-		return 0;
+		return isl_stat_ok;
 	}
 
 	C = isl_mat_alloc(ctx, 1 + bset->n_eq, 1);
@@ -781,23 +785,23 @@ int isl_basic_set_dim_residue_class(stru
 	isl_mat_free(U);
 	C = isl_mat_product(U1, C);
 	if (!C)
-		return -1;
+		return isl_stat_error;
 	if (!isl_int_is_divisible_by(C->row[1][0], C->row[0][0])) {
 		bset = isl_basic_set_copy(bset);
 		bset = isl_basic_set_set_to_empty(bset);
 		isl_basic_set_free(bset);
 		isl_int_set_si(*modulo, 1);
 		isl_int_set_si(*residue, 0);
-		return 0;
+		return isl_stat_ok;
 	}
 	isl_int_divexact(*residue, C->row[1][0], C->row[0][0]);
 	isl_int_fdiv_r(*residue, *residue, *modulo);
 	isl_mat_free(C);
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_mat_free(H);
 	isl_mat_free(U);
-	return -1;
+	return isl_stat_error;
 }
 
 /* Check if dimension dim belongs to a residue class
@@ -809,7 +813,7 @@ error:
  * If i_dim does not belong to such a residue class, then *modulo
  * is set to 1 and *residue is set to 0.
  */
-int isl_set_dim_residue_class(struct isl_set *set,
+isl_stat isl_set_dim_residue_class(__isl_keep isl_set *set,
 	int pos, isl_int *modulo, isl_int *residue)
 {
 	isl_int m;
@@ -817,22 +821,22 @@ int isl_set_dim_residue_class(struct isl
 	int i;
 
 	if (!set || !modulo || !residue)
-		return -1;
+		return isl_stat_error;
 
 	if (set->n == 0) {
 		isl_int_set_si(*modulo, 0);
 		isl_int_set_si(*residue, 0);
-		return 0;
+		return isl_stat_ok;
 	}
 
 	if (isl_basic_set_dim_residue_class(set->p[0], pos, modulo, residue)<0)
-		return -1;
+		return isl_stat_error;
 
 	if (set->n == 1)
-		return 0;
+		return isl_stat_ok;
 
 	if (isl_int_is_one(*modulo))
-		return 0;
+		return isl_stat_ok;
 
 	isl_int_init(m);
 	isl_int_init(r);
@@ -852,11 +856,11 @@ int isl_set_dim_residue_class(struct isl
 	isl_int_clear(m);
 	isl_int_clear(r);
 
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_int_clear(m);
 	isl_int_clear(r);
-	return -1;
+	return isl_stat_error;
 }
 
 /* Check if dimension "dim" belongs to a residue class

Modified: polly/trunk/lib/External/isl/isl_factorization.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_factorization.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_factorization.h (original)
+++ polly/trunk/lib/External/isl/isl_factorization.h Thu Feb 16 23:11:16 2017
@@ -1,3 +1,6 @@
+#ifndef ISL_FACTORIZATION_H
+#define ISL_FACTORIZATION_H
+
 #include <isl/set.h>
 #include <isl_morph.h>
 
@@ -27,3 +30,5 @@ void isl_factorizer_dump(__isl_take isl_
 #if defined(__cplusplus)
 }
 #endif
+
+#endif

Modified: polly/trunk/lib/External/isl/isl_farkas.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_farkas.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_farkas.c (original)
+++ polly/trunk/lib/External/isl/isl_farkas.c Thu Feb 16 23:11:16 2017
@@ -281,8 +281,8 @@ static __isl_give isl_basic_set *farkas(
 	}
 
 	dual = isl_basic_set_remove_divs(dual);
-	isl_basic_set_simplify(dual);
-	isl_basic_set_finalize(dual);
+	dual = isl_basic_set_simplify(dual);
+	dual = isl_basic_set_finalize(dual);
 
 	isl_basic_set_free(bset);
 	return dual;

Modified: polly/trunk/lib/External/isl/isl_fold.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_fold.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_fold.c (original)
+++ polly/trunk/lib/External/isl/isl_fold.c Thu Feb 16 23:11:16 2017
@@ -652,6 +652,8 @@ __isl_give isl_qpolynomial_fold *isl_qpo
 	return isl_qpolynomial_fold_gist(fold, dom_context);
 }
 
+#define isl_qpolynomial_fold_involves_nan isl_qpolynomial_fold_is_nan
+
 #define HAS_TYPE
 
 #undef PW
@@ -1424,14 +1426,12 @@ error:
 
 static isl_stat add_pwqp(__isl_take isl_pw_qpolynomial *pwqp, void *user)
 {
-	isl_ctx *ctx;
 	isl_pw_qpolynomial_fold *pwf;
 	isl_union_pw_qpolynomial_fold **upwf;
 	struct isl_hash_table_entry *entry;
 
 	upwf = (isl_union_pw_qpolynomial_fold **)user;
 
-	ctx = pwqp->dim->ctx;
 	entry = isl_union_pw_qpolynomial_fold_find_part_entry(*upwf,
 			 pwqp->dim, 1);
 	if (!entry)
@@ -1481,13 +1481,15 @@ error:
 	return NULL;
 }
 
-static int join_compatible(__isl_keep isl_space *dim1, __isl_keep isl_space *dim2)
+static isl_bool join_compatible(__isl_keep isl_space *space1,
+	__isl_keep isl_space *space2)
 {
-	int m;
-	m = isl_space_match(dim1, isl_dim_param, dim2, isl_dim_param);
+	isl_bool m;
+	m = isl_space_match(space1, isl_dim_param, space2, isl_dim_param);
 	if (m < 0 || !m)
 		return m;
-	return isl_space_tuple_is_equal(dim1, isl_dim_out, dim2, isl_dim_in);
+	return isl_space_tuple_is_equal(space1, isl_dim_out,
+					space2, isl_dim_in);
 }
 
 /* Compute the intersection of the range of the map and the domain
@@ -1508,7 +1510,7 @@ __isl_give isl_pw_qpolynomial_fold *isl_
 	isl_space *map_dim;
 	isl_space *pwf_dim;
 	unsigned n_in;
-	int ok;
+	isl_bool ok;
 
 	ctx = isl_map_get_ctx(map);
 	if (!ctx)
@@ -1519,6 +1521,8 @@ __isl_give isl_pw_qpolynomial_fold *isl_
 	ok = join_compatible(map_dim, pwf_dim);
 	isl_space_free(map_dim);
 	isl_space_free(pwf_dim);
+	if (ok < 0)
+		goto error;
 	if (!ok)
 		isl_die(ctx, isl_error_invalid, "incompatible dimensions",
 			goto error);
@@ -1560,7 +1564,7 @@ static isl_stat pw_qpolynomial_fold_appl
 	isl_space *map_dim;
 	isl_space *pwf_dim;
 	struct isl_apply_fold_data *data = user;
-	int ok;
+	isl_bool ok;
 
 	map_dim = isl_map_get_space(data->map);
 	pwf_dim = isl_pw_qpolynomial_fold_get_space(pwf);
@@ -1568,6 +1572,8 @@ static isl_stat pw_qpolynomial_fold_appl
 	isl_space_free(map_dim);
 	isl_space_free(pwf_dim);
 
+	if (ok < 0)
+		return isl_stat_error;
 	if (ok) {
 		pwf = isl_map_apply_pw_qpolynomial_fold(isl_map_copy(data->map),
 				    pwf, data->tight ? &data->tight : NULL);

Modified: polly/trunk/lib/External/isl/isl_ilp.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_ilp.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_ilp.c (original)
+++ polly/trunk/lib/External/isl/isl_ilp.c Thu Feb 16 23:11:16 2017
@@ -315,7 +315,8 @@ enum isl_lp_result isl_basic_set_solve_i
 	if (sol_p)
 		*sol_p = NULL;
 
-	isl_assert(bset->ctx, isl_basic_set_n_param(bset) == 0, goto error);
+	isl_assert(bset->ctx, isl_basic_set_n_param(bset) == 0,
+		return isl_lp_error);
 
 	if (isl_basic_set_plain_is_empty(bset))
 		return isl_lp_empty;
@@ -336,9 +337,6 @@ enum isl_lp_result isl_basic_set_solve_i
 	}
 
 	return res;
-error:
-	isl_basic_set_free(bset);
-	return isl_lp_error;
 }
 
 static enum isl_lp_result basic_set_opt(__isl_keep isl_basic_set *bset, int max,

Modified: polly/trunk/lib/External/isl/isl_input.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_input.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_input.c (original)
+++ polly/trunk/lib/External/isl/isl_input.c Thu Feb 16 23:11:16 2017
@@ -412,7 +412,7 @@ static __isl_give isl_pw_aff *accept_div
 			isl_stream_push_token(s, tok);
 			goto error;
 		}
-		isl_pw_aff_scale_down(pwaff,  tok->u.v);
+		pwaff = isl_pw_aff_scale_down(pwaff,  tok->u.v);
 		isl_token_free(tok);
 	}
 
@@ -3272,29 +3272,154 @@ __isl_give isl_pw_aff *isl_pw_aff_read_f
 	return pa;
 }
 
+/* Extract an isl_multi_pw_aff with domain space "dom_space"
+ * from a tuple "tuple" read by read_tuple.
+ *
+ * Note that the function read_tuple accepts tuples where some output or
+ * set dimensions are defined in terms of other output or set dimensions
+ * since this function is also used to read maps.  As a special case,
+ * read_tuple also accept dimensions that are defined in terms of themselves
+ * (i.e., that are not defined).
+ * These cases are not allowed when extracting an isl_multi_pw_aff so check
+ * that the definitions of the output/set dimensions do not involve any
+ * output/set dimensions.
+ * Finally, drop the output dimensions from the domain of the result
+ * of read_tuple (which is of the form [input, output] -> [output],
+ * with anonymous domain) and reset the space.
+ */
+static __isl_give isl_multi_pw_aff *extract_mpa_from_tuple(
+	__isl_take isl_space *dom_space, __isl_keep isl_multi_pw_aff *tuple)
+{
+	int dim, i, n;
+	isl_space *space;
+	isl_multi_pw_aff *mpa;
+
+	n = isl_multi_pw_aff_dim(tuple, isl_dim_out);
+	dim = isl_space_dim(dom_space, isl_dim_all);
+	space = isl_space_range(isl_multi_pw_aff_get_space(tuple));
+	space = isl_space_align_params(space, isl_space_copy(dom_space));
+	if (!isl_space_is_params(dom_space))
+		space = isl_space_map_from_domain_and_range(
+				isl_space_copy(dom_space), space);
+	isl_space_free(dom_space);
+	mpa = isl_multi_pw_aff_alloc(space);
+
+	for (i = 0; i < n; ++i) {
+		isl_pw_aff *pa;
+		pa = isl_multi_pw_aff_get_pw_aff(tuple, i);
+		if (!pa)
+			return isl_multi_pw_aff_free(mpa);
+		if (isl_pw_aff_involves_dims(pa, isl_dim_in, dim, i + 1)) {
+			isl_ctx *ctx = isl_pw_aff_get_ctx(pa);
+			isl_pw_aff_free(pa);
+			isl_die(ctx, isl_error_invalid,
+				"not an affine expression",
+				return isl_multi_pw_aff_free(mpa));
+		}
+		pa = isl_pw_aff_drop_dims(pa, isl_dim_in, dim, n);
+		space = isl_multi_pw_aff_get_domain_space(mpa);
+		pa = isl_pw_aff_reset_domain_space(pa, space);
+		mpa = isl_multi_pw_aff_set_pw_aff(mpa, i, pa);
+	}
+
+	return mpa;
+}
+
+/* Read a tuple of affine expressions, together with optional constraints
+ * on the domain from "s".  "dom" represents the initial constraints
+ * on the domain.
+ *
+ * The isl_multi_aff may live in either a set or a map space.
+ * First read the first tuple and check if it is followed by a "->".
+ * If so, convert the tuple into the domain of the isl_multi_pw_aff and
+ * read in the next tuple.  This tuple (or the first tuple if it was
+ * not followed by a "->") is then converted into an isl_multi_pw_aff
+ * through a call to extract_mpa_from_tuple.
+ * The result is converted to an isl_pw_multi_aff and
+ * its domain is intersected with the domain.
+ */
+static __isl_give isl_pw_multi_aff *read_conditional_multi_aff(
+	__isl_keep isl_stream *s, __isl_take isl_set *dom, struct vars *v)
+{
+	isl_multi_pw_aff *tuple;
+	isl_multi_pw_aff *mpa;
+	isl_pw_multi_aff *pma;
+	int n = v->n;
+
+	tuple = read_tuple(s, v, 0, 0);
+	if (!tuple)
+		goto error;
+	if (isl_stream_eat_if_available(s, ISL_TOKEN_TO)) {
+		isl_map *map = map_from_tuple(tuple, dom, isl_dim_in, v, 0);
+		dom = isl_map_domain(map);
+		tuple = read_tuple(s, v, 0, 0);
+		if (!tuple)
+			goto error;
+	}
+
+	dom = read_optional_formula(s, dom, v, 0);
+
+	vars_drop(v, v->n - n);
+
+	mpa = extract_mpa_from_tuple(isl_set_get_space(dom), tuple);
+	isl_multi_pw_aff_free(tuple);
+	pma = isl_pw_multi_aff_from_multi_pw_aff(mpa);
+	pma = isl_pw_multi_aff_intersect_domain(pma, dom);
+
+	return pma;
+error:
+	isl_set_free(dom);
+	return NULL;
+}
+
 /* Read an isl_pw_multi_aff from "s".
- * We currently read a generic object and if it turns out to be a set or
- * a map, we convert that to an isl_pw_multi_aff.
- * It would be more efficient if we were to construct the isl_pw_multi_aff
- * directly.
+ *
+ * In particular, first read the parameters and then read a sequence
+ * of one or more tuples of affine expressions with optional conditions and
+ * add them up.
  */
 __isl_give isl_pw_multi_aff *isl_stream_read_pw_multi_aff(
 	__isl_keep isl_stream *s)
 {
-	struct isl_obj obj;
+	struct vars *v;
+	isl_set *dom;
+	isl_pw_multi_aff *pma = NULL;
 
-	obj = obj_read(s);
-	if (!obj.v)
+	v = vars_new(s->ctx);
+	if (!v)
 		return NULL;
 
-	if (obj.type == isl_obj_map)
-		return isl_pw_multi_aff_from_map(obj.v);
-	if (obj.type == isl_obj_set)
-		return isl_pw_multi_aff_from_set(obj.v);
+	dom = isl_set_universe(isl_space_params_alloc(s->ctx, 0));
+	if (next_is_tuple(s)) {
+		dom = read_map_tuple(s, dom, isl_dim_param, v, 1, 0);
+		if (isl_stream_eat(s, ISL_TOKEN_TO))
+			goto error;
+	}
+	if (isl_stream_eat(s, '{'))
+		goto error;
 
-	obj.type->free(obj.v);
-	isl_die(s->ctx, isl_error_invalid, "unexpected object type",
-		return NULL);
+	pma = read_conditional_multi_aff(s, isl_set_copy(dom), v);
+
+	while (isl_stream_eat_if_available(s, ';')) {
+		isl_pw_multi_aff *pma2;
+
+		pma2 = read_conditional_multi_aff(s, isl_set_copy(dom), v);
+		pma = isl_pw_multi_aff_union_add(pma, pma2);
+		if (!pma)
+			goto error;
+	}
+
+	if (isl_stream_eat(s, '}'))
+		goto error;
+
+	isl_set_free(dom);
+	vars_free(v);
+	return pma;
+error:
+	isl_pw_multi_aff_free(pma);
+	isl_set_free(dom);
+	vars_free(v);
+	return NULL;
 }
 
 __isl_give isl_pw_multi_aff *isl_pw_multi_aff_read_from_str(isl_ctx *ctx,
@@ -3579,19 +3704,9 @@ __isl_give isl_multi_aff *isl_multi_aff_
  * if it is followed by a "->".  If so, we convert the tuple into
  * the domain of the isl_multi_pw_aff and read in the next tuple.
  * This tuple (or the first tuple if it was not followed by a "->")
- * is then converted into the isl_multi_pw_aff.
- *
- * Note that the function read_tuple accepts tuples where some output or
- * set dimensions are defined in terms of other output or set dimensions
- * since this function is also used to read maps.  As a special case,
- * read_tuple also accept dimensions that are defined in terms of themselves
- * (i.e., that are not defined).
- * These cases are not allowed when reading am isl_multi_pw_aff so we check
- * that the definition of the output/set dimensions does not involve any
- * output/set dimensions.
- * We then drop the output dimensions from the domain of the result
- * of read_tuple (which is of the form [input, output] -> [output],
- * with anonymous domain) and reset the space.
+ * is then converted into the isl_multi_pw_aff through a call
+ * to extract_mpa_from_tuple and the domain of the result
+ * is intersected with the domain.
  */
 __isl_give isl_multi_pw_aff *isl_stream_read_multi_pw_aff(
 	__isl_keep isl_stream *s)
@@ -3599,8 +3714,6 @@ __isl_give isl_multi_pw_aff *isl_stream_
 	struct vars *v;
 	isl_set *dom = NULL;
 	isl_multi_pw_aff *tuple = NULL;
-	int dim, i, n;
-	isl_space *space, *dom_space;
 	isl_multi_pw_aff *mpa = NULL;
 
 	v = vars_new(s->ctx);
@@ -3630,32 +3743,7 @@ __isl_give isl_multi_pw_aff *isl_stream_
 	if (isl_stream_eat(s, '}'))
 		goto error;
 
-	n = isl_multi_pw_aff_dim(tuple, isl_dim_out);
-	dim = isl_set_dim(dom, isl_dim_all);
-	dom_space = isl_set_get_space(dom);
-	space = isl_space_range(isl_multi_pw_aff_get_space(tuple));
-	space = isl_space_align_params(space, isl_space_copy(dom_space));
-	if (!isl_space_is_params(dom_space))
-		space = isl_space_map_from_domain_and_range(
-				isl_space_copy(dom_space), space);
-	isl_space_free(dom_space);
-	mpa = isl_multi_pw_aff_alloc(space);
-
-	for (i = 0; i < n; ++i) {
-		isl_pw_aff *pa;
-		pa = isl_multi_pw_aff_get_pw_aff(tuple, i);
-		if (!pa)
-			goto error;
-		if (isl_pw_aff_involves_dims(pa, isl_dim_in, dim, i + 1)) {
-			isl_pw_aff_free(pa);
-			isl_die(s->ctx, isl_error_invalid,
-				"not an affine expression", goto error);
-		}
-		pa = isl_pw_aff_drop_dims(pa, isl_dim_in, dim, n);
-		space = isl_multi_pw_aff_get_domain_space(mpa);
-		pa = isl_pw_aff_reset_domain_space(pa, space);
-		mpa = isl_multi_pw_aff_set_pw_aff(mpa, i, pa);
-	}
+	mpa = extract_mpa_from_tuple(isl_set_get_space(dom), tuple);
 
 	isl_multi_pw_aff_free(tuple);
 	vars_free(v);

Modified: polly/trunk/lib/External/isl/isl_local_space.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_local_space.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_local_space.c (original)
+++ polly/trunk/lib/External/isl/isl_local_space.c Thu Feb 16 23:11:16 2017
@@ -729,8 +729,8 @@ __isl_give isl_local_space *isl_local_sp
 	isl_ctx *ctx;
 	int *exp1 = NULL;
 	int *exp2 = NULL;
-	isl_mat *div;
-	int equal;
+	isl_mat *div = NULL;
+	isl_bool equal;
 
 	if (!ls1 || !ls2)
 		goto error;
@@ -777,6 +777,7 @@ __isl_give isl_local_space *isl_local_sp
 error:
 	free(exp1);
 	free(exp2);
+	isl_mat_free(div);
 	isl_local_space_free(ls1);
 	isl_local_space_free(ls2);
 	return NULL;
@@ -1036,11 +1037,11 @@ __isl_give isl_local_space *isl_local_sp
 					    subs->v->size, 0, ls->div->n_row);
 }
 
-int isl_local_space_is_named_or_nested(__isl_keep isl_local_space *ls,
+isl_bool isl_local_space_is_named_or_nested(__isl_keep isl_local_space *ls,
 	enum isl_dim_type type)
 {
 	if (!ls)
-		return -1;
+		return isl_bool_error;
 	return isl_space_is_named_or_nested(ls->dim, type);
 }
 
@@ -1125,16 +1126,16 @@ __isl_give isl_local_space *isl_local_sp
  * or
  *		-(f-(m-1)) + m d >= 0
  */
-int isl_local_space_is_div_constraint(__isl_keep isl_local_space *ls,
+isl_bool isl_local_space_is_div_constraint(__isl_keep isl_local_space *ls,
 	isl_int *constraint, unsigned div)
 {
 	unsigned pos;
 
 	if (!ls)
-		return -1;
+		return isl_bool_error;
 
 	if (isl_int_is_zero(ls->div->row[div][0]))
-		return 0;
+		return isl_bool_false;
 
 	pos = isl_local_space_offset(ls, isl_dim_div) + div;
 
@@ -1148,20 +1149,20 @@ int isl_local_space_is_div_constraint(__
 		isl_int_add(ls->div->row[div][1],
 				ls->div->row[div][1], ls->div->row[div][0]);
 		if (!neg)
-			return 0;
+			return isl_bool_false;
 		if (isl_seq_first_non_zero(constraint+pos+1,
 					    ls->div->n_row-div-1) != -1)
-			return 0;
+			return isl_bool_false;
 	} else if (isl_int_abs_eq(constraint[pos], ls->div->row[div][0])) {
 		if (!isl_seq_eq(constraint, ls->div->row[div]+1, pos))
-			return 0;
+			return isl_bool_false;
 		if (isl_seq_first_non_zero(constraint+pos+1,
 					    ls->div->n_row-div-1) != -1)
-			return 0;
+			return isl_bool_false;
 	} else
-		return 0;
+		return isl_bool_false;
 
-	return 1;
+	return isl_bool_true;
 }
 
 /*

Modified: polly/trunk/lib/External/isl/isl_local_space_private.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_local_space_private.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_local_space_private.h (original)
+++ polly/trunk/lib/External/isl/isl_local_space_private.h Thu Feb 16 23:11:16 2017
@@ -41,7 +41,7 @@ isl_bool isl_local_space_divs_known(__is
 __isl_give isl_local_space *isl_local_space_substitute_equalities(
 	__isl_take isl_local_space *ls, __isl_take isl_basic_set *eq);
 
-int isl_local_space_is_named_or_nested(__isl_keep isl_local_space *ls,
+isl_bool isl_local_space_is_named_or_nested(__isl_keep isl_local_space *ls,
 	enum isl_dim_type type);
 
 isl_bool isl_local_space_has_equal_space(__isl_keep isl_local_space *ls1,
@@ -52,7 +52,7 @@ __isl_give isl_local_space *isl_local_sp
 __isl_give isl_local_space *isl_local_space_realign(
 	__isl_take isl_local_space *ls, __isl_take isl_reordering *r);
 
-int isl_local_space_is_div_constraint(__isl_keep isl_local_space *ls,
+isl_bool isl_local_space_is_div_constraint(__isl_keep isl_local_space *ls,
 	isl_int *constraint, unsigned div);
 
 int *isl_local_space_get_active(__isl_keep isl_local_space *ls, isl_int *l);

Modified: polly/trunk/lib/External/isl/isl_map.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_map.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_map.c (original)
+++ polly/trunk/lib/External/isl/isl_map.c Thu Feb 16 23:11:16 2017
@@ -202,11 +202,12 @@ unsigned isl_map_n_param(const struct is
 	return map ? map->dim->nparam : 0;
 }
 
-int isl_map_compatible_domain(struct isl_map *map, struct isl_set *set)
+isl_bool isl_map_compatible_domain(__isl_keep isl_map *map,
+	__isl_keep isl_set *set)
 {
-	int m;
+	isl_bool m;
 	if (!map || !set)
-		return -1;
+		return isl_bool_error;
 	m = isl_space_match(map->dim, isl_dim_param, set->dim, isl_dim_param);
 	if (m < 0 || !m)
 		return m;
@@ -227,11 +228,12 @@ isl_bool isl_basic_map_compatible_domain
 					bset->dim, isl_dim_set);
 }
 
-int isl_map_compatible_range(__isl_keep isl_map *map, __isl_keep isl_set *set)
+isl_bool isl_map_compatible_range(__isl_keep isl_map *map,
+	__isl_keep isl_set *set)
 {
-	int m;
+	isl_bool m;
 	if (!map || !set)
-		return -1;
+		return isl_bool_error;
 	m = isl_space_match(map->dim, isl_dim_param, set->dim, isl_dim_param);
 	if (m < 0 || !m)
 		return m;
@@ -239,12 +241,12 @@ int isl_map_compatible_range(__isl_keep
 					set->dim, isl_dim_set);
 }
 
-int isl_basic_map_compatible_range(struct isl_basic_map *bmap,
-		struct isl_basic_set *bset)
+isl_bool isl_basic_map_compatible_range(__isl_keep isl_basic_map *bmap,
+	__isl_keep isl_basic_set *bset)
 {
-	int m;
+	isl_bool m;
 	if (!bmap || !bset)
-		return -1;
+		return isl_bool_error;
 	m = isl_space_match(bmap->dim, isl_dim_param, bset->dim, isl_dim_param);
 	if (m < 0 || !m)
 		return m;
@@ -819,10 +821,10 @@ __isl_give isl_set *isl_set_reset_user(_
 	return isl_map_reset_user(set);
 }
 
-int isl_basic_map_is_rational(__isl_keep isl_basic_map *bmap)
+isl_bool isl_basic_map_is_rational(__isl_keep isl_basic_map *bmap)
 {
 	if (!bmap)
-		return -1;
+		return isl_bool_error;
 	return ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL);
 }
 
@@ -849,7 +851,7 @@ isl_bool isl_map_is_rational(__isl_keep
 
 		rational_i = isl_basic_map_is_rational(map->p[i]);
 		if (rational_i < 0)
-			return rational;
+			return rational_i;
 		if (rational != rational_i)
 			isl_die(isl_map_get_ctx(map), isl_error_unsupported,
 				"mixed rational and integer basic maps "
@@ -881,21 +883,21 @@ int isl_basic_set_is_rational(__isl_keep
  * to an integer constant, then it has no rational points, even if it
  * is marked as rational.
  */
-int isl_basic_map_has_rational(__isl_keep isl_basic_map *bmap)
+isl_bool isl_basic_map_has_rational(__isl_keep isl_basic_map *bmap)
 {
-	int has_rational = 1;
+	isl_bool has_rational = isl_bool_true;
 	unsigned total;
 
 	if (!bmap)
-		return -1;
+		return isl_bool_error;
 	if (isl_basic_map_plain_is_empty(bmap))
-		return 0;
+		return isl_bool_false;
 	if (!isl_basic_map_is_rational(bmap))
-		return 0;
+		return isl_bool_false;
 	bmap = isl_basic_map_copy(bmap);
 	bmap = isl_basic_map_implicit_equalities(bmap);
 	if (!bmap)
-		return -1;
+		return isl_bool_error;
 	total = isl_basic_map_total_dim(bmap);
 	if (bmap->n_eq == total) {
 		int i, j;
@@ -912,7 +914,7 @@ int isl_basic_map_has_rational(__isl_kee
 				break;
 		}
 		if (i == bmap->n_eq)
-			has_rational = 0;
+			has_rational = isl_bool_false;
 	}
 	isl_basic_map_free(bmap);
 
@@ -921,36 +923,34 @@ int isl_basic_map_has_rational(__isl_kee
 
 /* Does "map" contain any rational points?
  */
-int isl_map_has_rational(__isl_keep isl_map *map)
+isl_bool isl_map_has_rational(__isl_keep isl_map *map)
 {
 	int i;
-	int has_rational;
+	isl_bool has_rational;
 
 	if (!map)
-		return -1;
+		return isl_bool_error;
 	for (i = 0; i < map->n; ++i) {
 		has_rational = isl_basic_map_has_rational(map->p[i]);
-		if (has_rational < 0)
-			return -1;
-		if (has_rational)
-			return 1;
+		if (has_rational < 0 || has_rational)
+			return has_rational;
 	}
-	return 0;
+	return isl_bool_false;
 }
 
 /* Does "set" contain any rational points?
  */
-int isl_set_has_rational(__isl_keep isl_set *set)
+isl_bool isl_set_has_rational(__isl_keep isl_set *set)
 {
 	return isl_map_has_rational(set);
 }
 
 /* Is this basic set a parameter domain?
  */
-int isl_basic_set_is_params(__isl_keep isl_basic_set *bset)
+isl_bool isl_basic_set_is_params(__isl_keep isl_basic_set *bset)
 {
 	if (!bset)
-		return -1;
+		return isl_bool_error;
 	return isl_space_is_params(bset->dim);
 }
 
@@ -967,10 +967,10 @@ isl_bool isl_set_is_params(__isl_keep is
  * Users should never call this function.  Outside of isl,
  * a map can never be a parameter domain.
  */
-int isl_map_is_params(__isl_keep isl_map *map)
+isl_bool isl_map_is_params(__isl_keep isl_map *map)
 {
 	if (!map)
-		return -1;
+		return isl_bool_error;
 	return isl_space_is_params(map->dim);
 }
 
@@ -1536,16 +1536,16 @@ __isl_give isl_basic_map *isl_basic_map_
 	return bmap;
 }
 
-int isl_basic_map_free_div(struct isl_basic_map *bmap, unsigned n)
+isl_stat isl_basic_map_free_div(struct isl_basic_map *bmap, unsigned n)
 {
 	if (!bmap)
-		return -1;
-	isl_assert(bmap->ctx, n <= bmap->n_div, return -1);
+		return isl_stat_error;
+	isl_assert(bmap->ctx, n <= bmap->n_div, return isl_stat_error);
 	bmap->n_div -= n;
-	return 0;
+	return isl_stat_ok;
 }
 
-int isl_basic_set_free_div(struct isl_basic_set *bset, unsigned n)
+isl_stat isl_basic_set_free_div(struct isl_basic_set *bset, unsigned n)
 {
 	return isl_basic_map_free_div(bset_to_bmap(bset), n);
 }
@@ -1880,7 +1880,8 @@ struct isl_basic_map *isl_basic_map_set_
 	if (!bmap)
 		goto error;
 	total = isl_basic_map_total_dim(bmap);
-	isl_basic_map_free_div(bmap, bmap->n_div);
+	if (isl_basic_map_free_div(bmap, bmap->n_div) < 0)
+		return isl_basic_map_free(bmap);
 	isl_basic_map_free_inequality(bmap, bmap->n_ineq);
 	if (bmap->n_eq > 0)
 		isl_basic_map_free_equality(bmap, bmap->n_eq-1);
@@ -2065,25 +2066,28 @@ struct isl_basic_map *isl_basic_map_remo
 /* Return true if the definition of the given div (recursively) involves
  * any of the given variables.
  */
-static int div_involves_vars(__isl_keep isl_basic_map *bmap, int div,
+static isl_bool div_involves_vars(__isl_keep isl_basic_map *bmap, int div,
 	unsigned first, unsigned n)
 {
 	int i;
 	unsigned div_offset = isl_basic_map_offset(bmap, isl_dim_div);
 
 	if (isl_int_is_zero(bmap->div[div][0]))
-		return 0;
+		return isl_bool_false;
 	if (isl_seq_first_non_zero(bmap->div[div] + 1 + first, n) >= 0)
-		return 1;
+		return isl_bool_true;
 
 	for (i = bmap->n_div - 1; i >= 0; --i) {
+		isl_bool involves;
+
 		if (isl_int_is_zero(bmap->div[div][1 + div_offset + i]))
 			continue;
-		if (div_involves_vars(bmap, i, first, n))
-			return 1;
+		involves = div_involves_vars(bmap, i, first, n);
+		if (involves < 0 || involves)
+			return involves;
 	}
 
-	return 0;
+	return isl_bool_false;
 }
 
 /* Try and add a lower and/or upper bound on "div" to "bmap"
@@ -2292,7 +2296,12 @@ __isl_give isl_basic_map *isl_basic_map_
 	first += isl_basic_map_offset(bmap, type);
 
 	for (i = bmap->n_div - 1; i >= 0; --i) {
-		if (!div_involves_vars(bmap, i, first, n))
+		isl_bool involves;
+
+		involves = div_involves_vars(bmap, i, first, n);
+		if (involves < 0)
+			return isl_basic_map_free(bmap);
+		if (!involves)
 			continue;
 		bmap = insert_bounds_on_div(bmap, i);
 		bmap = isl_basic_map_remove_dims(bmap, isl_dim_div, i, 1);
@@ -3099,6 +3108,23 @@ error:
 	return NULL;
 }
 
+/* Check that the space of "bset" is the same as that of the range of "bmap".
+ */
+static isl_stat isl_basic_map_check_compatible_range(
+	__isl_keep isl_basic_map *bmap, __isl_keep isl_basic_set *bset)
+{
+	isl_bool ok;
+
+	ok = isl_basic_map_compatible_range(bmap, bset);
+	if (ok < 0)
+		return isl_stat_error;
+	if (!ok)
+		isl_die(isl_basic_set_get_ctx(bset), isl_error_invalid,
+			"incompatible spaces", return isl_stat_error);
+
+	return isl_stat_ok;
+}
+
 struct isl_basic_map *isl_basic_map_intersect_range(
 		struct isl_basic_map *bmap, struct isl_basic_set *bset)
 {
@@ -3110,9 +3136,9 @@ struct isl_basic_map *isl_basic_map_inte
 	isl_assert(bset->ctx, isl_space_match(bmap->dim, isl_dim_param,
 					bset->dim, isl_dim_param), goto error);
 
-	if (isl_space_dim(bset->dim, isl_dim_set) != 0)
-		isl_assert(bset->ctx,
-		    isl_basic_map_compatible_range(bmap, bset), goto error);
+	if (isl_space_dim(bset->dim, isl_dim_set) != 0 &&
+	    isl_basic_map_check_compatible_range(bmap, bset) < 0)
+		goto error;
 
 	if (isl_basic_set_plain_is_universe(bset)) {
 		isl_basic_set_free(bset);
@@ -3147,7 +3173,7 @@ isl_bool isl_basic_map_contains(__isl_ke
 
 	total = 1 + isl_basic_map_total_dim(bmap);
 	if (total != vec->size)
-		return isl_bool_error;
+		return isl_bool_false;
 
 	isl_int_init(s);
 
@@ -3459,6 +3485,7 @@ __isl_give isl_basic_map *isl_basic_map_
 	__isl_take isl_basic_map *bmap, enum isl_dim_type type,
 	unsigned pos, unsigned n)
 {
+	isl_bool rational;
 	isl_space *res_dim;
 	struct isl_basic_map *res;
 	struct isl_dim_map *dim_map;
@@ -3492,7 +3519,10 @@ __isl_give isl_basic_map *isl_basic_map_
 
 	res = isl_basic_map_alloc_space(res_dim,
 			bmap->n_div, bmap->n_eq, bmap->n_ineq);
-	if (isl_basic_map_is_rational(bmap))
+	rational = isl_basic_map_is_rational(bmap);
+	if (rational < 0)
+		res = isl_basic_map_free(res);
+	if (rational)
 		res = isl_basic_map_set_rational(res);
 	if (isl_basic_map_plain_is_empty(bmap)) {
 		isl_basic_map_free(bmap);
@@ -4794,7 +4824,7 @@ __isl_give isl_basic_map *isl_basic_map_
  *
  *		f - m d >= 0
  */
-static int add_upper_div_constraint(__isl_keep isl_basic_map *bmap,
+static isl_stat add_upper_div_constraint(__isl_keep isl_basic_map *bmap,
 	unsigned pos, isl_int *div)
 {
 	int i;
@@ -4802,18 +4832,18 @@ static int add_upper_div_constraint(__is
 
 	i = isl_basic_map_alloc_inequality(bmap);
 	if (i < 0)
-		return -1;
+		return isl_stat_error;
 	isl_seq_cpy(bmap->ineq[i], div + 1, 1 + total);
 	isl_int_neg(bmap->ineq[i][1 + pos], div[0]);
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* For a div d = floor(f/m), add the constraint
  *
  *		-(f-(m-1)) + m d >= 0
  */
-static int add_lower_div_constraint(__isl_keep isl_basic_map *bmap,
+static isl_stat add_lower_div_constraint(__isl_keep isl_basic_map *bmap,
 	unsigned pos, isl_int *div)
 {
 	int i;
@@ -4821,13 +4851,13 @@ static int add_lower_div_constraint(__is
 
 	i = isl_basic_map_alloc_inequality(bmap);
 	if (i < 0)
-		return -1;
+		return isl_stat_error;
 	isl_seq_neg(bmap->ineq[i], div + 1, 1 + total);
 	isl_int_set(bmap->ineq[i][1 + pos], div[0]);
 	isl_int_add(bmap->ineq[i][0], bmap->ineq[i][0], bmap->ineq[i][1 + pos]);
 	isl_int_sub_ui(bmap->ineq[i][0], bmap->ineq[i][0], 1);
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* For a div d = floor(f/m), add the constraints
@@ -5207,10 +5237,14 @@ __isl_give isl_set *isl_set_reset_space(
  */
 __isl_give isl_basic_set *isl_basic_set_params(__isl_take isl_basic_set *bset)
 {
+	isl_bool is_params;
 	isl_space *space;
 	unsigned n;
 
-	if (isl_basic_set_is_params(bset))
+	is_params = isl_basic_set_is_params(bset);
+	if (is_params < 0)
+		return isl_basic_set_free(bset);
+	if (is_params)
 		return bset;
 
 	n = isl_basic_set_dim(bset, isl_dim_set);
@@ -5294,10 +5328,10 @@ struct isl_basic_set *isl_basic_map_doma
 	return isl_basic_map_reset_space(bmap, space);
 }
 
-int isl_basic_map_may_be_set(__isl_keep isl_basic_map *bmap)
+isl_bool isl_basic_map_may_be_set(__isl_keep isl_basic_map *bmap)
 {
 	if (!bmap)
-		return -1;
+		return isl_bool_error;
 	return isl_space_may_be_set(bmap->dim);
 }
 
@@ -5305,30 +5339,35 @@ int isl_basic_map_may_be_set(__isl_keep
  * Users should never call this function.  Outside of isl,
  * the type should indicate whether something is a set or a map.
  */
-int isl_basic_map_is_set(__isl_keep isl_basic_map *bmap)
+isl_bool isl_basic_map_is_set(__isl_keep isl_basic_map *bmap)
 {
 	if (!bmap)
-		return -1;
+		return isl_bool_error;
 	return isl_space_is_set(bmap->dim);
 }
 
 struct isl_basic_set *isl_basic_map_range(struct isl_basic_map *bmap)
 {
-	if (!bmap)
-		return NULL;
-	if (isl_basic_map_is_set(bmap))
+	isl_bool is_set;
+
+	is_set = isl_basic_map_is_set(bmap);
+	if (is_set < 0)
+		goto error;
+	if (is_set)
 		return bmap;
 	return isl_basic_map_domain(isl_basic_map_reverse(bmap));
+error:
+	isl_basic_map_free(bmap);
+	return NULL;
 }
 
 __isl_give isl_basic_map *isl_basic_map_domain_map(
 	__isl_take isl_basic_map *bmap)
 {
-	int i, k;
+	int i;
 	isl_space *dim;
 	isl_basic_map *domain;
 	int nparam, n_in, n_out;
-	unsigned total;
 
 	nparam = isl_basic_map_dim(bmap, isl_dim_param);
 	n_in = isl_basic_map_dim(bmap, isl_dim_in);
@@ -5341,32 +5380,21 @@ __isl_give isl_basic_map *isl_basic_map_
 	bmap = isl_basic_map_apply_range(bmap, domain);
 	bmap = isl_basic_map_extend_constraints(bmap, n_in, 0);
 
-	total = isl_basic_map_total_dim(bmap);
-
-	for (i = 0; i < n_in; ++i) {
-		k = isl_basic_map_alloc_equality(bmap);
-		if (k < 0)
-			goto error;
-		isl_seq_clr(bmap->eq[k], 1 + total);
-		isl_int_set_si(bmap->eq[k][1 + nparam + i], -1);
-		isl_int_set_si(bmap->eq[k][1 + nparam + n_in + n_out + i], 1);
-	}
+	for (i = 0; i < n_in; ++i)
+		bmap = isl_basic_map_equate(bmap, isl_dim_in, i,
+						    isl_dim_out, i);
 
 	bmap = isl_basic_map_gauss(bmap, NULL);
 	return isl_basic_map_finalize(bmap);
-error:
-	isl_basic_map_free(bmap);
-	return NULL;
 }
 
 __isl_give isl_basic_map *isl_basic_map_range_map(
 	__isl_take isl_basic_map *bmap)
 {
-	int i, k;
+	int i;
 	isl_space *dim;
 	isl_basic_map *range;
 	int nparam, n_in, n_out;
-	unsigned total;
 
 	nparam = isl_basic_map_dim(bmap, isl_dim_param);
 	n_in = isl_basic_map_dim(bmap, isl_dim_in);
@@ -5379,22 +5407,12 @@ __isl_give isl_basic_map *isl_basic_map_
 	bmap = isl_basic_map_apply_range(bmap, range);
 	bmap = isl_basic_map_extend_constraints(bmap, n_out, 0);
 
-	total = isl_basic_map_total_dim(bmap);
-
-	for (i = 0; i < n_out; ++i) {
-		k = isl_basic_map_alloc_equality(bmap);
-		if (k < 0)
-			goto error;
-		isl_seq_clr(bmap->eq[k], 1 + total);
-		isl_int_set_si(bmap->eq[k][1 + nparam + n_in + i], -1);
-		isl_int_set_si(bmap->eq[k][1 + nparam + n_in + n_out + i], 1);
-	}
+	for (i = 0; i < n_out; ++i)
+		bmap = isl_basic_map_equate(bmap, isl_dim_in, n_in + i,
+						    isl_dim_out, i);
 
 	bmap = isl_basic_map_gauss(bmap, NULL);
 	return isl_basic_map_finalize(bmap);
-error:
-	isl_basic_map_free(bmap);
-	return NULL;
 }
 
 int isl_map_may_be_set(__isl_keep isl_map *map)
@@ -5408,21 +5426,23 @@ int isl_map_may_be_set(__isl_keep isl_ma
  * Users should never call this function.  Outside of isl,
  * the type should indicate whether something is a set or a map.
  */
-int isl_map_is_set(__isl_keep isl_map *map)
+isl_bool isl_map_is_set(__isl_keep isl_map *map)
 {
 	if (!map)
-		return -1;
+		return isl_bool_error;
 	return isl_space_is_set(map->dim);
 }
 
 struct isl_set *isl_map_range(struct isl_map *map)
 {
 	int i;
+	isl_bool is_set;
 	struct isl_set *set;
 
-	if (!map)
+	is_set = isl_map_is_set(map);
+	if (is_set < 0)
 		goto error;
-	if (isl_map_is_set(map))
+	if (is_set)
 		return set_from_map(map);
 
 	map = isl_map_cow(map);
@@ -6582,7 +6602,7 @@ static __isl_give isl_set *isl_basic_set
  * This domain is known to be disjoint from other domains
  * because of the way isl_basic_map_foreach_lexmax works.
  */
-static int update_dim_opt(__isl_take isl_basic_set *dom,
+static isl_stat update_dim_opt(__isl_take isl_basic_set *dom,
 	__isl_take isl_aff_list *list, void *user)
 {
 	isl_ctx *ctx = isl_basic_set_get_ctx(dom);
@@ -6603,11 +6623,11 @@ static int update_dim_opt(__isl_take isl
 
 	isl_aff_list_free(list);
 
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_basic_set_free(dom);
 	isl_aff_list_free(list);
-	return -1;
+	return isl_stat_error;
 }
 
 /* Given a basic map with one output dimension, compute the minimum or
@@ -6621,7 +6641,7 @@ static __isl_give isl_pw_aff *basic_map_
 {
 	isl_space *dim = isl_basic_map_get_space(bmap);
 	isl_pw_aff *pwaff;
-	int r;
+	isl_stat r;
 
 	dim = isl_space_from_domain(isl_space_domain(dim));
 	dim = isl_space_add_dims(dim, isl_dim_out, 1);
@@ -7544,10 +7564,12 @@ static __isl_give isl_map *map_intersect
 static __isl_give isl_map *map_intersect_range(__isl_take isl_map *map,
 	__isl_take isl_set *set)
 {
-	if (!map || !set)
-		goto error;
+	isl_bool ok;
 
-	if (!isl_map_compatible_range(map, set))
+	ok = isl_map_compatible_range(map, set);
+	if (ok < 0)
+		goto error;
+	if (!ok)
 		isl_die(set->ctx, isl_error_invalid,
 			"incompatible spaces", goto error);
 
@@ -7567,10 +7589,12 @@ __isl_give isl_map *isl_map_intersect_ra
 static __isl_give isl_map *map_intersect_domain(__isl_take isl_map *map,
 	__isl_take isl_set *set)
 {
-	if (!map || !set)
-		goto error;
+	isl_bool ok;
 
-	if (!isl_map_compatible_domain(map, set))
+	ok = isl_map_compatible_domain(map, set);
+	if (ok < 0)
+		goto error;
+	if (!ok)
 		isl_die(set->ctx, isl_error_invalid,
 			"incompatible spaces", goto error);
 
@@ -7964,17 +7988,18 @@ error:
 	return NULL;
 }
 
-static int foreach_orthant(__isl_take isl_set *set, int *signs, int first,
-	int len, int (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
+static isl_stat foreach_orthant(__isl_take isl_set *set, int *signs, int first,
+	int len,
+	isl_stat (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
 	void *user)
 {
 	isl_set *half;
 
 	if (!set)
-		return -1;
+		return isl_stat_error;
 	if (isl_set_plain_is_empty(set)) {
 		isl_set_free(set);
-		return 0;
+		return isl_stat_ok;
 	}
 	if (first == len)
 		return fn(set, signs, user);
@@ -7993,7 +8018,7 @@ static int foreach_orthant(__isl_take is
 	return foreach_orthant(half, signs, first + 1, len, fn, user);
 error:
 	isl_set_free(set);
-	return -1;
+	return isl_stat_error;
 }
 
 /* Call "fn" on the intersections of "set" with each of the orthants
@@ -8001,19 +8026,19 @@ error:
  * by the signs array, with each entry having value 1 or -1 according
  * to the sign of the corresponding variable.
  */
-int isl_set_foreach_orthant(__isl_keep isl_set *set,
-	int (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
+isl_stat isl_set_foreach_orthant(__isl_keep isl_set *set,
+	isl_stat (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
 	void *user)
 {
 	unsigned nparam;
 	unsigned nvar;
 	int *signs;
-	int r;
+	isl_stat r;
 
 	if (!set)
-		return -1;
+		return isl_stat_error;
 	if (isl_set_plain_is_empty(set))
-		return 0;
+		return isl_stat_ok;
 
 	nparam = isl_set_dim(set, isl_dim_param);
 	nvar = isl_set_dim(set, isl_dim_set);
@@ -8113,18 +8138,20 @@ isl_bool isl_set_is_empty(__isl_keep isl
 	return isl_map_is_empty(set_to_map(set));
 }
 
-int isl_map_has_equal_space(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
+isl_bool isl_map_has_equal_space(__isl_keep isl_map *map1,
+	__isl_keep isl_map *map2)
 {
 	if (!map1 || !map2)
-		return -1;
+		return isl_bool_error;
 
 	return isl_space_is_equal(map1->dim, map2->dim);
 }
 
-int isl_set_has_equal_space(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
+isl_bool isl_set_has_equal_space(__isl_keep isl_set *set1,
+	__isl_keep isl_set *set2)
 {
 	if (!set1 || !set2)
-		return -1;
+		return isl_bool_error;
 
 	return isl_space_is_equal(set1->dim, set2->dim);
 }
@@ -8701,9 +8728,14 @@ __isl_give isl_basic_map_list *isl_basic
 static __isl_give isl_set *set_apply( __isl_take isl_set *set,
 	__isl_take isl_map *map)
 {
-	if (!set || !map)
+	isl_bool ok;
+
+	ok = isl_map_compatible_domain(map, set);
+	if (ok < 0)
 		goto error;
-	isl_assert(set->ctx, isl_map_compatible_domain(map, set), goto error);
+	if (!ok)
+		isl_die(isl_set_get_ctx(set), isl_error_invalid,
+			"incompatible spaces", goto error);
 	map = isl_map_intersect_domain(map, set);
 	set = isl_map_range(map);
 	return set;
@@ -8958,15 +8990,15 @@ int isl_set_follows_at(__isl_keep isl_se
 	return follows;
 }
 
-static int isl_basic_map_plain_has_fixed_var(__isl_keep isl_basic_map *bmap,
-	unsigned pos, isl_int *val)
+static isl_bool isl_basic_map_plain_has_fixed_var(
+	__isl_keep isl_basic_map *bmap, unsigned pos, isl_int *val)
 {
 	int i;
 	int d;
 	unsigned total;
 
 	if (!bmap)
-		return -1;
+		return isl_bool_error;
 	total = isl_basic_map_total_dim(bmap);
 	for (i = 0, d = total-1; i < bmap->n_eq && d+1 > pos; ++i) {
 		for (; d+1 > pos; --d)
@@ -8975,39 +9007,39 @@ static int isl_basic_map_plain_has_fixed
 		if (d != pos)
 			continue;
 		if (isl_seq_first_non_zero(bmap->eq[i]+1, d) != -1)
-			return 0;
+			return isl_bool_false;
 		if (isl_seq_first_non_zero(bmap->eq[i]+1+d+1, total-d-1) != -1)
-			return 0;
+			return isl_bool_false;
 		if (!isl_int_is_one(bmap->eq[i][1+d]))
-			return 0;
+			return isl_bool_false;
 		if (val)
 			isl_int_neg(*val, bmap->eq[i][0]);
-		return 1;
+		return isl_bool_true;
 	}
-	return 0;
+	return isl_bool_false;
 }
 
-static int isl_map_plain_has_fixed_var(__isl_keep isl_map *map,
+static isl_bool isl_map_plain_has_fixed_var(__isl_keep isl_map *map,
 	unsigned pos, isl_int *val)
 {
 	int i;
 	isl_int v;
 	isl_int tmp;
-	int fixed;
+	isl_bool fixed;
 
 	if (!map)
-		return -1;
+		return isl_bool_error;
 	if (map->n == 0)
-		return 0;
+		return isl_bool_false;
 	if (map->n == 1)
 		return isl_basic_map_plain_has_fixed_var(map->p[0], pos, val); 
 	isl_int_init(v);
 	isl_int_init(tmp);
 	fixed = isl_basic_map_plain_has_fixed_var(map->p[0], pos, &v); 
-	for (i = 1; fixed == 1 && i < map->n; ++i) {
+	for (i = 1; fixed == isl_bool_true && i < map->n; ++i) {
 		fixed = isl_basic_map_plain_has_fixed_var(map->p[i], pos, &tmp); 
-		if (fixed == 1 && isl_int_ne(tmp, v))
-			fixed = 0;
+		if (fixed == isl_bool_true && isl_int_ne(tmp, v))
+			fixed = isl_bool_false;
 	}
 	if (val)
 		isl_int_set(*val, v);
@@ -9016,8 +9048,8 @@ static int isl_map_plain_has_fixed_var(_
 	return fixed;
 }
 
-static int isl_basic_set_plain_has_fixed_var(__isl_keep isl_basic_set *bset,
-	unsigned pos, isl_int *val)
+static isl_bool isl_basic_set_plain_has_fixed_var(
+	__isl_keep isl_basic_set *bset, unsigned pos, isl_int *val)
 {
 	return isl_basic_map_plain_has_fixed_var(bset_to_bmap(bset),
 						pos, val);
@@ -9029,11 +9061,11 @@ static int isl_set_plain_has_fixed_var(_
 	return isl_map_plain_has_fixed_var(set_to_map(set), pos, val);
 }
 
-int isl_basic_map_plain_is_fixed(__isl_keep isl_basic_map *bmap,
+isl_bool isl_basic_map_plain_is_fixed(__isl_keep isl_basic_map *bmap,
 	enum isl_dim_type type, unsigned pos, isl_int *val)
 {
-	if (pos >= isl_basic_map_dim(bmap, type))
-		return -1;
+	if (isl_basic_map_check_range(bmap, type, pos, 1) < 0)
+		return isl_bool_error;
 	return isl_basic_map_plain_has_fixed_var(bmap,
 		isl_basic_map_offset(bmap, type) - 1 + pos, val);
 }
@@ -9048,7 +9080,7 @@ __isl_give isl_val *isl_basic_map_plain_
 {
 	isl_ctx *ctx;
 	isl_val *v;
-	int fixed;
+	isl_bool fixed;
 
 	if (!bmap)
 		return NULL;
@@ -9067,11 +9099,12 @@ __isl_give isl_val *isl_basic_map_plain_
 	return isl_val_nan(ctx);
 }
 
-int isl_map_plain_is_fixed(__isl_keep isl_map *map,
+isl_bool isl_map_plain_is_fixed(__isl_keep isl_map *map,
 	enum isl_dim_type type, unsigned pos, isl_int *val)
 {
 	if (pos >= isl_map_dim(map, type))
-		return -1;
+		isl_die(isl_map_get_ctx(map), isl_error_invalid,
+			"position out of bounds", return isl_bool_error);
 	return isl_map_plain_has_fixed_var(map,
 		map_offset(map, type) - 1 + pos, val);
 }
@@ -9085,7 +9118,7 @@ __isl_give isl_val *isl_map_plain_get_va
 {
 	isl_ctx *ctx;
 	isl_val *v;
-	int fixed;
+	isl_bool fixed;
 
 	if (!map)
 		return NULL;
@@ -9114,7 +9147,7 @@ __isl_give isl_val *isl_set_plain_get_va
 	return isl_map_plain_get_val_if_fixed(set, type, pos);
 }
 
-int isl_set_plain_is_fixed(__isl_keep isl_set *set,
+isl_bool isl_set_plain_is_fixed(__isl_keep isl_set *set,
 	enum isl_dim_type type, unsigned pos, isl_int *val)
 {
 	return isl_map_plain_is_fixed(set, type, pos, val);
@@ -9123,7 +9156,7 @@ int isl_set_plain_is_fixed(__isl_keep is
 /* Check if dimension dim has fixed value and if so and if val is not NULL,
  * then return this fixed value in *val.
  */
-int isl_basic_set_plain_dim_is_fixed(__isl_keep isl_basic_set *bset,
+isl_bool isl_basic_set_plain_dim_is_fixed(__isl_keep isl_basic_set *bset,
 	unsigned dim, isl_int *val)
 {
 	return isl_basic_set_plain_has_fixed_var(bset,
@@ -9880,7 +9913,7 @@ error:
 __isl_give isl_basic_map *isl_basic_map_range_product(
 	__isl_take isl_basic_map *bmap1, __isl_take isl_basic_map *bmap2)
 {
-	int rational;
+	isl_bool rational;
 	isl_space *dim_result = NULL;
 	isl_basic_map *bmap;
 	unsigned in, out1, out2, nparam, total, pos;
@@ -10607,7 +10640,7 @@ static isl_bool basic_map_dim_is_bounded
 	return lower && upper;
 }
 
-int isl_basic_map_dim_is_bounded(__isl_keep isl_basic_map *bmap,
+isl_bool isl_basic_map_dim_is_bounded(__isl_keep isl_basic_map *bmap,
 	enum isl_dim_type type, unsigned pos)
 {
 	return basic_map_dim_is_bounded(bmap, type, pos, 0, 0);
@@ -10625,28 +10658,28 @@ isl_bool isl_basic_map_dim_has_upper_bou
 	return basic_map_dim_is_bounded(bmap, type, pos, 1, 0);
 }
 
-int isl_map_dim_is_bounded(__isl_keep isl_map *map,
+isl_bool isl_map_dim_is_bounded(__isl_keep isl_map *map,
 	enum isl_dim_type type, unsigned pos)
 {
 	int i;
 
 	if (!map)
-		return -1;
+		return isl_bool_error;
 
 	for (i = 0; i < map->n; ++i) {
-		int bounded;
+		isl_bool bounded;
 		bounded = isl_basic_map_dim_is_bounded(map->p[i], type, pos);
 		if (bounded < 0 || !bounded)
 			return bounded;
 	}
 
-	return 1;
+	return isl_bool_true;
 }
 
-/* Return 1 if the specified dim is involved in both an upper bound
+/* Return true if the specified dim is involved in both an upper bound
  * and a lower bound.
  */
-int isl_set_dim_is_bounded(__isl_keep isl_set *set,
+isl_bool isl_set_dim_is_bounded(__isl_keep isl_set *set,
 	enum isl_dim_type type, unsigned pos)
 {
 	return isl_map_dim_is_bounded(set_to_map(set), type, pos);
@@ -10738,7 +10771,7 @@ isl_bool isl_set_dim_has_upper_bound(__i
  *	-1 means that the variable is non-positive
  *	0 means the variable attains both positive and negative values.
  */
-int isl_basic_set_vars_get_sign(__isl_keep isl_basic_set *bset,
+isl_stat isl_basic_set_vars_get_sign(__isl_keep isl_basic_set *bset,
 	unsigned first, unsigned n, int *signs)
 {
 	isl_vec *bound = NULL;
@@ -10747,7 +10780,7 @@ int isl_basic_set_vars_get_sign(__isl_ke
 	int i;
 
 	if (!bset || !signs)
-		return -1;
+		return isl_stat_error;
 
 	bound = isl_vec_alloc(bset->ctx, 1 + isl_basic_set_total_dim(bset));
 	tab = isl_tab_from_basic_set(bset, 0);
@@ -10787,20 +10820,20 @@ int isl_basic_set_vars_get_sign(__isl_ke
 
 	isl_tab_free(tab);
 	isl_vec_free(bound);
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_tab_free(tab);
 	isl_vec_free(bound);
-	return -1;
+	return isl_stat_error;
 }
 
-int isl_basic_set_dims_get_sign(__isl_keep isl_basic_set *bset,
+isl_stat isl_basic_set_dims_get_sign(__isl_keep isl_basic_set *bset,
 	enum isl_dim_type type, unsigned first, unsigned n, int *signs)
 {
 	if (!bset || !signs)
-		return -1;
+		return isl_stat_error;
 	isl_assert(bset->ctx, first + n <= isl_basic_set_dim(bset, type),
-		return -1);
+		return isl_stat_error);
 
 	first += pos(bset->dim, type) - 1;
 	return isl_basic_set_vars_get_sign(bset, first, n, signs);
@@ -10814,32 +10847,35 @@ int isl_basic_set_dims_get_sign(__isl_ke
  * Otherwise, we check if it actually depends on them or on any integer
  * divisions that may depend on them.
  */
-static int div_may_involve_output(__isl_keep isl_basic_map *bmap, int div)
+static isl_bool div_may_involve_output(__isl_keep isl_basic_map *bmap, int div)
 {
 	int i;
 	unsigned n_out, o_out;
 	unsigned n_div, o_div;
 
 	if (isl_int_is_zero(bmap->div[div][0]))
-		return 1;
+		return isl_bool_true;
 
 	n_out = isl_basic_map_dim(bmap, isl_dim_out);
 	o_out = isl_basic_map_offset(bmap, isl_dim_out);
 
 	if (isl_seq_first_non_zero(bmap->div[div] + 1 + o_out, n_out) != -1)
-		return 1;
+		return isl_bool_true;
 
 	n_div = isl_basic_map_dim(bmap, isl_dim_div);
 	o_div = isl_basic_map_offset(bmap, isl_dim_div);
 
 	for (i = 0; i < n_div; ++i) {
+		isl_bool may_involve;
+
 		if (isl_int_is_zero(bmap->div[div][1 + o_div + i]))
 			continue;
-		if (div_may_involve_output(bmap, i))
-			return 1;
+		may_involve = div_may_involve_output(bmap, i);
+		if (may_involve < 0 || may_involve)
+			return may_involve;
 	}
 
-	return 0;
+	return isl_bool_false;
 }
 
 /* Return the first integer division of "bmap" in the range
@@ -10856,9 +10892,14 @@ static int first_div_may_involve_output(
 		return -1;
 
 	for (k = first; k < first + n; ++k) {
+		isl_bool may_involve;
+
 		if (isl_int_is_zero(c[k]))
 			continue;
-		if (div_may_involve_output(bmap, k))
+		may_involve = div_may_involve_output(bmap, k);
+		if (may_involve < 0)
+			return -1;
+		if (may_involve)
 			return k;
 	}
 
@@ -11206,17 +11247,17 @@ static int unique(isl_int *p, unsigned p
 	return 1;
 }
 
-int isl_basic_set_is_box(__isl_keep isl_basic_set *bset)
+isl_bool isl_basic_set_is_box(__isl_keep isl_basic_set *bset)
 {
 	int i, j;
 	unsigned nvar;
 	unsigned ovar;
 
 	if (!bset)
-		return -1;
+		return isl_bool_error;
 
 	if (isl_basic_set_dim(bset, isl_dim_div) != 0)
-		return 0;
+		return isl_bool_false;
 
 	nvar = isl_basic_set_dim(bset, isl_dim_set);
 	ovar = isl_space_offset(bset->dim, isl_dim_set);
@@ -11226,7 +11267,7 @@ int isl_basic_set_is_box(__isl_keep isl_
 			if (isl_int_is_zero(bset->eq[i][1 + ovar + j]))
 				continue;
 			if (!unique(bset->eq[i] + 1 + ovar, j, nvar))
-				return 0;
+				return isl_bool_false;
 			break;
 		}
 		if (i < bset->n_eq)
@@ -11235,25 +11276,25 @@ int isl_basic_set_is_box(__isl_keep isl_
 			if (isl_int_is_zero(bset->ineq[i][1 + ovar + j]))
 				continue;
 			if (!unique(bset->ineq[i] + 1 + ovar, j, nvar))
-				return 0;
+				return isl_bool_false;
 			if (isl_int_is_pos(bset->ineq[i][1 + ovar + j]))
 				lower = 1;
 			else
 				upper = 1;
 		}
 		if (!lower || !upper)
-			return 0;
+			return isl_bool_false;
 	}
 
-	return 1;
+	return isl_bool_true;
 }
 
-int isl_set_is_box(__isl_keep isl_set *set)
+isl_bool isl_set_is_box(__isl_keep isl_set *set)
 {
 	if (!set)
-		return -1;
+		return isl_bool_error;
 	if (set->n != 1)
-		return 0;
+		return isl_bool_false;
 
 	return isl_basic_set_is_box(set->p[0]);
 }
@@ -12696,13 +12737,12 @@ error:
 
 /* Check if the range of "ma" is compatible with the domain or range
  * (depending on "type") of "bmap".
- * Return -1 if anything is wrong.
  */
-static int check_basic_map_compatible_range_multi_aff(
+static isl_stat check_basic_map_compatible_range_multi_aff(
 	__isl_keep isl_basic_map *bmap, enum isl_dim_type type,
 	__isl_keep isl_multi_aff *ma)
 {
-	int m;
+	isl_bool m;
 	isl_space *ma_space;
 
 	ma_space = isl_multi_aff_get_space(ma);
@@ -12721,10 +12761,10 @@ static int check_basic_map_compatible_ra
 			"spaces don't match", goto error);
 
 	isl_space_free(ma_space);
-	return m;
+	return isl_stat_ok;
 error:
 	isl_space_free(ma_space);
-	return -1;
+	return isl_stat_error;
 }
 
 /* Copy the divs from "ma" to "bmap", adding zeros for the "n_before"
@@ -12934,7 +12974,8 @@ __isl_give isl_basic_map *isl_basic_map_
 	isl_basic_map *res = NULL;
 	int n_before, n_after, n_div_bmap, n_div_ma;
 	isl_int f, c1, c2, g;
-	int rational, strides;
+	isl_bool rational;
+	int strides;
 
 	isl_int_init(f);
 	isl_int_init(c1);
@@ -13057,22 +13098,24 @@ __isl_give isl_basic_map *isl_basic_map_
 
 /* Check if the range of "ma" is compatible with the domain or range
  * (depending on "type") of "map".
- * Return -1 if anything is wrong.
+ * Return isl_stat_error if anything is wrong.
  */
-static int check_map_compatible_range_multi_aff(
+static isl_stat check_map_compatible_range_multi_aff(
 	__isl_keep isl_map *map, enum isl_dim_type type,
 	__isl_keep isl_multi_aff *ma)
 {
-	int m;
+	isl_bool m;
 	isl_space *ma_space;
 
 	ma_space = isl_multi_aff_get_space(ma);
 	m = isl_space_tuple_is_equal(map->dim, type, ma_space, isl_dim_out);
 	isl_space_free(ma_space);
-	if (m >= 0 && !m)
+	if (m < 0)
+		return isl_stat_error;
+	if (!m)
 		isl_die(isl_map_get_ctx(map), isl_error_invalid,
-			"spaces don't match", return -1);
-	return m;
+			"spaces don't match", return isl_stat_error);
+	return isl_stat_ok;
 }
 
 /* Compute the preimage of the domain or range (depending on "type")

Modified: polly/trunk/lib/External/isl/isl_map_private.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_map_private.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_map_private.h (original)
+++ polly/trunk/lib/External/isl/isl_map_private.h Thu Feb 16 23:11:16 2017
@@ -186,13 +186,14 @@ unsigned isl_basic_map_offset(struct isl
 unsigned isl_basic_set_offset(struct isl_basic_set *bset,
 					enum isl_dim_type type);
 
-int isl_basic_map_may_be_set(__isl_keep isl_basic_map *bmap);
+isl_bool isl_basic_map_may_be_set(__isl_keep isl_basic_map *bmap);
 int isl_map_may_be_set(__isl_keep isl_map *map);
-int isl_map_compatible_domain(struct isl_map *map, struct isl_set *set);
+isl_bool isl_map_compatible_domain(__isl_keep isl_map *map,
+	__isl_keep isl_set *set);
 isl_bool isl_basic_map_compatible_domain(__isl_keep isl_basic_map *bmap,
 	__isl_keep isl_basic_set *bset);
-int isl_basic_map_compatible_range(struct isl_basic_map *bmap,
-		struct isl_basic_set *bset);
+isl_bool isl_basic_map_compatible_range(__isl_keep isl_basic_map *bmap,
+	__isl_keep isl_basic_set *bset);
 
 struct isl_basic_map *isl_basic_map_extend_space(struct isl_basic_map *base,
 		__isl_take isl_space *dim, unsigned extra,
@@ -234,8 +235,8 @@ int isl_basic_map_alloc_div(struct isl_b
 __isl_give isl_basic_map *isl_basic_map_insert_div(
 	__isl_take isl_basic_map *bmap, int pos, __isl_keep isl_vec *div);
 int isl_basic_set_alloc_div(struct isl_basic_set *bset);
-int isl_basic_map_free_div(struct isl_basic_map *bmap, unsigned n);
-int isl_basic_set_free_div(struct isl_basic_set *bset, unsigned n);
+isl_stat isl_basic_map_free_div(struct isl_basic_map *bmap, unsigned n);
+isl_stat isl_basic_set_free_div(struct isl_basic_set *bset, unsigned n);
 __isl_give isl_basic_map *isl_basic_map_drop_div(
 	__isl_take isl_basic_map *bmap, unsigned div);
 void isl_basic_map_inequality_to_equality(
@@ -388,8 +389,8 @@ __isl_give isl_map *isl_map_set_rational
 isl_bool isl_map_is_rational(__isl_keep isl_map *map);
 isl_bool isl_set_is_rational(__isl_keep isl_set *set);
 
-int isl_map_has_rational(__isl_keep isl_map *map);
-int isl_set_has_rational(__isl_keep isl_set *set);
+isl_bool isl_map_has_rational(__isl_keep isl_map *map);
+isl_bool isl_set_has_rational(__isl_keep isl_set *set);
 
 __isl_give isl_basic_map *isl_basic_map_from_multi_aff2(
 	__isl_take isl_multi_aff *maff, int rational);
@@ -415,19 +416,19 @@ isl_bool isl_basic_map_contains_point(__
 isl_bool isl_set_contains_point(__isl_keep isl_set *set,
 	__isl_keep isl_point *point);
 
-int isl_basic_set_vars_get_sign(__isl_keep isl_basic_set *bset,
+isl_stat isl_basic_set_vars_get_sign(__isl_keep isl_basic_set *bset,
 	unsigned first, unsigned n, int *signs);
-int isl_set_foreach_orthant(__isl_keep isl_set *set,
-	int (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
+isl_stat isl_set_foreach_orthant(__isl_keep isl_set *set,
+	isl_stat (*fn)(__isl_take isl_set *orthant, int *signs, void *user),
 	void *user);
 
 int isl_basic_map_add_div_constraints_var(__isl_keep isl_basic_map *bmap,
 	unsigned pos, isl_int *div);
 int isl_basic_set_add_div_constraints_var(__isl_keep isl_basic_set *bset,
 	unsigned pos, isl_int *div);
-int isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
+isl_bool isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
 	isl_int *constraint, unsigned div);
-int isl_basic_set_is_div_constraint(__isl_keep isl_basic_set *bset,
+isl_bool isl_basic_set_is_div_constraint(__isl_keep isl_basic_set *bset,
 	isl_int *constraint, unsigned div);
 
 __isl_give isl_basic_set *isl_basic_set_from_local_space(
@@ -463,13 +464,13 @@ isl_bool isl_map_align_params_map_map_an
 	__isl_keep isl_map *map2,
 	isl_bool (*fn)(__isl_keep isl_map *map1, __isl_keep isl_map *map2));
 
-int isl_basic_map_foreach_lexopt(__isl_keep isl_basic_map *bmap, int max,
-	int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_aff_list *list,
-		  void *user),
+isl_stat isl_basic_map_foreach_lexopt(__isl_keep isl_basic_map *bmap, int max,
+	isl_stat (*fn)(__isl_take isl_basic_set *dom,
+		__isl_take isl_aff_list *list, void *user),
 	void *user);
-int isl_basic_set_foreach_lexopt(__isl_keep isl_basic_set *bset, int max,
-	int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_aff_list *list,
-		  void *user),
+isl_stat isl_basic_set_foreach_lexopt(__isl_keep isl_basic_set *bset, int max,
+	isl_stat (*fn)(__isl_take isl_basic_set *dom,
+		__isl_take isl_aff_list *list, void *user),
 	void *user);
 
 __isl_give isl_set *isl_set_substitute(__isl_take isl_set *set,
@@ -478,14 +479,15 @@ __isl_give isl_set *isl_set_substitute(_
 __isl_give isl_set *isl_set_gist_params_basic_set(__isl_take isl_set *set,
 	__isl_take isl_basic_set *context);
 
-int isl_map_compatible_range(__isl_keep isl_map *map, __isl_keep isl_set *set);
+isl_bool isl_map_compatible_range(__isl_keep isl_map *map,
+	__isl_keep isl_set *set);
 
 isl_bool isl_basic_map_plain_is_non_empty(__isl_keep isl_basic_map *bmap);
 isl_bool isl_basic_map_plain_is_single_valued(__isl_keep isl_basic_map *bmap);
 
-int isl_map_is_set(__isl_keep isl_map *map);
+isl_bool isl_map_is_set(__isl_keep isl_map *map);
 
-int isl_basic_set_plain_dim_is_fixed(__isl_keep isl_basic_set *bset,
+isl_bool isl_basic_set_plain_dim_is_fixed(__isl_keep isl_basic_set *bset,
 	unsigned dim, isl_int *val);
 
 __isl_give isl_map *isl_map_plain_gist_basic_map(__isl_take isl_map *map,
@@ -496,9 +498,9 @@ __isl_give isl_basic_set *isl_basic_set_
 __isl_give isl_basic_map *isl_basic_map_plain_affine_hull(
 	__isl_take isl_basic_map *bmap);
 
-int isl_basic_set_dim_residue_class(struct isl_basic_set *bset,
+isl_stat isl_basic_set_dim_residue_class(__isl_keep isl_basic_set *bset,
 	int pos, isl_int *modulo, isl_int *residue);
-int isl_set_dim_residue_class(struct isl_set *set,
+isl_stat isl_set_dim_residue_class(__isl_keep isl_set *set,
 	int pos, isl_int *modulo, isl_int *residue);
 
 __isl_give isl_basic_set *isl_basic_set_fix(__isl_take isl_basic_set *bset,
@@ -507,7 +509,7 @@ __isl_give isl_basic_map *isl_basic_map_
 	enum isl_dim_type type, unsigned pos, isl_int value);
 __isl_give isl_set *isl_set_fix(__isl_take isl_set *set,
 	enum isl_dim_type type, unsigned pos, isl_int value);
-int isl_map_plain_is_fixed(__isl_keep isl_map *map,
+isl_bool isl_map_plain_is_fixed(__isl_keep isl_map *map,
 	enum isl_dim_type type, unsigned pos, isl_int *val);
 
 int isl_basic_map_output_defining_equality(__isl_keep isl_basic_map *bmap,

Modified: polly/trunk/lib/External/isl/isl_map_simplify.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_map_simplify.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_map_simplify.c (original)
+++ polly/trunk/lib/External/isl/isl_map_simplify.c Thu Feb 16 23:11:16 2017
@@ -200,7 +200,8 @@ struct isl_basic_map *isl_basic_map_drop
 		bmap = move_divs_last(bmap, first, n);
 		if (!bmap)
 			goto error;
-		isl_basic_map_free_div(bmap, n);
+		if (isl_basic_map_free_div(bmap, n) < 0)
+			return isl_basic_map_free(bmap);
 	} else
 		bmap->dim = isl_space_drop_dims(bmap->dim, type, first, n);
 	if (!bmap->dim)
@@ -312,7 +313,8 @@ __isl_give isl_basic_map *isl_basic_map_
 		bmap->div[bmap->n_div - 1] = t;
 	}
 	ISL_F_CLR(bmap, ISL_BASIC_MAP_NORMALIZED);
-	isl_basic_map_free_div(bmap, 1);
+	if (isl_basic_map_free_div(bmap, 1) < 0)
+		return isl_basic_map_free(bmap);
 
 	return bmap;
 error:
@@ -381,26 +383,39 @@ struct isl_basic_set *isl_basic_set_norm
 	return bset_from_bmap(isl_basic_map_normalize_constraints(bmap));
 }
 
-/* Assuming the variable at position "pos" has an integer coefficient
- * in integer division "div", extract it from this integer division.
+/* Reduce the coefficient of the variable at position "pos"
+ * in integer division "div", such that it lies in the half-open
+ * interval (1/2,1/2], extracting any excess value from this integer division.
  * "pos" is as determined by isl_basic_map_offset, i.e., pos == 0
  * corresponds to the constant term.
  *
  * That is, the integer division is of the form
  *
- *	floor((... + c * d * x_pos + ...)/d)
+ *	floor((... + (c * d + r) * x_pos + ...)/d)
  *
+ * with -d < 2 * r <= d.
  * Replace it by
  *
- *	floor((... + 0 * x_pos + ...)/d) + c * x_pos
+ *	floor((... + r * x_pos + ...)/d) + c * x_pos
+ *
+ * If 2 * ((c * d + r) % d) <= d, then c = floor((c * d + r)/d).
+ * Otherwise, c = floor((c * d + r)/d) + 1.
+ *
+ * This is the same normalization that is performed by isl_aff_floor.
  */
-static __isl_give isl_basic_map *remove_var_from_div(
+static __isl_give isl_basic_map *reduce_coefficient_in_div(
 	__isl_take isl_basic_map *bmap, int div, int pos)
 {
 	isl_int shift;
+	int add_one;
 
 	isl_int_init(shift);
-	isl_int_divexact(shift, bmap->div[div][1 + pos], bmap->div[div][0]);
+	isl_int_fdiv_r(shift, bmap->div[div][1 + pos], bmap->div[div][0]);
+	isl_int_mul_ui(shift, shift, 2);
+	add_one = isl_int_gt(shift, bmap->div[div][0]);
+	isl_int_fdiv_q(shift, bmap->div[div][1 + pos], bmap->div[div][0]);
+	if (add_one)
+		isl_int_add_ui(shift, shift, 1);
 	isl_int_neg(shift, shift);
 	bmap = isl_basic_map_shift_div(bmap, div, pos, shift);
 	isl_int_clear(shift);
@@ -408,22 +423,49 @@ static __isl_give isl_basic_map *remove_
 	return bmap;
 }
 
-/* Check if integer division "div" has any integral coefficient
- * (or constant term).  If so, extract them from the integer division.
+/* Does the coefficient of the variable at position "pos"
+ * in integer division "div" need to be reduced?
+ * That is, does it lie outside the half-open interval (1/2,1/2]?
+ * The coefficient c/d lies outside this interval if abs(2 * c) >= d and
+ * 2 * c != d.
+ */
+static isl_bool needs_reduction(__isl_keep isl_basic_map *bmap, int div,
+	int pos)
+{
+	isl_bool r;
+
+	if (isl_int_is_zero(bmap->div[div][1 + pos]))
+		return isl_bool_false;
+
+	isl_int_mul_ui(bmap->div[div][1 + pos], bmap->div[div][1 + pos], 2);
+	r = isl_int_abs_ge(bmap->div[div][1 + pos], bmap->div[div][0]) &&
+	    !isl_int_eq(bmap->div[div][1 + pos], bmap->div[div][0]);
+	isl_int_divexact_ui(bmap->div[div][1 + pos],
+			    bmap->div[div][1 + pos], 2);
+
+	return r;
+}
+
+/* Reduce the coefficients (including the constant term) of
+ * integer division "div", if needed.
+ * In particular, make sure all coefficients lie in
+ * the half-open interval (1/2,1/2].
  */
-static __isl_give isl_basic_map *remove_independent_vars_from_div(
+static __isl_give isl_basic_map *reduce_div_coefficients_of_div(
 	__isl_take isl_basic_map *bmap, int div)
 {
 	int i;
 	unsigned total = 1 + isl_basic_map_total_dim(bmap);
 
 	for (i = 0; i < total; ++i) {
-		if (isl_int_is_zero(bmap->div[div][1 + i]))
-			continue;
-		if (!isl_int_is_divisible_by(bmap->div[div][1 + i],
-					     bmap->div[div][0]))
+		isl_bool reduce;
+
+		reduce = needs_reduction(bmap, div, i);
+		if (reduce < 0)
+			return isl_basic_map_free(bmap);
+		if (!reduce)
 			continue;
-		bmap = remove_var_from_div(bmap, div, i);
+		bmap = reduce_coefficient_in_div(bmap, div, i);
 		if (!bmap)
 			break;
 	}
@@ -431,10 +473,12 @@ static __isl_give isl_basic_map *remove_
 	return bmap;
 }
 
-/* Check if any known integer division has any integral coefficient
- * (or constant term).  If so, extract them from the integer division.
+/* Reduce the coefficients (including the constant term) of
+ * the known integer divisions, if needed
+ * In particular, make sure all coefficients lie in
+ * the half-open interval (1/2,1/2].
  */
-static __isl_give isl_basic_map *remove_independent_vars_from_divs(
+static __isl_give isl_basic_map *reduce_div_coefficients(
 	__isl_take isl_basic_map *bmap)
 {
 	int i;
@@ -447,7 +491,7 @@ static __isl_give isl_basic_map *remove_
 	for (i = 0; i < bmap->n_div; ++i) {
 		if (isl_int_is_zero(bmap->div[i][0]))
 			continue;
-		bmap = remove_independent_vars_from_div(bmap, i);
+		bmap = reduce_div_coefficients_of_div(bmap, i);
 		if (!bmap)
 			break;
 	}
@@ -591,7 +635,7 @@ static __isl_give isl_basic_map *elimina
 /* Check if elimination of div "div" using equality "eq" would not
  * result in a div depending on a later div.
  */
-static int ok_to_eliminate_div(struct isl_basic_map *bmap, isl_int *eq,
+static isl_bool ok_to_eliminate_div(struct isl_basic_map *bmap, isl_int *eq,
 	unsigned div)
 {
 	int k;
@@ -601,19 +645,19 @@ static int ok_to_eliminate_div(struct is
 
 	last_div = isl_seq_last_non_zero(eq + 1 + space_total, bmap->n_div);
 	if (last_div < 0 || last_div <= div)
-		return 1;
+		return isl_bool_true;
 
 	for (k = 0; k <= last_div; ++k) {
 		if (isl_int_is_zero(bmap->div[k][0]))
-			return 1;
+			continue;
 		if (!isl_int_is_zero(bmap->div[k][1 + 1 + pos]))
-			return 0;
+			return isl_bool_false;
 	}
 
-	return 1;
+	return isl_bool_true;
 }
 
-/* Elimininate divs based on equalities
+/* Eliminate divs based on equalities
  */
 static struct isl_basic_map *eliminate_divs_eq(
 		struct isl_basic_map *bmap, int *progress)
@@ -632,10 +676,15 @@ static struct isl_basic_map *eliminate_d
 
 	for (d = bmap->n_div - 1; d >= 0 ; --d) {
 		for (i = 0; i < bmap->n_eq; ++i) {
+			isl_bool ok;
+
 			if (!isl_int_is_one(bmap->eq[i][off + d]) &&
 			    !isl_int_is_negone(bmap->eq[i][off + d]))
 				continue;
-			if (!ok_to_eliminate_div(bmap, bmap->eq[i], d))
+			ok = ok_to_eliminate_div(bmap, bmap->eq[i], d);
+			if (ok < 0)
+				return isl_basic_map_free(bmap);
+			if (!ok)
 				continue;
 			modified = 1;
 			*progress = 1;
@@ -688,6 +737,88 @@ static struct isl_basic_map *eliminate_d
 	return bmap;
 }
 
+/* Does the equality constraint at position "eq" in "bmap" involve
+ * any local variables in the range [first, first + n)
+ * that are not marked as having an explicit representation?
+ */
+static isl_bool bmap_eq_involves_unknown_divs(__isl_keep isl_basic_map *bmap,
+	int eq, unsigned first, unsigned n)
+{
+	unsigned o_div;
+	int i;
+
+	if (!bmap)
+		return isl_bool_error;
+
+	o_div = isl_basic_map_offset(bmap, isl_dim_div);
+	for (i = 0; i < n; ++i) {
+		isl_bool unknown;
+
+		if (isl_int_is_zero(bmap->eq[eq][o_div + first + i]))
+			continue;
+		unknown = isl_basic_map_div_is_marked_unknown(bmap, first + i);
+		if (unknown < 0)
+			return isl_bool_error;
+		if (unknown)
+			return isl_bool_true;
+	}
+
+	return isl_bool_false;
+}
+
+/* The last local variable involved in the equality constraint
+ * at position "eq" in "bmap" is the local variable at position "div".
+ * It can therefore be used to extract an explicit representation
+ * for that variable.
+ * Do so unless the local variable already has an explicit representation or
+ * the explicit representation would involve any other local variables
+ * that in turn do not have an explicit representation.
+ * An equality constraint involving local variables without an explicit
+ * representation can be used in isl_basic_map_drop_redundant_divs
+ * to separate out an independent local variable.  Introducing
+ * an explicit representation here would block this transformation,
+ * while the partial explicit representation in itself is not very useful.
+ * Set *progress if anything is changed.
+ *
+ * The equality constraint is of the form
+ *
+ *	f(x) + n e >= 0
+ *
+ * with n a positive number.  The explicit representation derived from
+ * this constraint is
+ *
+ *	floor((-f(x))/n)
+ */
+static __isl_give isl_basic_map *set_div_from_eq(__isl_take isl_basic_map *bmap,
+	int div, int eq, int *progress)
+{
+	unsigned total, o_div;
+	isl_bool involves;
+
+	if (!bmap)
+		return NULL;
+
+	if (!isl_int_is_zero(bmap->div[div][0]))
+		return bmap;
+
+	involves = bmap_eq_involves_unknown_divs(bmap, eq, 0, div);
+	if (involves < 0)
+		return isl_basic_map_free(bmap);
+	if (involves)
+		return bmap;
+
+	total = isl_basic_map_dim(bmap, isl_dim_all);
+	o_div = isl_basic_map_offset(bmap, isl_dim_div);
+	isl_seq_neg(bmap->div[div] + 1, bmap->eq[eq], 1 + total);
+	isl_int_set_si(bmap->div[div][1 + o_div + div], 0);
+	isl_int_set(bmap->div[div][0], bmap->eq[eq][o_div + div]);
+	if (progress)
+		*progress = 1;
+	ISL_F_CLR(bmap, ISL_BASIC_MAP_NORMALIZED);
+
+	return bmap;
+}
+
 struct isl_basic_map *isl_basic_map_gauss(
 	struct isl_basic_map *bmap, int *progress)
 {
@@ -724,17 +855,11 @@ struct isl_basic_map *isl_basic_map_gaus
 		eliminate_var_using_equality(bmap, last_var, bmap->eq[done], 1,
 						progress);
 
-		if (last_var >= total_var &&
-		    isl_int_is_zero(bmap->div[last_var - total_var][0])) {
-			unsigned div = last_var - total_var;
-			isl_seq_neg(bmap->div[div]+1, bmap->eq[done], 1+total);
-			isl_int_set_si(bmap->div[div][1+1+last_var], 0);
-			isl_int_set(bmap->div[div][0],
-				    bmap->eq[done][1+last_var]);
-			if (progress)
-				*progress = 1;
-			ISL_F_CLR(bmap, ISL_BASIC_MAP_NORMALIZED);
-		}
+		if (last_var >= total_var)
+			bmap = set_div_from_eq(bmap, last_var - total_var,
+						done, progress);
+		if (!bmap)
+			return NULL;
 	}
 	if (done == bmap->n_eq)
 		return bmap;
@@ -1050,7 +1175,7 @@ static struct isl_basic_map *normalize_d
 	struct isl_mat *C = NULL;
 	struct isl_mat *C2 = NULL;
 	isl_int v;
-	int *pos;
+	int *pos = NULL;
 	int dropped, needed;
 
 	if (!bmap)
@@ -1181,6 +1306,7 @@ done:
 
 	return bmap;
 error:
+	free(pos);
 	isl_mat_free(C);
 	isl_mat_free(C2);
 	isl_mat_free(T);
@@ -1207,7 +1333,7 @@ static struct isl_basic_map *set_div_fro
  * any other undefined divs or if any known div is defined in
  * terms of the unknown div.
  */
-static int ok_to_set_div_from_bound(struct isl_basic_map *bmap,
+static isl_bool ok_to_set_div_from_bound(struct isl_basic_map *bmap,
 	int div, int ineq)
 {
 	int j;
@@ -1220,7 +1346,7 @@ static int ok_to_set_div_from_bound(stru
 		if (isl_int_is_zero(bmap->ineq[ineq][total + j]))
 			continue;
 		if (isl_int_is_zero(bmap->div[j][0]))
-			return 0;
+			return isl_bool_false;
 	}
 
 	/* No other div defined in terms of this one => avoid loops */
@@ -1230,10 +1356,10 @@ static int ok_to_set_div_from_bound(stru
 		if (isl_int_is_zero(bmap->div[j][0]))
 			continue;
 		if (!isl_int_is_zero(bmap->div[j][1 + total + div]))
-			return 0;
+			return isl_bool_false;
 	}
 
-	return 1;
+	return isl_bool_true;
 }
 
 /* Would an expression for div "div" based on inequality "ineq" of "bmap"
@@ -1244,7 +1370,7 @@ static int ok_to_set_div_from_bound(stru
  * (disregarding the div that it would define) is in an earlier position
  * than the last variable involved in the current div expression.
  */
-static int better_div_constraint(__isl_keep isl_basic_map *bmap,
+static isl_bool better_div_constraint(__isl_keep isl_basic_map *bmap,
 	int div, int ineq)
 {
 	unsigned total = 1 + isl_space_dim(bmap->dim, isl_dim_all);
@@ -1252,11 +1378,11 @@ static int better_div_constraint(__isl_k
 	int last_ineq;
 
 	if (isl_int_is_zero(bmap->div[div][0]))
-		return 1;
+		return isl_bool_true;
 
 	if (isl_seq_last_non_zero(bmap->ineq[ineq] + total + div + 1,
 				  bmap->n_div - (div + 1)) >= 0)
-		return 0;
+		return isl_bool_false;
 
 	last_ineq = isl_seq_last_non_zero(bmap->ineq[ineq], total + div);
 	last_div = isl_seq_last_non_zero(bmap->div[div] + 1,
@@ -1284,13 +1410,18 @@ static struct isl_basic_map *check_for_d
 	unsigned total = 1 + isl_space_dim(bmap->dim, isl_dim_all);
 
 	for (i = 0; i < bmap->n_div; ++i) {
+		isl_bool set_div;
+
 		if (isl_int_is_zero(bmap->ineq[k][total + i]))
 			continue;
 		if (isl_int_abs_ge(sum, bmap->ineq[k][total + i]))
 			continue;
-		if (!better_div_constraint(bmap, i, k))
-			continue;
-		if (!ok_to_set_div_from_bound(bmap, i, k))
+		set_div = better_div_constraint(bmap, i, k);
+		if (set_div >= 0 && set_div)
+			set_div = ok_to_set_div_from_bound(bmap, i, k);
+		if (set_div < 0)
+			return isl_basic_map_free(bmap);
+		if (!set_div)
 			break;
 		if (isl_int_is_pos(bmap->ineq[k][total + i]))
 			bmap = set_div_from_lower_bound(bmap, i, k);
@@ -1488,13 +1619,16 @@ struct isl_basic_map *isl_basic_map_simp
 	if (!bmap)
 		return NULL;
 	while (progress) {
+		isl_bool empty;
+
 		progress = 0;
-		if (!bmap)
-			break;
-		if (isl_basic_map_plain_is_empty(bmap))
+		empty = isl_basic_map_plain_is_empty(bmap);
+		if (empty < 0)
+			return isl_basic_map_free(bmap);
+		if (empty)
 			break;
 		bmap = isl_basic_map_normalize_constraints(bmap);
-		bmap = remove_independent_vars_from_divs(bmap);
+		bmap = reduce_div_coefficients(bmap);
 		bmap = normalize_div_expressions(bmap);
 		bmap = remove_duplicate_divs(bmap, &progress);
 		bmap = eliminate_unit_divs(bmap, &progress);
@@ -1517,13 +1651,13 @@ struct isl_basic_set *isl_basic_set_simp
 }
 
 
-int isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
+isl_bool isl_basic_map_is_div_constraint(__isl_keep isl_basic_map *bmap,
 	isl_int *constraint, unsigned div)
 {
 	unsigned pos;
 
 	if (!bmap)
-		return -1;
+		return isl_bool_error;
 
 	pos = 1 + isl_space_dim(bmap->dim, isl_dim_all) + div;
 
@@ -1537,23 +1671,23 @@ int isl_basic_map_is_div_constraint(__is
 		isl_int_add(bmap->div[div][1],
 				bmap->div[div][1], bmap->div[div][0]);
 		if (!neg)
-			return 0;
+			return isl_bool_false;
 		if (isl_seq_first_non_zero(constraint+pos+1,
 					    bmap->n_div-div-1) != -1)
-			return 0;
+			return isl_bool_false;
 	} else if (isl_int_abs_eq(constraint[pos], bmap->div[div][0])) {
 		if (!isl_seq_eq(constraint, bmap->div[div]+1, pos))
-			return 0;
+			return isl_bool_false;
 		if (isl_seq_first_non_zero(constraint+pos+1,
 					    bmap->n_div-div-1) != -1)
-			return 0;
+			return isl_bool_false;
 	} else
-		return 0;
+		return isl_bool_false;
 
-	return 1;
+	return isl_bool_true;
 }
 
-int isl_basic_set_is_div_constraint(__isl_keep isl_basic_set *bset,
+isl_bool isl_basic_set_is_div_constraint(__isl_keep isl_basic_set *bset,
 	isl_int *constraint, unsigned div)
 {
 	return isl_basic_map_is_div_constraint(bset, constraint, div);
@@ -1568,30 +1702,33 @@ int isl_basic_set_is_div_constraint(__is
  *
  * then it can safely be removed.
  */
-static int div_is_redundant(struct isl_basic_map *bmap, int div)
+static isl_bool div_is_redundant(struct isl_basic_map *bmap, int div)
 {
 	int i;
 	unsigned pos = 1 + isl_space_dim(bmap->dim, isl_dim_all) + div;
 
 	for (i = 0; i < bmap->n_eq; ++i)
 		if (!isl_int_is_zero(bmap->eq[i][pos]))
-			return 0;
+			return isl_bool_false;
 
 	for (i = 0; i < bmap->n_ineq; ++i) {
+		isl_bool red;
+
 		if (isl_int_is_zero(bmap->ineq[i][pos]))
 			continue;
-		if (!isl_basic_map_is_div_constraint(bmap, bmap->ineq[i], div))
-			return 0;
+		red = isl_basic_map_is_div_constraint(bmap, bmap->ineq[i], div);
+		if (red < 0 || !red)
+			return red;
 	}
 
 	for (i = 0; i < bmap->n_div; ++i) {
 		if (isl_int_is_zero(bmap->div[i][0]))
 			continue;
 		if (!isl_int_is_zero(bmap->div[i][1+pos]))
-			return 0;
+			return isl_bool_false;
 	}
 
-	return 1;
+	return isl_bool_true;
 }
 
 /*
@@ -1608,7 +1745,12 @@ static struct isl_basic_map *remove_redu
 		return NULL;
 
 	for (i = bmap->n_div-1; i >= 0; --i) {
-		if (!div_is_redundant(bmap, i))
+		isl_bool redundant;
+
+		redundant = div_is_redundant(bmap, i);
+		if (redundant < 0)
+			return isl_basic_map_free(bmap);
+		if (!redundant)
 			continue;
 		bmap = isl_basic_map_drop_div(bmap, i);
 	}
@@ -2504,7 +2646,6 @@ static __isl_give isl_basic_set *uset_gi
 	isl_basic_set *combined = NULL;
 	struct isl_tab *tab = NULL;
 	unsigned n_eq, context_ineq;
-	unsigned total;
 
 	if (!bset || !ineq || !context)
 		goto error;
@@ -2554,7 +2695,6 @@ static __isl_give isl_basic_set *uset_gi
 		goto error;
 	if (isl_tab_detect_redundant(tab) < 0)
 		goto error;
-	total = isl_basic_set_total_dim(bset);
 	for (i = bset->n_ineq - 1; i >= 0; --i) {
 		isl_basic_set *test;
 		int is_empty;
@@ -4476,8 +4616,10 @@ static struct isl_basic_map *coalesce_or
 		}
 	}
 
-	if (ISL_F_ISSET(bmap, ISL_BASIC_MAP_EMPTY))
+	if (ISL_F_ISSET(bmap, ISL_BASIC_MAP_EMPTY)) {
+		free(pairs);
 		return bmap;
+	}
 
 	return drop_more_redundant_divs(bmap, pairs, n);
 }
@@ -4503,7 +4645,7 @@ static int is_opposite_part(__isl_keep i
 /* Are inequality constraints "i" and "j" of "bmap" opposite to each other,
  * apart from the constant term?
  */
-static int is_opposite(__isl_keep isl_basic_map *bmap, int i, int j)
+static isl_bool is_opposite(__isl_keep isl_basic_map *bmap, int i, int j)
 {
 	unsigned total;
 
@@ -4555,41 +4697,47 @@ static __isl_give isl_basic_map *drop_re
  * in inequality constraint "ineq" of "bmap"?
  * "div" is known to have a non-zero coefficient in "ineq".
  */
-static int single_unknown(__isl_keep isl_basic_map *bmap, int ineq, int div)
+static isl_bool single_unknown(__isl_keep isl_basic_map *bmap, int ineq,
+	int div)
 {
 	int i;
 	unsigned n_div, o_div;
+	isl_bool known;
 
-	if (isl_basic_map_div_is_known(bmap, div))
-		return 0;
+	known = isl_basic_map_div_is_known(bmap, div);
+	if (known < 0 || known)
+		return isl_bool_not(known);
 	n_div = isl_basic_map_dim(bmap, isl_dim_div);
 	if (n_div == 1)
-		return 1;
+		return isl_bool_true;
 	o_div = isl_basic_map_offset(bmap, isl_dim_div);
 	for (i = 0; i < n_div; ++i) {
+		isl_bool known;
+
 		if (i == div)
 			continue;
 		if (isl_int_is_zero(bmap->ineq[ineq][o_div + i]))
 			continue;
-		if (!isl_basic_map_div_is_known(bmap, i))
-			return 0;
+		known = isl_basic_map_div_is_known(bmap, i);
+		if (known < 0 || !known)
+			return known;
 	}
 
-	return 1;
+	return isl_bool_true;
 }
 
 /* Does integer division "div" have coefficient 1 in inequality constraint
  * "ineq" of "map"?
  */
-static int has_coef_one(__isl_keep isl_basic_map *bmap, int div, int ineq)
+static isl_bool has_coef_one(__isl_keep isl_basic_map *bmap, int div, int ineq)
 {
 	unsigned o_div;
 
 	o_div = isl_basic_map_offset(bmap, isl_dim_div);
 	if (isl_int_is_one(bmap->ineq[ineq][o_div + div]))
-		return 1;
+		return isl_bool_true;
 
-	return 0;
+	return isl_bool_false;
 }
 
 /* Turn inequality constraint "ineq" of "bmap" into an equality and
@@ -4845,6 +4993,7 @@ static __isl_give isl_basic_map *isl_bas
 		int last_pos, last_neg;
 		int redundant;
 		int defined;
+		isl_bool opp, set_div;
 
 		defined = !isl_int_is_zero(bmap->div[i][0]);
 		for (j = i; j < bmap->n_div; ++j)
@@ -4877,14 +5026,27 @@ static __isl_give isl_basic_map *isl_bas
 			bmap = isl_basic_map_drop_div(bmap, i);
 			return drop_redundant_divs_again(bmap, pairs, 0);
 		}
-		if (pairs[i] != 1 || !is_opposite(bmap, last_pos, last_neg)) {
-			int single, lower;
+		if (pairs[i] != 1)
+			opp = isl_bool_false;
+		else
+			opp = is_opposite(bmap, last_pos, last_neg);
+		if (opp < 0)
+			goto error;
+		if (!opp) {
+			int lower;
+			isl_bool single, one;
+
 			if (pos != 1)
 				continue;
 			single = single_unknown(bmap, last_pos, i);
+			if (single < 0)
+				goto error;
 			if (!single)
 				continue;
-			if (has_coef_one(bmap, i, last_pos))
+			one = has_coef_one(bmap, i, last_pos);
+			if (one < 0)
+				goto error;
+			if (one)
 				return set_eq_and_try_again(bmap, last_pos,
 							    pairs);
 			lower = lower_bound_is_cst(bmap, i, last_pos);
@@ -4907,7 +5069,13 @@ static __isl_give isl_basic_map *isl_bas
 		if (redundant)
 			return drop_div_and_try_again(bmap, i,
 						    last_pos, last_neg, pairs);
-		if (!defined && ok_to_set_div_from_bound(bmap, i, last_pos)) {
+		if (defined)
+			set_div = isl_bool_false;
+		else
+			set_div = ok_to_set_div_from_bound(bmap, i, last_pos);
+		if (set_div < 0)
+			return isl_basic_map_free(bmap);
+		if (set_div) {
 			bmap = set_div_from_lower_bound(bmap, i, last_pos);
 			return drop_redundant_divs_again(bmap, pairs, 1);
 		}

Modified: polly/trunk/lib/External/isl/isl_map_subtract.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_map_subtract.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_map_subtract.c (original)
+++ polly/trunk/lib/External/isl/isl_map_subtract.c Thu Feb 16 23:11:16 2017
@@ -46,7 +46,7 @@ static void expand_constraint(isl_vec *v
 /* Add all constraints of bmap to tab.  The equalities of bmap
  * are added as a pair of inequalities.
  */
-static int tab_add_constraints(struct isl_tab *tab,
+static isl_stat tab_add_constraints(struct isl_tab *tab,
 	__isl_keep isl_basic_map *bmap, int *div_map)
 {
 	int i;
@@ -56,18 +56,18 @@ static int tab_add_constraints(struct is
 	isl_vec *v;
 
 	if (!tab || !bmap)
-		return -1;
+		return isl_stat_error;
 
 	tab_total = isl_basic_map_total_dim(tab->bmap);
 	bmap_total = isl_basic_map_total_dim(bmap);
 	dim = isl_space_dim(tab->bmap->dim, isl_dim_all);
 
 	if (isl_tab_extend_cons(tab, 2 * bmap->n_eq + bmap->n_ineq) < 0)
-		return -1;
+		return isl_stat_error;
 
 	v = isl_vec_alloc(bmap->ctx, 1 + tab_total);
 	if (!v)
-		return -1;
+		return isl_stat_error;
 
 	for (i = 0; i < bmap->n_eq; ++i) {
 		expand_constraint(v, dim, bmap->eq[i], div_map, bmap->n_div);
@@ -91,10 +91,10 @@ static int tab_add_constraints(struct is
 	}
 
 	isl_vec_free(v);
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_vec_free(v);
-	return -1;
+	return isl_stat_error;
 }
 
 /* Add a specific constraint of bmap (or its opposite) to tab.
@@ -106,17 +106,17 @@ error:
  * tab_add_constraints (and later removed again), so there should
  * already be a row available for the constraint.
  */
-static int tab_add_constraint(struct isl_tab *tab,
+static isl_stat tab_add_constraint(struct isl_tab *tab,
 	__isl_keep isl_basic_map *bmap, int *div_map, int c, int oppose)
 {
 	unsigned dim;
 	unsigned tab_total;
 	unsigned bmap_total;
 	isl_vec *v;
-	int r;
+	isl_stat r;
 
 	if (!tab || !bmap)
-		return -1;
+		return isl_stat_error;
 
 	tab_total = isl_basic_map_total_dim(tab->bmap);
 	bmap_total = isl_basic_map_total_dim(bmap);
@@ -124,7 +124,7 @@ static int tab_add_constraint(struct isl
 
 	v = isl_vec_alloc(bmap->ctx, 1 + tab_total);
 	if (!v)
-		return -1;
+		return isl_stat_error;
 
 	if (c < 2 * bmap->n_eq) {
 		if ((c % 2) != oppose)
@@ -159,8 +159,8 @@ static int tab_add_constraint(struct isl
 	return r;
 }
 
-static int tab_add_divs(struct isl_tab *tab, __isl_keep isl_basic_map *bmap,
-	int **div_map)
+static isl_stat tab_add_divs(struct isl_tab *tab,
+	__isl_keep isl_basic_map *bmap, int **div_map)
 {
 	int i, j;
 	struct isl_vec *vec;
@@ -168,20 +168,20 @@ static int tab_add_divs(struct isl_tab *
 	unsigned dim;
 
 	if (!bmap)
-		return -1;
+		return isl_stat_error;
 	if (!bmap->n_div)
-		return 0;
+		return isl_stat_ok;
 
 	if (!*div_map)
 		*div_map = isl_alloc_array(bmap->ctx, int, bmap->n_div);
 	if (!*div_map)
-		return -1;
+		return isl_stat_error;
 
 	total = isl_basic_map_total_dim(tab->bmap);
 	dim = total - tab->bmap->n_div;
 	vec = isl_vec_alloc(bmap->ctx, 2 + total + bmap->n_div);
 	if (!vec)
-		return -1;
+		return isl_stat_error;
 
 	for (i = 0; i < bmap->n_div; ++i) {
 		isl_seq_cpy(vec->el, bmap->div[i], 2 + dim);
@@ -203,11 +203,11 @@ static int tab_add_divs(struct isl_tab *
 
 	isl_vec_free(vec);
 
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_vec_free(vec);
 
-	return -1;
+	return isl_stat_error;
 }
 
 /* Freeze all constraints of tableau tab.
@@ -261,7 +261,7 @@ static int n_non_redundant(isl_ctx *ctx,
  * return a negative value.
  */
 struct isl_diff_collector {
-	int (*add)(struct isl_diff_collector *dc,
+	isl_stat (*add)(struct isl_diff_collector *dc,
 		    __isl_take isl_basic_map *bmap);
 };
 
@@ -471,7 +471,7 @@ struct isl_subtract_diff_collector {
 
 /* isl_subtract_diff_collector callback.
  */
-static int basic_map_subtract_add(struct isl_diff_collector *dc,
+static isl_stat basic_map_subtract_add(struct isl_diff_collector *dc,
 			    __isl_take isl_basic_map *bmap)
 {
 	struct isl_subtract_diff_collector *sdc;
@@ -480,7 +480,7 @@ static int basic_map_subtract_add(struct
 	sdc->diff = isl_map_union_disjoint(sdc->diff,
 			isl_map_from_basic_map(bmap));
 
-	return sdc->diff ? 0 : -1;
+	return sdc->diff ? isl_stat_ok : isl_stat_error;
 }
 
 /* Return the set difference between bmap and map.
@@ -591,9 +591,13 @@ struct isl_set *isl_set_subtract(struct
 static __isl_give isl_map *map_subtract_domain(__isl_take isl_map *map,
 	__isl_take isl_set *dom)
 {
+	isl_bool ok;
 	isl_map *ext_dom;
 
-	if (!isl_map_compatible_domain(map, dom))
+	ok = isl_map_compatible_domain(map, dom);
+	if (ok < 0)
+		goto error;
+	if (!ok)
 		isl_die(isl_set_get_ctx(dom), isl_error_invalid,
 			"incompatible spaces", goto error);
 	
@@ -617,9 +621,13 @@ __isl_give isl_map *isl_map_subtract_dom
 static __isl_give isl_map *map_subtract_range(__isl_take isl_map *map,
 	__isl_take isl_set *dom)
 {
+	isl_bool ok;
 	isl_map *ext_dom;
 
-	if (!isl_map_compatible_range(map, dom))
+	ok = isl_map_compatible_range(map, dom);
+	if (ok < 0)
+		goto error;
+	if (!ok)
 		isl_die(isl_set_get_ctx(dom), isl_error_invalid,
 			"incompatible spaces", goto error);
 	
@@ -648,7 +656,7 @@ struct isl_is_empty_diff_collector {
 
 /* isl_is_empty_diff_collector callback.
  */
-static int basic_map_is_empty_add(struct isl_diff_collector *dc,
+static isl_stat basic_map_is_empty_add(struct isl_diff_collector *dc,
 			    __isl_take isl_basic_map *bmap)
 {
 	struct isl_is_empty_diff_collector *edc;
@@ -657,7 +665,7 @@ static int basic_map_is_empty_add(struct
 	edc->empty = 0;
 
 	isl_basic_map_free(bmap);
-	return -1;
+	return isl_stat_error;
 }
 
 /* Check if bmap \ map is empty by computing this set difference
@@ -705,27 +713,27 @@ static isl_bool map_diff_is_empty(__isl_
 	return is_empty;
 }
 
-/* Return 1 if "bmap" contains a single element.
+/* Return true if "bmap" contains a single element.
  */
-int isl_basic_map_plain_is_singleton(__isl_keep isl_basic_map *bmap)
+isl_bool isl_basic_map_plain_is_singleton(__isl_keep isl_basic_map *bmap)
 {
 	if (!bmap)
-		return -1;
+		return isl_bool_error;
 	if (bmap->n_div)
-		return 0;
+		return isl_bool_false;
 	if (bmap->n_ineq)
-		return 0;
+		return isl_bool_false;
 	return bmap->n_eq == isl_basic_map_total_dim(bmap);
 }
 
-/* Return 1 if "map" contains a single element.
+/* Return true if "map" contains a single element.
  */
-int isl_map_plain_is_singleton(__isl_keep isl_map *map)
+isl_bool isl_map_plain_is_singleton(__isl_keep isl_map *map)
 {
 	if (!map)
-		return -1;
+		return isl_bool_error;
 	if (map->n != 1)
-		return 0;
+		return isl_bool_false;
 
 	return isl_basic_map_plain_is_singleton(map->p[0]);
 }
@@ -819,8 +827,8 @@ static isl_bool map_is_subset(__isl_keep
 	__isl_keep isl_map *map2)
 {
 	isl_bool is_subset = isl_bool_false;
-	isl_bool empty;
-	int rat1, rat2;
+	isl_bool empty, single;
+	isl_bool rat1, rat2;
 
 	if (!map1 || !map2)
 		return isl_bool_error;
@@ -850,8 +858,11 @@ static isl_bool map_is_subset(__isl_keep
 	if (isl_map_plain_is_universe(map2))
 		return isl_bool_true;
 
+	single = isl_map_plain_is_singleton(map1);
+	if (single < 0)
+		return isl_bool_error;
 	map2 = isl_map_compute_divs(isl_map_copy(map2));
-	if (isl_map_plain_is_singleton(map1)) {
+	if (single) {
 		is_subset = map_is_singleton_subset(map1, map2);
 		isl_map_free(map2);
 		return is_subset;

Modified: polly/trunk/lib/External/isl/isl_mat.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_mat.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_mat.c (original)
+++ polly/trunk/lib/External/isl/isl_mat.c Thu Feb 16 23:11:16 2017
@@ -799,11 +799,15 @@ static int row_abs_min_non_zero(isl_int
 	return min;
 }
 
-static void inv_exchange(struct isl_mat *left, struct isl_mat *right,
-	unsigned i, unsigned j)
+static isl_stat inv_exchange(__isl_keep isl_mat **left,
+	__isl_keep isl_mat **right, unsigned i, unsigned j)
 {
-	left = isl_mat_swap_rows(left, i, j);
-	right = isl_mat_swap_rows(right, i, j);
+	*left = isl_mat_swap_rows(*left, i, j);
+	*right = isl_mat_swap_rows(*right, i, j);
+
+	if (!*left || !*right)
+		return isl_stat_error;
+	return isl_stat_ok;
 }
 
 static void inv_oppose(
@@ -861,7 +865,8 @@ struct isl_mat *isl_mat_inverse_product(
 		}
 		pivot += row;
 		if (pivot != row)
-			inv_exchange(left, right, pivot, row);
+			if (inv_exchange(&left, &right, pivot, row) < 0)
+				goto error;
 		if (isl_int_is_neg(left->row[row][row]))
 			inv_oppose(left, right, row);
 		first = row+1;
@@ -871,10 +876,12 @@ struct isl_mat *isl_mat_inverse_product(
 			isl_int_fdiv_q(a, left->row[first][row],
 					left->row[row][row]);
 			inv_subtract(left, right, row, first, a);
-			if (!isl_int_is_zero(left->row[first][row]))
-				inv_exchange(left, right, row, first);
-			else
+			if (!isl_int_is_zero(left->row[first][row])) {
+				if (inv_exchange(&left, &right, row, first) < 0)
+					goto error;
+			} else {
 				++first;
+			}
 		}
 		for (i = 0; i < row; ++i) {
 			if (isl_int_is_zero(left->row[i][row]))
@@ -1652,24 +1659,24 @@ error:
 	return NULL;
 }
 
-int isl_mat_is_equal(__isl_keep isl_mat *mat1, __isl_keep isl_mat *mat2)
+isl_bool isl_mat_is_equal(__isl_keep isl_mat *mat1, __isl_keep isl_mat *mat2)
 {
 	int i;
 
 	if (!mat1 || !mat2)
-		return -1;
+		return isl_bool_error;
 
 	if (mat1->n_row != mat2->n_row)
-		return 0;
+		return isl_bool_false;
 
 	if (mat1->n_col != mat2->n_col)
-		return 0;
+		return isl_bool_false;
 
 	for (i = 0; i < mat1->n_row; ++i)
 		if (!isl_seq_eq(mat1->row[i], mat2->row[i], mat1->n_col))
-			return 0;
+			return isl_bool_false;
 
-	return 1;
+	return isl_bool_true;
 }
 
 __isl_give isl_mat *isl_mat_from_row_vec(__isl_take isl_vec *vec)

Modified: polly/trunk/lib/External/isl/isl_multi_templ.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_multi_templ.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_multi_templ.c (original)
+++ polly/trunk/lib/External/isl/isl_multi_templ.c Thu Feb 16 23:11:16 2017
@@ -291,7 +291,7 @@ __isl_give MULTI(BASE) *FN(FN(MULTI(BASE
 {
 	isl_space *multi_space = NULL;
 	isl_space *el_space = NULL;
-	int match;
+	isl_bool match;
 
 	multi = FN(MULTI(BASE),cow)(multi);
 	if (!multi || !el)
@@ -1442,6 +1442,26 @@ isl_bool FN(MULTI(BASE),plain_is_equal)(
 	return isl_bool_true;
 }
 
+/* Does "multi" involve any NaNs?
+ */
+isl_bool FN(MULTI(BASE),involves_nan)(__isl_keep MULTI(BASE) *multi)
+{
+	int i;
+
+	if (!multi)
+		return isl_bool_error;
+	if (multi->n == 0)
+		return isl_bool_false;
+
+	for (i = 0; i < multi->n; ++i) {
+		isl_bool has_nan = FN(EL,involves_nan)(multi->p[i]);
+		if (has_nan < 0 || has_nan)
+			return has_nan;
+	}
+
+	return isl_bool_false;
+}
+
 #ifndef NO_DOMAIN
 /* Return the shared domain of the elements of "multi".
  */

Modified: polly/trunk/lib/External/isl/isl_output.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_output.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_output.c (original)
+++ polly/trunk/lib/External/isl/isl_output.c Thu Feb 16 23:11:16 2017
@@ -464,10 +464,15 @@ static int next_is_opposite(__isl_keep i
 		return 0;
 	if (isl_seq_last_non_zero(bmap->ineq[i + 1], 1 + total) != last)
 		return 0;
-	if (last >= o_div &&
-	    isl_basic_map_is_div_constraint(bmap, bmap->ineq[i + 1],
-					    last - o_div))
-		return 0;
+	if (last >= o_div) {
+		isl_bool is_div;
+		is_div = isl_basic_map_is_div_constraint(bmap,
+					    bmap->ineq[i + 1], last - o_div);
+		if (is_div < 0)
+			return -1;
+		if (is_div)
+			return 0;
+	}
 	return isl_int_abs_eq(bmap->ineq[i][last], bmap->ineq[i + 1][last]) &&
 		!isl_int_eq(bmap->ineq[i][last], bmap->ineq[i + 1][last]);
 }
@@ -642,10 +647,15 @@ static __isl_give isl_printer *print_con
 		if (l < 0)
 			continue;
 		if (!dump && l >= o_div &&
-		    can_print_div_expr(p, div, l - o_div) &&
-		    isl_basic_map_is_div_constraint(bmap, bmap->ineq[i],
-						    l - o_div))
-			continue;
+		    can_print_div_expr(p, div, l - o_div)) {
+			isl_bool is_div;
+			is_div = isl_basic_map_is_div_constraint(bmap,
+						    bmap->ineq[i], l - o_div);
+			if (is_div < 0)
+				goto error;
+			if (is_div)
+				continue;
+		}
 		s = isl_int_sgn(bmap->ineq[i][l]);
 		strict = !rational && isl_int_is_negone(bmap->ineq[i][0]);
 		if (s < 0)
@@ -1955,8 +1965,13 @@ static __isl_give isl_printer *print_con
 	o_div = isl_basic_set_offset(bset, isl_dim_div);
 	n_div = isl_basic_set_dim(bset, isl_dim_div);
 	div = isl_seq_last_non_zero(c + o_div, n_div);
-	if (div >= 0 && isl_basic_set_is_div_constraint(bset, c, div))
-		return p;
+	if (div >= 0) {
+		isl_bool is_div = isl_basic_set_is_div_constraint(bset, c, div);
+		if (is_div < 0)
+			return isl_printer_free(p);
+		if (is_div)
+			return p;
+	}
 
 	if (!*first)
 		p = isl_printer_print_str(p, " && ");

Modified: polly/trunk/lib/External/isl/isl_point.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_point.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_point.c (original)
+++ polly/trunk/lib/External/isl/isl_point.c Thu Feb 16 23:11:16 2017
@@ -392,18 +392,19 @@ isl_bool isl_basic_map_contains_point(__
 	return contains;
 }
 
-int isl_map_contains_point(__isl_keep isl_map *map, __isl_keep isl_point *point)
+isl_bool isl_map_contains_point(__isl_keep isl_map *map,
+	__isl_keep isl_point *point)
 {
 	int i;
-	int found = 0;
+	isl_bool found = isl_bool_false;
 
 	if (!map || !point)
-		return -1;
+		return isl_bool_error;
 
 	map = isl_map_copy(map);
 	map = isl_map_compute_divs(map);
 	if (!map)
-		return -1;
+		return isl_bool_error;
 
 	for (i = 0; i < map->n; ++i) {
 		found = isl_basic_map_contains_point(map->p[i], point);
@@ -417,7 +418,7 @@ int isl_map_contains_point(__isl_keep is
 	return found;
 error:
 	isl_map_free(map);
-	return -1;
+	return isl_bool_error;
 }
 
 isl_bool isl_set_contains_point(__isl_keep isl_set *set,
@@ -470,7 +471,7 @@ __isl_give isl_union_set *isl_union_set_
 __isl_give isl_basic_set *isl_basic_set_box_from_points(
 	__isl_take isl_point *pnt1, __isl_take isl_point *pnt2)
 {
-	isl_basic_set *bset;
+	isl_basic_set *bset = NULL;
 	unsigned total;
 	int i;
 	int k;
@@ -548,6 +549,7 @@ error:
 	isl_point_free(pnt1);
 	isl_point_free(pnt2);
 	isl_int_clear(t);
+	isl_basic_set_free(bset);
 	return NULL;
 }
 
@@ -581,7 +583,6 @@ __isl_give isl_printer *isl_printer_prin
 	struct isl_print_space_data data = { 0 };
 	int i;
 	unsigned nparam;
-	unsigned dim;
 
 	if (!pnt)
 		return p;
@@ -591,7 +592,6 @@ __isl_give isl_printer *isl_printer_prin
 	}
 
 	nparam = isl_space_dim(pnt->dim, isl_dim_param);
-	dim = isl_space_dim(pnt->dim, isl_dim_set);
 	if (nparam > 0) {
 		p = isl_printer_print_str(p, "[");
 		for (i = 0; i < nparam; ++i) {

Modified: polly/trunk/lib/External/isl/isl_polynomial.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_polynomial.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_polynomial.c (original)
+++ polly/trunk/lib/External/isl/isl_polynomial.c Thu Feb 16 23:11:16 2017
@@ -1277,13 +1277,15 @@ error:
 	return NULL;
 }
 
-static int compatible_divs(__isl_keep isl_mat *div1, __isl_keep isl_mat *div2)
+static isl_bool compatible_divs(__isl_keep isl_mat *div1,
+	__isl_keep isl_mat *div2)
 {
 	int n_row, n_col;
-	int equal;
+	isl_bool equal;
 
 	isl_assert(div1->ctx, div1->n_row >= div2->n_row &&
-				div1->n_col >= div2->n_col, return -1);
+				div1->n_col >= div2->n_col,
+		    return isl_bool_error);
 
 	if (div1->n_row == div2->n_row)
 		return isl_mat_is_equal(div1, div2);
@@ -1509,6 +1511,8 @@ error:
 __isl_give isl_qpolynomial *isl_qpolynomial_add(__isl_take isl_qpolynomial *qp1,
 	__isl_take isl_qpolynomial *qp2)
 {
+	isl_bool compatible;
+
 	qp1 = isl_qpolynomial_cow(qp1);
 
 	if (!qp1 || !qp2)
@@ -1518,7 +1522,10 @@ __isl_give isl_qpolynomial *isl_qpolynom
 		return isl_qpolynomial_add(qp2, qp1);
 
 	isl_assert(qp1->dim->ctx, isl_space_is_equal(qp1->dim, qp2->dim), goto error);
-	if (!compatible_divs(qp1->div, qp2->div))
+	compatible = compatible_divs(qp1->div, qp2->div);
+	if (compatible < 0)
+		goto error;
+	if (!compatible)
 		return with_merged_divs(isl_qpolynomial_add, qp1, qp2);
 
 	qp1->upoly = isl_upoly_sum(qp1->upoly, isl_upoly_copy(qp2->upoly));
@@ -1679,6 +1686,8 @@ error:
 __isl_give isl_qpolynomial *isl_qpolynomial_mul(__isl_take isl_qpolynomial *qp1,
 	__isl_take isl_qpolynomial *qp2)
 {
+	isl_bool compatible;
+
 	qp1 = isl_qpolynomial_cow(qp1);
 
 	if (!qp1 || !qp2)
@@ -1688,7 +1697,10 @@ __isl_give isl_qpolynomial *isl_qpolynom
 		return isl_qpolynomial_mul(qp2, qp1);
 
 	isl_assert(qp1->dim->ctx, isl_space_is_equal(qp1->dim, qp2->dim), goto error);
-	if (!compatible_divs(qp1->div, qp2->div))
+	compatible = compatible_divs(qp1->div, qp2->div);
+	if (compatible < 0)
+		goto error;
+	if (!compatible)
 		return with_merged_divs(isl_qpolynomial_mul, qp1, qp2);
 
 	qp1->upoly = isl_upoly_mul(qp1->upoly, isl_upoly_copy(qp2->upoly));
@@ -2925,6 +2937,8 @@ __isl_give isl_pw_qpolynomial *isl_pw_qp
 	return isl_pw_qpolynomial_alloc(dom, qp);
 }
 
+#define isl_qpolynomial_involves_nan isl_qpolynomial_is_nan
+
 #undef PW
 #define PW isl_pw_qpolynomial
 #undef EL
@@ -3477,9 +3491,9 @@ error:
  * that results from replacing each of the integer divisions by the
  * corresponding extra set dimension.
  */
-int isl_qpolynomial_as_polynomial_on_domain(__isl_keep isl_qpolynomial *qp,
+isl_stat isl_qpolynomial_as_polynomial_on_domain(__isl_keep isl_qpolynomial *qp,
 	__isl_keep isl_basic_set *bset,
-	int (*fn)(__isl_take isl_basic_set *bset,
+	isl_stat (*fn)(__isl_take isl_basic_set *bset,
 		  __isl_take isl_qpolynomial *poly, void *user), void *user)
 {
 	isl_space *dim;
@@ -3487,7 +3501,7 @@ int isl_qpolynomial_as_polynomial_on_dom
 	isl_qpolynomial *poly;
 
 	if (!qp || !bset)
-		goto error;
+		return isl_stat_error;
 	if (qp->div->n_row == 0)
 		return fn(isl_basic_set_copy(bset), isl_qpolynomial_copy(qp),
 			  user);
@@ -3501,8 +3515,6 @@ int isl_qpolynomial_as_polynomial_on_dom
 	bset = add_div_constraints(bset, div);
 
 	return fn(bset, poly, user);
-error:
-	return -1;
 }
 
 /* Return total degree in variables first (inclusive) up to last (exclusive).
@@ -4648,7 +4660,7 @@ __isl_give isl_pw_qpolynomial *isl_basic
 	__isl_take isl_basic_set *bset,
 	__isl_give isl_pw_qpolynomial *(*fn)(__isl_take isl_basic_set *bset))
 {
-	int bounded;
+	isl_bool bounded;
 	isl_morph *morph;
 	isl_pw_qpolynomial *pwqp;
 
@@ -4851,8 +4863,8 @@ struct isl_to_poly_data {
  * overapproximated by a/m, while in the second it is underapproximated
  * by (a-(m-1))/m.
  */
-static int to_polynomial_on_orthant(__isl_take isl_set *orthant, int *signs,
-	void *user)
+static isl_stat to_polynomial_on_orthant(__isl_take isl_set *orthant,
+	int *signs, void *user)
 {
 	struct isl_to_poly_data *data = user;
 	isl_pw_qpolynomial *t;
@@ -4872,7 +4884,7 @@ static int to_polynomial_on_orthant(__is
 	t = isl_pw_qpolynomial_alloc(orthant, qp);
 	data->res = isl_pw_qpolynomial_add_disjoint(data->res, t);
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Approximate each quasipolynomial by a polynomial.  If "sign" is positive,

Modified: polly/trunk/lib/External/isl/isl_pw_templ.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_pw_templ.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_pw_templ.c (original)
+++ polly/trunk/lib/External/isl/isl_pw_templ.c Thu Feb 16 23:11:16 2017
@@ -1593,10 +1593,10 @@ __isl_give PW *FN(PW,reset_user)(__isl_t
 	return FN(PW,reset_space)(pw, space);
 }
 
-int FN(PW,has_equal_space)(__isl_keep PW *pw1, __isl_keep PW *pw2)
+isl_bool FN(PW,has_equal_space)(__isl_keep PW *pw1, __isl_keep PW *pw2)
 {
 	if (!pw1 || !pw2)
-		return -1;
+		return isl_bool_error;
 
 	return isl_space_is_equal(pw1->dim, pw2->dim);
 }
@@ -1666,18 +1666,18 @@ isl_stat FN(PW,foreach_piece)(__isl_keep
 }
 
 #ifndef NO_LIFT
-static int any_divs(__isl_keep isl_set *set)
+static isl_bool any_divs(__isl_keep isl_set *set)
 {
 	int i;
 
 	if (!set)
-		return -1;
+		return isl_bool_error;
 
 	for (i = 0; i < set->n; ++i)
 		if (set->p[i]->n_div > 0)
-			return 1;
+			return isl_bool_true;
 
-	return 0;
+	return isl_bool_false;
 }
 
 static isl_stat foreach_lifted_subset(__isl_take isl_set *set,
@@ -1724,12 +1724,16 @@ isl_stat FN(PW,foreach_lifted_piece)(__i
 		return isl_stat_error;
 
 	for (i = 0; i < pw->n; ++i) {
+		isl_bool any;
 		isl_set *set;
 		EL *el;
 
+		any = any_divs(pw->p[i].set);
+		if (any < 0)
+			return isl_stat_error;
 		set = isl_set_copy(pw->p[i].set);
 		el = FN(EL,copy)(pw->p[i].FIELD);
-		if (!any_divs(set)) {
+		if (!any) {
 			if (fn(set, el, user) < 0)
 				return isl_stat_error;
 			continue;
@@ -1959,15 +1963,25 @@ __isl_give PW *FN(PW,normalize)(__isl_ta
 /* Is pw1 obviously equal to pw2?
  * That is, do they have obviously identical cells and obviously identical
  * elements on each cell?
+ *
+ * If "pw1" or "pw2" contain any NaNs, then they are considered
+ * not to be the same.  A NaN is not equal to anything, not even
+ * to another NaN.
  */
 isl_bool FN(PW,plain_is_equal)(__isl_keep PW *pw1, __isl_keep PW *pw2)
 {
 	int i;
-	isl_bool equal;
+	isl_bool equal, has_nan;
 
 	if (!pw1 || !pw2)
 		return isl_bool_error;
 
+	has_nan = FN(PW,involves_nan)(pw1);
+	if (has_nan >= 0 && !has_nan)
+		has_nan = FN(PW,involves_nan)(pw2);
+	if (has_nan < 0 || has_nan)
+		return isl_bool_not(has_nan);
+
 	if (pw1 == pw2)
 		return isl_bool_true;
 	if (!isl_space_is_equal(pw1->dim, pw2->dim))
@@ -2001,6 +2015,26 @@ error:
 	return isl_bool_error;
 }
 
+/* Does "pw" involve any NaNs?
+ */
+isl_bool FN(PW,involves_nan)(__isl_keep PW *pw)
+{
+	int i;
+
+	if (!pw)
+		return isl_bool_error;
+	if (pw->n == 0)
+		return isl_bool_false;
+
+	for (i = 0; i < pw->n; ++i) {
+		isl_bool has_nan = FN(EL,involves_nan)(pw->p[i].FIELD);
+		if (has_nan < 0 || has_nan)
+			return has_nan;
+	}
+
+	return isl_bool_false;
+}
+
 #ifndef NO_PULLBACK
 static __isl_give PW *FN(PW,align_params_pw_multi_aff_and)(__isl_take PW *pw,
 	__isl_take isl_multi_aff *ma,

Modified: polly/trunk/lib/External/isl/isl_range.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_range.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_range.c (original)
+++ polly/trunk/lib/External/isl/isl_range.c Thu Feb 16 23:11:16 2017
@@ -483,8 +483,9 @@ error:
 	return isl_stat_error;
 }
 
-static int qpolynomial_bound_on_domain_range(__isl_take isl_basic_set *bset,
-	__isl_take isl_qpolynomial *poly, struct range_data *data)
+static isl_stat qpolynomial_bound_on_domain_range(
+	__isl_take isl_basic_set *bset, __isl_take isl_qpolynomial *poly,
+	struct range_data *data)
 {
 	unsigned nparam = isl_basic_set_dim(bset, isl_dim_param);
 	unsigned nvar = isl_basic_set_dim(bset, isl_dim_set);
@@ -509,18 +510,18 @@ static int qpolynomial_bound_on_domain_r
 	isl_set_free(set);
 	isl_qpolynomial_free(poly);
 
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_set_free(set);
 	isl_qpolynomial_free(poly);
-	return -1;
+	return isl_stat_error;
 }
 
-int isl_qpolynomial_bound_on_domain_range(__isl_take isl_basic_set *bset,
+isl_stat isl_qpolynomial_bound_on_domain_range(__isl_take isl_basic_set *bset,
 	__isl_take isl_qpolynomial *poly, struct isl_bound *bound)
 {
 	struct range_data data;
-	int r;
+	isl_stat r;
 
 	data.pwf = bound->pwf;
 	data.pwf_tight = bound->pwf_tight;

Modified: polly/trunk/lib/External/isl/isl_range.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_range.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_range.h (original)
+++ polly/trunk/lib/External/isl/isl_range.h Thu Feb 16 23:11:16 2017
@@ -1,6 +1,6 @@
 #include <isl_bound.h>
 
-int isl_qpolynomial_bound_on_domain_range(__isl_take isl_basic_set *bset,
+isl_stat isl_qpolynomial_bound_on_domain_range(__isl_take isl_basic_set *bset,
 	__isl_take isl_qpolynomial *poly, struct isl_bound *bound);
 __isl_give isl_qpolynomial *isl_qpolynomial_terms_of_sign(
 	__isl_keep isl_qpolynomial *poly, int *signs, int sign);

Modified: polly/trunk/lib/External/isl/isl_scan.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_scan.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_scan.c (original)
+++ polly/trunk/lib/External/isl/isl_scan.c Thu Feb 16 23:11:16 2017
@@ -65,7 +65,7 @@ static int add_solution(struct isl_tab *
 	return callback->add(callback, sample);
 }
 
-static int scan_0D(struct isl_basic_set *bset,
+static isl_stat scan_0D(__isl_take isl_basic_set *bset,
 	struct isl_scan_callback *callback)
 {
 	struct isl_vec *sample;
@@ -74,7 +74,7 @@ static int scan_0D(struct isl_basic_set
 	isl_basic_set_free(bset);
 
 	if (!sample)
-		return -1;
+		return isl_stat_error;
 
 	isl_int_set_si(sample->el[0], 1);
 
@@ -99,7 +99,7 @@ static int scan_0D(struct isl_basic_set
  * Solutions are added in the leaves of the search tree, i.e., after
  * we have fixed a value in each direction of the basis.
  */
-int isl_basic_set_scan(struct isl_basic_set *bset,
+isl_stat isl_basic_set_scan(__isl_take isl_basic_set *bset,
 	struct isl_scan_callback *callback)
 {
 	unsigned dim;
@@ -113,7 +113,7 @@ int isl_basic_set_scan(struct isl_basic_
 	enum isl_lp_result res;
 
 	if (!bset)
-		return -1;
+		return isl_stat_error;
 
 	dim = isl_basic_set_total_dim(bset);
 	if (dim == 0)
@@ -209,7 +209,7 @@ int isl_basic_set_scan(struct isl_basic_
 	isl_vec_free(max);
 	isl_basic_set_free(bset);
 	isl_mat_free(B);
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_tab_free(tab);
 	free(snap);
@@ -217,10 +217,11 @@ error:
 	isl_vec_free(max);
 	isl_basic_set_free(bset);
 	isl_mat_free(B);
-	return -1;
+	return isl_stat_error;
 }
 
-int isl_set_scan(__isl_take isl_set *set, struct isl_scan_callback *callback)
+isl_stat isl_set_scan(__isl_take isl_set *set,
+	struct isl_scan_callback *callback)
 {
 	int i;
 
@@ -239,10 +240,10 @@ int isl_set_scan(__isl_take isl_set *set
 			goto error;
 
 	isl_set_free(set);
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_set_free(set);
-	return -1;
+	return isl_stat_error;
 }
 
 int isl_basic_set_count_upto(__isl_keep isl_basic_set *bset,

Modified: polly/trunk/lib/External/isl/isl_scan.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_scan.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_scan.h (original)
+++ polly/trunk/lib/External/isl/isl_scan.h Thu Feb 16 23:11:16 2017
@@ -18,8 +18,9 @@ struct isl_scan_callback {
 		__isl_take isl_vec *sample);
 };
 
-int isl_basic_set_scan(struct isl_basic_set *bset,
+isl_stat isl_basic_set_scan(__isl_take isl_basic_set *bset,
+	struct isl_scan_callback *callback);
+isl_stat isl_set_scan(__isl_take isl_set *set,
 	struct isl_scan_callback *callback);
-int isl_set_scan(__isl_take isl_set *set, struct isl_scan_callback *callback);
 
 #endif

Modified: polly/trunk/lib/External/isl/isl_schedule_band.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_schedule_band.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_schedule_band.c (original)
+++ polly/trunk/lib/External/isl/isl_schedule_band.c Thu Feb 16 23:11:16 2017
@@ -257,7 +257,7 @@ __isl_give isl_schedule_band *isl_schedu
 	if (pos < 0 || pos >= band->n)
 		isl_die(isl_schedule_band_get_ctx(band), isl_error_invalid,
 			"invalid member position",
-			isl_schedule_band_free(band));
+			return isl_schedule_band_free(band));
 
 	band->coincident[pos] = coincident;
 
@@ -392,7 +392,7 @@ __isl_give isl_schedule_band *isl_schedu
 	if (pos < 0 || pos >= band->n)
 		isl_die(isl_schedule_band_get_ctx(band), isl_error_invalid,
 			"invalid member position",
-			isl_schedule_band_free(band));
+			return isl_schedule_band_free(band));
 
 	band = isl_schedule_band_cow(band);
 	if (!band)
@@ -450,7 +450,7 @@ isl_schedule_band_member_set_isolate_ast
 	if (pos < 0 || pos >= band->n)
 		isl_die(isl_schedule_band_get_ctx(band), isl_error_invalid,
 			"invalid member position",
-			isl_schedule_band_free(band));
+			return isl_schedule_band_free(band));
 
 	band = isl_schedule_band_cow(band);
 	if (!band)
@@ -523,14 +523,12 @@ static __isl_give isl_union_set *add_loo
 	int isolate)
 {
 	int i;
-	isl_ctx *ctx;
 
 	if (!type)
 		return options;
 	if (!options)
 		return NULL;
 
-	ctx = isl_union_set_get_ctx(options);
 	for (i = 0; i < n; ++i) {
 		int first;
 		isl_space *space;
@@ -945,7 +943,7 @@ __isl_give isl_schedule_band *isl_schedu
 
 	band = isl_schedule_band_cow(band);
 	if (!band)
-		return NULL;
+		goto error;
 
 	options = band->ast_build_options;
 	options = isl_union_set_subtract(options, isl_union_set_from_set(drop));
@@ -956,6 +954,11 @@ __isl_give isl_schedule_band *isl_schedu
 		return isl_schedule_band_free(band);
 
 	return band;
+error:
+	isl_schedule_band_free(band);
+	isl_set_free(drop);
+	isl_set_free(add);
+	return NULL;
 }
 
 /* Multiply the partial schedule of "band" with the factors in "mv".

Modified: polly/trunk/lib/External/isl/isl_schedule_node.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_schedule_node.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_schedule_node.c (original)
+++ polly/trunk/lib/External/isl/isl_schedule_node.c Thu Feb 16 23:11:16 2017
@@ -1934,14 +1934,14 @@ __isl_give isl_schedule_node *isl_schedu
 	type = isl_schedule_node_get_type(node);
 	if (type != isl_schedule_node_band)
 		isl_die(isl_schedule_node_get_ctx(node), isl_error_invalid,
-			"not a band node", isl_schedule_node_free(node));
+			"not a band node", return isl_schedule_node_free(node));
 	anchored = isl_schedule_node_is_subtree_anchored(node);
 	if (anchored < 0)
 		return isl_schedule_node_free(node);
 	if (anchored)
 		isl_die(isl_schedule_node_get_ctx(node), isl_error_invalid,
 			"cannot sink band node in anchored subtree",
-			isl_schedule_node_free(node));
+			return isl_schedule_node_free(node));
 	if (isl_schedule_tree_n_children(node->tree) == 0)
 		return node;
 
@@ -2205,12 +2205,14 @@ __isl_give isl_schedule_node *isl_schedu
 		return NULL;
 	if (isl_schedule_node_get_type(node) != isl_schedule_node_sequence)
 		isl_die(isl_schedule_node_get_ctx(node), isl_error_invalid,
-			"not a sequence node", isl_schedule_node_free(node));
+			"not a sequence node",
+			return isl_schedule_node_free(node));
 	node = isl_schedule_node_child(node, pos);
 	node = isl_schedule_node_child(node, 0);
 	if (isl_schedule_node_get_type(node) != isl_schedule_node_sequence)
 		isl_die(isl_schedule_node_get_ctx(node), isl_error_invalid,
-			"not a sequence node", isl_schedule_node_free(node));
+			"not a sequence node",
+			return isl_schedule_node_free(node));
 	child = isl_schedule_node_copy(node);
 	node = isl_schedule_node_parent(node);
 	filter = isl_schedule_node_filter_get_filter(node);
@@ -2252,7 +2254,6 @@ static __isl_give isl_schedule_node *upd
 {
 	int i, n;
 	int is_leaf;
-	isl_ctx *ctx;
 	isl_schedule_tree *tree;
 	isl_schedule_node *pos = NULL;
 
@@ -2263,7 +2264,6 @@ static __isl_give isl_schedule_node *upd
 	if (!node)
 		return isl_schedule_node_free(pos);
 
-	ctx = isl_schedule_node_get_ctx(node);
 	n = isl_schedule_tree_list_n_schedule_tree(node->ancestors);
 	tree = isl_schedule_tree_copy(node->tree);
 
@@ -3137,7 +3137,7 @@ __isl_give isl_schedule_node *isl_schedu
 	if (!disjoint)
 		isl_die(isl_schedule_node_get_ctx(node), isl_error_invalid,
 			"group instances already reach node",
-			isl_schedule_node_free(node));
+			return isl_schedule_node_free(node));
 
 	return node;
 error:

Modified: polly/trunk/lib/External/isl/isl_schedule_read.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_schedule_read.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_schedule_read.c (original)
+++ polly/trunk/lib/External/isl/isl_schedule_read.c Thu Feb 16 23:11:16 2017
@@ -568,7 +568,7 @@ static __isl_give isl_schedule_tree *rea
 
 		switch (key) {
 		case isl_schedule_key_schedule:
-			isl_multi_union_pw_aff_free(schedule);
+			schedule = isl_multi_union_pw_aff_free(schedule);
 			tok = isl_stream_next_token(s);
 			if (!tok) {
 				isl_stream_error(s, NULL, "unexpected EOF");

Modified: polly/trunk/lib/External/isl/isl_schedule_tree.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_schedule_tree.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_schedule_tree.c (original)
+++ polly/trunk/lib/External/isl/isl_schedule_tree.c Thu Feb 16 23:11:16 2017
@@ -82,7 +82,7 @@ __isl_take isl_schedule_tree *isl_schedu
 	case isl_schedule_node_error:
 		isl_die(ctx, isl_error_internal,
 			"allocation should have failed",
-			isl_schedule_tree_free(dup));
+			return isl_schedule_tree_free(dup));
 	case isl_schedule_node_band:
 		dup->band = isl_schedule_band_copy(tree->band);
 		if (!dup->band)

Modified: polly/trunk/lib/External/isl/isl_scheduler.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_scheduler.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_scheduler.c (original)
+++ polly/trunk/lib/External/isl/isl_scheduler.c Thu Feb 16 23:11:16 2017
@@ -716,16 +716,16 @@ static isl_stat compute_max_row(struct i
 
 /* Does "bset" have any defining equalities for its set variables?
  */
-static int has_any_defining_equality(__isl_keep isl_basic_set *bset)
+static isl_bool has_any_defining_equality(__isl_keep isl_basic_set *bset)
 {
 	int i, n;
 
 	if (!bset)
-		return -1;
+		return isl_bool_error;
 
 	n = isl_basic_set_dim(bset, isl_dim_set);
 	for (i = 0; i < n; ++i) {
-		int has;
+		isl_bool has;
 
 		has = isl_basic_set_has_defining_equality(bset, isl_dim_set, i,
 							NULL);
@@ -733,7 +733,7 @@ static int has_any_defining_equality(__i
 			return has;
 	}
 
-	return 0;
+	return isl_bool_false;
 }
 
 /* Set the entries of node->max to the value of the schedule_max_coefficient
@@ -966,7 +966,7 @@ static isl_stat add_node(struct isl_sche
 static isl_stat extract_node(__isl_take isl_set *set, void *user)
 {
 	int nvar;
-	int has_equality;
+	isl_bool has_equality;
 	isl_basic_set *hull;
 	isl_set *hull_set;
 	isl_morph *morph;
@@ -2043,7 +2043,7 @@ static int edge_multiplicity(struct isl_
  *
  * "use_coincidence" is set if we should take into account coincidence edges.
  */
-static int count_map_constraints(struct isl_sched_graph *graph,
+static isl_stat count_map_constraints(struct isl_sched_graph *graph,
 	struct isl_sched_edge *edge, __isl_take isl_map *map,
 	int *n_eq, int *n_ineq, int carry, int use_coincidence)
 {
@@ -2052,7 +2052,7 @@ static int count_map_constraints(struct
 
 	if (f == 0) {
 		isl_map_free(map);
-		return 0;
+		return isl_stat_ok;
 	}
 
 	if (edge->src == edge->dst)
@@ -2060,12 +2060,12 @@ static int count_map_constraints(struct
 	else
 		coef = inter_coefficients(graph, edge, map);
 	if (!coef)
-		return -1;
+		return isl_stat_error;
 	*n_eq += f * coef->n_eq;
 	*n_ineq += f * coef->n_ineq;
 	isl_basic_set_free(coef);
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Count the number of equality and inequality constraints
@@ -3550,7 +3550,7 @@ static int add_inter_constraints(struct
 /* Add constraints to graph->lp that force all (conditional) validity
  * dependences to be respected and attempt to carry them.
  */
-static int add_all_constraints(struct isl_sched_graph *graph)
+static isl_stat add_all_constraints(struct isl_sched_graph *graph)
 {
 	int i, j;
 	int pos;
@@ -3571,22 +3571,22 @@ static int add_all_constraints(struct is
 
 			if (edge->src == edge->dst &&
 			    add_intra_constraints(graph, edge, map, pos) < 0)
-				return -1;
+				return isl_stat_error;
 			if (edge->src != edge->dst &&
 			    add_inter_constraints(graph, edge, map, pos) < 0)
-				return -1;
+				return isl_stat_error;
 			++pos;
 		}
 	}
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Count the number of equality and inequality constraints
  * that will be added to the carry_lp problem.
  * We count each edge exactly once.
  */
-static int count_all_constraints(struct isl_sched_graph *graph,
+static isl_stat count_all_constraints(struct isl_sched_graph *graph,
 	int *n_eq, int *n_ineq)
 {
 	int i, j;
@@ -3607,11 +3607,11 @@ static int count_all_constraints(struct
 
 			if (count_map_constraints(graph, edge, map,
 						  n_eq, n_ineq, 1, 0) < 0)
-				    return -1;
+				    return isl_stat_error;
 		}
 	}
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Construct an LP problem for finding schedule coefficients

Modified: polly/trunk/lib/External/isl/isl_space.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_space.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_space.c (original)
+++ polly/trunk/lib/External/isl/isl_space.c Thu Feb 16 23:11:16 2017
@@ -830,25 +830,25 @@ int isl_space_tuple_match(__isl_keep isl
 	return isl_space_tuple_is_equal(space1, type1, space2, type2);
 }
 
-static int match(__isl_keep isl_space *space1, enum isl_dim_type type1,
+static isl_bool match(__isl_keep isl_space *space1, enum isl_dim_type type1,
 	__isl_keep isl_space *space2, enum isl_dim_type type2)
 {
 	int i;
 
 	if (space1 == space2 && type1 == type2)
-		return 1;
+		return isl_bool_true;
 
 	if (!isl_space_tuple_is_equal(space1, type1, space2, type2))
-		return 0;
+		return isl_bool_false;
 
 	if (!space1->ids && !space2->ids)
-		return 1;
+		return isl_bool_true;
 
 	for (i = 0; i < n(space1, type1); ++i) {
 		if (get_id(space1, type1, i) != get_id(space2, type2, i))
-			return 0;
+			return isl_bool_false;
 	}
-	return 1;
+	return isl_bool_true;
 }
 
 isl_bool isl_space_match(__isl_keep isl_space *space1, enum isl_dim_type type1,
@@ -2078,30 +2078,34 @@ error:
 	return NULL;
 }
 
-int isl_space_is_named_or_nested(__isl_keep isl_space *dim, enum isl_dim_type type)
+isl_bool isl_space_is_named_or_nested(__isl_keep isl_space *space,
+	enum isl_dim_type type)
 {
 	if (type != isl_dim_in && type != isl_dim_out)
-		return 0;
-	if (!dim)
-		return -1;
-	if (dim->tuple_id[type - isl_dim_in])
-		return 1;
-	if (dim->nested[type - isl_dim_in])
-		return 1;
-	return 0;
+		return isl_bool_false;
+	if (!space)
+		return isl_bool_error;
+	if (space->tuple_id[type - isl_dim_in])
+		return isl_bool_true;
+	if (space->nested[type - isl_dim_in])
+		return isl_bool_true;
+	return isl_bool_false;
 }
 
-int isl_space_may_be_set(__isl_keep isl_space *dim)
+isl_bool isl_space_may_be_set(__isl_keep isl_space *space)
 {
-	if (!dim)
-		return -1;
-	if (isl_space_is_set(dim))
-		return 1;
-	if (isl_space_dim(dim, isl_dim_in) != 0)
-		return 0;
-	if (isl_space_is_named_or_nested(dim, isl_dim_in))
-		return 0;
-	return 1;
+	isl_bool nested;
+
+	if (!space)
+		return isl_bool_error;
+	if (isl_space_is_set(space))
+		return isl_bool_true;
+	if (isl_space_dim(space, isl_dim_in) != 0)
+		return isl_bool_false;
+	nested = isl_space_is_named_or_nested(space, isl_dim_in);
+	if (nested < 0 || nested)
+		return isl_bool_not(nested);
+	return isl_bool_true;
 }
 
 __isl_give isl_space *isl_space_reset(__isl_take isl_space *dim,
@@ -2364,22 +2368,22 @@ __isl_give isl_space *isl_space_uncurry(
 			    isl_space_from_range(ran_ran));
 }
 
-int isl_space_has_named_params(__isl_keep isl_space *dim)
+isl_bool isl_space_has_named_params(__isl_keep isl_space *space)
 {
 	int i;
 	unsigned off;
 
-	if (!dim)
-		return -1;
-	if (dim->nparam == 0)
-		return 1;
-	off = isl_space_offset(dim, isl_dim_param);
-	if (off + dim->nparam > dim->n_id)
-		return 0;
-	for (i = 0; i < dim->nparam; ++i)
-		if (!dim->ids[off + i])
-			return 0;
-	return 1;
+	if (!space)
+		return isl_bool_error;
+	if (space->nparam == 0)
+		return isl_bool_true;
+	off = isl_space_offset(space, isl_dim_param);
+	if (off + space->nparam > space->n_id)
+		return isl_bool_false;
+	for (i = 0; i < space->nparam; ++i)
+		if (!space->ids[off + i])
+			return isl_bool_false;
+	return isl_bool_true;
 }
 
 /* Align the initial parameters of dim1 to match the order in dim2.

Modified: polly/trunk/lib/External/isl/isl_space_private.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_space_private.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_space_private.h (original)
+++ polly/trunk/lib/External/isl/isl_space_private.h Thu Feb 16 23:11:16 2017
@@ -41,9 +41,10 @@ __isl_give isl_space *isl_space_as_set_s
 
 unsigned isl_space_offset(__isl_keep isl_space *dim, enum isl_dim_type type);
 
-int isl_space_may_be_set(__isl_keep isl_space *dim);
-int isl_space_is_named_or_nested(__isl_keep isl_space *dim, enum isl_dim_type type);
-int isl_space_has_named_params(__isl_keep isl_space *dim);
+isl_bool isl_space_may_be_set(__isl_keep isl_space *space);
+isl_bool isl_space_is_named_or_nested(__isl_keep isl_space *space,
+	enum isl_dim_type type);
+isl_bool isl_space_has_named_params(__isl_keep isl_space *space);
 __isl_give isl_space *isl_space_reset(__isl_take isl_space *dim,
 	enum isl_dim_type type);
 __isl_give isl_space *isl_space_flatten(__isl_take isl_space *dim);

Modified: polly/trunk/lib/External/isl/isl_tab.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_tab.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_tab.c (original)
+++ polly/trunk/lib/External/isl/isl_tab.c Thu Feb 16 23:11:16 2017
@@ -980,15 +980,15 @@ int isl_tab_mark_rational(struct isl_tab
 	return 0;
 }
 
-int isl_tab_mark_empty(struct isl_tab *tab)
+isl_stat isl_tab_mark_empty(struct isl_tab *tab)
 {
 	if (!tab)
-		return -1;
+		return isl_stat_error;
 	if (!tab->empty && tab->need_undo)
 		if (isl_tab_push(tab, isl_tab_undo_empty) < 0)
-			return -1;
+			return isl_stat_error;
 	tab->empty = 1;
-	return 0;
+	return isl_stat_ok;
 }
 
 int isl_tab_freeze_constraint(struct isl_tab *tab, int con)
@@ -1855,14 +1855,15 @@ int isl_tab_add_row(struct isl_tab *tab,
 	return r;
 }
 
-static int drop_row(struct isl_tab *tab, int row)
+static isl_stat drop_row(struct isl_tab *tab, int row)
 {
-	isl_assert(tab->mat->ctx, ~tab->row_var[row] == tab->n_con - 1, return -1);
+	isl_assert(tab->mat->ctx, ~tab->row_var[row] == tab->n_con - 1,
+		return isl_stat_error);
 	if (row != tab->n_row - 1)
 		swap_rows(tab, row, tab->n_row - 1);
 	tab->n_row--;
 	tab->n_con--;
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Drop the variable in column "col" along with the column.
@@ -1871,7 +1872,7 @@ static int drop_row(struct isl_tab *tab,
  * the contents of the col_var array in a state
  * before the removal of the variable.
  */
-static int drop_col(struct isl_tab *tab, int col)
+static isl_stat drop_col(struct isl_tab *tab, int col)
 {
 	int var;
 
@@ -1880,8 +1881,8 @@ static int drop_col(struct isl_tab *tab,
 		swap_cols(tab, col, tab->n_col - 1);
 	tab->n_col--;
 	if (var_drop_entry(tab, var) < 0)
-		return -1;
-	return 0;
+		return isl_stat_error;
+	return isl_stat_ok;
 }
 
 /* Add inequality "ineq" and check if it conflicts with the
@@ -1890,25 +1891,27 @@ static int drop_col(struct isl_tab *tab,
  * This function assumes that at least one more row and at least
  * one more element in the constraint array are available in the tableau.
  */
-int isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq)
+isl_stat isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq)
 {
 	int r;
 	int sgn;
 	isl_int cst;
 
 	if (!tab)
-		return -1;
+		return isl_stat_error;
 	if (tab->bmap) {
 		struct isl_basic_map *bmap = tab->bmap;
 
-		isl_assert(tab->mat->ctx, tab->n_eq == bmap->n_eq, return -1);
+		isl_assert(tab->mat->ctx, tab->n_eq == bmap->n_eq,
+			return isl_stat_error);
 		isl_assert(tab->mat->ctx,
-			    tab->n_con == bmap->n_eq + bmap->n_ineq, return -1);
+			    tab->n_con == bmap->n_eq + bmap->n_ineq,
+			    return isl_stat_error);
 		tab->bmap = isl_basic_map_add_ineq(tab->bmap, ineq);
 		if (isl_tab_push(tab, isl_tab_undo_bmap_ineq) < 0)
-			return -1;
+			return isl_stat_error;
 		if (!tab->bmap)
-			return -1;
+			return isl_stat_error;
 	}
 	if (tab->cone) {
 		isl_int_init(cst);
@@ -1921,25 +1924,25 @@ int isl_tab_add_ineq(struct isl_tab *tab
 		isl_int_clear(cst);
 	}
 	if (r < 0)
-		return -1;
+		return isl_stat_error;
 	tab->con[r].is_nonneg = 1;
 	if (isl_tab_push_var(tab, isl_tab_undo_nonneg, &tab->con[r]) < 0)
-		return -1;
+		return isl_stat_error;
 	if (isl_tab_row_is_redundant(tab, tab->con[r].index)) {
 		if (isl_tab_mark_redundant(tab, tab->con[r].index) < 0)
-			return -1;
-		return 0;
+			return isl_stat_error;
+		return isl_stat_ok;
 	}
 
 	sgn = restore_row(tab, &tab->con[r]);
 	if (sgn < -1)
-		return -1;
+		return isl_stat_error;
 	if (sgn < 0)
 		return isl_tab_mark_empty(tab);
 	if (tab->con[r].is_row && isl_tab_row_is_redundant(tab, tab->con[r].index))
 		if (isl_tab_mark_redundant(tab, tab->con[r].index) < 0)
-			return -1;
-	return 0;
+			return isl_stat_error;
+	return isl_stat_ok;
 }
 
 /* Pivot a non-negative variable down until it reaches the value zero
@@ -2228,8 +2231,8 @@ static struct isl_vec *ineq_for_div(stru
  * This function assumes that at least two more rows and at least
  * two more elements in the constraint array are available in the tableau.
  */
-static int add_div_constraints(struct isl_tab *tab, unsigned div,
-	int (*add_ineq)(void *user, isl_int *), void *user)
+static isl_stat add_div_constraints(struct isl_tab *tab, unsigned div,
+	isl_stat (*add_ineq)(void *user, isl_int *), void *user)
 {
 	unsigned total;
 	unsigned div_pos;
@@ -2311,7 +2314,7 @@ static int div_is_nonneg(struct isl_tab
  * is added to the tableau.
  */
 int isl_tab_insert_div(struct isl_tab *tab, int pos, __isl_keep isl_vec *div,
-	int (*add_ineq)(void *user, isl_int *), void *user)
+	isl_stat (*add_ineq)(void *user, isl_int *), void *user)
 {
 	int r;
 	int nonneg;
@@ -2474,16 +2477,16 @@ error:
 /* Assuming "tab" is the tableau of a cone, check if the cone is
  * bounded, i.e., if it is empty or only contains the origin.
  */
-int isl_tab_cone_is_bounded(struct isl_tab *tab)
+isl_bool isl_tab_cone_is_bounded(struct isl_tab *tab)
 {
 	int i;
 
 	if (!tab)
-		return -1;
+		return isl_bool_error;
 	if (tab->empty)
-		return 1;
+		return isl_bool_true;
 	if (tab->n_dead == tab->n_col)
-		return 1;
+		return isl_bool_true;
 
 	for (;;) {
 		for (i = tab->n_redundant; i < tab->n_row; ++i) {
@@ -2494,17 +2497,17 @@ int isl_tab_cone_is_bounded(struct isl_t
 				continue;
 			sgn = sign_of_max(tab, var);
 			if (sgn < -1)
-				return -1;
+				return isl_bool_error;
 			if (sgn != 0)
-				return 0;
+				return isl_bool_false;
 			if (close_row(tab, var, 0) < 0)
-				return -1;
+				return isl_bool_error;
 			break;
 		}
 		if (tab->n_dead == tab->n_col)
-			return 1;
+			return isl_bool_true;
 		if (i == tab->n_row)
-			return 0;
+			return isl_bool_false;
 	}
 }
 
@@ -2894,6 +2897,37 @@ static int may_be_equality(struct isl_ta
 					    tab->mat->row[row][0]);
 }
 
+/* Return an isl_tab_var that has been marked or NULL if no such
+ * variable can be found.
+ * The marked field has only been set for variables that
+ * appear in non-redundant rows or non-dead columns.
+ *
+ * Pick the last constraint variable that is marked and
+ * that appears in either a non-redundant row or a non-dead columns.
+ * Since the returned variable is tested for being a redundant constraint or
+ * an implicit equality, there is no need to return any tab variable that
+ * corresponds to a variable.
+ */
+static struct isl_tab_var *select_marked(struct isl_tab *tab)
+{
+	int i;
+	struct isl_tab_var *var;
+
+	for (i = tab->n_con - 1; i >= 0; --i) {
+		var = &tab->con[i];
+		if (var->index < 0)
+			continue;
+		if (var->is_row && var->index < tab->n_redundant)
+			continue;
+		if (!var->is_row && var->index < tab->n_dead)
+			continue;
+		if (var->marked)
+			return var;
+	}
+
+	return NULL;
+}
+
 /* Check for (near) equalities among the constraints.
  * A constraint is an equality if it is non-negative and if
  * its maximal value is either
@@ -2909,6 +2943,7 @@ static int may_be_equality(struct isl_ta
  * Otherwise, if the maximal value is strictly less than one (and the
  * tableau is integer), then we restrict the value to being zero
  * by adding an opposite non-negative variable.
+ * The order in which the variables are considered is not important.
  */
 int isl_tab_detect_implicit_equalities(struct isl_tab *tab)
 {
@@ -2939,20 +2974,9 @@ int isl_tab_detect_implicit_equalities(s
 	while (n_marked) {
 		struct isl_tab_var *var;
 		int sgn;
-		for (i = tab->n_redundant; i < tab->n_row; ++i) {
-			var = isl_tab_var_from_row(tab, i);
-			if (var->marked)
-				break;
-		}
-		if (i == tab->n_row) {
-			for (i = tab->n_dead; i < tab->n_col; ++i) {
-				var = var_from_col(tab, i);
-				if (var->marked)
-					break;
-			}
-			if (i == tab->n_col)
-				break;
-		}
+		var = select_marked(tab);
+		if (!var)
+			break;
 		var->marked = 0;
 		n_marked--;
 		sgn = sign_of_max(tab, var);
@@ -3097,36 +3121,6 @@ static int con_is_redundant(struct isl_t
 	}
 }
 
-/* Return an isl_tab_var that has been marked or NULL if no such
- * variable can be found.
- * The marked field has only been set for variables that
- * appear in non-redundant rows or non-dead columns.
- *
- * Pick the last constraint variable that is marked and
- * that appears in either a non-redundant row or a non-dead columns.
- * Since the returned variable is tested for being a redundant constraint,
- * there is no need to return any tab variable that corresponds to a variable.
- */
-static struct isl_tab_var *select_marked(struct isl_tab *tab)
-{
-	int i;
-	struct isl_tab_var *var;
-
-	for (i = tab->n_con - 1; i >= 0; --i) {
-		var = &tab->con[i];
-		if (var->index < 0)
-			continue;
-		if (var->is_row && var->index < tab->n_redundant)
-			continue;
-		if (!var->is_row && var->index < tab->n_dead)
-			continue;
-		if (var->marked)
-			return var;
-	}
-
-	return NULL;
-}
-
 /* Check for (near) redundant constraints.
  * A constraint is redundant if it is non-negative and if
  * its minimal value (temporarily ignoring the non-negativity) is either
@@ -3591,21 +3585,23 @@ void isl_tab_clear_undo(struct isl_tab *
 
 /* Undo the operation performed by isl_tab_relax.
  */
-static int unrelax(struct isl_tab *tab, struct isl_tab_var *var) WARN_UNUSED;
-static int unrelax(struct isl_tab *tab, struct isl_tab_var *var)
+static isl_stat unrelax(struct isl_tab *tab, struct isl_tab_var *var)
+	WARN_UNUSED;
+static isl_stat unrelax(struct isl_tab *tab, struct isl_tab_var *var)
 {
 	unsigned off = 2 + tab->M;
 
 	if (!var->is_row && !max_is_manifestly_unbounded(tab, var))
 		if (to_row(tab, var, 1) < 0)
-			return -1;
+			return isl_stat_error;
 
 	if (var->is_row) {
 		isl_int_sub(tab->mat->row[var->index][1],
 		    tab->mat->row[var->index][1], tab->mat->row[var->index][0]);
 		if (var->is_nonneg) {
 			int sgn = restore_row(tab, var);
-			isl_assert(tab->mat->ctx, sgn >= 0, return -1);
+			isl_assert(tab->mat->ctx, sgn >= 0,
+				return isl_stat_error);
 		}
 	} else {
 		int i;
@@ -3619,7 +3615,7 @@ static int unrelax(struct isl_tab *tab,
 
 	}
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Undo the operation performed by isl_tab_unrestrict.
@@ -3627,14 +3623,14 @@ static int unrelax(struct isl_tab *tab,
  * In particular, mark the variable as being non-negative and make
  * sure the sample value respects this constraint.
  */
-static int ununrestrict(struct isl_tab *tab, struct isl_tab_var *var)
+static isl_stat ununrestrict(struct isl_tab *tab, struct isl_tab_var *var)
 {
 	var->is_nonneg = 1;
 
 	if (var->is_row && restore_row(tab, var) < -1)
-		return -1;
+		return isl_stat_error;
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Unmark the last redundant row in "tab" as being redundant.
@@ -3660,8 +3656,9 @@ static isl_stat restore_last_redundant(s
 	return isl_stat_ok;
 }
 
-static int perform_undo_var(struct isl_tab *tab, struct isl_tab_undo *undo) WARN_UNUSED;
-static int perform_undo_var(struct isl_tab *tab, struct isl_tab_undo *undo)
+static isl_stat perform_undo_var(struct isl_tab *tab, struct isl_tab_undo *undo)
+	WARN_UNUSED;
+static isl_stat perform_undo_var(struct isl_tab *tab, struct isl_tab_undo *undo)
 {
 	struct isl_tab_var *var = var_from_index(tab, undo->u.var_index);
 	switch (undo->type) {
@@ -3683,19 +3680,20 @@ static int perform_undo_var(struct isl_t
 		break;
 	case isl_tab_undo_allocate:
 		if (undo->u.var_index >= 0) {
-			isl_assert(tab->mat->ctx, !var->is_row, return -1);
+			isl_assert(tab->mat->ctx, !var->is_row,
+				return isl_stat_error);
 			return drop_col(tab, var->index);
 		}
 		if (!var->is_row) {
 			if (!max_is_manifestly_unbounded(tab, var)) {
 				if (to_row(tab, var, 1) < 0)
-					return -1;
+					return isl_stat_error;
 			} else if (!min_is_manifestly_unbounded(tab, var)) {
 				if (to_row(tab, var, -1) < 0)
-					return -1;
+					return isl_stat_error;
 			} else
 				if (to_row(tab, var, 0) < 0)
-					return -1;
+					return isl_stat_error;
 		}
 		return drop_row(tab, var->index);
 	case isl_tab_undo_relax:
@@ -3705,10 +3703,10 @@ static int perform_undo_var(struct isl_t
 	default:
 		isl_die(tab->mat->ctx, isl_error_internal,
 			"perform_undo_var called on invalid undo record",
-			return -1);
+			return isl_stat_error);
 	}
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Restore all rows that have been marked redundant by isl_tab_mark_redundant
@@ -3838,8 +3836,9 @@ static void drop_samples_since(struct is
 	}
 }
 
-static int perform_undo(struct isl_tab *tab, struct isl_tab_undo *undo) WARN_UNUSED;
-static int perform_undo(struct isl_tab *tab, struct isl_tab_undo *undo)
+static isl_stat perform_undo(struct isl_tab *tab, struct isl_tab_undo *undo)
+	WARN_UNUSED;
+static isl_stat perform_undo(struct isl_tab *tab, struct isl_tab_undo *undo)
 {
 	switch (undo->type) {
 	case isl_tab_undo_rational:
@@ -3864,7 +3863,7 @@ static int perform_undo(struct isl_tab *
 		return drop_bmap_div(tab, undo->u.var_index);
 	case isl_tab_undo_saved_basis:
 		if (restore_basis(tab, undo->u.col_var) < 0)
-			return -1;
+			return isl_stat_error;
 		break;
 	case isl_tab_undo_drop_sample:
 		tab->n_outside--;
@@ -3875,9 +3874,9 @@ static int perform_undo(struct isl_tab *
 	case isl_tab_undo_callback:
 		return undo->u.callback->run(undo->u.callback);
 	default:
-		isl_assert(tab->mat->ctx, 0, return -1);
+		isl_assert(tab->mat->ctx, 0, return isl_stat_error);
 	}
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Return the tableau to the state it was in when the snapshot "snap"
@@ -4009,7 +4008,7 @@ error:
 	return isl_ineq_error;
 }
 
-int isl_tab_track_bmap(struct isl_tab *tab, __isl_take isl_basic_map *bmap)
+isl_stat isl_tab_track_bmap(struct isl_tab *tab, __isl_take isl_basic_map *bmap)
 {
 	bmap = isl_basic_map_cow(bmap);
 	if (!tab || !bmap)
@@ -4020,7 +4019,7 @@ int isl_tab_track_bmap(struct isl_tab *t
 		if (!bmap)
 			goto error;
 		tab->bmap = bmap;
-		return 0;
+		return isl_stat_ok;
 	}
 
 	isl_assert(tab->mat->ctx, tab->n_eq == bmap->n_eq, goto error);
@@ -4029,13 +4028,13 @@ int isl_tab_track_bmap(struct isl_tab *t
 
 	tab->bmap = bmap;
 
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_basic_map_free(bmap);
-	return -1;
+	return isl_stat_error;
 }
 
-int isl_tab_track_bset(struct isl_tab *tab, __isl_take isl_basic_set *bset)
+isl_stat isl_tab_track_bset(struct isl_tab *tab, __isl_take isl_basic_set *bset)
 {
 	return isl_tab_track_bmap(tab, bset_to_bmap(bset));
 }

Modified: polly/trunk/lib/External/isl/isl_tab.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_tab.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_tab.h (original)
+++ polly/trunk/lib/External/isl/isl_tab.h Thu Feb 16 23:11:16 2017
@@ -48,7 +48,7 @@ enum isl_tab_undo_type {
 };
 
 struct isl_tab_callback {
-	int (*run)(struct isl_tab_callback *cb);
+	isl_stat (*run)(struct isl_tab_callback *cb);
 };
 
 union isl_tab_undo_val {
@@ -192,7 +192,7 @@ __isl_give struct isl_tab *isl_tab_from_
 	__isl_keep isl_basic_set *bset, int track);
 struct isl_tab *isl_tab_from_recession_cone(struct isl_basic_set *bset,
 	int parametric);
-int isl_tab_cone_is_bounded(struct isl_tab *tab);
+isl_bool isl_tab_cone_is_bounded(struct isl_tab *tab);
 struct isl_basic_map *isl_basic_map_update_from_tab(struct isl_basic_map *bmap,
 	struct isl_tab *tab);
 struct isl_basic_set *isl_basic_set_update_from_tab(struct isl_basic_set *bset,
@@ -207,14 +207,16 @@ enum isl_lp_result isl_tab_min(struct is
 	isl_int *f, isl_int denom, isl_int *opt, isl_int *opt_denom,
 	unsigned flags) WARN_UNUSED;
 
-int isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq) WARN_UNUSED;
+isl_stat isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq) WARN_UNUSED;
 int isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED;
 int isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED;
 
 int isl_tab_freeze_constraint(struct isl_tab *tab, int con) WARN_UNUSED;
 
-int isl_tab_track_bmap(struct isl_tab *tab, __isl_take isl_basic_map *bmap) WARN_UNUSED;
-int isl_tab_track_bset(struct isl_tab *tab, __isl_take isl_basic_set *bset) WARN_UNUSED;
+isl_stat isl_tab_track_bmap(struct isl_tab *tab, __isl_take isl_basic_map *bmap)
+	WARN_UNUSED;
+isl_stat isl_tab_track_bset(struct isl_tab *tab, __isl_take isl_basic_set *bset)
+	WARN_UNUSED;
 __isl_keep isl_basic_set *isl_tab_peek_bset(struct isl_tab *tab);
 
 int isl_tab_is_equality(struct isl_tab *tab, int con);
@@ -289,7 +291,7 @@ __isl_null isl_tab_lexmin *isl_tab_lexmi
 struct isl_tab_var *isl_tab_var_from_row(struct isl_tab *tab, int i);
 int isl_tab_mark_redundant(struct isl_tab *tab, int row) WARN_UNUSED;
 int isl_tab_mark_rational(struct isl_tab *tab) WARN_UNUSED;
-int isl_tab_mark_empty(struct isl_tab *tab) WARN_UNUSED;
+isl_stat isl_tab_mark_empty(struct isl_tab *tab) WARN_UNUSED;
 struct isl_tab *isl_tab_dup(struct isl_tab *tab);
 struct isl_tab *isl_tab_product(struct isl_tab *tab1, struct isl_tab *tab2);
 int isl_tab_extend_cons(struct isl_tab *tab, unsigned n_new) WARN_UNUSED;
@@ -324,7 +326,7 @@ int isl_tab_push_callback(struct isl_tab
 	struct isl_tab_callback *callback) WARN_UNUSED;
 
 int isl_tab_insert_div(struct isl_tab *tab, int pos, __isl_keep isl_vec *div,
-	int (*add_ineq)(void *user, isl_int *), void *user);
+	isl_stat (*add_ineq)(void *user, isl_int *), void *user);
 int isl_tab_add_div(struct isl_tab *tab, __isl_keep isl_vec *div);
 
 int isl_tab_shift_var(struct isl_tab *tab, int pos, isl_int shift) WARN_UNUSED;

Modified: polly/trunk/lib/External/isl/isl_tab_lexopt_templ.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_tab_lexopt_templ.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_tab_lexopt_templ.c (original)
+++ polly/trunk/lib/External/isl/isl_tab_lexopt_templ.c Thu Feb 16 23:11:16 2017
@@ -145,7 +145,7 @@ static __isl_give TYPE *SF(basic_map_par
 	__isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
 	__isl_give isl_set **empty, int max)
 {
-	int par = 0;
+	isl_bool par = isl_bool_false;
 	int first, second;
 
 	if (!bmap)

Modified: polly/trunk/lib/External/isl/isl_tab_pip.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_tab_pip.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_tab_pip.c (original)
+++ polly/trunk/lib/External/isl/isl_tab_pip.c Thu Feb 16 23:11:16 2017
@@ -133,16 +133,15 @@ struct isl_context_lex {
 
 /* A stack (linked list) of solutions of subtrees of the search space.
  *
- * "M" describes the solution in terms of the dimensions of "dom".
- * The number of columns of "M" is one more than the total number
- * of dimensions of "dom".
+ * "ma" describes the solution as a function of "dom".
+ * In particular, the domain space of "ma" is equal to the space of "dom".
  *
- * If "M" is NULL, then there is no solution on "dom".
+ * If "ma" is NULL, then there is no solution on "dom".
  */
 struct isl_partial_sol {
 	int level;
 	struct isl_basic_set *dom;
-	struct isl_mat *M;
+	isl_multi_aff *ma;
 
 	struct isl_partial_sol *next;
 };
@@ -156,16 +155,29 @@ struct isl_sol_callback {
 /* isl_sol is an interface for constructing a solution to
  * a parametric integer linear programming problem.
  * Every time the algorithm reaches a state where a solution
- * can be read off from the tableau (including cases where the tableau
- * is empty), the function "add" is called on the isl_sol passed
- * to find_solutions_main.
+ * can be read off from the tableau, the function "add" is called
+ * on the isl_sol passed to find_solutions_main.  In a state where
+ * the tableau is empty, "add_empty" is called instead.
+ * "free" is called to free the implementation specific fields, if any.
+ *
+ * "error" is set if some error has occurred.  This flag invalidates
+ * the remainder of the data structure.
+ * If "rational" is set, then a rational optimization is being performed.
+ * "level" is the current level in the tree with nodes for each
+ * split in the context.
+ * If "max" is set, then a maximization problem is being solved, rather than
+ * a minimization problem, which means that the variables in the
+ * tableau have value "M - x" rather than "M + x".
+ * "n_out" is the number of output dimensions in the input.
+ * "space" is the space in which the solution (and also the input) lives.
  *
  * The context tableau is owned by isl_sol and is updated incrementally.
  *
- * There are currently two implementations of this interface,
+ * There are currently three implementations of this interface,
  * isl_sol_map, which simply collects the solutions in an isl_map
  * and (optionally) the parts of the context where there is no solution
- * in an isl_set, and
+ * in an isl_set,
+ * isl_sol_pma, which collects an isl_pw_multi_aff instead, and
  * isl_sol_for, which calls a user-defined function for each part of
  * the solution.
  */
@@ -175,10 +187,11 @@ struct isl_sol {
 	int level;
 	int max;
 	int n_out;
+	isl_space *space;
 	struct isl_context *context;
 	struct isl_partial_sol *partial;
 	void (*add)(struct isl_sol *sol,
-			    struct isl_basic_set *dom, struct isl_mat *M);
+		__isl_take isl_basic_set *dom, __isl_take isl_multi_aff *ma);
 	void (*add_empty)(struct isl_sol *sol, struct isl_basic_set *bset);
 	void (*free)(struct isl_sol *sol);
 	struct isl_sol_callback	dec_level;
@@ -192,17 +205,23 @@ static void sol_free(struct isl_sol *sol
 	for (partial = sol->partial; partial; partial = next) {
 		next = partial->next;
 		isl_basic_set_free(partial->dom);
-		isl_mat_free(partial->M);
+		isl_multi_aff_free(partial->ma);
 		free(partial);
 	}
+	isl_space_free(sol->space);
+	if (sol->context)
+		sol->context->op->free(sol->context);
 	sol->free(sol);
+	free(sol);
 }
 
-/* Push a partial solution represented by a domain and mapping M
+/* Push a partial solution represented by a domain and function "ma"
  * onto the stack of partial solutions.
+ * If "ma" is NULL, then "dom" represents a part of the domain
+ * with no solution.
  */
 static void sol_push_sol(struct isl_sol *sol,
-	struct isl_basic_set *dom, struct isl_mat *M)
+	__isl_take isl_basic_set *dom, __isl_take isl_multi_aff *ma)
 {
 	struct isl_partial_sol *partial;
 
@@ -215,7 +234,7 @@ static void sol_push_sol(struct isl_sol
 
 	partial->level = sol->level;
 	partial->dom = dom;
-	partial->M = M;
+	partial->ma = ma;
 	partial->next = sol->partial;
 
 	sol->partial = partial;
@@ -223,10 +242,110 @@ static void sol_push_sol(struct isl_sol
 	return;
 error:
 	isl_basic_set_free(dom);
-	isl_mat_free(M);
+	isl_multi_aff_free(ma);
 	sol->error = 1;
 }
 
+/* Check that the final columns of "M", starting at "first", are zero.
+ */
+static isl_stat check_final_columns_are_zero(__isl_keep isl_mat *M,
+	unsigned first)
+{
+	int i;
+	unsigned rows, cols, n;
+
+	if (!M)
+		return isl_stat_error;
+	rows = isl_mat_rows(M);
+	cols = isl_mat_cols(M);
+	n = cols - first;
+	for (i = 0; i < rows; ++i)
+		if (isl_seq_first_non_zero(M->row[i] + first, n) != -1)
+			isl_die(isl_mat_get_ctx(M), isl_error_internal,
+				"final columns should be zero",
+				return isl_stat_error);
+	return isl_stat_ok;
+}
+
+/* Set the affine expressions in "ma" according to the rows in "M", which
+ * are defined over the local space "ls".
+ * The matrix "M" may have extra (zero) columns beyond the number
+ * of variables in "ls".
+ */
+static __isl_give isl_multi_aff *set_from_affine_matrix(
+	__isl_take isl_multi_aff *ma, __isl_take isl_local_space *ls,
+	__isl_take isl_mat *M)
+{
+	int i, dim;
+	isl_aff *aff;
+
+	if (!ma || !ls || !M)
+		goto error;
+
+	dim = isl_local_space_dim(ls, isl_dim_all);
+	if (check_final_columns_are_zero(M, 1 + dim) < 0)
+		goto error;
+	for (i = 1; i < M->n_row; ++i) {
+		aff = isl_aff_alloc(isl_local_space_copy(ls));
+		if (aff) {
+			isl_int_set(aff->v->el[0], M->row[0][0]);
+			isl_seq_cpy(aff->v->el + 1, M->row[i], 1 + dim);
+		}
+		aff = isl_aff_normalize(aff);
+		ma = isl_multi_aff_set_aff(ma, i - 1, aff);
+	}
+	isl_local_space_free(ls);
+	isl_mat_free(M);
+
+	return ma;
+error:
+	isl_local_space_free(ls);
+	isl_mat_free(M);
+	isl_multi_aff_free(ma);
+	return NULL;
+}
+
+/* Push a partial solution represented by a domain and mapping M
+ * onto the stack of partial solutions.
+ *
+ * The affine matrix "M" maps the dimensions of the context
+ * to the output variables.  Convert it into an isl_multi_aff and
+ * then call sol_push_sol.
+ *
+ * Note that the description of the initial context may have involved
+ * existentially quantified variables, in which case they also appear
+ * in "dom".  These need to be removed before creating the affine
+ * expression because an affine expression cannot be defined in terms
+ * of existentially quantified variables without a known representation.
+ * Since newly added integer divisions are inserted before these
+ * existentially quantified variables, they are still in the final
+ * positions and the corresponding final columns of "M" are zero
+ * because align_context_divs adds the existentially quantified
+ * variables of the context to the main tableau without any constraints and
+ * any equality constraints that are added later on can only serve
+ * to eliminate these existentially quantified variables.
+ */
+static void sol_push_sol_mat(struct isl_sol *sol,
+	__isl_take isl_basic_set *dom, __isl_take isl_mat *M)
+{
+	isl_local_space *ls;
+	isl_multi_aff *ma;
+	int n_div, n_known;
+
+	n_div = isl_basic_set_dim(dom, isl_dim_div);
+	n_known = n_div - sol->context->n_unknown;
+
+	ma = isl_multi_aff_alloc(isl_space_copy(sol->space));
+	ls = isl_basic_set_get_local_space(dom);
+	ls = isl_local_space_drop_dims(ls, isl_dim_div,
+					n_known, n_div - n_known);
+	ma = set_from_affine_matrix(ma, ls, M);
+
+	if (!ma)
+		dom = isl_basic_set_free(dom);
+	sol_push_sol(sol, dom, ma);
+}
+
 /* Pop one partial solution from the partial solution stack and
  * pass it on to sol->add or sol->add_empty.
  */
@@ -237,8 +356,8 @@ static void sol_pop_one(struct isl_sol *
 	partial = sol->partial;
 	sol->partial = partial->next;
 
-	if (partial->M)
-		sol->add(sol, partial->dom, partial->M);
+	if (partial->ma)
+		sol->add(sol, partial->dom, partial->ma);
 	else
 		sol->add_empty(sol, partial->dom);
 	free(partial);
@@ -260,33 +379,143 @@ static struct isl_basic_set *sol_domain(
 	return bset;
 }
 
-/* Check whether two partial solutions have the same mapping, where n_div
- * is the number of divs that the two partial solutions have in common.
+/* Check whether two partial solutions have the same affine expressions.
  */
-static int same_solution(struct isl_partial_sol *s1, struct isl_partial_sol *s2,
-	unsigned n_div)
+static isl_bool same_solution(struct isl_partial_sol *s1,
+	struct isl_partial_sol *s2)
 {
-	int i;
-	unsigned dim;
+	if (!s1->ma != !s2->ma)
+		return isl_bool_false;
+	if (!s1->ma)
+		return isl_bool_true;
 
-	if (!s1->M != !s2->M)
-		return 0;
-	if (!s1->M)
-		return 1;
+	return isl_multi_aff_plain_is_equal(s1->ma, s2->ma);
+}
 
-	dim = isl_basic_set_total_dim(s1->dom) - s1->dom->n_div;
+/* Swap the initial two partial solutions in "sol".
+ *
+ * That is, go from
+ *
+ *	sol->partial = p1; p1->next = p2; p2->next = p3
+ *
+ * to
+ *
+ *	sol->partial = p2; p2->next = p1; p1->next = p3
+ */
+static void swap_initial(struct isl_sol *sol)
+{
+	struct isl_partial_sol *partial;
 
-	for (i = 0; i < s1->M->n_row; ++i) {
-		if (isl_seq_first_non_zero(s1->M->row[i]+1+dim+n_div,
-					    s1->M->n_col-1-dim-n_div) != -1)
-			return 0;
-		if (isl_seq_first_non_zero(s2->M->row[i]+1+dim+n_div,
-					    s2->M->n_col-1-dim-n_div) != -1)
-			return 0;
-		if (!isl_seq_eq(s1->M->row[i], s2->M->row[i], 1+dim+n_div))
-			return 0;
+	partial = sol->partial;
+	sol->partial = partial->next;
+	partial->next = partial->next->next;
+	sol->partial->next = partial;
+}
+
+/* Combine the initial two partial solution of "sol" into
+ * a partial solution with the current context domain of "sol" and
+ * the function description of the second partial solution in the list.
+ * The level of the new partial solution is set to the current level.
+ *
+ * That is, the first two partial solutions (D1,M1) and (D2,M2) are
+ * replaced by (D,M2), where D is the domain of "sol", which is assumed
+ * to be the union of D1 and D2, while M1 is assumed to be equal to M2
+ * (at least on D1).
+ */
+static isl_stat combine_initial_into_second(struct isl_sol *sol)
+{
+	struct isl_partial_sol *partial;
+	isl_basic_set *bset;
+
+	partial = sol->partial;
+
+	bset = sol_domain(sol);
+	isl_basic_set_free(partial->next->dom);
+	partial->next->dom = bset;
+	partial->next->level = sol->level;
+
+	if (!bset)
+		return isl_stat_error;
+
+	sol->partial = partial->next;
+	isl_basic_set_free(partial->dom);
+	isl_multi_aff_free(partial->ma);
+	free(partial);
+
+	return isl_stat_ok;
+}
+
+/* Are "ma1" and "ma2" equal to each other on "dom"?
+ *
+ * Combine "ma1" and "ma2" with "dom" and check if the results are the same.
+ * "dom" may have existentially quantified variables.  Eliminate them first
+ * as otherwise they would have to be eliminated twice, in a more complicated
+ * context.
+ */
+static isl_bool equal_on_domain(__isl_keep isl_multi_aff *ma1,
+	__isl_keep isl_multi_aff *ma2, __isl_keep isl_basic_set *dom)
+{
+	isl_set *set;
+	isl_pw_multi_aff *pma1, *pma2;
+	isl_bool equal;
+
+	set = isl_basic_set_compute_divs(isl_basic_set_copy(dom));
+	pma1 = isl_pw_multi_aff_alloc(isl_set_copy(set),
+					isl_multi_aff_copy(ma1));
+	pma2 = isl_pw_multi_aff_alloc(set, isl_multi_aff_copy(ma2));
+	equal = isl_pw_multi_aff_is_equal(pma1, pma2);
+	isl_pw_multi_aff_free(pma1);
+	isl_pw_multi_aff_free(pma2);
+
+	return equal;
+}
+
+/* The initial two partial solutions of "sol" are known to be at
+ * the same level.
+ * If they represent the same solution (on different parts of the domain),
+ * then combine them into a single solution at the current level.
+ * Otherwise, pop them both.
+ *
+ * Even if the two partial solution are not obviously the same,
+ * one may still be a simplification of the other over its own domain.
+ * Also check if the two sets of affine functions are equal when
+ * restricted to one of the domains.  If so, combine the two
+ * using the set of affine functions on the other domain.
+ * That is, for two partial solutions (D1,M1) and (D2,M2),
+ * if M1 = M2 on D1, then the pair of partial solutions can
+ * be replaced by (D1+D2,M2) and similarly when M1 = M2 on D2.
+ */
+static isl_stat combine_initial_if_equal(struct isl_sol *sol)
+{
+	struct isl_partial_sol *partial;
+	isl_bool same;
+
+	partial = sol->partial;
+
+	same = same_solution(partial, partial->next);
+	if (same < 0)
+		return isl_stat_error;
+	if (same)
+		return combine_initial_into_second(sol);
+	if (partial->ma && partial->next->ma) {
+		same = equal_on_domain(partial->ma, partial->next->ma,
+					partial->dom);
+		if (same < 0)
+			return isl_stat_error;
+		if (same)
+			return combine_initial_into_second(sol);
+		same = equal_on_domain(partial->ma, partial->next->ma,
+					partial->next->dom);
+		if (same) {
+			swap_initial(sol);
+			return combine_initial_into_second(sol);
+		}
 	}
-	return 1;
+
+	sol_pop_one(sol);
+	sol_pop_one(sol);
+
+	return isl_stat_ok;
 }
 
 /* Pop all solutions from the partial solution stack that were pushed onto
@@ -301,7 +530,6 @@ static int same_solution(struct isl_part
 static void sol_pop(struct isl_sol *sol)
 {
 	struct isl_partial_sol *partial;
-	unsigned n_div;
 
 	if (sol->error)
 		return;
@@ -320,40 +548,8 @@ static void sol_pop(struct isl_sol *sol)
 		return;
 
 	if (partial->next && partial->next->level == partial->level) {
-		n_div = isl_basic_set_dim(
-				sol->context->op->peek_basic_set(sol->context),
-				isl_dim_div);
-
-		if (!same_solution(partial, partial->next, n_div)) {
-			sol_pop_one(sol);
-			sol_pop_one(sol);
-		} else {
-			struct isl_basic_set *bset;
-			isl_mat *M;
-			unsigned n;
-
-			n = isl_basic_set_dim(partial->next->dom, isl_dim_div);
-			n -= n_div;
-			bset = sol_domain(sol);
-			isl_basic_set_free(partial->next->dom);
-			partial->next->dom = bset;
-			M = partial->next->M;
-			if (M) {
-				M = isl_mat_drop_cols(M, M->n_col - n, n);
-				partial->next->M = M;
-				if (!M)
-					goto error;
-			}
-			partial->next->level = sol->level;
-
-			if (!bset)
-				goto error;
-
-			sol->partial = partial->next;
-			isl_basic_set_free(partial->dom);
-			isl_mat_free(partial->M);
-			free(partial);
-		}
+		if (combine_initial_if_equal(sol) < 0)
+			goto error;
 	} else
 		sol_pop_one(sol);
 
@@ -377,13 +573,13 @@ static void sol_dec_level(struct isl_sol
 	sol_pop(sol);
 }
 
-static int sol_dec_level_wrap(struct isl_tab_callback *cb)
+static isl_stat sol_dec_level_wrap(struct isl_tab_callback *cb)
 {
 	struct isl_sol_callback *callback = (struct isl_sol_callback *)cb;
 
 	sol_dec_level(callback->sol);
 
-	return callback->sol->error ? -1 : 0;
+	return callback->sol->error ? isl_stat_error : isl_stat_ok;
 }
 
 /* Move down to next level and push callback onto context tableau
@@ -544,7 +740,7 @@ static void sol_add(struct isl_sol *sol,
 
 	isl_int_clear(m);
 
-	sol_push_sol(sol, bset, mat);
+	sol_push_sol_mat(sol, bset, mat);
 	return;
 error2:
 	isl_int_clear(m);
@@ -560,20 +756,11 @@ struct isl_sol_map {
 	struct isl_set	*empty;
 };
 
-static void sol_map_free(struct isl_sol_map *sol_map)
+static void sol_map_free(struct isl_sol *sol)
 {
-	if (!sol_map)
-		return;
-	if (sol_map->sol.context)
-		sol_map->sol.context->op->free(sol_map->sol.context);
+	struct isl_sol_map *sol_map = (struct isl_sol_map *) sol;
 	isl_map_free(sol_map->map);
 	isl_set_free(sol_map->empty);
-	free(sol_map);
-}
-
-static void sol_map_free_wrap(struct isl_sol *sol)
-{
-	sol_map_free((struct isl_sol_map *)sol);
 }
 
 /* This function is called for parts of the context where there is
@@ -605,104 +792,35 @@ static void sol_map_add_empty_wrap(struc
 	sol_map_add_empty((struct isl_sol_map *)sol, bset);
 }
 
-/* Given a basic set "dom" that represents the context and an affine
- * matrix "M" that maps the dimensions of the context to the
- * output variables, construct a basic map with the same parameters
- * and divs as the context, the dimensions of the context as input
- * dimensions and a number of output dimensions that is equal to
- * the number of output dimensions in the input map.
- *
- * The constraints and divs of the context are simply copied
- * from "dom".  For each row
- *	x = c + e(y)
- * an equality
- *	c + e(y) - d x = 0
- * is added, with d the common denominator of M.
+/* Given a basic set "dom" that represents the context and a tuple of
+ * affine expressions "ma" defined over this domain, construct a basic map
+ * that expresses this function on the domain.
  */
 static void sol_map_add(struct isl_sol_map *sol,
-	struct isl_basic_set *dom, struct isl_mat *M)
+	__isl_take isl_basic_set *dom, __isl_take isl_multi_aff *ma)
 {
-	int i;
-	struct isl_basic_map *bmap = NULL;
-	unsigned n_eq;
-	unsigned n_ineq;
-	unsigned nparam;
-	unsigned total;
-	unsigned n_div;
-	unsigned n_out;
+	isl_basic_map *bmap;
 
-	if (sol->sol.error || !dom || !M)
+	if (sol->sol.error || !dom || !ma)
 		goto error;
 
-	n_out = sol->sol.n_out;
-	n_eq = dom->n_eq + n_out;
-	n_ineq = dom->n_ineq;
-	n_div = dom->n_div;
-	nparam = isl_basic_set_total_dim(dom) - n_div;
-	total = isl_map_dim(sol->map, isl_dim_all);
-	bmap = isl_basic_map_alloc_space(isl_map_get_space(sol->map),
-					n_div, n_eq, 2 * n_div + n_ineq);
-	if (!bmap)
-		goto error;
-	if (sol->sol.rational)
-		ISL_F_SET(bmap, ISL_BASIC_MAP_RATIONAL);
-	for (i = 0; i < dom->n_div; ++i) {
-		int k = isl_basic_map_alloc_div(bmap);
-		if (k < 0)
-			goto error;
-		isl_seq_cpy(bmap->div[k], dom->div[i], 1 + 1 + nparam);
-		isl_seq_clr(bmap->div[k] + 1 + 1 + nparam, total - nparam);
-		isl_seq_cpy(bmap->div[k] + 1 + 1 + total,
-			    dom->div[i] + 1 + 1 + nparam, i);
-	}
-	for (i = 0; i < dom->n_eq; ++i) {
-		int k = isl_basic_map_alloc_equality(bmap);
-		if (k < 0)
-			goto error;
-		isl_seq_cpy(bmap->eq[k], dom->eq[i], 1 + nparam);
-		isl_seq_clr(bmap->eq[k] + 1 + nparam, total - nparam);
-		isl_seq_cpy(bmap->eq[k] + 1 + total,
-			    dom->eq[i] + 1 + nparam, n_div);
-	}
-	for (i = 0; i < dom->n_ineq; ++i) {
-		int k = isl_basic_map_alloc_inequality(bmap);
-		if (k < 0)
-			goto error;
-		isl_seq_cpy(bmap->ineq[k], dom->ineq[i], 1 + nparam);
-		isl_seq_clr(bmap->ineq[k] + 1 + nparam, total - nparam);
-		isl_seq_cpy(bmap->ineq[k] + 1 + total,
-			dom->ineq[i] + 1 + nparam, n_div);
-	}
-	for (i = 0; i < M->n_row - 1; ++i) {
-		int k = isl_basic_map_alloc_equality(bmap);
-		if (k < 0)
-			goto error;
-		isl_seq_cpy(bmap->eq[k], M->row[1 + i], 1 + nparam);
-		isl_seq_clr(bmap->eq[k] + 1 + nparam, n_out);
-		isl_int_neg(bmap->eq[k][1 + nparam + i], M->row[0][0]);
-		isl_seq_cpy(bmap->eq[k] + 1 + nparam + n_out,
-			    M->row[1 + i] + 1 + nparam, n_div);
-	}
-	bmap = isl_basic_map_simplify(bmap);
-	bmap = isl_basic_map_finalize(bmap);
+	bmap = isl_basic_map_from_multi_aff2(ma, sol->sol.rational);
+	bmap = isl_basic_map_intersect_domain(bmap, dom);
 	sol->map = isl_map_grow(sol->map, 1);
 	sol->map = isl_map_add_basic_map(sol->map, bmap);
-	isl_basic_set_free(dom);
-	isl_mat_free(M);
 	if (!sol->map)
 		sol->sol.error = 1;
 	return;
 error:
 	isl_basic_set_free(dom);
-	isl_mat_free(M);
-	isl_basic_map_free(bmap);
+	isl_multi_aff_free(ma);
 	sol->sol.error = 1;
 }
 
 static void sol_map_add_wrap(struct isl_sol *sol,
-	struct isl_basic_set *dom, struct isl_mat *M)
+	__isl_take isl_basic_set *dom, __isl_take isl_multi_aff *ma)
 {
-	sol_map_add((struct isl_sol_map *)sol, dom, M);
+	sol_map_add((struct isl_sol_map *)sol, dom, ma);
 }
 
 
@@ -1875,7 +1993,7 @@ static int tab_has_valid_sample(struct i
  */
 static isl_bool context_tab_insert_div(struct isl_tab *tab, int pos,
 	__isl_keep isl_vec *div,
-	int (*add_ineq)(void *user, isl_int *), void *user)
+	isl_stat (*add_ineq)(void *user, isl_int *), void *user)
 {
 	int i;
 	int r;
@@ -2333,11 +2451,11 @@ error:
 	clex->tab = NULL;
 }
 
-static int context_lex_add_ineq_wrap(void *user, isl_int *ineq)
+static isl_stat context_lex_add_ineq_wrap(void *user, isl_int *ineq)
 {
 	struct isl_context *context = (struct isl_context *)user;
 	context_lex_add_ineq(context, ineq, 0, 0);
-	return context->op->is_ok(context) ? 0 : -1;
+	return context->op->is_ok(context) ? isl_stat_ok : isl_stat_error;
 }
 
 /* Check which signs can be obtained by "ineq" on all the currently
@@ -2637,14 +2755,12 @@ static struct isl_tab *context_tab_for_l
 	if (!bset)
 		return NULL;
 	tab = tab_for_lexmin(bset_to_bmap(bset), NULL, 1, 0);
-	if (!tab)
-		goto error;
 	if (isl_tab_track_bset(tab, bset) < 0)
 		goto error;
 	tab = isl_tab_init_samples(tab);
 	return tab;
 error:
-	isl_basic_set_free(bset);
+	isl_tab_free(tab);
 	return NULL;
 }
 
@@ -3023,11 +3139,11 @@ error:
 	cgbr->tab = NULL;
 }
 
-static int context_gbr_add_ineq_wrap(void *user, isl_int *ineq)
+static isl_stat context_gbr_add_ineq_wrap(void *user, isl_int *ineq)
 {
 	struct isl_context *context = (struct isl_context *)user;
 	context_gbr_add_ineq(context, ineq, 0, 0);
-	return context->op->is_ok(context) ? 0 : -1;
+	return context->op->is_ok(context) ? isl_stat_ok : isl_stat_error;
 }
 
 static enum isl_tab_row_sign context_gbr_ineq_sign(struct isl_context *context,
@@ -3464,6 +3580,30 @@ static struct isl_context *isl_context_a
 	return context;
 }
 
+/* Initialize some common fields of "sol", which keeps track
+ * of the solution of an optimization problem on "bmap" over
+ * the domain "dom".
+ * If "max" is set, then a maximization problem is being solved, rather than
+ * a minimization problem, which means that the variables in the
+ * tableau have value "M - x" rather than "M + x".
+ */
+static isl_stat sol_init(struct isl_sol *sol, __isl_keep isl_basic_map *bmap,
+	__isl_keep isl_basic_set *dom, int max)
+{
+	sol->rational = ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL);
+	sol->dec_level.callback.run = &sol_dec_level_wrap;
+	sol->dec_level.sol = sol;
+	sol->max = max;
+	sol->n_out = isl_basic_map_dim(bmap, isl_dim_out);
+	sol->space = isl_basic_map_get_space(bmap);
+
+	sol->context = isl_context_alloc(dom);
+	if (!sol->space || !sol->context)
+		return isl_stat_error;
+
+	return isl_stat_ok;
+}
+
 /* Construct an isl_sol_map structure for accumulating the solution.
  * If track_empty is set, then we also keep track of the parts
  * of the context where there is no solution.
@@ -3471,10 +3611,11 @@ static struct isl_context *isl_context_a
  * a minimization problem, which means that the variables in the
  * tableau have value "M - x" rather than "M + x".
  */
-static struct isl_sol *sol_map_init(struct isl_basic_map *bmap,
-	struct isl_basic_set *dom, int track_empty, int max)
+static struct isl_sol *sol_map_init(__isl_keep isl_basic_map *bmap,
+	__isl_take isl_basic_set *dom, int track_empty, int max)
 {
 	struct isl_sol_map *sol_map = NULL;
+	isl_space *space;
 
 	if (!bmap)
 		goto error;
@@ -3483,23 +3624,16 @@ static struct isl_sol *sol_map_init(stru
 	if (!sol_map)
 		goto error;
 
-	sol_map->sol.rational = ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL);
-	sol_map->sol.dec_level.callback.run = &sol_dec_level_wrap;
-	sol_map->sol.dec_level.sol = &sol_map->sol;
-	sol_map->sol.max = max;
-	sol_map->sol.n_out = isl_basic_map_dim(bmap, isl_dim_out);
+	sol_map->sol.free = &sol_map_free;
+	if (sol_init(&sol_map->sol, bmap, dom, max) < 0)
+		goto error;
 	sol_map->sol.add = &sol_map_add_wrap;
 	sol_map->sol.add_empty = track_empty ? &sol_map_add_empty_wrap : NULL;
-	sol_map->sol.free = &sol_map_free_wrap;
-	sol_map->map = isl_map_alloc_space(isl_basic_map_get_space(bmap), 1,
-					    ISL_MAP_DISJOINT);
+	space = isl_space_copy(sol_map->sol.space);
+	sol_map->map = isl_map_alloc_space(space, 1, ISL_MAP_DISJOINT);
 	if (!sol_map->map)
 		goto error;
 
-	sol_map->sol.context = isl_context_alloc(dom);
-	if (!sol_map->sol.context)
-		goto error;
-
 	if (track_empty) {
 		sol_map->empty = isl_set_alloc_space(isl_basic_set_get_space(dom),
 							1, ISL_SET_DISJOINT);
@@ -3511,7 +3645,7 @@ static struct isl_sol *sol_map_init(stru
 	return &sol_map->sol;
 error:
 	isl_basic_set_free(dom);
-	sol_map_free(sol_map);
+	sol_free(&sol_map->sol);
 	return NULL;
 }
 
@@ -4345,10 +4479,10 @@ static int constraint_equal(const void *
  * of the result are usually not the same as those of the input.
  * Furthermore, check that each of the input variables that occur
  * in those constraints does not occur in any other constraint.
- * If so, return 1 and return the row indices of the two constraints
+ * If so, return true and return the row indices of the two constraints
  * in *first and *second.
  */
-static int parallel_constraints(__isl_keep isl_basic_map *bmap,
+static isl_bool parallel_constraints(__isl_keep isl_basic_map *bmap,
 	int *first, int *second)
 {
 	int i;
@@ -4407,7 +4541,7 @@ static int parallel_constraints(__isl_ke
 error:
 	isl_hash_table_free(ctx, table);
 	free(occurrences);
-	return -1;
+	return isl_bool_error;
 }
 
 /* Given a set of upper bounds in "var", add constraints to "bset"
@@ -4505,7 +4639,7 @@ error:
  * an upper bound that is different from the upper bounds on which it
  * is defined.
  */
-static int need_split_basic_map(__isl_keep isl_basic_map *bmap,
+static isl_bool need_split_basic_map(__isl_keep isl_basic_map *bmap,
 	__isl_keep isl_mat *cst)
 {
 	int i, j;
@@ -4517,29 +4651,29 @@ static int need_split_basic_map(__isl_ke
 
 	for (i = 0; i < bmap->n_div; ++i)
 		if (!isl_int_is_zero(bmap->div[i][2 + pos]))
-			return 1;
+			return isl_bool_true;
 
 	for (i = 0; i < bmap->n_eq; ++i)
 		if (!isl_int_is_zero(bmap->eq[i][1 + pos]))
-			return 1;
+			return isl_bool_true;
 
 	for (i = 0; i < bmap->n_ineq; ++i) {
 		if (isl_int_is_nonneg(bmap->ineq[i][1 + pos]))
 			continue;
 		if (!isl_int_is_negone(bmap->ineq[i][1 + pos]))
-			return 1;
+			return isl_bool_true;
 		if (isl_seq_first_non_zero(bmap->ineq[i] + 1 + pos + 1,
 					   total - pos - 1) >= 0)
-			return 1;
+			return isl_bool_true;
 
 		for (j = 0; j < cst->n_row; ++j)
 			if (isl_seq_eq(bmap->ineq[i], cst->row[j], cst->n_col))
 				break;
 		if (j >= cst->n_row)
-			return 1;
+			return isl_bool_true;
 	}
 
-	return 0;
+	return isl_bool_false;
 }
 
 /* Given that the last set variable of "bset" represents the minimum
@@ -4550,7 +4684,7 @@ static int need_split_basic_map(__isl_ke
  * the position of the minimum is computed from "cst" and not
  * from "bmap".
  */
-static int need_split_basic_set(__isl_keep isl_basic_set *bset,
+static isl_bool need_split_basic_set(__isl_keep isl_basic_set *bset,
 	__isl_keep isl_mat *cst)
 {
 	return need_split_basic_map(bset_to_bmap(bset), cst);
@@ -4560,15 +4694,19 @@ static int need_split_basic_set(__isl_ke
  * of the bounds in "cst", check whether we need to split the domain
  * based on which bound attains the minimum.
  */
-static int need_split_set(__isl_keep isl_set *set, __isl_keep isl_mat *cst)
+static isl_bool need_split_set(__isl_keep isl_set *set, __isl_keep isl_mat *cst)
 {
 	int i;
 
-	for (i = 0; i < set->n; ++i)
-		if (need_split_basic_set(set->p[i], cst))
-			return 1;
+	for (i = 0; i < set->n; ++i) {
+		isl_bool split;
 
-	return 0;
+		split = need_split_basic_set(set->p[i], cst);
+		if (split < 0 || split)
+			return split;
+	}
+
+	return isl_bool_false;
 }
 
 /* Given a set of which the last set variable is the minimum
@@ -4601,10 +4739,14 @@ static __isl_give isl_set *split(__isl_t
 	res = isl_set_empty(dim);
 
 	for (i = 0; i < empty->n; ++i) {
+		isl_bool split;
 		isl_set *set;
 
 		set = isl_set_from_basic_set(isl_basic_set_copy(empty->p[i]));
-		if (need_split_basic_set(empty->p[i], cst))
+		split = need_split_basic_set(empty->p[i], cst);
+		if (split < 0)
+			set = isl_set_free(set);
+		else if (split)
 			set = isl_set_intersect(set, isl_set_copy(min_expr));
 		set = isl_set_remove_dims(set, isl_dim_set, n_in - 1, 1);
 
@@ -4648,9 +4790,13 @@ static __isl_give isl_map *split_domain(
 
 	for (i = 0; i < opt->n; ++i) {
 		isl_map *map;
+		isl_bool split;
 
 		map = isl_map_from_basic_map(isl_basic_map_copy(opt->p[i]));
-		if (need_split_basic_map(opt->p[i], cst))
+		split = need_split_basic_map(opt->p[i], cst);
+		if (split < 0)
+			map = isl_map_free(map);
+		else if (split)
 			map = isl_map_intersect_domain(map,
 						       isl_set_copy(min_expr));
 		map = isl_map_remove_dims(map, isl_dim_in, n_in - 1, 1);
@@ -4754,26 +4900,18 @@ static __isl_give isl_basic_set *extract
 
 struct isl_sol_for {
 	struct isl_sol	sol;
-	int		(*fn)(__isl_take isl_basic_set *dom,
+	isl_stat	(*fn)(__isl_take isl_basic_set *dom,
 				__isl_take isl_aff_list *list, void *user);
 	void		*user;
 };
 
-static void sol_for_free(struct isl_sol_for *sol_for)
+static void sol_for_free(struct isl_sol *sol)
 {
-	if (!sol_for)
-		return;
-	if (sol_for->sol.context)
-		sol_for->sol.context->op->free(sol_for->sol.context);
-	free(sol_for);
-}
-
-static void sol_for_free_wrap(struct isl_sol *sol)
-{
-	sol_for_free((struct isl_sol_for *)sol);
 }
 
 /* Add the solution identified by the tableau and the context tableau.
+ * In particular, "dom" represents the context and "ma" expresses
+ * the solution on that context.
  *
  * See documentation of sol_add for more details.
  *
@@ -4785,30 +4923,23 @@ static void sol_for_free_wrap(struct isl
  * affine expressions in the list is equal to the number of output variables.
  */
 static void sol_for_add(struct isl_sol_for *sol,
-	struct isl_basic_set *dom, struct isl_mat *M)
+	__isl_take isl_basic_set *dom, __isl_take isl_multi_aff *ma)
 {
-	int i;
+	int i, n;
 	isl_ctx *ctx;
-	isl_local_space *ls;
 	isl_aff *aff;
 	isl_aff_list *list;
 
-	if (sol->sol.error || !dom || !M)
+	if (sol->sol.error || !dom || !ma)
 		goto error;
 
 	ctx = isl_basic_set_get_ctx(dom);
-	ls = isl_basic_set_get_local_space(dom);
-	list = isl_aff_list_alloc(ctx, M->n_row - 1);
-	for (i = 1; i < M->n_row; ++i) {
-		aff = isl_aff_alloc(isl_local_space_copy(ls));
-		if (aff) {
-			isl_int_set(aff->v->el[0], M->row[0][0]);
-			isl_seq_cpy(aff->v->el + 1, M->row[i], M->n_col);
-		}
-		aff = isl_aff_normalize(aff);
+	n = isl_multi_aff_dim(ma, isl_dim_out);
+	list = isl_aff_list_alloc(ctx, n);
+	for (i = 0; i < n; ++i) {
+		aff = isl_multi_aff_get_aff(ma, i);
 		list = isl_aff_list_add(list, aff);
 	}
-	isl_local_space_free(ls);
 
 	dom = isl_basic_set_finalize(dom);
 
@@ -4816,23 +4947,23 @@ static void sol_for_add(struct isl_sol_f
 		goto error;
 
 	isl_basic_set_free(dom);
-	isl_mat_free(M);
+	isl_multi_aff_free(ma);
 	return;
 error:
 	isl_basic_set_free(dom);
-	isl_mat_free(M);
+	isl_multi_aff_free(ma);
 	sol->sol.error = 1;
 }
 
 static void sol_for_add_wrap(struct isl_sol *sol,
-	struct isl_basic_set *dom, struct isl_mat *M)
+	__isl_take isl_basic_set *dom, __isl_take isl_multi_aff *ma)
 {
-	sol_for_add((struct isl_sol_for *)sol, dom, M);
+	sol_for_add((struct isl_sol_for *)sol, dom, ma);
 }
 
-static struct isl_sol_for *sol_for_init(struct isl_basic_map *bmap, int max,
-	int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_aff_list *list,
-		  void *user),
+static struct isl_sol_for *sol_for_init(__isl_keep isl_basic_map *bmap, int max,
+	isl_stat (*fn)(__isl_take isl_basic_set *dom,
+		__isl_take isl_aff_list *list, void *user),
 	void *user)
 {
 	struct isl_sol_for *sol_for = NULL;
@@ -4846,26 +4977,19 @@ static struct isl_sol_for *sol_for_init(
 	dom_dim = isl_space_domain(isl_space_copy(bmap->dim));
 	dom = isl_basic_set_universe(dom_dim);
 
-	sol_for->sol.rational = ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL);
-	sol_for->sol.dec_level.callback.run = &sol_dec_level_wrap;
-	sol_for->sol.dec_level.sol = &sol_for->sol;
+	sol_for->sol.free = &sol_for_free;
+	if (sol_init(&sol_for->sol, bmap, dom, max) < 0)
+		goto error;
 	sol_for->fn = fn;
 	sol_for->user = user;
-	sol_for->sol.max = max;
-	sol_for->sol.n_out = isl_basic_map_dim(bmap, isl_dim_out);
 	sol_for->sol.add = &sol_for_add_wrap;
 	sol_for->sol.add_empty = NULL;
-	sol_for->sol.free = &sol_for_free_wrap;
-
-	sol_for->sol.context = isl_context_alloc(dom);
-	if (!sol_for->sol.context)
-		goto error;
 
 	isl_basic_set_free(dom);
 	return sol_for;
 error:
 	isl_basic_set_free(dom);
-	sol_for_free(sol_for);
+	sol_free(&sol_for->sol);
 	return NULL;
 }
 
@@ -4875,9 +4999,9 @@ static void sol_for_find_solutions(struc
 	find_solutions_main(&sol_for->sol, tab);
 }
 
-int isl_basic_map_foreach_lexopt(__isl_keep isl_basic_map *bmap, int max,
-	int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_aff_list *list,
-		  void *user),
+isl_stat isl_basic_map_foreach_lexopt(__isl_keep isl_basic_map *bmap, int max,
+	isl_stat (*fn)(__isl_take isl_basic_set *dom,
+		__isl_take isl_aff_list *list, void *user),
 	void *user)
 {
 	struct isl_sol_for *sol_for = NULL;
@@ -4885,7 +5009,7 @@ int isl_basic_map_foreach_lexopt(__isl_k
 	bmap = isl_basic_map_copy(bmap);
 	bmap = isl_basic_map_detect_equalities(bmap);
 	if (!bmap)
-		return -1;
+		return isl_stat_error;
 
 	sol_for = sol_for_init(bmap, max, fn, user);
 	if (!sol_for)
@@ -4906,16 +5030,16 @@ int isl_basic_map_foreach_lexopt(__isl_k
 
 	sol_free(&sol_for->sol);
 	isl_basic_map_free(bmap);
-	return 0;
+	return isl_stat_ok;
 error:
 	sol_free(&sol_for->sol);
 	isl_basic_map_free(bmap);
-	return -1;
+	return isl_stat_error;
 }
 
-int isl_basic_set_foreach_lexopt(__isl_keep isl_basic_set *bset, int max,
-	int (*fn)(__isl_take isl_basic_set *dom, __isl_take isl_aff_list *list,
-		  void *user),
+isl_stat isl_basic_set_foreach_lexopt(__isl_keep isl_basic_set *bset, int max,
+	isl_stat (*fn)(__isl_take isl_basic_set *dom,
+		__isl_take isl_aff_list *list, void *user),
 	void *user)
 {
 	return isl_basic_map_foreach_lexopt(bset, max, fn, user);
@@ -5330,15 +5454,11 @@ struct isl_sol_pma {
 	isl_set *empty;
 };
 
-static void sol_pma_free(struct isl_sol_pma *sol_pma)
+static void sol_pma_free(struct isl_sol *sol)
 {
-	if (!sol_pma)
-		return;
-	if (sol_pma->sol.context)
-		sol_pma->sol.context->op->free(sol_pma->sol.context);
+	struct isl_sol_pma *sol_pma = (struct isl_sol_pma *) sol;
 	isl_pw_multi_aff_free(sol_pma->pma);
 	isl_set_free(sol_pma->empty);
-	free(sol_pma);
 }
 
 /* This function is called for parts of the context where there is
@@ -5363,99 +5483,16 @@ error:
 	sol->sol.error = 1;
 }
 
-/* Check that the final columns of "M", starting at "first", are zero.
- */
-static isl_stat check_final_columns_are_zero(__isl_keep isl_mat *M,
-	unsigned first)
-{
-	int i;
-	unsigned rows, cols, n;
-
-	if (!M)
-		return isl_stat_error;
-	rows = isl_mat_rows(M);
-	cols = isl_mat_cols(M);
-	n = cols - first;
-	for (i = 0; i < rows; ++i)
-		if (isl_seq_first_non_zero(M->row[i] + first, n) != -1)
-			isl_die(isl_mat_get_ctx(M), isl_error_internal,
-				"final columns should be zero",
-				return isl_stat_error);
-	return isl_stat_ok;
-}
-
-/* Set the affine expressions in "ma" according to the rows in "M", which
- * are defined over the local space "ls".
- * The matrix "M" may have extra (zero) columns beyond the number
- * of variables in "ls".
- */
-static __isl_give isl_multi_aff *set_from_affine_matrix(
-	__isl_take isl_multi_aff *ma, __isl_take isl_local_space *ls,
-	__isl_take isl_mat *M)
-{
-	int i, dim;
-	isl_aff *aff;
-
-	if (!ma || !ls || !M)
-		goto error;
-
-	dim = isl_local_space_dim(ls, isl_dim_all);
-	if (check_final_columns_are_zero(M, 1 + dim) < 0)
-		goto error;
-	for (i = 1; i < M->n_row; ++i) {
-		aff = isl_aff_alloc(isl_local_space_copy(ls));
-		if (aff) {
-			isl_int_set(aff->v->el[0], M->row[0][0]);
-			isl_seq_cpy(aff->v->el + 1, M->row[i], 1 + dim);
-		}
-		aff = isl_aff_normalize(aff);
-		ma = isl_multi_aff_set_aff(ma, i - 1, aff);
-	}
-	isl_local_space_free(ls);
-	isl_mat_free(M);
-
-	return ma;
-error:
-	isl_local_space_free(ls);
-	isl_mat_free(M);
-	isl_multi_aff_free(ma);
-	return NULL;
-}
-
-/* Given a basic set "dom" that represents the context and an affine
- * matrix "M" that maps the dimensions of the context to the
- * output variables, construct an isl_pw_multi_aff with a single
- * cell corresponding to "dom" and affine expressions copied from "M".
- *
- * Note that the description of the initial context may have involved
- * existentially quantified variables, in which case they also appear
- * in "dom".  These need to be removed before creating the affine
- * expression because an affine expression cannot be defined in terms
- * of existentially quantified variables without a known representation.
- * Since newly added integer divisions are inserted before these
- * existentially quantified variables, they are still in the final
- * positions and the corresponding final columns of "M" are zero
- * because align_context_divs adds the existentially quantified
- * variables of the context to the main tableau without any constraints and
- * any equality constraints that are added later on can only serve
- * to eliminate these existentially quantified variables.
+/* Given a basic set "dom" that represents the context and a tuple of
+ * affine expressions "maff" defined over this domain, construct
+ * an isl_pw_multi_aff with a single cell corresponding to "dom" and
+ * the affine expressions in "maff".
  */
 static void sol_pma_add(struct isl_sol_pma *sol,
-	__isl_take isl_basic_set *dom, __isl_take isl_mat *M)
+	__isl_take isl_basic_set *dom, __isl_take isl_multi_aff *maff)
 {
-	isl_local_space *ls;
-	isl_multi_aff *maff;
 	isl_pw_multi_aff *pma;
-	int n_div, n_known;
-
-	n_div = isl_basic_set_dim(dom, isl_dim_div);
-	n_known = n_div - sol->sol.context->n_unknown;
 
-	maff = isl_multi_aff_alloc(isl_pw_multi_aff_get_space(sol->pma));
-	ls = isl_basic_set_get_local_space(dom);
-	ls = isl_local_space_drop_dims(ls, isl_dim_div,
-					n_known, n_div - n_known);
-	maff = set_from_affine_matrix(maff, ls, M);
 	dom = isl_basic_set_simplify(dom);
 	dom = isl_basic_set_finalize(dom);
 	pma = isl_pw_multi_aff_alloc(isl_set_from_basic_set(dom), maff);
@@ -5464,11 +5501,6 @@ static void sol_pma_add(struct isl_sol_p
 		sol->sol.error = 1;
 }
 
-static void sol_pma_free_wrap(struct isl_sol *sol)
-{
-	sol_pma_free((struct isl_sol_pma *)sol);
-}
-
 static void sol_pma_add_empty_wrap(struct isl_sol *sol,
 	__isl_take isl_basic_set *bset)
 {
@@ -5476,9 +5508,9 @@ static void sol_pma_add_empty_wrap(struc
 }
 
 static void sol_pma_add_wrap(struct isl_sol *sol,
-	__isl_take isl_basic_set *dom, __isl_take isl_mat *M)
+	__isl_take isl_basic_set *dom, __isl_take isl_multi_aff *ma)
 {
-	sol_pma_add((struct isl_sol_pma *)sol, dom, M);
+	sol_pma_add((struct isl_sol_pma *)sol, dom, ma);
 }
 
 /* Construct an isl_sol_pma structure for accumulating the solution.
@@ -5492,6 +5524,7 @@ static struct isl_sol *sol_pma_init(__is
 	__isl_take isl_basic_set *dom, int track_empty, int max)
 {
 	struct isl_sol_pma *sol_pma = NULL;
+	isl_space *space;
 
 	if (!bmap)
 		goto error;
@@ -5500,22 +5533,16 @@ static struct isl_sol *sol_pma_init(__is
 	if (!sol_pma)
 		goto error;
 
-	sol_pma->sol.rational = ISL_F_ISSET(bmap, ISL_BASIC_MAP_RATIONAL);
-	sol_pma->sol.dec_level.callback.run = &sol_dec_level_wrap;
-	sol_pma->sol.dec_level.sol = &sol_pma->sol;
-	sol_pma->sol.max = max;
-	sol_pma->sol.n_out = isl_basic_map_dim(bmap, isl_dim_out);
+	sol_pma->sol.free = &sol_pma_free;
+	if (sol_init(&sol_pma->sol, bmap, dom, max) < 0)
+		goto error;
 	sol_pma->sol.add = &sol_pma_add_wrap;
 	sol_pma->sol.add_empty = track_empty ? &sol_pma_add_empty_wrap : NULL;
-	sol_pma->sol.free = &sol_pma_free_wrap;
-	sol_pma->pma = isl_pw_multi_aff_empty(isl_basic_map_get_space(bmap));
+	space = isl_space_copy(sol_pma->sol.space);
+	sol_pma->pma = isl_pw_multi_aff_empty(space);
 	if (!sol_pma->pma)
 		goto error;
 
-	sol_pma->sol.context = isl_context_alloc(dom);
-	if (!sol_pma->sol.context)
-		goto error;
-
 	if (track_empty) {
 		sol_pma->empty = isl_set_alloc_space(isl_basic_set_get_space(dom),
 							1, ISL_SET_DISJOINT);
@@ -5527,7 +5554,7 @@ static struct isl_sol *sol_pma_init(__is
 	return &sol_pma->sol;
 error:
 	isl_basic_set_free(dom);
-	sol_pma_free(sol_pma);
+	sol_free(&sol_pma->sol);
 	return NULL;
 }
 
@@ -5681,9 +5708,15 @@ static __isl_give isl_pw_multi_aff *spli
 		if (need_substitution(opt->p[i].maff))
 			pma = isl_pw_multi_aff_substitute(pma,
 					isl_dim_in, n_in - 1, min_expr_pa);
-		else if (need_split_set(opt->p[i].set, cst))
-			pma = isl_pw_multi_aff_intersect_domain(pma,
+		else {
+			isl_bool split;
+			split = need_split_set(opt->p[i].set, cst);
+			if (split < 0)
+				pma = isl_pw_multi_aff_free(pma);
+			else if (split)
+				pma = isl_pw_multi_aff_intersect_domain(pma,
 						       isl_set_copy(min_expr));
+		}
 		pma = isl_pw_multi_aff_project_out(pma,
 						    isl_dim_in, n_in - 1, 1);
 

Modified: polly/trunk/lib/External/isl/isl_test.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_test.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_test.c (original)
+++ polly/trunk/lib/External/isl/isl_test.c Thu Feb 16 23:11:16 2017
@@ -290,7 +290,7 @@ static int test_read(isl_ctx *ctx)
 static int test_bounded(isl_ctx *ctx)
 {
 	isl_set *set;
-	int bounded;
+	isl_bool bounded;
 
 	set = isl_set_read_from_str(ctx, "[n] -> {[i] : 0 <= i <= n }");
 	bounded = isl_set_is_bounded(set);
@@ -343,16 +343,16 @@ static int test_construction(isl_ctx *ct
 
 	c = isl_constraint_alloc_inequality(isl_local_space_copy(ls));
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 1);
-	isl_constraint_set_coefficient(c, isl_dim_param, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_param, 0, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	c = isl_constraint_alloc_inequality(isl_local_space_copy(ls));
 	isl_int_set_si(v, 1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, -5);
-	isl_constraint_set_constant(c, v);
+	c = isl_constraint_set_constant(c, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	isl_local_space_free(ls);
@@ -685,20 +685,20 @@ static int test_div(isl_ctx *ctx)
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, -1);
-	isl_constraint_set_constant(c, v);
+	c = isl_constraint_set_constant(c, v);
 	isl_int_set_si(v, 1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, 1);
-	isl_constraint_set_constant(c, v);
+	c = isl_constraint_set_constant(c, v);
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 2);
@@ -714,20 +714,20 @@ static int test_div(isl_ctx *ctx)
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, 1);
-	isl_constraint_set_constant(c, v);
+	c = isl_constraint_set_constant(c, v);
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, -1);
-	isl_constraint_set_constant(c, v);
+	c = isl_constraint_set_constant(c, v);
 	isl_int_set_si(v, 1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 2);
@@ -743,20 +743,20 @@ static int test_div(isl_ctx *ctx)
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, 1);
-	isl_constraint_set_constant(c, v);
+	c = isl_constraint_set_constant(c, v);
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, -3);
-	isl_constraint_set_constant(c, v);
+	c = isl_constraint_set_constant(c, v);
 	isl_int_set_si(v, 1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 4);
-	isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 2);
@@ -772,20 +772,20 @@ static int test_div(isl_ctx *ctx)
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, 2);
-	isl_constraint_set_constant(c, v);
+	c = isl_constraint_set_constant(c, v);
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, -1);
-	isl_constraint_set_constant(c, v);
+	c = isl_constraint_set_constant(c, v);
 	isl_int_set_si(v, 1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 6);
-	isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	bset = isl_basic_set_project_out(bset, isl_dim_set, 1, 2);
@@ -801,16 +801,16 @@ static int test_div(isl_ctx *ctx)
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, 1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, -3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	bset = isl_basic_set_project_out(bset, isl_dim_set, 2, 1);
@@ -826,16 +826,16 @@ static int test_div(isl_ctx *ctx)
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 6);
-	isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, 1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, -3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	bset = isl_basic_set_project_out(bset, isl_dim_set, 2, 1);
@@ -860,13 +860,13 @@ static int test_div(isl_ctx *ctx)
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, -3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
 	isl_int_set_si(v, -3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
 	isl_int_set_si(v, 6);
-	isl_constraint_set_coefficient(c, isl_dim_set, 3, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 3, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	bset = isl_basic_set_project_out(bset, isl_dim_set, 3, 1);
@@ -885,22 +885,22 @@ static int test_div(isl_ctx *ctx)
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, -3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
 	isl_int_set_si(v, -3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 3, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 3, v);
 	isl_int_set_si(v, 6);
-	isl_constraint_set_coefficient(c, isl_dim_set, 4, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 4, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
 	isl_int_set_si(v, 1);
-	isl_constraint_set_constant(c, v);
+	c = isl_constraint_set_constant(c, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	bset = isl_basic_set_project_out(bset, isl_dim_set, 4, 1);
@@ -919,20 +919,20 @@ static int test_div(isl_ctx *ctx)
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, 1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
 	isl_int_set_si(v, -2);
-	isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, -1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, 3);
-	isl_constraint_set_coefficient(c, isl_dim_set, 3, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 3, v);
 	isl_int_set_si(v, 2);
-	isl_constraint_set_constant(c, v);
+	c = isl_constraint_set_constant(c, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	bset = isl_basic_set_project_out(bset, isl_dim_set, 2, 2);
@@ -951,9 +951,9 @@ static int test_div(isl_ctx *ctx)
 
 	c = isl_constraint_alloc_equality(isl_local_space_copy(ls));
 	isl_int_set_si(v, 1);
-	isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 0, v);
 	isl_int_set_si(v, -2);
-	isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
+	c = isl_constraint_set_coefficient(c, isl_dim_set, 2, v);
 	bset = isl_basic_set_add_constraint(bset, c);
 
 	bset = isl_basic_set_project_out(bset, isl_dim_set, 2, 1);
@@ -1895,6 +1895,14 @@ struct {
 	{ 1, "[n, m] -> { S_0[i] : (-n + i) mod 3 = 0 and m >= 3 + n and "
 			    "i >= n and 3*floor((2 + n + 2m)/3) <= n + 3m - i; "
 			 "S_0[n] : n <= m <= 2 + n }" },
+	{ 1, "{ [a, b] : exists (e0: 0 <= a <= 1 and b >= 0 and "
+			"2e0 >= -5 + a + 2b and 2e0 >= -1 + a + b and "
+			"2e0 <= a + b); "
+		"[a, b] : exists (e0: 0 <= a <= 1 and 2e0 >= -5 + a + 2b and "
+			"2e0 >= -1 - a + b and 2e0 <= -a + b and "
+			"2e0 < -a + 2b) }" },
+	{ 1, "{ [i, j, i - 8j] : 8 <= i <= 63 and -7 + i <= 8j <= i; "
+		"[i, 0, i] : 0 <= i <= 7 }" },
 };
 
 /* A specialized coalescing test case that would result
@@ -4875,8 +4883,27 @@ static int test_disjoint(isl_ctx *ctx)
 	return 0;
 }
 
+/* Inputs for isl_pw_multi_aff_is_equal tests.
+ * "f1" and "f2" are the two function that need to be compared.
+ * "equal" is the expected result.
+ */
+struct {
+	int equal;
+	const char *f1;
+	const char *f2;
+} pma_equal_tests[] = {
+	{ 1, "[N] -> { [floor(N/2)] : 0 <= N <= 1 }",
+	     "[N] -> { [0] : 0 <= N <= 1 }" },
+	{ 1, "[N] -> { [floor(N/2)] : 0 <= N <= 2 }",
+	     "[N] -> { [0] : 0 <= N <= 1; [1] : N = 2 }" },
+	{ 0, "[N] -> { [floor(N/2)] : 0 <= N <= 2 }",
+	     "[N] -> { [0] : 0 <= N <= 1 }" },
+	{ 0, "{ [NaN] }", "{ [NaN] }" },
+};
+
 int test_equal(isl_ctx *ctx)
 {
+	int i;
 	const char *str;
 	isl_set *set, *set2;
 	int equal;
@@ -4893,13 +4920,29 @@ int test_equal(isl_ctx *ctx)
 	if (equal)
 		isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
 
+	for (i = 0; i < ARRAY_SIZE(pma_equal_tests); ++i) {
+		int expected = pma_equal_tests[i].equal;
+		isl_pw_multi_aff *f1, *f2;
+
+		f1 = isl_pw_multi_aff_read_from_str(ctx, pma_equal_tests[i].f1);
+		f2 = isl_pw_multi_aff_read_from_str(ctx, pma_equal_tests[i].f2);
+		equal = isl_pw_multi_aff_is_equal(f1, f2);
+		isl_pw_multi_aff_free(f1);
+		isl_pw_multi_aff_free(f2);
+		if (equal < 0)
+			return -1;
+		if (equal != expected)
+			isl_die(ctx, isl_error_unknown,
+				"unexpected equality result", return -1);
+	}
+
 	return 0;
 }
 
 static int test_plain_fixed(isl_ctx *ctx, __isl_take isl_map *map,
 	enum isl_dim_type type, unsigned pos, int fixed)
 {
-	int test;
+	isl_bool test;
 
 	test = isl_map_plain_is_fixed(map, type, pos, NULL);
 	isl_map_free(map);
@@ -5340,7 +5383,7 @@ static int test_residue_class(isl_ctx *c
 	const char *str;
 	isl_set *set;
 	isl_int m, r;
-	int res;
+	isl_stat res;
 
 	str = "{ [i,j] : j = 4 i + 1 and 0 <= i <= 100; "
 		"[i,j] : j = 4 i + 3 and 500 <= i <= 600 }";
@@ -5351,7 +5394,7 @@ static int test_residue_class(isl_ctx *c
 	if (res >= 0 &&
 	    (isl_int_cmp_si(m, 2) != 0 || isl_int_cmp_si(r, 1) != 0))
 		isl_die(ctx, isl_error_unknown, "incorrect residue class",
-			res = -1);
+			res = isl_stat_error);
 	isl_int_clear(r);
 	isl_int_clear(m);
 	isl_set_free(set);
@@ -6809,7 +6852,7 @@ const char *chambers_tests[] = {
 
 /* Add the domain of "cell" to "cells".
  */
-static int add_cell(__isl_take isl_cell *cell, void *user)
+static isl_stat add_cell(__isl_take isl_cell *cell, void *user)
 {
 	isl_basic_set_list **cells = user;
 	isl_basic_set *dom;
@@ -6818,7 +6861,7 @@ static int add_cell(__isl_take isl_cell
 	isl_cell_free(cell);
 	*cells = isl_basic_set_list_add(*cells, dom);
 
-	return *cells ? 0 : -1;
+	return *cells ? isl_stat_ok : isl_stat_error;
 }
 
 /* Check that the elements of "list" are pairwise disjoint.

Modified: polly/trunk/lib/External/isl/isl_transitive_closure.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_transitive_closure.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_transitive_closure.c (original)
+++ polly/trunk/lib/External/isl/isl_transitive_closure.c Thu Feb 16 23:11:16 2017
@@ -284,15 +284,15 @@ error:
 /* Check whether the parametric constant term of constraint c is never
  * positive in "bset".
  */
-static int parametric_constant_never_positive(__isl_keep isl_basic_set *bset,
-	isl_int *c, int *div_purity)
+static isl_bool parametric_constant_never_positive(
+	__isl_keep isl_basic_set *bset, isl_int *c, int *div_purity)
 {
 	unsigned d;
 	unsigned n_div;
 	unsigned nparam;
 	int i;
 	int k;
-	int empty;
+	isl_bool empty;
 
 	n_div = isl_basic_set_dim(bset, isl_dim_div);
 	d = isl_basic_set_dim(bset, isl_dim_set);
@@ -319,7 +319,7 @@ static int parametric_constant_never_pos
 	return empty;
 error:
 	isl_basic_set_free(bset);
-	return -1;
+	return isl_bool_error;
 }
 
 /* Return PURE_PARAM if only the coefficients of the parameters are non-zero.
@@ -335,7 +335,7 @@ static int purity(__isl_keep isl_basic_s
 	unsigned d;
 	unsigned n_div;
 	unsigned nparam;
-	int empty;
+	isl_bool empty;
 	int i;
 	int p = 0, v = 0;
 
@@ -777,7 +777,7 @@ static __isl_give isl_map *construct_ext
 		delta = isl_basic_map_deltas(isl_basic_map_copy(map->p[i]));
 
 		for (j = 0; j < d; ++j) {
-			int fixed;
+			isl_bool fixed;
 
 			fixed = isl_basic_set_plain_dim_is_fixed(delta, j,
 							    &steps->row[n][j]);
@@ -822,23 +822,24 @@ error:
 	return NULL;
 }
 
-static int isl_set_overlaps(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
+static isl_bool isl_set_overlaps(__isl_keep isl_set *set1,
+	__isl_keep isl_set *set2)
 {
 	isl_set *i;
-	int no_overlap;
+	isl_bool no_overlap;
 
 	if (!set1 || !set2)
-		return -1;
+		return isl_bool_error;
 
 	if (!isl_space_tuple_is_equal(set1->dim, isl_dim_set,
 					set2->dim, isl_dim_set))
-		return 0;
+		return isl_bool_false;
 
 	i = isl_set_intersect(isl_set_copy(set1), isl_set_copy(set2));
 	no_overlap = isl_set_is_empty(i);
 	isl_set_free(i);
 
-	return no_overlap < 0 ? -1 : !no_overlap;
+	return isl_bool_not(no_overlap);
 }
 
 /* Given a union of basic maps R = \cup_i R_i \subseteq D \times D
@@ -867,7 +868,7 @@ static __isl_give isl_map *construct_com
 	struct isl_set *range = NULL;
 	struct isl_map *app = NULL;
 	struct isl_map *path = NULL;
-	int overlaps;
+	isl_bool overlaps;
 
 	domain = isl_map_domain(isl_map_copy(map));
 	domain = isl_set_coalesce(domain);
@@ -1040,7 +1041,7 @@ static int composability(__isl_keep isl_
 
 	ok = LEFT | RIGHT;
 	for (j = 0; j < map->n && ok; ++j) {
-		int overlaps, subset;
+		isl_bool overlaps, subset;
 		if (j == i)
 			continue;
 
@@ -1440,7 +1441,7 @@ static int merge(isl_set **set, int *gro
 	set[pos] = isl_set_copy(dom);
 
 	for (i = pos - 1; i >= 0; --i) {
-		int o;
+		isl_bool o;
 
 		if (group[i] != i)
 			continue;
@@ -2122,7 +2123,7 @@ __isl_give isl_map *isl_map_reaching_pat
  *
  * with k a constant and e an existentially quantified variable.
  */
-static int is_eq_stride(__isl_keep isl_basic_set *bset, int i)
+static isl_bool is_eq_stride(__isl_keep isl_basic_set *bset, int i)
 {
 	unsigned nparam;
 	unsigned d;
@@ -2131,35 +2132,35 @@ static int is_eq_stride(__isl_keep isl_b
 	int pos2;
 
 	if (!bset)
-		return -1;
+		return isl_bool_error;
 
 	if (!isl_int_is_zero(bset->eq[i][0]))
-		return 0;
+		return isl_bool_false;
 
 	nparam = isl_basic_set_dim(bset, isl_dim_param);
 	d = isl_basic_set_dim(bset, isl_dim_set);
 	n_div = isl_basic_set_dim(bset, isl_dim_div);
 
 	if (isl_seq_first_non_zero(bset->eq[i] + 1, nparam) != -1)
-		return 0;
+		return isl_bool_false;
 	pos1 = isl_seq_first_non_zero(bset->eq[i] + 1 + nparam, d);
 	if (pos1 == -1)
-		return 0;
+		return isl_bool_false;
 	if (isl_seq_first_non_zero(bset->eq[i] + 1 + nparam + pos1 + 1, 
 					d - pos1 - 1) != -1)
-		return 0;
+		return isl_bool_false;
 
 	pos2 = isl_seq_first_non_zero(bset->eq[i] + 1 + nparam + d, n_div);
 	if (pos2 == -1)
-		return 0;
+		return isl_bool_false;
 	if (isl_seq_first_non_zero(bset->eq[i] + 1 + nparam + d  + pos2 + 1,
 				   n_div - pos2 - 1) != -1)
-		return 0;
+		return isl_bool_false;
 	if (!isl_int_is_one(bset->eq[i][1 + nparam + pos1]) &&
 	    !isl_int_is_negone(bset->eq[i][1 + nparam + pos1]))
-		return 0;
+		return isl_bool_false;
 
-	return 1;
+	return isl_bool_true;
 }
 
 /* Given a map, compute the smallest superset of this map that is of the form

Modified: polly/trunk/lib/External/isl/isl_union_map.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_union_map.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_union_map.c (original)
+++ polly/trunk/lib/External/isl/isl_union_map.c Thu Feb 16 23:11:16 2017
@@ -531,25 +531,25 @@ __isl_give isl_set *isl_union_set_extrac
 
 /* Check if umap contains a map in the given space.
  */
-__isl_give int isl_union_map_contains(__isl_keep isl_union_map *umap,
-	__isl_keep isl_space *dim)
+isl_bool isl_union_map_contains(__isl_keep isl_union_map *umap,
+	__isl_keep isl_space *space)
 {
 	uint32_t hash;
 	struct isl_hash_table_entry *entry;
 
-	if (!umap || !dim)
-		return -1;
+	if (!umap || !space)
+		return isl_bool_error;
 
-	hash = isl_space_get_hash(dim);
+	hash = isl_space_get_hash(space);
 	entry = isl_hash_table_find(umap->dim->ctx, &umap->table, hash,
-				    &has_dim, dim, 0);
+				    &has_dim, space, 0);
 	return !!entry;
 }
 
-__isl_give int isl_union_set_contains(__isl_keep isl_union_set *uset,
-	__isl_keep isl_space *dim)
+isl_bool isl_union_set_contains(__isl_keep isl_union_set *uset,
+	__isl_keep isl_space *space)
 {
-	return isl_union_map_contains(uset, dim);
+	return isl_union_map_contains(uset, space);
 }
 
 isl_stat isl_union_set_foreach_set(__isl_keep isl_union_set *uset,

Modified: polly/trunk/lib/External/isl/isl_union_templ.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_union_templ.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_union_templ.c (original)
+++ polly/trunk/lib/External/isl/isl_union_templ.c Thu Feb 16 23:11:16 2017
@@ -1055,6 +1055,39 @@ error:
 	return isl_bool_error;
 }
 
+/* Check whether the element that "entry" points to involves any NaNs and
+ * store the result in *nan.
+ * Abort as soon as one such element has been found.
+ */
+static isl_stat FN(UNION,involves_nan_entry)(void **entry, void *user)
+{
+	isl_bool *nan = user;
+	PW *pw = *entry;
+
+	*nan = FN(PW,involves_nan)(pw);
+	if (*nan < 0 || !nan)
+		return isl_stat_error;
+
+	return isl_stat_ok;
+}
+
+/* Does "u" involve any NaNs?
+ */
+isl_bool FN(UNION,involves_nan)(__isl_keep UNION *u)
+{
+	isl_bool nan = isl_bool_false;
+
+	if (!u)
+		return isl_bool_error;
+
+	if (FN(UNION,foreach_inplace)(u,
+				    &FN(UNION,involves_nan_entry), &nan) < 0 &&
+	    !nan)
+		return isl_bool_error;
+
+	return nan;
+}
+
 /* Internal data structure for isl_union_*_drop_dims.
  * type, first and n are passed to isl_*_drop_dims.
  */

Modified: polly/trunk/lib/External/isl/isl_val.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_val.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_val.c (original)
+++ polly/trunk/lib/External/isl/isl_val.c Thu Feb 16 23:11:16 2017
@@ -1578,32 +1578,33 @@ __isl_give isl_val *isl_val_zero_on_doma
  * This function is only meant to be used in the generic isl_multi_*
  * functions which have to deal with base objects that have an associated
  * space.  Since an isl_val does not have an associated space, this function
- * simply returns 1, except if "v" or "space" are NULL.
+ * simply returns true, except if "v" or "space" are NULL.
  */
-int isl_val_matching_params(__isl_keep isl_val *v, __isl_keep isl_space *space)
+isl_bool isl_val_matching_params(__isl_keep isl_val *v,
+	__isl_keep isl_space *space)
 {
 	if (!v || !space)
-		return -1;
-	return 1;
+		return isl_bool_error;
+	return isl_bool_true;
 }
 
 /* Check that the domain space of "v" matches "space".
  *
- * Return 0 on success and -1 on error.
- *
  * This function is only meant to be used in the generic isl_multi_*
  * functions which have to deal with base objects that have an associated
  * space.  Since an isl_val does not have an associated space, this function
  * simply returns 0, except if "v" or "space" are NULL.
  */
-int isl_val_check_match_domain_space(__isl_keep isl_val *v,
+isl_stat isl_val_check_match_domain_space(__isl_keep isl_val *v,
 	__isl_keep isl_space *space)
 {
 	if (!v || !space)
-		return -1;
-	return 0;
+		return isl_stat_error;
+	return isl_stat_ok;
 }
 
+#define isl_val_involves_nan isl_val_is_nan
+
 #undef BASE
 #define BASE val
 

Modified: polly/trunk/lib/External/isl/isl_val_private.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_val_private.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_val_private.h (original)
+++ polly/trunk/lib/External/isl/isl_val_private.h Thu Feb 16 23:11:16 2017
@@ -62,8 +62,9 @@ __isl_give isl_val *isl_val_mod_val(__is
 
 int isl_val_plain_is_equal(__isl_keep isl_val *val1, __isl_keep isl_val *val2);
 
-int isl_val_matching_params(__isl_keep isl_val *v, __isl_keep isl_space *space);
-int isl_val_check_match_domain_space(__isl_keep isl_val *v,
+isl_bool isl_val_matching_params(__isl_keep isl_val *v,
+	__isl_keep isl_space *space);
+isl_stat isl_val_check_match_domain_space(__isl_keep isl_val *v,
 	__isl_keep isl_space *space);
 
 #undef BASE

Modified: polly/trunk/lib/External/isl/isl_vec.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_vec.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_vec.c (original)
+++ polly/trunk/lib/External/isl/isl_vec.c Thu Feb 16 23:11:16 2017
@@ -94,7 +94,7 @@ __isl_give isl_vec *isl_vec_expand(__isl
 		return NULL;
 	if (expanded < n)
 		isl_die(isl_vec_get_ctx(vec), isl_error_invalid,
-			"not an expansion", isl_vec_free(vec));
+			"not an expansion", return isl_vec_free(vec));
 	if (expanded == n)
 		return vec;
 	if (pos < 0 || n < 0 || pos + n > vec->size)

Modified: polly/trunk/lib/External/isl/isl_vertices.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_vertices.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_vertices.c (original)
+++ polly/trunk/lib/External/isl/isl_vertices.c Thu Feb 16 23:11:16 2017
@@ -530,23 +530,24 @@ static void free_chamber_list(struct isl
 /* Check whether the basic set "bset" is a superset of the basic set described
  * by "tab", i.e., check whether all constraints of "bset" are redundant.
  */
-static int bset_covers_tab(__isl_keep isl_basic_set *bset, struct isl_tab *tab)
+static isl_bool bset_covers_tab(__isl_keep isl_basic_set *bset,
+	struct isl_tab *tab)
 {
 	int i;
 
 	if (!bset || !tab)
-		return -1;
+		return isl_bool_error;
 
 	for (i = 0; i < bset->n_ineq; ++i) {
 		enum isl_ineq_type type = isl_tab_ineq_type(tab, bset->ineq[i]);
 		switch (type) {
-		case isl_ineq_error:		return -1;
+		case isl_ineq_error:		return isl_bool_error;
 		case isl_ineq_redundant:	continue;
-		default:			return 0;
+		default:			return isl_bool_false;
 		}
 	}
 
-	return 1;
+	return isl_bool_true;
 }
 
 static __isl_give isl_vertices *vertices_add_chambers(
@@ -1221,31 +1222,31 @@ static __isl_give isl_vec *isl_basic_set
  * of the first non-zero coefficient is used to determine which
  * of the two (internal) constraints should be tightened.
  */
-int isl_vertices_foreach_disjoint_cell(__isl_keep isl_vertices *vertices,
-	int (*fn)(__isl_take isl_cell *cell, void *user), void *user)
+isl_stat isl_vertices_foreach_disjoint_cell(__isl_keep isl_vertices *vertices,
+	isl_stat (*fn)(__isl_take isl_cell *cell, void *user), void *user)
 {
 	int i;
 	isl_vec *vec;
 	isl_cell *cell;
 
 	if (!vertices)
-		return -1;
+		return isl_stat_error;
 
 	if (vertices->n_chambers == 0)
-		return 0;
+		return isl_stat_ok;
 
 	if (vertices->n_chambers == 1) {
 		isl_basic_set *dom = isl_basic_set_copy(vertices->c[0].dom);
 		dom = isl_basic_set_set_integral(dom);
 		cell = isl_cell_alloc(isl_vertices_copy(vertices), dom, 0);
 		if (!cell)
-			return -1;
+			return isl_stat_error;
 		return fn(cell, user);
 	}
 
 	vec = isl_basic_set_interior_point(vertices->c[0].dom);
 	if (!vec)
-		return -1;
+		return isl_stat_error;
 
 	for (i = 0; i < vertices->n_chambers; ++i) {
 		int r;
@@ -1263,10 +1264,10 @@ int isl_vertices_foreach_disjoint_cell(_
 
 	isl_vec_free(vec);
 
-	return 0;
+	return isl_stat_ok;
 error:
 	isl_vec_free(vec);
-	return -1;
+	return isl_stat_error;
 }
 
 isl_stat isl_vertices_foreach_cell(__isl_keep isl_vertices *vertices,
@@ -1406,9 +1407,9 @@ error:
 /* Construct a simplex isl_cell spanned by the vertices with indices in
  * "simplex_ids" and "other_ids" and call "fn" on this isl_cell.
  */
-static int call_on_simplex(__isl_keep isl_cell *cell,
+static isl_stat call_on_simplex(__isl_keep isl_cell *cell,
 	int *simplex_ids, int n_simplex, int *other_ids, int n_other,
-	int (*fn)(__isl_take isl_cell *simplex, void *user), void *user)
+	isl_stat (*fn)(__isl_take isl_cell *simplex, void *user), void *user)
 {
 	int i;
 	isl_ctx *ctx;
@@ -1418,7 +1419,7 @@ static int call_on_simplex(__isl_keep is
 
 	simplex = isl_calloc_type(ctx, struct isl_cell);
 	if (!simplex)
-		return -1;
+		return isl_stat_error;
 	simplex->vertices = isl_vertices_copy(cell->vertices);
 	if (!simplex->vertices)
 		goto error;
@@ -1438,7 +1439,7 @@ static int call_on_simplex(__isl_keep is
 	return fn(simplex, user);
 error:
 	isl_cell_free(simplex);
-	return -1;
+	return isl_stat_error;
 }
 
 /* Check whether the parametric vertex described by "vertex"
@@ -1481,7 +1482,7 @@ static int vertex_on_facet(__isl_keep is
  * and call ourselves recursively on the polytope spanned by the new
  * "simplex_ids" and those points in "other_ids" that lie on the facet.
  */
-static int triangulate(__isl_keep isl_cell *cell, __isl_keep isl_vec *v,
+static isl_stat triangulate(__isl_keep isl_cell *cell, __isl_keep isl_vec *v,
 	int *simplex_ids, int n_simplex, int *other_ids, int n_other,
 	int (*fn)(__isl_take isl_cell *simplex, void *user), void *user)
 {
@@ -1505,6 +1506,8 @@ static int triangulate(__isl_keep isl_ce
 	bset = cell->vertices->bset;
 
 	ids = isl_alloc_array(ctx, int, n_other - 1);
+	if (!ids)
+		goto error;
 	for (i = 0; i < bset->n_ineq; ++i) {
 		if (isl_seq_first_non_zero(bset->ineq[i] + 1 + nparam, d) == -1)
 			continue;
@@ -1526,17 +1529,17 @@ static int triangulate(__isl_keep isl_ce
 	}
 	free(ids);
 
-	return 0;
+	return isl_stat_ok;
 error:
 	free(ids);
-	return -1;
+	return isl_stat_error;
 }
 
 /* Triangulate the given cell and call "fn" on each of the resulting
  * simplices.
  */
-int isl_cell_foreach_simplex(__isl_take isl_cell *cell,
-	int (*fn)(__isl_take isl_cell *simplex, void *user), void *user)
+isl_stat isl_cell_foreach_simplex(__isl_take isl_cell *cell,
+	isl_stat (*fn)(__isl_take isl_cell *simplex, void *user), void *user)
 {
 	int d, total;
 	int r;
@@ -1545,7 +1548,7 @@ int isl_cell_foreach_simplex(__isl_take
 	int *simplex_ids = NULL;
 
 	if (!cell)
-		return -1;
+		return isl_stat_error;
 
 	d = isl_basic_set_dim(cell->vertices->bset, isl_dim_set);
 	total = isl_basic_set_total_dim(cell->vertices->bset);
@@ -1575,5 +1578,5 @@ error:
 	free(simplex_ids);
 	isl_vec_free(v);
 	isl_cell_free(cell);
-	return -1;
+	return isl_stat_error;
 }

Modified: polly/trunk/lib/External/isl/isl_vertices_private.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_vertices_private.h?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_vertices_private.h (original)
+++ polly/trunk/lib/External/isl/isl_vertices_private.h Thu Feb 16 23:11:16 2017
@@ -1,3 +1,6 @@
+#ifndef ISL_VERTICES_PRIVATE_H
+#define ISL_VERTICES_PRIVATE_H
+
 #include <isl/set.h>
 #include <isl/vertices.h>
 
@@ -53,10 +56,10 @@ struct isl_external_vertex {
 	int id;
 };
 
-int isl_vertices_foreach_disjoint_cell(__isl_keep isl_vertices *vertices,
-	int (*fn)(__isl_take isl_cell *cell, void *user), void *user);
-int isl_cell_foreach_simplex(__isl_take isl_cell *cell,
-	int (*fn)(__isl_take isl_cell *simplex, void *user), void *user);
+isl_stat isl_vertices_foreach_disjoint_cell(__isl_keep isl_vertices *vertices,
+	isl_stat (*fn)(__isl_take isl_cell *cell, void *user), void *user);
+isl_stat isl_cell_foreach_simplex(__isl_take isl_cell *cell,
+	isl_stat (*fn)(__isl_take isl_cell *simplex, void *user), void *user);
 
 __isl_give isl_vertices *isl_morph_vertices(__isl_take struct isl_morph *morph,
 	__isl_take isl_vertices *vertices);
@@ -64,3 +67,5 @@ __isl_give isl_vertices *isl_morph_verti
 #if defined(__cplusplus)
 }
 #endif
+
+#endif

Added: polly/trunk/lib/External/isl/m4/ax_detect_clang.m4
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/m4/ax_detect_clang.m4?rev=295419&view=auto
==============================================================================
--- polly/trunk/lib/External/isl/m4/ax_detect_clang.m4 (added)
+++ polly/trunk/lib/External/isl/m4/ax_detect_clang.m4 Thu Feb 16 23:11:16 2017
@@ -0,0 +1,165 @@
+AC_DEFUN([AX_DETECT_CLANG], [
+AC_SUBST(CLANG_CXXFLAGS)
+AC_SUBST(CLANG_LDFLAGS)
+AC_SUBST(CLANG_LIBS)
+AC_PROG_GREP
+AC_PROG_SED
+llvm_config="llvm-config"
+AC_CHECK_PROG([llvm_config_found], ["$llvm_config"], [yes])
+if test "x$with_clang_prefix" != "x"; then
+	llvm_config="$with_clang_prefix/bin/llvm-config"
+	if test -x "$llvm_config"; then
+		llvm_config_found=yes
+	fi
+fi
+if test "$llvm_config_found" != yes; then
+	AC_MSG_ERROR([llvm-config not found])
+fi
+CLANG_CXXFLAGS=`$llvm_config --cxxflags | \
+	$SED -e 's/-Wcovered-switch-default//'`
+CLANG_LDFLAGS=`$llvm_config --ldflags`
+targets=`$llvm_config --targets-built`
+components="$targets asmparser bitreader support mc"
+$llvm_config --components | $GREP option > /dev/null 2> /dev/null
+if test $? -eq 0; then
+	components="$components option"
+fi
+CLANG_LIBS=`$llvm_config --libs $components`
+systemlibs=`$llvm_config --system-libs 2> /dev/null | tail -1`
+if test $? -eq 0; then
+	CLANG_LIBS="$CLANG_LIBS $systemlibs"
+fi
+CLANG_PREFIX=`$llvm_config --prefix`
+AC_DEFINE_UNQUOTED(CLANG_PREFIX, ["$CLANG_PREFIX"], [Clang installation prefix])
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
+AC_LANG_PUSH(C++)
+AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [],
+	[AC_ERROR([clang header file not found])])
+AC_EGREP_HEADER([getDefaultTargetTriple], [llvm/Support/Host.h], [],
+	[AC_DEFINE([getDefaultTargetTriple], [getHostTriple],
+	[Define to getHostTriple for older versions of clang])])
+AC_EGREP_HEADER([getExpansionLineNumber], [clang/Basic/SourceLocation.h], [],
+	[AC_DEFINE([getExpansionLineNumber], [getInstantiationLineNumber],
+	[Define to getInstantiationLineNumber for older versions of clang])])
+AC_EGREP_HEADER([DiagnosticsEngine], [clang/Basic/Diagnostic.h], [],
+	[AC_DEFINE([DiagnosticsEngine], [Diagnostic],
+	[Define to Diagnostic for older versions of clang])])
+AC_EGREP_HEADER([ArrayRef], [clang/Driver/Driver.h],
+	[AC_DEFINE([USE_ARRAYREF], [],
+		[Define if Driver::BuildCompilation takes ArrayRef])])
+AC_EGREP_HEADER([CXXIsProduction], [clang/Driver/Driver.h],
+	[AC_DEFINE([HAVE_CXXISPRODUCTION], [],
+		[Define if Driver constructor takes CXXIsProduction argument])])
+AC_EGREP_HEADER([ IsProduction], [clang/Driver/Driver.h],
+	[AC_DEFINE([HAVE_ISPRODUCTION], [],
+		[Define if Driver constructor takes IsProduction argument])])
+AC_TRY_COMPILE([#include <clang/Driver/Driver.h>], [
+	using namespace clang;
+	DiagnosticsEngine *Diags;
+	new driver::Driver("", "", "", *Diags);
+], [AC_DEFINE([DRIVER_CTOR_TAKES_DEFAULTIMAGENAME], [],
+	      [Define if Driver constructor takes default image name])])
+AC_EGREP_HEADER([void HandleTopLevelDecl\(], [clang/AST/ASTConsumer.h],
+	[AC_DEFINE([HandleTopLevelDeclReturn], [void],
+		   [Return type of HandleTopLevelDeclReturn])
+	 AC_DEFINE([HandleTopLevelDeclContinue], [],
+		   [Return type of HandleTopLevelDeclReturn])],
+	[AC_DEFINE([HandleTopLevelDeclReturn], [bool],
+		   [Return type of HandleTopLevelDeclReturn])
+	 AC_DEFINE([HandleTopLevelDeclContinue], [true],
+		   [Return type of HandleTopLevelDeclReturn])])
+AC_CHECK_HEADER([clang/Basic/DiagnosticOptions.h],
+	[AC_DEFINE([HAVE_BASIC_DIAGNOSTICOPTIONS_H], [],
+		   [Define if clang/Basic/DiagnosticOptions.h exists])])
+AC_CHECK_HEADER([clang/Lex/PreprocessorOptions.h],
+	[AC_DEFINE([HAVE_LEX_PREPROCESSOROPTIONS_H], [],
+		   [Define if clang/Lex/PreprocessorOptions.h exists])], [],
+	[#include <clang/Basic/LLVM.h>])
+AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
+	using namespace clang;
+	std::shared_ptr<TargetOptions> TO;
+	DiagnosticsEngine *Diags;
+	TargetInfo::CreateTargetInfo(*Diags, TO);
+], [AC_DEFINE([CREATETARGETINFO_TAKES_SHARED_PTR], [],
+	      [Define if TargetInfo::CreateTargetInfo takes shared_ptr])])
+AC_TRY_COMPILE([#include <clang/Basic/TargetInfo.h>], [
+	using namespace clang;
+	TargetOptions *TO;
+	DiagnosticsEngine *Diags;
+	TargetInfo::CreateTargetInfo(*Diags, TO);
+], [AC_DEFINE([CREATETARGETINFO_TAKES_POINTER], [],
+	      [Define if TargetInfo::CreateTargetInfo takes pointer])])
+AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
+	using namespace clang;
+	DiagnosticConsumer *client;
+	CompilerInstance *Clang;
+	Clang->createDiagnostics(client);
+], [], [AC_DEFINE([CREATEDIAGNOSTICS_TAKES_ARG], [],
+	[Define if CompilerInstance::createDiagnostics takes argc and argv])])
+AC_TRY_COMPILE([#include <clang/Lex/HeaderSearchOptions.h>], [
+	using namespace clang;
+	HeaderSearchOptions HSO;
+	HSO.AddPath("", frontend::Angled, false, false);
+], [AC_DEFINE([ADDPATH_TAKES_4_ARGUMENTS], [],
+	[Define if HeaderSearchOptions::AddPath takes 4 arguments])])
+AC_EGREP_HEADER([getNumParams],
+	[clang/AST/CanonicalType.h],
+	[AC_DEFINE([getNumArgs], [getNumParams],
+	    [Define to getNumParams for newer versions of clang])
+	 AC_DEFINE([getArgType], [getParamType],
+	    [Define to getParamType for newer versions of clang])])
+AC_EGREP_HEADER([getReturnType],
+	[clang/AST/CanonicalType.h], [],
+	[AC_DEFINE([getReturnType], [getResultType],
+	    [Define to getResultType for older versions of clang])])
+AC_TRY_COMPILE([#include <clang/Frontend/CompilerInstance.h>], [
+	using namespace clang;
+	CompilerInstance *Clang;
+	Clang->createPreprocessor(TU_Complete);
+], [AC_DEFINE([CREATEPREPROCESSOR_TAKES_TUKIND], [],
+[Define if CompilerInstance::createPreprocessor takes TranslationUnitKind])])
+AC_EGREP_HEADER([setMainFileID], [clang/Basic/SourceManager.h],
+	[AC_DEFINE([HAVE_SETMAINFILEID], [],
+	[Define if SourceManager has a setMainFileID method])])
+AC_CHECK_HEADER([llvm/ADT/OwningPtr.h],
+	[AC_DEFINE([HAVE_ADT_OWNINGPTR_H], [],
+		   [Define if llvm/ADT/OwningPtr.h exists])])
+AC_EGREP_HEADER([initializeBuiltins],
+	[clang/Basic/Builtins.h], [],
+	[AC_DEFINE([initializeBuiltins], [InitializeBuiltins],
+		[Define to InitializeBuiltins for older versions of clang])])
+AC_TRY_COMPILE([
+	#include <clang/Basic/TargetOptions.h>
+	#include <clang/Lex/PreprocessorOptions.h>
+	#include <clang/Frontend/CompilerInstance.h>
+], [
+	using namespace clang;
+	CompilerInstance *Clang;
+	TargetOptions TO;
+	llvm::Triple T(TO.Triple);
+	PreprocessorOptions PO;
+	CompilerInvocation::setLangDefaults(Clang->getLangOpts(), IK_C,
+			T, PO, LangStandard::lang_unspecified);
+], [AC_DEFINE([SETLANGDEFAULTS_TAKES_5_ARGUMENTS], [],
+	[Define if CompilerInvocation::setLangDefaults takes 5 arguments])])
+AC_TRY_COMPILE([
+	#include <clang/Frontend/CompilerInstance.h>
+	#include <clang/Frontend/CompilerInvocation.h>
+], [
+	using namespace clang;
+	CompilerInvocation *invocation;
+	CompilerInstance *Clang;
+	Clang->setInvocation(std::make_shared<CompilerInvocation>(*invocation));
+], [AC_DEFINE([SETINVOCATION_TAKES_SHARED_PTR], [],
+	[Defined if CompilerInstance::setInvocation takes a shared_ptr])])
+AC_LANG_POP
+CPPFLAGS="$SAVE_CPPFLAGS"
+
+SAVE_LDFLAGS="$LDFLAGS"
+LDFLAGS="$CLANG_LDFLAGS $LDFLAGS"
+AC_SUBST(LIB_CLANG_EDIT)
+AC_CHECK_LIB([clangEdit], [main], [LIB_CLANG_EDIT=-lclangEdit], [])
+LDFLAGS="$SAVE_LDFLAGS"
+])

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/cloog/faber.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/cloog/faber.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/cloog/faber.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/cloog/faber.c Thu Feb 16 23:11:16 2017
@@ -71,7 +71,7 @@
     for (int c1 = (c0 + 5) / 14 - 8; c1 < min(0, c0 / 14 - 5); c1 += 1) {
       if (c0 <= 46 && c1 == -3)
         S7(c0, -3, 6);
-      if (-77 * ((-3 * c1 + 1) / 5) + 447 >= 6 * c0)
+      if (77 * c1 + 77 * ((-2 * c1 - 2) / 5) + 524 >= 6 * c0)
         S6(c0, c1, -((-2 * c1 + 3) / 5) + 9);
       for (int c2 = c1 + 24; c2 <= -2 * c1 + 24; c2 += 1)
         S2(c0, c1, c2);

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/cloog/jacobi-shared.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/cloog/jacobi-shared.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/cloog/jacobi-shared.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/cloog/jacobi-shared.c Thu Feb 16 23:11:16 2017
@@ -1,3 +1,3 @@
-if (((t1 + 31) % 32) + g2 >= 2 && N >= ((t1 + 31) % 32) + g2 + 2 && (h0 - 1) % 2 == 0)
+if (((t1 + 31) % 32) + g2 >= 2 && N >= ((t1 + 31) % 32) + g2 + 2 && (h0 + 1) % 2 == 0)
   for (int c0 = max(((t0 + 15) % 16) + 1, ((g1 + t0 + 13) % 16) - g1 + 3); c0 <= min(32, N - g1 - 1); c0 += 16)
     S1(g1 + c0 - 1, -((g2 - t1 + 32) % 32) + g2 + 31);

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/cloog/levenshtein-1-2-3.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/cloog/levenshtein-1-2-3.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/cloog/levenshtein-1-2-3.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/cloog/levenshtein-1-2-3.c Thu Feb 16 23:11:16 2017
@@ -13,7 +13,7 @@
   }
   for (int c0 = N + 2; c0 < 2 * M - N - 1; c0 += 1) {
     S7(c0, -N + (N + c0 + 1) / 2 - 1);
-    if ((N - c0) % 2 == 0) {
+    if ((N + c0) % 2 == 0) {
       S5(c0, (-N + c0) / 2);
       S8(c0, (-N + c0) / 2);
     }
@@ -21,7 +21,7 @@
       S6(c0, c1);
       S8(c0, c1);
     }
-    if ((N - c0) % 2 == 0) {
+    if ((N + c0) % 2 == 0) {
       S4(c0, (N + c0) / 2);
       S8(c0, (N + c0) / 2);
     }

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/cloog/reservoir-cholesky2.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/cloog/reservoir-cholesky2.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/cloog/reservoir-cholesky2.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/cloog/reservoir-cholesky2.c Thu Feb 16 23:11:16 2017
@@ -1,5 +1,5 @@
 for (int c0 = 2; c0 < 3 * M; c0 += 1) {
-  if ((c0 - 2) % 3 == 0)
+  if ((c0 + 1) % 3 == 0)
     S1((c0 + 1) / 3);
   for (int c1 = (c0 + 1) / 3 + 1; c1 <= min(M, c0 - 2); c1 += 1)
     for (int c2 = -c1 + (c0 + c1 + 1) / 2 + 1; c2 <= min(c1, c0 - c1); c2 += 1)

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/cloog/reservoir-pingali1.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/cloog/reservoir-pingali1.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/cloog/reservoir-pingali1.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/cloog/reservoir-pingali1.c Thu Feb 16 23:11:16 2017
@@ -2,6 +2,6 @@ for (int c0 = 1; c0 <= M; c0 += 1)
   for (int c1 = 1; c1 < 2 * N; c1 += 1) {
     for (int c2 = max(1, -N + c1); c2 < (c1 + 1) / 2; c2 += 1)
       S1(c0, c1 - c2, c2);
-    if ((c1 - 1) % 2 == 0)
+    if ((c1 + 1) % 2 == 0)
       S2(c0, (c1 + 1) / 2);
   }

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/cloog/walters.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/cloog/walters.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/cloog/walters.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/cloog/walters.c Thu Feb 16 23:11:16 2017
@@ -4,12 +4,12 @@
   S3(2, 0, 1, 1);
   S4(2, 0, 1, 1);
   for (int c0 = 3; c0 <= 10; c0 += 1) {
-    if (c0 % 3 == 0) {
+    if ((c0 + 1) % 3 == 0) {
+      S3(c0, (c0 - 2) / 3, (c0 + 1) / 3, (c0 + 1) / 3);
+    } else if (c0 % 3 == 0) {
       S1(c0, c0 / 3, c0 / 3, c0 / 3);
-    } else if ((c0 - 1) % 3 == 0) {
-      S2(c0, (c0 - 1) / 3, (c0 + 2) / 3, (c0 - 1) / 3);
     } else {
-      S3(c0, (c0 - 2) / 3, (c0 + 1) / 3, (c0 + 1) / 3);
+      S2(c0, (c0 - 1) / 3, (c0 + 2) / 3, (c0 - 1) / 3);
     }
     S4(c0, c0 / 3, (c0 - 1) / 3 + 1, c0 - (c0 - 1) / 3 - c0 / 3 - 1);
   }

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/isolate5.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/isolate5.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/isolate5.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/isolate5.c Thu Feb 16 23:11:16 2017
@@ -1,29 +1,29 @@
 {
   for (int c0 = 0; c0 <= 9; c0 += 1) {
-    if (c0 % 2 == 0) {
+    if ((c0 + 1) % 2 == 0) {
       for (int c1 = 0; c1 <= 1; c1 += 1)
-        A(c0 / 2, c1);
+        B((c0 - 1) / 2, c1);
     } else {
       for (int c1 = 0; c1 <= 1; c1 += 1)
-        B((c0 - 1) / 2, c1);
+        A(c0 / 2, c1);
     }
   }
   for (int c0 = 10; c0 <= 89; c0 += 1) {
-    if (c0 % 2 == 0) {
+    if ((c0 + 1) % 2 == 0) {
       for (int c1 = 0; c1 <= 1; c1 += 1)
-        A(c0 / 2, c1);
+        B((c0 - 1) / 2, c1);
     } else {
       for (int c1 = 0; c1 <= 1; c1 += 1)
-        B((c0 - 1) / 2, c1);
+        A(c0 / 2, c1);
     }
   }
   for (int c0 = 90; c0 <= 199; c0 += 1) {
-    if (c0 % 2 == 0) {
+    if ((c0 + 1) % 2 == 0) {
       for (int c1 = 0; c1 <= 1; c1 += 1)
-        A(c0 / 2, c1);
+        B((c0 - 1) / 2, c1);
     } else {
       for (int c1 = 0; c1 <= 1; c1 += 1)
-        B((c0 - 1) / 2, c1);
+        A(c0 / 2, c1);
     }
   }
 }

Added: polly/trunk/lib/External/isl/test_inputs/codegen/jacobi_kernel4.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/jacobi_kernel4.c?rev=295419&view=auto
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/jacobi_kernel4.c (added)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/jacobi_kernel4.c Thu Feb 16 23:11:16 2017
@@ -0,0 +1,2 @@
+if (8 * a + 64 * b >= t0 + 2 * t + 512 * floord(-t0 - 8 * a + 64 * b + 2 * t - 1, 512) + 512 && t0 + 512 * floord(-t0 - 8 * a + 64 * b + 2 * t - 1, 512) >= -511 && t0 + 512 * floord(-t0 - 8 * a + 64 * b + 2 * t - 1, 512) <= 1310206)
+  S_0(t, -((-t0 - 8 * a + 64 * b + 2 * t + 511) % 512) - 8 * a + 64 * b + 2 * t + 511);

Added: polly/trunk/lib/External/isl/test_inputs/codegen/jacobi_kernel4.in
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/jacobi_kernel4.in?rev=295419&view=auto
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/jacobi_kernel4.in (added)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/jacobi_kernel4.in Thu Feb 16 23:11:16 2017
@@ -0,0 +1,4 @@
+# Check that an affine value is extracted for the final dimension
+[t0,a,b,t] -> { S_0[t, i] -> [i, t0] : exists (e0 = [(t0 - i)/512]:  512e0 = t0 - i and 64b >= 2t + i - 8a and 64b <= -2t + i + 8a and 4a <= 3 + t and 4a >= t and t >= 0 and t <= 1999 and i >= 1 and i <= 1310718 and a >= 0 and a <= 500 and 8b <= 163839 + a and b <= 20480 and 8b >= 1 - a and b >= 0 and 32b <= 655359 - t + 4a and 32b >= 1 + t - 4a and t0 >= 0 and t0 <= 511) }
+[t0,a,b,t] -> { :  t <= -1 + 4a + 32b and t >= 0 and t <= 4a and t >= -3 + 4a and t <= 1999 and t <= 655359 + 4a - 32b and t0 >= 0 and t0 <= 511 }
+[t0] -> {  }

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/omega/guard1-0.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/omega/guard1-0.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/omega/guard1-0.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/omega/guard1-0.c Thu Feb 16 23:11:16 2017
@@ -1,2 +1,2 @@
-if ((n - m + 2) % 3 == 0)
+if ((n - m - 1) % 3 == 0)
   s0(n, m);

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/omega/guard1-1.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/omega/guard1-1.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/omega/guard1-1.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/omega/guard1-1.c Thu Feb 16 23:11:16 2017
@@ -1,2 +1,2 @@
-if ((n - m + 1) % 2 == 0)
+if ((n + m + 1) % 2 == 0)
   s0(n, m);

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/omega/m7-1.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/omega/m7-1.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/omega/m7-1.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/omega/m7-1.c Thu Feb 16 23:11:16 2017
@@ -1,11 +1,11 @@
 for (int c0 = 1; c0 <= 9; c0 += 1) {
-  if (c0 % 2 == 0) {
+  if ((c0 + 1) % 2 == 0) {
+    for (int c1 = 1; c1 <= 9; c1 += 1)
+      s0(c1, c0);
+  } else {
     for (int c1 = 1; c1 <= 9; c1 += 1) {
       s0(c1, c0);
       s1(c1, c0);
     }
-  } else {
-    for (int c1 = 1; c1 <= 9; c1 += 1)
-      s0(c1, c0);
   }
 }

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/omega/m8-1.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/omega/m8-1.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/omega/m8-1.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/omega/m8-1.c Thu Feb 16 23:11:16 2017
@@ -1,11 +1,11 @@
 for (int c0 = 2; c0 <= 8; c0 += 2) {
-  if (c0 % 4 == 0) {
+  if ((c0 + 2) % 4 == 0) {
+    for (int c1 = 1; c1 <= 9; c1 += 1)
+      s1(c1, c0);
+  } else {
     for (int c1 = 1; c1 <= 9; c1 += 1) {
       s0(c1, c0);
       s1(c1, c0);
     }
-  } else {
-    for (int c1 = 1; c1 <= 9; c1 += 1)
-      s1(c1, c0);
   }
 }

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/omega/p.delft2-0.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/omega/p.delft2-0.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/omega/p.delft2-0.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/omega/p.delft2-0.c Thu Feb 16 23:11:16 2017
@@ -2,9 +2,9 @@ if (P1 >= 0 && P1 <= 3 && P2 >= 0 && P2
   for (int c0 = P1 - 1; c0 <= 3; c0 += 1)
     for (int c2 = 0; c2 <= 7; c2 += 1)
       for (int c3 = 0; c3 <= 7; c3 += 1)
-        if ((5 * P2 + 2 * c3) % 9 <= 3) {
-          if (P1 >= 1 && c0 + 1 == P1 && (5 * P1 + 2 * c2) % 9 <= 2) {
-            s0(P1 - 1, P2, c2, c3, ((5 * P1 + 2 * c2 + 9) % 9) + 1, -4 * P2 + 2 * c3 - 9 * floord(-4 * P2 + 2 * c3, 9));
+        if (4 * P2 >= 2 * c3 + 9 * floord(4 * P2 - 2 * c3 - 1, 9) + 6) {
+          if (P1 >= 1 && c0 + 1 == P1 && 4 * P1 >= 2 * c2 + 9 * floord(4 * P1 - 2 * c2 - 1, 9) + 7) {
+            s0(P1 - 1, P2, c2, c3, ((-4 * P1 + 2 * c2 + 9) % 9) + 1, -4 * P2 + 2 * c3 - 9 * floord(-4 * P2 + 2 * c3, 9));
           } else if (P1 == 0 && c0 == 3 && c2 % 4 == 0) {
             s0(3, P2, c2, c3, (-c2 / 4) + 3, -4 * P2 + 2 * c3 - 9 * floord(-4 * P2 + 2 * c3, 9));
           }

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/redundant.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/redundant.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/redundant.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/redundant.c Thu Feb 16 23:11:16 2017
@@ -5,7 +5,7 @@ for (int c0 = 0; c0 <= 2; c0 += 1)
         for (int c3 = 1; c3 <= 14; c3 += 1)
           write(c0, c1, 8 * b0 + c2 - 5, c3);
     for (int c2 = max(max(3, -8 * b0 + 6), 8 * c0 - 12); c2 <= min(min(7, -8 * b0 + 17), 8 * c0 + 6); c2 += 1)
-      if (4 * c0 + c1 >= 2 * floord(2 * c1 + c2 - 5, 4) + 1 && 2 * ((2 * c1 + c2 - 1) / 4) + 7 >= 4 * c0 + c1 && 2 * c1 + c2 >= 4 * ((2 * c1 + c2 - 1) / 4) + 2 && ((-2 * c1 - c2 + 8) % 4) + 2 * c2 <= 14)
+      if (4 * c0 + c1 + 1 >= 2 * ((2 * c1 + c2 - 1) / 4) && 2 * ((2 * c1 + c2 - 1) / 4) + 7 >= 4 * c0 + c1 && (2 * c1 + c2 - 1) % 4 >= 1 && ((2 * c1 + c2 - 1) % 4) + 11 >= 2 * c2)
         for (int c3 = 1; c3 <= 14; c3 += 1)
           write(c0, c1, 8 * b0 + c2 - 5, c3);
   }

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/sor1d-part.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/sor1d-part.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/sor1d-part.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/sor1d-part.c Thu Feb 16 23:11:16 2017
@@ -1,3 +1,3 @@
-for (int c0 = 1; c0 < max((6 * M + 3 * N + 188) / 200 - 2, (N + 93) / 100 + 3 * ((2 * M + N + 196) / 200) - 4); c0 += 1)
+for (int c0 = 1; c0 < max((6 * M + 3 * N + 188) / 200 - 2, (N + 93) / 100 + 3 * ((2 * M + N - 4) / 200) - 1); c0 += 1)
   for (int c1 = max(0, floord(-N + 100 * c0 + 106, 300)); c1 <= min((2 * M + N - 4) / 200 - 1, (c0 - 1) / 3); c1 += 1)
     S2(c0 - c1, c1);

Modified: polly/trunk/lib/External/isl/test_inputs/codegen/stride5.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/test_inputs/codegen/stride5.c?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/test_inputs/codegen/stride5.c (original)
+++ polly/trunk/lib/External/isl/test_inputs/codegen/stride5.c Thu Feb 16 23:11:16 2017
@@ -1,3 +1,3 @@
 if (n % 2 == 0)
-  for (int c0 = (n / 2) + 2 * floord(-n - 1, 4) + 2; c0 <= 100; c0 += 2)
+  for (int c0 = (-n / 2) + 2 * floord(n - 1, 4) + 2; c0 <= 100; c0 += 2)
     S(c0);

Modified: polly/trunk/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_4.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_4.ll?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_4.ll (original)
+++ polly/trunk/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_4.ll Thu Feb 16 23:11:16 2017
@@ -7,10 +7,11 @@
 ; CHECK:    for (int c1 = 0; c1 < 2 * n; c1 += 1)
 ; CHECK:      #pragma simd reduction
 ; CHECK:      for (int c3 = -1023; c3 <= 1023; c3 += 1) {
-; CHECK:        if (c3 <= 0 && c3 % 2 == 0) {
-; CHECK:          Stmt_for_body3(c1, -c3);
-; CHECK:        } else if (c3 >= 1 && (c3 - 1) % 2 == 0)
+; CHECK:        if (c3 >= 1 && (c3 + 1) % 2 == 0) {
 ; CHECK:          Stmt_for_body3(c1, c3);
+; CHECK:        } else if (c3 <= 0 && c3 % 2 == 0) {
+; CHECK:          Stmt_for_body3(c1, -c3);
+; CHECK:        }
 ; CHECK:      }
 ;
 ;    void rmsmd4(int *A, long n) {

Modified: polly/trunk/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_5.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_5.ll?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_5.ll (original)
+++ polly/trunk/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_5.ll Thu Feb 16 23:11:16 2017
@@ -4,16 +4,17 @@
 ;
 ; CHECK:    #pragma known-parallel reduction
 ; CHECK:    for (int c1 = 0; c1 <= 1023; c1 += 1) {
-; CHECK:      if (c1 % 2 == 0) {
-; CHECK-NOT:    #pragma simd reduction
-; CHECK:        #pragma simd
-; CHECK:        for (int c3 = 0; c3 < 2 * n; c3 += 1)
-; CHECK:          Stmt_for_body3(c3, c1);
-; CHECK:      } else
+; CHECK:      if ((c1 + 1) % 2 == 0) {
 ; CHECK-NOT:    #pragma simd reduction
 ; CHECK:        #pragma simd
 ; CHECK:        for (int c3 = -2 * n + 1; c3 <= 0; c3 += 1)
 ; CHECK:          Stmt_for_body3(-c3, c1);
+; CHECK:      } else {
+; CHECK-NOT:    #pragma simd reduction
+; CHECK:        #pragma simd
+; CHECK:        for (int c3 = 0; c3 < 2 * n; c3 += 1)
+; CHECK:          Stmt_for_body3(c3, c1);
+; CHECK:      }
 ; CHECK:    }
 ;
 ;    void rmsmd5(int *A, long n) {

Modified: polly/trunk/test/Isl/CodeGen/if-conditions-in-vector-code.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/if-conditions-in-vector-code.ll?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/if-conditions-in-vector-code.ll (original)
+++ polly/trunk/test/Isl/CodeGen/if-conditions-in-vector-code.ll Thu Feb 16 23:11:16 2017
@@ -18,7 +18,7 @@ target datalayout = "e-m:e-i64:64-f80:12
 ; AST: #pragma simd
 ; AST: #pragma known-parallel
 ; AST: for (int c0 = 0; c0 <= 15; c0 += 1) {
-; AST:   if ((c0 - 1) % 2 == 0)
+; AST:   if ((c0 + 1) % 2 == 0)
 ; AST:     Stmt_bb4(c0);
 ; AST:   if (c0 % 3 >= 1)
 ; AST:     Stmt_bb11(c0);

Modified: polly/trunk/test/ScopInfo/modulo_zext_1.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/modulo_zext_1.ll?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/modulo_zext_1.ll (original)
+++ polly/trunk/test/ScopInfo/modulo_zext_1.ll Thu Feb 16 23:11:16 2017
@@ -12,9 +12,9 @@
 ; CHECK-NEXT:            Schedule :=
 ; CHECK-NEXT:                [N] -> { Stmt_for_body[i0] -> [i0] };
 ; CHECK-NEXT:            ReadAccess :=	[Reduction Type: +] [Scalar: 0]
-; CHECK-NEXT:                [N] -> { Stmt_for_body[i0] -> MemRef_A[1] : 2*floor((-1 + i0)/2) = -1 + i0; Stmt_for_body[i0] -> MemRef_A[0] : 2*floor((i0)/2) = i0 };
+; CHECK-NEXT:                [N] -> { Stmt_for_body[i0] -> MemRef_A[1] : 2*floor((1 + i0)/2) = 1 + i0; Stmt_for_body[i0] -> MemRef_A[0] : 2*floor((i0)/2) = i0 };
 ; CHECK-NEXT:            MustWriteAccess :=	[Reduction Type: +] [Scalar: 0]
-; CHECK-NEXT:                [N] -> { Stmt_for_body[i0] -> MemRef_A[1] : 2*floor((-1 + i0)/2) = -1 + i0; Stmt_for_body[i0] -> MemRef_A[0] : 2*floor((i0)/2) = i0 };
+; CHECK-NEXT:                [N] -> { Stmt_for_body[i0] -> MemRef_A[1] : 2*floor((1 + i0)/2) = 1 + i0; Stmt_for_body[i0] -> MemRef_A[0] : 2*floor((i0)/2) = i0 };
 ; CHECK-NEXT:    }
 ;
 ;    void f(int *A, int N) {

Modified: polly/trunk/test/ScopInfo/modulo_zext_2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/modulo_zext_2.ll?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/modulo_zext_2.ll (original)
+++ polly/trunk/test/ScopInfo/modulo_zext_2.ll Thu Feb 16 23:11:16 2017
@@ -8,7 +8,7 @@
 ; CHECK:         Statements {
 ; CHECK-NEXT:    	Stmt_if_then
 ; CHECK-NEXT:            Domain :=
-; CHECK-NEXT:                [N] -> { Stmt_if_then[i0] : 2*floor((-1 + i0)/2) = -1 + i0 and 0 < i0 < N };
+; CHECK-NEXT:                [N] -> { Stmt_if_then[i0] : 2*floor((1 + i0)/2) = 1 + i0 and 0 < i0 < N }
 ; CHECK-NEXT:            Schedule :=
 ; CHECK-NEXT:                [N] -> { Stmt_if_then[i0] -> [i0] };
 ; CHECK-NEXT:            ReadAccess :=	[Reduction Type: +] [Scalar: 0]

Modified: polly/trunk/test/ScopInfo/multidim_fortran_srem.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_fortran_srem.ll?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_fortran_srem.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_fortran_srem.ll Thu Feb 16 23:11:16 2017
@@ -23,7 +23,7 @@ target datalayout = "e-p:64:64:64-S128-i
 ; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 1]
 ; CHECK-NEXT:             [tmp180, tmp177, tmp183, tmp162, tmp157, tmp150, tmp146, tmp140, tmp] -> { Stmt_bb203[i0, i1, i2] -> MemRef_tmp194[] };
 ; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
-; CHECK-NEXT:             [tmp180, tmp177, tmp183, tmp162, tmp157, tmp150, tmp146, tmp140, tmp] -> { Stmt_bb203[i0, i1, i2] -> MemRef_tmp173[o0, 1 + i1, 1 + i2] : 3*floor((-2 - i0 + o0)/3) = -2 - i0 + o0 and 0 <= o0 <= 2 };
+; CHECK-NEXT:             [tmp180, tmp177, tmp183, tmp162, tmp157, tmp150, tmp146, tmp140, tmp] -> { Stmt_bb203[i0, i1, i2] -> MemRef_tmp173[o0, 1 + i1, 1 + i2] : 3*floor((1 - i0 + o0)/3) = 1 - i0 + o0 and 0 <= o0 <= 2 };
 ; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
 ; CHECK-NEXT:             [tmp180, tmp177, tmp183, tmp162, tmp157, tmp150, tmp146, tmp140, tmp] -> { Stmt_bb203[i0, i1, i2] -> MemRef_arg56[1 + i0, 1 + i1, 1 + i2] };
 ; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]

Modified: polly/trunk/test/ScopInfo/multidim_srem.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_srem.ll?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_srem.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_srem.ll Thu Feb 16 23:11:16 2017
@@ -14,9 +14,9 @@
 ; CHECK-NEXT:         Schedule :=
 ; CHECK-NEXT:             [n] -> { Stmt_for_body_8[i0, i1, i2] -> [i0, i1, i2] };
 ; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
-; CHECK-NEXT:             [n] -> { Stmt_for_body_8[i0, i1, i2] -> MemRef_A[o0, i1, i2] : 2*floor((-i0 + o0)/2) = -i0 + o0 and 0 <= o0 <= 1 };
+; CHECK-NEXT:             [n] -> { Stmt_for_body_8[i0, i1, i2] -> MemRef_A[o0, i1, i2] : 2*floor((i0 + o0)/2) = i0 + o0 and 0 <= o0 <= 1 };
 ; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
-; CHECK-NEXT:             [n] -> { Stmt_for_body_8[i0, i1, i2] -> MemRef_A[o0, i1, i2] : 2*floor((-i0 + o0)/2) = -i0 + o0 and 0 <= o0 <= 1 };
+; CHECK-NEXT:             [n] -> { Stmt_for_body_8[i0, i1, i2] -> MemRef_A[o0, i1, i2] : 2*floor((i0 + o0)/2) = i0 + o0 and 0 <= o0 <= 1 };
 ; CHECK-NEXT: }
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

Modified: polly/trunk/test/ScopInfo/switch-1.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/switch-1.ll?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/switch-1.ll (original)
+++ polly/trunk/test/ScopInfo/switch-1.ll Thu Feb 16 23:11:16 2017
@@ -30,7 +30,7 @@
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb_1[i0] -> MemRef_A[i0] };
 ; CHECK-NEXT:     Stmt_sw_bb_2
 ; CHECK-NEXT:         Domain :=
-; CHECK-NEXT:             [N] -> { Stmt_sw_bb_2[i0] : 4*floor((-2 + i0)/4) = -2 + i0 and 2 <= i0 < N };
+; CHECK-NEXT:             [N] -> { Stmt_sw_bb_2[i0] : 4*floor((2 + i0)/4) = 2 + i0 and 2 <= i0 < N };
 ; CHECK-NEXT:         Schedule :=
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb_2[i0] -> [i0, 1] };
 ; CHECK-NEXT:         ReadAccess :=    [Reduction Type: +] [Scalar: 0]
@@ -39,7 +39,7 @@
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb_2[i0] -> MemRef_A[i0] };
 ; CHECK-NEXT:     Stmt_sw_bb_6
 ; CHECK-NEXT:         Domain :=
-; CHECK-NEXT:             [N] -> { Stmt_sw_bb_6[i0] : 4*floor((-3 + i0)/4) = -3 + i0 and 3 <= i0 < N };
+; CHECK-NEXT:             [N] -> { Stmt_sw_bb_6[i0] : 4*floor((1 + i0)/4) = 1 + i0 and 3 <= i0 < N };
 ; CHECK-NEXT:         Schedule :=
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb_6[i0] -> [i0, 0] };
 ; CHECK-NEXT:         ReadAccess :=    [Reduction Type: +] [Scalar: 0]

Modified: polly/trunk/test/ScopInfo/switch-2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/switch-2.ll?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/switch-2.ll (original)
+++ polly/trunk/test/ScopInfo/switch-2.ll Thu Feb 16 23:11:16 2017
@@ -29,7 +29,7 @@
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb[i0] -> MemRef_A[i0] };
 ; CHECK-NEXT:     Stmt_sw_bb_2
 ; CHECK-NEXT:         Domain :=
-; CHECK-NEXT:             [N] -> { Stmt_sw_bb_2[i0] : 4*floor((-2 + i0)/4) = -2 + i0 and 2 <= i0 < N };
+; CHECK-NEXT:             [N] -> { Stmt_sw_bb_2[i0] : 4*floor((2 + i0)/4) = 2 + i0 and 2 <= i0 < N };
 ; CHECK-NEXT:         Schedule :=
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb_2[i0] -> [i0, 0] };
 ; CHECK-NEXT:         ReadAccess :=    [Reduction Type: +] [Scalar: 0]

Modified: polly/trunk/test/ScopInfo/switch-3.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/switch-3.ll?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/switch-3.ll (original)
+++ polly/trunk/test/ScopInfo/switch-3.ll Thu Feb 16 23:11:16 2017
@@ -38,7 +38,7 @@
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb_1[i0] -> MemRef_A[i0] };
 ; CHECK-NEXT:     Stmt_sw_bb_5
 ; CHECK-NEXT:         Domain :=
-; CHECK-NEXT:             [N] -> { Stmt_sw_bb_5[i0] : 4*floor((-2 + i0)/4) = -2 + i0 and 2 <= i0 < N };
+; CHECK-NEXT:             [N] -> { Stmt_sw_bb_5[i0] : 4*floor((2 + i0)/4) = 2 + i0 and 2 <= i0 < N };
 ; CHECK-NEXT:         Schedule :=
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb_5[i0] -> [i0, 0] };
 ; CHECK-NEXT:         ReadAccess :=    [Reduction Type: +] [Scalar: 0]
@@ -59,7 +59,7 @@
 ; AST:      if (1)
 ;
 ; AST:          for (int c0 = 0; c0 < N; c0 += 1) {
-; AST-NEXT:       if ((c0 - 2) % 4 == 0)
+; AST-NEXT:       if ((c0 + 2) % 4 == 0)
 ; AST-NEXT:         Stmt_sw_bb_5(c0);
 ; AST-NEXT:       if (c0 % 4 >= 2) {
 ; AST-NEXT:         Stmt_sw_bb_9(c0);

Modified: polly/trunk/test/ScopInfo/switch-4.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/switch-4.ll?rev=295419&r1=295418&r2=295419&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/switch-4.ll (original)
+++ polly/trunk/test/ScopInfo/switch-4.ll Thu Feb 16 23:11:16 2017
@@ -42,7 +42,7 @@
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb_1[i0] -> MemRef_A[i0] };
 ; CHECK-NEXT:     Stmt_sw_bb_5
 ; CHECK-NEXT:         Domain :=
-; CHECK-NEXT:             [N] -> { Stmt_sw_bb_5[i0] : 4*floor((-2 + i0)/4) = -2 + i0 and 2 <= i0 < N };
+; CHECK-NEXT:             [N] -> { Stmt_sw_bb_5[i0] : 4*floor((2 + i0)/4) = 2 + i0 and 2 <= i0 < N };
 ; CHECK-NEXT:         Schedule :=
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb_5[i0] -> [i0, 1] };
 ; CHECK-NEXT:         ReadAccess :=    [Reduction Type: +] [Scalar: 0]
@@ -51,7 +51,7 @@
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb_5[i0] -> MemRef_A[i0] };
 ; CHECK-NEXT:     Stmt_sw_bb_9
 ; CHECK-NEXT:         Domain :=
-; CHECK-NEXT:             [N] -> { Stmt_sw_bb_9[i0] : 4*floor((-3 + i0)/4) = -3 + i0 and 3 <= i0 < N };
+; CHECK-NEXT:             [N] -> { Stmt_sw_bb_9[i0] : 4*floor((1 + i0)/4) = 1 + i0 and 3 <= i0 < N }; 
 ; CHECK-NEXT:         Schedule :=
 ; CHECK-NEXT:             [N] -> { Stmt_sw_bb_9[i0] -> [i0, 0] };
 ; CHECK-NEXT:         ReadAccess :=    [Reduction Type: +] [Scalar: 0]




More information about the llvm-commits mailing list