Files
clang-p2996/polly/lib/External/isl/isl_multi_dims.c
Michael Kruse e8227804ac [Polly] Update ISL to isl-0.22.1-87-gfee05a13.
The primary motivation is to fix an assertion failure in
isl_basic_map_alloc_equality:

    isl_assert(ctx, room_for_con(bmap, 1), return -1);

Although the assertion does not occur anymore, I could not identify
which of ISL's commits fixed it.

Compared to the previous ISL version, Polly requires some changes for this update

 * Since ISL commit
   20d3574 "perform parameter alignment by modifying both arguments to function"
   isl_*_gist_* and similar functions do not always align the paramter
   list anymore. This caused the parameter lists in JScop files to
   become out-of-sync. Since many regression tests use JScop files with
   a fixed parameter list and order, we explicitly call align_params to
   ensure a predictable parameter list.

 * ISL changed some return types to isl_size, a typedef of (signed) int.
   This caused some issues where the return type was unsigned int before:
   - No overload for std::max(unsigned,isl_size)
   - It cause additional 'mixed signed/unsigned comparison' warnings.
     Since they do not break compilation, and sizes larger than 2^31
     were never supported, I am going to fix it separately.

 * With the change to isl_size, commit
   57d547 "isl_*_list_size: return isl_size"
   also changed the return value in case of an error from 0 to -1. This
   caused undefined looping over isl_iterator since the 'end iterator'
   got index -1, never reached from the 'begin iterator' with index 0.

 * Some internal changes in ISL caused the number of operations to
   increase when determining access ranges to determine aliasing
   overlaps. In one test, this caused exceeding the default limit of
   800000. The operations-limit was disabled for this test.
2020-02-10 19:03:08 -06:00

120 lines
3.2 KiB
C

/*
* Copyright 2011 Sven Verdoolaege
* Copyright 2012-2013 Ecole Normale Superieure
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege,
* Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
*/
#include <isl_space_private.h>
#include <isl_multi_macro.h>
/* Check whether "multi" has non-zero coefficients for any dimension
* in the given range or if any of these dimensions appear
* with non-zero coefficients in any of the integer divisions involved.
*/
isl_bool FN(MULTI(BASE),involves_dims)(__isl_keep MULTI(BASE) *multi,
enum isl_dim_type type, unsigned first, unsigned n)
{
int i;
if (!multi)
return isl_bool_error;
if (n == 0)
return isl_bool_false;
for (i = 0; i < multi->n; ++i) {
isl_bool involves;
involves = FN(EL,involves_dims)(multi->u.p[i], type, first, n);
if (involves < 0 || involves)
return involves;
}
if (FN(MULTI(BASE),has_explicit_domain)(multi))
return FN(MULTI(BASE),involves_explicit_domain_dims)(multi,
type, first, n);
return isl_bool_false;
}
__isl_give MULTI(BASE) *FN(MULTI(BASE),insert_dims)(
__isl_take MULTI(BASE) *multi,
enum isl_dim_type type, unsigned first, unsigned n)
{
int i;
if (!multi)
return NULL;
if (type == isl_dim_out)
isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
"cannot insert output/set dimensions",
return FN(MULTI(BASE),free)(multi));
if (n == 0 && !isl_space_is_named_or_nested(multi->space, type))
return multi;
multi = FN(MULTI(BASE),cow)(multi);
if (!multi)
return NULL;
multi->space = isl_space_insert_dims(multi->space, type, first, n);
if (!multi->space)
return FN(MULTI(BASE),free)(multi);
if (FN(MULTI(BASE),has_explicit_domain)(multi))
multi = FN(MULTI(BASE),insert_explicit_domain_dims)(multi,
type, first, n);
if (!multi)
return NULL;
for (i = 0; i < multi->n; ++i) {
multi->u.p[i] = FN(EL,insert_dims)(multi->u.p[i],
type, first, n);
if (!multi->u.p[i])
return FN(MULTI(BASE),free)(multi);
}
return multi;
}
__isl_give MULTI(BASE) *FN(MULTI(BASE),add_dims)(__isl_take MULTI(BASE) *multi,
enum isl_dim_type type, unsigned n)
{
isl_size pos;
pos = FN(MULTI(BASE),dim)(multi, type);
if (pos < 0)
return FN(MULTI(BASE),free)(multi);
return FN(MULTI(BASE),insert_dims)(multi, type, pos, n);
}
/* Project the domain of "multi" onto its parameter space.
* "multi" may not involve any of the domain dimensions.
*/
__isl_give MULTI(BASE) *FN(MULTI(BASE),project_domain_on_params)(
__isl_take MULTI(BASE) *multi)
{
isl_size n;
isl_bool involves;
isl_space *space;
n = FN(MULTI(BASE),dim)(multi, isl_dim_in);
if (n < 0)
return FN(MULTI(BASE),free)(multi);
involves = FN(MULTI(BASE),involves_dims)(multi, isl_dim_in, 0, n);
if (involves < 0)
return FN(MULTI(BASE),free)(multi);
if (involves)
isl_die(FN(MULTI(BASE),get_ctx)(multi), isl_error_invalid,
"expression involves some of the domain dimensions",
return FN(MULTI(BASE),free)(multi));
multi = FN(MULTI(BASE),drop_dims)(multi, isl_dim_in, 0, n);
space = FN(MULTI(BASE),get_domain_space)(multi);
space = isl_space_params(space);
multi = FN(MULTI(BASE),reset_domain_space)(multi, space);
return multi;
}