Coverage Report

Created: 2018-06-24 14:39

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/polly/lib/External/isl/isl_pw_templ.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2010-2011 INRIA Saclay
3
 * Copyright 2011      Sven Verdoolaege
4
 * Copyright 2012-2014 Ecole Normale Superieure
5
 *
6
 * Use of this software is governed by the MIT license
7
 *
8
 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
9
 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
10
 * 91893 Orsay, France
11
 * and Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
12
 */
13
14
#include <isl/id.h>
15
#include <isl/aff.h>
16
#include <isl_sort.h>
17
#include <isl_val_private.h>
18
19
#include <isl_pw_macro.h>
20
21
#ifdef HAS_TYPE
22
__isl_give PW *FN(PW,alloc_size)(__isl_take isl_space *dim,
23
  enum isl_fold type, int n)
24
#else
25
__isl_give PW *FN(PW,alloc_size)(__isl_take isl_space *dim, int n)
26
#endif
27
281k
{
28
281k
  isl_ctx *ctx;
29
281k
  struct PW *pw;
30
281k
31
281k
  if (!dim)
32
0
    return NULL;
33
281k
  ctx = isl_space_get_ctx(dim);
34
281k
  isl_assert(ctx, n >= 0, goto error);
35
281k
  pw = isl_alloc(ctx, struct PW,
36
281k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
37
281k
  if (!pw)
38
0
    goto error;
39
281k
40
281k
  pw->ref = 1;
41
#ifdef HAS_TYPE
42
  pw->type = type;
43
#endif
44
  pw->size = n;
45
281k
  pw->n = 0;
46
281k
  pw->dim = dim;
47
281k
  return pw;
48
281k
error:
49
0
  isl_space_free(dim);
50
0
  return NULL;
51
281k
}
isl_pw_aff_alloc_size
Line
Count
Source
27
248k
{
28
248k
  isl_ctx *ctx;
29
248k
  struct PW *pw;
30
248k
31
248k
  if (!dim)
32
0
    return NULL;
33
248k
  ctx = isl_space_get_ctx(dim);
34
248k
  isl_assert(ctx, n >= 0, goto error);
35
248k
  pw = isl_alloc(ctx, struct PW,
36
248k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
37
248k
  if (!pw)
38
0
    goto error;
39
248k
40
248k
  pw->ref = 1;
41
#ifdef HAS_TYPE
42
  pw->type = type;
43
#endif
44
  pw->size = n;
45
248k
  pw->n = 0;
46
248k
  pw->dim = dim;
47
248k
  return pw;
48
248k
error:
49
0
  isl_space_free(dim);
50
0
  return NULL;
51
248k
}
isl_pw_multi_aff_alloc_size
Line
Count
Source
27
33.2k
{
28
33.2k
  isl_ctx *ctx;
29
33.2k
  struct PW *pw;
30
33.2k
31
33.2k
  if (!dim)
32
0
    return NULL;
33
33.2k
  ctx = isl_space_get_ctx(dim);
34
33.2k
  isl_assert(ctx, n >= 0, goto error);
35
33.2k
  pw = isl_alloc(ctx, struct PW,
36
33.2k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
37
33.2k
  if (!pw)
38
0
    goto error;
39
33.2k
40
33.2k
  pw->ref = 1;
41
#ifdef HAS_TYPE
42
  pw->type = type;
43
#endif
44
  pw->size = n;
45
33.2k
  pw->n = 0;
46
33.2k
  pw->dim = dim;
47
33.2k
  return pw;
48
33.2k
error:
49
0
  isl_space_free(dim);
50
0
  return NULL;
51
33.2k
}
isl_pw_qpolynomial_fold_alloc_size
Line
Count
Source
27
35
{
28
35
  isl_ctx *ctx;
29
35
  struct PW *pw;
30
35
31
35
  if (!dim)
32
0
    return NULL;
33
35
  ctx = isl_space_get_ctx(dim);
34
35
  isl_assert(ctx, n >= 0, goto error);
35
35
  pw = isl_alloc(ctx, struct PW,
36
35
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
37
35
  if (!pw)
38
0
    goto error;
39
35
40
35
  pw->ref = 1;
41
35
#ifdef HAS_TYPE
42
35
  pw->type = type;
43
35
#endif
44
35
  pw->size = n;
45
35
  pw->n = 0;
46
35
  pw->dim = dim;
47
35
  return pw;
48
35
error:
49
0
  isl_space_free(dim);
50
0
  return NULL;
51
35
}
isl_pw_qpolynomial_alloc_size
Line
Count
Source
27
104
{
28
104
  isl_ctx *ctx;
29
104
  struct PW *pw;
30
104
31
104
  if (!dim)
32
0
    return NULL;
33
104
  ctx = isl_space_get_ctx(dim);
34
104
  isl_assert(ctx, n >= 0, goto error);
35
104
  pw = isl_alloc(ctx, struct PW,
36
104
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
37
104
  if (!pw)
38
0
    goto error;
39
104
40
104
  pw->ref = 1;
41
#ifdef HAS_TYPE
42
  pw->type = type;
43
#endif
44
  pw->size = n;
45
104
  pw->n = 0;
46
104
  pw->dim = dim;
47
104
  return pw;
48
104
error:
49
0
  isl_space_free(dim);
50
0
  return NULL;
51
104
}
52
53
#ifdef HAS_TYPE
54
__isl_give PW *FN(PW,ZERO)(__isl_take isl_space *dim, enum isl_fold type)
55
16
{
56
16
  return FN(PW,alloc_size)(dim, type, 0);
57
16
}
58
#else
59
__isl_give PW *FN(PW,ZERO)(__isl_take isl_space *dim)
60
8.17k
{
61
8.17k
  return FN(PW,alloc_size)(dim, 0);
62
8.17k
}
isl_pw_aff_empty
Line
Count
Source
60
3.39k
{
61
3.39k
  return FN(PW,alloc_size)(dim, 0);
62
3.39k
}
isl_pw_multi_aff_empty
Line
Count
Source
60
4.77k
{
61
4.77k
  return FN(PW,alloc_size)(dim, 0);
62
4.77k
}
isl_pw_qpolynomial_zero
Line
Count
Source
60
2
{
61
2
  return FN(PW,alloc_size)(dim, 0);
62
2
}
63
#endif
64
65
__isl_give PW *FN(PW,add_piece)(__isl_take PW *pw,
66
  __isl_take isl_set *set, __isl_take EL *el)
67
284k
{
68
284k
  isl_ctx *ctx;
69
284k
  isl_space *el_dim = NULL;
70
284k
71
284k
  if (!pw || !set || !el)
72
0
    goto error;
73
284k
74
284k
  if (isl_set_plain_is_empty(set) || 
FN283k
(EL,EL_IS_ZERO)(el)283k
) {
75
793
    isl_set_free(set);
76
793
    FN(EL,free)(el);
77
793
    return pw;
78
793
  }
79
283k
80
283k
  ctx = isl_set_get_ctx(set);
81
#ifdef HAS_TYPE
82
18
  if (pw->type != el->type)
83
0
    isl_die(ctx, isl_error_invalid, "fold types don't match",
84
      goto error);
85
#endif
86
283k
  
el_dim = 18
FN(EL,get_space(el));
87
283k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
88
283k
  isl_assert(ctx, pw->n < pw->size, goto error);
89
283k
90
283k
  pw->p[pw->n].set = set;
91
283k
  pw->p[pw->n].FIELD = el;
92
283k
  pw->n++;
93
283k
  
94
283k
  isl_space_free(el_dim);
95
283k
  return pw;
96
283k
error:
97
0
  isl_space_free(el_dim);
98
0
  FN(PW,free)(pw);
99
0
  isl_set_free(set);
100
0
  FN(EL,free)(el);
101
0
  return NULL;
102
283k
}
isl_pw_aff_add_piece
Line
Count
Source
67
251k
{
68
251k
  isl_ctx *ctx;
69
251k
  isl_space *el_dim = NULL;
70
251k
71
251k
  if (!pw || !set || !el)
72
0
    goto error;
73
251k
74
251k
  if (isl_set_plain_is_empty(set) || 
FN250k
(EL,EL_IS_ZERO)(el)250k
) {
75
393
    isl_set_free(set);
76
393
    FN(EL,free)(el);
77
393
    return pw;
78
393
  }
79
250k
80
250k
  ctx = isl_set_get_ctx(set);
81
#ifdef HAS_TYPE
82
  if (pw->type != el->type)
83
    isl_die(ctx, isl_error_invalid, "fold types don't match",
84
      goto error);
85
#endif
86
250k
  el_dim = FN(EL,get_space(el));
87
250k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
88
250k
  isl_assert(ctx, pw->n < pw->size, goto error);
89
250k
90
250k
  pw->p[pw->n].set = set;
91
250k
  pw->p[pw->n].FIELD = el;
92
250k
  pw->n++;
93
250k
  
94
250k
  isl_space_free(el_dim);
95
250k
  return pw;
96
250k
error:
97
0
  isl_space_free(el_dim);
98
0
  FN(PW,free)(pw);
99
0
  isl_set_free(set);
100
0
  FN(EL,free)(el);
101
0
  return NULL;
102
250k
}
isl_pw_multi_aff_add_piece
Line
Count
Source
67
32.8k
{
68
32.8k
  isl_ctx *ctx;
69
32.8k
  isl_space *el_dim = NULL;
70
32.8k
71
32.8k
  if (!pw || !set || !el)
72
0
    goto error;
73
32.8k
74
32.8k
  if (isl_set_plain_is_empty(set) || 
FN32.4k
(EL,EL_IS_ZERO)(el)32.4k
) {
75
341
    isl_set_free(set);
76
341
    FN(EL,free)(el);
77
341
    return pw;
78
341
  }
79
32.4k
80
32.4k
  ctx = isl_set_get_ctx(set);
81
#ifdef HAS_TYPE
82
  if (pw->type != el->type)
83
    isl_die(ctx, isl_error_invalid, "fold types don't match",
84
      goto error);
85
#endif
86
32.4k
  el_dim = FN(EL,get_space(el));
87
32.4k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
88
32.4k
  isl_assert(ctx, pw->n < pw->size, goto error);
89
32.4k
90
32.4k
  pw->p[pw->n].set = set;
91
32.4k
  pw->p[pw->n].FIELD = el;
92
32.4k
  pw->n++;
93
32.4k
  
94
32.4k
  isl_space_free(el_dim);
95
32.4k
  return pw;
96
32.4k
error:
97
0
  isl_space_free(el_dim);
98
0
  FN(PW,free)(pw);
99
0
  isl_set_free(set);
100
0
  FN(EL,free)(el);
101
0
  return NULL;
102
32.4k
}
isl_pw_qpolynomial_fold_add_piece
Line
Count
Source
67
24
{
68
24
  isl_ctx *ctx;
69
24
  isl_space *el_dim = NULL;
70
24
71
24
  if (!pw || !set || !el)
72
0
    goto error;
73
24
74
24
  if (isl_set_plain_is_empty(set) || 
FN18
(EL,EL_IS_ZERO)(el)18
) {
75
6
    isl_set_free(set);
76
6
    FN(EL,free)(el);
77
6
    return pw;
78
6
  }
79
18
80
18
  ctx = isl_set_get_ctx(set);
81
18
#ifdef HAS_TYPE
82
18
  if (pw->type != el->type)
83
18
    
isl_die0
(ctx, isl_error_invalid, "fold types don't match",
84
18
      goto error);
85
18
#endif
86
18
  el_dim = FN(EL,get_space(el));
87
18
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
88
18
  isl_assert(ctx, pw->n < pw->size, goto error);
89
18
90
18
  pw->p[pw->n].set = set;
91
18
  pw->p[pw->n].FIELD = el;
92
18
  pw->n++;
93
18
  
94
18
  isl_space_free(el_dim);
95
18
  return pw;
96
18
error:
97
0
  isl_space_free(el_dim);
98
0
  FN(PW,free)(pw);
99
0
  isl_set_free(set);
100
0
  FN(EL,free)(el);
101
0
  return NULL;
102
18
}
isl_pw_qpolynomial_add_piece
Line
Count
Source
67
151
{
68
151
  isl_ctx *ctx;
69
151
  isl_space *el_dim = NULL;
70
151
71
151
  if (!pw || !set || !el)
72
0
    goto error;
73
151
74
151
  if (isl_set_plain_is_empty(set) || 
FN107
(EL,EL_IS_ZERO)(el)107
) {
75
53
    isl_set_free(set);
76
53
    FN(EL,free)(el);
77
53
    return pw;
78
53
  }
79
98
80
98
  ctx = isl_set_get_ctx(set);
81
#ifdef HAS_TYPE
82
  if (pw->type != el->type)
83
    isl_die(ctx, isl_error_invalid, "fold types don't match",
84
      goto error);
85
#endif
86
98
  el_dim = FN(EL,get_space(el));
87
98
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
88
98
  isl_assert(ctx, pw->n < pw->size, goto error);
89
98
90
98
  pw->p[pw->n].set = set;
91
98
  pw->p[pw->n].FIELD = el;
92
98
  pw->n++;
93
98
  
94
98
  isl_space_free(el_dim);
95
98
  return pw;
96
98
error:
97
0
  isl_space_free(el_dim);
98
0
  FN(PW,free)(pw);
99
0
  isl_set_free(set);
100
0
  FN(EL,free)(el);
101
0
  return NULL;
102
98
}
103
104
/* Does the space of "set" correspond to that of the domain of "el".
105
 */
106
static isl_bool FN(PW,compatible_domain)(__isl_keep EL *el,
107
  __isl_keep isl_set *set)
108
107k
{
109
107k
  isl_bool ok;
110
107k
  isl_space *el_space, *set_space;
111
107k
112
107k
  if (!set || 
!el107k
)
113
3
    return isl_bool_error;
114
107k
  set_space = isl_set_get_space(set);
115
107k
  el_space = FN(EL,get_space)(el);
116
107k
  ok = isl_space_is_domain_internal(set_space, el_space);
117
107k
  isl_space_free(el_space);
118
107k
  isl_space_free(set_space);
119
107k
  return ok;
120
107k
}
isl_aff.c:isl_pw_aff_compatible_domain
Line
Count
Source
108
82.6k
{
109
82.6k
  isl_bool ok;
110
82.6k
  isl_space *el_space, *set_space;
111
82.6k
112
82.6k
  if (!set || 
!el82.6k
)
113
3
    return isl_bool_error;
114
82.6k
  set_space = isl_set_get_space(set);
115
82.6k
  el_space = FN(EL,get_space)(el);
116
82.6k
  ok = isl_space_is_domain_internal(set_space, el_space);
117
82.6k
  isl_space_free(el_space);
118
82.6k
  isl_space_free(set_space);
119
82.6k
  return ok;
120
82.6k
}
isl_aff.c:isl_pw_multi_aff_compatible_domain
Line
Count
Source
108
24.3k
{
109
24.3k
  isl_bool ok;
110
24.3k
  isl_space *el_space, *set_space;
111
24.3k
112
24.3k
  if (!set || !el)
113
0
    return isl_bool_error;
114
24.3k
  set_space = isl_set_get_space(set);
115
24.3k
  el_space = FN(EL,get_space)(el);
116
24.3k
  ok = isl_space_is_domain_internal(set_space, el_space);
117
24.3k
  isl_space_free(el_space);
118
24.3k
  isl_space_free(set_space);
119
24.3k
  return ok;
120
24.3k
}
isl_fold.c:isl_pw_qpolynomial_fold_compatible_domain
Line
Count
Source
108
12
{
109
12
  isl_bool ok;
110
12
  isl_space *el_space, *set_space;
111
12
112
12
  if (!set || !el)
113
0
    return isl_bool_error;
114
12
  set_space = isl_set_get_space(set);
115
12
  el_space = FN(EL,get_space)(el);
116
12
  ok = isl_space_is_domain_internal(set_space, el_space);
117
12
  isl_space_free(el_space);
118
12
  isl_space_free(set_space);
119
12
  return ok;
120
12
}
isl_polynomial.c:isl_pw_qpolynomial_compatible_domain
Line
Count
Source
108
33
{
109
33
  isl_bool ok;
110
33
  isl_space *el_space, *set_space;
111
33
112
33
  if (!set || !el)
113
0
    return isl_bool_error;
114
33
  set_space = isl_set_get_space(set);
115
33
  el_space = FN(EL,get_space)(el);
116
33
  ok = isl_space_is_domain_internal(set_space, el_space);
117
33
  isl_space_free(el_space);
118
33
  isl_space_free(set_space);
119
33
  return ok;
120
33
}
121
122
/* Check that the space of "set" corresponds to that of the domain of "el".
123
 */
124
static isl_stat FN(PW,check_compatible_domain)(__isl_keep EL *el,
125
  __isl_keep isl_set *set)
126
107k
{
127
107k
  isl_bool ok;
128
107k
129
107k
  ok = FN(PW,compatible_domain)(el, set);
130
107k
  if (ok < 0)
131
3
    return isl_stat_error;
132
107k
  if (!ok)
133
107k
    
isl_die0
(isl_set_get_ctx(set), isl_error_invalid,
134
107k
      "incompatible spaces", return isl_stat_error);
135
107k
136
107k
  return isl_stat_ok;
137
107k
}
isl_aff.c:isl_pw_aff_check_compatible_domain
Line
Count
Source
126
82.6k
{
127
82.6k
  isl_bool ok;
128
82.6k
129
82.6k
  ok = FN(PW,compatible_domain)(el, set);
130
82.6k
  if (ok < 0)
131
3
    return isl_stat_error;
132
82.6k
  if (!ok)
133
82.6k
    
isl_die0
(isl_set_get_ctx(set), isl_error_invalid,
134
82.6k
      "incompatible spaces", return isl_stat_error);
135
82.6k
136
82.6k
  return isl_stat_ok;
137
82.6k
}
isl_aff.c:isl_pw_multi_aff_check_compatible_domain
Line
Count
Source
126
24.3k
{
127
24.3k
  isl_bool ok;
128
24.3k
129
24.3k
  ok = FN(PW,compatible_domain)(el, set);
130
24.3k
  if (ok < 0)
131
0
    return isl_stat_error;
132
24.3k
  if (!ok)
133
24.3k
    
isl_die0
(isl_set_get_ctx(set), isl_error_invalid,
134
24.3k
      "incompatible spaces", return isl_stat_error);
135
24.3k
136
24.3k
  return isl_stat_ok;
137
24.3k
}
isl_fold.c:isl_pw_qpolynomial_fold_check_compatible_domain
Line
Count
Source
126
12
{
127
12
  isl_bool ok;
128
12
129
12
  ok = FN(PW,compatible_domain)(el, set);
130
12
  if (ok < 0)
131
0
    return isl_stat_error;
132
12
  if (!ok)
133
12
    
isl_die0
(isl_set_get_ctx(set), isl_error_invalid,
134
12
      "incompatible spaces", return isl_stat_error);
135
12
136
12
  return isl_stat_ok;
137
12
}
isl_polynomial.c:isl_pw_qpolynomial_check_compatible_domain
Line
Count
Source
126
33
{
127
33
  isl_bool ok;
128
33
129
33
  ok = FN(PW,compatible_domain)(el, set);
130
33
  if (ok < 0)
131
0
    return isl_stat_error;
132
33
  if (!ok)
133
33
    
isl_die0
(isl_set_get_ctx(set), isl_error_invalid,
134
33
      "incompatible spaces", return isl_stat_error);
135
33
136
33
  return isl_stat_ok;
137
33
}
138
139
#ifdef HAS_TYPE
140
__isl_give PW *FN(PW,alloc)(enum isl_fold type,
141
  __isl_take isl_set *set, __isl_take EL *el)
142
#else
143
__isl_give PW *FN(PW,alloc)(__isl_take isl_set *set, __isl_take EL *el)
144
#endif
145
107k
{
146
107k
  PW *pw;
147
107k
148
107k
  if (FN(PW,check_compatible_domain)(el, set) < 0)
149
3
    goto error;
150
12
151
#ifdef HAS_TYPE
152
12
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
153
#else
154
107k
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
155
#endif
156
157
107k
  return FN(PW,add_piece)(pw, set, el);
158
107k
error:
159
3
  isl_set_free(set);
160
3
  FN(EL,free)(el);
161
3
  return NULL;
162
107k
}
isl_pw_aff_alloc
Line
Count
Source
145
82.6k
{
146
82.6k
  PW *pw;
147
82.6k
148
82.6k
  if (FN(PW,check_compatible_domain)(el, set) < 0)
149
3
    goto error;
150
82.6k
151
#ifdef HAS_TYPE
152
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
153
#else
154
82.6k
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
155
82.6k
#endif
156
82.6k
157
82.6k
  return FN(PW,add_piece)(pw, set, el);
158
82.6k
error:
159
3
  isl_set_free(set);
160
3
  FN(EL,free)(el);
161
3
  return NULL;
162
82.6k
}
isl_pw_multi_aff_alloc
Line
Count
Source
145
24.3k
{
146
24.3k
  PW *pw;
147
24.3k
148
24.3k
  if (FN(PW,check_compatible_domain)(el, set) < 0)
149
0
    goto error;
150
24.3k
151
#ifdef HAS_TYPE
152
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
153
#else
154
24.3k
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
155
24.3k
#endif
156
24.3k
157
24.3k
  return FN(PW,add_piece)(pw, set, el);
158
24.3k
error:
159
0
  isl_set_free(set);
160
0
  FN(EL,free)(el);
161
0
  return NULL;
162
24.3k
}
isl_pw_qpolynomial_fold_alloc
Line
Count
Source
145
12
{
146
12
  PW *pw;
147
12
148
12
  if (FN(PW,check_compatible_domain)(el, set) < 0)
149
0
    goto error;
150
12
151
12
#ifdef HAS_TYPE
152
12
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
153
#else
154
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
155
#endif
156
157
12
  return FN(PW,add_piece)(pw, set, el);
158
12
error:
159
0
  isl_set_free(set);
160
0
  FN(EL,free)(el);
161
0
  return NULL;
162
12
}
isl_pw_qpolynomial_alloc
Line
Count
Source
145
33
{
146
33
  PW *pw;
147
33
148
33
  if (FN(PW,check_compatible_domain)(el, set) < 0)
149
0
    goto error;
150
33
151
#ifdef HAS_TYPE
152
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
153
#else
154
33
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
155
33
#endif
156
33
157
33
  return FN(PW,add_piece)(pw, set, el);
158
33
error:
159
0
  isl_set_free(set);
160
0
  FN(EL,free)(el);
161
0
  return NULL;
162
33
}
163
164
__isl_give PW *FN(PW,dup)(__isl_keep PW *pw)
165
69.3k
{
166
69.3k
  int i;
167
69.3k
  PW *dup;
168
69.3k
169
69.3k
  if (!pw)
170
0
    return NULL;
171
0
172
#ifdef HAS_TYPE
173
0
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
174
#else
175
69.3k
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
176
#endif
177
69.3k
  if (!dup)
178
0
    return NULL;
179
69.3k
180
140k
  
for (i = 0; 69.3k
i < pw->n;
++i71.6k
)
181
71.6k
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
182
71.6k
              FN(EL,copy)(pw->p[i].FIELD));
183
69.3k
184
69.3k
  return dup;
185
69.3k
}
isl_pw_aff_dup
Line
Count
Source
165
67.9k
{
166
67.9k
  int i;
167
67.9k
  PW *dup;
168
67.9k
169
67.9k
  if (!pw)
170
0
    return NULL;
171
67.9k
172
#ifdef HAS_TYPE
173
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
174
#else
175
67.9k
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
176
67.9k
#endif
177
67.9k
  if (!dup)
178
0
    return NULL;
179
67.9k
180
138k
  
for (i = 0; 67.9k
i < pw->n;
++i70.1k
)
181
70.1k
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
182
70.1k
              FN(EL,copy)(pw->p[i].FIELD));
183
67.9k
184
67.9k
  return dup;
185
67.9k
}
isl_pw_multi_aff_dup
Line
Count
Source
165
1.39k
{
166
1.39k
  int i;
167
1.39k
  PW *dup;
168
1.39k
169
1.39k
  if (!pw)
170
0
    return NULL;
171
1.39k
172
#ifdef HAS_TYPE
173
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
174
#else
175
1.39k
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
176
1.39k
#endif
177
1.39k
  if (!dup)
178
0
    return NULL;
179
1.39k
180
2.82k
  
for (i = 0; 1.39k
i < pw->n;
++i1.42k
)
181
1.42k
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
182
1.42k
              FN(EL,copy)(pw->p[i].FIELD));
183
1.39k
184
1.39k
  return dup;
185
1.39k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_dup
isl_pw_qpolynomial_dup
Line
Count
Source
165
1
{
166
1
  int i;
167
1
  PW *dup;
168
1
169
1
  if (!pw)
170
0
    return NULL;
171
1
172
#ifdef HAS_TYPE
173
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
174
#else
175
1
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
176
1
#endif
177
1
  if (!dup)
178
0
    return NULL;
179
1
180
2
  
for (i = 0; 1
i < pw->n;
++i1
)
181
1
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
182
1
              FN(EL,copy)(pw->p[i].FIELD));
183
1
184
1
  return dup;
185
1
}
186
187
__isl_give PW *FN(PW,cow)(__isl_take PW *pw)
188
197k
{
189
197k
  if (!pw)
190
0
    return NULL;
191
197k
192
197k
  if (pw->ref == 1)
193
128k
    return pw;
194
69.3k
  pw->ref--;
195
69.3k
  return FN(PW,dup)(pw);
196
69.3k
}
isl_pw_aff_cow
Line
Count
Source
188
187k
{
189
187k
  if (!pw)
190
0
    return NULL;
191
187k
192
187k
  if (pw->ref == 1)
193
119k
    return pw;
194
67.9k
  pw->ref--;
195
67.9k
  return FN(PW,dup)(pw);
196
67.9k
}
isl_pw_multi_aff_cow
Line
Count
Source
188
10.5k
{
189
10.5k
  if (!pw)
190
0
    return NULL;
191
10.5k
192
10.5k
  if (pw->ref == 1)
193
9.16k
    return pw;
194
1.39k
  pw->ref--;
195
1.39k
  return FN(PW,dup)(pw);
196
1.39k
}
isl_pw_qpolynomial_fold_cow
Line
Count
Source
188
7
{
189
7
  if (!pw)
190
0
    return NULL;
191
7
192
7
  if (pw->ref == 1)
193
7
    return pw;
194
0
  pw->ref--;
195
0
  return FN(PW,dup)(pw);
196
0
}
isl_pw_qpolynomial_cow
Line
Count
Source
188
51
{
189
51
  if (!pw)
190
0
    return NULL;
191
51
192
51
  if (pw->ref == 1)
193
50
    return pw;
194
1
  pw->ref--;
195
1
  return FN(PW,dup)(pw);
196
1
}
197
198
__isl_give PW *FN(PW,copy)(__isl_keep PW *pw)
199
477k
{
200
477k
  if (!pw)
201
46.4k
    return NULL;
202
431k
203
431k
  pw->ref++;
204
431k
  return pw;
205
431k
}
isl_pw_aff_copy
Line
Count
Source
199
435k
{
200
435k
  if (!pw)
201
46.4k
    return NULL;
202
388k
203
388k
  pw->ref++;
204
388k
  return pw;
205
388k
}
isl_pw_multi_aff_copy
Line
Count
Source
199
42.1k
{
200
42.1k
  if (!pw)
201
9
    return NULL;
202
42.1k
203
42.1k
  pw->ref++;
204
42.1k
  return pw;
205
42.1k
}
isl_pw_qpolynomial_fold_copy
Line
Count
Source
199
2
{
200
2
  if (!pw)
201
0
    return NULL;
202
2
203
2
  pw->ref++;
204
2
  return pw;
205
2
}
isl_pw_qpolynomial_copy
Line
Count
Source
199
10
{
200
10
  if (!pw)
201
0
    return NULL;
202
10
203
10
  pw->ref++;
204
10
  return pw;
205
10
}
206
207
__isl_null PW *FN(PW,free)(__isl_take PW *pw)
208
691k
{
209
691k
  int i;
210
691k
211
691k
  if (!pw)
212
48.2k
    return NULL;
213
643k
  if (--pw->ref > 0)
214
361k
    return NULL;
215
281k
216
564k
  
for (i = 0; 281k
i < pw->n;
++i283k
) {
217
283k
    isl_set_free(pw->p[i].set);
218
283k
    FN(EL,free)(pw->p[i].FIELD);
219
283k
  }
220
281k
  isl_space_free(pw->dim);
221
281k
  free(pw);
222
281k
223
281k
  return NULL;
224
281k
}
isl_pw_aff_free
Line
Count
Source
208
617k
{
209
617k
  int i;
210
617k
211
617k
  if (!pw)
212
48.2k
    return NULL;
213
569k
  if (--pw->ref > 0)
214
320k
    return NULL;
215
248k
216
498k
  
for (i = 0; 248k
i < pw->n;
++i250k
) {
217
250k
    isl_set_free(pw->p[i].set);
218
250k
    FN(EL,free)(pw->p[i].FIELD);
219
250k
  }
220
248k
  isl_space_free(pw->dim);
221
248k
  free(pw);
222
248k
223
248k
  return NULL;
224
248k
}
isl_pw_multi_aff_free
Line
Count
Source
208
73.9k
{
209
73.9k
  int i;
210
73.9k
211
73.9k
  if (!pw)
212
3
    return NULL;
213
73.9k
  if (--pw->ref > 0)
214
40.7k
    return NULL;
215
33.2k
216
65.6k
  
for (i = 0; 33.2k
i < pw->n;
++i32.4k
) {
217
32.4k
    isl_set_free(pw->p[i].set);
218
32.4k
    FN(EL,free)(pw->p[i].FIELD);
219
32.4k
  }
220
33.2k
  isl_space_free(pw->dim);
221
33.2k
  free(pw);
222
33.2k
223
33.2k
  return NULL;
224
33.2k
}
isl_pw_qpolynomial_fold_free
Line
Count
Source
208
37
{
209
37
  int i;
210
37
211
37
  if (!pw)
212
0
    return NULL;
213
37
  if (--pw->ref > 0)
214
2
    return NULL;
215
35
216
53
  
for (i = 0; 35
i < pw->n;
++i18
) {
217
18
    isl_set_free(pw->p[i].set);
218
18
    FN(EL,free)(pw->p[i].FIELD);
219
18
  }
220
35
  isl_space_free(pw->dim);
221
35
  free(pw);
222
35
223
35
  return NULL;
224
35
}
isl_pw_qpolynomial_free
Line
Count
Source
208
113
{
209
113
  int i;
210
113
211
113
  if (!pw)
212
0
    return NULL;
213
113
  if (--pw->ref > 0)
214
9
    return NULL;
215
104
216
202
  
for (i = 0; 104
i < pw->n;
++i98
) {
217
98
    isl_set_free(pw->p[i].set);
218
98
    FN(EL,free)(pw->p[i].FIELD);
219
98
  }
220
104
  isl_space_free(pw->dim);
221
104
  free(pw);
222
104
223
104
  return NULL;
224
104
}
225
226
const char *FN(PW,get_dim_name)(__isl_keep PW *pw, enum isl_dim_type type,
227
  unsigned pos)
228
0
{
229
0
  return pw ? isl_space_get_dim_name(pw->dim, type, pos) : NULL;
230
0
}
Unexecuted instantiation: isl_pw_aff_get_dim_name
Unexecuted instantiation: isl_pw_multi_aff_get_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_get_dim_name
231
232
isl_bool FN(PW,has_dim_id)(__isl_keep PW *pw, enum isl_dim_type type,
233
  unsigned pos)
234
0
{
235
0
  return pw ? isl_space_has_dim_id(pw->dim, type, pos) : isl_bool_error;
236
0
}
Unexecuted instantiation: isl_pw_aff_has_dim_id
Unexecuted instantiation: isl_pw_multi_aff_has_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_has_dim_id
237
238
__isl_give isl_id *FN(PW,get_dim_id)(__isl_keep PW *pw, enum isl_dim_type type,
239
  unsigned pos)
240
16
{
241
16
  return pw ? isl_space_get_dim_id(pw->dim, type, pos) : NULL;
242
16
}
isl_pw_aff_get_dim_id
Line
Count
Source
240
16
{
241
16
  return pw ? isl_space_get_dim_id(pw->dim, type, pos) : NULL;
242
16
}
Unexecuted instantiation: isl_pw_multi_aff_get_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_get_dim_id
243
244
isl_bool FN(PW,has_tuple_name)(__isl_keep PW *pw, enum isl_dim_type type)
245
0
{
246
0
  return pw ? isl_space_has_tuple_name(pw->dim, type) : isl_bool_error;
247
0
}
Unexecuted instantiation: isl_pw_aff_has_tuple_name
Unexecuted instantiation: isl_pw_multi_aff_has_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_has_tuple_name
248
249
const char *FN(PW,get_tuple_name)(__isl_keep PW *pw, enum isl_dim_type type)
250
0
{
251
0
  return pw ? isl_space_get_tuple_name(pw->dim, type) : NULL;
252
0
}
Unexecuted instantiation: isl_pw_aff_get_tuple_name
Unexecuted instantiation: isl_pw_multi_aff_get_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_get_tuple_name
253
254
isl_bool FN(PW,has_tuple_id)(__isl_keep PW *pw, enum isl_dim_type type)
255
0
{
256
0
  return pw ? isl_space_has_tuple_id(pw->dim, type) : isl_bool_error;
257
0
}
Unexecuted instantiation: isl_pw_aff_has_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_has_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_has_tuple_id
258
259
__isl_give isl_id *FN(PW,get_tuple_id)(__isl_keep PW *pw, enum isl_dim_type type)
260
346
{
261
346
  return pw ? isl_space_get_tuple_id(pw->dim, type) : NULL;
262
346
}
Unexecuted instantiation: isl_pw_aff_get_tuple_id
isl_pw_multi_aff_get_tuple_id
Line
Count
Source
260
346
{
261
346
  return pw ? isl_space_get_tuple_id(pw->dim, type) : NULL;
262
346
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_get_tuple_id
263
264
isl_bool FN(PW,IS_ZERO)(__isl_keep PW *pw)
265
72.8k
{
266
72.8k
  if (!pw)
267
0
    return isl_bool_error;
268
72.8k
269
72.8k
  return pw->n == 0;
270
72.8k
}
isl_pw_aff_is_empty
Line
Count
Source
265
46.5k
{
266
46.5k
  if (!pw)
267
0
    return isl_bool_error;
268
46.5k
269
46.5k
  return pw->n == 0;
270
46.5k
}
isl_pw_multi_aff_is_empty
Line
Count
Source
265
26.1k
{
266
26.1k
  if (!pw)
267
0
    return isl_bool_error;
268
26.1k
269
26.1k
  return pw->n == 0;
270
26.1k
}
isl_pw_qpolynomial_fold_is_zero
Line
Count
Source
265
26
{
266
26
  if (!pw)
267
0
    return isl_bool_error;
268
26
269
26
  return pw->n == 0;
270
26
}
isl_pw_qpolynomial_is_zero
Line
Count
Source
265
102
{
266
102
  if (!pw)
267
0
    return isl_bool_error;
268
102
269
102
  return pw->n == 0;
270
102
}
271
272
#ifndef NO_REALIGN
273
__isl_give PW *FN(PW,realign_domain)(__isl_take PW *pw,
274
  __isl_take isl_reordering *exp)
275
9.61k
{
276
9.61k
  int i;
277
9.61k
278
9.61k
  pw = FN(PW,cow)(pw);
279
9.61k
  if (!pw || !exp)
280
0
    goto error;
281
9.61k
282
19.7k
  
for (i = 0; 9.61k
i < pw->n;
++i10.1k
) {
283
10.1k
    pw->p[i].set = isl_set_realign(pw->p[i].set,
284
10.1k
                isl_reordering_copy(exp));
285
10.1k
    if (!pw->p[i].set)
286
0
      goto error;
287
10.1k
    pw->p[i].FIELD = FN(EL,realign_domain)(pw->p[i].FIELD,
288
10.1k
                isl_reordering_copy(exp));
289
10.1k
    if (!pw->p[i].FIELD)
290
10.1k
      
goto error0
;
291
10.1k
  }
292
9.61k
293
9.61k
  pw = FN(PW,reset_domain_space)(pw, isl_reordering_get_space(exp));
294
9.61k
295
9.61k
  isl_reordering_free(exp);
296
9.61k
  return pw;
297
9.61k
error:
298
0
  isl_reordering_free(exp);
299
0
  FN(PW,free)(pw);
300
0
  return NULL;
301
9.61k
}
isl_pw_aff_realign_domain
Line
Count
Source
275
9.61k
{
276
9.61k
  int i;
277
9.61k
278
9.61k
  pw = FN(PW,cow)(pw);
279
9.61k
  if (!pw || !exp)
280
0
    goto error;
281
9.61k
282
19.7k
  
for (i = 0; 9.61k
i < pw->n;
++i10.1k
) {
283
10.1k
    pw->p[i].set = isl_set_realign(pw->p[i].set,
284
10.1k
                isl_reordering_copy(exp));
285
10.1k
    if (!pw->p[i].set)
286
0
      goto error;
287
10.1k
    pw->p[i].FIELD = FN(EL,realign_domain)(pw->p[i].FIELD,
288
10.1k
                isl_reordering_copy(exp));
289
10.1k
    if (!pw->p[i].FIELD)
290
10.1k
      
goto error0
;
291
10.1k
  }
292
9.61k
293
9.61k
  pw = FN(PW,reset_domain_space)(pw, isl_reordering_get_space(exp));
294
9.61k
295
9.61k
  isl_reordering_free(exp);
296
9.61k
  return pw;
297
9.61k
error:
298
0
  isl_reordering_free(exp);
299
0
  FN(PW,free)(pw);
300
0
  return NULL;
301
9.61k
}
isl_pw_multi_aff_realign_domain
Line
Count
Source
275
7
{
276
7
  int i;
277
7
278
7
  pw = FN(PW,cow)(pw);
279
7
  if (!pw || !exp)
280
0
    goto error;
281
7
282
14
  
for (i = 0; 7
i < pw->n;
++i7
) {
283
7
    pw->p[i].set = isl_set_realign(pw->p[i].set,
284
7
                isl_reordering_copy(exp));
285
7
    if (!pw->p[i].set)
286
0
      goto error;
287
7
    pw->p[i].FIELD = FN(EL,realign_domain)(pw->p[i].FIELD,
288
7
                isl_reordering_copy(exp));
289
7
    if (!pw->p[i].FIELD)
290
7
      
goto error0
;
291
7
  }
292
7
293
7
  pw = FN(PW,reset_domain_space)(pw, isl_reordering_get_space(exp));
294
7
295
7
  isl_reordering_free(exp);
296
7
  return pw;
297
7
error:
298
0
  isl_reordering_free(exp);
299
0
  FN(PW,free)(pw);
300
0
  return NULL;
301
7
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_realign_domain
Unexecuted instantiation: isl_pw_qpolynomial_realign_domain
302
303
/* Check that "pw" has only named parameters, reporting an error
304
 * if it does not.
305
 */
306
isl_stat FN(PW,check_named_params)(__isl_keep PW *pw)
307
65.7k
{
308
65.7k
  return isl_space_check_named_params(FN(PW,peek_space)(pw));
309
65.7k
}
isl_pw_aff_check_named_params
Line
Count
Source
307
46.2k
{
308
46.2k
  return isl_space_check_named_params(FN(PW,peek_space)(pw));
309
46.2k
}
isl_pw_multi_aff_check_named_params
Line
Count
Source
307
19.4k
{
308
19.4k
  return isl_space_check_named_params(FN(PW,peek_space)(pw));
309
19.4k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_check_named_params
isl_pw_qpolynomial_check_named_params
Line
Count
Source
307
5
{
308
5
  return isl_space_check_named_params(FN(PW,peek_space)(pw));
309
5
}
310
311
/* Align the parameters of "pw" to those of "model".
312
 */
313
__isl_give PW *FN(PW,align_params)(__isl_take PW *pw, __isl_take isl_space *model)
314
55.4k
{
315
55.4k
  isl_ctx *ctx;
316
55.4k
  isl_bool equal_params;
317
55.4k
318
55.4k
  if (!pw || !model)
319
0
    goto error;
320
55.4k
321
55.4k
  ctx = isl_space_get_ctx(model);
322
55.4k
  if (!isl_space_has_named_params(model))
323
55.4k
    
isl_die0
(ctx, isl_error_invalid,
324
55.4k
      "model has unnamed parameters", goto error);
325
55.4k
  if (FN(PW,check_named_params)(pw) < 0)
326
0
    goto error;
327
55.4k
  equal_params = isl_space_has_equal_params(pw->dim, model);
328
55.4k
  if (equal_params < 0)
329
0
    goto error;
330
55.4k
  if (!equal_params) {
331
9.28k
    isl_reordering *exp;
332
9.28k
333
9.28k
    exp = isl_parameter_alignment_reordering(pw->dim, model);
334
9.28k
    exp = isl_reordering_extend_space(exp,
335
9.28k
          FN(PW,get_domain_space)(pw));
336
9.28k
    pw = FN(PW,realign_domain)(pw, exp);
337
9.28k
  }
338
55.4k
339
55.4k
  isl_space_free(model);
340
55.4k
  return pw;
341
55.4k
error:
342
0
  isl_space_free(model);
343
0
  FN(PW,free)(pw);
344
0
  return NULL;
345
55.4k
}
isl_pw_aff_align_params
Line
Count
Source
314
36.0k
{
315
36.0k
  isl_ctx *ctx;
316
36.0k
  isl_bool equal_params;
317
36.0k
318
36.0k
  if (!pw || !model)
319
0
    goto error;
320
36.0k
321
36.0k
  ctx = isl_space_get_ctx(model);
322
36.0k
  if (!isl_space_has_named_params(model))
323
36.0k
    
isl_die0
(ctx, isl_error_invalid,
324
36.0k
      "model has unnamed parameters", goto error);
325
36.0k
  if (FN(PW,check_named_params)(pw) < 0)
326
0
    goto error;
327
36.0k
  equal_params = isl_space_has_equal_params(pw->dim, model);
328
36.0k
  if (equal_params < 0)
329
0
    goto error;
330
36.0k
  if (!equal_params) {
331
9.27k
    isl_reordering *exp;
332
9.27k
333
9.27k
    exp = isl_parameter_alignment_reordering(pw->dim, model);
334
9.27k
    exp = isl_reordering_extend_space(exp,
335
9.27k
          FN(PW,get_domain_space)(pw));
336
9.27k
    pw = FN(PW,realign_domain)(pw, exp);
337
9.27k
  }
338
36.0k
339
36.0k
  isl_space_free(model);
340
36.0k
  return pw;
341
36.0k
error:
342
0
  isl_space_free(model);
343
0
  FN(PW,free)(pw);
344
0
  return NULL;
345
36.0k
}
isl_pw_multi_aff_align_params
Line
Count
Source
314
19.4k
{
315
19.4k
  isl_ctx *ctx;
316
19.4k
  isl_bool equal_params;
317
19.4k
318
19.4k
  if (!pw || !model)
319
0
    goto error;
320
19.4k
321
19.4k
  ctx = isl_space_get_ctx(model);
322
19.4k
  if (!isl_space_has_named_params(model))
323
19.4k
    
isl_die0
(ctx, isl_error_invalid,
324
19.4k
      "model has unnamed parameters", goto error);
325
19.4k
  if (FN(PW,check_named_params)(pw) < 0)
326
0
    goto error;
327
19.4k
  equal_params = isl_space_has_equal_params(pw->dim, model);
328
19.4k
  if (equal_params < 0)
329
0
    goto error;
330
19.4k
  if (!equal_params) {
331
5
    isl_reordering *exp;
332
5
333
5
    exp = isl_parameter_alignment_reordering(pw->dim, model);
334
5
    exp = isl_reordering_extend_space(exp,
335
5
          FN(PW,get_domain_space)(pw));
336
5
    pw = FN(PW,realign_domain)(pw, exp);
337
5
  }
338
19.4k
339
19.4k
  isl_space_free(model);
340
19.4k
  return pw;
341
19.4k
error:
342
0
  isl_space_free(model);
343
0
  FN(PW,free)(pw);
344
0
  return NULL;
345
19.4k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_align_params
isl_pw_qpolynomial_align_params
Line
Count
Source
314
5
{
315
5
  isl_ctx *ctx;
316
5
  isl_bool equal_params;
317
5
318
5
  if (!pw || !model)
319
0
    goto error;
320
5
321
5
  ctx = isl_space_get_ctx(model);
322
5
  if (!isl_space_has_named_params(model))
323
5
    
isl_die0
(ctx, isl_error_invalid,
324
5
      "model has unnamed parameters", goto error);
325
5
  if (FN(PW,check_named_params)(pw) < 0)
326
0
    goto error;
327
5
  equal_params = isl_space_has_equal_params(pw->dim, model);
328
5
  if (equal_params < 0)
329
0
    goto error;
330
5
  if (!equal_params) {
331
0
    isl_reordering *exp;
332
0
333
0
    exp = isl_parameter_alignment_reordering(pw->dim, model);
334
0
    exp = isl_reordering_extend_space(exp,
335
0
          FN(PW,get_domain_space)(pw));
336
0
    pw = FN(PW,realign_domain)(pw, exp);
337
0
  }
338
5
339
5
  isl_space_free(model);
340
5
  return pw;
341
5
error:
342
0
  isl_space_free(model);
343
0
  FN(PW,free)(pw);
344
0
  return NULL;
345
5
}
346
347
static __isl_give PW *FN(PW,align_params_pw_pw_and)(__isl_take PW *pw1,
348
  __isl_take PW *pw2,
349
  __isl_give PW *(*fn)(__isl_take PW *pw1, __isl_take PW *pw2))
350
90.5k
{
351
90.5k
  isl_bool equal_params;
352
90.5k
353
90.5k
  if (!pw1 || 
!pw290.5k
)
354
3
    goto error;
355
90.5k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
356
90.5k
  if (equal_params < 0)
357
0
    goto error;
358
90.5k
  if (equal_params)
359
87.0k
    return fn(pw1, pw2);
360
3.57k
  if (FN(PW,check_named_params)(pw1) < 0 ||
361
3.57k
      FN(PW,check_named_params)(pw2) < 0)
362
0
    goto error;
363
3.57k
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
364
3.57k
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
365
3.57k
  return fn(pw1, pw2);
366
3.57k
error:
367
3
  FN(PW,free)(pw1);
368
3
  FN(PW,free)(pw2);
369
3
  return NULL;
370
3.57k
}
isl_aff.c:isl_pw_aff_align_params_pw_pw_and
Line
Count
Source
350
84.0k
{
351
84.0k
  isl_bool equal_params;
352
84.0k
353
84.0k
  if (!pw1 || 
!pw284.0k
)
354
3
    goto error;
355
84.0k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
356
84.0k
  if (equal_params < 0)
357
0
    goto error;
358
84.0k
  if (equal_params)
359
80.5k
    return fn(pw1, pw2);
360
3.57k
  if (FN(PW,check_named_params)(pw1) < 0 ||
361
3.57k
      FN(PW,check_named_params)(pw2) < 0)
362
0
    goto error;
363
3.57k
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
364
3.57k
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
365
3.57k
  return fn(pw1, pw2);
366
3.57k
error:
367
3
  FN(PW,free)(pw1);
368
3
  FN(PW,free)(pw2);
369
3
  return NULL;
370
3.57k
}
isl_aff.c:isl_pw_multi_aff_align_params_pw_pw_and
Line
Count
Source
350
6.48k
{
351
6.48k
  isl_bool equal_params;
352
6.48k
353
6.48k
  if (!pw1 || !pw2)
354
0
    goto error;
355
6.48k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
356
6.48k
  if (equal_params < 0)
357
0
    goto error;
358
6.48k
  if (equal_params)
359
6.48k
    return fn(pw1, pw2);
360
0
  if (FN(PW,check_named_params)(pw1) < 0 ||
361
0
      FN(PW,check_named_params)(pw2) < 0)
362
0
    goto error;
363
0
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
364
0
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
365
0
  return fn(pw1, pw2);
366
0
error:
367
0
  FN(PW,free)(pw1);
368
0
  FN(PW,free)(pw2);
369
0
  return NULL;
370
0
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_align_params_pw_pw_and
isl_polynomial.c:isl_pw_qpolynomial_align_params_pw_pw_and
Line
Count
Source
350
26
{
351
26
  isl_bool equal_params;
352
26
353
26
  if (!pw1 || !pw2)
354
0
    goto error;
355
26
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
356
26
  if (equal_params < 0)
357
0
    goto error;
358
26
  if (equal_params)
359
26
    return fn(pw1, pw2);
360
0
  if (FN(PW,check_named_params)(pw1) < 0 ||
361
0
      FN(PW,check_named_params)(pw2) < 0)
362
0
    goto error;
363
0
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
364
0
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
365
0
  return fn(pw1, pw2);
366
0
error:
367
0
  FN(PW,free)(pw1);
368
0
  FN(PW,free)(pw2);
369
0
  return NULL;
370
0
}
371
372
static __isl_give PW *FN(PW,align_params_pw_set_and)(__isl_take PW *pw,
373
  __isl_take isl_set *set,
374
  __isl_give PW *(*fn)(__isl_take PW *pw, __isl_take isl_set *set))
375
58.7k
{
376
58.7k
  isl_ctx *ctx;
377
58.7k
  isl_bool aligned;
378
58.7k
379
58.7k
  if (!pw || !set)
380
0
    goto error;
381
58.7k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
382
58.7k
  if (aligned < 0)
383
0
    goto error;
384
58.7k
  if (aligned)
385
58.7k
    return fn(pw, set);
386
2
  ctx = FN(PW,get_ctx)(pw);
387
2
  if (FN(PW,check_named_params)(pw) < 0)
388
0
    goto error;
389
2
  if (!isl_space_has_named_params(set->dim))
390
2
    
isl_die0
(ctx, isl_error_invalid,
391
2
      "unaligned unnamed parameters", goto error);
392
2
  pw = FN(PW,align_params)(pw, isl_set_get_space(set));
393
2
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
394
2
  return fn(pw, set);
395
2
error:
396
0
  FN(PW,free)(pw);
397
0
  isl_set_free(set);
398
0
  return NULL;
399
2
}
isl_aff.c:isl_pw_aff_align_params_pw_set_and
Line
Count
Source
375
53.6k
{
376
53.6k
  isl_ctx *ctx;
377
53.6k
  isl_bool aligned;
378
53.6k
379
53.6k
  if (!pw || !set)
380
0
    goto error;
381
53.6k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
382
53.6k
  if (aligned < 0)
383
0
    goto error;
384
53.6k
  if (aligned)
385
53.6k
    return fn(pw, set);
386
2
  ctx = FN(PW,get_ctx)(pw);
387
2
  if (FN(PW,check_named_params)(pw) < 0)
388
0
    goto error;
389
2
  if (!isl_space_has_named_params(set->dim))
390
2
    
isl_die0
(ctx, isl_error_invalid,
391
2
      "unaligned unnamed parameters", goto error);
392
2
  pw = FN(PW,align_params)(pw, isl_set_get_space(set));
393
2
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
394
2
  return fn(pw, set);
395
2
error:
396
0
  FN(PW,free)(pw);
397
0
  isl_set_free(set);
398
0
  return NULL;
399
2
}
isl_aff.c:isl_pw_multi_aff_align_params_pw_set_and
Line
Count
Source
375
5.12k
{
376
5.12k
  isl_ctx *ctx;
377
5.12k
  isl_bool aligned;
378
5.12k
379
5.12k
  if (!pw || !set)
380
0
    goto error;
381
5.12k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
382
5.12k
  if (aligned < 0)
383
0
    goto error;
384
5.12k
  if (aligned)
385
5.12k
    return fn(pw, set);
386
0
  ctx = FN(PW,get_ctx)(pw);
387
0
  if (FN(PW,check_named_params)(pw) < 0)
388
0
    goto error;
389
0
  if (!isl_space_has_named_params(set->dim))
390
0
    isl_die(ctx, isl_error_invalid,
391
0
      "unaligned unnamed parameters", goto error);
392
0
  pw = FN(PW,align_params)(pw, isl_set_get_space(set));
393
0
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
394
0
  return fn(pw, set);
395
0
error:
396
0
  FN(PW,free)(pw);
397
0
  isl_set_free(set);
398
0
  return NULL;
399
0
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_align_params_pw_set_and
isl_polynomial.c:isl_pw_qpolynomial_align_params_pw_set_and
Line
Count
Source
375
39
{
376
39
  isl_ctx *ctx;
377
39
  isl_bool aligned;
378
39
379
39
  if (!pw || !set)
380
0
    goto error;
381
39
  aligned = isl_set_space_has_equal_params(set, pw->dim);
382
39
  if (aligned < 0)
383
0
    goto error;
384
39
  if (aligned)
385
39
    return fn(pw, set);
386
0
  ctx = FN(PW,get_ctx)(pw);
387
0
  if (FN(PW,check_named_params)(pw) < 0)
388
0
    goto error;
389
0
  if (!isl_space_has_named_params(set->dim))
390
0
    isl_die(ctx, isl_error_invalid,
391
0
      "unaligned unnamed parameters", goto error);
392
0
  pw = FN(PW,align_params)(pw, isl_set_get_space(set));
393
0
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
394
0
  return fn(pw, set);
395
0
error:
396
0
  FN(PW,free)(pw);
397
0
  isl_set_free(set);
398
0
  return NULL;
399
0
}
400
#endif
401
402
static __isl_give PW *FN(PW,union_add_aligned)(__isl_take PW *pw1,
403
  __isl_take PW *pw2)
404
3.96k
{
405
3.96k
  int i, j, n;
406
3.96k
  struct PW *res;
407
3.96k
  isl_ctx *ctx;
408
3.96k
  isl_set *set;
409
3.96k
410
3.96k
  if (!pw1 || !pw2)
411
0
    goto error;
412
3.96k
413
3.96k
  ctx = isl_space_get_ctx(pw1->dim);
414
#ifdef HAS_TYPE
415
0
  if (pw1->type != pw2->type)
416
0
    isl_die(ctx, isl_error_invalid,
417
      "fold types don't match", goto error);
418
#endif
419
3.96k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
420
0
421
3.96k
  if (FN(PW,IS_ZERO)(pw1)) {
422
3.51k
    FN(PW,free)(pw1);
423
3.51k
    return pw2;
424
3.51k
  }
425
447
426
447
  if (FN(PW,IS_ZERO)(pw2)) {
427
290
    FN(PW,free)(pw2);
428
290
    return pw1;
429
290
  }
430
157
431
157
  n = (pw1->n + 1) * (pw2->n + 1);
432
#ifdef HAS_TYPE
433
0
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
434
#else
435
157
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
436
#endif
437
438
349
  for (i = 0; i < pw1->n; 
++i192
) {
439
192
    set = isl_set_copy(pw1->p[i].set);
440
386
    for (j = 0; j < pw2->n; 
++j194
) {
441
194
      struct isl_set *common;
442
194
      EL *sum;
443
194
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
444
194
            isl_set_copy(pw2->p[j].set));
445
194
      if (isl_set_plain_is_empty(common)) {
446
168
        isl_set_free(common);
447
168
        continue;
448
168
      }
449
26
      set = isl_set_subtract(set,
450
26
          isl_set_copy(pw2->p[j].set));
451
26
452
26
      sum = FN(EL,add_on_domain)(common,
453
26
               FN(EL,copy)(pw1->p[i].FIELD),
454
26
               FN(EL,copy)(pw2->p[j].FIELD));
455
26
456
26
      res = FN(PW,add_piece)(res, common, sum);
457
26
    }
458
192
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw1->p[i].FIELD));
459
192
  }
460
157
461
315
  for (j = 0; j < pw2->n; 
++j158
) {
462
158
    set = isl_set_copy(pw2->p[j].set);
463
352
    for (i = 0; i < pw1->n; 
++i194
)
464
194
      set = isl_set_subtract(set,
465
194
          isl_set_copy(pw1->p[i].set));
466
158
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw2->p[j].FIELD));
467
158
  }
468
157
469
157
  FN(PW,free)(pw1);
470
157
  FN(PW,free)(pw2);
471
157
472
157
  return res;
473
157
error:
474
0
  FN(PW,free)(pw1);
475
0
  FN(PW,free)(pw2);
476
0
  return NULL;
477
157
}
isl_aff.c:isl_pw_aff_union_add_aligned
Line
Count
Source
404
3.47k
{
405
3.47k
  int i, j, n;
406
3.47k
  struct PW *res;
407
3.47k
  isl_ctx *ctx;
408
3.47k
  isl_set *set;
409
3.47k
410
3.47k
  if (!pw1 || !pw2)
411
0
    goto error;
412
3.47k
413
3.47k
  ctx = isl_space_get_ctx(pw1->dim);
414
#ifdef HAS_TYPE
415
  if (pw1->type != pw2->type)
416
    isl_die(ctx, isl_error_invalid,
417
      "fold types don't match", goto error);
418
#endif
419
3.47k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
420
3.47k
421
3.47k
  if (FN(PW,IS_ZERO)(pw1)) {
422
3.38k
    FN(PW,free)(pw1);
423
3.38k
    return pw2;
424
3.38k
  }
425
84
426
84
  if (FN(PW,IS_ZERO)(pw2)) {
427
0
    FN(PW,free)(pw2);
428
0
    return pw1;
429
0
  }
430
84
431
84
  n = (pw1->n + 1) * (pw2->n + 1);
432
#ifdef HAS_TYPE
433
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
434
#else
435
84
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
436
84
#endif
437
84
438
169
  for (i = 0; i < pw1->n; 
++i85
) {
439
85
    set = isl_set_copy(pw1->p[i].set);
440
170
    for (j = 0; j < pw2->n; 
++j85
) {
441
85
      struct isl_set *common;
442
85
      EL *sum;
443
85
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
444
85
            isl_set_copy(pw2->p[j].set));
445
85
      if (isl_set_plain_is_empty(common)) {
446
83
        isl_set_free(common);
447
83
        continue;
448
83
      }
449
2
      set = isl_set_subtract(set,
450
2
          isl_set_copy(pw2->p[j].set));
451
2
452
2
      sum = FN(EL,add_on_domain)(common,
453
2
               FN(EL,copy)(pw1->p[i].FIELD),
454
2
               FN(EL,copy)(pw2->p[j].FIELD));
455
2
456
2
      res = FN(PW,add_piece)(res, common, sum);
457
2
    }
458
85
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw1->p[i].FIELD));
459
85
  }
460
84
461
168
  for (j = 0; j < pw2->n; 
++j84
) {
462
84
    set = isl_set_copy(pw2->p[j].set);
463
169
    for (i = 0; i < pw1->n; 
++i85
)
464
85
      set = isl_set_subtract(set,
465
85
          isl_set_copy(pw1->p[i].set));
466
84
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw2->p[j].FIELD));
467
84
  }
468
84
469
84
  FN(PW,free)(pw1);
470
84
  FN(PW,free)(pw2);
471
84
472
84
  return res;
473
84
error:
474
0
  FN(PW,free)(pw1);
475
0
  FN(PW,free)(pw2);
476
0
  return NULL;
477
84
}
isl_aff.c:isl_pw_multi_aff_union_add_aligned
Line
Count
Source
404
464
{
405
464
  int i, j, n;
406
464
  struct PW *res;
407
464
  isl_ctx *ctx;
408
464
  isl_set *set;
409
464
410
464
  if (!pw1 || !pw2)
411
0
    goto error;
412
464
413
464
  ctx = isl_space_get_ctx(pw1->dim);
414
#ifdef HAS_TYPE
415
  if (pw1->type != pw2->type)
416
    isl_die(ctx, isl_error_invalid,
417
      "fold types don't match", goto error);
418
#endif
419
464
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
420
464
421
464
  if (FN(PW,IS_ZERO)(pw1)) {
422
125
    FN(PW,free)(pw1);
423
125
    return pw2;
424
125
  }
425
339
426
339
  if (FN(PW,IS_ZERO)(pw2)) {
427
290
    FN(PW,free)(pw2);
428
290
    return pw1;
429
290
  }
430
49
431
49
  n = (pw1->n + 1) * (pw2->n + 1);
432
#ifdef HAS_TYPE
433
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
434
#else
435
49
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
436
49
#endif
437
49
438
131
  for (i = 0; i < pw1->n; 
++i82
) {
439
82
    set = isl_set_copy(pw1->p[i].set);
440
164
    for (j = 0; j < pw2->n; 
++j82
) {
441
82
      struct isl_set *common;
442
82
      EL *sum;
443
82
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
444
82
            isl_set_copy(pw2->p[j].set));
445
82
      if (isl_set_plain_is_empty(common)) {
446
80
        isl_set_free(common);
447
80
        continue;
448
80
      }
449
2
      set = isl_set_subtract(set,
450
2
          isl_set_copy(pw2->p[j].set));
451
2
452
2
      sum = FN(EL,add_on_domain)(common,
453
2
               FN(EL,copy)(pw1->p[i].FIELD),
454
2
               FN(EL,copy)(pw2->p[j].FIELD));
455
2
456
2
      res = FN(PW,add_piece)(res, common, sum);
457
2
    }
458
82
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw1->p[i].FIELD));
459
82
  }
460
49
461
98
  for (j = 0; j < pw2->n; 
++j49
) {
462
49
    set = isl_set_copy(pw2->p[j].set);
463
131
    for (i = 0; i < pw1->n; 
++i82
)
464
82
      set = isl_set_subtract(set,
465
82
          isl_set_copy(pw1->p[i].set));
466
49
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw2->p[j].FIELD));
467
49
  }
468
49
469
49
  FN(PW,free)(pw1);
470
49
  FN(PW,free)(pw2);
471
49
472
49
  return res;
473
49
error:
474
0
  FN(PW,free)(pw1);
475
0
  FN(PW,free)(pw2);
476
0
  return NULL;
477
49
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_union_add_aligned
isl_polynomial.c:isl_pw_qpolynomial_union_add_aligned
Line
Count
Source
404
24
{
405
24
  int i, j, n;
406
24
  struct PW *res;
407
24
  isl_ctx *ctx;
408
24
  isl_set *set;
409
24
410
24
  if (!pw1 || !pw2)
411
0
    goto error;
412
24
413
24
  ctx = isl_space_get_ctx(pw1->dim);
414
#ifdef HAS_TYPE
415
  if (pw1->type != pw2->type)
416
    isl_die(ctx, isl_error_invalid,
417
      "fold types don't match", goto error);
418
#endif
419
24
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
420
24
421
24
  if (FN(PW,IS_ZERO)(pw1)) {
422
0
    FN(PW,free)(pw1);
423
0
    return pw2;
424
0
  }
425
24
426
24
  if (FN(PW,IS_ZERO)(pw2)) {
427
0
    FN(PW,free)(pw2);
428
0
    return pw1;
429
0
  }
430
24
431
24
  n = (pw1->n + 1) * (pw2->n + 1);
432
#ifdef HAS_TYPE
433
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
434
#else
435
24
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
436
24
#endif
437
24
438
49
  for (i = 0; i < pw1->n; 
++i25
) {
439
25
    set = isl_set_copy(pw1->p[i].set);
440
52
    for (j = 0; j < pw2->n; 
++j27
) {
441
27
      struct isl_set *common;
442
27
      EL *sum;
443
27
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
444
27
            isl_set_copy(pw2->p[j].set));
445
27
      if (isl_set_plain_is_empty(common)) {
446
5
        isl_set_free(common);
447
5
        continue;
448
5
      }
449
22
      set = isl_set_subtract(set,
450
22
          isl_set_copy(pw2->p[j].set));
451
22
452
22
      sum = FN(EL,add_on_domain)(common,
453
22
               FN(EL,copy)(pw1->p[i].FIELD),
454
22
               FN(EL,copy)(pw2->p[j].FIELD));
455
22
456
22
      res = FN(PW,add_piece)(res, common, sum);
457
22
    }
458
25
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw1->p[i].FIELD));
459
25
  }
460
24
461
49
  for (j = 0; j < pw2->n; 
++j25
) {
462
25
    set = isl_set_copy(pw2->p[j].set);
463
52
    for (i = 0; i < pw1->n; 
++i27
)
464
27
      set = isl_set_subtract(set,
465
27
          isl_set_copy(pw1->p[i].set));
466
25
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw2->p[j].FIELD));
467
25
  }
468
24
469
24
  FN(PW,free)(pw1);
470
24
  FN(PW,free)(pw2);
471
24
472
24
  return res;
473
24
error:
474
0
  FN(PW,free)(pw1);
475
0
  FN(PW,free)(pw2);
476
0
  return NULL;
477
24
}
478
479
/* Private version of "union_add".  For isl_pw_qpolynomial and
480
 * isl_pw_qpolynomial_fold, we prefer to simply call it "add".
481
 */
482
static __isl_give PW *FN(PW,union_add_)(__isl_take PW *pw1, __isl_take PW *pw2)
483
3.96k
{
484
3.96k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
485
3.96k
            &FN(PW,union_add_aligned));
486
3.96k
}
isl_aff.c:isl_pw_aff_union_add_
Line
Count
Source
483
3.47k
{
484
3.47k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
485
3.47k
            &FN(PW,union_add_aligned));
486
3.47k
}
isl_aff.c:isl_pw_multi_aff_union_add_
Line
Count
Source
483
464
{
484
464
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
485
464
            &FN(PW,union_add_aligned));
486
464
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_union_add_
isl_polynomial.c:isl_pw_qpolynomial_union_add_
Line
Count
Source
483
24
{
484
24
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
485
24
            &FN(PW,union_add_aligned));
486
24
}
487
488
/* Make sure "pw" has room for at least "n" more pieces.
489
 *
490
 * If there is only one reference to pw, we extend it in place.
491
 * Otherwise, we create a new PW and copy the pieces.
492
 */
493
static __isl_give PW *FN(PW,grow)(__isl_take PW *pw, int n)
494
497
{
495
497
  int i;
496
497
  isl_ctx *ctx;
497
497
  PW *res;
498
497
499
497
  if (!pw)
500
0
    return NULL;
501
497
  if (pw->n + n <= pw->size)
502
0
    return pw;
503
497
  ctx = FN(PW,get_ctx)(pw);
504
497
  n += pw->n;
505
497
  if (pw->ref == 1) {
506
497
    res = isl_realloc(ctx, pw, struct PW,
507
497
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
508
497
    if (!res)
509
0
      return FN(PW,free)(pw);
510
497
    res->size = n;
511
497
    return res;
512
497
  }
513
#ifdef HAS_TYPE
514
0
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
515
#else
516
0
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
517
#endif
518
0
  if (!res)
519
0
    return FN(PW,free)(pw);
520
0
  for (i = 0; i < pw->n; ++i)
521
0
    res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
522
0
              FN(EL,copy)(pw->p[i].FIELD));
523
0
  FN(PW,free)(pw);
524
0
  return res;
525
0
}
isl_aff.c:isl_pw_aff_grow
Line
Count
Source
494
388
{
495
388
  int i;
496
388
  isl_ctx *ctx;
497
388
  PW *res;
498
388
499
388
  if (!pw)
500
0
    return NULL;
501
388
  if (pw->n + n <= pw->size)
502
0
    return pw;
503
388
  ctx = FN(PW,get_ctx)(pw);
504
388
  n += pw->n;
505
388
  if (pw->ref == 1) {
506
388
    res = isl_realloc(ctx, pw, struct PW,
507
388
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
508
388
    if (!res)
509
0
      return FN(PW,free)(pw);
510
388
    res->size = n;
511
388
    return res;
512
388
  }
513
#ifdef HAS_TYPE
514
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
515
#else
516
0
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
517
0
#endif
518
0
  if (!res)
519
0
    return FN(PW,free)(pw);
520
0
  for (i = 0; i < pw->n; ++i)
521
0
    res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
522
0
              FN(EL,copy)(pw->p[i].FIELD));
523
0
  FN(PW,free)(pw);
524
0
  return res;
525
0
}
isl_aff.c:isl_pw_multi_aff_grow
Line
Count
Source
494
108
{
495
108
  int i;
496
108
  isl_ctx *ctx;
497
108
  PW *res;
498
108
499
108
  if (!pw)
500
0
    return NULL;
501
108
  if (pw->n + n <= pw->size)
502
0
    return pw;
503
108
  ctx = FN(PW,get_ctx)(pw);
504
108
  n += pw->n;
505
108
  if (pw->ref == 1) {
506
108
    res = isl_realloc(ctx, pw, struct PW,
507
108
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
508
108
    if (!res)
509
0
      return FN(PW,free)(pw);
510
108
    res->size = n;
511
108
    return res;
512
108
  }
513
#ifdef HAS_TYPE
514
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
515
#else
516
0
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
517
0
#endif
518
0
  if (!res)
519
0
    return FN(PW,free)(pw);
520
0
  for (i = 0; i < pw->n; ++i)
521
0
    res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
522
0
              FN(EL,copy)(pw->p[i].FIELD));
523
0
  FN(PW,free)(pw);
524
0
  return res;
525
0
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_grow
isl_polynomial.c:isl_pw_qpolynomial_grow
Line
Count
Source
494
1
{
495
1
  int i;
496
1
  isl_ctx *ctx;
497
1
  PW *res;
498
1
499
1
  if (!pw)
500
0
    return NULL;
501
1
  if (pw->n + n <= pw->size)
502
0
    return pw;
503
1
  ctx = FN(PW,get_ctx)(pw);
504
1
  n += pw->n;
505
1
  if (pw->ref == 1) {
506
1
    res = isl_realloc(ctx, pw, struct PW,
507
1
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
508
1
    if (!res)
509
0
      return FN(PW,free)(pw);
510
1
    res->size = n;
511
1
    return res;
512
1
  }
513
#ifdef HAS_TYPE
514
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
515
#else
516
0
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
517
0
#endif
518
0
  if (!res)
519
0
    return FN(PW,free)(pw);
520
0
  for (i = 0; i < pw->n; ++i)
521
0
    res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
522
0
              FN(EL,copy)(pw->p[i].FIELD));
523
0
  FN(PW,free)(pw);
524
0
  return res;
525
0
}
526
527
static __isl_give PW *FN(PW,add_disjoint_aligned)(__isl_take PW *pw1,
528
  __isl_take PW *pw2)
529
8.88k
{
530
8.88k
  int i;
531
8.88k
  isl_ctx *ctx;
532
8.88k
533
8.88k
  if (!pw1 || !pw2)
534
0
    goto error;
535
8.88k
536
8.88k
  if (pw1->size < pw1->n + pw2->n && 
pw1->n < pw2->n4.55k
)
537
4.05k
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
538
4.82k
539
4.82k
  ctx = isl_space_get_ctx(pw1->dim);
540
#ifdef HAS_TYPE
541
0
  if (pw1->type != pw2->type)
542
0
    isl_die(ctx, isl_error_invalid,
543
      "fold types don't match", goto error);
544
#endif
545
4.82k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
546
0
547
4.82k
  if (FN(PW,IS_ZERO)(pw1)) {
548
238
    FN(PW,free)(pw1);
549
238
    return pw2;
550
238
  }
551
4.59k
552
4.59k
  if (FN(PW,IS_ZERO)(pw2)) {
553
4.09k
    FN(PW,free)(pw2);
554
4.09k
    return pw1;
555
4.09k
  }
556
497
557
497
  pw1 = FN(PW,grow)(pw1, pw2->n);
558
497
  if (!pw1)
559
0
    goto error;
560
497
561
996
  
for (i = 0; 497
i < pw2->n;
++i499
)
562
499
    pw1 = FN(PW,add_piece)(pw1,
563
499
        isl_set_copy(pw2->p[i].set),
564
499
        FN(EL,copy)(pw2->p[i].FIELD));
565
497
566
497
  FN(PW,free)(pw2);
567
497
568
497
  return pw1;
569
497
error:
570
0
  FN(PW,free)(pw1);
571
0
  FN(PW,free)(pw2);
572
0
  return NULL;
573
497
}
isl_aff.c:isl_pw_aff_add_disjoint_aligned
Line
Count
Source
529
674
{
530
674
  int i;
531
674
  isl_ctx *ctx;
532
674
533
674
  if (!pw1 || !pw2)
534
0
    goto error;
535
674
536
674
  if (pw1->size < pw1->n + pw2->n && 
pw1->n < pw2->n394
)
537
6
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
538
668
539
668
  ctx = isl_space_get_ctx(pw1->dim);
540
#ifdef HAS_TYPE
541
  if (pw1->type != pw2->type)
542
    isl_die(ctx, isl_error_invalid,
543
      "fold types don't match", goto error);
544
#endif
545
668
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
546
668
547
668
  if (FN(PW,IS_ZERO)(pw1)) {
548
238
    FN(PW,free)(pw1);
549
238
    return pw2;
550
238
  }
551
430
552
430
  if (FN(PW,IS_ZERO)(pw2)) {
553
42
    FN(PW,free)(pw2);
554
42
    return pw1;
555
42
  }
556
388
557
388
  pw1 = FN(PW,grow)(pw1, pw2->n);
558
388
  if (!pw1)
559
0
    goto error;
560
388
561
778
  
for (i = 0; 388
i < pw2->n;
++i390
)
562
390
    pw1 = FN(PW,add_piece)(pw1,
563
390
        isl_set_copy(pw2->p[i].set),
564
390
        FN(EL,copy)(pw2->p[i].FIELD));
565
388
566
388
  FN(PW,free)(pw2);
567
388
568
388
  return pw1;
569
388
error:
570
0
  FN(PW,free)(pw1);
571
0
  FN(PW,free)(pw2);
572
0
  return NULL;
573
388
}
isl_aff.c:isl_pw_multi_aff_add_disjoint_aligned
Line
Count
Source
529
8.20k
{
530
8.20k
  int i;
531
8.20k
  isl_ctx *ctx;
532
8.20k
533
8.20k
  if (!pw1 || !pw2)
534
0
    goto error;
535
8.20k
536
8.20k
  if (pw1->size < pw1->n + pw2->n && 
pw1->n < pw2->n4.15k
)
537
4.05k
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
538
4.15k
539
4.15k
  ctx = isl_space_get_ctx(pw1->dim);
540
#ifdef HAS_TYPE
541
  if (pw1->type != pw2->type)
542
    isl_die(ctx, isl_error_invalid,
543
      "fold types don't match", goto error);
544
#endif
545
4.15k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
546
4.15k
547
4.15k
  if (FN(PW,IS_ZERO)(pw1)) {
548
0
    FN(PW,free)(pw1);
549
0
    return pw2;
550
0
  }
551
4.15k
552
4.15k
  if (FN(PW,IS_ZERO)(pw2)) {
553
4.05k
    FN(PW,free)(pw2);
554
4.05k
    return pw1;
555
4.05k
  }
556
108
557
108
  pw1 = FN(PW,grow)(pw1, pw2->n);
558
108
  if (!pw1)
559
0
    goto error;
560
108
561
216
  
for (i = 0; 108
i < pw2->n;
++i108
)
562
108
    pw1 = FN(PW,add_piece)(pw1,
563
108
        isl_set_copy(pw2->p[i].set),
564
108
        FN(EL,copy)(pw2->p[i].FIELD));
565
108
566
108
  FN(PW,free)(pw2);
567
108
568
108
  return pw1;
569
108
error:
570
0
  FN(PW,free)(pw1);
571
0
  FN(PW,free)(pw2);
572
0
  return NULL;
573
108
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_add_disjoint_aligned
isl_polynomial.c:isl_pw_qpolynomial_add_disjoint_aligned
Line
Count
Source
529
3
{
530
3
  int i;
531
3
  isl_ctx *ctx;
532
3
533
3
  if (!pw1 || !pw2)
534
0
    goto error;
535
3
536
3
  if (pw1->size < pw1->n + pw2->n && 
pw1->n < pw2->n2
)
537
1
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
538
2
539
2
  ctx = isl_space_get_ctx(pw1->dim);
540
#ifdef HAS_TYPE
541
  if (pw1->type != pw2->type)
542
    isl_die(ctx, isl_error_invalid,
543
      "fold types don't match", goto error);
544
#endif
545
2
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
546
2
547
2
  if (FN(PW,IS_ZERO)(pw1)) {
548
0
    FN(PW,free)(pw1);
549
0
    return pw2;
550
0
  }
551
2
552
2
  if (FN(PW,IS_ZERO)(pw2)) {
553
1
    FN(PW,free)(pw2);
554
1
    return pw1;
555
1
  }
556
1
557
1
  pw1 = FN(PW,grow)(pw1, pw2->n);
558
1
  if (!pw1)
559
0
    goto error;
560
1
561
2
  
for (i = 0; 1
i < pw2->n;
++i1
)
562
1
    pw1 = FN(PW,add_piece)(pw1,
563
1
        isl_set_copy(pw2->p[i].set),
564
1
        FN(EL,copy)(pw2->p[i].FIELD));
565
1
566
1
  FN(PW,free)(pw2);
567
1
568
1
  return pw1;
569
1
error:
570
0
  FN(PW,free)(pw1);
571
0
  FN(PW,free)(pw2);
572
0
  return NULL;
573
1
}
574
575
__isl_give PW *FN(PW,add_disjoint)(__isl_take PW *pw1, __isl_take PW *pw2)
576
4.82k
{
577
4.82k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
578
4.82k
            &FN(PW,add_disjoint_aligned));
579
4.82k
}
isl_pw_aff_add_disjoint
Line
Count
Source
576
668
{
577
668
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
578
668
            &FN(PW,add_disjoint_aligned));
579
668
}
isl_pw_multi_aff_add_disjoint
Line
Count
Source
576
4.15k
{
577
4.15k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
578
4.15k
            &FN(PW,add_disjoint_aligned));
579
4.15k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_add_disjoint
isl_pw_qpolynomial_add_disjoint
Line
Count
Source
576
2
{
577
2
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
578
2
            &FN(PW,add_disjoint_aligned));
579
2
}
580
581
/* This function is currently only used from isl_aff.c
582
 */
583
static __isl_give PW *FN(PW,on_shared_domain_in)(__isl_take PW *pw1,
584
  __isl_take PW *pw2, __isl_take isl_space *space,
585
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
586
  __attribute__ ((unused));
587
588
/* Apply "fn" to pairs of elements from pw1 and pw2 on shared domains.
589
 * The result of "fn" (and therefore also of this function) lives in "space".
590
 */
591
static __isl_give PW *FN(PW,on_shared_domain_in)(__isl_take PW *pw1,
592
  __isl_take PW *pw2, __isl_take isl_space *space,
593
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
594
79.6k
{
595
79.6k
  int i, j, n;
596
79.6k
  PW *res = NULL;
597
79.6k
598
79.6k
  if (!pw1 || !pw2)
599
0
    goto error;
600
79.6k
601
79.6k
  n = pw1->n * pw2->n;
602
#ifdef HAS_TYPE
603
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
604
#else
605
79.6k
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
606
79.6k
#endif
607
79.6k
608
162k
  for (i = 0; i < pw1->n; 
++i82.5k
) {
609
169k
    for (j = 0; j < pw2->n; 
++j86.8k
) {
610
86.8k
      isl_set *common;
611
86.8k
      EL *res_ij;
612
86.8k
      int empty;
613
86.8k
614
86.8k
      common = isl_set_intersect(
615
86.8k
          isl_set_copy(pw1->p[i].set),
616
86.8k
          isl_set_copy(pw2->p[j].set));
617
86.8k
      empty = isl_set_plain_is_empty(common);
618
86.8k
      if (empty < 0 || empty) {
619
4.00k
        isl_set_free(common);
620
4.00k
        if (empty < 0)
621
0
          goto error;
622
4.00k
        continue;
623
4.00k
      }
624
82.8k
625
82.8k
      res_ij = fn(FN(EL,copy)(pw1->p[i].FIELD),
626
82.8k
            FN(EL,copy)(pw2->p[j].FIELD));
627
82.8k
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
628
82.8k
629
82.8k
      res = FN(PW,add_piece)(res, common, res_ij);
630
82.8k
    }
631
82.5k
  }
632
79.6k
633
79.6k
  isl_space_free(space);
634
79.6k
  FN(PW,free)(pw1);
635
79.6k
  FN(PW,free)(pw2);
636
79.6k
  return res;
637
79.6k
error:
638
0
  isl_space_free(space);
639
0
  FN(PW,free)(pw1);
640
0
  FN(PW,free)(pw2);
641
0
  FN(PW,free)(res);
642
0
  return NULL;
643
79.6k
}
isl_aff.c:isl_pw_aff_on_shared_domain_in
Line
Count
Source
594
79.4k
{
595
79.4k
  int i, j, n;
596
79.4k
  PW *res = NULL;
597
79.4k
598
79.4k
  if (!pw1 || !pw2)
599
0
    goto error;
600
79.4k
601
79.4k
  n = pw1->n * pw2->n;
602
#ifdef HAS_TYPE
603
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
604
#else
605
79.4k
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
606
79.4k
#endif
607
79.4k
608
161k
  for (i = 0; i < pw1->n; 
++i82.3k
) {
609
168k
    for (j = 0; j < pw2->n; 
++j86.6k
) {
610
86.6k
      isl_set *common;
611
86.6k
      EL *res_ij;
612
86.6k
      int empty;
613
86.6k
614
86.6k
      common = isl_set_intersect(
615
86.6k
          isl_set_copy(pw1->p[i].set),
616
86.6k
          isl_set_copy(pw2->p[j].set));
617
86.6k
      empty = isl_set_plain_is_empty(common);
618
86.6k
      if (empty < 0 || empty) {
619
4.00k
        isl_set_free(common);
620
4.00k
        if (empty < 0)
621
0
          goto error;
622
4.00k
        continue;
623
4.00k
      }
624
82.6k
625
82.6k
      res_ij = fn(FN(EL,copy)(pw1->p[i].FIELD),
626
82.6k
            FN(EL,copy)(pw2->p[j].FIELD));
627
82.6k
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
628
82.6k
629
82.6k
      res = FN(PW,add_piece)(res, common, res_ij);
630
82.6k
    }
631
82.3k
  }
632
79.4k
633
79.4k
  isl_space_free(space);
634
79.4k
  FN(PW,free)(pw1);
635
79.4k
  FN(PW,free)(pw2);
636
79.4k
  return res;
637
79.4k
error:
638
0
  isl_space_free(space);
639
0
  FN(PW,free)(pw1);
640
0
  FN(PW,free)(pw2);
641
0
  FN(PW,free)(res);
642
0
  return NULL;
643
79.4k
}
isl_aff.c:isl_pw_multi_aff_on_shared_domain_in
Line
Count
Source
594
201
{
595
201
  int i, j, n;
596
201
  PW *res = NULL;
597
201
598
201
  if (!pw1 || !pw2)
599
0
    goto error;
600
201
601
201
  n = pw1->n * pw2->n;
602
#ifdef HAS_TYPE
603
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
604
#else
605
201
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
606
201
#endif
607
201
608
402
  for (i = 0; i < pw1->n; 
++i201
) {
609
405
    for (j = 0; j < pw2->n; 
++j204
) {
610
204
      isl_set *common;
611
204
      EL *res_ij;
612
204
      int empty;
613
204
614
204
      common = isl_set_intersect(
615
204
          isl_set_copy(pw1->p[i].set),
616
204
          isl_set_copy(pw2->p[j].set));
617
204
      empty = isl_set_plain_is_empty(common);
618
204
      if (empty < 0 || empty) {
619
0
        isl_set_free(common);
620
0
        if (empty < 0)
621
0
          goto error;
622
0
        continue;
623
0
      }
624
204
625
204
      res_ij = fn(FN(EL,copy)(pw1->p[i].FIELD),
626
204
            FN(EL,copy)(pw2->p[j].FIELD));
627
204
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
628
204
629
204
      res = FN(PW,add_piece)(res, common, res_ij);
630
204
    }
631
201
  }
632
201
633
201
  isl_space_free(space);
634
201
  FN(PW,free)(pw1);
635
201
  FN(PW,free)(pw2);
636
201
  return res;
637
201
error:
638
0
  isl_space_free(space);
639
0
  FN(PW,free)(pw1);
640
0
  FN(PW,free)(pw2);
641
0
  FN(PW,free)(res);
642
0
  return NULL;
643
201
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_on_shared_domain_in
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_on_shared_domain_in
644
645
/* This function is currently only used from isl_aff.c
646
 */
647
static __isl_give PW *FN(PW,on_shared_domain)(__isl_take PW *pw1,
648
  __isl_take PW *pw2,
649
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
650
  __attribute__ ((unused));
651
652
/* Apply "fn" to pairs of elements from pw1 and pw2 on shared domains.
653
 * The result of "fn" is assumed to live in the same space as "pw1" and "pw2".
654
 */
655
static __isl_give PW *FN(PW,on_shared_domain)(__isl_take PW *pw1,
656
  __isl_take PW *pw2,
657
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
658
79.4k
{
659
79.4k
  isl_space *space;
660
79.4k
661
79.4k
  if (!pw1 || !pw2)
662
0
    goto error;
663
79.4k
664
79.4k
  space = isl_space_copy(pw1->dim);
665
79.4k
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
666
79.4k
error:
667
0
  FN(PW,free)(pw1);
668
0
  FN(PW,free)(pw2);
669
0
  return NULL;
670
79.4k
}
isl_aff.c:isl_pw_aff_on_shared_domain
Line
Count
Source
658
79.4k
{
659
79.4k
  isl_space *space;
660
79.4k
661
79.4k
  if (!pw1 || !pw2)
662
0
    goto error;
663
79.4k
664
79.4k
  space = isl_space_copy(pw1->dim);
665
79.4k
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
666
79.4k
error:
667
0
  FN(PW,free)(pw1);
668
0
  FN(PW,free)(pw2);
669
0
  return NULL;
670
79.4k
}
isl_aff.c:isl_pw_multi_aff_on_shared_domain
Line
Count
Source
658
1
{
659
1
  isl_space *space;
660
1
661
1
  if (!pw1 || !pw2)
662
0
    goto error;
663
1
664
1
  space = isl_space_copy(pw1->dim);
665
1
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
666
1
error:
667
0
  FN(PW,free)(pw1);
668
0
  FN(PW,free)(pw2);
669
0
  return NULL;
670
1
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_on_shared_domain
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_on_shared_domain
671
672
#ifndef NO_NEG
673
__isl_give PW *FN(PW,neg)(__isl_take PW *pw)
674
24.3k
{
675
24.3k
  int i;
676
24.3k
677
24.3k
  if (!pw)
678
0
    return NULL;
679
24.3k
680
24.3k
  if (FN(PW,IS_ZERO)(pw))
681
1
    return pw;
682
24.3k
683
24.3k
  pw = FN(PW,cow)(pw);
684
24.3k
  if (!pw)
685
0
    return NULL;
686
24.3k
687
49.6k
  
for (i = 0; 24.3k
i < pw->n;
++i25.2k
) {
688
25.2k
    pw->p[i].FIELD = FN(EL,neg)(pw->p[i].FIELD);
689
25.2k
    if (!pw->p[i].FIELD)
690
25.2k
      
return 0
FN0
(PW,free)(pw);
691
25.2k
  }
692
24.3k
693
24.3k
  return pw;
694
24.3k
}
isl_pw_aff_neg
Line
Count
Source
674
24.3k
{
675
24.3k
  int i;
676
24.3k
677
24.3k
  if (!pw)
678
0
    return NULL;
679
24.3k
680
24.3k
  if (FN(PW,IS_ZERO)(pw))
681
1
    return pw;
682
24.3k
683
24.3k
  pw = FN(PW,cow)(pw);
684
24.3k
  if (!pw)
685
0
    return NULL;
686
24.3k
687
49.5k
  
for (i = 0; 24.3k
i < pw->n;
++i25.2k
) {
688
25.2k
    pw->p[i].FIELD = FN(EL,neg)(pw->p[i].FIELD);
689
25.2k
    if (!pw->p[i].FIELD)
690
25.2k
      
return 0
FN0
(PW,free)(pw);
691
25.2k
  }
692
24.3k
693
24.3k
  return pw;
694
24.3k
}
Unexecuted instantiation: isl_pw_multi_aff_neg
isl_pw_qpolynomial_neg
Line
Count
Source
674
11
{
675
11
  int i;
676
11
677
11
  if (!pw)
678
0
    return NULL;
679
11
680
11
  if (FN(PW,IS_ZERO)(pw))
681
0
    return pw;
682
11
683
11
  pw = FN(PW,cow)(pw);
684
11
  if (!pw)
685
0
    return NULL;
686
11
687
23
  
for (i = 0; 11
i < pw->n;
++i12
) {
688
12
    pw->p[i].FIELD = FN(EL,neg)(pw->p[i].FIELD);
689
12
    if (!pw->p[i].FIELD)
690
12
      
return 0
FN0
(PW,free)(pw);
691
12
  }
692
11
693
11
  return pw;
694
11
}
695
#endif
696
697
#ifndef NO_SUB
698
__isl_give PW *FN(PW,sub)(__isl_take PW *pw1, __isl_take PW *pw2)
699
7.13k
{
700
7.13k
  return FN(PW,add)(pw1, FN(PW,neg)(pw2));
701
7.13k
}
isl_pw_aff_sub
Line
Count
Source
699
7.12k
{
700
7.12k
  return FN(PW,add)(pw1, FN(PW,neg)(pw2));
701
7.12k
}
isl_pw_qpolynomial_sub
Line
Count
Source
699
9
{
700
9
  return FN(PW,add)(pw1, FN(PW,neg)(pw2));
701
9
}
702
#endif
703
704
/* Return the parameter domain of "pw".
705
 */
706
__isl_give isl_set *FN(PW,params)(__isl_take PW *pw)
707
0
{
708
0
  return isl_set_params(FN(PW,domain)(pw));
709
0
}
Unexecuted instantiation: isl_pw_aff_params
Unexecuted instantiation: isl_pw_multi_aff_params
Unexecuted instantiation: isl_pw_qpolynomial_fold_params
Unexecuted instantiation: isl_pw_qpolynomial_params
710
711
__isl_give isl_set *FN(PW,domain)(__isl_take PW *pw)
712
55.8k
{
713
55.8k
  int i;
714
55.8k
  isl_set *dom;
715
55.8k
716
55.8k
  if (!pw)
717
0
    return NULL;
718
55.8k
719
55.8k
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
720
113k
  for (i = 0; i < pw->n; 
++i57.8k
)
721
57.8k
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
722
55.8k
723
55.8k
  FN(PW,free)(pw);
724
55.8k
725
55.8k
  return dom;
726
55.8k
}
isl_pw_aff_domain
Line
Count
Source
712
54.8k
{
713
54.8k
  int i;
714
54.8k
  isl_set *dom;
715
54.8k
716
54.8k
  if (!pw)
717
0
    return NULL;
718
54.8k
719
54.8k
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
720
111k
  for (i = 0; i < pw->n; 
++i56.7k
)
721
56.7k
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
722
54.8k
723
54.8k
  FN(PW,free)(pw);
724
54.8k
725
54.8k
  return dom;
726
54.8k
}
isl_pw_multi_aff_domain
Line
Count
Source
712
1.02k
{
713
1.02k
  int i;
714
1.02k
  isl_set *dom;
715
1.02k
716
1.02k
  if (!pw)
717
0
    return NULL;
718
1.02k
719
1.02k
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
720
2.06k
  for (i = 0; i < pw->n; 
++i1.04k
)
721
1.04k
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
722
1.02k
723
1.02k
  FN(PW,free)(pw);
724
1.02k
725
1.02k
  return dom;
726
1.02k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_domain
isl_pw_qpolynomial_domain
Line
Count
Source
712
1
{
713
1
  int i;
714
1
  isl_set *dom;
715
1
716
1
  if (!pw)
717
0
    return NULL;
718
1
719
1
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
720
2
  for (i = 0; i < pw->n; 
++i1
)
721
1
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
722
1
723
1
  FN(PW,free)(pw);
724
1
725
1
  return dom;
726
1
}
727
728
/* Exploit the equalities in the domain of piece "i" of "pw"
729
 * to simplify the associated function.
730
 * If the domain of piece "i" is empty, then remove it entirely,
731
 * replacing it with the final piece.
732
 */
733
static int FN(PW,exploit_equalities_and_remove_if_empty)(__isl_keep PW *pw,
734
  int i)
735
46.6k
{
736
46.6k
  isl_basic_set *aff;
737
46.6k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
738
46.6k
739
46.6k
  if (empty < 0)
740
0
    return -1;
741
46.6k
  if (empty) {
742
53
    isl_set_free(pw->p[i].set);
743
53
    FN(EL,free)(pw->p[i].FIELD);
744
53
    if (i != pw->n - 1)
745
0
      pw->p[i] = pw->p[pw->n - 1];
746
53
    pw->n--;
747
53
748
53
    return 0;
749
53
  }
750
46.5k
751
46.5k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
752
46.5k
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
753
46.5k
  if (!pw->p[i].FIELD)
754
46.5k
    
return -10
;
755
46.5k
756
46.5k
  return 0;
757
46.5k
}
isl_aff.c:isl_pw_aff_exploit_equalities_and_remove_if_empty
Line
Count
Source
735
43.6k
{
736
43.6k
  isl_basic_set *aff;
737
43.6k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
738
43.6k
739
43.6k
  if (empty < 0)
740
0
    return -1;
741
43.6k
  if (empty) {
742
48
    isl_set_free(pw->p[i].set);
743
48
    FN(EL,free)(pw->p[i].FIELD);
744
48
    if (i != pw->n - 1)
745
0
      pw->p[i] = pw->p[pw->n - 1];
746
48
    pw->n--;
747
48
748
48
    return 0;
749
48
  }
750
43.5k
751
43.5k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
752
43.5k
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
753
43.5k
  if (!pw->p[i].FIELD)
754
43.5k
    
return -10
;
755
43.5k
756
43.5k
  return 0;
757
43.5k
}
isl_aff.c:isl_pw_multi_aff_exploit_equalities_and_remove_if_empty
Line
Count
Source
735
2.99k
{
736
2.99k
  isl_basic_set *aff;
737
2.99k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
738
2.99k
739
2.99k
  if (empty < 0)
740
0
    return -1;
741
2.99k
  if (empty) {
742
5
    isl_set_free(pw->p[i].set);
743
5
    FN(EL,free)(pw->p[i].FIELD);
744
5
    if (i != pw->n - 1)
745
0
      pw->p[i] = pw->p[pw->n - 1];
746
5
    pw->n--;
747
5
748
5
    return 0;
749
5
  }
750
2.99k
751
2.99k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
752
2.99k
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
753
2.99k
  if (!pw->p[i].FIELD)
754
2.99k
    
return -10
;
755
2.99k
756
2.99k
  return 0;
757
2.99k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_exploit_equalities_and_remove_if_empty
isl_polynomial.c:isl_pw_qpolynomial_exploit_equalities_and_remove_if_empty
Line
Count
Source
735
35
{
736
35
  isl_basic_set *aff;
737
35
  int empty = isl_set_plain_is_empty(pw->p[i].set);
738
35
739
35
  if (empty < 0)
740
0
    return -1;
741
35
  if (empty) {
742
0
    isl_set_free(pw->p[i].set);
743
0
    FN(EL,free)(pw->p[i].FIELD);
744
0
    if (i != pw->n - 1)
745
0
      pw->p[i] = pw->p[pw->n - 1];
746
0
    pw->n--;
747
0
748
0
    return 0;
749
0
  }
750
35
751
35
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
752
35
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
753
35
  if (!pw->p[i].FIELD)
754
35
    
return -10
;
755
35
756
35
  return 0;
757
35
}
758
759
/* Convert a piecewise expression defined over a parameter domain
760
 * into one that is defined over a zero-dimensional set.
761
 */
762
__isl_give PW *FN(PW,from_range)(__isl_take PW *pw)
763
58
{
764
58
  isl_space *space;
765
58
766
58
  if (!pw)
767
0
    return NULL;
768
58
  if (!isl_space_is_set(pw->dim))
769
58
    
isl_die0
(FN(PW,get_ctx)(pw), isl_error_invalid,
770
58
      "not living in a set space", return FN(PW,free)(pw));
771
58
772
58
  space = FN(PW,get_space)(pw);
773
58
  space = isl_space_from_range(space);
774
58
  pw = FN(PW,reset_space)(pw, space);
775
58
776
58
  return pw;
777
58
}
isl_pw_aff_from_range
Line
Count
Source
763
58
{
764
58
  isl_space *space;
765
58
766
58
  if (!pw)
767
0
    return NULL;
768
58
  if (!isl_space_is_set(pw->dim))
769
58
    
isl_die0
(FN(PW,get_ctx)(pw), isl_error_invalid,
770
58
      "not living in a set space", return FN(PW,free)(pw));
771
58
772
58
  space = FN(PW,get_space)(pw);
773
58
  space = isl_space_from_range(space);
774
58
  pw = FN(PW,reset_space)(pw, space);
775
58
776
58
  return pw;
777
58
}
Unexecuted instantiation: isl_pw_multi_aff_from_range
Unexecuted instantiation: isl_pw_qpolynomial_fold_from_range
Unexecuted instantiation: isl_pw_qpolynomial_from_range
778
779
/* Fix the value of the given parameter or domain dimension of "pw"
780
 * to be equal to "value".
781
 */
782
__isl_give PW *FN(PW,fix_si)(__isl_take PW *pw, enum isl_dim_type type,
783
  unsigned pos, int value)
784
0
{
785
0
  int i;
786
0
787
0
  if (!pw)
788
0
    return NULL;
789
0
790
0
  if (type == isl_dim_out)
791
0
    isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
792
0
      "cannot fix output dimension", return FN(PW,free)(pw));
793
0
794
0
  if (pw->n == 0)
795
0
    return pw;
796
0
797
0
  if (type == isl_dim_in)
798
0
    type = isl_dim_set;
799
0
800
0
  pw = FN(PW,cow)(pw);
801
0
  if (!pw)
802
0
    return FN(PW,free)(pw);
803
0
804
0
  for (i = pw->n - 1; i >= 0; --i) {
805
0
    pw->p[i].set = isl_set_fix_si(pw->p[i].set, type, pos, value);
806
0
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
807
0
      return FN(PW,free)(pw);
808
0
  }
809
0
810
0
  return pw;
811
0
}
Unexecuted instantiation: isl_pw_aff_fix_si
Unexecuted instantiation: isl_pw_multi_aff_fix_si
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_si
Unexecuted instantiation: isl_pw_qpolynomial_fix_si
812
813
/* Restrict the domain of "pw" by combining each cell
814
 * with "set" through a call to "fn", where "fn" may be
815
 * isl_set_intersect, isl_set_intersect_params or isl_set_subtract.
816
 */
817
static __isl_give PW *FN(PW,restrict_domain_aligned)(__isl_take PW *pw,
818
  __isl_take isl_set *set,
819
  __isl_give isl_set *(*fn)(__isl_take isl_set *set1,
820
            __isl_take isl_set *set2))
821
45.0k
{
822
45.0k
  int i;
823
45.0k
824
45.0k
  if (!pw || !set)
825
0
    goto error;
826
45.0k
827
45.0k
  if (pw->n == 0) {
828
4
    isl_set_free(set);
829
4
    return pw;
830
4
  }
831
45.0k
832
45.0k
  pw = FN(PW,cow)(pw);
833
45.0k
  if (!pw)
834
0
    goto error;
835
45.0k
836
91.7k
  
for (i = pw->n - 1; 45.0k
i >= 0;
--i46.6k
) {
837
46.6k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
838
46.6k
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
839
0
      goto error;
840
46.6k
  }
841
45.0k
  
842
45.0k
  isl_set_free(set);
843
45.0k
  return pw;
844
45.0k
error:
845
0
  isl_set_free(set);
846
0
  FN(PW,free)(pw);
847
0
  return NULL;
848
45.0k
}
isl_aff.c:isl_pw_aff_restrict_domain_aligned
Line
Count
Source
821
42.0k
{
822
42.0k
  int i;
823
42.0k
824
42.0k
  if (!pw || !set)
825
0
    goto error;
826
42.0k
827
42.0k
  if (pw->n == 0) {
828
1
    isl_set_free(set);
829
1
    return pw;
830
1
  }
831
42.0k
832
42.0k
  pw = FN(PW,cow)(pw);
833
42.0k
  if (!pw)
834
0
    goto error;
835
42.0k
836
85.6k
  
for (i = pw->n - 1; 42.0k
i >= 0;
--i43.6k
) {
837
43.6k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
838
43.6k
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
839
0
      goto error;
840
43.6k
  }
841
42.0k
  
842
42.0k
  isl_set_free(set);
843
42.0k
  return pw;
844
42.0k
error:
845
0
  isl_set_free(set);
846
0
  FN(PW,free)(pw);
847
0
  return NULL;
848
42.0k
}
isl_aff.c:isl_pw_multi_aff_restrict_domain_aligned
Line
Count
Source
821
2.96k
{
822
2.96k
  int i;
823
2.96k
824
2.96k
  if (!pw || !set)
825
0
    goto error;
826
2.96k
827
2.96k
  if (pw->n == 0) {
828
2
    isl_set_free(set);
829
2
    return pw;
830
2
  }
831
2.96k
832
2.96k
  pw = FN(PW,cow)(pw);
833
2.96k
  if (!pw)
834
0
    goto error;
835
2.96k
836
5.96k
  
for (i = pw->n - 1; 2.96k
i >= 0;
--i2.99k
) {
837
2.99k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
838
2.99k
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
839
0
      goto error;
840
2.99k
  }
841
2.96k
  
842
2.96k
  isl_set_free(set);
843
2.96k
  return pw;
844
2.96k
error:
845
0
  isl_set_free(set);
846
0
  FN(PW,free)(pw);
847
0
  return NULL;
848
2.96k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_restrict_domain_aligned
isl_polynomial.c:isl_pw_qpolynomial_restrict_domain_aligned
Line
Count
Source
821
35
{
822
35
  int i;
823
35
824
35
  if (!pw || !set)
825
0
    goto error;
826
35
827
35
  if (pw->n == 0) {
828
1
    isl_set_free(set);
829
1
    return pw;
830
1
  }
831
34
832
34
  pw = FN(PW,cow)(pw);
833
34
  if (!pw)
834
0
    goto error;
835
34
836
68
  
for (i = pw->n - 1; 34
i >= 0;
--i34
) {
837
34
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
838
34
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
839
0
      goto error;
840
34
  }
841
34
  
842
34
  isl_set_free(set);
843
34
  return pw;
844
34
error:
845
0
  isl_set_free(set);
846
0
  FN(PW,free)(pw);
847
0
  return NULL;
848
34
}
849
850
static __isl_give PW *FN(PW,intersect_domain_aligned)(__isl_take PW *pw,
851
  __isl_take isl_set *set)
852
38.6k
{
853
38.6k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
854
38.6k
}
isl_aff.c:isl_pw_aff_intersect_domain_aligned
Line
Count
Source
852
36.3k
{
853
36.3k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
854
36.3k
}
isl_aff.c:isl_pw_multi_aff_intersect_domain_aligned
Line
Count
Source
852
2.28k
{
853
2.28k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
854
2.28k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_intersect_domain_aligned
isl_polynomial.c:isl_pw_qpolynomial_intersect_domain_aligned
Line
Count
Source
852
35
{
853
35
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
854
35
}
855
856
__isl_give PW *FN(PW,intersect_domain)(__isl_take PW *pw,
857
  __isl_take isl_set *context)
858
38.6k
{
859
38.6k
  return FN(PW,align_params_pw_set_and)(pw, context,
860
38.6k
          &FN(PW,intersect_domain_aligned));
861
38.6k
}
isl_pw_aff_intersect_domain
Line
Count
Source
858
36.3k
{
859
36.3k
  return FN(PW,align_params_pw_set_and)(pw, context,
860
36.3k
          &FN(PW,intersect_domain_aligned));
861
36.3k
}
isl_pw_multi_aff_intersect_domain
Line
Count
Source
858
2.28k
{
859
2.28k
  return FN(PW,align_params_pw_set_and)(pw, context,
860
2.28k
          &FN(PW,intersect_domain_aligned));
861
2.28k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_intersect_domain
isl_pw_qpolynomial_intersect_domain
Line
Count
Source
858
35
{
859
35
  return FN(PW,align_params_pw_set_and)(pw, context,
860
35
          &FN(PW,intersect_domain_aligned));
861
35
}
862
863
static __isl_give PW *FN(PW,intersect_params_aligned)(__isl_take PW *pw,
864
  __isl_take isl_set *set)
865
6.39k
{
866
6.39k
  return FN(PW,restrict_domain_aligned)(pw, set,
867
6.39k
          &isl_set_intersect_params);
868
6.39k
}
isl_aff.c:isl_pw_aff_intersect_params_aligned
Line
Count
Source
865
5.71k
{
866
5.71k
  return FN(PW,restrict_domain_aligned)(pw, set,
867
5.71k
          &isl_set_intersect_params);
868
5.71k
}
isl_aff.c:isl_pw_multi_aff_intersect_params_aligned
Line
Count
Source
865
682
{
866
682
  return FN(PW,restrict_domain_aligned)(pw, set,
867
682
          &isl_set_intersect_params);
868
682
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_intersect_params_aligned
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_intersect_params_aligned
869
870
/* Intersect the domain of "pw" with the parameter domain "context".
871
 */
872
__isl_give PW *FN(PW,intersect_params)(__isl_take PW *pw,
873
  __isl_take isl_set *context)
874
6.39k
{
875
6.39k
  return FN(PW,align_params_pw_set_and)(pw, context,
876
6.39k
          &FN(PW,intersect_params_aligned));
877
6.39k
}
isl_pw_aff_intersect_params
Line
Count
Source
874
5.71k
{
875
5.71k
  return FN(PW,align_params_pw_set_and)(pw, context,
876
5.71k
          &FN(PW,intersect_params_aligned));
877
5.71k
}
isl_pw_multi_aff_intersect_params
Line
Count
Source
874
682
{
875
682
  return FN(PW,align_params_pw_set_and)(pw, context,
876
682
          &FN(PW,intersect_params_aligned));
877
682
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_intersect_params
Unexecuted instantiation: isl_pw_qpolynomial_intersect_params
878
879
/* Subtract "domain' from the domain of "pw", assuming their
880
 * parameters have been aligned.
881
 */
882
static __isl_give PW *FN(PW,subtract_domain_aligned)(__isl_take PW *pw,
883
  __isl_take isl_set *domain)
884
3
{
885
3
  return FN(PW,restrict_domain_aligned)(pw, domain, &isl_set_subtract);
886
3
}
Unexecuted instantiation: isl_aff.c:isl_pw_aff_subtract_domain_aligned
isl_aff.c:isl_pw_multi_aff_subtract_domain_aligned
Line
Count
Source
884
3
{
885
3
  return FN(PW,restrict_domain_aligned)(pw, domain, &isl_set_subtract);
886
3
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_subtract_domain_aligned
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_subtract_domain_aligned
887
888
/* Subtract "domain' from the domain of "pw".
889
 */
890
__isl_give PW *FN(PW,subtract_domain)(__isl_take PW *pw,
891
  __isl_take isl_set *domain)
892
3
{
893
3
  return FN(PW,align_params_pw_set_and)(pw, domain,
894
3
          &FN(PW,subtract_domain_aligned));
895
3
}
Unexecuted instantiation: isl_pw_aff_subtract_domain
isl_pw_multi_aff_subtract_domain
Line
Count
Source
892
3
{
893
3
  return FN(PW,align_params_pw_set_and)(pw, domain,
894
3
          &FN(PW,subtract_domain_aligned));
895
3
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_subtract_domain
Unexecuted instantiation: isl_pw_qpolynomial_subtract_domain
896
897
/* Compute the gist of "pw" with respect to the domain constraints
898
 * of "context" for the case where the domain of the last element
899
 * of "pw" is equal to "context".
900
 * Call "fn_el" to compute the gist of this element, replace
901
 * its domain by the universe and drop all other elements
902
 * as their domains are necessarily disjoint from "context".
903
 */
904
static __isl_give PW *FN(PW,gist_last)(__isl_take PW *pw,
905
  __isl_take isl_set *context,
906
  __isl_give EL *(*fn_el)(__isl_take EL *el, __isl_take isl_set *set))
907
10.2k
{
908
10.2k
  int i;
909
10.2k
  isl_space *space;
910
10.2k
911
10.2k
  for (i = 0; i < pw->n - 1; 
++i0
) {
912
0
    isl_set_free(pw->p[i].set);
913
0
    FN(EL,free)(pw->p[i].FIELD);
914
0
  }
915
10.2k
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
916
10.2k
  pw->p[0].set = pw->p[pw->n - 1].set;
917
10.2k
  pw->n = 1;
918
10.2k
919
10.2k
  space = isl_set_get_space(context);
920
10.2k
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
921
10.2k
  context = isl_set_universe(space);
922
10.2k
  isl_set_free(pw->p[0].set);
923
10.2k
  pw->p[0].set = context;
924
10.2k
925
10.2k
  if (!pw->p[0].FIELD || !pw->p[0].set)
926
0
    return FN(PW,free)(pw);
927
10.2k
928
10.2k
  return pw;
929
10.2k
}
isl_aff.c:isl_pw_aff_gist_last
Line
Count
Source
907
8.29k
{
908
8.29k
  int i;
909
8.29k
  isl_space *space;
910
8.29k
911
8.29k
  for (i = 0; i < pw->n - 1; 
++i0
) {
912
0
    isl_set_free(pw->p[i].set);
913
0
    FN(EL,free)(pw->p[i].FIELD);
914
0
  }
915
8.29k
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
916
8.29k
  pw->p[0].set = pw->p[pw->n - 1].set;
917
8.29k
  pw->n = 1;
918
8.29k
919
8.29k
  space = isl_set_get_space(context);
920
8.29k
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
921
8.29k
  context = isl_set_universe(space);
922
8.29k
  isl_set_free(pw->p[0].set);
923
8.29k
  pw->p[0].set = context;
924
8.29k
925
8.29k
  if (!pw->p[0].FIELD || !pw->p[0].set)
926
0
    return FN(PW,free)(pw);
927
8.29k
928
8.29k
  return pw;
929
8.29k
}
isl_aff.c:isl_pw_multi_aff_gist_last
Line
Count
Source
907
1.97k
{
908
1.97k
  int i;
909
1.97k
  isl_space *space;
910
1.97k
911
1.97k
  for (i = 0; i < pw->n - 1; 
++i0
) {
912
0
    isl_set_free(pw->p[i].set);
913
0
    FN(EL,free)(pw->p[i].FIELD);
914
0
  }
915
1.97k
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
916
1.97k
  pw->p[0].set = pw->p[pw->n - 1].set;
917
1.97k
  pw->n = 1;
918
1.97k
919
1.97k
  space = isl_set_get_space(context);
920
1.97k
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
921
1.97k
  context = isl_set_universe(space);
922
1.97k
  isl_set_free(pw->p[0].set);
923
1.97k
  pw->p[0].set = context;
924
1.97k
925
1.97k
  if (!pw->p[0].FIELD || !pw->p[0].set)
926
0
    return FN(PW,free)(pw);
927
1.97k
928
1.97k
  return pw;
929
1.97k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_last
isl_polynomial.c:isl_pw_qpolynomial_gist_last
Line
Count
Source
907
1
{
908
1
  int i;
909
1
  isl_space *space;
910
1
911
1
  for (i = 0; i < pw->n - 1; 
++i0
) {
912
0
    isl_set_free(pw->p[i].set);
913
0
    FN(EL,free)(pw->p[i].FIELD);
914
0
  }
915
1
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
916
1
  pw->p[0].set = pw->p[pw->n - 1].set;
917
1
  pw->n = 1;
918
1
919
1
  space = isl_set_get_space(context);
920
1
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
921
1
  context = isl_set_universe(space);
922
1
  isl_set_free(pw->p[0].set);
923
1
  pw->p[0].set = context;
924
1
925
1
  if (!pw->p[0].FIELD || !pw->p[0].set)
926
0
    return FN(PW,free)(pw);
927
1
928
1
  return pw;
929
1
}
930
931
/* Compute the gist of "pw" with respect to the domain constraints
932
 * of "context".  Call "fn_el" to compute the gist of the elements
933
 * and "fn_dom" to compute the gist of the domains.
934
 *
935
 * If the piecewise expression is empty or the context is the universe,
936
 * then nothing can be simplified.
937
 */
938
static __isl_give PW *FN(PW,gist_aligned)(__isl_take PW *pw,
939
  __isl_take isl_set *context,
940
  __isl_give EL *(*fn_el)(__isl_take EL *el,
941
            __isl_take isl_set *set),
942
  __isl_give isl_set *(*fn_dom)(__isl_take isl_set *set,
943
            __isl_take isl_basic_set *bset))
944
13.6k
{
945
13.6k
  int i;
946
13.6k
  int is_universe;
947
13.6k
  isl_bool aligned;
948
13.6k
  isl_basic_set *hull = NULL;
949
13.6k
950
13.6k
  if (!pw || !context)
951
0
    goto error;
952
13.6k
953
13.6k
  if (pw->n == 0) {
954
0
    isl_set_free(context);
955
0
    return pw;
956
0
  }
957
13.6k
958
13.6k
  is_universe = isl_set_plain_is_universe(context);
959
13.6k
  if (is_universe < 0)
960
0
    goto error;
961
13.6k
  if (is_universe) {
962
1.14k
    isl_set_free(context);
963
1.14k
    return pw;
964
1.14k
  }
965
12.5k
966
12.5k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
967
12.5k
  if (aligned < 0)
968
0
    goto error;
969
12.5k
  if (!aligned) {
970
0
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
971
0
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
972
0
  }
973
12.5k
974
12.5k
  pw = FN(PW,cow)(pw);
975
12.5k
  if (!pw)
976
0
    goto error;
977
12.5k
978
12.5k
  if (pw->n == 1) {
979
12.5k
    int equal;
980
12.5k
981
12.5k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
982
12.5k
    if (equal < 0)
983
0
      goto error;
984
12.5k
    if (equal)
985
10.2k
      return FN(PW,gist_last)(pw, context, fn_el);
986
2.27k
  }
987
2.27k
988
2.27k
  context = isl_set_compute_divs(context);
989
2.27k
  hull = isl_set_simple_hull(isl_set_copy(context));
990
2.27k
991
4.57k
  for (i = pw->n - 1; i >= 0; 
--i2.30k
) {
992
2.30k
    isl_set *set_i;
993
2.30k
    int empty;
994
2.30k
995
2.30k
    if (i == pw->n - 1) {
996
2.27k
      int equal;
997
2.27k
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
998
2.27k
      if (equal < 0)
999
0
        goto error;
1000
2.27k
      if (equal) {
1001
0
        isl_basic_set_free(hull);
1002
0
        return FN(PW,gist_last)(pw, context, fn_el);
1003
0
      }
1004
2.30k
    }
1005
2.30k
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1006
2.30k
             isl_set_copy(context));
1007
2.30k
    empty = isl_set_plain_is_empty(set_i);
1008
2.30k
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1009
2.30k
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1010
2.30k
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1011
0
      goto error;
1012
2.30k
    if (empty) {
1013
2
      isl_set_free(pw->p[i].set);
1014
2
      FN(EL,free)(pw->p[i].FIELD);
1015
2
      if (i != pw->n - 1)
1016
0
        pw->p[i] = pw->p[pw->n - 1];
1017
2
      pw->n--;
1018
2
    }
1019
2.30k
  }
1020
2.27k
1021
2.27k
  isl_basic_set_free(hull);
1022
2.27k
  isl_set_free(context);
1023
2.27k
1024
2.27k
  return pw;
1025
2.27k
error:
1026
0
  FN(PW,free)(pw);
1027
0
  isl_basic_set_free(hull);
1028
0
  isl_set_free(context);
1029
0
  return NULL;
1030
2.27k
}
isl_aff.c:isl_pw_aff_gist_aligned
Line
Count
Source
944
11.5k
{
945
11.5k
  int i;
946
11.5k
  int is_universe;
947
11.5k
  isl_bool aligned;
948
11.5k
  isl_basic_set *hull = NULL;
949
11.5k
950
11.5k
  if (!pw || !context)
951
0
    goto error;
952
11.5k
953
11.5k
  if (pw->n == 0) {
954
0
    isl_set_free(context);
955
0
    return pw;
956
0
  }
957
11.5k
958
11.5k
  is_universe = isl_set_plain_is_universe(context);
959
11.5k
  if (is_universe < 0)
960
0
    goto error;
961
11.5k
  if (is_universe) {
962
1.06k
    isl_set_free(context);
963
1.06k
    return pw;
964
1.06k
  }
965
10.4k
966
10.4k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
967
10.4k
  if (aligned < 0)
968
0
    goto error;
969
10.4k
  if (!aligned) {
970
0
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
971
0
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
972
0
  }
973
10.4k
974
10.4k
  pw = FN(PW,cow)(pw);
975
10.4k
  if (!pw)
976
0
    goto error;
977
10.4k
978
10.4k
  if (pw->n == 1) {
979
10.4k
    int equal;
980
10.4k
981
10.4k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
982
10.4k
    if (equal < 0)
983
0
      goto error;
984
10.4k
    if (equal)
985
8.29k
      return FN(PW,gist_last)(pw, context, fn_el);
986
2.16k
  }
987
2.16k
988
2.16k
  context = isl_set_compute_divs(context);
989
2.16k
  hull = isl_set_simple_hull(isl_set_copy(context));
990
2.16k
991
4.36k
  for (i = pw->n - 1; i >= 0; 
--i2.20k
) {
992
2.20k
    isl_set *set_i;
993
2.20k
    int empty;
994
2.20k
995
2.20k
    if (i == pw->n - 1) {
996
2.16k
      int equal;
997
2.16k
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
998
2.16k
      if (equal < 0)
999
0
        goto error;
1000
2.16k
      if (equal) {
1001
0
        isl_basic_set_free(hull);
1002
0
        return FN(PW,gist_last)(pw, context, fn_el);
1003
0
      }
1004
2.20k
    }
1005
2.20k
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1006
2.20k
             isl_set_copy(context));
1007
2.20k
    empty = isl_set_plain_is_empty(set_i);
1008
2.20k
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1009
2.20k
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1010
2.20k
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1011
0
      goto error;
1012
2.20k
    if (empty) {
1013
0
      isl_set_free(pw->p[i].set);
1014
0
      FN(EL,free)(pw->p[i].FIELD);
1015
0
      if (i != pw->n - 1)
1016
0
        pw->p[i] = pw->p[pw->n - 1];
1017
0
      pw->n--;
1018
0
    }
1019
2.20k
  }
1020
2.16k
1021
2.16k
  isl_basic_set_free(hull);
1022
2.16k
  isl_set_free(context);
1023
2.16k
1024
2.16k
  return pw;
1025
2.16k
error:
1026
0
  FN(PW,free)(pw);
1027
0
  isl_basic_set_free(hull);
1028
0
  isl_set_free(context);
1029
0
  return NULL;
1030
2.16k
}
isl_aff.c:isl_pw_multi_aff_gist_aligned
Line
Count
Source
944
2.15k
{
945
2.15k
  int i;
946
2.15k
  int is_universe;
947
2.15k
  isl_bool aligned;
948
2.15k
  isl_basic_set *hull = NULL;
949
2.15k
950
2.15k
  if (!pw || !context)
951
0
    goto error;
952
2.15k
953
2.15k
  if (pw->n == 0) {
954
0
    isl_set_free(context);
955
0
    return pw;
956
0
  }
957
2.15k
958
2.15k
  is_universe = isl_set_plain_is_universe(context);
959
2.15k
  if (is_universe < 0)
960
0
    goto error;
961
2.15k
  if (is_universe) {
962
76
    isl_set_free(context);
963
76
    return pw;
964
76
  }
965
2.07k
966
2.07k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
967
2.07k
  if (aligned < 0)
968
0
    goto error;
969
2.07k
  if (!aligned) {
970
0
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
971
0
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
972
0
  }
973
2.07k
974
2.07k
  pw = FN(PW,cow)(pw);
975
2.07k
  if (!pw)
976
0
    goto error;
977
2.07k
978
2.07k
  if (pw->n == 1) {
979
2.07k
    int equal;
980
2.07k
981
2.07k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
982
2.07k
    if (equal < 0)
983
0
      goto error;
984
2.07k
    if (equal)
985
1.97k
      return FN(PW,gist_last)(pw, context, fn_el);
986
104
  }
987
104
988
104
  context = isl_set_compute_divs(context);
989
104
  hull = isl_set_simple_hull(isl_set_copy(context));
990
104
991
208
  for (i = pw->n - 1; i >= 0; 
--i104
) {
992
104
    isl_set *set_i;
993
104
    int empty;
994
104
995
104
    if (i == pw->n - 1) {
996
104
      int equal;
997
104
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
998
104
      if (equal < 0)
999
0
        goto error;
1000
104
      if (equal) {
1001
0
        isl_basic_set_free(hull);
1002
0
        return FN(PW,gist_last)(pw, context, fn_el);
1003
0
      }
1004
104
    }
1005
104
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1006
104
             isl_set_copy(context));
1007
104
    empty = isl_set_plain_is_empty(set_i);
1008
104
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1009
104
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1010
104
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1011
0
      goto error;
1012
104
    if (empty) {
1013
2
      isl_set_free(pw->p[i].set);
1014
2
      FN(EL,free)(pw->p[i].FIELD);
1015
2
      if (i != pw->n - 1)
1016
0
        pw->p[i] = pw->p[pw->n - 1];
1017
2
      pw->n--;
1018
2
    }
1019
104
  }
1020
104
1021
104
  isl_basic_set_free(hull);
1022
104
  isl_set_free(context);
1023
104
1024
104
  return pw;
1025
104
error:
1026
0
  FN(PW,free)(pw);
1027
0
  isl_basic_set_free(hull);
1028
0
  isl_set_free(context);
1029
0
  return NULL;
1030
104
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_aligned
isl_polynomial.c:isl_pw_qpolynomial_gist_aligned
Line
Count
Source
944
4
{
945
4
  int i;
946
4
  int is_universe;
947
4
  isl_bool aligned;
948
4
  isl_basic_set *hull = NULL;
949
4
950
4
  if (!pw || !context)
951
0
    goto error;
952
4
953
4
  if (pw->n == 0) {
954
0
    isl_set_free(context);
955
0
    return pw;
956
0
  }
957
4
958
4
  is_universe = isl_set_plain_is_universe(context);
959
4
  if (is_universe < 0)
960
0
    goto error;
961
4
  if (is_universe) {
962
0
    isl_set_free(context);
963
0
    return pw;
964
0
  }
965
4
966
4
  aligned = isl_set_space_has_equal_params(context, pw->dim);
967
4
  if (aligned < 0)
968
0
    goto error;
969
4
  if (!aligned) {
970
0
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
971
0
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
972
0
  }
973
4
974
4
  pw = FN(PW,cow)(pw);
975
4
  if (!pw)
976
0
    goto error;
977
4
978
4
  if (pw->n == 1) {
979
4
    int equal;
980
4
981
4
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
982
4
    if (equal < 0)
983
0
      goto error;
984
4
    if (equal)
985
1
      return FN(PW,gist_last)(pw, context, fn_el);
986
3
  }
987
3
988
3
  context = isl_set_compute_divs(context);
989
3
  hull = isl_set_simple_hull(isl_set_copy(context));
990
3
991
6
  for (i = pw->n - 1; i >= 0; 
--i3
) {
992
3
    isl_set *set_i;
993
3
    int empty;
994
3
995
3
    if (i == pw->n - 1) {
996
3
      int equal;
997
3
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
998
3
      if (equal < 0)
999
0
        goto error;
1000
3
      if (equal) {
1001
0
        isl_basic_set_free(hull);
1002
0
        return FN(PW,gist_last)(pw, context, fn_el);
1003
0
      }
1004
3
    }
1005
3
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1006
3
             isl_set_copy(context));
1007
3
    empty = isl_set_plain_is_empty(set_i);
1008
3
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1009
3
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1010
3
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1011
0
      goto error;
1012
3
    if (empty) {
1013
0
      isl_set_free(pw->p[i].set);
1014
0
      FN(EL,free)(pw->p[i].FIELD);
1015
0
      if (i != pw->n - 1)
1016
0
        pw->p[i] = pw->p[pw->n - 1];
1017
0
      pw->n--;
1018
0
    }
1019
3
  }
1020
3
1021
3
  isl_basic_set_free(hull);
1022
3
  isl_set_free(context);
1023
3
1024
3
  return pw;
1025
3
error:
1026
0
  FN(PW,free)(pw);
1027
0
  isl_basic_set_free(hull);
1028
0
  isl_set_free(context);
1029
0
  return NULL;
1030
3
}
1031
1032
static __isl_give PW *FN(PW,gist_domain_aligned)(__isl_take PW *pw,
1033
  __isl_take isl_set *set)
1034
13.6k
{
1035
13.6k
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1036
13.6k
          &isl_set_gist_basic_set);
1037
13.6k
}
isl_aff.c:isl_pw_aff_gist_domain_aligned
Line
Count
Source
1034
11.5k
{
1035
11.5k
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1036
11.5k
          &isl_set_gist_basic_set);
1037
11.5k
}
isl_aff.c:isl_pw_multi_aff_gist_domain_aligned
Line
Count
Source
1034
2.15k
{
1035
2.15k
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1036
2.15k
          &isl_set_gist_basic_set);
1037
2.15k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_domain_aligned
isl_polynomial.c:isl_pw_qpolynomial_gist_domain_aligned
Line
Count
Source
1034
4
{
1035
4
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1036
4
          &isl_set_gist_basic_set);
1037
4
}
1038
1039
__isl_give PW *FN(PW,gist)(__isl_take PW *pw, __isl_take isl_set *context)
1040
13.6k
{
1041
13.6k
  return FN(PW,align_params_pw_set_and)(pw, context,
1042
13.6k
            &FN(PW,gist_domain_aligned));
1043
13.6k
}
isl_pw_aff_gist
Line
Count
Source
1040
11.5k
{
1041
11.5k
  return FN(PW,align_params_pw_set_and)(pw, context,
1042
11.5k
            &FN(PW,gist_domain_aligned));
1043
11.5k
}
isl_pw_multi_aff_gist
Line
Count
Source
1040
2.15k
{
1041
2.15k
  return FN(PW,align_params_pw_set_and)(pw, context,
1042
2.15k
            &FN(PW,gist_domain_aligned));
1043
2.15k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_gist
isl_pw_qpolynomial_gist
Line
Count
Source
1040
4
{
1041
4
  return FN(PW,align_params_pw_set_and)(pw, context,
1042
4
            &FN(PW,gist_domain_aligned));
1043
4
}
1044
1045
static __isl_give PW *FN(PW,gist_params_aligned)(__isl_take PW *pw,
1046
  __isl_take isl_set *set)
1047
0
{
1048
0
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist_params),
1049
0
          &isl_set_gist_params_basic_set);
1050
0
}
Unexecuted instantiation: isl_aff.c:isl_pw_aff_gist_params_aligned
Unexecuted instantiation: isl_aff.c:isl_pw_multi_aff_gist_params_aligned
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_params_aligned
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_gist_params_aligned
1051
1052
__isl_give PW *FN(PW,gist_params)(__isl_take PW *pw,
1053
  __isl_take isl_set *context)
1054
0
{
1055
0
  return FN(PW,align_params_pw_set_and)(pw, context,
1056
0
            &FN(PW,gist_params_aligned));
1057
0
}
Unexecuted instantiation: isl_pw_aff_gist_params
Unexecuted instantiation: isl_pw_multi_aff_gist_params
Unexecuted instantiation: isl_pw_qpolynomial_fold_gist_params
Unexecuted instantiation: isl_pw_qpolynomial_gist_params
1058
1059
/* Return -1 if the piece "p1" should be sorted before "p2"
1060
 * and 1 if it should be sorted after "p2".
1061
 * Return 0 if they do not need to be sorted in a specific order.
1062
 *
1063
 * The two pieces are compared on the basis of their function value expressions.
1064
 */
1065
static int FN(PW,sort_field_cmp)(const void *p1, const void *p2, void *arg)
1066
6.93k
{
1067
6.93k
  struct FN(PW,piece) const *pc1 = p1;
1068
6.93k
  struct FN(PW,piece) const *pc2 = p2;
1069
6.93k
1070
6.93k
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1071
6.93k
}
isl_aff.c:isl_pw_aff_sort_field_cmp
Line
Count
Source
1066
685
{
1067
685
  struct FN(PW,piece) const *pc1 = p1;
1068
685
  struct FN(PW,piece) const *pc2 = p2;
1069
685
1070
685
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1071
685
}
isl_aff.c:isl_pw_multi_aff_sort_field_cmp
Line
Count
Source
1066
6.25k
{
1067
6.25k
  struct FN(PW,piece) const *pc1 = p1;
1068
6.25k
  struct FN(PW,piece) const *pc2 = p2;
1069
6.25k
1070
6.25k
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1071
6.25k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_sort_field_cmp
isl_polynomial.c:isl_pw_qpolynomial_sort_field_cmp
Line
Count
Source
1066
1
{
1067
1
  struct FN(PW,piece) const *pc1 = p1;
1068
1
  struct FN(PW,piece) const *pc2 = p2;
1069
1
1070
1
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1071
1
}
1072
1073
/* Sort the pieces of "pw" according to their function value
1074
 * expressions and then combine pairs of adjacent pieces with
1075
 * the same such expression.
1076
 *
1077
 * The sorting is performed in place because it does not
1078
 * change the meaning of "pw", but care needs to be
1079
 * taken not to change any possible other copies of "pw"
1080
 * in case anything goes wrong.
1081
 */
1082
__isl_give PW *FN(PW,sort)(__isl_take PW *pw)
1083
29.5k
{
1084
29.5k
  int i, j;
1085
29.5k
  isl_set *set;
1086
29.5k
1087
29.5k
  if (!pw)
1088
6
    return NULL;
1089
29.5k
  if (pw->n <= 1)
1090
28.3k
    return pw;
1091
1.21k
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1092
1.21k
        &FN(PW,sort_field_cmp), NULL) < 0)
1093
0
    return FN(PW,free)(pw);
1094
4.90k
  
for (i = pw->n - 1; 1.21k
i >= 1;
--i3.69k
) {
1095
3.69k
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1096
3.64k
      continue;
1097
45
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1098
45
            isl_set_copy(pw->p[i].set));
1099
45
    if (!set)
1100
0
      return FN(PW,free)(pw);
1101
45
    isl_set_free(pw->p[i].set);
1102
45
    FN(EL,free)(pw->p[i].FIELD);
1103
45
    isl_set_free(pw->p[i - 1].set);
1104
45
    pw->p[i - 1].set = set;
1105
59
    for (j = i + 1; j < pw->n; 
++j14
)
1106
14
      pw->p[j - 1] = pw->p[j];
1107
45
    pw->n--;
1108
45
  }
1109
1.21k
1110
1.21k
  return pw;
1111
1.21k
}
isl_pw_aff_sort
Line
Count
Source
1083
24.9k
{
1084
24.9k
  int i, j;
1085
24.9k
  isl_set *set;
1086
24.9k
1087
24.9k
  if (!pw)
1088
0
    return NULL;
1089
24.9k
  if (pw->n <= 1)
1090
24.5k
    return pw;
1091
374
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1092
374
        &FN(PW,sort_field_cmp), NULL) < 0)
1093
0
    return FN(PW,free)(pw);
1094
902
  
for (i = pw->n - 1; 374
i >= 1;
--i528
) {
1095
528
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1096
521
      continue;
1097
7
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1098
7
            isl_set_copy(pw->p[i].set));
1099
7
    if (!set)
1100
0
      return FN(PW,free)(pw);
1101
7
    isl_set_free(pw->p[i].set);
1102
7
    FN(EL,free)(pw->p[i].FIELD);
1103
7
    isl_set_free(pw->p[i - 1].set);
1104
7
    pw->p[i - 1].set = set;
1105
19
    for (j = i + 1; j < pw->n; 
++j12
)
1106
12
      pw->p[j - 1] = pw->p[j];
1107
7
    pw->n--;
1108
7
  }
1109
374
1110
374
  return pw;
1111
374
}
isl_pw_multi_aff_sort
Line
Count
Source
1083
4.59k
{
1084
4.59k
  int i, j;
1085
4.59k
  isl_set *set;
1086
4.59k
1087
4.59k
  if (!pw)
1088
6
    return NULL;
1089
4.58k
  if (pw->n <= 1)
1090
3.74k
    return pw;
1091
838
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1092
838
        &FN(PW,sort_field_cmp), NULL) < 0)
1093
0
    return FN(PW,free)(pw);
1094
4.00k
  
for (i = pw->n - 1; 838
i >= 1;
--i3.16k
) {
1095
3.16k
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1096
3.12k
      continue;
1097
38
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1098
38
            isl_set_copy(pw->p[i].set));
1099
38
    if (!set)
1100
0
      return FN(PW,free)(pw);
1101
38
    isl_set_free(pw->p[i].set);
1102
38
    FN(EL,free)(pw->p[i].FIELD);
1103
38
    isl_set_free(pw->p[i - 1].set);
1104
38
    pw->p[i - 1].set = set;
1105
40
    for (j = i + 1; j < pw->n; 
++j2
)
1106
2
      pw->p[j - 1] = pw->p[j];
1107
38
    pw->n--;
1108
38
  }
1109
838
1110
838
  return pw;
1111
838
}
isl_pw_qpolynomial_fold_sort
Line
Count
Source
1083
2
{
1084
2
  int i, j;
1085
2
  isl_set *set;
1086
2
1087
2
  if (!pw)
1088
0
    return NULL;
1089
2
  if (pw->n <= 1)
1090
2
    return pw;
1091
0
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1092
0
        &FN(PW,sort_field_cmp), NULL) < 0)
1093
0
    return FN(PW,free)(pw);
1094
0
  for (i = pw->n - 1; i >= 1; --i) {
1095
0
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1096
0
      continue;
1097
0
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1098
0
            isl_set_copy(pw->p[i].set));
1099
0
    if (!set)
1100
0
      return FN(PW,free)(pw);
1101
0
    isl_set_free(pw->p[i].set);
1102
0
    FN(EL,free)(pw->p[i].FIELD);
1103
0
    isl_set_free(pw->p[i - 1].set);
1104
0
    pw->p[i - 1].set = set;
1105
0
    for (j = i + 1; j < pw->n; ++j)
1106
0
      pw->p[j - 1] = pw->p[j];
1107
0
    pw->n--;
1108
0
  }
1109
0
1110
0
  return pw;
1111
0
}
isl_pw_qpolynomial_sort
Line
Count
Source
1083
7
{
1084
7
  int i, j;
1085
7
  isl_set *set;
1086
7
1087
7
  if (!pw)
1088
0
    return NULL;
1089
7
  if (pw->n <= 1)
1090
6
    return pw;
1091
1
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1092
1
        &FN(PW,sort_field_cmp), NULL) < 0)
1093
0
    return FN(PW,free)(pw);
1094
2
  
for (i = pw->n - 1; 1
i >= 1;
--i1
) {
1095
1
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1096
1
      continue;
1097
0
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1098
0
            isl_set_copy(pw->p[i].set));
1099
0
    if (!set)
1100
0
      return FN(PW,free)(pw);
1101
0
    isl_set_free(pw->p[i].set);
1102
0
    FN(EL,free)(pw->p[i].FIELD);
1103
0
    isl_set_free(pw->p[i - 1].set);
1104
0
    pw->p[i - 1].set = set;
1105
0
    for (j = i + 1; j < pw->n; ++j)
1106
0
      pw->p[j - 1] = pw->p[j];
1107
0
    pw->n--;
1108
0
  }
1109
1
1110
1
  return pw;
1111
1
}
1112
1113
/* Coalesce the domains of "pw".
1114
 *
1115
 * Prior to the actual coalescing, first sort the pieces such that
1116
 * pieces with the same function value expression are combined
1117
 * into a single piece, the combined domain of which can then
1118
 * be coalesced.
1119
 */
1120
__isl_give PW *FN(PW,coalesce)(__isl_take PW *pw)
1121
24.6k
{
1122
24.6k
  int i;
1123
24.6k
1124
24.6k
  pw = FN(PW,sort)(pw);
1125
24.6k
  if (!pw)
1126
6
    return NULL;
1127
24.6k
1128
49.8k
  
for (i = 0; 24.6k
i < pw->n;
++i25.1k
) {
1129
25.1k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1130
25.1k
    if (!pw->p[i].set)
1131
0
      goto error;
1132
25.1k
  }
1133
24.6k
1134
24.6k
  return pw;
1135
24.6k
error:
1136
0
  FN(PW,free)(pw);
1137
0
  return NULL;
1138
24.6k
}
isl_pw_aff_coalesce
Line
Count
Source
1121
23.5k
{
1122
23.5k
  int i;
1123
23.5k
1124
23.5k
  pw = FN(PW,sort)(pw);
1125
23.5k
  if (!pw)
1126
0
    return NULL;
1127
23.5k
1128
47.6k
  
for (i = 0; 23.5k
i < pw->n;
++i24.0k
) {
1129
24.0k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1130
24.0k
    if (!pw->p[i].set)
1131
0
      goto error;
1132
24.0k
  }
1133
23.5k
1134
23.5k
  return pw;
1135
23.5k
error:
1136
0
  FN(PW,free)(pw);
1137
0
  return NULL;
1138
23.5k
}
isl_pw_multi_aff_coalesce
Line
Count
Source
1121
1.08k
{
1122
1.08k
  int i;
1123
1.08k
1124
1.08k
  pw = FN(PW,sort)(pw);
1125
1.08k
  if (!pw)
1126
6
    return NULL;
1127
1.08k
1128
2.23k
  
for (i = 0; 1.08k
i < pw->n;
++i1.15k
) {
1129
1.15k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1130
1.15k
    if (!pw->p[i].set)
1131
0
      goto error;
1132
1.15k
  }
1133
1.08k
1134
1.08k
  return pw;
1135
1.08k
error:
1136
0
  FN(PW,free)(pw);
1137
0
  return NULL;
1138
1.08k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_coalesce
isl_pw_qpolynomial_coalesce
Line
Count
Source
1121
1
{
1122
1
  int i;
1123
1
1124
1
  pw = FN(PW,sort)(pw);
1125
1
  if (!pw)
1126
0
    return NULL;
1127
1
1128
3
  
for (i = 0; 1
i < pw->n;
++i2
) {
1129
2
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1130
2
    if (!pw->p[i].set)
1131
0
      goto error;
1132
2
  }
1133
1
1134
1
  return pw;
1135
1
error:
1136
0
  FN(PW,free)(pw);
1137
0
  return NULL;
1138
1
}
1139
1140
isl_ctx *FN(PW,get_ctx)(__isl_keep PW *pw)
1141
21.9k
{
1142
21.9k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1143
21.9k
}
isl_pw_aff_get_ctx
Line
Count
Source
1141
18.4k
{
1142
18.4k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1143
18.4k
}
isl_pw_multi_aff_get_ctx
Line
Count
Source
1141
3.53k
{
1142
3.53k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1143
3.53k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_ctx
isl_pw_qpolynomial_get_ctx
Line
Count
Source
1141
1
{
1142
1
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1143
1
}
1144
1145
isl_bool FN(PW,involves_dims)(__isl_keep PW *pw, enum isl_dim_type type,
1146
  unsigned first, unsigned n)
1147
222
{
1148
222
  int i;
1149
222
  enum isl_dim_type set_type;
1150
222
1151
222
  if (!pw)
1152
0
    return isl_bool_error;
1153
222
  if (pw->n == 0 || n == 0)
1154
0
    return isl_bool_false;
1155
222
1156
222
  set_type = type == isl_dim_in ? 
isl_dim_set219
:
type3
;
1157
222
1158
443
  for (i = 0; i < pw->n; 
++i221
) {
1159
222
    isl_bool involves = FN(EL,involves_dims)(pw->p[i].FIELD,
1160
222
              type, first, n);
1161
222
    if (involves < 0 || involves)
1162
1
      return involves;
1163
221
    involves = isl_set_involves_dims(pw->p[i].set,
1164
221
              set_type, first, n);
1165
221
    if (involves < 0 || involves)
1166
0
      return involves;
1167
221
  }
1168
222
  
return isl_bool_false221
;
1169
222
}
isl_pw_aff_involves_dims
Line
Count
Source
1147
222
{
1148
222
  int i;
1149
222
  enum isl_dim_type set_type;
1150
222
1151
222
  if (!pw)
1152
0
    return isl_bool_error;
1153
222
  if (pw->n == 0 || n == 0)
1154
0
    return isl_bool_false;
1155
222
1156
222
  set_type = type == isl_dim_in ? 
isl_dim_set219
:
type3
;
1157
222
1158
443
  for (i = 0; i < pw->n; 
++i221
) {
1159
222
    isl_bool involves = FN(EL,involves_dims)(pw->p[i].FIELD,
1160
222
              type, first, n);
1161
222
    if (involves < 0 || involves)
1162
1
      return involves;
1163
221
    involves = isl_set_involves_dims(pw->p[i].set,
1164
221
              set_type, first, n);
1165
221
    if (involves < 0 || involves)
1166
0
      return involves;
1167
221
  }
1168
222
  
return isl_bool_false221
;
1169
222
}
Unexecuted instantiation: isl_pw_multi_aff_involves_dims
Unexecuted instantiation: isl_pw_qpolynomial_fold_involves_dims
Unexecuted instantiation: isl_pw_qpolynomial_involves_dims
1170
1171
__isl_give PW *FN(PW,set_dim_name)(__isl_take PW *pw,
1172
  enum isl_dim_type type, unsigned pos, const char *s)
1173
0
{
1174
0
  int i;
1175
0
  enum isl_dim_type set_type;
1176
0
1177
0
  pw = FN(PW,cow)(pw);
1178
0
  if (!pw)
1179
0
    return NULL;
1180
0
1181
0
  set_type = type == isl_dim_in ? isl_dim_set : type;
1182
0
1183
0
  pw->dim = isl_space_set_dim_name(pw->dim, type, pos, s);
1184
0
  if (!pw->dim)
1185
0
    goto error;
1186
0
1187
0
  for (i = 0; i < pw->n; ++i) {
1188
0
    pw->p[i].set = isl_set_set_dim_name(pw->p[i].set,
1189
0
              set_type, pos, s);
1190
0
    if (!pw->p[i].set)
1191
0
      goto error;
1192
0
    pw->p[i].FIELD = FN(EL,set_dim_name)(pw->p[i].FIELD, type, pos, s);
1193
0
    if (!pw->p[i].FIELD)
1194
0
      goto error;
1195
0
  }
1196
0
1197
0
  return pw;
1198
0
error:
1199
0
  FN(PW,free)(pw);
1200
0
  return NULL;
1201
0
}
Unexecuted instantiation: isl_pw_aff_set_dim_name
Unexecuted instantiation: isl_pw_multi_aff_set_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_set_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_set_dim_name
1202
1203
__isl_give PW *FN(PW,drop_dims)(__isl_take PW *pw,
1204
  enum isl_dim_type type, unsigned first, unsigned n)
1205
831
{
1206
831
  int i;
1207
831
  enum isl_dim_type set_type;
1208
831
1209
831
  if (!pw)
1210
0
    return NULL;
1211
831
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)0
)
1212
0
    return pw;
1213
831
1214
831
  set_type = type == isl_dim_in ? 
isl_dim_set219
:
type612
;
1215
831
1216
831
  pw = FN(PW,cow)(pw);
1217
831
  if (!pw)
1218
0
    return NULL;
1219
831
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1220
831
  if (!pw->dim)
1221
0
    goto error;
1222
1.66k
  
for (i = 0; 831
i < pw->n;
++i831
) {
1223
831
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1224
831
    if (!pw->p[i].FIELD)
1225
831
      
goto error0
;
1226
831
    if (type == isl_dim_out)
1227
610
      continue;
1228
221
    pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
1229
221
    if (!pw->p[i].set)
1230
0
      goto error;
1231
221
  }
1232
831
1233
831
  return pw;
1234
831
error:
1235
0
  FN(PW,free)(pw);
1236
0
  return NULL;
1237
831
}
isl_pw_aff_drop_dims
Line
Count
Source
1205
221
{
1206
221
  int i;
1207
221
  enum isl_dim_type set_type;
1208
221
1209
221
  if (!pw)
1210
0
    return NULL;
1211
221
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)0
)
1212
0
    return pw;
1213
221
1214
221
  set_type = type == isl_dim_in ? 
isl_dim_set219
:
type2
;
1215
221
1216
221
  pw = FN(PW,cow)(pw);
1217
221
  if (!pw)
1218
0
    return NULL;
1219
221
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1220
221
  if (!pw->dim)
1221
0
    goto error;
1222
442
  
for (i = 0; 221
i < pw->n;
++i221
) {
1223
221
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1224
221
    if (!pw->p[i].FIELD)
1225
221
      
goto error0
;
1226
221
    if (type == isl_dim_out)
1227
0
      continue;
1228
221
    pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
1229
221
    if (!pw->p[i].set)
1230
0
      goto error;
1231
221
  }
1232
221
1233
221
  return pw;
1234
221
error:
1235
0
  FN(PW,free)(pw);
1236
0
  return NULL;
1237
221
}
isl_pw_multi_aff_drop_dims
Line
Count
Source
1205
610
{
1206
610
  int i;
1207
610
  enum isl_dim_type set_type;
1208
610
1209
610
  if (!pw)
1210
0
    return NULL;
1211
610
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)0
)
1212
0
    return pw;
1213
610
1214
610
  set_type = type == isl_dim_in ? 
isl_dim_set0
: type;
1215
610
1216
610
  pw = FN(PW,cow)(pw);
1217
610
  if (!pw)
1218
0
    return NULL;
1219
610
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1220
610
  if (!pw->dim)
1221
0
    goto error;
1222
1.22k
  
for (i = 0; 610
i < pw->n;
++i610
) {
1223
610
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1224
610
    if (!pw->p[i].FIELD)
1225
610
      
goto error0
;
1226
610
    if (type == isl_dim_out)
1227
610
      continue;
1228
0
    pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
1229
0
    if (!pw->p[i].set)
1230
0
      goto error;
1231
0
  }
1232
610
1233
610
  return pw;
1234
610
error:
1235
0
  FN(PW,free)(pw);
1236
0
  return NULL;
1237
610
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_drop_dims
Unexecuted instantiation: isl_pw_qpolynomial_drop_dims
1238
1239
/* This function is very similar to drop_dims.
1240
 * The only difference is that the cells may still involve
1241
 * the specified dimensions.  They are removed using
1242
 * isl_set_project_out instead of isl_set_drop.
1243
 */
1244
__isl_give PW *FN(PW,project_out)(__isl_take PW *pw,
1245
  enum isl_dim_type type, unsigned first, unsigned n)
1246
211
{
1247
211
  int i;
1248
211
  enum isl_dim_type set_type;
1249
211
1250
211
  if (!pw)
1251
0
    return NULL;
1252
211
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)19
)
1253
0
    return pw;
1254
211
1255
211
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1256
211
1257
211
  pw = FN(PW,cow)(pw);
1258
211
  if (!pw)
1259
0
    return NULL;
1260
211
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1261
211
  if (!pw->dim)
1262
0
    goto error;
1263
604
  
for (i = 0; 211
i < pw->n;
++i393
) {
1264
393
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1265
393
              set_type, first, n);
1266
393
    if (!pw->p[i].set)
1267
0
      goto error;
1268
393
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1269
393
    if (!pw->p[i].FIELD)
1270
393
      
goto error0
;
1271
393
  }
1272
211
1273
211
  return pw;
1274
211
error:
1275
0
  FN(PW,free)(pw);
1276
0
  return NULL;
1277
211
}
isl_pw_aff_project_out
Line
Count
Source
1246
7
{
1247
7
  int i;
1248
7
  enum isl_dim_type set_type;
1249
7
1250
7
  if (!pw)
1251
0
    return NULL;
1252
7
  if (n == 0 && !isl_space_get_tuple_name(pw->dim, type))
1253
0
    return pw;
1254
7
1255
7
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1256
7
1257
7
  pw = FN(PW,cow)(pw);
1258
7
  if (!pw)
1259
0
    return NULL;
1260
7
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1261
7
  if (!pw->dim)
1262
0
    goto error;
1263
16
  
for (i = 0; 7
i < pw->n;
++i9
) {
1264
9
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1265
9
              set_type, first, n);
1266
9
    if (!pw->p[i].set)
1267
0
      goto error;
1268
9
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1269
9
    if (!pw->p[i].FIELD)
1270
9
      
goto error0
;
1271
9
  }
1272
7
1273
7
  return pw;
1274
7
error:
1275
0
  FN(PW,free)(pw);
1276
0
  return NULL;
1277
7
}
isl_pw_multi_aff_project_out
Line
Count
Source
1246
203
{
1247
203
  int i;
1248
203
  enum isl_dim_type set_type;
1249
203
1250
203
  if (!pw)
1251
0
    return NULL;
1252
203
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)11
)
1253
0
    return pw;
1254
203
1255
203
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1256
203
1257
203
  pw = FN(PW,cow)(pw);
1258
203
  if (!pw)
1259
0
    return NULL;
1260
203
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1261
203
  if (!pw->dim)
1262
0
    goto error;
1263
586
  
for (i = 0; 203
i < pw->n;
++i383
) {
1264
383
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1265
383
              set_type, first, n);
1266
383
    if (!pw->p[i].set)
1267
0
      goto error;
1268
383
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1269
383
    if (!pw->p[i].FIELD)
1270
383
      
goto error0
;
1271
383
  }
1272
203
1273
203
  return pw;
1274
203
error:
1275
0
  FN(PW,free)(pw);
1276
0
  return NULL;
1277
203
}
isl_pw_qpolynomial_fold_project_out
Line
Count
Source
1246
1
{
1247
1
  int i;
1248
1
  enum isl_dim_type set_type;
1249
1
1250
1
  if (!pw)
1251
0
    return NULL;
1252
1
  if (n == 0 && !isl_space_get_tuple_name(pw->dim, type))
1253
0
    return pw;
1254
1
1255
1
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1256
1
1257
1
  pw = FN(PW,cow)(pw);
1258
1
  if (!pw)
1259
0
    return NULL;
1260
1
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1261
1
  if (!pw->dim)
1262
0
    goto error;
1263
2
  
for (i = 0; 1
i < pw->n;
++i1
) {
1264
1
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1265
1
              set_type, first, n);
1266
1
    if (!pw->p[i].set)
1267
0
      goto error;
1268
1
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1269
1
    if (!pw->p[i].FIELD)
1270
1
      
goto error0
;
1271
1
  }
1272
1
1273
1
  return pw;
1274
1
error:
1275
0
  FN(PW,free)(pw);
1276
0
  return NULL;
1277
1
}
Unexecuted instantiation: isl_pw_qpolynomial_project_out
1278
1279
/* Project the domain of pw onto its parameter space.
1280
 */
1281
__isl_give PW *FN(PW,project_domain_on_params)(__isl_take PW *pw)
1282
19
{
1283
19
  isl_space *space;
1284
19
  unsigned n;
1285
19
1286
19
  n = FN(PW,dim)(pw, isl_dim_in);
1287
19
  pw = FN(PW,project_out)(pw, isl_dim_in, 0, n);
1288
19
  space = FN(PW,get_domain_space)(pw);
1289
19
  space = isl_space_params(space);
1290
19
  pw = FN(PW,reset_domain_space)(pw, space);
1291
19
  return pw;
1292
19
}
isl_pw_aff_project_domain_on_params
Line
Count
Source
1282
7
{
1283
7
  isl_space *space;
1284
7
  unsigned n;
1285
7
1286
7
  n = FN(PW,dim)(pw, isl_dim_in);
1287
7
  pw = FN(PW,project_out)(pw, isl_dim_in, 0, n);
1288
7
  space = FN(PW,get_domain_space)(pw);
1289
7
  space = isl_space_params(space);
1290
7
  pw = FN(PW,reset_domain_space)(pw, space);
1291
7
  return pw;
1292
7
}
isl_pw_multi_aff_project_domain_on_params
Line
Count
Source
1282
11
{
1283
11
  isl_space *space;
1284
11
  unsigned n;
1285
11
1286
11
  n = FN(PW,dim)(pw, isl_dim_in);
1287
11
  pw = FN(PW,project_out)(pw, isl_dim_in, 0, n);
1288
11
  space = FN(PW,get_domain_space)(pw);
1289
11
  space = isl_space_params(space);
1290
11
  pw = FN(PW,reset_domain_space)(pw, space);
1291
11
  return pw;
1292
11
}
isl_pw_qpolynomial_fold_project_domain_on_params
Line
Count
Source
1282
1
{
1283
1
  isl_space *space;
1284
1
  unsigned n;
1285
1
1286
1
  n = FN(PW,dim)(pw, isl_dim_in);
1287
1
  pw = FN(PW,project_out)(pw, isl_dim_in, 0, n);
1288
1
  space = FN(PW,get_domain_space)(pw);
1289
1
  space = isl_space_params(space);
1290
1
  pw = FN(PW,reset_domain_space)(pw, space);
1291
1
  return pw;
1292
1
}
Unexecuted instantiation: isl_pw_qpolynomial_project_domain_on_params
1293
1294
/* Drop all parameters not referenced by "pw".
1295
 */
1296
__isl_give PW *FN(PW,drop_unused_params)(__isl_take PW *pw)
1297
1
{
1298
1
  int i;
1299
1
1300
1
  if (FN(PW,check_named_params)(pw) < 0)
1301
0
    return FN(PW,free)(pw);
1302
1
1303
4
  
for (i = 1
FN1
(PW,dim)(pw, isl_dim_param) - 1; i >= 0;
i--3
) {
1304
3
    isl_bool involves;
1305
3
1306
3
    involves = FN(PW,involves_dims)(pw, isl_dim_param, i, 1);
1307
3
    if (involves < 0)
1308
0
      return FN(PW,free)(pw);
1309
3
    if (!involves)
1310
2
      pw = FN(PW,drop_dims)(pw, isl_dim_param, i, 1);
1311
3
  }
1312
1
1313
1
  return pw;
1314
1
}
isl_pw_aff_drop_unused_params
Line
Count
Source
1297
1
{
1298
1
  int i;
1299
1
1300
1
  if (FN(PW,check_named_params)(pw) < 0)
1301
0
    return FN(PW,free)(pw);
1302
1
1303
4
  
for (i = 1
FN1
(PW,dim)(pw, isl_dim_param) - 1; i >= 0;
i--3
) {
1304
3
    isl_bool involves;
1305
3
1306
3
    involves = FN(PW,involves_dims)(pw, isl_dim_param, i, 1);
1307
3
    if (involves < 0)
1308
0
      return FN(PW,free)(pw);
1309
3
    if (!involves)
1310
2
      pw = FN(PW,drop_dims)(pw, isl_dim_param, i, 1);
1311
3
  }
1312
1
1313
1
  return pw;
1314
1
}
Unexecuted instantiation: isl_pw_multi_aff_drop_unused_params
Unexecuted instantiation: isl_pw_qpolynomial_fold_drop_unused_params
Unexecuted instantiation: isl_pw_qpolynomial_drop_unused_params
1315
1316
#ifndef NO_INSERT_DIMS
1317
__isl_give PW *FN(PW,insert_dims)(__isl_take PW *pw, enum isl_dim_type type,
1318
  unsigned first, unsigned n)
1319
3.85k
{
1320
3.85k
  int i;
1321
3.85k
  enum isl_dim_type set_type;
1322
3.85k
1323
3.85k
  if (!pw)
1324
0
    return NULL;
1325
3.85k
  if (n == 0 && 
!isl_space_is_named_or_nested(pw->dim, type)15
)
1326
13
    return pw;
1327
3.83k
1328
3.83k
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1329
3.83k
1330
3.83k
  pw = FN(PW,cow)(pw);
1331
3.83k
  if (!pw)
1332
0
    return NULL;
1333
3.83k
1334
3.83k
  pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
1335
3.83k
  if (!pw->dim)
1336
0
    goto error;
1337
3.83k
1338
7.67k
  
for (i = 0; 3.83k
i < pw->n;
++i3.83k
) {
1339
3.83k
    pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1340
3.83k
                  set_type, first, n);
1341
3.83k
    if (!pw->p[i].set)
1342
0
      goto error;
1343
3.83k
    pw->p[i].FIELD = FN(EL,insert_dims)(pw->p[i].FIELD,
1344
3.83k
                type, first, n);
1345
3.83k
    if (!pw->p[i].FIELD)
1346
3.83k
      
goto error0
;
1347
3.83k
  }
1348
3.83k
1349
3.83k
  return pw;
1350
3.83k
error:
1351
0
  FN(PW,free)(pw);
1352
0
  return NULL;
1353
3.83k
}
isl_pw_aff_insert_dims
Line
Count
Source
1319
3.85k
{
1320
3.85k
  int i;
1321
3.85k
  enum isl_dim_type set_type;
1322
3.85k
1323
3.85k
  if (!pw)
1324
0
    return NULL;
1325
3.85k
  if (n == 0 && 
!isl_space_is_named_or_nested(pw->dim, type)15
)
1326
13
    return pw;
1327
3.83k
1328
3.83k
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1329
3.83k
1330
3.83k
  pw = FN(PW,cow)(pw);
1331
3.83k
  if (!pw)
1332
0
    return NULL;
1333
3.83k
1334
3.83k
  pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
1335
3.83k
  if (!pw->dim)
1336
0
    goto error;
1337
3.83k
1338
7.67k
  
for (i = 0; 3.83k
i < pw->n;
++i3.83k
) {
1339
3.83k
    pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1340
3.83k
                  set_type, first, n);
1341
3.83k
    if (!pw->p[i].set)
1342
0
      goto error;
1343
3.83k
    pw->p[i].FIELD = FN(EL,insert_dims)(pw->p[i].FIELD,
1344
3.83k
                type, first, n);
1345
3.83k
    if (!pw->p[i].FIELD)
1346
3.83k
      
goto error0
;
1347
3.83k
  }
1348
3.83k
1349
3.83k
  return pw;
1350
3.83k
error:
1351
0
  FN(PW,free)(pw);
1352
0
  return NULL;
1353
3.83k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_insert_dims
Unexecuted instantiation: isl_pw_qpolynomial_insert_dims
1354
#endif
1355
1356
__isl_give PW *FN(PW,fix_dim)(__isl_take PW *pw,
1357
  enum isl_dim_type type, unsigned pos, isl_int v)
1358
1
{
1359
1
  int i;
1360
1
1361
1
  if (!pw)
1362
0
    return NULL;
1363
1
1364
1
  if (type == isl_dim_in)
1365
0
    type = isl_dim_set;
1366
1
1367
1
  pw = FN(PW,cow)(pw);
1368
1
  if (!pw)
1369
0
    return NULL;
1370
2
  
for (i = 0; 1
i < pw->n;
++i1
) {
1371
1
    pw->p[i].set = isl_set_fix(pw->p[i].set, type, pos, v);
1372
1
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
1373
0
      return FN(PW,free)(pw);
1374
1
  }
1375
1
1376
1
  return pw;
1377
1
}
Unexecuted instantiation: isl_pw_aff_fix_dim
Unexecuted instantiation: isl_pw_multi_aff_fix_dim
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_dim
isl_pw_qpolynomial_fix_dim
Line
Count
Source
1358
1
{
1359
1
  int i;
1360
1
1361
1
  if (!pw)
1362
0
    return NULL;
1363
1
1364
1
  if (type == isl_dim_in)
1365
0
    type = isl_dim_set;
1366
1
1367
1
  pw = FN(PW,cow)(pw);
1368
1
  if (!pw)
1369
0
    return NULL;
1370
2
  
for (i = 0; 1
i < pw->n;
++i1
) {
1371
1
    pw->p[i].set = isl_set_fix(pw->p[i].set, type, pos, v);
1372
1
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
1373
0
      return FN(PW,free)(pw);
1374
1
  }
1375
1
1376
1
  return pw;
1377
1
}
1378
1379
/* Fix the value of the variable at position "pos" of type "type" of "pw"
1380
 * to be equal to "v".
1381
 */
1382
__isl_give PW *FN(PW,fix_val)(__isl_take PW *pw,
1383
  enum isl_dim_type type, unsigned pos, __isl_take isl_val *v)
1384
1
{
1385
1
  if (!v)
1386
0
    return FN(PW,free)(pw);
1387
1
  if (!isl_val_is_int(v))
1388
1
    
isl_die0
(FN(PW,get_ctx)(pw), isl_error_invalid,
1389
1
      "expecting integer value", goto error);
1390
1
1391
1
  pw = FN(PW,fix_dim)(pw, type, pos, v->n);
1392
1
  isl_val_free(v);
1393
1
1394
1
  return pw;
1395
1
error:
1396
0
  isl_val_free(v);
1397
0
  return FN(PW,free)(pw);
1398
1
}
Unexecuted instantiation: isl_pw_aff_fix_val
Unexecuted instantiation: isl_pw_multi_aff_fix_val
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_val
isl_pw_qpolynomial_fix_val
Line
Count
Source
1384
1
{
1385
1
  if (!v)
1386
0
    return FN(PW,free)(pw);
1387
1
  if (!isl_val_is_int(v))
1388
1
    
isl_die0
(FN(PW,get_ctx)(pw), isl_error_invalid,
1389
1
      "expecting integer value", goto error);
1390
1
1391
1
  pw = FN(PW,fix_dim)(pw, type, pos, v->n);
1392
1
  isl_val_free(v);
1393
1
1394
1
  return pw;
1395
1
error:
1396
0
  isl_val_free(v);
1397
0
  return FN(PW,free)(pw);
1398
1
}
1399
1400
unsigned FN(PW,dim)(__isl_keep PW *pw, enum isl_dim_type type)
1401
26.2k
{
1402
26.2k
  return pw ? 
isl_space_dim(pw->dim, type)26.2k
:
03
;
1403
26.2k
}
isl_pw_aff_dim
Line
Count
Source
1401
3.86k
{
1402
3.86k
  return pw ? isl_space_dim(pw->dim, type) : 
00
;
1403
3.86k
}
isl_pw_multi_aff_dim
Line
Count
Source
1401
22.3k
{
1402
22.3k
  return pw ? 
isl_space_dim(pw->dim, type)22.3k
:
03
;
1403
22.3k
}
isl_pw_qpolynomial_fold_dim
Line
Count
Source
1401
3
{
1402
3
  return pw ? isl_space_dim(pw->dim, type) : 
00
;
1403
3
}
Unexecuted instantiation: isl_pw_qpolynomial_dim
1404
1405
__isl_give PW *FN(PW,split_dims)(__isl_take PW *pw,
1406
  enum isl_dim_type type, unsigned first, unsigned n)
1407
0
{
1408
0
  int i;
1409
0
1410
0
  if (!pw)
1411
0
    return NULL;
1412
0
  if (n == 0)
1413
0
    return pw;
1414
0
1415
0
  if (type == isl_dim_in)
1416
0
    type = isl_dim_set;
1417
0
1418
0
  pw = FN(PW,cow)(pw);
1419
0
  if (!pw)
1420
0
    return NULL;
1421
0
  if (!pw->dim)
1422
0
    goto error;
1423
0
  for (i = 0; i < pw->n; ++i) {
1424
0
    pw->p[i].set = isl_set_split_dims(pw->p[i].set, type, first, n);
1425
0
    if (!pw->p[i].set)
1426
0
      goto error;
1427
0
  }
1428
0
1429
0
  return pw;
1430
0
error:
1431
0
  FN(PW,free)(pw);
1432
0
  return NULL;
1433
0
}
Unexecuted instantiation: isl_pw_aff_split_dims
Unexecuted instantiation: isl_pw_multi_aff_split_dims
Unexecuted instantiation: isl_pw_qpolynomial_fold_split_dims
Unexecuted instantiation: isl_pw_qpolynomial_split_dims
1434
1435
#ifndef NO_OPT
1436
/* Compute the maximal value attained by the piecewise quasipolynomial
1437
 * on its domain or zero if the domain is empty.
1438
 * In the worst case, the domain is scanned completely,
1439
 * so the domain is assumed to be bounded.
1440
 */
1441
__isl_give isl_val *FN(PW,opt)(__isl_take PW *pw, int max)
1442
7
{
1443
7
  int i;
1444
7
  isl_val *opt;
1445
7
1446
7
  if (!pw)
1447
0
    return NULL;
1448
7
1449
7
  if (pw->n == 0) {
1450
0
    opt = isl_val_zero(FN(PW,get_ctx)(pw));
1451
0
    FN(PW,free)(pw);
1452
0
    return opt;
1453
0
  }
1454
7
1455
7
  opt = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[0].FIELD),
1456
7
          isl_set_copy(pw->p[0].set), max);
1457
7
  for (i = 1; i < pw->n; 
++i0
) {
1458
0
    isl_val *opt_i;
1459
0
    opt_i = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[i].FIELD),
1460
0
            isl_set_copy(pw->p[i].set), max);
1461
0
    if (max)
1462
0
      opt = isl_val_max(opt, opt_i);
1463
0
    else
1464
0
      opt = isl_val_min(opt, opt_i);
1465
0
  }
1466
7
1467
7
  FN(PW,free)(pw);
1468
7
  return opt;
1469
7
}
isl_pw_qpolynomial_fold_opt
Line
Count
Source
1442
7
{
1443
7
  int i;
1444
7
  isl_val *opt;
1445
7
1446
7
  if (!pw)
1447
0
    return NULL;
1448
7
1449
7
  if (pw->n == 0) {
1450
0
    opt = isl_val_zero(FN(PW,get_ctx)(pw));
1451
0
    FN(PW,free)(pw);
1452
0
    return opt;
1453
0
  }
1454
7
1455
7
  opt = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[0].FIELD),
1456
7
          isl_set_copy(pw->p[0].set), max);
1457
7
  for (i = 1; i < pw->n; 
++i0
) {
1458
0
    isl_val *opt_i;
1459
0
    opt_i = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[i].FIELD),
1460
0
            isl_set_copy(pw->p[i].set), max);
1461
0
    if (max)
1462
0
      opt = isl_val_max(opt, opt_i);
1463
0
    else
1464
0
      opt = isl_val_min(opt, opt_i);
1465
0
  }
1466
7
1467
7
  FN(PW,free)(pw);
1468
7
  return opt;
1469
7
}
Unexecuted instantiation: isl_pw_qpolynomial_opt
1470
1471
__isl_give isl_val *FN(PW,max)(__isl_take PW *pw)
1472
2
{
1473
2
  return FN(PW,opt)(pw, 1);
1474
2
}
isl_pw_qpolynomial_fold_max
Line
Count
Source
1472
2
{
1473
2
  return FN(PW,opt)(pw, 1);
1474
2
}
Unexecuted instantiation: isl_pw_qpolynomial_max
1475
1476
__isl_give isl_val *FN(PW,min)(__isl_take PW *pw)
1477
5
{
1478
5
  return FN(PW,opt)(pw, 0);
1479
5
}
isl_pw_qpolynomial_fold_min
Line
Count
Source
1477
5
{
1478
5
  return FN(PW,opt)(pw, 0);
1479
5
}
Unexecuted instantiation: isl_pw_qpolynomial_min
1480
#endif
1481
1482
/* Return the space of "pw".
1483
 */
1484
__isl_keep isl_space *FN(PW,peek_space)(__isl_keep PW *pw)
1485
276k
{
1486
276k
  return pw ? pw->dim : NULL;
1487
276k
}
isl_pw_aff_peek_space
Line
Count
Source
1485
198k
{
1486
198k
  return pw ? pw->dim : NULL;
1487
198k
}
isl_pw_multi_aff_peek_space
Line
Count
Source
1485
78.0k
{
1486
78.0k
  return pw ? pw->dim : NULL;
1487
78.0k
}
isl_pw_qpolynomial_fold_peek_space
Line
Count
Source
1485
1
{
1486
1
  return pw ? pw->dim : NULL;
1487
1
}
isl_pw_qpolynomial_peek_space
Line
Count
Source
1485
15
{
1486
15
  return pw ? pw->dim : NULL;
1487
15
}
1488
1489
__isl_give isl_space *FN(PW,get_space)(__isl_keep PW *pw)
1490
211k
{
1491
211k
  return isl_space_copy(FN(PW,peek_space)(pw));
1492
211k
}
isl_pw_aff_get_space
Line
Count
Source
1490
152k
{
1491
152k
  return isl_space_copy(FN(PW,peek_space)(pw));
1492
152k
}
isl_pw_multi_aff_get_space
Line
Count
Source
1490
58.6k
{
1491
58.6k
  return isl_space_copy(FN(PW,peek_space)(pw));
1492
58.6k
}
isl_pw_qpolynomial_fold_get_space
Line
Count
Source
1490
1
{
1491
1
  return isl_space_copy(FN(PW,peek_space)(pw));
1492
1
}
isl_pw_qpolynomial_get_space
Line
Count
Source
1490
9
{
1491
9
  return isl_space_copy(FN(PW,peek_space)(pw));
1492
9
}
1493
1494
__isl_give isl_space *FN(PW,get_domain_space)(__isl_keep PW *pw)
1495
112k
{
1496
112k
  return pw ? 
isl_space_domain(isl_space_copy(pw->dim))112k
: NULL;
1497
112k
}
isl_pw_aff_get_domain_space
Line
Count
Source
1495
111k
{
1496
111k
  return pw ? 
isl_space_domain(isl_space_copy(pw->dim))111k
: NULL;
1497
111k
}
isl_pw_multi_aff_get_domain_space
Line
Count
Source
1495
1.09k
{
1496
1.09k
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1497
1.09k
}
isl_pw_qpolynomial_fold_get_domain_space
Line
Count
Source
1495
5
{
1496
5
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1497
5
}
isl_pw_qpolynomial_get_domain_space
Line
Count
Source
1495
2
{
1496
2
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1497
2
}
1498
1499
/* Return the position of the dimension of the given type and name
1500
 * in "pw".
1501
 * Return -1 if no such dimension can be found.
1502
 */
1503
int FN(PW,find_dim_by_name)(__isl_keep PW *pw,
1504
  enum isl_dim_type type, const char *name)
1505
0
{
1506
0
  if (!pw)
1507
0
    return -1;
1508
0
  return isl_space_find_dim_by_name(pw->dim, type, name);
1509
0
}
Unexecuted instantiation: isl_pw_aff_find_dim_by_name
Unexecuted instantiation: isl_pw_multi_aff_find_dim_by_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_find_dim_by_name
Unexecuted instantiation: isl_pw_qpolynomial_find_dim_by_name
1510
1511
#ifndef NO_RESET_DIM
1512
/* Reset the space of "pw".  Since we don't know if the elements
1513
 * represent the spaces themselves or their domains, we pass along
1514
 * both when we call their reset_space_and_domain.
1515
 */
1516
static __isl_give PW *FN(PW,reset_space_and_domain)(__isl_take PW *pw,
1517
  __isl_take isl_space *space, __isl_take isl_space *domain)
1518
70.0k
{
1519
70.0k
  int i;
1520
70.0k
1521
70.0k
  pw = FN(PW,cow)(pw);
1522
70.0k
  if (!pw || !space || !domain)
1523
0
    goto error;
1524
70.0k
1525
140k
  
for (i = 0; 70.0k
i < pw->n;
++i70.8k
) {
1526
70.8k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1527
70.8k
             isl_space_copy(domain));
1528
70.8k
    if (!pw->p[i].set)
1529
0
      goto error;
1530
70.8k
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1531
70.8k
            isl_space_copy(space), isl_space_copy(domain));
1532
70.8k
    if (!pw->p[i].FIELD)
1533
70.8k
      
goto error0
;
1534
70.8k
  }
1535
70.0k
1536
70.0k
  isl_space_free(domain);
1537
70.0k
1538
70.0k
  isl_space_free(pw->dim);
1539
70.0k
  pw->dim = space;
1540
70.0k
1541
70.0k
  return pw;
1542
70.0k
error:
1543
0
  isl_space_free(domain);
1544
0
  isl_space_free(space);
1545
0
  FN(PW,free)(pw);
1546
0
  return NULL;
1547
70.0k
}
isl_aff.c:isl_pw_aff_reset_space_and_domain
Line
Count
Source
1518
67.5k
{
1519
67.5k
  int i;
1520
67.5k
1521
67.5k
  pw = FN(PW,cow)(pw);
1522
67.5k
  if (!pw || !space || !domain)
1523
0
    goto error;
1524
67.5k
1525
135k
  
for (i = 0; 67.5k
i < pw->n;
++i68.1k
) {
1526
68.1k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1527
68.1k
             isl_space_copy(domain));
1528
68.1k
    if (!pw->p[i].set)
1529
0
      goto error;
1530
68.1k
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1531
68.1k
            isl_space_copy(space), isl_space_copy(domain));
1532
68.1k
    if (!pw->p[i].FIELD)
1533
68.1k
      
goto error0
;
1534
68.1k
  }
1535
67.5k
1536
67.5k
  isl_space_free(domain);
1537
67.5k
1538
67.5k
  isl_space_free(pw->dim);
1539
67.5k
  pw->dim = space;
1540
67.5k
1541
67.5k
  return pw;
1542
67.5k
error:
1543
0
  isl_space_free(domain);
1544
0
  isl_space_free(space);
1545
0
  FN(PW,free)(pw);
1546
0
  return NULL;
1547
67.5k
}
isl_aff.c:isl_pw_multi_aff_reset_space_and_domain
Line
Count
Source
1518
2.51k
{
1519
2.51k
  int i;
1520
2.51k
1521
2.51k
  pw = FN(PW,cow)(pw);
1522
2.51k
  if (!pw || !space || !domain)
1523
0
    goto error;
1524
2.51k
1525
5.22k
  
for (i = 0; 2.51k
i < pw->n;
++i2.70k
) {
1526
2.70k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1527
2.70k
             isl_space_copy(domain));
1528
2.70k
    if (!pw->p[i].set)
1529
0
      goto error;
1530
2.70k
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1531
2.70k
            isl_space_copy(space), isl_space_copy(domain));
1532
2.70k
    if (!pw->p[i].FIELD)
1533
2.70k
      
goto error0
;
1534
2.70k
  }
1535
2.51k
1536
2.51k
  isl_space_free(domain);
1537
2.51k
1538
2.51k
  isl_space_free(pw->dim);
1539
2.51k
  pw->dim = space;
1540
2.51k
1541
2.51k
  return pw;
1542
2.51k
error:
1543
0
  isl_space_free(domain);
1544
0
  isl_space_free(space);
1545
0
  FN(PW,free)(pw);
1546
0
  return NULL;
1547
2.51k
}
isl_fold.c:isl_pw_qpolynomial_fold_reset_space_and_domain
Line
Count
Source
1518
4
{
1519
4
  int i;
1520
4
1521
4
  pw = FN(PW,cow)(pw);
1522
4
  if (!pw || !space || !domain)
1523
0
    goto error;
1524
4
1525
7
  
for (i = 0; 4
i < pw->n;
++i3
) {
1526
3
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1527
3
             isl_space_copy(domain));
1528
3
    if (!pw->p[i].set)
1529
0
      goto error;
1530
3
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1531
3
            isl_space_copy(space), isl_space_copy(domain));
1532
3
    if (!pw->p[i].FIELD)
1533
3
      
goto error0
;
1534
3
  }
1535
4
1536
4
  isl_space_free(domain);
1537
4
1538
4
  isl_space_free(pw->dim);
1539
4
  pw->dim = space;
1540
4
1541
4
  return pw;
1542
4
error:
1543
0
  isl_space_free(domain);
1544
0
  isl_space_free(space);
1545
0
  FN(PW,free)(pw);
1546
0
  return NULL;
1547
4
}
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_reset_space_and_domain
1548
1549
__isl_give PW *FN(PW,reset_domain_space)(__isl_take PW *pw,
1550
  __isl_take isl_space *domain)
1551
54.9k
{
1552
54.9k
  isl_space *space;
1553
54.9k
1554
54.9k
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1555
54.9k
               FN(PW,get_space)(pw));
1556
54.9k
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1557
54.9k
}
isl_pw_aff_reset_domain_space
Line
Count
Source
1551
54.9k
{
1552
54.9k
  isl_space *space;
1553
54.9k
1554
54.9k
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1555
54.9k
               FN(PW,get_space)(pw));
1556
54.9k
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1557
54.9k
}
isl_pw_multi_aff_reset_domain_space
Line
Count
Source
1551
18
{
1552
18
  isl_space *space;
1553
18
1554
18
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1555
18
               FN(PW,get_space)(pw));
1556
18
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1557
18
}
isl_pw_qpolynomial_fold_reset_domain_space
Line
Count
Source
1551
1
{
1552
1
  isl_space *space;
1553
1
1554
1
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1555
1
               FN(PW,get_space)(pw));
1556
1
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1557
1
}
Unexecuted instantiation: isl_pw_qpolynomial_reset_domain_space
1558
1559
__isl_give PW *FN(PW,reset_space)(__isl_take PW *pw, __isl_take isl_space *dim)
1560
15.1k
{
1561
15.1k
  isl_space *domain;
1562
15.1k
1563
15.1k
  domain = isl_space_domain(isl_space_copy(dim));
1564
15.1k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1565
15.1k
}
isl_pw_aff_reset_space
Line
Count
Source
1560
12.6k
{
1561
12.6k
  isl_space *domain;
1562
12.6k
1563
12.6k
  domain = isl_space_domain(isl_space_copy(dim));
1564
12.6k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1565
12.6k
}
isl_pw_multi_aff_reset_space
Line
Count
Source
1560
2.49k
{
1561
2.49k
  isl_space *domain;
1562
2.49k
1563
2.49k
  domain = isl_space_domain(isl_space_copy(dim));
1564
2.49k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1565
2.49k
}
isl_pw_qpolynomial_fold_reset_space
Line
Count
Source
1560
3
{
1561
3
  isl_space *domain;
1562
3
1563
3
  domain = isl_space_domain(isl_space_copy(dim));
1564
3
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1565
3
}
Unexecuted instantiation: isl_pw_qpolynomial_reset_space
1566
1567
__isl_give PW *FN(PW,set_tuple_id)(__isl_take PW *pw, enum isl_dim_type type,
1568
  __isl_take isl_id *id)
1569
546
{
1570
546
  isl_space *space;
1571
546
1572
546
  pw = FN(PW,cow)(pw);
1573
546
  if (!pw)
1574
0
    goto error;
1575
546
1576
546
  space = FN(PW,get_space)(pw);
1577
546
  space = isl_space_set_tuple_id(space, type, id);
1578
546
1579
546
  return FN(PW,reset_space)(pw, space);
1580
546
error:
1581
0
  isl_id_free(id);
1582
0
  return FN(PW,free)(pw);
1583
546
}
isl_pw_aff_set_tuple_id
Line
Count
Source
1569
546
{
1570
546
  isl_space *space;
1571
546
1572
546
  pw = FN(PW,cow)(pw);
1573
546
  if (!pw)
1574
0
    goto error;
1575
546
1576
546
  space = FN(PW,get_space)(pw);
1577
546
  space = isl_space_set_tuple_id(space, type, id);
1578
546
1579
546
  return FN(PW,reset_space)(pw, space);
1580
546
error:
1581
0
  isl_id_free(id);
1582
0
  return FN(PW,free)(pw);
1583
546
}
Unexecuted instantiation: isl_pw_multi_aff_set_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_set_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_set_tuple_id
1584
1585
/* Drop the id on the specified tuple.
1586
 */
1587
__isl_give PW *FN(PW,reset_tuple_id)(__isl_take PW *pw, enum isl_dim_type type)
1588
0
{
1589
0
  isl_space *space;
1590
0
1591
0
  if (!pw)
1592
0
    return NULL;
1593
0
  if (!FN(PW,has_tuple_id)(pw, type))
1594
0
    return pw;
1595
0
1596
0
  pw = FN(PW,cow)(pw);
1597
0
  if (!pw)
1598
0
    return NULL;
1599
0
1600
0
  space = FN(PW,get_space)(pw);
1601
0
  space = isl_space_reset_tuple_id(space, type);
1602
0
1603
0
  return FN(PW,reset_space)(pw, space);
1604
0
}
Unexecuted instantiation: isl_pw_aff_reset_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_reset_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_reset_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_reset_tuple_id
1605
1606
__isl_give PW *FN(PW,set_dim_id)(__isl_take PW *pw,
1607
  enum isl_dim_type type, unsigned pos, __isl_take isl_id *id)
1608
0
{
1609
0
  pw = FN(PW,cow)(pw);
1610
0
  if (!pw)
1611
0
    goto error;
1612
0
  pw->dim = isl_space_set_dim_id(pw->dim, type, pos, id);
1613
0
  return FN(PW,reset_space)(pw, isl_space_copy(pw->dim));
1614
0
error:
1615
0
  isl_id_free(id);
1616
0
  return FN(PW,free)(pw);
1617
0
}
Unexecuted instantiation: isl_pw_aff_set_dim_id
Unexecuted instantiation: isl_pw_multi_aff_set_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_set_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_set_dim_id
1618
#endif
1619
1620
/* Reset the user pointer on all identifiers of parameters and tuples
1621
 * of the space of "pw".
1622
 */
1623
__isl_give PW *FN(PW,reset_user)(__isl_take PW *pw)
1624
0
{
1625
0
  isl_space *space;
1626
0
1627
0
  space = FN(PW,get_space)(pw);
1628
0
  space = isl_space_reset_user(space);
1629
0
1630
0
  return FN(PW,reset_space)(pw, space);
1631
0
}
Unexecuted instantiation: isl_pw_aff_reset_user
Unexecuted instantiation: isl_pw_multi_aff_reset_user
Unexecuted instantiation: isl_pw_qpolynomial_fold_reset_user
Unexecuted instantiation: isl_pw_qpolynomial_reset_user
1632
1633
isl_bool FN(PW,has_equal_space)(__isl_keep PW *pw1, __isl_keep PW *pw2)
1634
4
{
1635
4
  if (!pw1 || !pw2)
1636
0
    return isl_bool_error;
1637
4
1638
4
  return isl_space_is_equal(pw1->dim, pw2->dim);
1639
4
}
Unexecuted instantiation: isl_pw_aff_has_equal_space
Unexecuted instantiation: isl_pw_multi_aff_has_equal_space
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_equal_space
isl_pw_qpolynomial_has_equal_space
Line
Count
Source
1634
4
{
1635
4
  if (!pw1 || !pw2)
1636
0
    return isl_bool_error;
1637
4
1638
4
  return isl_space_is_equal(pw1->dim, pw2->dim);
1639
4
}
1640
1641
#ifndef NO_MORPH
1642
__isl_give PW *FN(PW,morph_domain)(__isl_take PW *pw,
1643
  __isl_take isl_morph *morph)
1644
2
{
1645
2
  int i;
1646
2
  isl_ctx *ctx;
1647
2
1648
2
  if (!pw || !morph)
1649
0
    goto error;
1650
2
1651
2
  ctx = isl_space_get_ctx(pw->dim);
1652
2
  isl_assert(ctx, isl_space_is_domain_internal(morph->dom->dim, pw->dim),
1653
2
    goto error);
1654
2
1655
2
  pw = FN(PW,cow)(pw);
1656
2
  if (!pw)
1657
0
    goto error;
1658
2
  pw->dim = isl_space_extend_domain_with_range(
1659
2
      isl_space_copy(morph->ran->dim), pw->dim);
1660
2
  if (!pw->dim)
1661
0
    goto error;
1662
2
1663
3
  
for (i = 0; 2
i < pw->n;
++i1
) {
1664
1
    pw->p[i].set = isl_morph_set(isl_morph_copy(morph), pw->p[i].set);
1665
1
    if (!pw->p[i].set)
1666
0
      goto error;
1667
1
    pw->p[i].FIELD = FN(EL,morph_domain)(pw->p[i].FIELD,
1668
1
            isl_morph_copy(morph));
1669
1
    if (!pw->p[i].FIELD)
1670
1
      
goto error0
;
1671
1
  }
1672
2
1673
2
  isl_morph_free(morph);
1674
2
1675
2
  return pw;
1676
2
error:
1677
0
  FN(PW,free)(pw);
1678
0
  isl_morph_free(morph);
1679
0
  return NULL;
1680
2
}
isl_pw_qpolynomial_fold_morph_domain
Line
Count
Source
1644
2
{
1645
2
  int i;
1646
2
  isl_ctx *ctx;
1647
2
1648
2
  if (!pw || !morph)
1649
0
    goto error;
1650
2
1651
2
  ctx = isl_space_get_ctx(pw->dim);
1652
2
  isl_assert(ctx, isl_space_is_domain_internal(morph->dom->dim, pw->dim),
1653
2
    goto error);
1654
2
1655
2
  pw = FN(PW,cow)(pw);
1656
2
  if (!pw)
1657
0
    goto error;
1658
2
  pw->dim = isl_space_extend_domain_with_range(
1659
2
      isl_space_copy(morph->ran->dim), pw->dim);
1660
2
  if (!pw->dim)
1661
0
    goto error;
1662
2
1663
3
  
for (i = 0; 2
i < pw->n;
++i1
) {
1664
1
    pw->p[i].set = isl_morph_set(isl_morph_copy(morph), pw->p[i].set);
1665
1
    if (!pw->p[i].set)
1666
0
      goto error;
1667
1
    pw->p[i].FIELD = FN(EL,morph_domain)(pw->p[i].FIELD,
1668
1
            isl_morph_copy(morph));
1669
1
    if (!pw->p[i].FIELD)
1670
1
      
goto error0
;
1671
1
  }
1672
2
1673
2
  isl_morph_free(morph);
1674
2
1675
2
  return pw;
1676
2
error:
1677
0
  FN(PW,free)(pw);
1678
0
  isl_morph_free(morph);
1679
0
  return NULL;
1680
2
}
Unexecuted instantiation: isl_pw_qpolynomial_morph_domain
1681
#endif
1682
1683
int FN(PW,n_piece)(__isl_keep PW *pw)
1684
11.1k
{
1685
11.1k
  return pw ? pw->n : 
00
;
1686
11.1k
}
isl_pw_aff_n_piece
Line
Count
Source
1684
11.1k
{
1685
11.1k
  return pw ? pw->n : 
00
;
1686
11.1k
}
Unexecuted instantiation: isl_pw_multi_aff_n_piece
Unexecuted instantiation: isl_pw_qpolynomial_fold_n_piece
Unexecuted instantiation: isl_pw_qpolynomial_n_piece
1687
1688
isl_stat FN(PW,foreach_piece)(__isl_keep PW *pw,
1689
  isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el, void *user),
1690
  void *user)
1691
12.3k
{
1692
12.3k
  int i;
1693
12.3k
1694
12.3k
  if (!pw)
1695
0
    return isl_stat_error;
1696
12.3k
1697
21.4k
  
for (i = 0; 12.3k
i < pw->n;
++i9.04k
)
1698
12.7k
    if (fn(isl_set_copy(pw->p[i].set),
1699
12.7k
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1700
3.69k
      return isl_stat_error;
1701
12.3k
1702
12.3k
  
return isl_stat_ok8.66k
;
1703
12.3k
}
isl_pw_aff_foreach_piece
Line
Count
Source
1691
12.3k
{
1692
12.3k
  int i;
1693
12.3k
1694
12.3k
  if (!pw)
1695
0
    return isl_stat_error;
1696
12.3k
1697
21.4k
  
for (i = 0; 12.3k
i < pw->n;
++i9.04k
)
1698
12.7k
    if (fn(isl_set_copy(pw->p[i].set),
1699
12.7k
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1700
3.69k
      return isl_stat_error;
1701
12.3k
1702
12.3k
  
return isl_stat_ok8.66k
;
1703
12.3k
}
isl_pw_multi_aff_foreach_piece
Line
Count
Source
1691
2
{
1692
2
  int i;
1693
2
1694
2
  if (!pw)
1695
0
    return isl_stat_error;
1696
2
1697
4
  
for (i = 0; 2
i < pw->n;
++i2
)
1698
2
    if (fn(isl_set_copy(pw->p[i].set),
1699
2
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1700
0
      return isl_stat_error;
1701
2
1702
2
  return isl_stat_ok;
1703
2
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_foreach_piece
isl_pw_qpolynomial_foreach_piece
Line
Count
Source
1691
1
{
1692
1
  int i;
1693
1
1694
1
  if (!pw)
1695
0
    return isl_stat_error;
1696
1
1697
3
  
for (i = 0; 1
i < pw->n;
++i2
)
1698
2
    if (fn(isl_set_copy(pw->p[i].set),
1699
2
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1700
0
      return isl_stat_error;
1701
1
1702
1
  return isl_stat_ok;
1703
1
}
1704
1705
#ifndef NO_LIFT
1706
static isl_bool any_divs(__isl_keep isl_set *set)
1707
2
{
1708
2
  int i;
1709
2
1710
2
  if (!set)
1711
0
    return isl_bool_error;
1712
2
1713
3
  
for (i = 0; 2
i < set->n;
++i1
)
1714
2
    if (set->p[i]->n_div > 0)
1715
1
      return isl_bool_true;
1716
2
1717
2
  
return isl_bool_false1
;
1718
2
}
isl_fold.c:any_divs
Line
Count
Source
1707
2
{
1708
2
  int i;
1709
2
1710
2
  if (!set)
1711
0
    return isl_bool_error;
1712
2
1713
3
  
for (i = 0; 2
i < set->n;
++i1
)
1714
2
    if (set->p[i]->n_div > 0)
1715
1
      return isl_bool_true;
1716
2
1717
2
  
return isl_bool_false1
;
1718
2
}
Unexecuted instantiation: isl_polynomial.c:any_divs
1719
1720
static isl_stat foreach_lifted_subset(__isl_take isl_set *set,
1721
  __isl_take EL *el,
1722
  isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el,
1723
    void *user), void *user)
1724
1
{
1725
1
  int i;
1726
1
1727
1
  if (!set || !el)
1728
0
    goto error;
1729
1
1730
2
  
for (i = 0; 1
i < set->n;
++i1
) {
1731
1
    isl_set *lift;
1732
1
    EL *copy;
1733
1
1734
1
    lift = isl_set_from_basic_set(isl_basic_set_copy(set->p[i]));
1735
1
    lift = isl_set_lift(lift);
1736
1
1737
1
    copy = FN(EL,copy)(el);
1738
1
    copy = FN(EL,lift)(copy, isl_set_get_space(lift));
1739
1
1740
1
    if (fn(lift, copy, user) < 0)
1741
0
      goto error;
1742
1
  }
1743
1
1744
1
  isl_set_free(set);
1745
1
  FN(EL,free)(el);
1746
1
1747
1
  return isl_stat_ok;
1748
1
error:
1749
0
  isl_set_free(set);
1750
0
  FN(EL,free)(el);
1751
0
  return isl_stat_error;
1752
1
}
isl_fold.c:foreach_lifted_subset
Line
Count
Source
1724
1
{
1725
1
  int i;
1726
1
1727
1
  if (!set || !el)
1728
0
    goto error;
1729
1
1730
2
  
for (i = 0; 1
i < set->n;
++i1
) {
1731
1
    isl_set *lift;
1732
1
    EL *copy;
1733
1
1734
1
    lift = isl_set_from_basic_set(isl_basic_set_copy(set->p[i]));
1735
1
    lift = isl_set_lift(lift);
1736
1
1737
1
    copy = FN(EL,copy)(el);
1738
1
    copy = FN(EL,lift)(copy, isl_set_get_space(lift));
1739
1
1740
1
    if (fn(lift, copy, user) < 0)
1741
0
      goto error;
1742
1
  }
1743
1
1744
1
  isl_set_free(set);
1745
1
  FN(EL,free)(el);
1746
1
1747
1
  return isl_stat_ok;
1748
1
error:
1749
0
  isl_set_free(set);
1750
0
  FN(EL,free)(el);
1751
0
  return isl_stat_error;
1752
1
}
Unexecuted instantiation: isl_polynomial.c:foreach_lifted_subset
1753
1754
isl_stat FN(PW,foreach_lifted_piece)(__isl_keep PW *pw,
1755
  isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el,
1756
        void *user), void *user)
1757
2
{
1758
2
  int i;
1759
2
1760
2
  if (!pw)
1761
0
    return isl_stat_error;
1762
2
1763
4
  
for (i = 0; 2
i < pw->n;
++i2
) {
1764
2
    isl_bool any;
1765
2
    isl_set *set;
1766
2
    EL *el;
1767
2
1768
2
    any = any_divs(pw->p[i].set);
1769
2
    if (any < 0)
1770
0
      return isl_stat_error;
1771
2
    set = isl_set_copy(pw->p[i].set);
1772
2
    el = FN(EL,copy)(pw->p[i].FIELD);
1773
2
    if (!any) {
1774
1
      if (fn(set, el, user) < 0)
1775
0
        return isl_stat_error;
1776
1
      continue;
1777
1
    }
1778
1
    if (foreach_lifted_subset(set, el, fn, user) < 0)
1779
0
      return isl_stat_error;
1780
1
  }
1781
2
1782
2
  return isl_stat_ok;
1783
2
}
isl_pw_qpolynomial_fold_foreach_lifted_piece
Line
Count
Source
1757
2
{
1758
2
  int i;
1759
2
1760
2
  if (!pw)
1761
0
    return isl_stat_error;
1762
2
1763
4
  
for (i = 0; 2
i < pw->n;
++i2
) {
1764
2
    isl_bool any;
1765
2
    isl_set *set;
1766
2
    EL *el;
1767
2
1768
2
    any = any_divs(pw->p[i].set);
1769
2
    if (any < 0)
1770
0
      return isl_stat_error;
1771
2
    set = isl_set_copy(pw->p[i].set);
1772
2
    el = FN(EL,copy)(pw->p[i].FIELD);
1773
2
    if (!any) {
1774
1
      if (fn(set, el, user) < 0)
1775
0
        return isl_stat_error;
1776
1
      continue;
1777
1
    }
1778
1
    if (foreach_lifted_subset(set, el, fn, user) < 0)
1779
0
      return isl_stat_error;
1780
1
  }
1781
2
1782
2
  return isl_stat_ok;
1783
2
}
Unexecuted instantiation: isl_pw_qpolynomial_foreach_lifted_piece
1784
#endif
1785
1786
#ifndef NO_MOVE_DIMS
1787
__isl_give PW *FN(PW,move_dims)(__isl_take PW *pw,
1788
  enum isl_dim_type dst_type, unsigned dst_pos,
1789
  enum isl_dim_type src_type, unsigned src_pos, unsigned n)
1790
1
{
1791
1
  int i;
1792
1
1793
1
  pw = FN(PW,cow)(pw);
1794
1
  if (!pw)
1795
0
    return NULL;
1796
1
1797
1
  pw->dim = isl_space_move_dims(pw->dim, dst_type, dst_pos, src_type, src_pos, n);
1798
1
  if (!pw->dim)
1799
0
    goto error;
1800
1
1801
2
  
for (i = 0; 1
i < pw->n;
++i1
) {
1802
1
    pw->p[i].FIELD = FN(EL,move_dims)(pw->p[i].FIELD,
1803
1
          dst_type, dst_pos, src_type, src_pos, n);
1804
1
    if (!pw->p[i].FIELD)
1805
1
      
goto error0
;
1806
1
  }
1807
1
1808
1
  if (dst_type == isl_dim_in)
1809
0
    dst_type = isl_dim_set;
1810
1
  if (src_type == isl_dim_in)
1811
1
    src_type = isl_dim_set;
1812
1
1813
2
  for (i = 0; i < pw->n; 
++i1
) {
1814
1
    pw->p[i].set = isl_set_move_dims(pw->p[i].set,
1815
1
            dst_type, dst_pos,
1816
1
            src_type, src_pos, n);
1817
1
    if (!pw->p[i].set)
1818
0
      goto error;
1819
1
  }
1820
1
1821
1
  return pw;
1822
1
error:
1823
0
  FN(PW,free)(pw);
1824
0
  return NULL;
1825
1
}
Unexecuted instantiation: isl_pw_aff_move_dims
Unexecuted instantiation: isl_pw_multi_aff_move_dims
Unexecuted instantiation: isl_pw_qpolynomial_fold_move_dims
isl_pw_qpolynomial_move_dims
Line
Count
Source
1790
1
{
1791
1
  int i;
1792
1
1793
1
  pw = FN(PW,cow)(pw);
1794
1
  if (!pw)
1795
0
    return NULL;
1796
1
1797
1
  pw->dim = isl_space_move_dims(pw->dim, dst_type, dst_pos, src_type, src_pos, n);
1798
1
  if (!pw->dim)
1799
0
    goto error;
1800
1
1801
2
  
for (i = 0; 1
i < pw->n;
++i1
) {
1802
1
    pw->p[i].FIELD = FN(EL,move_dims)(pw->p[i].FIELD,
1803
1
          dst_type, dst_pos, src_type, src_pos, n);
1804
1
    if (!pw->p[i].FIELD)
1805
1
      
goto error0
;
1806
1
  }
1807
1
1808
1
  if (dst_type == isl_dim_in)
1809
0
    dst_type = isl_dim_set;
1810
1
  if (src_type == isl_dim_in)
1811
1
    src_type = isl_dim_set;
1812
1
1813
2
  for (i = 0; i < pw->n; 
++i1
) {
1814
1
    pw->p[i].set = isl_set_move_dims(pw->p[i].set,
1815
1
            dst_type, dst_pos,
1816
1
            src_type, src_pos, n);
1817
1
    if (!pw->p[i].set)
1818
0
      goto error;
1819
1
  }
1820
1
1821
1
  return pw;
1822
1
error:
1823
0
  FN(PW,free)(pw);
1824
0
  return NULL;
1825
1
}
1826
#endif
1827
1828
__isl_give PW *FN(PW,mul_isl_int)(__isl_take PW *pw, isl_int v)
1829
4.56k
{
1830
4.56k
  int i;
1831
4.56k
1832
4.56k
  if (isl_int_is_one(v))
1833
4.56k
    
return pw0
;
1834
4.56k
  if (pw && DEFAULT_IS_ZERO && 
isl_int_is_zero0
(v)) {
1835
0
    PW *zero;
1836
0
    isl_space *dim = FN(PW,get_space)(pw);
1837
#ifdef HAS_TYPE
1838
0
    zero = FN(PW,ZERO)(dim, pw->type);
1839
#else
1840
0
    zero = FN(PW,ZERO)(dim);
1841
#endif
1842
0
    FN(PW,free)(pw);
1843
0
    return zero;
1844
0
  }
1845
4.56k
  pw = FN(PW,cow)(pw);
1846
4.56k
  if (!pw)
1847
0
    return NULL;
1848
4.56k
  if (pw->n == 0)
1849
0
    return pw;
1850
0
1851
#ifdef HAS_TYPE
1852
0
  if (isl_int_is_neg(v))
1853
0
    pw->type = isl_fold_type_negate(pw->type);
1854
#endif
1855
9.42k
  
for (i = 0; 4.56k
i < pw->n;
++i4.85k
) {
1856
4.85k
    pw->p[i].FIELD = FN(EL,scale)(pw->p[i].FIELD, v);
1857
4.85k
    if (!pw->p[i].FIELD)
1858
4.85k
      
goto error0
;
1859
4.85k
  }
1860
4.56k
1861
4.56k
  return pw;
1862
4.56k
error:
1863
0
  FN(PW,free)(pw);
1864
0
  return NULL;
1865
4.56k
}
isl_pw_aff_mul_isl_int
Line
Count
Source
1829
4.56k
{
1830
4.56k
  int i;
1831
4.56k
1832
4.56k
  if (isl_int_is_one(v))
1833
4.56k
    
return pw0
;
1834
4.56k
  if (pw && DEFAULT_IS_ZERO && 
isl_int_is_zero0
(v)) {
1835
0
    PW *zero;
1836
0
    isl_space *dim = FN(PW,get_space)(pw);
1837
#ifdef HAS_TYPE
1838
    zero = FN(PW,ZERO)(dim, pw->type);
1839
#else
1840
0
    zero = FN(PW,ZERO)(dim);
1841
0
#endif
1842
0
    FN(PW,free)(pw);
1843
0
    return zero;
1844
0
  }
1845
4.56k
  pw = FN(PW,cow)(pw);
1846
4.56k
  if (!pw)
1847
0
    return NULL;
1848
4.56k
  if (pw->n == 0)
1849
0
    return pw;
1850
4.56k
1851
#ifdef HAS_TYPE
1852
  if (isl_int_is_neg(v))
1853
    pw->type = isl_fold_type_negate(pw->type);
1854
#endif
1855
9.42k
  
for (i = 0; 4.56k
i < pw->n;
++i4.85k
) {
1856
4.85k
    pw->p[i].FIELD = FN(EL,scale)(pw->p[i].FIELD, v);
1857
4.85k
    if (!pw->p[i].FIELD)
1858
4.85k
      
goto error0
;
1859
4.85k
  }
1860
4.56k
1861
4.56k
  return pw;
1862
4.56k
error:
1863
0
  FN(PW,free)(pw);
1864
0
  return NULL;
1865
4.56k
}
Unexecuted instantiation: isl_pw_multi_aff_mul_isl_int
Unexecuted instantiation: isl_pw_qpolynomial_fold_mul_isl_int
Unexecuted instantiation: isl_pw_qpolynomial_mul_isl_int
1866
1867
/* Multiply the pieces of "pw" by "v" and return the result.
1868
 */
1869
__isl_give PW *FN(PW,scale_val)(__isl_take PW *pw, __isl_take isl_val *v)
1870
165
{
1871
165
  int i;
1872
165
1873
165