Coverage Report

Created: 2018-12-13 20:48

/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
279k
{
28
279k
  isl_ctx *ctx;
29
279k
  struct PW *pw;
30
279k
31
279k
  if (!dim)
32
0
    return NULL;
33
279k
  ctx = isl_space_get_ctx(dim);
34
279k
  isl_assert(ctx, n >= 0, goto error);
35
279k
  pw = isl_alloc(ctx, struct PW,
36
279k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
37
279k
  if (!pw)
38
0
    goto error;
39
279k
40
279k
  pw->ref = 1;
41
#ifdef HAS_TYPE
42
  pw->type = type;
43
#endif
44
  pw->size = n;
45
279k
  pw->n = 0;
46
279k
  pw->dim = dim;
47
279k
  return pw;
48
279k
error:
49
0
  isl_space_free(dim);
50
0
  return NULL;
51
279k
}
isl_pw_aff_alloc_size
Line
Count
Source
27
246k
{
28
246k
  isl_ctx *ctx;
29
246k
  struct PW *pw;
30
246k
31
246k
  if (!dim)
32
0
    return NULL;
33
246k
  ctx = isl_space_get_ctx(dim);
34
246k
  isl_assert(ctx, n >= 0, goto error);
35
246k
  pw = isl_alloc(ctx, struct PW,
36
246k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
37
246k
  if (!pw)
38
0
    goto error;
39
246k
40
246k
  pw->ref = 1;
41
#ifdef HAS_TYPE
42
  pw->type = type;
43
#endif
44
  pw->size = n;
45
246k
  pw->n = 0;
46
246k
  pw->dim = dim;
47
246k
  return pw;
48
246k
error:
49
0
  isl_space_free(dim);
50
0
  return NULL;
51
246k
}
isl_pw_multi_aff_alloc_size
Line
Count
Source
27
33.0k
{
28
33.0k
  isl_ctx *ctx;
29
33.0k
  struct PW *pw;
30
33.0k
31
33.0k
  if (!dim)
32
0
    return NULL;
33
33.0k
  ctx = isl_space_get_ctx(dim);
34
33.0k
  isl_assert(ctx, n >= 0, goto error);
35
33.0k
  pw = isl_alloc(ctx, struct PW,
36
33.0k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
37
33.0k
  if (!pw)
38
0
    goto error;
39
33.0k
40
33.0k
  pw->ref = 1;
41
#ifdef HAS_TYPE
42
  pw->type = type;
43
#endif
44
  pw->size = n;
45
33.0k
  pw->n = 0;
46
33.0k
  pw->dim = dim;
47
33.0k
  return pw;
48
33.0k
error:
49
0
  isl_space_free(dim);
50
0
  return NULL;
51
33.0k
}
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
7.84k
{
61
7.84k
  return FN(PW,alloc_size)(dim, 0);
62
7.84k
}
isl_pw_aff_empty
Line
Count
Source
60
3.36k
{
61
3.36k
  return FN(PW,alloc_size)(dim, 0);
62
3.36k
}
isl_pw_multi_aff_empty
Line
Count
Source
60
4.47k
{
61
4.47k
  return FN(PW,alloc_size)(dim, 0);
62
4.47k
}
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
281k
{
68
281k
  isl_ctx *ctx;
69
281k
  isl_space *el_dim = NULL;
70
281k
71
281k
  if (!pw || !set || !el)
72
0
    goto error;
73
281k
74
281k
  if (isl_set_plain_is_empty(set) || 
FN280k
(EL,EL_IS_ZERO)(el)280k
) {
75
790
    isl_set_free(set);
76
790
    FN(EL,free)(el);
77
790
    return pw;
78
790
  }
79
280k
80
280k
  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
280k
  
el_dim = 18
FN(EL,get_space(el));
87
280k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
88
280k
  isl_assert(ctx, pw->n < pw->size, goto error);
89
280k
90
280k
  pw->p[pw->n].set = set;
91
280k
  pw->p[pw->n].FIELD = el;
92
280k
  pw->n++;
93
280k
  
94
280k
  isl_space_free(el_dim);
95
280k
  return pw;
96
280k
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
280k
}
isl_pw_aff_add_piece
Line
Count
Source
67
248k
{
68
248k
  isl_ctx *ctx;
69
248k
  isl_space *el_dim = NULL;
70
248k
71
248k
  if (!pw || !set || !el)
72
0
    goto error;
73
248k
74
248k
  if (isl_set_plain_is_empty(set) || 
FN247k
(EL,EL_IS_ZERO)(el)247k
) {
75
391
    isl_set_free(set);
76
391
    FN(EL,free)(el);
77
391
    return pw;
78
391
  }
79
247k
80
247k
  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
247k
  el_dim = FN(EL,get_space(el));
87
247k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
88
247k
  isl_assert(ctx, pw->n < pw->size, goto error);
89
247k
90
247k
  pw->p[pw->n].set = set;
91
247k
  pw->p[pw->n].FIELD = el;
92
247k
  pw->n++;
93
247k
  
94
247k
  isl_space_free(el_dim);
95
247k
  return pw;
96
247k
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
247k
}
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.5k
(EL,EL_IS_ZERO)(el)32.5k
) {
75
340
    isl_set_free(set);
76
340
    FN(EL,free)(el);
77
340
    return pw;
78
340
  }
79
32.5k
80
32.5k
  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.5k
  el_dim = FN(EL,get_space(el));
87
32.5k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
88
32.5k
  isl_assert(ctx, pw->n < pw->size, goto error);
89
32.5k
90
32.5k
  pw->p[pw->n].set = set;
91
32.5k
  pw->p[pw->n].FIELD = el;
92
32.5k
  pw->n++;
93
32.5k
  
94
32.5k
  isl_space_free(el_dim);
95
32.5k
  return pw;
96
32.5k
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.5k
}
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
106k
{
109
106k
  isl_bool ok;
110
106k
  isl_space *el_space, *set_space;
111
106k
112
106k
  if (!set || 
!el106k
)
113
3
    return isl_bool_error;
114
106k
  set_space = isl_set_get_space(set);
115
106k
  el_space = FN(EL,get_space)(el);
116
106k
  ok = isl_space_is_domain_internal(set_space, el_space);
117
106k
  isl_space_free(el_space);
118
106k
  isl_space_free(set_space);
119
106k
  return ok;
120
106k
}
isl_aff.c:isl_pw_aff_compatible_domain
Line
Count
Source
108
82.2k
{
109
82.2k
  isl_bool ok;
110
82.2k
  isl_space *el_space, *set_space;
111
82.2k
112
82.2k
  if (!set || 
!el82.2k
)
113
3
    return isl_bool_error;
114
82.2k
  set_space = isl_set_get_space(set);
115
82.2k
  el_space = FN(EL,get_space)(el);
116
82.2k
  ok = isl_space_is_domain_internal(set_space, el_space);
117
82.2k
  isl_space_free(el_space);
118
82.2k
  isl_space_free(set_space);
119
82.2k
  return ok;
120
82.2k
}
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
106k
{
127
106k
  isl_bool ok;
128
106k
129
106k
  ok = FN(PW,compatible_domain)(el, set);
130
106k
  if (ok < 0)
131
3
    return isl_stat_error;
132
106k
  if (!ok)
133
106k
    
isl_die0
(isl_set_get_ctx(set), isl_error_invalid,
134
106k
      "incompatible spaces", return isl_stat_error);
135
106k
136
106k
  return isl_stat_ok;
137
106k
}
isl_aff.c:isl_pw_aff_check_compatible_domain
Line
Count
Source
126
82.2k
{
127
82.2k
  isl_bool ok;
128
82.2k
129
82.2k
  ok = FN(PW,compatible_domain)(el, set);
130
82.2k
  if (ok < 0)
131
3
    return isl_stat_error;
132
82.2k
  if (!ok)
133
82.2k
    
isl_die0
(isl_set_get_ctx(set), isl_error_invalid,
134
82.2k
      "incompatible spaces", return isl_stat_error);
135
82.2k
136
82.2k
  return isl_stat_ok;
137
82.2k
}
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
106k
{
146
106k
  PW *pw;
147
106k
148
106k
  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
106k
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
155
#endif
156
157
106k
  return FN(PW,add_piece)(pw, set, el);
158
106k
error:
159
3
  isl_set_free(set);
160
3
  FN(EL,free)(el);
161
3
  return NULL;
162
106k
}
isl_pw_aff_alloc
Line
Count
Source
145
82.2k
{
146
82.2k
  PW *pw;
147
82.2k
148
82.2k
  if (FN(PW,check_compatible_domain)(el, set) < 0)
149
3
    goto error;
150
82.2k
151
#ifdef HAS_TYPE
152
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
153
#else
154
82.2k
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
155
82.2k
#endif
156
82.2k
157
82.2k
  return FN(PW,add_piece)(pw, set, el);
158
82.2k
error:
159
3
  isl_set_free(set);
160
3
  FN(EL,free)(el);
161
3
  return NULL;
162
82.2k
}
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
68.5k
{
166
68.5k
  int i;
167
68.5k
  PW *dup;
168
68.5k
169
68.5k
  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
68.5k
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
176
#endif
177
68.5k
  if (!dup)
178
0
    return NULL;
179
68.5k
180
139k
  
for (i = 0; 68.5k
i < pw->n;
++i70.5k
)
181
70.5k
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
182
70.5k
              FN(EL,copy)(pw->p[i].FIELD));
183
68.5k
184
68.5k
  return dup;
185
68.5k
}
isl_pw_aff_dup
Line
Count
Source
165
67.1k
{
166
67.1k
  int i;
167
67.1k
  PW *dup;
168
67.1k
169
67.1k
  if (!pw)
170
0
    return NULL;
171
67.1k
172
#ifdef HAS_TYPE
173
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
174
#else
175
67.1k
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
176
67.1k
#endif
177
67.1k
  if (!dup)
178
0
    return NULL;
179
67.1k
180
136k
  
for (i = 0; 67.1k
i < pw->n;
++i69.1k
)
181
69.1k
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
182
69.1k
              FN(EL,copy)(pw->p[i].FIELD));
183
67.1k
184
67.1k
  return dup;
185
67.1k
}
isl_pw_multi_aff_dup
Line
Count
Source
165
1.40k
{
166
1.40k
  int i;
167
1.40k
  PW *dup;
168
1.40k
169
1.40k
  if (!pw)
170
0
    return NULL;
171
1.40k
172
#ifdef HAS_TYPE
173
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
174
#else
175
1.40k
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
176
1.40k
#endif
177
1.40k
  if (!dup)
178
0
    return NULL;
179
1.40k
180
2.83k
  
for (i = 0; 1.40k
i < pw->n;
++i1.43k
)
181
1.43k
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
182
1.43k
              FN(EL,copy)(pw->p[i].FIELD));
183
1.40k
184
1.40k
  return dup;
185
1.40k
}
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
196k
{
189
196k
  if (!pw)
190
0
    return NULL;
191
196k
192
196k
  if (pw->ref == 1)
193
128k
    return pw;
194
68.5k
  pw->ref--;
195
68.5k
  return FN(PW,dup)(pw);
196
68.5k
}
isl_pw_aff_cow
Line
Count
Source
188
186k
{
189
186k
  if (!pw)
190
0
    return NULL;
191
186k
192
186k
  if (pw->ref == 1)
193
119k
    return pw;
194
67.1k
  pw->ref--;
195
67.1k
  return FN(PW,dup)(pw);
196
67.1k
}
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.19k
    return pw;
194
1.40k
  pw->ref--;
195
1.40k
  return FN(PW,dup)(pw);
196
1.40k
}
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
476k
{
200
476k
  if (!pw)
201
47.0k
    return NULL;
202
429k
203
429k
  pw->ref++;
204
429k
  return pw;
205
429k
}
isl_pw_aff_copy
Line
Count
Source
199
434k
{
200
434k
  if (!pw)
201
47.0k
    return NULL;
202
387k
203
387k
  pw->ref++;
204
387k
  return pw;
205
387k
}
isl_pw_multi_aff_copy
Line
Count
Source
199
42.3k
{
200
42.3k
  if (!pw)
201
9
    return NULL;
202
42.3k
203
42.3k
  pw->ref++;
204
42.3k
  return pw;
205
42.3k
}
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
686k
{
209
686k
  int i;
210
686k
211
686k
  if (!pw)
212
46.5k
    return NULL;
213
640k
  if (--pw->ref > 0)
214
361k
    return NULL;
215
278k
216
559k
  
for (i = 0; 278k
i < pw->n;
++i280k
) {
217
280k
    isl_set_free(pw->p[i].set);
218
280k
    FN(EL,free)(pw->p[i].FIELD);
219
280k
  }
220
278k
  isl_space_free(pw->dim);
221
278k
  free(pw);
222
278k
223
278k
  return NULL;
224
278k
}
isl_pw_aff_free
Line
Count
Source
208
612k
{
209
612k
  int i;
210
612k
211
612k
  if (!pw)
212
46.5k
    return NULL;
213
565k
  if (--pw->ref > 0)
214
320k
    return NULL;
215
245k
216
493k
  
for (i = 0; 245k
i < pw->n;
++i247k
) {
217
247k
    isl_set_free(pw->p[i].set);
218
247k
    FN(EL,free)(pw->p[i].FIELD);
219
247k
  }
220
245k
  isl_space_free(pw->dim);
221
245k
  free(pw);
222
245k
223
245k
  return NULL;
224
245k
}
isl_pw_multi_aff_free
Line
Count
Source
208
74.0k
{
209
74.0k
  int i;
210
74.0k
211
74.0k
  if (!pw)
212
3
    return NULL;
213
73.9k
  if (--pw->ref > 0)
214
40.9k
    return NULL;
215
33.0k
216
65.5k
  
for (i = 0; 33.0k
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.0k
  isl_space_free(pw->dim);
221
33.0k
  free(pw);
222
33.0k
223
33.0k
  return NULL;
224
33.0k
}
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
71.5k
{
266
71.5k
  if (!pw)
267
0
    return isl_bool_error;
268
71.5k
269
71.5k
  return pw->n == 0;
270
71.5k
}
isl_pw_aff_is_empty
Line
Count
Source
265
45.7k
{
266
45.7k
  if (!pw)
267
0
    return isl_bool_error;
268
45.7k
269
45.7k
  return pw->n == 0;
270
45.7k
}
isl_pw_multi_aff_is_empty
Line
Count
Source
265
25.6k
{
266
25.6k
  if (!pw)
267
0
    return isl_bool_error;
268
25.6k
269
25.6k
  return pw->n == 0;
270
25.6k
}
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.68k
{
276
9.68k
  int i;
277
9.68k
278
9.68k
  pw = FN(PW,cow)(pw);
279
9.68k
  if (!pw || !exp)
280
0
    goto error;
281
9.68k
282
19.8k
  
for (i = 0; 9.68k
i < pw->n;
++i10.2k
) {
283
10.2k
    pw->p[i].set = isl_set_realign(pw->p[i].set,
284
10.2k
                isl_reordering_copy(exp));
285
10.2k
    if (!pw->p[i].set)
286
0
      goto error;
287
10.2k
    pw->p[i].FIELD = FN(EL,realign_domain)(pw->p[i].FIELD,
288
10.2k
                isl_reordering_copy(exp));
289
10.2k
    if (!pw->p[i].FIELD)
290
10.2k
      
goto error0
;
291
10.2k
  }
292
9.68k
293
9.68k
  pw = FN(PW,reset_domain_space)(pw, isl_reordering_get_space(exp));
294
9.68k
295
9.68k
  isl_reordering_free(exp);
296
9.68k
  return pw;
297
9.68k
error:
298
0
  isl_reordering_free(exp);
299
0
  FN(PW,free)(pw);
300
0
  return NULL;
301
9.68k
}
isl_pw_aff_realign_domain
Line
Count
Source
275
9.67k
{
276
9.67k
  int i;
277
9.67k
278
9.67k
  pw = FN(PW,cow)(pw);
279
9.67k
  if (!pw || !exp)
280
0
    goto error;
281
9.67k
282
19.8k
  
for (i = 0; 9.67k
i < pw->n;
++i10.2k
) {
283
10.2k
    pw->p[i].set = isl_set_realign(pw->p[i].set,
284
10.2k
                isl_reordering_copy(exp));
285
10.2k
    if (!pw->p[i].set)
286
0
      goto error;
287
10.2k
    pw->p[i].FIELD = FN(EL,realign_domain)(pw->p[i].FIELD,
288
10.2k
                isl_reordering_copy(exp));
289
10.2k
    if (!pw->p[i].FIELD)
290
10.2k
      
goto error0
;
291
10.2k
  }
292
9.67k
293
9.67k
  pw = FN(PW,reset_domain_space)(pw, isl_reordering_get_space(exp));
294
9.67k
295
9.67k
  isl_reordering_free(exp);
296
9.67k
  return pw;
297
9.67k
error:
298
0
  isl_reordering_free(exp);
299
0
  FN(PW,free)(pw);
300
0
  return NULL;
301
9.67k
}
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
66.1k
{
308
66.1k
  return isl_space_check_named_params(FN(PW,peek_space)(pw));
309
66.1k
}
isl_pw_aff_check_named_params
Line
Count
Source
307
46.3k
{
308
46.3k
  return isl_space_check_named_params(FN(PW,peek_space)(pw));
309
46.3k
}
isl_pw_multi_aff_check_named_params
Line
Count
Source
307
19.7k
{
308
19.7k
  return isl_space_check_named_params(FN(PW,peek_space)(pw));
309
19.7k
}
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.8k
{
315
55.8k
  isl_ctx *ctx;
316
55.8k
  isl_bool equal_params;
317
55.8k
318
55.8k
  if (!pw || !model)
319
0
    goto error;
320
55.8k
321
55.8k
  ctx = isl_space_get_ctx(model);
322
55.8k
  if (!isl_space_has_named_params(model))
323
55.8k
    
isl_die0
(ctx, isl_error_invalid,
324
55.8k
      "model has unnamed parameters", goto error);
325
55.8k
  if (FN(PW,check_named_params)(pw) < 0)
326
0
    goto error;
327
55.8k
  equal_params = isl_space_has_equal_params(pw->dim, model);
328
55.8k
  if (equal_params < 0)
329
0
    goto error;
330
55.8k
  if (!equal_params) {
331
9.32k
    isl_reordering *exp;
332
9.32k
333
9.32k
    exp = isl_parameter_alignment_reordering(pw->dim, model);
334
9.32k
    exp = isl_reordering_extend_space(exp,
335
9.32k
          FN(PW,get_domain_space)(pw));
336
9.32k
    pw = FN(PW,realign_domain)(pw, exp);
337
9.32k
  }
338
55.8k
339
55.8k
  isl_space_free(model);
340
55.8k
  return pw;
341
55.8k
error:
342
0
  isl_space_free(model);
343
0
  FN(PW,free)(pw);
344
0
  return NULL;
345
55.8k
}
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.32k
    isl_reordering *exp;
332
9.32k
333
9.32k
    exp = isl_parameter_alignment_reordering(pw->dim, model);
334
9.32k
    exp = isl_reordering_extend_space(exp,
335
9.32k
          FN(PW,get_domain_space)(pw));
336
9.32k
    pw = FN(PW,realign_domain)(pw, exp);
337
9.32k
  }
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.7k
{
315
19.7k
  isl_ctx *ctx;
316
19.7k
  isl_bool equal_params;
317
19.7k
318
19.7k
  if (!pw || !model)
319
0
    goto error;
320
19.7k
321
19.7k
  ctx = isl_space_get_ctx(model);
322
19.7k
  if (!isl_space_has_named_params(model))
323
19.7k
    
isl_die0
(ctx, isl_error_invalid,
324
19.7k
      "model has unnamed parameters", goto error);
325
19.7k
  if (FN(PW,check_named_params)(pw) < 0)
326
0
    goto error;
327
19.7k
  equal_params = isl_space_has_equal_params(pw->dim, model);
328
19.7k
  if (equal_params < 0)
329
0
    goto error;
330
19.7k
  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.7k
339
19.7k
  isl_space_free(model);
340
19.7k
  return pw;
341
19.7k
error:
342
0
  isl_space_free(model);
343
0
  FN(PW,free)(pw);
344
0
  return NULL;
345
19.7k
}
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
88.8k
{
351
88.8k
  isl_bool equal_params;
352
88.8k
353
88.8k
  if (!pw1 || 
!pw288.8k
)
354
3
    goto error;
355
88.8k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
356
88.8k
  if (equal_params < 0)
357
0
    goto error;
358
88.8k
  if (equal_params)
359
85.2k
    return fn(pw1, pw2);
360
3.58k
  if (FN(PW,check_named_params)(pw1) < 0 ||
361
3.58k
      FN(PW,check_named_params)(pw2) < 0)
362
0
    goto error;
363
3.58k
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
364
3.58k
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
365
3.58k
  return fn(pw1, pw2);
366
3.58k
error:
367
3
  FN(PW,free)(pw1);
368
3
  FN(PW,free)(pw2);
369
3
  return NULL;
370
3.58k
}
isl_aff.c:isl_pw_aff_align_params_pw_pw_and
Line
Count
Source
350
82.7k
{
351
82.7k
  isl_bool equal_params;
352
82.7k
353
82.7k
  if (!pw1 || 
!pw282.7k
)
354
3
    goto error;
355
82.7k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
356
82.7k
  if (equal_params < 0)
357
0
    goto error;
358
82.7k
  if (equal_params)
359
79.2k
    return fn(pw1, pw2);
360
3.58k
  if (FN(PW,check_named_params)(pw1) < 0 ||
361
3.58k
      FN(PW,check_named_params)(pw2) < 0)
362
0
    goto error;
363
3.58k
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
364
3.58k
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
365
3.58k
  return fn(pw1, pw2);
366
3.58k
error:
367
3
  FN(PW,free)(pw1);
368
3
  FN(PW,free)(pw2);
369
3
  return NULL;
370
3.58k
}
isl_aff.c:isl_pw_multi_aff_align_params_pw_pw_and
Line
Count
Source
350
6.06k
{
351
6.06k
  isl_bool equal_params;
352
6.06k
353
6.06k
  if (!pw1 || !pw2)
354
0
    goto error;
355
6.06k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
356
6.06k
  if (equal_params < 0)
357
0
    goto error;
358
6.06k
  if (equal_params)
359
6.06k
    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.3k
{
376
58.3k
  isl_ctx *ctx;
377
58.3k
  isl_bool aligned;
378
58.3k
379
58.3k
  if (!pw || !set)
380
0
    goto error;
381
58.3k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
382
58.3k
  if (aligned < 0)
383
0
    goto error;
384
58.3k
  if (aligned)
385
58.3k
    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.1k
{
376
53.1k
  isl_ctx *ctx;
377
53.1k
  isl_bool aligned;
378
53.1k
379
53.1k
  if (!pw || !set)
380
0
    goto error;
381
53.1k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
382
53.1k
  if (aligned < 0)
383
0
    goto error;
384
53.1k
  if (aligned)
385
53.1k
    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.16k
{
376
5.16k
  isl_ctx *ctx;
377
5.16k
  isl_bool aligned;
378
5.16k
379
5.16k
  if (!pw || !set)
380
0
    goto error;
381
5.16k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
382
5.16k
  if (aligned < 0)
383
0
    goto error;
384
5.16k
  if (aligned)
385
5.16k
    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.85k
{
405
3.85k
  int i, j, n;
406
3.85k
  struct PW *res;
407
3.85k
  isl_ctx *ctx;
408
3.85k
  isl_set *set;
409
3.85k
410
3.85k
  if (!pw1 || !pw2)
411
0
    goto error;
412
3.85k
413
3.85k
  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.85k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
420
0
421
3.85k
  if (FN(PW,IS_ZERO)(pw1)) {
422
3.51k
    FN(PW,free)(pw1);
423
3.51k
    return pw2;
424
3.51k
  }
425
348
426
348
  if (FN(PW,IS_ZERO)(pw2)) {
427
191
    FN(PW,free)(pw2);
428
191
    return pw1;
429
191
  }
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.44k
{
405
3.44k
  int i, j, n;
406
3.44k
  struct PW *res;
407
3.44k
  isl_ctx *ctx;
408
3.44k
  isl_set *set;
409
3.44k
410
3.44k
  if (!pw1 || !pw2)
411
0
    goto error;
412
3.44k
413
3.44k
  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.44k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
420
3.44k
421
3.44k
  if (FN(PW,IS_ZERO)(pw1)) {
422
3.36k
    FN(PW,free)(pw1);
423
3.36k
    return pw2;
424
3.36k
  }
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
388
{
405
388
  int i, j, n;
406
388
  struct PW *res;
407
388
  isl_ctx *ctx;
408
388
  isl_set *set;
409
388
410
388
  if (!pw1 || !pw2)
411
0
    goto error;
412
388
413
388
  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
388
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
420
388
421
388
  if (FN(PW,IS_ZERO)(pw1)) {
422
148
    FN(PW,free)(pw1);
423
148
    return pw2;
424
148
  }
425
240
426
240
  if (FN(PW,IS_ZERO)(pw2)) {
427
191
    FN(PW,free)(pw2);
428
191
    return pw1;
429
191
  }
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.85k
{
484
3.85k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
485
3.85k
            &FN(PW,union_add_aligned));
486
3.85k
}
isl_aff.c:isl_pw_aff_union_add_
Line
Count
Source
483
3.44k
{
484
3.44k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
485
3.44k
            &FN(PW,union_add_aligned));
486
3.44k
}
isl_aff.c:isl_pw_multi_aff_union_add_
Line
Count
Source
483
388
{
484
388
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
485
388
            &FN(PW,union_add_aligned));
486
388
}
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
469
{
495
469
  int i;
496
469
  isl_ctx *ctx;
497
469
  PW *res;
498
469
499
469
  if (!pw)
500
0
    return NULL;
501
469
  if (pw->n + n <= pw->size)
502
0
    return pw;
503
469
  ctx = FN(PW,get_ctx)(pw);
504
469
  n += pw->n;
505
469
  if (pw->ref == 1) {
506
469
    res = isl_realloc(ctx, pw, struct PW,
507
469
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
508
469
    if (!res)
509
0
      return FN(PW,free)(pw);
510
469
    res->size = n;
511
469
    return res;
512
469
  }
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
360
{
495
360
  int i;
496
360
  isl_ctx *ctx;
497
360
  PW *res;
498
360
499
360
  if (!pw)
500
0
    return NULL;
501
360
  if (pw->n + n <= pw->size)
502
0
    return pw;
503
360
  ctx = FN(PW,get_ctx)(pw);
504
360
  n += pw->n;
505
360
  if (pw->ref == 1) {
506
360
    res = isl_realloc(ctx, pw, struct PW,
507
360
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
508
360
    if (!res)
509
0
      return FN(PW,free)(pw);
510
360
    res->size = n;
511
360
    return res;
512
360
  }
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.54k
{
530
8.54k
  int i;
531
8.54k
  isl_ctx *ctx;
532
8.54k
533
8.54k
  if (!pw1 || !pw2)
534
0
    goto error;
535
8.54k
536
8.54k
  if (pw1->size < pw1->n + pw2->n && 
pw1->n < pw2->n4.38k
)
537
3.91k
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
538
4.63k
539
4.63k
  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.63k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
546
0
547
4.63k
  if (FN(PW,IS_ZERO)(pw1)) {
548
210
    FN(PW,free)(pw1);
549
210
    return pw2;
550
210
  }
551
4.42k
552
4.42k
  if (FN(PW,IS_ZERO)(pw2)) {
553
3.95k
    FN(PW,free)(pw2);
554
3.95k
    return pw1;
555
3.95k
  }
556
469
557
469
  pw1 = FN(PW,grow)(pw1, pw2->n);
558
469
  if (!pw1)
559
0
    goto error;
560
469
561
940
  
for (i = 0; 469
i < pw2->n;
++i471
)
562
471
    pw1 = FN(PW,add_piece)(pw1,
563
471
        isl_set_copy(pw2->p[i].set),
564
471
        FN(EL,copy)(pw2->p[i].FIELD));
565
469
566
469
  FN(PW,free)(pw2);
567
469
568
469
  return pw1;
569
469
error:
570
0
  FN(PW,free)(pw1);
571
0
  FN(PW,free)(pw2);
572
0
  return NULL;
573
469
}
isl_aff.c:isl_pw_aff_add_disjoint_aligned
Line
Count
Source
529
618
{
530
618
  int i;
531
618
  isl_ctx *ctx;
532
618
533
618
  if (!pw1 || !pw2)
534
0
    goto error;
535
618
536
618
  if (pw1->size < pw1->n + pw2->n && 
pw1->n < pw2->n366
)
537
6
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
538
612
539
612
  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
612
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
546
612
547
612
  if (FN(PW,IS_ZERO)(pw1)) {
548
210
    FN(PW,free)(pw1);
549
210
    return pw2;
550
210
  }
551
402
552
402
  if (FN(PW,IS_ZERO)(pw2)) {
553
42
    FN(PW,free)(pw2);
554
42
    return pw1;
555
42
  }
556
360
557
360
  pw1 = FN(PW,grow)(pw1, pw2->n);
558
360
  if (!pw1)
559
0
    goto error;
560
360
561
722
  
for (i = 0; 360
i < pw2->n;
++i362
)
562
362
    pw1 = FN(PW,add_piece)(pw1,
563
362
        isl_set_copy(pw2->p[i].set),
564
362
        FN(EL,copy)(pw2->p[i].FIELD));
565
360
566
360
  FN(PW,free)(pw2);
567
360
568
360
  return pw1;
569
360
error:
570
0
  FN(PW,free)(pw1);
571
0
  FN(PW,free)(pw2);
572
0
  return NULL;
573
360
}
isl_aff.c:isl_pw_multi_aff_add_disjoint_aligned
Line
Count
Source
529
7.92k
{
530
7.92k
  int i;
531
7.92k
  isl_ctx *ctx;
532
7.92k
533
7.92k
  if (!pw1 || !pw2)
534
0
    goto error;
535
7.92k
536
7.92k
  if (pw1->size < pw1->n + pw2->n && 
pw1->n < pw2->n4.01k
)
537
3.90k
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
538
4.01k
539
4.01k
  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.01k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
546
4.01k
547
4.01k
  if (FN(PW,IS_ZERO)(pw1)) {
548
0
    FN(PW,free)(pw1);
549
0
    return pw2;
550
0
  }
551
4.01k
552
4.01k
  if (FN(PW,IS_ZERO)(pw2)) {
553
3.90k
    FN(PW,free)(pw2);
554
3.90k
    return pw1;
555
3.90k
  }
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.63k
{
577
4.63k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
578
4.63k
            &FN(PW,add_disjoint_aligned));
579
4.63k
}
isl_pw_aff_add_disjoint
Line
Count
Source
576
612
{
577
612
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
578
612
            &FN(PW,add_disjoint_aligned));
579
612
}
isl_pw_multi_aff_add_disjoint
Line
Count
Source
576
4.01k
{
577
4.01k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
578
4.01k
            &FN(PW,add_disjoint_aligned));
579
4.01k
}
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
78.4k
{
595
78.4k
  int i, j, n;
596
78.4k
  PW *res = NULL;
597
78.4k
598
78.4k
  if (!pw1 || !pw2)
599
0
    goto error;
600
78.4k
601
78.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
78.4k
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
606
78.4k
#endif
607
78.4k
608
159k
  for (i = 0; i < pw1->n; 
++i80.9k
) {
609
165k
    for (j = 0; j < pw2->n; 
++j84.8k
) {
610
84.8k
      isl_set *common;
611
84.8k
      EL *res_ij;
612
84.8k
      int empty;
613
84.8k
614
84.8k
      common = isl_set_intersect(
615
84.8k
          isl_set_copy(pw1->p[i].set),
616
84.8k
          isl_set_copy(pw2->p[j].set));
617
84.8k
      empty = isl_set_plain_is_empty(common);
618
84.8k
      if (empty < 0 || empty) {
619
3.65k
        isl_set_free(common);
620
3.65k
        if (empty < 0)
621
0
          goto error;
622
3.65k
        continue;
623
3.65k
      }
624
81.2k
625
81.2k
      res_ij = fn(FN(EL,copy)(pw1->p[i].FIELD),
626
81.2k
            FN(EL,copy)(pw2->p[j].FIELD));
627
81.2k
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
628
81.2k
629
81.2k
      res = FN(PW,add_piece)(res, common, res_ij);
630
81.2k
    }
631
80.9k
  }
632
78.4k
633
78.4k
  isl_space_free(space);
634
78.4k
  FN(PW,free)(pw1);
635
78.4k
  FN(PW,free)(pw2);
636
78.4k
  return res;
637
78.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
78.4k
}
isl_aff.c:isl_pw_aff_on_shared_domain_in
Line
Count
Source
594
78.2k
{
595
78.2k
  int i, j, n;
596
78.2k
  PW *res = NULL;
597
78.2k
598
78.2k
  if (!pw1 || !pw2)
599
0
    goto error;
600
78.2k
601
78.2k
  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
78.2k
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
606
78.2k
#endif
607
78.2k
608
159k
  for (i = 0; i < pw1->n; 
++i80.7k
) {
609
165k
    for (j = 0; j < pw2->n; 
++j84.6k
) {
610
84.6k
      isl_set *common;
611
84.6k
      EL *res_ij;
612
84.6k
      int empty;
613
84.6k
614
84.6k
      common = isl_set_intersect(
615
84.6k
          isl_set_copy(pw1->p[i].set),
616
84.6k
          isl_set_copy(pw2->p[j].set));
617
84.6k
      empty = isl_set_plain_is_empty(common);
618
84.6k
      if (empty < 0 || empty) {
619
3.65k
        isl_set_free(common);
620
3.65k
        if (empty < 0)
621
0
          goto error;
622
3.65k
        continue;
623
3.65k
      }
624
81.0k
625
81.0k
      res_ij = fn(FN(EL,copy)(pw1->p[i].FIELD),
626
81.0k
            FN(EL,copy)(pw2->p[j].FIELD));
627
81.0k
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
628
81.0k
629
81.0k
      res = FN(PW,add_piece)(res, common, res_ij);
630
81.0k
    }
631
80.7k
  }
632
78.2k
633
78.2k
  isl_space_free(space);
634
78.2k
  FN(PW,free)(pw1);
635
78.2k
  FN(PW,free)(pw2);
636
78.2k
  return res;
637
78.2k
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
78.2k
}
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
78.2k
{
659
78.2k
  isl_space *space;
660
78.2k
661
78.2k
  if (!pw1 || !pw2)
662
0
    goto error;
663
78.2k
664
78.2k
  space = isl_space_copy(pw1->dim);
665
78.2k
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
666
78.2k
error:
667
0
  FN(PW,free)(pw1);
668
0
  FN(PW,free)(pw2);
669
0
  return NULL;
670
78.2k
}
isl_aff.c:isl_pw_aff_on_shared_domain
Line
Count
Source
658
78.2k
{
659
78.2k
  isl_space *space;
660
78.2k
661
78.2k
  if (!pw1 || !pw2)
662
0
    goto error;
663
78.2k
664
78.2k
  space = isl_space_copy(pw1->dim);
665
78.2k
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
666
78.2k
error:
667
0
  FN(PW,free)(pw1);
668
0
  FN(PW,free)(pw2);
669
0
  return NULL;
670
78.2k
}
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
23.6k
{
675
23.6k
  int i;
676
23.6k
677
23.6k
  if (!pw)
678
0
    return NULL;
679
23.6k
680
23.6k
  if (FN(PW,IS_ZERO)(pw))
681
1
    return pw;
682
23.6k
683
23.6k
  pw = FN(PW,cow)(pw);
684
23.6k
  if (!pw)
685
0
    return NULL;
686
23.6k
687
48.0k
  
for (i = 0; 23.6k
i < pw->n;
++i24.4k
) {
688
24.4k
    pw->p[i].FIELD = FN(EL,neg)(pw->p[i].FIELD);
689
24.4k
    if (!pw->p[i].FIELD)
690
24.4k
      
return 0
FN0
(PW,free)(pw);
691
24.4k
  }
692
23.6k
693
23.6k
  return pw;
694
23.6k
}
isl_pw_aff_neg
Line
Count
Source
674
23.6k
{
675
23.6k
  int i;
676
23.6k
677
23.6k
  if (!pw)
678
0
    return NULL;
679
23.6k
680
23.6k
  if (FN(PW,IS_ZERO)(pw))
681
1
    return pw;
682
23.6k
683
23.6k
  pw = FN(PW,cow)(pw);
684
23.6k
  if (!pw)
685
0
    return NULL;
686
23.6k
687
48.0k
  
for (i = 0; 23.6k
i < pw->n;
++i24.4k
) {
688
24.4k
    pw->p[i].FIELD = FN(EL,neg)(pw->p[i].FIELD);
689
24.4k
    if (!pw->p[i].FIELD)
690
24.4k
      
return 0
FN0
(PW,free)(pw);
691
24.4k
  }
692
23.6k
693
23.6k
  return pw;
694
23.6k
}
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
6.75k
{
700
6.75k
  return FN(PW,add)(pw1, FN(PW,neg)(pw2));
701
6.75k
}
isl_pw_aff_sub
Line
Count
Source
699
6.74k
{
700
6.74k
  return FN(PW,add)(pw1, FN(PW,neg)(pw2));
701
6.74k
}
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.2k
{
713
55.2k
  int i;
714
55.2k
  isl_set *dom;
715
55.2k
716
55.2k
  if (!pw)
717
0
    return NULL;
718
55.2k
719
55.2k
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
720
112k
  for (i = 0; i < pw->n; 
++i56.9k
)
721
56.9k
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
722
55.2k
723
55.2k
  FN(PW,free)(pw);
724
55.2k
725
55.2k
  return dom;
726
55.2k
}
isl_pw_aff_domain
Line
Count
Source
712
54.2k
{
713
54.2k
  int i;
714
54.2k
  isl_set *dom;
715
54.2k
716
54.2k
  if (!pw)
717
0
    return NULL;
718
54.2k
719
54.2k
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
720
110k
  for (i = 0; i < pw->n; 
++i55.8k
)
721
55.8k
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
722
54.2k
723
54.2k
  FN(PW,free)(pw);
724
54.2k
725
54.2k
  return dom;
726
54.2k
}
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
45.8k
{
736
45.8k
  isl_basic_set *aff;
737
45.8k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
738
45.8k
739
45.8k
  if (empty < 0)
740
0
    return -1;
741
45.8k
  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
45.7k
751
45.7k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
752
45.7k
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
753
45.7k
  if (!pw->p[i].FIELD)
754
45.7k
    
return -10
;
755
45.7k
756
45.7k
  return 0;
757
45.7k
}
isl_aff.c:isl_pw_aff_exploit_equalities_and_remove_if_empty
Line
Count
Source
735
42.7k
{
736
42.7k
  isl_basic_set *aff;
737
42.7k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
738
42.7k
739
42.7k
  if (empty < 0)
740
0
    return -1;
741
42.7k
  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
42.7k
751
42.7k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
752
42.7k
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
753
42.7k
  if (!pw->p[i].FIELD)
754
42.7k
    
return -10
;
755
42.7k
756
42.7k
  return 0;
757
42.7k
}
isl_aff.c:isl_pw_multi_aff_exploit_equalities_and_remove_if_empty
Line
Count
Source
735
3.01k
{
736
3.01k
  isl_basic_set *aff;
737
3.01k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
738
3.01k
739
3.01k
  if (empty < 0)
740
0
    return -1;
741
3.01k
  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
3.01k
751
3.01k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
752
3.01k
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
753
3.01k
  if (!pw->p[i].FIELD)
754
3.01k
    
return -10
;
755
3.01k
756
3.01k
  return 0;
757
3.01k
}
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
44.4k
{
822
44.4k
  int i;
823
44.4k
824
44.4k
  if (!pw || !set)
825
0
    goto error;
826
44.4k
827
44.4k
  if (pw->n == 0) {
828
4
    isl_set_free(set);
829
4
    return pw;
830
4
  }
831
44.4k
832
44.4k
  pw = FN(PW,cow)(pw);
833
44.4k
  if (!pw)
834
0
    goto error;
835
44.4k
836
90.3k
  
for (i = pw->n - 1; 44.4k
i >= 0;
--i45.8k
) {
837
45.8k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
838
45.8k
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
839
0
      goto error;
840
45.8k
  }
841
44.4k
  
842
44.4k
  isl_set_free(set);
843
44.4k
  return pw;
844
44.4k
error:
845
0
  isl_set_free(set);
846
0
  FN(PW,free)(pw);
847
0
  return NULL;
848
44.4k
}
isl_aff.c:isl_pw_aff_restrict_domain_aligned
Line
Count
Source
821
41.4k
{
822
41.4k
  int i;
823
41.4k
824
41.4k
  if (!pw || !set)
825
0
    goto error;
826
41.4k
827
41.4k
  if (pw->n == 0) {
828
1
    isl_set_free(set);
829
1
    return pw;
830
1
  }
831
41.4k
832
41.4k
  pw = FN(PW,cow)(pw);
833
41.4k
  if (!pw)
834
0
    goto error;
835
41.4k
836
84.2k
  
for (i = pw->n - 1; 41.4k
i >= 0;
--i42.7k
) {
837
42.7k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
838
42.7k
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
839
0
      goto error;
840
42.7k
  }
841
41.4k
  
842
41.4k
  isl_set_free(set);
843
41.4k
  return pw;
844
41.4k
error:
845
0
  isl_set_free(set);
846
0
  FN(PW,free)(pw);
847
0
  return NULL;
848
41.4k
}
isl_aff.c:isl_pw_multi_aff_restrict_domain_aligned
Line
Count
Source
821
2.99k
{
822
2.99k
  int i;
823
2.99k
824
2.99k
  if (!pw || !set)
825
0
    goto error;
826
2.99k
827
2.99k
  if (pw->n == 0) {
828
2
    isl_set_free(set);
829
2
    return pw;
830
2
  }
831
2.98k
832
2.98k
  pw = FN(PW,cow)(pw);
833
2.98k
  if (!pw)
834
0
    goto error;
835
2.98k
836
6.00k
  
for (i = pw->n - 1; 2.98k
i >= 0;
--i3.01k
) {
837
3.01k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
838
3.01k
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
839
0
      goto error;
840
3.01k
  }
841
2.98k
  
842
2.98k
  isl_set_free(set);
843
2.98k
  return pw;
844
2.98k
error:
845
0
  isl_set_free(set);
846
0
  FN(PW,free)(pw);
847
0
  return NULL;
848
2.98k
}
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.0k
{
853
38.0k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
854
38.0k
}
isl_aff.c:isl_pw_aff_intersect_domain_aligned
Line
Count
Source
852
35.7k
{
853
35.7k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
854
35.7k
}
isl_aff.c:isl_pw_multi_aff_intersect_domain_aligned
Line
Count
Source
852
2.30k
{
853
2.30k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
854
2.30k
}
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.0k
{
859
38.0k
  return FN(PW,align_params_pw_set_and)(pw, context,
860
38.0k
          &FN(PW,intersect_domain_aligned));
861
38.0k
}
isl_pw_aff_intersect_domain
Line
Count
Source
858
35.7k
{
859
35.7k
  return FN(PW,align_params_pw_set_and)(pw, context,
860
35.7k
          &FN(PW,intersect_domain_aligned));
861
35.7k
}
isl_pw_multi_aff_intersect_domain
Line
Count
Source
858
2.30k
{
859
2.30k
  return FN(PW,align_params_pw_set_and)(pw, context,
860
2.30k
          &FN(PW,intersect_domain_aligned));
861
2.30k
}
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.3k
{
908
10.3k
  int i;
909
10.3k
  isl_space *space;
910
10.3k
911
10.3k
  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.3k
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
916
10.3k
  pw->p[0].set = pw->p[pw->n - 1].set;
917
10.3k
  pw->n = 1;
918
10.3k
919
10.3k
  space = isl_set_get_space(context);
920
10.3k
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
921
10.3k
  context = isl_set_universe(space);
922
10.3k
  isl_set_free(pw->p[0].set);
923
10.3k
  pw->p[0].set = context;
924
10.3k
925
10.3k
  if (!pw->p[0].FIELD || !pw->p[0].set)
926
0
    return FN(PW,free)(pw);
927
10.3k
928
10.3k
  return pw;
929
10.3k
}
isl_aff.c:isl_pw_aff_gist_last
Line
Count
Source
907
8.38k
{
908
8.38k
  int i;
909
8.38k
  isl_space *space;
910
8.38k
911
8.38k
  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.38k
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
916
8.38k
  pw->p[0].set = pw->p[pw->n - 1].set;
917
8.38k
  pw->n = 1;
918
8.38k
919
8.38k
  space = isl_set_get_space(context);
920
8.38k
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
921
8.38k
  context = isl_set_universe(space);
922
8.38k
  isl_set_free(pw->p[0].set);
923
8.38k
  pw->p[0].set = context;
924
8.38k
925
8.38k
  if (!pw->p[0].FIELD || !pw->p[0].set)
926
0
    return FN(PW,free)(pw);
927
8.38k
928
8.38k
  return pw;
929
8.38k
}
isl_aff.c:isl_pw_multi_aff_gist_last
Line
Count
Source
907
1.99k
{
908
1.99k
  int i;
909
1.99k
  isl_space *space;
910
1.99k
911
1.99k
  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.99k
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
916
1.99k
  pw->p[0].set = pw->p[pw->n - 1].set;
917
1.99k
  pw->n = 1;
918
1.99k
919
1.99k
  space = isl_set_get_space(context);
920
1.99k
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
921
1.99k
  context = isl_set_universe(space);
922
1.99k
  isl_set_free(pw->p[0].set);
923
1.99k
  pw->p[0].set = context;
924
1.99k
925
1.99k
  if (!pw->p[0].FIELD || !pw->p[0].set)
926
0
    return FN(PW,free)(pw);
927
1.99k
928
1.99k
  return pw;
929
1.99k
}
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.9k
{
945
13.9k
  int i;
946
13.9k
  int is_universe;
947
13.9k
  isl_bool aligned;
948
13.9k
  isl_basic_set *hull = NULL;
949
13.9k
950
13.9k
  if (!pw || !context)
951
0
    goto error;
952
13.9k
953
13.9k
  if (pw->n == 0) {
954
0
    isl_set_free(context);
955
0
    return pw;
956
0
  }
957
13.9k
958
13.9k
  is_universe = isl_set_plain_is_universe(context);
959
13.9k
  if (is_universe < 0)
960
0
    goto error;
961
13.9k
  if (is_universe) {
962
1.15k
    isl_set_free(context);
963
1.15k
    return pw;
964
1.15k
  }
965
12.7k
966
12.7k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
967
12.7k
  if (aligned < 0)
968
0
    goto error;
969
12.7k
  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.7k
974
12.7k
  pw = FN(PW,cow)(pw);
975
12.7k
  if (!pw)
976
0
    goto error;
977
12.7k
978
12.7k
  if (pw->n == 1) {
979
12.7k
    int equal;
980
12.7k
981
12.7k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
982
12.7k
    if (equal < 0)
983
0
      goto error;
984
12.7k
    if (equal)
985
10.3k
      return FN(PW,gist_last)(pw, context, fn_el);
986
2.38k
  }
987
2.38k
988
2.38k
  context = isl_set_compute_divs(context);
989
2.38k
  hull = isl_set_simple_hull(isl_set_copy(context));
990
2.38k
991
4.80k
  for (i = pw->n - 1; i >= 0; 
--i2.42k
) {
992
2.42k
    isl_set *set_i;
993
2.42k
    int empty;
994
2.42k
995
2.42k
    if (i == pw->n - 1) {
996
2.38k
      int equal;
997
2.38k
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
998
2.38k
      if (equal < 0)
999
0
        goto error;
1000
2.38k
      if (equal) {
1001
2
        isl_basic_set_free(hull);
1002
2
        return FN(PW,gist_last)(pw, context, fn_el);
1003
2
      }
1004
2.42k
    }
1005
2.42k
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1006
2.42k
             isl_set_copy(context));
1007
2.42k
    empty = isl_set_plain_is_empty(set_i);
1008
2.42k
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1009
2.42k
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1010
2.42k
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1011
0
      goto error;
1012
2.42k
    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.42k
  }
1020
2.38k
1021
2.38k
  isl_basic_set_free(hull);
1022
2.38k
  isl_set_free(context);
1023
2.38k
1024
2.38k
  return pw;
1025
2.38k
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.38k
}
isl_aff.c:isl_pw_aff_gist_aligned
Line
Count
Source
944
11.7k
{
945
11.7k
  int i;
946
11.7k
  int is_universe;
947
11.7k
  isl_bool aligned;
948
11.7k
  isl_basic_set *hull = NULL;
949
11.7k
950
11.7k
  if (!pw || !context)
951
0
    goto error;
952
11.7k
953
11.7k
  if (pw->n == 0) {
954
0
    isl_set_free(context);
955
0
    return pw;
956
0
  }
957
11.7k
958
11.7k
  is_universe = isl_set_plain_is_universe(context);
959
11.7k
  if (is_universe < 0)
960
0
    goto error;
961
11.7k
  if (is_universe) {
962
1.07k
    isl_set_free(context);
963
1.07k
    return pw;
964
1.07k
  }
965
10.6k
966
10.6k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
967
10.6k
  if (aligned < 0)
968
0
    goto error;
969
10.6k
  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.6k
974
10.6k
  pw = FN(PW,cow)(pw);
975
10.6k
  if (!pw)
976
0
    goto error;
977
10.6k
978
10.6k
  if (pw->n == 1) {
979
10.6k
    int equal;
980
10.6k
981
10.6k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
982
10.6k
    if (equal < 0)
983
0
      goto error;
984
10.6k
    if (equal)
985
8.37k
      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.58k
  for (i = pw->n - 1; i >= 0; 
--i2.30k
) {
992
2.31k
    isl_set *set_i;
993
2.31k
    int empty;
994
2.31k
995
2.31k
    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
2
        isl_basic_set_free(hull);
1002
2
        return FN(PW,gist_last)(pw, context, fn_el);
1003
2
      }
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
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.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_multi_aff_gist_aligned
Line
Count
Source
944
2.17k
{
945
2.17k
  int i;
946
2.17k
  int is_universe;
947
2.17k
  isl_bool aligned;
948
2.17k
  isl_basic_set *hull = NULL;
949
2.17k
950
2.17k
  if (!pw || !context)
951
0
    goto error;
952
2.17k
953
2.17k
  if (pw->n == 0) {
954
0
    isl_set_free(context);
955
0
    return pw;
956
0
  }
957
2.17k
958
2.17k
  is_universe = isl_set_plain_is_universe(context);
959
2.17k
  if (is_universe < 0)
960
0
    goto error;
961
2.17k
  if (is_universe) {
962
76
    isl_set_free(context);
963
76
    return pw;
964
76
  }
965
2.09k
966
2.09k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
967
2.09k
  if (aligned < 0)
968
0
    goto error;
969
2.09k
  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.09k
974
2.09k
  pw = FN(PW,cow)(pw);
975
2.09k
  if (!pw)
976
0
    goto error;
977
2.09k
978
2.09k
  if (pw->n == 1) {
979
2.09k
    int equal;
980
2.09k
981
2.09k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
982
2.09k
    if (equal < 0)
983
0
      goto error;
984
2.09k
    if (equal)
985
1.99k
      return FN(PW,gist_last)(pw, context, fn_el);
986
109
  }
987
109
988
109
  context = isl_set_compute_divs(context);
989
109
  hull = isl_set_simple_hull(isl_set_copy(context));
990
109
991
218
  for (i = pw->n - 1; i >= 0; 
--i109
) {
992
109
    isl_set *set_i;
993
109
    int empty;
994
109
995
109
    if (i == pw->n - 1) {
996
109
      int equal;
997
109
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
998
109
      if (equal < 0)
999
0
        goto error;
1000
109
      if (equal) {
1001
0
        isl_basic_set_free(hull);
1002
0
        return FN(PW,gist_last)(pw, context, fn_el);
1003
0
      }
1004
109
    }
1005
109
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1006
109
             isl_set_copy(context));
1007
109
    empty = isl_set_plain_is_empty(set_i);
1008
109
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1009
109
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1010
109
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1011
0
      goto error;
1012
109
    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
109
  }
1020
109
1021
109
  isl_basic_set_free(hull);
1022
109
  isl_set_free(context);
1023
109
1024
109
  return pw;
1025
109
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
109
}
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.9k
{
1035
13.9k
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1036
13.9k
          &isl_set_gist_basic_set);
1037
13.9k
}
isl_aff.c:isl_pw_aff_gist_domain_aligned
Line
Count
Source
1034
11.7k
{
1035
11.7k
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1036
11.7k
          &isl_set_gist_basic_set);
1037
11.7k
}
isl_aff.c:isl_pw_multi_aff_gist_domain_aligned
Line
Count
Source
1034
2.17k
{
1035
2.17k
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1036
2.17k
          &isl_set_gist_basic_set);
1037
2.17k
}
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.9k
{
1041
13.9k
  return FN(PW,align_params_pw_set_and)(pw, context,
1042
13.9k
            &FN(PW,gist_domain_aligned));
1043
13.9k
}
isl_pw_aff_gist
Line
Count
Source
1040
11.7k
{
1041
11.7k
  return FN(PW,align_params_pw_set_and)(pw, context,
1042
11.7k
            &FN(PW,gist_domain_aligned));
1043
11.7k
}
isl_pw_multi_aff_gist
Line
Count
Source
1040
2.17k
{
1041
2.17k
  return FN(PW,align_params_pw_set_and)(pw, context,
1042
2.17k
            &FN(PW,gist_domain_aligned));
1043
2.17k
}
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.90k
{
1067
6.90k
  struct FN(PW,piece) const *pc1 = p1;
1068
6.90k
  struct FN(PW,piece) const *pc2 = p2;
1069
6.90k
1070
6.90k
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1071
6.90k
}
isl_aff.c:isl_pw_aff_sort_field_cmp
Line
Count
Source
1066
690
{
1067
690
  struct FN(PW,piece) const *pc1 = p1;
1068
690
  struct FN(PW,piece) const *pc2 = p2;
1069
690
1070
690
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1071
690
}
isl_aff.c:isl_pw_multi_aff_sort_field_cmp
Line
Count
Source
1066
6.21k
{
1067
6.21k
  struct FN(PW,piece) const *pc1 = p1;
1068
6.21k
  struct FN(PW,piece) const *pc2 = p2;
1069
6.21k
1070
6.21k
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1071
6.21k
}
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.17k
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1092
1.17k
        &FN(PW,sort_field_cmp), NULL) < 0)
1093
0
    return FN(PW,free)(pw);
1094
4.83k
  
for (i = pw->n - 1; 1.17k
i >= 1;
--i3.65k
) {
1095
3.65k
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1096
3.61k
      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.17k
1110
1.17k
  return pw;
1111
1.17k
}
isl_pw_aff_sort
Line
Count
Source
1083
25.1k
{
1084
25.1k
  int i, j;
1085
25.1k
  isl_set *set;
1086
25.1k
1087
25.1k
  if (!pw)
1088
0
    return NULL;
1089
25.1k
  if (pw->n <= 1)
1090
24.8k
    return pw;
1091
375
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1092
375
        &FN(PW,sort_field_cmp), NULL) < 0)
1093
0
    return FN(PW,free)(pw);
1094
906
  
for (i = pw->n - 1; 375
i >= 1;
--i531
) {
1095
531
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1096
524
      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
375
1110
375
  return pw;
1111
375
}
isl_pw_multi_aff_sort
Line
Count
Source
1083
4.36k
{
1084
4.36k
  int i, j;
1085
4.36k
  isl_set *set;
1086
4.36k
1087
4.36k
  if (!pw)
1088
6
    return NULL;
1089
4.35k
  if (pw->n <= 1)
1090
3.55k
    return pw;
1091
801
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1092
801
        &FN(PW,sort_field_cmp), NULL) < 0)
1093
0
    return FN(PW,free)(pw);
1094
3.92k
  
for (i = pw->n - 1; 801
i >= 1;
--i3.12k
) {
1095
3.12k
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1096
3.08k
      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
801
1110
801
  return pw;
1111
801
}
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.9k
{
1122
24.9k
  int i;
1123
24.9k
1124
24.9k
  pw = FN(PW,sort)(pw);
1125
24.9k
  if (!pw)
1126
6
    return NULL;
1127
24.9k
1128
50.3k
  
for (i = 0; 24.9k
i < pw->n;
++i25.4k
) {
1129
25.4k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1130
25.4k
    if (!pw->p[i].set)
1131
0
      goto error;
1132
25.4k
  }
1133
24.9k
1134
24.9k
  return pw;
1135
24.9k
error:
1136
0
  FN(PW,free)(pw);
1137
0
  return NULL;
1138
24.9k
}
isl_pw_aff_coalesce
Line
Count
Source
1121
23.8k
{
1122
23.8k
  int i;
1123
23.8k
1124
23.8k
  pw = FN(PW,sort)(pw);
1125
23.8k
  if (!pw)
1126
0
    return NULL;
1127
23.8k
1128
48.1k
  
for (i = 0; 23.8k
i < pw->n;
++i24.2k
) {
1129
24.2k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1130
24.2k
    if (!pw->p[i].set)
1131
0
      goto error;
1132
24.2k
  }
1133
23.8k
1134
23.8k
  return pw;
1135
23.8k
error:
1136
0
  FN(PW,free)(pw);
1137
0
  return NULL;
1138
23.8k
}
isl_pw_multi_aff_coalesce
Line
Count
Source
1121
1.09k
{
1122
1.09k
  int i;
1123
1.09k
1124
1.09k
  pw = FN(PW,sort)(pw);
1125
1.09k
  if (!pw)
1126
6
    return NULL;
1127
1.08k
1128
2.24k
  
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.6k
{
1142
18.6k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1143
18.6k
}
isl_pw_multi_aff_get_ctx
Line
Count
Source
1141
3.30k
{
1142
3.30k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1143
3.30k
}
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
836
{
1206
836
  int i;
1207
836
  enum isl_dim_type set_type;
1208
836
1209
836
  if (!pw)
1210
0
    return NULL;
1211
836
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)0
)
1212
0
    return pw;
1213
836
1214
836
  set_type = type == isl_dim_in ? 
isl_dim_set219
:
type617
;
1215
836
1216
836
  pw = FN(PW,cow)(pw);
1217
836
  if (!pw)
1218
0
    return NULL;
1219
836
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1220
836
  if (!pw->dim)
1221
0
    goto error;
1222
1.67k
  
for (i = 0; 836
i < pw->n;
++i836
) {
1223
836
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1224
836
    if (!pw->p[i].FIELD)
1225
836
      
goto error0
;
1226
836
    if (type == isl_dim_out)
1227
615
      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
836
1233
836
  return pw;
1234
836
error:
1235
0
  FN(PW,free)(pw);
1236
0
  return NULL;
1237
836
}
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
615
{
1206
615
  int i;
1207
615
  enum isl_dim_type set_type;
1208
615
1209
615
  if (!pw)
1210
0
    return NULL;
1211
615
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)0
)
1212
0
    return pw;
1213
615
1214
615
  set_type = type == isl_dim_in ? 
isl_dim_set0
: type;
1215
615
1216
615
  pw = FN(PW,cow)(pw);
1217
615
  if (!pw)
1218
0
    return NULL;
1219
615
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1220
615
  if (!pw->dim)
1221
0
    goto error;
1222
1.23k
  
for (i = 0; 615
i < pw->n;
++i615
) {
1223
615
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1224
615
    if (!pw->p[i].FIELD)
1225
615
      
goto error0
;
1226
615
    if (type == isl_dim_out)
1227
615
      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
615
1233
615
  return pw;
1234
615
error:
1235
0
  FN(PW,free)(pw);
1236
0
  return NULL;
1237
615
}
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
183
{
1247
183
  int i;
1248
183
  enum isl_dim_type set_type;
1249
183
1250
183
  if (!pw)
1251
0
    return NULL;
1252
183
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)19
)
1253
0
    return pw;
1254
183
1255
183
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1256
183
1257
183
  pw = FN(PW,cow)(pw);
1258
183
  if (!pw)
1259
0
    return NULL;
1260
183
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1261
183
  if (!pw->dim)
1262
0
    goto error;
1263
520
  
for (i = 0; 183
i < pw->n;
++i337
) {
1264
337
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1265
337
              set_type, first, n);
1266
337
    if (!pw->p[i].set)
1267
0
      goto error;
1268
337
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1269
337
    if (!pw->p[i].FIELD)
1270
337
      
goto error0
;
1271
337
  }
1272
183
1273
183
  return pw;
1274
183
error:
1275
0
  FN(PW,free)(pw);
1276
0
  return NULL;
1277
183
}
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
175
{
1247
175
  int i;
1248
175
  enum isl_dim_type set_type;
1249
175
1250
175
  if (!pw)
1251
0
    return NULL;
1252
175
  if (n == 0 && 
!isl_space_get_tuple_name(pw->dim, type)11
)
1253
0
    return pw;
1254
175
1255
175
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1256
175
1257
175
  pw = FN(PW,cow)(pw);
1258
175
  if (!pw)
1259
0
    return NULL;
1260
175
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1261
175
  if (!pw->dim)
1262
0
    goto error;
1263
502
  
for (i = 0; 175
i < pw->n;
++i327
) {
1264
327
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1265
327
              set_type, first, n);
1266
327
    if (!pw->p[i].set)
1267
0
      goto error;
1268
327
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1269
327
    if (!pw->p[i].FIELD)
1270
327
      
goto error0
;
1271
327
  }
1272
175
1273
175
  return pw;
1274
175
error:
1275
0
  FN(PW,free)(pw);
1276
0
  return NULL;
1277
175
}
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.83k
{
1320
3.83k
  int i;
1321
3.83k
  enum isl_dim_type set_type;
1322
3.83k
1323
3.83k
  if (!pw)
1324
0
    return NULL;
1325
3.83k
  if (n == 0 && 
!isl_space_is_named_or_nested(pw->dim, type)15
)
1326
13
    return pw;
1327
3.82k
1328
3.82k
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1329
3.82k
1330
3.82k
  pw = FN(PW,cow)(pw);
1331
3.82k
  if (!pw)
1332
0
    return NULL;
1333
3.82k
1334
3.82k
  pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
1335
3.82k
  if (!pw->dim)
1336
0
    goto error;
1337
3.82k
1338
7.64k
  
for (i = 0; 3.82k
i < pw->n;
++i3.82k
) {
1339
3.82k
    pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1340
3.82k
                  set_type, first, n);
1341
3.82k
    if (!pw->p[i].set)
1342
0
      goto error;
1343
3.82k
    pw->p[i].FIELD = FN(EL,insert_dims)(pw->p[i].FIELD,
1344
3.82k
                type, first, n);
1345
3.82k
    if (!pw->p[i].FIELD)
1346
3.82k
      
goto error0
;
1347
3.82k
  }
1348
3.82k
1349
3.82k
  return pw;
1350
3.82k
error:
1351
0
  FN(PW,free)(pw);
1352
0
  return NULL;
1353
3.82k
}
isl_pw_aff_insert_dims
Line
Count
Source
1319
3.83k
{
1320
3.83k
  int i;
1321
3.83k
  enum isl_dim_type set_type;
1322
3.83k
1323
3.83k
  if (!pw)
1324
0
    return NULL;
1325
3.83k
  if (n == 0 && 
!isl_space_is_named_or_nested(pw->dim, type)15
)
1326
13
    return pw;
1327
3.82k
1328
3.82k
  set_type = type == isl_dim_in ? isl_dim_set : 
type0
;
1329
3.82k
1330
3.82k
  pw = FN(PW,cow)(pw);
1331
3.82k
  if (!pw)
1332
0
    return NULL;
1333
3.82k
1334
3.82k
  pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
1335
3.82k
  if (!pw->dim)
1336
0
    goto error;
1337
3.82k
1338
7.64k
  
for (i = 0; 3.82k
i < pw->n;
++i3.82k
) {
1339
3.82k
    pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1340
3.82k
                  set_type, first, n);
1341
3.82k
    if (!pw->p[i].set)
1342
0
      goto error;
1343
3.82k
    pw->p[i].FIELD = FN(EL,insert_dims)(pw->p[i].FIELD,
1344
3.82k
                type, first, n);
1345
3.82k
    if (!pw->p[i].FIELD)
1346
3.82k
      
goto error0
;
1347
3.82k
  }
1348
3.82k
1349
3.82k
  return pw;
1350
3.82k
error:
1351
0
  FN(PW,free)(pw);
1352
0
  return NULL;
1353
3.82k
}
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.3k
{
1402
26.3k
  return pw ? 
isl_space_dim(pw->dim, type)26.3k
:
03
;
1403
26.3k
}
isl_pw_aff_dim
Line
Count
Source
1401
3.85k
{
1402
3.85k
  return pw ? isl_space_dim(pw->dim, type) : 
00
;
1403
3.85k
}
isl_pw_multi_aff_dim
Line
Count
Source
1401
22.4k
{
1402
22.4k
  return pw ? 
isl_space_dim(pw->dim, type)22.4k
:
03
;
1403
22.4k
}
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
302k
{
1486
302k
  return pw ? pw->dim : NULL;
1487
302k
}
isl_pw_aff_peek_space
Line
Count
Source
1485
222k
{
1486
222k
  return pw ? pw->dim : NULL;
1487
222k
}
isl_pw_multi_aff_peek_space
Line
Count
Source
1485
79.2k
{
1486
79.2k
  return pw ? pw->dim : NULL;
1487
79.2k
}
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
212k
{
1491
212k
  return isl_space_copy(FN(PW,peek_space)(pw));
1492
212k
}
isl_pw_aff_get_space
Line
Count
Source
1490
153k
{
1491
153k
  return isl_space_copy(FN(PW,peek_space)(pw));
1492
153k
}
isl_pw_multi_aff_get_space
Line
Count
Source
1490
59.4k
{
1491
59.4k
  return isl_space_copy(FN(PW,peek_space)(pw));
1492
59.4k
}
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
111k
{
1496
111k
  return pw ? 
isl_space_domain(isl_space_copy(pw->dim))111k
: NULL;
1497
111k
}
isl_pw_aff_get_domain_space
Line
Count
Source
1495
110k
{
1496
110k
  return pw ? 
isl_space_domain(isl_space_copy(pw->dim))110k
: NULL;
1497
110k
}
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.7k
{
1519
70.7k
  int i;
1520
70.7k
1521
70.7k
  pw = FN(PW,cow)(pw);
1522
70.7k
  if (!pw || !space || !domain)
1523
0
    goto error;
1524
70.7k
1525
142k
  
for (i = 0; 70.7k
i < pw->n;
++i71.4k
) {
1526
71.4k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1527
71.4k
             isl_space_copy(domain));
1528
71.4k
    if (!pw->p[i].set)
1529
0
      goto error;
1530
71.4k
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1531
71.4k
            isl_space_copy(space), isl_space_copy(domain));
1532
71.4k
    if (!pw->p[i].FIELD)
1533
71.4k
      
goto error0
;
1534
71.4k
  }
1535
70.7k
1536
70.7k
  isl_space_free(domain);
1537
70.7k
1538
70.7k
  isl_space_free(pw->dim);
1539
70.7k
  pw->dim = space;
1540
70.7k
1541
70.7k
  return pw;
1542
70.7k
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.7k
}
isl_aff.c:isl_pw_aff_reset_space_and_domain
Line
Count
Source
1518
68.1k
{
1519
68.1k
  int i;
1520
68.1k
1521
68.1k
  pw = FN(PW,cow)(pw);
1522
68.1k
  if (!pw || !space || !domain)
1523
0
    goto error;
1524
68.1k
1525
136k
  
for (i = 0; 68.1k
i < pw->n;
++i68.7k
) {
1526
68.7k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1527
68.7k
             isl_space_copy(domain));
1528
68.7k
    if (!pw->p[i].set)
1529
0
      goto error;
1530
68.7k
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1531
68.7k
            isl_space_copy(space), isl_space_copy(domain));
1532
68.7k
    if (!pw->p[i].FIELD)
1533
68.7k
      
goto error0
;
1534
68.7k
  }
1535
68.1k
1536
68.1k
  isl_space_free(domain);
1537
68.1k
1538
68.1k
  isl_space_free(pw->dim);
1539
68.1k
  pw->dim = space;
1540
68.1k
1541
68.1k
  return pw;
1542
68.1k
error:
1543
0
  isl_space_free(domain);
1544
0
  isl_space_free(space);
1545
0
  FN(PW,free)(pw);
1546
0
  return NULL;
1547
68.1k
}
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.18k
  
for (i = 0; 2.51k
i < pw->n;
++i2.67k
) {
1526
2.67k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1527
2.67k
             isl_space_copy(domain));
1528
2.67k
    if (!pw->p[i].set)
1529
0
      goto error;
1530
2.67k
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1531
2.67k
            isl_space_copy(space), isl_space_copy(domain));
1532
2.67k
    if (!pw->p[i].FIELD)
1533
2.67k
      
goto error0
;
1534
2.67k
  }
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
55.3k
{
1552
55.3k
  isl_space *space;
1553
55.3k
1554
55.3k
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1555
55.3k
               FN(PW,get_space)(pw));
1556
55.3k
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1557
55.3k
}
isl_pw_aff_reset_domain_space
Line
Count
Source
1551
55.3k
{
1552
55.3k
  isl_space *space;
1553
55.3k
1554
55.3k
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1555
55.3k
               FN(PW,get_space)(pw));
1556
55.3k
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1557
55.3k
}
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.3k
{
1561
15.3k
  isl_space *domain;
1562
15.3k
1563
15.3k
  domain = isl_space_domain(isl_space_copy(dim));
1564
15.3k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1565
15.3k
}
isl_pw_aff_reset_space
Line
Count
Source
1560
12.8k
{
1561
12.8k
  isl_space *domain;
1562
12.8k
1563
12.8k
  domain = isl_space_domain(isl_space_copy(dim));
1564
12.8k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1565
12.8k
}
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
549
{
1570
549
  isl_space *space;
1571
549
1572
549
  pw = FN(PW,cow)(pw);
1573
549
  if (!pw)
1574
0
    goto error;
1575
549
1576
549
  space = FN(PW,get_space)(pw);
1577
549
  space = isl_space_set_tuple_id(space, type, id);
1578
549
1579
549
  return FN(PW,reset_space)(pw, space);
1580
549
error:
1581
0
  isl_id_free(id);
1582
0
  return FN(PW,free)(pw);
1583
549
}
isl_pw_aff_set_tuple_id
Line
Count
Source
1569
549
{
1570
549
  isl_space *space;
1571
549
1572
549
  pw = FN(PW,cow)(pw);
1573
549
  if (!pw)
1574
0
    goto error;
1575
549
1576
549
  space = FN(PW,get_space)(pw);
1577
549
  space = isl_space_set_tuple_id(space, type, id);
1578
549
1579
549
  return FN(PW,reset_space)(pw, space);
1580
549
error:
1581
0
  isl_id_free(id);
1582
0
  return FN(PW,free)(pw);
1583
549
}
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.3k
{
1685
11.3k
  return pw ? pw->n : 
00
;
1686
11.3k
}
isl_pw_aff_n_piece
Line
Count
Source
1684
11.3k
{
1685
11.3k
  return pw ? pw->n : 
00
;
1686
11.3k
}
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.5k
{
1692
12.5k
  int i;
1693
12.5k
1694
12.5k
  if (!pw)
1695
0
    return isl_stat_error;
1696
12.5k
1697
21.8k
  
for (i = 0; 12.5k
i < pw->n;
++i9.21k
)
1698
12.9k
    if (fn(isl_set_copy(pw->p[i].set),
1699
12.9k
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1700
3.76k
      return isl_stat_error;
1701
12.5k
1702
12.5k
  
return isl_stat_ok8.83k
;
1703
12.5k
}
isl_pw_aff_foreach_piece
Line
Count
Source
1691
12.5k
{
1692
12.5k
  int i;
1693
12.5k
1694
12.5k
  if (!pw)
1695
0
    return isl_stat_error;
1696
12.5k
1697
21.8k
  
for (i = 0; 12.5k
i < pw->n;
++i9.21k
)
1698
12.9k
    if (fn(isl_set_copy(pw->p[i].set),
1699
12.9k
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1700
3.76k
      return isl_stat_error;
1701
12.5k
1702
12.5k
  
return isl_stat_ok8.83k
;
1703
12.5k
}
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.39k
{
1830
4.39k
  int i;
1831
4.39k
1832
4.39k
  if (isl_int_is_one(v))
1833
4.39k
    
return pw0
;
1834
4.39k
  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.39k
  pw = FN(PW,cow)(pw);
1846
4.39k
  if (!pw)
1847
0
    return NULL;
1848
4.39k
  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.02k
  
for (i = 0; 4.39k
i < pw->n;
++i4.63k
) {
1856
4.63k
    pw->p[i].FIELD = FN(EL,scale)(pw->p[i].FIELD, v);
1857
4.63k
    if (!pw->p[i].FIELD)
1858
4.63k
      
goto error0
;
1859
4.63k
  }
1860
4.39k
1861
4.39k
  return pw;
1862
4.39k
error:
1863
0
  FN(PW,free)(pw);
1864
0
  return NULL;
1865
4.39k
}
isl_pw_aff_mul_isl_int
Line
Count
Source
1829
4.39k
{
1830
4.39k
  int i;
1831
4.39k
1832
4.39k
  if (isl_int_is_one(v))
1833
4.39k
    
return pw0
;
1834
4.39k
  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.39k
  pw = FN(PW,cow)(pw);
1846
4.39k
  if (!pw)
1847
0
    return NULL;
1848
4.39k
  if (pw->n == 0)
1849
0
    return pw;
1850
4.39k
1851
#ifdef HAS_TYPE
1852
  if (isl_int_is_neg(v))
1853
    pw->type = isl_fold_type_negate(pw->type);
1854
#endif
1855
9.02k
  
for (i = 0; 4.39k
i < pw->n;
++i4.63k
) {
1856
4.63k
    pw->p[i].FIELD = FN(EL,scale)(pw->p[i].FIELD, v);
1857
4.63k
    if (!pw->p[i].FIELD)
1858
4.63k
      
goto error0
;
1859
4.63k
  }
1860
4.39k
1861
4.39k
  return pw;
1862
4.39k
error:
1863
0
  FN(PW,free)(pw);
1864
0
  return NULL;
1865
4.39k
}
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
169
{
1871
169
  int i;
1872
169
1873
169
  if (!pw || !v)
1874
0
    goto error;
1875