diff options
author | Tobias Grosser <tobias@grosser.es> | 2017-02-17 05:11:16 +0000 |
---|---|---|
committer | Tobias Grosser <tobias@grosser.es> | 2017-02-17 05:11:16 +0000 |
commit | 72745c2ef5ef258b77a7c2d8b0c6d70dbc36f499 (patch) | |
tree | c3b995618fc0d379bde807bcbea5237a997ece52 | |
parent | e427e4b81b1699de4166d0253ab533cc31a2eb2d (diff) | |
download | bcm5719-llvm-72745c2ef5ef258b77a7c2d8b0c6d70dbc36f499.tar.gz bcm5719-llvm-72745c2ef5ef258b77a7c2d8b0c6d70dbc36f499.zip |
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, ...).
llvm-svn: 295419
101 files changed, 2506 insertions, 1749 deletions
diff --git a/polly/lib/External/isl/GIT_HEAD_ID b/polly/lib/External/isl/GIT_HEAD_ID index 181aa3fe800..7285e93501d 100644 --- a/polly/lib/External/isl/GIT_HEAD_ID +++ b/polly/lib/External/isl/GIT_HEAD_ID @@ -1 +1 @@ -isl-0.18-43-g0b4256f +isl-0.18-254-g6bc184d diff --git a/polly/lib/External/isl/Makefile.in b/polly/lib/External/isl/Makefile.in index 342203d9fd7..94860644a43 100644 --- a/polly/lib/External/isl/Makefile.in +++ b/polly/lib/External/isl/Makefile.in @@ -114,6 +114,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ $(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 \ diff --git a/polly/lib/External/isl/aclocal.m4 b/polly/lib/External/isl/aclocal.m4 index 86521385068..7fc091f8ab1 100644 --- a/polly/lib/External/isl/aclocal.m4 +++ b/polly/lib/External/isl/aclocal.m4 @@ -1156,6 +1156,7 @@ m4_include([m4/ax_check_compiler_flags.m4]) 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]) diff --git a/polly/lib/External/isl/bound.c b/polly/lib/External/isl/bound.c index e0eeaa89caf..00b643d8fa0 100644 --- a/polly/lib/External/isl/bound.c +++ b/polly/lib/External/isl/bound.c @@ -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_point *pnt, void *user) 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 isl_point *pnt, void *user) 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) diff --git a/polly/lib/External/isl/configure b/polly/lib/External/isl/configure index ef333012671..72ce93c89db 100755 --- a/polly/lib/External/isl/configure +++ b/polly/lib/External/isl/configure @@ -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 +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 - 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` +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 getHostTriple" >>confdefs.h 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 getInstantiationLineNumber" >>confdefs. 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 Diagnostic" >>confdefs.h 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 /**/" >>confdefs.h 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 /**/" >>confdefs.h 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 /**/" >>confdefs.h 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_DEFAULTIMAGENAME /**/" >>confdefs.h 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 HandleTopLevelDeclContinue true" >>confdefs.h 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_DIAGNOSTICOPTIONS_H /**/" >>confdefs.h 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_PREPROCESSOROPTIONS_H /**/" >>confdefs.h 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_SHARED_PTR /**/" >>confdefs.h 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_POINTER /**/" >>confdefs.h 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_TAKES_ARG /**/" >>confdefs.h 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_ARGUMENTS /**/" >>confdefs.h 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 getParamType" >>confdefs.h 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 getResultType" >>confdefs.h 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_TAKES_TUKIND /**/" >>confdefs.h 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 /**/" >>confdefs.h 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 /**/" >>confdefs.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 InitializeBuiltins" >>confdefs.h 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_5_ARGUMENTS /**/" >>confdefs.h 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" = xyes; then : LIB_CLANG_EDIT=-lclangEdit fi - LDFLAGS="$SAVE_LDFLAGS" +LDFLAGS="$SAVE_LDFLAGS" + ;; esac if test $with_clang = system; then diff --git a/polly/lib/External/isl/configure.ac b/polly/lib/External/isl/configure.ac index fabcf061983..16018490686 100644 --- a/polly/lib/External/isl/configure.ac +++ b/polly/lib/External/isl/configure.ac @@ -95,168 +95,10 @@ if test "x$ac_cv_have_decl_snprintf" = xno -a \ 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) diff --git a/polly/lib/External/isl/doc/Makefile.in b/polly/lib/External/isl/doc/Makefile.in index 8f04b377302..c02eb18f653 100644 --- a/polly/lib/External/isl/doc/Makefile.in +++ b/polly/lib/External/isl/doc/Makefile.in @@ -95,6 +95,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ $(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 \ diff --git a/polly/lib/External/isl/doc/user.pod b/polly/lib/External/isl/doc/user.pod index 82c4ed90840..5600c384e22 100644 --- a/polly/lib/External/isl/doc/user.pod +++ b/polly/lib/External/isl/doc/user.pod @@ -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 same. 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); diff --git a/polly/lib/External/isl/include/isl/aff.h b/polly/lib/External/isl/include/isl/aff.h index 2d56ed813c8..f9f1ba74bd9 100644 --- a/polly/lib/External/isl/include/isl/aff.h +++ b/polly/lib/External/isl/include/isl/aff.h @@ -188,7 +188,8 @@ int isl_pw_aff_plain_cmp(__isl_keep isl_pw_aff *pa1, __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_multi_aff_set_dim_id( __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_pw_multi_aff( __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_keep isl_union_pw_aff *upa, __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); diff --git a/polly/lib/External/isl/include/isl/constraint.h b/polly/lib/External/isl/include/isl/constraint.h index a7ffa329137..a12ba13f891 100644 --- a/polly/lib/External/isl/include/isl/constraint.h +++ b/polly/lib/External/isl/include/isl/constraint.h @@ -68,13 +68,13 @@ __isl_give isl_map *isl_map_add_constraint(__isl_take isl_map *map, __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); diff --git a/polly/lib/External/isl/include/isl/deprecated/aff_int.h b/polly/lib/External/isl/include/isl/deprecated/aff_int.h index cbab1f98717..a0673747187 100644 --- a/polly/lib/External/isl/include/isl/deprecated/aff_int.h +++ b/polly/lib/External/isl/include/isl/deprecated/aff_int.h @@ -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); diff --git a/polly/lib/External/isl/include/isl/deprecated/map_int.h b/polly/lib/External/isl/include/isl/deprecated/map_int.h index e9f770191fb..c120c40e81a 100644 --- a/polly/lib/External/isl/include/isl/deprecated/map_int.h +++ b/polly/lib/External/isl/include/isl/deprecated/map_int.h @@ -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); diff --git a/polly/lib/External/isl/include/isl/deprecated/set_int.h b/polly/lib/External/isl/include/isl/deprecated/set_int.h index 84bb88ae3d4..6f9ed068eb4 100644 --- a/polly/lib/External/isl/include/isl/deprecated/set_int.h +++ b/polly/lib/External/isl/include/isl/deprecated/set_int.h @@ -17,7 +17,7 @@ __isl_give isl_set *isl_set_upper_bound(__isl_take isl_set *set, __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) diff --git a/polly/lib/External/isl/include/isl/map.h b/polly/lib/External/isl/include/isl/map.h index 9082a371d97..a8a86e3d814 100644 --- a/polly/lib/External/isl/include/isl/map.h +++ b/polly/lib/External/isl/include/isl/map.h @@ -115,7 +115,7 @@ int isl_map_find_dim_by_id(__isl_keep isl_map *map, enum isl_dim_type type, 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_get_val_if_fixed( __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); diff --git a/polly/lib/External/isl/include/isl/mat.h b/polly/lib/External/isl/include/isl/mat.h index 7a43ccbaf64..4a8a6a21482 100644 --- a/polly/lib/External/isl/include/isl/mat.h +++ b/polly/lib/External/isl/include/isl/mat.h @@ -97,7 +97,7 @@ __isl_give isl_mat *isl_mat_concat(__isl_take isl_mat *top, __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); diff --git a/polly/lib/External/isl/include/isl/multi.h b/polly/lib/External/isl/include/isl/multi.h index 612bafce3c9..ad8a3e95773 100644 --- a/polly/lib/External/isl/include/isl/multi.h +++ b/polly/lib/External/isl/include/isl/multi.h @@ -32,6 +32,8 @@ __isl_null isl_multi_##BASE *isl_multi_##BASE##_free( \ 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); \ diff --git a/polly/lib/External/isl/include/isl/polynomial.h b/polly/lib/External/isl/include/isl/polynomial.h index 1f7fe878301..4ad7c4c571e 100644 --- a/polly/lib/External/isl/include/isl/polynomial.h +++ b/polly/lib/External/isl/include/isl/polynomial.h @@ -87,9 +87,9 @@ __isl_give isl_qpolynomial *isl_qpolynomial_substitute( 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_qpolynomial *qp); 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_keep isl_pw_qpolynomial *pwqp, 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_keep isl_qpolynomial_fold *fold); 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_pw_qpolynomial_fold_reset_space( __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_ctx( 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_get_ctx( 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); diff --git a/polly/lib/External/isl/include/isl/set.h b/polly/lib/External/isl/include/isl/set.h index c4c9d45c23b..57b8335dd77 100644 --- a/polly/lib/External/isl/include/isl/set.h +++ b/polly/lib/External/isl/include/isl/set.h @@ -218,7 +218,7 @@ __isl_give isl_basic_set *isl_basic_set_from_params( __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_keep isl_basic_set *bset); 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_keep isl_set *set); 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(struct isl_set *set, __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); diff --git a/polly/lib/External/isl/include/isl/union_map.h b/polly/lib/External/isl/include/isl/union_map.h index cdb89eec3e7..40dea4f8982 100644 --- a/polly/lib/External/isl/include/isl/union_map.h +++ b/polly/lib/External/isl/include/isl/union_map.h @@ -224,8 +224,8 @@ int isl_union_map_n_map(__isl_keep isl_union_map *umap); __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); diff --git a/polly/lib/External/isl/include/isl/union_set.h b/polly/lib/External/isl/include/isl/union_set.h index b0694799811..26858a40020 100644 --- a/polly/lib/External/isl/include/isl/union_set.h +++ b/polly/lib/External/isl/include/isl/union_set.h @@ -114,8 +114,8 @@ int isl_union_set_n_set(__isl_keep isl_union_set *uset); __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); diff --git a/polly/lib/External/isl/isl_aff.c b/polly/lib/External/isl/isl_aff.c index 158033a254e..bb1696bdb26 100644 --- a/polly/lib/External/isl/isl_aff.c +++ b/polly/lib/External/isl/isl_aff.c @@ -401,7 +401,7 @@ __isl_give isl_aff *isl_aff_reset_space_and_domain(__isl_take isl_aff *aff, } /* 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_aff *aff) 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_keep isl_aff *aff1, * * 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(__isl_take isl_aff *aff) * 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_aff(__isl_take isl_aff *aff) 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(__isl_take isl_pw_aff *pwaff, 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_list_set_rational( /* 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 isl_aff *aff, } /* 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(__isl_keep isl_aff *aff, 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_multi_aff_from_map_div( 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_multi_aff_from_map_div( 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_multi_aff_from_map_stride( 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_multi_aff_from_map_stride( 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_keep isl_pw_aff *pa, } /* 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_keep isl_pw_aff *pa, 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_pw_aff_from_pw_multi_aff( * 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_pw_aff *pa1, __isl_keep isl_pw_aff *pa2) 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_keep isl_multi_pw_aff *mpa1, 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_multi_aff( /* 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_multi_aff( * 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_domain_space( "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_union_pw_aff_reset_domain_space( __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) diff --git a/polly/lib/External/isl/isl_aff_private.h b/polly/lib/External/isl/isl_aff_private.h index fc6555ffbd9..8cd95dde842 100644 --- a/polly/lib/External/isl/isl_aff_private.h +++ b/polly/lib/External/isl/isl_aff_private.h @@ -107,9 +107,9 @@ __isl_give isl_pw_aff *isl_pw_aff_scale(__isl_take isl_pw_aff *pwaff, __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_multi_aff_substitute( __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 diff --git a/polly/lib/External/isl/isl_ast_build.c b/polly/lib/External/isl/isl_ast_build.c index bc208e19cc2..65ab6d51c3f 100644 --- a/polly/lib/External/isl/isl_ast_build.c +++ b/polly/lib/External/isl/isl_ast_build.c @@ -842,7 +842,7 @@ __isl_give isl_ast_build *isl_ast_build_set_loop_bounds( 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_set_loop_bounds( if (!build) goto error; } + isl_basic_set_free(bounds); if (!build->domain || !build->pending || !build->generated) return isl_ast_build_free(build); diff --git a/polly/lib/External/isl/isl_bernstein.c b/polly/lib/External/isl/isl_bernstein.c index a34a0d5f947..3036e8fd300 100644 --- a/polly/lib/External/isl/isl_bernstein.c +++ b/polly/lib/External/isl/isl_bernstein.c @@ -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(__isl_take isl_cell *cell, void *user) 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_fold *bernstein_coefficients_base( 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_bernstein(__isl_take isl_basic_set *bset, 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; } diff --git a/polly/lib/External/isl/isl_bernstein.h b/polly/lib/External/isl/isl_bernstein.h index 7694b04e566..ca11df4bf0f 100644 --- a/polly/lib/External/isl/isl_bernstein.h +++ b/polly/lib/External/isl/isl_bernstein.h @@ -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); diff --git a/polly/lib/External/isl/isl_bound.c b/polly/lib/External/isl/isl_bound.c index 0774d9af4c5..d4177f4a13c 100644 --- a/polly/lib/External/isl/isl_bound.c +++ b/polly/lib/External/isl/isl_bound.c @@ -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_take isl_basic_set *bset, 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(__isl_take isl_basic_set *bset, 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_basic_set *bset, 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); diff --git a/polly/lib/External/isl/isl_coalesce.c b/polly/lib/External/isl/isl_coalesce.c index cd85cf1d8b4..4b47facaf52 100644 --- a/polly/lib/External/isl/isl_coalesce.c +++ b/polly/lib/External/isl/isl_coalesce.c @@ -80,9 +80,6 @@ static int *eq_status_in(__isl_keep isl_basic_map *bmap_i, 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 i, int j, * (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_info *info, struct isl_tab *tab) 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_info *info, struct isl_tab *tab) 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_extension(int i, int j, 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_keep isl_mat *T, int row) * "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_basic_map *bmap, int ineq, int *affected, 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_tightening(struct isl_coalesce_info *info, 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(struct isl_coalesce_info *info, 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_extension(int i, int j, int n, int *relax, 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_wraps *wraps, } 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_wraps *wraps, * 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, __isl_take isl_mat *mat, 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 *wraps, int w, isl_int *bound, * 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 *wraps, struct isl_coalesce_info *info, 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 *wraps, struct isl_coalesce_info *info, 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 *wraps, struct isl_coalesce_info *info, } 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_updated_bmap(__isl_keep isl_basic_map *bmap, * 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 isl_wraps *wraps, 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(int i, int j, int k, 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(int i, int j, int n, 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(int i, int j, 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_coalesce_info *info) 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_pair_reuse(int i, int j, { 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_pair_reuse(int i, int j, 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(struct isl_coalesce_info *info1, 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_hulls(struct isl_coalesce_info *info1, * * 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 isl_coalesce_info *info1, 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 isl_coalesce_info *info1, * 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 i, int j, /* 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_basic_map *bmap) 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_coalesce_info *info, 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_coalesce_info *info, 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(int i, int j, 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) diff --git a/polly/lib/External/isl/isl_config.h.in b/polly/lib/External/isl/isl_config.h.in index 46d9dfa3ffd..e9d1eac8d79 100644 --- a/polly/lib/External/isl/isl_config.h.in +++ b/polly/lib/External/isl/isl_config.h.in @@ -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 diff --git a/polly/lib/External/isl/isl_constraint.c b/polly/lib/External/isl/isl_constraint.c index 3d4391a7938..eca62521d9f 100644 --- a/polly/lib/External/isl/isl_constraint.c +++ b/polly/lib/External/isl/isl_constraint.c @@ -773,9 +773,11 @@ int isl_constraint_is_div_constraint(__isl_keep isl_constraint *constraint) 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_inequalities( 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_inequalities( *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" diff --git a/polly/lib/External/isl/isl_convex_hull.c b/polly/lib/External/isl/isl_convex_hull.c index 2be7187b93e..c85cee4067c 100644 --- a/polly/lib/External/isl/isl_convex_hull.c +++ b/polly/lib/External/isl/isl_convex_hull.c @@ -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 isl_basic_set *bset) /* 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_keep isl_basic_map *bmap) /* 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_hull_wrap(struct isl_set *set) */ 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_hull(struct isl_set *set) 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_simple_hull(struct isl_set *set) return hull; error: isl_set_free(set); + isl_basic_set_free(hull); return NULL; } diff --git a/polly/lib/External/isl/isl_equalities.c b/polly/lib/External/isl/isl_equalities.c index 07b053e94f6..80c1ff7c9ca 100644 --- a/polly/lib/External/isl/isl_equalities.c +++ b/polly/lib/External/isl/isl_equalities.c @@ -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(struct isl_basic_set *bset, 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(struct isl_basic_set *bset, 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(struct isl_basic_set *bset, 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_set *set, 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_set *set, 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 diff --git a/polly/lib/External/isl/isl_factorization.h b/polly/lib/External/isl/isl_factorization.h index 4687b9cfd97..4d769d94275 100644 --- a/polly/lib/External/isl/isl_factorization.h +++ b/polly/lib/External/isl/isl_factorization.h @@ -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_factorizer *f); #if defined(__cplusplus) } #endif + +#endif diff --git a/polly/lib/External/isl/isl_farkas.c b/polly/lib/External/isl/isl_farkas.c index dddb49a76c2..eff8608b280 100644 --- a/polly/lib/External/isl/isl_farkas.c +++ b/polly/lib/External/isl/isl_farkas.c @@ -281,8 +281,8 @@ static __isl_give isl_basic_set *farkas(__isl_take isl_space *space, } 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; diff --git a/polly/lib/External/isl/isl_fold.c b/polly/lib/External/isl/isl_fold.c index e05ee101737..f0f92825cc1 100644 --- a/polly/lib/External/isl/isl_fold.c +++ b/polly/lib/External/isl/isl_fold.c @@ -652,6 +652,8 @@ __isl_give isl_qpolynomial_fold *isl_qpolynomial_fold_gist_params( 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_map_apply_pw_qpolynomial_fold( 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_map_apply_pw_qpolynomial_fold( 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_apply( 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_apply( 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); diff --git a/polly/lib/External/isl/isl_ilp.c b/polly/lib/External/isl/isl_ilp.c index cb97d27b63c..4ada75389e9 100644 --- a/polly/lib/External/isl/isl_ilp.c +++ b/polly/lib/External/isl/isl_ilp.c @@ -315,7 +315,8 @@ enum isl_lp_result isl_basic_set_solve_ilp(struct isl_basic_set *bset, int max, 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_ilp(struct isl_basic_set *bset, int max, } 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, diff --git a/polly/lib/External/isl/isl_input.c b/polly/lib/External/isl/isl_input.c index 8a4487082e7..ef702d76170 100644 --- a/polly/lib/External/isl/isl_input.c +++ b/polly/lib/External/isl/isl_input.c @@ -412,7 +412,7 @@ static __isl_give isl_pw_aff *accept_div(__isl_keep isl_stream *s, 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_from_str(isl_ctx *ctx, const char *str) 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_read_from_str(isl_ctx *ctx, * 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_read_multi_pw_aff( 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_read_multi_pw_aff( 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); diff --git a/polly/lib/External/isl/isl_local_space.c b/polly/lib/External/isl/isl_local_space.c index daefc91703e..58ce8475525 100644 --- a/polly/lib/External/isl/isl_local_space.c +++ b/polly/lib/External/isl/isl_local_space.c @@ -729,8 +729,8 @@ __isl_give isl_local_space *isl_local_space_intersect( 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_space_intersect( 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_space_substitute( 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_space_insert_dims( * 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_keep isl_local_space *ls, 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; } /* diff --git a/polly/lib/External/isl/isl_local_space_private.h b/polly/lib/External/isl/isl_local_space_private.h index 427c4a4db3b..a1bdb1b4d69 100644 --- a/polly/lib/External/isl/isl_local_space_private.h +++ b/polly/lib/External/isl/isl_local_space_private.h @@ -41,7 +41,7 @@ isl_bool isl_local_space_divs_known(__isl_keep isl_local_space *ls); __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_space_reset_space( __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); diff --git a/polly/lib/External/isl/isl_map.c b/polly/lib/External/isl/isl_map.c index 2f1c906a176..f8948e9f776 100644 --- a/polly/lib/External/isl/isl_map.c +++ b/polly/lib/External/isl/isl_map.c @@ -202,11 +202,12 @@ unsigned isl_map_n_param(const struct isl_map *map) 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(__isl_keep isl_basic_map *bmap, 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 isl_map *map, __isl_keep isl_set *set) 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(__isl_take isl_set *set) 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 isl_map *map) 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 isl_basic_set *bset) * 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_keep isl_basic_map *bmap) 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_keep isl_basic_map *bmap) /* 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 isl_set *set) * 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_insert_div( 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_to_empty(struct isl_basic_map *bmap) 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_remove_dims(struct isl_basic_map *bmap, /* 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_remove_divs_involving_dims( 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_intersect_range( 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_keep isl_basic_map *bmap, 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_insert_dims( __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_insert_dims( 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_from_basic_set( * * 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(__isl_keep isl_basic_map *bmap, 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(__isl_keep isl_basic_map *bmap, 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_take isl_set *set, */ __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_domain(struct isl_basic_map *bmap) 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 isl_basic_map *bmap) * 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_domain_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_range_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_map *map) * 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_lexmin_compute_divs( * 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_basic_set *dom, 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_dim_opt(__isl_keep isl_basic_map *bmap, { 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_set(__isl_take isl_map *map, 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_range(__isl_take isl_map *map, 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 isl_set *set, int *signs, int first, 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_set *set) 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_map_list_align_divs_to_basic_map( 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_set *set1, 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_var(__isl_keep isl_basic_map *bmap, 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(__isl_keep isl_map *map, 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(__isl_keep isl_set *set, unsigned pos, 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_get_val_if_fixed( { 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_get_val_if_fixed( 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_val_if_fixed(__isl_keep isl_map *map, { 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_val_if_fixed(__isl_keep isl_set *set, 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 isl_set *set, /* 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(__isl_keep isl_basic_map *bmap, 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_bound(__isl_keep isl_basic_map *bmap, 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(__isl_keep isl_set *set, * -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_keep isl_basic_set *bset, 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_keep isl_basic_set *bset, 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_keep isl_basic_set *bset, * 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(__isl_keep isl_basic_map *bmap, 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 pos, unsigned len) 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_basic_set *bset) 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_basic_set *bset) 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_range_multi_aff( "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_preimage_multi_aff( 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_preimage_range_multi_aff( /* 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") diff --git a/polly/lib/External/isl/isl_map_private.h b/polly/lib/External/isl/isl_map_private.h index db39f43fc28..d672cc4e16e 100644 --- a/polly/lib/External/isl/isl_map_private.h +++ b/polly/lib/External/isl/isl_map_private.h @@ -186,13 +186,14 @@ unsigned isl_basic_map_offset(struct isl_basic_map *bmap, 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_basic_map *bmap); __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_take isl_map *map); 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_keep isl_basic_map *bmap, 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_and_test(__isl_keep isl_map *map1, __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_take isl_set *set, __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_plain_affine_hull( __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_fix(__isl_take isl_basic_map *bmap, 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, diff --git a/polly/lib/External/isl/isl_map_simplify.c b/polly/lib/External/isl/isl_map_simplify.c index d47b59e5cc2..b238aa5e837 100644 --- a/polly/lib/External/isl/isl_map_simplify.c +++ b/polly/lib/External/isl/isl_map_simplify.c @@ -200,7 +200,8 @@ struct isl_basic_map *isl_basic_map_drop(struct isl_basic_map *bmap, 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_drop_div( 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_normalize_constraints( 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_var_from_div( 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_independent_vars_from_div( 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_independent_vars_from_divs( 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 *eliminate_div(__isl_take isl_basic_map *bmap, /* 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 isl_basic_map *bmap, isl_int *eq, 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_divs_eq( 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_divs_ineq( 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_gauss( 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_divs( 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_from_lower_bound( * 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(struct isl_basic_map *bmap, 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(struct isl_basic_map *bmap, 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(struct isl_basic_map *bmap, * (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_keep isl_basic_map *bmap, 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_div_constraints( 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_simplify(struct isl_basic_map *bmap) 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_simplify(struct isl_basic_set *bset) } -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(__isl_keep isl_basic_map *bmap, 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(__isl_keep isl_basic_set *bset, * * 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_redundant_divs(struct isl_basic_map *bmap) 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_gist_full(__isl_take isl_basic_set *bset, 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_gist_full(__isl_take isl_basic_set *bset, 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_drop_more_redundant_divs( } } - 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 isl_basic_map *bmap, int i, int j, /* 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_redundant_divs_again( * 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_basic_map_drop_redundant_divs_ineq( 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_basic_map_drop_redundant_divs_ineq( 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_basic_map_drop_redundant_divs_ineq( 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); } diff --git a/polly/lib/External/isl/isl_map_subtract.c b/polly/lib/External/isl/isl_map_subtract.c index 8eb27380255..df16ea9e303 100644 --- a/polly/lib/External/isl/isl_map_subtract.c +++ b/polly/lib/External/isl/isl_map_subtract.c @@ -46,7 +46,7 @@ static void expand_constraint(isl_vec *v, unsigned dim, /* 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 isl_tab *tab, 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 isl_tab *tab, } 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_tab *tab, 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_tab *tab, 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 *tab, __isl_keep isl_basic_map *bmap, 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 *tab, __isl_keep isl_basic_map *bmap, 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, struct isl_tab *tab, * 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 isl_diff_collector *dc, 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 isl_set *set1, struct isl_set *set2) 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_domain(__isl_take isl_map *map, 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 isl_diff_collector *dc, 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_keep isl_map *map1, 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_map *map1, __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 isl_map *map1, 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; diff --git a/polly/lib/External/isl/isl_mat.c b/polly/lib/External/isl/isl_mat.c index f8bbe179733..ec514bdd2fa 100644 --- a/polly/lib/External/isl/isl_mat.c +++ b/polly/lib/External/isl/isl_mat.c @@ -799,11 +799,15 @@ static int row_abs_min_non_zero(isl_int **row, unsigned n_row, unsigned col) 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(struct isl_mat *left, } 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(struct isl_mat *left, 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) diff --git a/polly/lib/External/isl/isl_multi_templ.c b/polly/lib/External/isl/isl_multi_templ.c index f8924dd80ff..166a3390a5e 100644 --- a/polly/lib/External/isl/isl_multi_templ.c +++ b/polly/lib/External/isl/isl_multi_templ.c @@ -291,7 +291,7 @@ __isl_give MULTI(BASE) *FN(FN(MULTI(BASE),set),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)(__isl_keep MULTI(BASE) *multi1, 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". */ diff --git a/polly/lib/External/isl/isl_output.c b/polly/lib/External/isl/isl_output.c index a5fb45990c7..90be2930054 100644 --- a/polly/lib/External/isl/isl_output.c +++ b/polly/lib/External/isl/isl_output.c @@ -464,10 +464,15 @@ static int next_is_opposite(__isl_keep isl_basic_map *bmap, int i, int last) 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_constraints(__isl_keep isl_basic_map *bmap, 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_constraint_c(__isl_take isl_printer *p, 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, " && "); diff --git a/polly/lib/External/isl/isl_point.c b/polly/lib/External/isl/isl_point.c index 73c34006e51..c25b76fba67 100644 --- a/polly/lib/External/isl/isl_point.c +++ b/polly/lib/External/isl/isl_point.c @@ -392,18 +392,19 @@ isl_bool isl_basic_map_contains_point(__isl_keep isl_basic_map *bmap, 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 isl_map *map, __isl_keep isl_point *point) 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_from_point(__isl_take isl_point *pnt) __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_print_point( 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_print_point( } 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) { diff --git a/polly/lib/External/isl/isl_polynomial.c b/polly/lib/External/isl/isl_polynomial.c index 6bf19b51c12..65f555cfdc2 100644 --- a/polly/lib/External/isl/isl_polynomial.c +++ b/polly/lib/External/isl/isl_polynomial.c @@ -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_qpolynomial_add(__isl_take isl_qpolynomial *qp1, 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_qpolynomial_mul(__isl_take isl_qpolynomial *qp1, 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_qpolynomial_from_qpolynomial( 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_domain(__isl_keep isl_qpolynomial *qp, 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_domain(__isl_keep isl_qpolynomial *qp, 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_set_multiplicative_call( __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(__isl_take isl_set *orthant, int *signs, 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, diff --git a/polly/lib/External/isl/isl_pw_templ.c b/polly/lib/External/isl/isl_pw_templ.c index a9b4404ce72..63636a9e256 100644 --- a/polly/lib/External/isl/isl_pw_templ.c +++ b/polly/lib/External/isl/isl_pw_templ.c @@ -1593,10 +1593,10 @@ __isl_give PW *FN(PW,reset_user)(__isl_take PW *pw) 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 PW *pw, } #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)(__isl_keep PW *pw, 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_take PW *pw) /* 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, diff --git a/polly/lib/External/isl/isl_range.c b/polly/lib/External/isl/isl_range.c index a23a6332b03..d63ce58758a 100644 --- a/polly/lib/External/isl/isl_range.c +++ b/polly/lib/External/isl/isl_range.c @@ -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_range(__isl_take isl_basic_set *bset, 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; diff --git a/polly/lib/External/isl/isl_range.h b/polly/lib/External/isl/isl_range.h index c0970790d9e..6a5dd4a42e3 100644 --- a/polly/lib/External/isl/isl_range.h +++ b/polly/lib/External/isl/isl_range.h @@ -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); diff --git a/polly/lib/External/isl/isl_scan.c b/polly/lib/External/isl/isl_scan.c index e8cd0c0e6ca..fea42f150d3 100644 --- a/polly/lib/External/isl/isl_scan.c +++ b/polly/lib/External/isl/isl_scan.c @@ -65,7 +65,7 @@ static int add_solution(struct isl_tab *tab, struct isl_scan_callback *callback) 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 *bset, 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 *bset, * 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_set *bset, 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_set *bset, 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, struct isl_scan_callback *callback) 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, diff --git a/polly/lib/External/isl/isl_scan.h b/polly/lib/External/isl/isl_scan.h index 5d31d1b981b..f2a5100e4c0 100644 --- a/polly/lib/External/isl/isl_scan.h +++ b/polly/lib/External/isl/isl_scan.h @@ -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 diff --git a/polly/lib/External/isl/isl_schedule_band.c b/polly/lib/External/isl/isl_schedule_band.c index f0d91217391..ed209616024 100644 --- a/polly/lib/External/isl/isl_schedule_band.c +++ b/polly/lib/External/isl/isl_schedule_band.c @@ -257,7 +257,7 @@ __isl_give isl_schedule_band *isl_schedule_band_member_set_coincident( 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_schedule_band_member_set_ast_loop_type( 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_loop_type( 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_loop_types( 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_schedule_band_replace_ast_build_option( 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_schedule_band_replace_ast_build_option( 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". diff --git a/polly/lib/External/isl/isl_schedule_node.c b/polly/lib/External/isl/isl_schedule_node.c index a636d744722..3a53dfe3f91 100644 --- a/polly/lib/External/isl/isl_schedule_node.c +++ b/polly/lib/External/isl/isl_schedule_node.c @@ -1934,14 +1934,14 @@ __isl_give isl_schedule_node *isl_schedule_node_band_sink( 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_schedule_node_sequence_splice_child( 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 *update_ancestors( { 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 *update_ancestors( 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_schedule_node_group( 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: diff --git a/polly/lib/External/isl/isl_schedule_read.c b/polly/lib/External/isl/isl_schedule_read.c index 5409a49c7a3..533821bae5c 100644 --- a/polly/lib/External/isl/isl_schedule_read.c +++ b/polly/lib/External/isl/isl_schedule_read.c @@ -568,7 +568,7 @@ static __isl_give isl_schedule_tree *read_band(isl_stream *s) 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"); diff --git a/polly/lib/External/isl/isl_schedule_tree.c b/polly/lib/External/isl/isl_schedule_tree.c index 1bf08453d60..6dbadfcf7e4 100644 --- a/polly/lib/External/isl/isl_schedule_tree.c +++ b/polly/lib/External/isl/isl_schedule_tree.c @@ -82,7 +82,7 @@ __isl_take isl_schedule_tree *isl_schedule_tree_dup( 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) diff --git a/polly/lib/External/isl/isl_scheduler.c b/polly/lib/External/isl/isl_scheduler.c index cc4794ca00d..46da9c6326d 100644 --- a/polly/lib/External/isl/isl_scheduler.c +++ b/polly/lib/External/isl/isl_scheduler.c @@ -716,16 +716,16 @@ static isl_stat compute_max_row(struct isl_sched_graph *graph, /* 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(__isl_keep isl_basic_set *bset) 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_sched_graph *graph, 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_sched_edge *edge, int carry, * * "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 isl_sched_graph *graph, 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 isl_sched_graph *graph, 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 isl_sched_graph *graph, /* 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 isl_sched_graph *graph) 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 isl_sched_graph *graph, 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 diff --git a/polly/lib/External/isl/isl_space.c b/polly/lib/External/isl/isl_space.c index a1cb8ef6817..edb23336411 100644 --- a/polly/lib/External/isl/isl_space.c +++ b/polly/lib/External/isl/isl_space.c @@ -830,25 +830,25 @@ int isl_space_tuple_match(__isl_keep isl_space *space1, enum isl_dim_type type1, 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_take isl_space *space) 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. diff --git a/polly/lib/External/isl/isl_space_private.h b/polly/lib/External/isl/isl_space_private.h index 41df885524d..f06318d9513 100644 --- a/polly/lib/External/isl/isl_space_private.h +++ b/polly/lib/External/isl/isl_space_private.h @@ -41,9 +41,10 @@ __isl_give isl_space *isl_space_as_set_space(__isl_take isl_space *dim); 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); diff --git a/polly/lib/External/isl/isl_tab.c b/polly/lib/External/isl/isl_tab.c index fff2dd1bd2b..fd184c5440e 100644 --- a/polly/lib/External/isl/isl_tab.c +++ b/polly/lib/External/isl/isl_tab.c @@ -980,15 +980,15 @@ int isl_tab_mark_rational(struct isl_tab *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, isl_int *line) 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, int row) * 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, int col) 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, int col) * 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 *ineq) 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(struct isl_basic_map *bmap, unsigned div) * 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 *tab, __isl_keep isl_vec *div) * 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_tab *tab) 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_tab *tab, int row) 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_tab *tab, int row) * 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(struct isl_tab *tab) 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_tab *tab, struct isl_tab_var *var) } } -/* 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 *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, struct isl_tab_var *var) } - 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, struct isl_tab_var *var) * 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(struct isl_tab *tab) 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_tab *tab, struct isl_tab_undo *undo) 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_tab *tab, struct isl_tab_undo *undo) 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 isl_tab *tab, int n) } } -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 *tab, struct isl_tab_undo *undo) 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 *tab, struct isl_tab_undo *undo) 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 *tab, __isl_take isl_basic_map *bmap) 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 *tab, __isl_take isl_basic_map *bmap) 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)); } diff --git a/polly/lib/External/isl/isl_tab.h b/polly/lib/External/isl/isl_tab.h index eee25d7fd16..fe8ddfdba97 100644 --- a/polly/lib/External/isl/isl_tab.h +++ b/polly/lib/External/isl/isl_tab.h @@ -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_basic_set( __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 isl_tab *tab, 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_lexmin_free(__isl_take isl_tab_lexmin *tl); 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 *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; diff --git a/polly/lib/External/isl/isl_tab_lexopt_templ.c b/polly/lib/External/isl/isl_tab_lexopt_templ.c index ff55550bf82..751e7bf8051 100644 --- a/polly/lib/External/isl/isl_tab_lexopt_templ.c +++ b/polly/lib/External/isl/isl_tab_lexopt_templ.c @@ -145,7 +145,7 @@ static __isl_give TYPE *SF(basic_map_partial_lexopt,SUFFIX)( __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) diff --git a/polly/lib/External/isl/isl_tab_pip.c b/polly/lib/External/isl/isl_tab_pip.c index 63dce300f3c..20abe47e3f3 100644 --- a/polly/lib/External/isl/isl_tab_pip.c +++ b/polly/lib/External/isl/isl_tab_pip.c @@ -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 *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 *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 *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(struct isl_sol *sol) 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_partial_sol *s1, struct isl_partial_sol *s2, 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) 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, struct isl_tab *tab) 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(struct isl_sol *sol, 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 isl_tab *tab, isl_int *ineq, int eq) */ 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_lexmin(struct isl_basic_set *bset) 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_alloc(__isl_keep isl_basic_set *dom) 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_alloc(__isl_keep isl_basic_set *dom) * 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(struct isl_basic_map *bmap, 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(struct isl_basic_map *bmap, 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 *entry, const void *val) * 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_keep isl_basic_map *bmap, 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_keep isl_basic_map *bmap, 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_keep isl_basic_map *bmap, * 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_keep isl_basic_set *bset, * 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_take isl_set *empty, 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(__isl_take isl_map *opt, 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_domain(__isl_keep isl_basic_map *bmap, 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) -{ - 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) +static void sol_for_free(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_sol *sol) * 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_for *sol, 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(struct isl_basic_map *bmap, int max, 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(struct isl_sol_for *sol_for, 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_keep isl_basic_map *bmap, int max, 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_keep isl_basic_map *bmap, int max, 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_pma *sol, 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(struct isl_sol *sol, } 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(__isl_keep isl_basic_map *bmap, __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(__isl_keep isl_basic_map *bmap, 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(__isl_keep isl_basic_map *bmap, 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 *split_domain_pma( 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); diff --git a/polly/lib/External/isl/isl_test.c b/polly/lib/External/isl/isl_test.c index 905032e63f6..07700e1e99f 100644 --- a/polly/lib/External/isl/isl_test.c +++ b/polly/lib/External/isl/isl_test.c @@ -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 *ctx) 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 *ctx) 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 *ctx) 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 *cell, void *user) 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. diff --git a/polly/lib/External/isl/isl_transitive_closure.c b/polly/lib/External/isl/isl_transitive_closure.c index 63eabe22e52..229626cd761 100644 --- a/polly/lib/External/isl/isl_transitive_closure.c +++ b/polly/lib/External/isl/isl_transitive_closure.c @@ -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_positive(__isl_keep isl_basic_set *bset, 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_set *bset, isl_int *c, int *div_purity, 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_extended_path(__isl_take isl_space *dim, 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_component(__isl_take isl_space *dim, 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_set *C, int i, 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 *group, __isl_take isl_set *dom, int pos) 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_path_lengths(__isl_take isl_map *map, * * 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_basic_set *bset, int i) 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 diff --git a/polly/lib/External/isl/isl_union_map.c b/polly/lib/External/isl/isl_union_map.c index c3fb1f9f8c5..53b0960ddab 100644 --- a/polly/lib/External/isl/isl_union_map.c +++ b/polly/lib/External/isl/isl_union_map.c @@ -531,25 +531,25 @@ __isl_give isl_set *isl_union_set_extract_set(__isl_keep isl_union_set *uset, /* 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, diff --git a/polly/lib/External/isl/isl_union_templ.c b/polly/lib/External/isl/isl_union_templ.c index 66bbd2b02f0..e787b6c36c4 100644 --- a/polly/lib/External/isl/isl_union_templ.c +++ b/polly/lib/External/isl/isl_union_templ.c @@ -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. */ diff --git a/polly/lib/External/isl/isl_val.c b/polly/lib/External/isl/isl_val.c index 6a62a33ba79..b1c6f792e92 100644 --- a/polly/lib/External/isl/isl_val.c +++ b/polly/lib/External/isl/isl_val.c @@ -1578,32 +1578,33 @@ __isl_give isl_val *isl_val_zero_on_domain(__isl_take isl_local_space *ls) * 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 diff --git a/polly/lib/External/isl/isl_val_private.h b/polly/lib/External/isl/isl_val_private.h index 0757dcdeb57..4276ddb31c4 100644 --- a/polly/lib/External/isl/isl_val_private.h +++ b/polly/lib/External/isl/isl_val_private.h @@ -62,8 +62,9 @@ __isl_give isl_val *isl_val_mod_val(__isl_take isl_val *v1, 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 diff --git a/polly/lib/External/isl/isl_vec.c b/polly/lib/External/isl/isl_vec.c index 2b49a8106ad..334bb00fb3a 100644 --- a/polly/lib/External/isl/isl_vec.c +++ b/polly/lib/External/isl/isl_vec.c @@ -94,7 +94,7 @@ __isl_give isl_vec *isl_vec_expand(__isl_take isl_vec *vec, int pos, int n, 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) diff --git a/polly/lib/External/isl/isl_vertices.c b/polly/lib/External/isl/isl_vertices.c index 011cda1363d..b970ca290d8 100644 --- a/polly/lib/External/isl/isl_vertices.c +++ b/polly/lib/External/isl/isl_vertices.c @@ -530,23 +530,24 @@ static void free_chamber_list(struct isl_chamber_list *list) /* 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_interior_point( * 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_keep isl_vertices *vertices, 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 isl_cell *cell, 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 isl_cell *cell, 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 isl_basic_set *vertex, * 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_cell *cell, __isl_keep isl_vec *v, 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_cell *cell, __isl_keep isl_vec *v, } 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 isl_cell *cell, 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; } diff --git a/polly/lib/External/isl/isl_vertices_private.h b/polly/lib/External/isl/isl_vertices_private.h index b77286d9b36..37e64075508 100644 --- a/polly/lib/External/isl/isl_vertices_private.h +++ b/polly/lib/External/isl/isl_vertices_private.h @@ -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_vertices(__isl_take struct isl_morph *morph, #if defined(__cplusplus) } #endif + +#endif diff --git a/polly/lib/External/isl/m4/ax_detect_clang.m4 b/polly/lib/External/isl/m4/ax_detect_clang.m4 new file mode 100644 index 00000000000..d511dab676c --- /dev/null +++ b/polly/lib/External/isl/m4/ax_detect_clang.m4 @@ -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" +]) diff --git a/polly/lib/External/isl/test_inputs/codegen/cloog/faber.c b/polly/lib/External/isl/test_inputs/codegen/cloog/faber.c index 984dafcf70c..3310f278947 100644 --- a/polly/lib/External/isl/test_inputs/codegen/cloog/faber.c +++ b/polly/lib/External/isl/test_inputs/codegen/cloog/faber.c @@ -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); diff --git a/polly/lib/External/isl/test_inputs/codegen/cloog/jacobi-shared.c b/polly/lib/External/isl/test_inputs/codegen/cloog/jacobi-shared.c index 0deb1064fd2..bf709329742 100644 --- a/polly/lib/External/isl/test_inputs/codegen/cloog/jacobi-shared.c +++ b/polly/lib/External/isl/test_inputs/codegen/cloog/jacobi-shared.c @@ -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); diff --git a/polly/lib/External/isl/test_inputs/codegen/cloog/levenshtein-1-2-3.c b/polly/lib/External/isl/test_inputs/codegen/cloog/levenshtein-1-2-3.c index 0e470b4d73b..70d1ea5c148 100644 --- a/polly/lib/External/isl/test_inputs/codegen/cloog/levenshtein-1-2-3.c +++ b/polly/lib/External/isl/test_inputs/codegen/cloog/levenshtein-1-2-3.c @@ -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); } diff --git a/polly/lib/External/isl/test_inputs/codegen/cloog/reservoir-cholesky2.c b/polly/lib/External/isl/test_inputs/codegen/cloog/reservoir-cholesky2.c index 0c17655b2fc..73f7790c4c6 100644 --- a/polly/lib/External/isl/test_inputs/codegen/cloog/reservoir-cholesky2.c +++ b/polly/lib/External/isl/test_inputs/codegen/cloog/reservoir-cholesky2.c @@ -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) diff --git a/polly/lib/External/isl/test_inputs/codegen/cloog/reservoir-pingali1.c b/polly/lib/External/isl/test_inputs/codegen/cloog/reservoir-pingali1.c index ddb1293be11..43c6ef02264 100644 --- a/polly/lib/External/isl/test_inputs/codegen/cloog/reservoir-pingali1.c +++ b/polly/lib/External/isl/test_inputs/codegen/cloog/reservoir-pingali1.c @@ -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); } diff --git a/polly/lib/External/isl/test_inputs/codegen/cloog/walters.c b/polly/lib/External/isl/test_inputs/codegen/cloog/walters.c index f65491528c6..3854892a141 100644 --- a/polly/lib/External/isl/test_inputs/codegen/cloog/walters.c +++ b/polly/lib/External/isl/test_inputs/codegen/cloog/walters.c @@ -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); } diff --git a/polly/lib/External/isl/test_inputs/codegen/isolate5.c b/polly/lib/External/isl/test_inputs/codegen/isolate5.c index 53d4300c563..0f1588d8e73 100644 --- a/polly/lib/External/isl/test_inputs/codegen/isolate5.c +++ b/polly/lib/External/isl/test_inputs/codegen/isolate5.c @@ -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); } } } diff --git a/polly/lib/External/isl/test_inputs/codegen/jacobi_kernel4.c b/polly/lib/External/isl/test_inputs/codegen/jacobi_kernel4.c new file mode 100644 index 00000000000..97b45448ae1 --- /dev/null +++ b/polly/lib/External/isl/test_inputs/codegen/jacobi_kernel4.c @@ -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); diff --git a/polly/lib/External/isl/test_inputs/codegen/jacobi_kernel4.in b/polly/lib/External/isl/test_inputs/codegen/jacobi_kernel4.in new file mode 100644 index 00000000000..9eadc1ba4f8 --- /dev/null +++ b/polly/lib/External/isl/test_inputs/codegen/jacobi_kernel4.in @@ -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] -> { } diff --git a/polly/lib/External/isl/test_inputs/codegen/omega/guard1-0.c b/polly/lib/External/isl/test_inputs/codegen/omega/guard1-0.c index 555d644f561..e430f2b5c8c 100644 --- a/polly/lib/External/isl/test_inputs/codegen/omega/guard1-0.c +++ b/polly/lib/External/isl/test_inputs/codegen/omega/guard1-0.c @@ -1,2 +1,2 @@ -if ((n - m + 2) % 3 == 0) +if ((n - m - 1) % 3 == 0) s0(n, m); diff --git a/polly/lib/External/isl/test_inputs/codegen/omega/guard1-1.c b/polly/lib/External/isl/test_inputs/codegen/omega/guard1-1.c index 335c1b838fe..3994a6122e7 100644 --- a/polly/lib/External/isl/test_inputs/codegen/omega/guard1-1.c +++ b/polly/lib/External/isl/test_inputs/codegen/omega/guard1-1.c @@ -1,2 +1,2 @@ -if ((n - m + 1) % 2 == 0) +if ((n + m + 1) % 2 == 0) s0(n, m); diff --git a/polly/lib/External/isl/test_inputs/codegen/omega/m7-1.c b/polly/lib/External/isl/test_inputs/codegen/omega/m7-1.c index f16840f6135..d33abe9d46f 100644 --- a/polly/lib/External/isl/test_inputs/codegen/omega/m7-1.c +++ b/polly/lib/External/isl/test_inputs/codegen/omega/m7-1.c @@ -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); } } diff --git a/polly/lib/External/isl/test_inputs/codegen/omega/m8-1.c b/polly/lib/External/isl/test_inputs/codegen/omega/m8-1.c index fbe7bbdb801..4f8a00f0428 100644 --- a/polly/lib/External/isl/test_inputs/codegen/omega/m8-1.c +++ b/polly/lib/External/isl/test_inputs/codegen/omega/m8-1.c @@ -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); } } diff --git a/polly/lib/External/isl/test_inputs/codegen/omega/p.delft2-0.c b/polly/lib/External/isl/test_inputs/codegen/omega/p.delft2-0.c index 7ab83b694cc..ab1bc728e03 100644 --- a/polly/lib/External/isl/test_inputs/codegen/omega/p.delft2-0.c +++ b/polly/lib/External/isl/test_inputs/codegen/omega/p.delft2-0.c @@ -2,9 +2,9 @@ if (P1 >= 0 && P1 <= 3 && P2 >= 0 && P2 <= 3) 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)); } diff --git a/polly/lib/External/isl/test_inputs/codegen/redundant.c b/polly/lib/External/isl/test_inputs/codegen/redundant.c index 57ec5a738a0..057416e88ba 100644 --- a/polly/lib/External/isl/test_inputs/codegen/redundant.c +++ b/polly/lib/External/isl/test_inputs/codegen/redundant.c @@ -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); } diff --git a/polly/lib/External/isl/test_inputs/codegen/sor1d-part.c b/polly/lib/External/isl/test_inputs/codegen/sor1d-part.c index 3c34838809a..096d34d1120 100644 --- a/polly/lib/External/isl/test_inputs/codegen/sor1d-part.c +++ b/polly/lib/External/isl/test_inputs/codegen/sor1d-part.c @@ -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); diff --git a/polly/lib/External/isl/test_inputs/codegen/stride5.c b/polly/lib/External/isl/test_inputs/codegen/stride5.c index ee89e367598..5954439dd36 100644 --- a/polly/lib/External/isl/test_inputs/codegen/stride5.c +++ b/polly/lib/External/isl/test_inputs/codegen/stride5.c @@ -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); diff --git a/polly/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_4.ll b/polly/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_4.ll index 11074d968fd..92a3e6231eb 100644 --- a/polly/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_4.ll +++ b/polly/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_4.ll @@ -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) { diff --git a/polly/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_5.ll b/polly/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_5.ll index b46559ed3f0..68c273a6071 100644 --- a/polly/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_5.ll +++ b/polly/test/Isl/Ast/reduction_modulo_schedule_multiple_dimensions_5.ll @@ -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) { diff --git a/polly/test/Isl/CodeGen/if-conditions-in-vector-code.ll b/polly/test/Isl/CodeGen/if-conditions-in-vector-code.ll index 844fc5f352c..ca0489e630f 100644 --- a/polly/test/Isl/CodeGen/if-conditions-in-vector-code.ll +++ b/polly/test/Isl/CodeGen/if-conditions-in-vector-code.ll @@ -18,7 +18,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" ; 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); diff --git a/polly/test/ScopInfo/modulo_zext_1.ll b/polly/test/ScopInfo/modulo_zext_1.ll index cbdb9ce40c7..da0e77315a8 100644 --- a/polly/test/ScopInfo/modulo_zext_1.ll +++ b/polly/test/ScopInfo/modulo_zext_1.ll @@ -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) { diff --git a/polly/test/ScopInfo/modulo_zext_2.ll b/polly/test/ScopInfo/modulo_zext_2.ll index 9d345a128c9..70eadf2f9f4 100644 --- a/polly/test/ScopInfo/modulo_zext_2.ll +++ b/polly/test/ScopInfo/modulo_zext_2.ll @@ -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] diff --git a/polly/test/ScopInfo/multidim_fortran_srem.ll b/polly/test/ScopInfo/multidim_fortran_srem.ll index 9680e3f77c0..46cec714559 100644 --- a/polly/test/ScopInfo/multidim_fortran_srem.ll +++ b/polly/test/ScopInfo/multidim_fortran_srem.ll @@ -23,7 +23,7 @@ target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64: ; 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] diff --git a/polly/test/ScopInfo/multidim_srem.ll b/polly/test/ScopInfo/multidim_srem.ll index 29c7557c169..61a7307e56a 100644 --- a/polly/test/ScopInfo/multidim_srem.ll +++ b/polly/test/ScopInfo/multidim_srem.ll @@ -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" diff --git a/polly/test/ScopInfo/switch-1.ll b/polly/test/ScopInfo/switch-1.ll index 9b1aeab4f74..ca63b3ef8ba 100644 --- a/polly/test/ScopInfo/switch-1.ll +++ b/polly/test/ScopInfo/switch-1.ll @@ -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] diff --git a/polly/test/ScopInfo/switch-2.ll b/polly/test/ScopInfo/switch-2.ll index 1b61d4cc2f7..10605197584 100644 --- a/polly/test/ScopInfo/switch-2.ll +++ b/polly/test/ScopInfo/switch-2.ll @@ -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] diff --git a/polly/test/ScopInfo/switch-3.ll b/polly/test/ScopInfo/switch-3.ll index 36d9ce18296..c32ce109bcc 100644 --- a/polly/test/ScopInfo/switch-3.ll +++ b/polly/test/ScopInfo/switch-3.ll @@ -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); diff --git a/polly/test/ScopInfo/switch-4.ll b/polly/test/ScopInfo/switch-4.ll index d76e0f8d8d4..19644aaf924 100644 --- a/polly/test/ScopInfo/switch-4.ll +++ b/polly/test/ScopInfo/switch-4.ll @@ -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] |