Coverage Report

Created: 2017-08-21 19:50

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/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/aff.h>
15
#include <isl_sort.h>
16
#include <isl_val_private.h>
17
18
#include <isl_pw_macro.h>
19
20
#ifdef HAS_TYPE
21
__isl_give PW *FN(PW,alloc_size)(__isl_take isl_space *dim,
22
  enum isl_fold type, int n)
23
#else
24
__isl_give PW *FN(PW,alloc_size)(__isl_take isl_space *dim, int n)
25
#endif
26
231k
{
27
231k
  isl_ctx *ctx;
28
231k
  struct PW *pw;
29
231k
30
231k
  if (!dim)
31
0
    return NULL;
32
231k
  ctx = isl_space_get_ctx(dim);
33
231k
  isl_assert(ctx, n >= 0, goto error);
34
231k
  
pw = 231k
isl_alloc231k
(ctx, struct PW,
35
231k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
231k
  if (!pw)
37
0
    goto error;
38
231k
39
231k
  pw->ref = 1;
40
231k
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
231k
  pw->size = n;
44
231k
  pw->n = 0;
45
231k
  pw->dim = dim;
46
231k
  return pw;
47
231k
error:
48
0
  isl_space_free(dim);
49
231k
  return NULL;
50
231k
}
isl_pw_qpolynomial_fold_alloc_size
Line
Count
Source
26
35
{
27
35
  isl_ctx *ctx;
28
35
  struct PW *pw;
29
35
30
35
  if (!dim)
31
0
    return NULL;
32
35
  ctx = isl_space_get_ctx(dim);
33
35
  isl_assert(ctx, n >= 0, goto error);
34
35
  
pw = 35
isl_alloc35
(ctx, struct PW,
35
35
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
35
  if (!pw)
37
0
    goto error;
38
35
39
35
  pw->ref = 1;
40
35
#ifdef HAS_TYPE
41
35
  pw->type = type;
42
35
#endif
43
35
  pw->size = n;
44
35
  pw->n = 0;
45
35
  pw->dim = dim;
46
35
  return pw;
47
35
error:
48
0
  isl_space_free(dim);
49
35
  return NULL;
50
35
}
isl_pw_multi_aff_alloc_size
Line
Count
Source
26
23.9k
{
27
23.9k
  isl_ctx *ctx;
28
23.9k
  struct PW *pw;
29
23.9k
30
23.9k
  if (!dim)
31
0
    return NULL;
32
23.9k
  ctx = isl_space_get_ctx(dim);
33
23.9k
  isl_assert(ctx, n >= 0, goto error);
34
23.9k
  
pw = 23.9k
isl_alloc23.9k
(ctx, struct PW,
35
23.9k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
23.9k
  if (!pw)
37
0
    goto error;
38
23.9k
39
23.9k
  pw->ref = 1;
40
23.9k
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
23.9k
  pw->size = n;
44
23.9k
  pw->n = 0;
45
23.9k
  pw->dim = dim;
46
23.9k
  return pw;
47
23.9k
error:
48
0
  isl_space_free(dim);
49
23.9k
  return NULL;
50
23.9k
}
isl_pw_aff_alloc_size
Line
Count
Source
26
207k
{
27
207k
  isl_ctx *ctx;
28
207k
  struct PW *pw;
29
207k
30
207k
  if (!dim)
31
0
    return NULL;
32
207k
  ctx = isl_space_get_ctx(dim);
33
207k
  isl_assert(ctx, n >= 0, goto error);
34
207k
  
pw = 207k
isl_alloc207k
(ctx, struct PW,
35
207k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
207k
  if (!pw)
37
0
    goto error;
38
207k
39
207k
  pw->ref = 1;
40
207k
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
207k
  pw->size = n;
44
207k
  pw->n = 0;
45
207k
  pw->dim = dim;
46
207k
  return pw;
47
207k
error:
48
0
  isl_space_free(dim);
49
207k
  return NULL;
50
207k
}
isl_pw_qpolynomial_alloc_size
Line
Count
Source
26
104
{
27
104
  isl_ctx *ctx;
28
104
  struct PW *pw;
29
104
30
104
  if (!dim)
31
0
    return NULL;
32
104
  ctx = isl_space_get_ctx(dim);
33
104
  isl_assert(ctx, n >= 0, goto error);
34
104
  
pw = 104
isl_alloc104
(ctx, struct PW,
35
104
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
104
  if (!pw)
37
0
    goto error;
38
104
39
104
  pw->ref = 1;
40
104
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
104
  pw->size = n;
44
104
  pw->n = 0;
45
104
  pw->dim = dim;
46
104
  return pw;
47
104
error:
48
0
  isl_space_free(dim);
49
104
  return NULL;
50
104
}
51
52
#ifdef HAS_TYPE
53
__isl_give PW *FN(PW,ZERO)(__isl_take isl_space *dim, enum isl_fold type)
54
16
{
55
16
  return FN(PW,alloc_size)(dim, type, 0);
56
16
}
57
#else
58
__isl_give PW *FN(PW,ZERO)(__isl_take isl_space *dim)
59
6.99k
{
60
6.99k
  return FN(PW,alloc_size)(dim, 0);
61
6.99k
}
isl_pw_multi_aff_empty
Line
Count
Source
59
3.39k
{
60
3.39k
  return FN(PW,alloc_size)(dim, 0);
61
3.39k
}
isl_pw_aff_empty
Line
Count
Source
59
3.60k
{
60
3.60k
  return FN(PW,alloc_size)(dim, 0);
61
3.60k
}
isl_pw_qpolynomial_zero
Line
Count
Source
59
2
{
60
2
  return FN(PW,alloc_size)(dim, 0);
61
2
}
62
#endif
63
64
__isl_give PW *FN(PW,add_piece)(__isl_take PW *pw,
65
  __isl_take isl_set *set, __isl_take EL *el)
66
230k
{
67
230k
  isl_ctx *ctx;
68
230k
  isl_space *el_dim = NULL;
69
230k
70
230k
  if (
!pw || 230k
!set230k
||
!el230k
)
71
0
    goto error;
72
230k
73
230k
  
if (230k
isl_set_plain_is_empty(set) || 230k
FN229k
(EL,EL_IS_ZERO)(el)229k
)
{658
74
658
    isl_set_free(set);
75
658
    FN(EL,free)(el);
76
658
    return pw;
77
230k
  }
78
230k
79
230k
  ctx = isl_set_get_ctx(set);
80
229k
#ifdef HAS_TYPE
81
18
  if (pw->type != el->type)
82
0
    isl_die(ctx, isl_error_invalid, "fold types don't match",
83
      goto error);
84
#endif
85
229k
  
el_dim = 18
FN229k
(EL,get_space(el));
86
229k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
229k
  
isl_assert229k
(ctx, pw->n < pw->size, goto error);229k
88
229k
89
229k
  pw->p[pw->n].set = set;
90
229k
  pw->p[pw->n].FIELD = el;
91
229k
  pw->n++;
92
229k
  
93
229k
  isl_space_free(el_dim);
94
229k
  return pw;
95
229k
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
229k
  return NULL;
101
230k
}
isl_pw_multi_aff_add_piece
Line
Count
Source
66
21.9k
{
67
21.9k
  isl_ctx *ctx;
68
21.9k
  isl_space *el_dim = NULL;
69
21.9k
70
21.9k
  if (
!pw || 21.9k
!set21.9k
||
!el21.9k
)
71
0
    goto error;
72
21.9k
73
21.9k
  
if (21.9k
isl_set_plain_is_empty(set) || 21.9k
FN21.7k
(EL,EL_IS_ZERO)(el)21.7k
)
{260
74
260
    isl_set_free(set);
75
260
    FN(EL,free)(el);
76
260
    return pw;
77
21.9k
  }
78
21.9k
79
21.9k
  ctx = isl_set_get_ctx(set);
80
21.7k
#ifdef HAS_TYPE
81
  if (pw->type != el->type)
82
    isl_die(ctx, isl_error_invalid, "fold types don't match",
83
      goto error);
84
#endif
85
21.7k
  el_dim = FN(EL,get_space(el));
86
21.7k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
21.7k
  
isl_assert21.7k
(ctx, pw->n < pw->size, goto error);21.7k
88
21.7k
89
21.7k
  pw->p[pw->n].set = set;
90
21.7k
  pw->p[pw->n].FIELD = el;
91
21.7k
  pw->n++;
92
21.7k
  
93
21.7k
  isl_space_free(el_dim);
94
21.7k
  return pw;
95
21.7k
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
21.7k
  return NULL;
101
21.9k
}
isl_pw_qpolynomial_fold_add_piece
Line
Count
Source
66
24
{
67
24
  isl_ctx *ctx;
68
24
  isl_space *el_dim = NULL;
69
24
70
24
  if (
!pw || 24
!set24
||
!el24
)
71
0
    goto error;
72
24
73
24
  
if (24
isl_set_plain_is_empty(set) || 24
FN18
(EL,EL_IS_ZERO)(el)18
)
{6
74
6
    isl_set_free(set);
75
6
    FN(EL,free)(el);
76
6
    return pw;
77
24
  }
78
24
79
24
  ctx = isl_set_get_ctx(set);
80
18
#ifdef HAS_TYPE
81
18
  if (pw->type != el->type)
82
0
    isl_die(ctx, isl_error_invalid, "fold types don't match",
83
18
      goto error);
84
18
#endif
85
18
  
el_dim = 18
FN18
(EL,get_space(el));
86
18
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
18
  
isl_assert18
(ctx, pw->n < pw->size, goto error);18
88
18
89
18
  pw->p[pw->n].set = set;
90
18
  pw->p[pw->n].FIELD = el;
91
18
  pw->n++;
92
18
  
93
18
  isl_space_free(el_dim);
94
18
  return pw;
95
18
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
18
  return NULL;
101
24
}
isl_pw_qpolynomial_add_piece
Line
Count
Source
66
151
{
67
151
  isl_ctx *ctx;
68
151
  isl_space *el_dim = NULL;
69
151
70
151
  if (
!pw || 151
!set151
||
!el151
)
71
0
    goto error;
72
151
73
151
  
if (151
isl_set_plain_is_empty(set) || 151
FN107
(EL,EL_IS_ZERO)(el)107
)
{53
74
53
    isl_set_free(set);
75
53
    FN(EL,free)(el);
76
53
    return pw;
77
151
  }
78
151
79
151
  ctx = isl_set_get_ctx(set);
80
98
#ifdef HAS_TYPE
81
  if (pw->type != el->type)
82
    isl_die(ctx, isl_error_invalid, "fold types don't match",
83
      goto error);
84
#endif
85
98
  el_dim = FN(EL,get_space(el));
86
98
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
98
  
isl_assert98
(ctx, pw->n < pw->size, goto error);98
88
98
89
98
  pw->p[pw->n].set = set;
90
98
  pw->p[pw->n].FIELD = el;
91
98
  pw->n++;
92
98
  
93
98
  isl_space_free(el_dim);
94
98
  return pw;
95
98
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
98
  return NULL;
101
151
}
isl_pw_aff_add_piece
Line
Count
Source
66
208k
{
67
208k
  isl_ctx *ctx;
68
208k
  isl_space *el_dim = NULL;
69
208k
70
208k
  if (
!pw || 208k
!set208k
||
!el208k
)
71
0
    goto error;
72
208k
73
208k
  
if (208k
isl_set_plain_is_empty(set) || 208k
FN208k
(EL,EL_IS_ZERO)(el)208k
)
{339
74
339
    isl_set_free(set);
75
339
    FN(EL,free)(el);
76
339
    return pw;
77
208k
  }
78
208k
79
208k
  ctx = isl_set_get_ctx(set);
80
208k
#ifdef HAS_TYPE
81
  if (pw->type != el->type)
82
    isl_die(ctx, isl_error_invalid, "fold types don't match",
83
      goto error);
84
#endif
85
208k
  el_dim = FN(EL,get_space(el));
86
208k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
208k
  
isl_assert208k
(ctx, pw->n < pw->size, goto error);208k
88
208k
89
208k
  pw->p[pw->n].set = set;
90
208k
  pw->p[pw->n].FIELD = el;
91
208k
  pw->n++;
92
208k
  
93
208k
  isl_space_free(el_dim);
94
208k
  return pw;
95
208k
error:
96
0
  isl_space_free(el_dim);
97
0
  FN(PW,free)(pw);
98
0
  isl_set_free(set);
99
0
  FN(EL,free)(el);
100
208k
  return NULL;
101
208k
}
102
103
#ifdef HAS_TYPE
104
__isl_give PW *FN(PW,alloc)(enum isl_fold type,
105
  __isl_take isl_set *set, __isl_take EL *el)
106
#else
107
__isl_give PW *FN(PW,alloc)(__isl_take isl_set *set, __isl_take EL *el)
108
#endif
109
92.4k
{
110
92.4k
  PW *pw;
111
92.4k
112
92.4k
  if (
!set || 92.4k
!el92.4k
)
113
0
    goto error;
114
92.4k
115
92.4k
#ifdef HAS_TYPE
116
12
  
pw = 12
FN12
(PW,alloc_size)(
FN12
(EL,get_space)(el), type, 1);
117
12
#else
118
92.4k
  
pw = 92.4k
FN92.4k
(PW,alloc_size)(
FN92.4k
(EL,get_space)(el), 1);
119
92.4k
#endif
120
92.4k
121
92.4k
  return FN(PW,add_piece)(pw, set, el);
122
error:
123
  isl_set_free(set);
124
  FN(EL,free)(el);
125
  return NULL;
126
}
isl_pw_aff_alloc
Line
Count
Source
109
74.4k
{
110
74.4k
  PW *pw;
111
74.4k
112
74.4k
  if (
!set || 74.4k
!el74.4k
)
113
0
    goto error;
114
74.4k
115
74.4k
#ifdef HAS_TYPE
116
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
117
#else
118
74.4k
  
pw = 74.4k
FN74.4k
(PW,alloc_size)(
FN74.4k
(EL,get_space)(el), 1);
119
74.4k
#endif
120
74.4k
121
74.4k
  return FN(PW,add_piece)(pw, set, el);
122
74.4k
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
74.4k
  return NULL;
126
74.4k
}
isl_pw_qpolynomial_alloc
Line
Count
Source
109
33
{
110
33
  PW *pw;
111
33
112
33
  if (
!set || 33
!el33
)
113
0
    goto error;
114
33
115
33
#ifdef HAS_TYPE
116
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
117
#else
118
33
  
pw = 33
FN33
(PW,alloc_size)(
FN33
(EL,get_space)(el), 1);
119
33
#endif
120
33
121
33
  return FN(PW,add_piece)(pw, set, el);
122
33
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
33
  return NULL;
126
33
}
isl_pw_qpolynomial_fold_alloc
Line
Count
Source
109
12
{
110
12
  PW *pw;
111
12
112
12
  if (
!set || 12
!el12
)
113
0
    goto error;
114
12
115
12
#ifdef HAS_TYPE
116
12
  
pw = 12
FN12
(PW,alloc_size)(
FN12
(EL,get_space)(el), type, 1);
117
12
#else
118
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), 1);
119
#endif
120
12
121
12
  return FN(PW,add_piece)(pw, set, el);
122
12
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
12
  return NULL;
126
12
}
isl_pw_multi_aff_alloc
Line
Count
Source
109
17.9k
{
110
17.9k
  PW *pw;
111
17.9k
112
17.9k
  if (
!set || 17.9k
!el17.9k
)
113
0
    goto error;
114
17.9k
115
17.9k
#ifdef HAS_TYPE
116
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
117
#else
118
17.9k
  
pw = 17.9k
FN17.9k
(PW,alloc_size)(
FN17.9k
(EL,get_space)(el), 1);
119
17.9k
#endif
120
17.9k
121
17.9k
  return FN(PW,add_piece)(pw, set, el);
122
17.9k
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
17.9k
  return NULL;
126
17.9k
}
127
128
__isl_give PW *FN(PW,dup)(__isl_keep PW *pw)
129
{
130
  int i;
131
  PW *dup;
132
133
  if (!pw)
134
    return NULL;
135
136
#ifdef HAS_TYPE
137
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
138
#else
139
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
140
#endif
141
  if (!dup)
142
    return NULL;
143
144
  for (i = 0; i < pw->n; ++i)
145
    dup = FN(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
146
              FN(EL,copy)(pw->p[i].FIELD));
147
148
  return dup;
149
}
isl_pw_aff_dup
Line
Count
Source
129
45.7k
{
130
45.7k
  int i;
131
45.7k
  PW *dup;
132
45.7k
133
45.7k
  if (!pw)
134
0
    return NULL;
135
45.7k
136
45.7k
#ifdef HAS_TYPE
137
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
138
#else
139
45.7k
  
dup = 45.7k
FN45.7k
(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
140
45.7k
#endif
141
45.7k
  if (!dup)
142
0
    return NULL;
143
45.7k
144
92.8k
  
for (i = 0; 45.7k
i < pw->n92.8k
;
++i47.0k
)
145
47.0k
    
dup = 47.0k
FN47.0k
(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
146
47.0k
              
FN47.0k
(EL,copy)(pw->p[i].
FIELD47.0k
));
147
45.7k
148
45.7k
  return dup;
149
45.7k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_dup
isl_pw_multi_aff_dup
Line
Count
Source
129
600
{
130
600
  int i;
131
600
  PW *dup;
132
600
133
600
  if (!pw)
134
0
    return NULL;
135
600
136
600
#ifdef HAS_TYPE
137
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
138
#else
139
600
  
dup = 600
FN600
(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
140
600
#endif
141
600
  if (!dup)
142
0
    return NULL;
143
600
144
1.20k
  
for (i = 0; 600
i < pw->n1.20k
;
++i601
)
145
601
    
dup = 601
FN601
(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
146
601
              
FN601
(EL,copy)(pw->p[i].
FIELD601
));
147
600
148
600
  return dup;
149
600
}
isl_pw_qpolynomial_dup
Line
Count
Source
129
1
{
130
1
  int i;
131
1
  PW *dup;
132
1
133
1
  if (!pw)
134
0
    return NULL;
135
1
136
1
#ifdef HAS_TYPE
137
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
138
#else
139
1
  
dup = 1
FN1
(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
140
1
#endif
141
1
  if (!dup)
142
0
    return NULL;
143
1
144
2
  
for (i = 0; 1
i < pw->n2
;
++i1
)
145
1
    
dup = 1
FN1
(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
146
1
              
FN1
(EL,copy)(pw->p[i].
FIELD1
));
147
1
148
1
  return dup;
149
1
}
150
151
__isl_give PW *FN(PW,cow)(__isl_take PW *pw)
152
{
153
  if (!pw)
154
    return NULL;
155
156
  if (pw->ref == 1)
157
    return pw;
158
  pw->ref--;
159
  return FN(PW,dup)(pw);
160
}
isl_pw_qpolynomial_fold_cow
Line
Count
Source
152
7
{
153
7
  if (!pw)
154
0
    return NULL;
155
7
156
7
  
if (7
pw->ref == 17
)
157
7
    return pw;
158
7
  pw->ref--;
159
0
  return FN(PW,dup)(pw);
160
7
}
isl_pw_multi_aff_cow
Line
Count
Source
152
7.31k
{
153
7.31k
  if (!pw)
154
0
    return NULL;
155
7.31k
156
7.31k
  
if (7.31k
pw->ref == 17.31k
)
157
6.71k
    return pw;
158
7.31k
  pw->ref--;
159
600
  return FN(PW,dup)(pw);
160
7.31k
}
isl_pw_qpolynomial_cow
Line
Count
Source
152
51
{
153
51
  if (!pw)
154
0
    return NULL;
155
51
156
51
  
if (51
pw->ref == 151
)
157
50
    return pw;
158
51
  pw->ref--;
159
1
  return FN(PW,dup)(pw);
160
51
}
isl_pw_aff_cow
Line
Count
Source
152
152k
{
153
152k
  if (!pw)
154
0
    return NULL;
155
152k
156
152k
  
if (152k
pw->ref == 1152k
)
157
106k
    return pw;
158
152k
  pw->ref--;
159
45.7k
  return FN(PW,dup)(pw);
160
152k
}
161
162
__isl_give PW *FN(PW,copy)(__isl_keep PW *pw)
163
{
164
  if (!pw)
165
    return NULL;
166
167
  pw->ref++;
168
  return pw;
169
}
isl_pw_qpolynomial_fold_copy
Line
Count
Source
163
2
{
164
2
  if (!pw)
165
0
    return NULL;
166
2
167
2
  pw->ref++;
168
2
  return pw;
169
2
}
isl_pw_qpolynomial_copy
Line
Count
Source
163
10
{
164
10
  if (!pw)
165
0
    return NULL;
166
10
167
10
  pw->ref++;
168
10
  return pw;
169
10
}
isl_pw_aff_copy
Line
Count
Source
163
186k
{
164
186k
  if (!pw)
165
28.1k
    return NULL;
166
186k
167
186k
  pw->ref++;
168
186k
  return pw;
169
186k
}
isl_pw_multi_aff_copy
Line
Count
Source
163
30.3k
{
164
30.3k
  if (!pw)
165
0
    return NULL;
166
30.3k
167
30.3k
  pw->ref++;
168
30.3k
  return pw;
169
30.3k
}
170
171
__isl_null PW *FN(PW,free)(__isl_take PW *pw)
172
{
173
  int i;
174
175
  if (!pw)
176
    return NULL;
177
  if (--pw->ref > 0)
178
    return NULL;
179
180
  for (i = 0; i < pw->n; ++i) {
181
    isl_set_free(pw->p[i].set);
182
    FN(EL,free)(pw->p[i].FIELD);
183
  }
184
  isl_space_free(pw->dim);
185
  free(pw);
186
187
  return NULL;
188
}
isl_pw_qpolynomial_fold_free
Line
Count
Source
172
37
{
173
37
  int i;
174
37
175
37
  if (!pw)
176
0
    return NULL;
177
37
  
if (37
--pw->ref > 037
)
178
2
    return NULL;
179
37
180
53
  
for (i = 0; 35
i < pw->n53
;
++i18
)
{18
181
18
    isl_set_free(pw->p[i].set);
182
18
    
FN18
(EL,free)(pw->p[i].
FIELD18
);
183
35
  }
184
35
  isl_space_free(pw->dim);
185
35
  free(pw);
186
35
187
37
  return NULL;
188
37
}
isl_pw_qpolynomial_free
Line
Count
Source
172
113
{
173
113
  int i;
174
113
175
113
  if (!pw)
176
0
    return NULL;
177
113
  
if (113
--pw->ref > 0113
)
178
9
    return NULL;
179
113
180
202
  
for (i = 0; 104
i < pw->n202
;
++i98
)
{98
181
98
    isl_set_free(pw->p[i].set);
182
98
    
FN98
(EL,free)(pw->p[i].
FIELD98
);
183
104
  }
184
104
  isl_space_free(pw->dim);
185
104
  free(pw);
186
104
187
113
  return NULL;
188
113
}
isl_pw_aff_free
Line
Count
Source
172
358k
{
173
358k
  int i;
174
358k
175
358k
  if (!pw)
176
38.9k
    return NULL;
177
319k
  
if (319k
--pw->ref > 0319k
)
178
112k
    return NULL;
179
319k
180
414k
  
for (i = 0; 207k
i < pw->n414k
;
++i207k
)
{207k
181
207k
    isl_set_free(pw->p[i].set);
182
207k
    
FN207k
(EL,free)(pw->p[i].
FIELD207k
);
183
207k
  }
184
207k
  isl_space_free(pw->dim);
185
207k
  free(pw);
186
207k
187
319k
  return NULL;
188
358k
}
isl_pw_multi_aff_free
Line
Count
Source
172
53.6k
{
173
53.6k
  int i;
174
53.6k
175
53.6k
  if (!pw)
176
0
    return NULL;
177
53.6k
  
if (53.6k
--pw->ref > 053.6k
)
178
29.7k
    return NULL;
179
53.6k
180
45.5k
  
for (i = 0; 23.8k
i < pw->n45.5k
;
++i21.6k
)
{21.6k
181
21.6k
    isl_set_free(pw->p[i].set);
182
21.6k
    
FN21.6k
(EL,free)(pw->p[i].
FIELD21.6k
);
183
23.8k
  }
184
23.8k
  isl_space_free(pw->dim);
185
23.8k
  free(pw);
186
23.8k
187
53.6k
  return NULL;
188
53.6k
}
189
190
const char *FN(PW,get_dim_name)(__isl_keep PW *pw, enum isl_dim_type type,
191
  unsigned pos)
192
{
193
  return pw ? isl_space_get_dim_name(pw->dim, type, pos) : NULL;
194
}
Unexecuted instantiation: isl_pw_qpolynomial_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_aff_get_dim_name
195
196
isl_bool FN(PW,has_dim_id)(__isl_keep PW *pw, enum isl_dim_type type,
197
  unsigned pos)
198
{
199
  return pw ? isl_space_has_dim_id(pw->dim, type, pos) : isl_bool_error;
200
}
Unexecuted instantiation: isl_pw_aff_has_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_has_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_dim_id
Unexecuted instantiation: isl_pw_multi_aff_has_dim_id
201
202
__isl_give isl_id *FN(PW,get_dim_id)(__isl_keep PW *pw, enum isl_dim_type type,
203
  unsigned pos)
204
{
205
  return pw ? isl_space_get_dim_id(pw->dim, type, pos) : NULL;
206
}
Unexecuted instantiation: isl_pw_multi_aff_get_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_get_dim_id
isl_pw_aff_get_dim_id
Line
Count
Source
204
16
{
205
16
  return pw ? isl_space_get_dim_id(pw->dim, type, pos) : NULL;
206
16
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_dim_id
207
208
isl_bool FN(PW,has_tuple_name)(__isl_keep PW *pw, enum isl_dim_type type)
209
{
210
  return pw ? isl_space_has_tuple_name(pw->dim, type) : isl_bool_error;
211
}
Unexecuted instantiation: isl_pw_multi_aff_has_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_has_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_tuple_name
Unexecuted instantiation: isl_pw_aff_has_tuple_name
212
213
const char *FN(PW,get_tuple_name)(__isl_keep PW *pw, enum isl_dim_type type)
214
{
215
  return pw ? isl_space_get_tuple_name(pw->dim, type) : NULL;
216
}
Unexecuted instantiation: isl_pw_multi_aff_get_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_tuple_name
Unexecuted instantiation: isl_pw_aff_get_tuple_name
Unexecuted instantiation: isl_pw_qpolynomial_get_tuple_name
217
218
isl_bool FN(PW,has_tuple_id)(__isl_keep PW *pw, enum isl_dim_type type)
219
{
220
  return pw ? isl_space_has_tuple_id(pw->dim, type) : isl_bool_error;
221
}
Unexecuted instantiation: isl_pw_qpolynomial_has_tuple_id
Unexecuted instantiation: isl_pw_aff_has_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_has_tuple_id
222
223
__isl_give isl_id *FN(PW,get_tuple_id)(__isl_keep PW *pw, enum isl_dim_type type)
224
{
225
  return pw ? isl_space_get_tuple_id(pw->dim, type) : NULL;
226
}
Unexecuted instantiation: isl_pw_qpolynomial_get_tuple_id
Unexecuted instantiation: isl_pw_aff_get_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_get_tuple_id
227
228
isl_bool FN(PW,IS_ZERO)(__isl_keep PW *pw)
229
{
230
  if (!pw)
231
    return isl_bool_error;
232
233
  return pw->n == 0;
234
}
isl_pw_multi_aff_is_empty
Line
Count
Source
229
19.0k
{
230
19.0k
  if (!pw)
231
0
    return isl_bool_error;
232
19.0k
233
19.0k
  return pw->n == 0;
234
19.0k
}
isl_pw_aff_is_empty
Line
Count
Source
229
35.4k
{
230
35.4k
  if (!pw)
231
0
    return isl_bool_error;
232
35.4k
233
35.4k
  return pw->n == 0;
234
35.4k
}
isl_pw_qpolynomial_is_zero
Line
Count
Source
229
102
{
230
102
  if (!pw)
231
0
    return isl_bool_error;
232
102
233
102
  return pw->n == 0;
234
102
}
isl_pw_qpolynomial_fold_is_zero
Line
Count
Source
229
26
{
230
26
  if (!pw)
231
0
    return isl_bool_error;
232
26
233
26
  return pw->n == 0;
234
26
}
235
236
#ifndef NO_REALIGN
237
__isl_give PW *FN(PW,realign_domain)(__isl_take PW *pw,
238
  __isl_take isl_reordering *exp)
239
{
240
  int i;
241
242
  pw = FN(PW,cow)(pw);
243
  if (!pw || !exp)
244
    goto error;
245
246
  for (i = 0; i < pw->n; ++i) {
247
    pw->p[i].set = isl_set_realign(pw->p[i].set,
248
                isl_reordering_copy(exp));
249
    if (!pw->p[i].set)
250
      goto error;
251
    pw->p[i].FIELD = FN(EL,realign_domain)(pw->p[i].FIELD,
252
                isl_reordering_copy(exp));
253
    if (!pw->p[i].FIELD)
254
      goto error;
255
  }
256
257
  pw = FN(PW,reset_domain_space)(pw, isl_space_copy(exp->dim));
258
259
  isl_reordering_free(exp);
260
  return pw;
261
error:
262
  isl_reordering_free(exp);
263
  FN(PW,free)(pw);
264
  return NULL;
265
}
isl_pw_aff_realign_domain
Line
Count
Source
239
8.92k
{
240
8.92k
  int i;
241
8.92k
242
8.92k
  pw = FN(PW,cow)(pw);
243
8.92k
  if (
!pw || 8.92k
!exp8.92k
)
244
0
    goto error;
245
8.92k
246
18.2k
  
for (i = 0; 8.92k
i < pw->n18.2k
;
++i9.36k
)
{9.36k
247
9.36k
    pw->p[i].set = isl_set_realign(pw->p[i].set,
248
9.36k
                isl_reordering_copy(exp));
249
9.36k
    if (!pw->p[i].set)
250
0
      goto error;
251
9.36k
    
pw->p[i].9.36k
FIELD9.36k
=
FN9.36k
(EL,realign_domain)(pw->p[i].
FIELD9.36k
,
252
9.36k
                isl_reordering_copy(exp));
253
9.36k
    if (
!pw->p[i].9.36k
FIELD9.36k
)
254
0
      goto error;
255
9.36k
  }
256
8.92k
257
8.92k
  
pw = 8.92k
FN8.92k
(PW,reset_domain_space)(pw, isl_space_copy(exp->dim));
258
8.92k
259
8.92k
  isl_reordering_free(exp);
260
8.92k
  return pw;
261
8.92k
error:
262
0
  isl_reordering_free(exp);
263
0
  FN(PW,free)(pw);
264
8.92k
  return NULL;
265
8.92k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_realign_domain
Unexecuted instantiation: isl_pw_multi_aff_realign_domain
Unexecuted instantiation: isl_pw_qpolynomial_realign_domain
266
267
/* Align the parameters of "pw" to those of "model".
268
 */
269
__isl_give PW *FN(PW,align_params)(__isl_take PW *pw, __isl_take isl_space *model)
270
{
271
  isl_ctx *ctx;
272
  isl_bool equal_params;
273
274
  if (!pw || !model)
275
    goto error;
276
277
  ctx = isl_space_get_ctx(model);
278
  if (!isl_space_has_named_params(model))
279
    isl_die(ctx, isl_error_invalid,
280
      "model has unnamed parameters", goto error);
281
  if (!isl_space_has_named_params(pw->dim))
282
    isl_die(ctx, isl_error_invalid,
283
      "input has unnamed parameters", goto error);
284
  equal_params = isl_space_has_equal_params(pw->dim, model);
285
  if (equal_params < 0)
286
    goto error;
287
  if (!equal_params) {
288
    isl_reordering *exp;
289
290
    model = isl_space_drop_dims(model, isl_dim_in,
291
          0, isl_space_dim(model, isl_dim_in));
292
    model = isl_space_drop_dims(model, isl_dim_out,
293
          0, isl_space_dim(model, isl_dim_out));
294
    exp = isl_parameter_alignment_reordering(pw->dim, model);
295
    exp = isl_reordering_extend_space(exp,
296
          FN(PW,get_domain_space)(pw));
297
    pw = FN(PW,realign_domain)(pw, exp);
298
  }
299
300
  isl_space_free(model);
301
  return pw;
302
error:
303
  isl_space_free(model);
304
  FN(PW,free)(pw);
305
  return NULL;
306
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_align_params
isl_pw_qpolynomial_align_params
Line
Count
Source
270
5
{
271
5
  isl_ctx *ctx;
272
5
  isl_bool equal_params;
273
5
274
5
  if (
!pw || 5
!model5
)
275
0
    goto error;
276
5
277
5
  ctx = isl_space_get_ctx(model);
278
5
  if (!isl_space_has_named_params(model))
279
0
    isl_die(ctx, isl_error_invalid,
280
5
      "model has unnamed parameters", goto error);
281
5
  
if (5
!isl_space_has_named_params(pw->dim)5
)
282
0
    isl_die(ctx, isl_error_invalid,
283
5
      "input has unnamed parameters", goto error);
284
5
  equal_params = isl_space_has_equal_params(pw->dim, model);
285
5
  if (equal_params < 0)
286
0
    goto error;
287
5
  
if (5
!equal_params5
)
{0
288
0
    isl_reordering *exp;
289
0
290
0
    model = isl_space_drop_dims(model, isl_dim_in,
291
0
          0, isl_space_dim(model, isl_dim_in));
292
0
    model = isl_space_drop_dims(model, isl_dim_out,
293
0
          0, isl_space_dim(model, isl_dim_out));
294
0
    exp = isl_parameter_alignment_reordering(pw->dim, model);
295
0
    exp = isl_reordering_extend_space(exp,
296
0
          FN(PW,get_domain_space)(pw));
297
0
    pw = FN(PW,realign_domain)(pw, exp);
298
5
  }
299
5
300
5
  isl_space_free(model);
301
5
  return pw;
302
5
error:
303
0
  isl_space_free(model);
304
0
  FN(PW,free)(pw);
305
5
  return NULL;
306
5
}
isl_pw_aff_align_params
Line
Count
Source
270
16.8k
{
271
16.8k
  isl_ctx *ctx;
272
16.8k
  isl_bool equal_params;
273
16.8k
274
16.8k
  if (
!pw || 16.8k
!model16.8k
)
275
0
    goto error;
276
16.8k
277
16.8k
  ctx = isl_space_get_ctx(model);
278
16.8k
  if (!isl_space_has_named_params(model))
279
0
    isl_die(ctx, isl_error_invalid,
280
16.8k
      "model has unnamed parameters", goto error);
281
16.8k
  
if (16.8k
!isl_space_has_named_params(pw->dim)16.8k
)
282
0
    isl_die(ctx, isl_error_invalid,
283
16.8k
      "input has unnamed parameters", goto error);
284
16.8k
  equal_params = isl_space_has_equal_params(pw->dim, model);
285
16.8k
  if (equal_params < 0)
286
0
    goto error;
287
16.8k
  
if (16.8k
!equal_params16.8k
)
{8.75k
288
8.75k
    isl_reordering *exp;
289
8.75k
290
8.75k
    model = isl_space_drop_dims(model, isl_dim_in,
291
8.75k
          0, isl_space_dim(model, isl_dim_in));
292
8.75k
    model = isl_space_drop_dims(model, isl_dim_out,
293
8.75k
          0, isl_space_dim(model, isl_dim_out));
294
8.75k
    exp = isl_parameter_alignment_reordering(pw->dim, model);
295
8.75k
    exp = isl_reordering_extend_space(exp,
296
8.75k
          FN(PW,get_domain_space)(pw));
297
8.75k
    pw = FN(PW,realign_domain)(pw, exp);
298
16.8k
  }
299
16.8k
300
16.8k
  isl_space_free(model);
301
16.8k
  return pw;
302
16.8k
error:
303
0
  isl_space_free(model);
304
0
  FN(PW,free)(pw);
305
16.8k
  return NULL;
306
16.8k
}
isl_pw_multi_aff_align_params
Line
Count
Source
270
14.4k
{
271
14.4k
  isl_ctx *ctx;
272
14.4k
  isl_bool equal_params;
273
14.4k
274
14.4k
  if (
!pw || 14.4k
!model14.4k
)
275
0
    goto error;
276
14.4k
277
14.4k
  ctx = isl_space_get_ctx(model);
278
14.4k
  if (!isl_space_has_named_params(model))
279
0
    isl_die(ctx, isl_error_invalid,
280
14.4k
      "model has unnamed parameters", goto error);
281
14.4k
  
if (14.4k
!isl_space_has_named_params(pw->dim)14.4k
)
282
0
    isl_die(ctx, isl_error_invalid,
283
14.4k
      "input has unnamed parameters", goto error);
284
14.4k
  equal_params = isl_space_has_equal_params(pw->dim, model);
285
14.4k
  if (equal_params < 0)
286
0
    goto error;
287
14.4k
  
if (14.4k
!equal_params14.4k
)
{0
288
0
    isl_reordering *exp;
289
0
290
0
    model = isl_space_drop_dims(model, isl_dim_in,
291
0
          0, isl_space_dim(model, isl_dim_in));
292
0
    model = isl_space_drop_dims(model, isl_dim_out,
293
0
          0, isl_space_dim(model, isl_dim_out));
294
0
    exp = isl_parameter_alignment_reordering(pw->dim, model);
295
0
    exp = isl_reordering_extend_space(exp,
296
0
          FN(PW,get_domain_space)(pw));
297
0
    pw = FN(PW,realign_domain)(pw, exp);
298
14.4k
  }
299
14.4k
300
14.4k
  isl_space_free(model);
301
14.4k
  return pw;
302
14.4k
error:
303
0
  isl_space_free(model);
304
0
  FN(PW,free)(pw);
305
14.4k
  return NULL;
306
14.4k
}
307
308
static __isl_give PW *FN(PW,align_params_pw_pw_and)(__isl_take PW *pw1,
309
  __isl_take PW *pw2,
310
  __isl_give PW *(*fn)(__isl_take PW *pw1, __isl_take PW *pw2))
311
{
312
  isl_ctx *ctx;
313
  isl_bool equal_params;
314
315
  if (!pw1 || !pw2)
316
    goto error;
317
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
318
  if (equal_params < 0)
319
    goto error;
320
  if (equal_params)
321
    return fn(pw1, pw2);
322
  ctx = FN(PW,get_ctx)(pw1);
323
  if (!isl_space_has_named_params(pw1->dim) ||
324
      !isl_space_has_named_params(pw2->dim))
325
    isl_die(ctx, isl_error_invalid,
326
      "unaligned unnamed parameters", goto error);
327
  pw1 = FN(PW,align_params)(pw1, FN(PW,get_space)(pw2));
328
  pw2 = FN(PW,align_params)(pw2, FN(PW,get_space)(pw1));
329
  return fn(pw1, pw2);
330
error:
331
  FN(PW,free)(pw1);
332
  FN(PW,free)(pw2);
333
  return NULL;
334
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_align_params_pw_pw_and
isl_aff.c:isl_pw_multi_aff_align_params_pw_pw_and
Line
Count
Source
311
4.59k
{
312
4.59k
  isl_ctx *ctx;
313
4.59k
  isl_bool equal_params;
314
4.59k
315
4.59k
  if (
!pw1 || 4.59k
!pw24.59k
)
316
0
    goto error;
317
4.59k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
318
4.59k
  if (equal_params < 0)
319
0
    goto error;
320
4.59k
  
if (4.59k
equal_params4.59k
)
321
4.59k
    return fn(pw1, pw2);
322
0
  
ctx = 0
FN0
(PW,get_ctx)(pw1);
323
0
  if (!isl_space_has_named_params(pw1->dim) ||
324
0
      !isl_space_has_named_params(pw2->dim))
325
0
    isl_die(ctx, isl_error_invalid,
326
0
      "unaligned unnamed parameters", goto error);
327
0
  
pw1 = 0
FN0
(PW,align_params)(pw1,
FN0
(PW,get_space)(pw2));
328
0
  pw2 = 
FN0
(PW,align_params)(pw2,
FN0
(PW,get_space)(pw1));
329
0
  return fn(pw1, pw2);
330
0
error:
331
0
  FN(PW,free)(pw1);
332
0
  FN(PW,free)(pw2);
333
0
  return NULL;
334
4.59k
}
isl_polynomial.c:isl_pw_qpolynomial_align_params_pw_pw_and
Line
Count
Source
311
26
{
312
26
  isl_ctx *ctx;
313
26
  isl_bool equal_params;
314
26
315
26
  if (
!pw1 || 26
!pw226
)
316
0
    goto error;
317
26
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
318
26
  if (equal_params < 0)
319
0
    goto error;
320
26
  
if (26
equal_params26
)
321
26
    return fn(pw1, pw2);
322
0
  
ctx = 0
FN0
(PW,get_ctx)(pw1);
323
0
  if (!isl_space_has_named_params(pw1->dim) ||
324
0
      !isl_space_has_named_params(pw2->dim))
325
0
    isl_die(ctx, isl_error_invalid,
326
0
      "unaligned unnamed parameters", goto error);
327
0
  
pw1 = 0
FN0
(PW,align_params)(pw1,
FN0
(PW,get_space)(pw2));
328
0
  pw2 = 
FN0
(PW,align_params)(pw2,
FN0
(PW,get_space)(pw1));
329
0
  return fn(pw1, pw2);
330
0
error:
331
0
  FN(PW,free)(pw1);
332
0
  FN(PW,free)(pw2);
333
0
  return NULL;
334
26
}
isl_aff.c:isl_pw_aff_align_params_pw_pw_and
Line
Count
Source
311
76.9k
{
312
76.9k
  isl_ctx *ctx;
313
76.9k
  isl_bool equal_params;
314
76.9k
315
76.9k
  if (
!pw1 || 76.9k
!pw276.9k
)
316
1
    goto error;
317
76.9k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
318
76.9k
  if (equal_params < 0)
319
0
    goto error;
320
76.9k
  
if (76.9k
equal_params76.9k
)
321
73.6k
    return fn(pw1, pw2);
322
3.34k
  
ctx = 3.34k
FN3.34k
(PW,get_ctx)(pw1);
323
3.34k
  if (!isl_space_has_named_params(pw1->dim) ||
324
3.34k
      !isl_space_has_named_params(pw2->dim))
325
0
    isl_die(ctx, isl_error_invalid,
326
3.34k
      "unaligned unnamed parameters", goto error);
327
3.34k
  
pw1 = 3.34k
FN3.34k
(PW,align_params)(pw1,
FN3.34k
(PW,get_space)(pw2));
328
3.34k
  pw2 = 
FN3.34k
(PW,align_params)(pw2,
FN3.34k
(PW,get_space)(pw1));
329
3.34k
  return fn(pw1, pw2);
330
3.34k
error:
331
1
  FN(PW,free)(pw1);
332
1
  FN(PW,free)(pw2);
333
3.34k
  return NULL;
334
76.9k
}
335
336
static __isl_give PW *FN(PW,align_params_pw_set_and)(__isl_take PW *pw,
337
  __isl_take isl_set *set,
338
  __isl_give PW *(*fn)(__isl_take PW *pw, __isl_take isl_set *set))
339
{
340
  isl_ctx *ctx;
341
  isl_bool aligned;
342
343
  if (!pw || !set)
344
    goto error;
345
  aligned = isl_set_space_has_equal_params(set, pw->dim);
346
  if (aligned < 0)
347
    goto error;
348
  if (aligned)
349
    return fn(pw, set);
350
  ctx = FN(PW,get_ctx)(pw);
351
  if (!isl_space_has_named_params(pw->dim) ||
352
      !isl_space_has_named_params(set->dim))
353
    isl_die(ctx, isl_error_invalid,
354
      "unaligned unnamed parameters", goto error);
355
  pw = FN(PW,align_params)(pw, isl_set_get_space(set));
356
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
357
  return fn(pw, set);
358
error:
359
  FN(PW,free)(pw);
360
  isl_set_free(set);
361
  return NULL;
362
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_align_params_pw_set_and
isl_aff.c:isl_pw_multi_aff_align_params_pw_set_and
Line
Count
Source
339
3.35k
{
340
3.35k
  isl_ctx *ctx;
341
3.35k
  isl_bool aligned;
342
3.35k
343
3.35k
  if (
!pw || 3.35k
!set3.35k
)
344
0
    goto error;
345
3.35k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
346
3.35k
  if (aligned < 0)
347
0
    goto error;
348
3.35k
  
if (3.35k
aligned3.35k
)
349
3.35k
    return fn(pw, set);
350
0
  
ctx = 0
FN0
(PW,get_ctx)(pw);
351
0
  if (!isl_space_has_named_params(pw->dim) ||
352
0
      !isl_space_has_named_params(set->dim))
353
0
    isl_die(ctx, isl_error_invalid,
354
0
      "unaligned unnamed parameters", goto error);
355
0
  
pw = 0
FN0
(PW,align_params)(pw, isl_set_get_space(set));
356
0
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
357
0
  return fn(pw, set);
358
0
error:
359
0
  FN(PW,free)(pw);
360
0
  isl_set_free(set);
361
0
  return NULL;
362
3.35k
}
isl_aff.c:isl_pw_aff_align_params_pw_set_and
Line
Count
Source
339
42.1k
{
340
42.1k
  isl_ctx *ctx;
341
42.1k
  isl_bool aligned;
342
42.1k
343
42.1k
  if (
!pw || 42.1k
!set42.1k
)
344
0
    goto error;
345
42.1k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
346
42.1k
  if (aligned < 0)
347
0
    goto error;
348
42.1k
  
if (42.1k
aligned42.1k
)
349
42.1k
    return fn(pw, set);
350
2
  
ctx = 2
FN2
(PW,get_ctx)(pw);
351
2
  if (!isl_space_has_named_params(pw->dim) ||
352
2
      !isl_space_has_named_params(set->dim))
353
0
    isl_die(ctx, isl_error_invalid,
354
2
      "unaligned unnamed parameters", goto error);
355
2
  
pw = 2
FN2
(PW,align_params)(pw, isl_set_get_space(set));
356
2
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
357
2
  return fn(pw, set);
358
2
error:
359
0
  FN(PW,free)(pw);
360
0
  isl_set_free(set);
361
2
  return NULL;
362
42.1k
}
isl_polynomial.c:isl_pw_qpolynomial_align_params_pw_set_and
Line
Count
Source
339
39
{
340
39
  isl_ctx *ctx;
341
39
  isl_bool aligned;
342
39
343
39
  if (
!pw || 39
!set39
)
344
0
    goto error;
345
39
  aligned = isl_set_space_has_equal_params(set, pw->dim);
346
39
  if (aligned < 0)
347
0
    goto error;
348
39
  
if (39
aligned39
)
349
39
    return fn(pw, set);
350
0
  
ctx = 0
FN0
(PW,get_ctx)(pw);
351
0
  if (!isl_space_has_named_params(pw->dim) ||
352
0
      !isl_space_has_named_params(set->dim))
353
0
    isl_die(ctx, isl_error_invalid,
354
0
      "unaligned unnamed parameters", goto error);
355
0
  
pw = 0
FN0
(PW,align_params)(pw, isl_set_get_space(set));
356
0
  set = isl_set_align_params(set, FN(PW,get_space)(pw));
357
0
  return fn(pw, set);
358
0
error:
359
0
  FN(PW,free)(pw);
360
0
  isl_set_free(set);
361
0
  return NULL;
362
39
}
363
#endif
364
365
static __isl_give PW *FN(PW,union_add_aligned)(__isl_take PW *pw1,
366
  __isl_take PW *pw2)
367
{
368
  int i, j, n;
369
  struct PW *res;
370
  isl_ctx *ctx;
371
  isl_set *set;
372
373
  if (!pw1 || !pw2)
374
    goto error;
375
376
  ctx = isl_space_get_ctx(pw1->dim);
377
#ifdef HAS_TYPE
378
  if (pw1->type != pw2->type)
379
    isl_die(ctx, isl_error_invalid,
380
      "fold types don't match", goto error);
381
#endif
382
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
383
384
  if (FN(PW,IS_ZERO)(pw1)) {
385
    FN(PW,free)(pw1);
386
    return pw2;
387
  }
388
389
  if (FN(PW,IS_ZERO)(pw2)) {
390
    FN(PW,free)(pw2);
391
    return pw1;
392
  }
393
394
  n = (pw1->n + 1) * (pw2->n + 1);
395
#ifdef HAS_TYPE
396
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
397
#else
398
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
399
#endif
400
401
  for (i = 0; i < pw1->n; ++i) {
402
    set = isl_set_copy(pw1->p[i].set);
403
    for (j = 0; j < pw2->n; ++j) {
404
      struct isl_set *common;
405
      EL *sum;
406
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
407
            isl_set_copy(pw2->p[j].set));
408
      if (isl_set_plain_is_empty(common)) {
409
        isl_set_free(common);
410
        continue;
411
      }
412
      set = isl_set_subtract(set,
413
          isl_set_copy(pw2->p[j].set));
414
415
      sum = FN(EL,add_on_domain)(common,
416
               FN(EL,copy)(pw1->p[i].FIELD),
417
               FN(EL,copy)(pw2->p[j].FIELD));
418
419
      res = FN(PW,add_piece)(res, common, sum);
420
    }
421
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw1->p[i].FIELD));
422
  }
423
424
  for (j = 0; j < pw2->n; ++j) {
425
    set = isl_set_copy(pw2->p[j].set);
426
    for (i = 0; i < pw1->n; ++i)
427
      set = isl_set_subtract(set,
428
          isl_set_copy(pw1->p[i].set));
429
    res = FN(PW,add_piece)(res, set, FN(EL,copy)(pw2->p[j].FIELD));
430
  }
431
432
  FN(PW,free)(pw1);
433
  FN(PW,free)(pw2);
434
435
  return res;
436
error:
437
  FN(PW,free)(pw1);
438
  FN(PW,free)(pw2);
439
  return NULL;
440
}
isl_polynomial.c:isl_pw_qpolynomial_union_add_aligned
Line
Count
Source
367
24
{
368
24
  int i, j, n;
369
24
  struct PW *res;
370
24
  isl_ctx *ctx;
371
24
  isl_set *set;
372
24
373
24
  if (
!pw1 || 24
!pw224
)
374
0
    goto error;
375
24
376
24
  ctx = isl_space_get_ctx(pw1->dim);
377
24
#ifdef HAS_TYPE
378
  if (pw1->type != pw2->type)
379
    isl_die(ctx, isl_error_invalid,
380
      "fold types don't match", goto error);
381
#endif
382
24
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
383
24
384
24
  
if (24
FN24
(PW,IS_ZERO)(pw1)24
)
{0
385
0
    FN(PW,free)(pw1);
386
0
    return pw2;
387
24
  }
388
24
389
24
  
if (24
FN24
(PW,IS_ZERO)(pw2)24
)
{0
390
0
    FN(PW,free)(pw2);
391
0
    return pw1;
392
24
  }
393
24
394
24
  n = (pw1->n + 1) * (pw2->n + 1);
395
24
#ifdef HAS_TYPE
396
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
397
#else
398
24
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
399
24
#endif
400
24
401
49
  for (i = 0; 
i < pw1->n49
;
++i25
)
{25
402
25
    set = isl_set_copy(pw1->p[i].set);
403
52
    for (j = 0; 
j < pw2->n52
;
++j27
)
{27
404
27
      struct isl_set *common;
405
27
      EL *sum;
406
27
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
407
27
            isl_set_copy(pw2->p[j].set));
408
27
      if (
isl_set_plain_is_empty(common)27
)
{5
409
5
        isl_set_free(common);
410
5
        continue;
411
27
      }
412
27
      set = isl_set_subtract(set,
413
22
          isl_set_copy(pw2->p[j].set));
414
22
415
22
      sum = FN(EL,add_on_domain)(common,
416
22
               
FN22
(EL,copy)(pw1->p[i].
FIELD22
),
417
22
               
FN22
(EL,copy)(pw2->p[j].
FIELD22
));
418
22
419
22
      res = FN(PW,add_piece)(res, common, sum);
420
25
    }
421
25
    res = 
FN25
(PW,add_piece)(res, set,
FN25
(EL,copy)(pw1->p[i].
FIELD25
));
422
25
  }
423
24
424
49
  for (j = 0; 
j < pw2->n49
;
++j25
)
{25
425
25
    set = isl_set_copy(pw2->p[j].set);
426
52
    for (i = 0; 
i < pw1->n52
;
++i27
)
427
27
      set = isl_set_subtract(set,
428
27
          isl_set_copy(pw1->p[i].set));
429
25
    res = 
FN25
(PW,add_piece)(res, set,
FN25
(EL,copy)(pw2->p[j].
FIELD25
));
430
25
  }
431
24
432
24
  FN(PW,free)(pw1);
433
24
  FN(PW,free)(pw2);
434
24
435
24
  return res;
436
24
error:
437
0
  FN(PW,free)(pw1);
438
0
  FN(PW,free)(pw2);
439
24
  return NULL;
440
24
}
isl_aff.c:isl_pw_aff_union_add_aligned
Line
Count
Source
367
2.98k
{
368
2.98k
  int i, j, n;
369
2.98k
  struct PW *res;
370
2.98k
  isl_ctx *ctx;
371
2.98k
  isl_set *set;
372
2.98k
373
2.98k
  if (
!pw1 || 2.98k
!pw22.98k
)
374
0
    goto error;
375
2.98k
376
2.98k
  ctx = isl_space_get_ctx(pw1->dim);
377
2.98k
#ifdef HAS_TYPE
378
  if (pw1->type != pw2->type)
379
    isl_die(ctx, isl_error_invalid,
380
      "fold types don't match", goto error);
381
#endif
382
2.98k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
383
2.98k
384
2.98k
  
if (2.98k
FN2.98k
(PW,IS_ZERO)(pw1)2.98k
)
{2.93k
385
2.93k
    FN(PW,free)(pw1);
386
2.93k
    return pw2;
387
2.98k
  }
388
2.98k
389
54
  
if (54
FN54
(PW,IS_ZERO)(pw2)54
)
{0
390
0
    FN(PW,free)(pw2);
391
0
    return pw1;
392
54
  }
393
54
394
54
  n = (pw1->n + 1) * (pw2->n + 1);
395
54
#ifdef HAS_TYPE
396
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
397
#else
398
54
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
399
54
#endif
400
54
401
108
  for (i = 0; 
i < pw1->n108
;
++i54
)
{54
402
54
    set = isl_set_copy(pw1->p[i].set);
403
108
    for (j = 0; 
j < pw2->n108
;
++j54
)
{54
404
54
      struct isl_set *common;
405
54
      EL *sum;
406
54
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
407
54
            isl_set_copy(pw2->p[j].set));
408
54
      if (
isl_set_plain_is_empty(common)54
)
{54
409
54
        isl_set_free(common);
410
54
        continue;
411
54
      }
412
54
      set = isl_set_subtract(set,
413
0
          isl_set_copy(pw2->p[j].set));
414
0
415
0
      sum = FN(EL,add_on_domain)(common,
416
0
               
FN0
(EL,copy)(pw1->p[i].
FIELD0
),
417
0
               
FN0
(EL,copy)(pw2->p[j].
FIELD0
));
418
0
419
0
      res = FN(PW,add_piece)(res, common, sum);
420
54
    }
421
54
    res = 
FN54
(PW,add_piece)(res, set,
FN54
(EL,copy)(pw1->p[i].
FIELD54
));
422
54
  }
423
54
424
108
  for (j = 0; 
j < pw2->n108
;
++j54
)
{54
425
54
    set = isl_set_copy(pw2->p[j].set);
426
108
    for (i = 0; 
i < pw1->n108
;
++i54
)
427
54
      set = isl_set_subtract(set,
428
54
          isl_set_copy(pw1->p[i].set));
429
54
    res = 
FN54
(PW,add_piece)(res, set,
FN54
(EL,copy)(pw2->p[j].
FIELD54
));
430
54
  }
431
54
432
54
  FN(PW,free)(pw1);
433
54
  FN(PW,free)(pw2);
434
54
435
54
  return res;
436
54
error:
437
0
  FN(PW,free)(pw1);
438
0
  FN(PW,free)(pw2);
439
54
  return NULL;
440
2.98k
}
isl_aff.c:isl_pw_multi_aff_union_add_aligned
Line
Count
Source
367
794
{
368
794
  int i, j, n;
369
794
  struct PW *res;
370
794
  isl_ctx *ctx;
371
794
  isl_set *set;
372
794
373
794
  if (
!pw1 || 794
!pw2794
)
374
0
    goto error;
375
794
376
794
  ctx = isl_space_get_ctx(pw1->dim);
377
794
#ifdef HAS_TYPE
378
  if (pw1->type != pw2->type)
379
    isl_die(ctx, isl_error_invalid,
380
      "fold types don't match", goto error);
381
#endif
382
794
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
383
794
384
794
  
if (794
FN794
(PW,IS_ZERO)(pw1)794
)
{70
385
70
    FN(PW,free)(pw1);
386
70
    return pw2;
387
794
  }
388
794
389
724
  
if (724
FN724
(PW,IS_ZERO)(pw2)724
)
{668
390
668
    FN(PW,free)(pw2);
391
668
    return pw1;
392
724
  }
393
724
394
724
  n = (pw1->n + 1) * (pw2->n + 1);
395
56
#ifdef HAS_TYPE
396
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
397
#else
398
56
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
399
56
#endif
400
56
401
160
  for (i = 0; 
i < pw1->n160
;
++i104
)
{104
402
104
    set = isl_set_copy(pw1->p[i].set);
403
208
    for (j = 0; 
j < pw2->n208
;
++j104
)
{104
404
104
      struct isl_set *common;
405
104
      EL *sum;
406
104
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
407
104
            isl_set_copy(pw2->p[j].set));
408
104
      if (
isl_set_plain_is_empty(common)104
)
{102
409
102
        isl_set_free(common);
410
102
        continue;
411
104
      }
412
104
      set = isl_set_subtract(set,
413
2
          isl_set_copy(pw2->p[j].set));
414
2
415
2
      sum = FN(EL,add_on_domain)(common,
416
2
               
FN2
(EL,copy)(pw1->p[i].
FIELD2
),
417
2
               
FN2
(EL,copy)(pw2->p[j].
FIELD2
));
418
2
419
2
      res = FN(PW,add_piece)(res, common, sum);
420
104
    }
421
104
    res = 
FN104
(PW,add_piece)(res, set,
FN104
(EL,copy)(pw1->p[i].
FIELD104
));
422
104
  }
423
56
424
112
  for (j = 0; 
j < pw2->n112
;
++j56
)
{56
425
56
    set = isl_set_copy(pw2->p[j].set);
426
160
    for (i = 0; 
i < pw1->n160
;
++i104
)
427
104
      set = isl_set_subtract(set,
428
104
          isl_set_copy(pw1->p[i].set));
429
56
    res = 
FN56
(PW,add_piece)(res, set,
FN56
(EL,copy)(pw2->p[j].
FIELD56
));
430
56
  }
431
56
432
56
  FN(PW,free)(pw1);
433
56
  FN(PW,free)(pw2);
434
56
435
724
  return res;
436
724
error:
437
0
  FN(PW,free)(pw1);
438
0
  FN(PW,free)(pw2);
439
724
  return NULL;
440
794
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_union_add_aligned
441
442
/* Private version of "union_add".  For isl_pw_qpolynomial and
443
 * isl_pw_qpolynomial_fold, we prefer to simply call it "add".
444
 */
445
static __isl_give PW *FN(PW,union_add_)(__isl_take PW *pw1, __isl_take PW *pw2)
446
{
447
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
448
            &FN(PW,union_add_aligned));
449
}
isl_aff.c:isl_pw_aff_union_add_
Line
Count
Source
446
2.98k
{
447
2.98k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
448
2.98k
            &FN(PW,union_add_aligned));
449
2.98k
}
isl_aff.c:isl_pw_multi_aff_union_add_
Line
Count
Source
446
794
{
447
794
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
448
794
            &FN(PW,union_add_aligned));
449
794
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_union_add_
isl_polynomial.c:isl_pw_qpolynomial_union_add_
Line
Count
Source
446
24
{
447
24
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
448
24
            &FN(PW,union_add_aligned));
449
24
}
450
451
/* Make sure "pw" has room for at least "n" more pieces.
452
 *
453
 * If there is only one reference to pw, we extend it in place.
454
 * Otherwise, we create a new PW and copy the pieces.
455
 */
456
static __isl_give PW *FN(PW,grow)(__isl_take PW *pw, int n)
457
{
458
  int i;
459
  isl_ctx *ctx;
460
  PW *res;
461
462
  if (!pw)
463
    return NULL;
464
  if (pw->n + n <= pw->size)
465
    return pw;
466
  ctx = FN(PW,get_ctx)(pw);
467
  n += pw->n;
468
  if (pw->ref == 1) {
469
    res = isl_realloc(ctx, pw, struct PW,
470
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
471
    if (!res)
472
      return FN(PW,free)(pw);
473
    res->size = n;
474
    return res;
475
  }
476
#ifdef HAS_TYPE
477
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
478
#else
479
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), n);
480
#endif
481
  if (!res)
482
    return FN(PW,free)(pw);
483
  for (i = 0; i < pw->n; ++i)
484
    res = FN(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
485
              FN(EL,copy)(pw->p[i].FIELD));
486
  FN(PW,free)(pw);
487
  return res;
488
}
isl_polynomial.c:isl_pw_qpolynomial_grow
Line
Count
Source
457
1
{
458
1
  int i;
459
1
  isl_ctx *ctx;
460
1
  PW *res;
461
1
462
1
  if (!pw)
463
0
    return NULL;
464
1
  
if (1
pw->n + n <= pw->size1
)
465
0
    return pw;
466
1
  
ctx = 1
FN1
(PW,get_ctx)(pw);
467
1
  n += pw->n;
468
1
  if (
pw->ref == 11
)
{1
469
1
    res = isl_realloc(ctx, pw, struct PW,
470
1
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
471
1
    if (!res)
472
0
      
return 0
FN0
(PW,free)(pw);
473
1
    res->size = n;
474
1
    return res;
475
1
  }
476
1
#ifdef HAS_TYPE
477
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
478
#else
479
0
  
res = 0
FN0
(PW,alloc_size)(isl_space_copy(pw->dim), n);
480
0
#endif
481
0
  if (!res)
482
0
    
return 0
FN0
(PW,free)(pw);
483
0
  
for (i = 0; 0
i < pw->n0
;
++i0
)
484
0
    
res = 0
FN0
(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
485
0
              
FN0
(EL,copy)(pw->p[i].
FIELD0
));
486
0
  FN(PW,free)(pw);
487
0
  return res;
488
1
}
isl_aff.c:isl_pw_multi_aff_grow
Line
Count
Source
457
78
{
458
78
  int i;
459
78
  isl_ctx *ctx;
460
78
  PW *res;
461
78
462
78
  if (!pw)
463
0
    return NULL;
464
78
  
if (78
pw->n + n <= pw->size78
)
465
0
    return pw;
466
78
  
ctx = 78
FN78
(PW,get_ctx)(pw);
467
78
  n += pw->n;
468
78
  if (
pw->ref == 178
)
{78
469
78
    res = isl_realloc(ctx, pw, struct PW,
470
78
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
471
78
    if (!res)
472
0
      
return 0
FN0
(PW,free)(pw);
473
78
    res->size = n;
474
78
    return res;
475
78
  }
476
78
#ifdef HAS_TYPE
477
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
478
#else
479
0
  
res = 0
FN0
(PW,alloc_size)(isl_space_copy(pw->dim), n);
480
0
#endif
481
0
  if (!res)
482
0
    
return 0
FN0
(PW,free)(pw);
483
0
  
for (i = 0; 0
i < pw->n0
;
++i0
)
484
0
    
res = 0
FN0
(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
485
0
              
FN0
(EL,copy)(pw->p[i].
FIELD0
));
486
0
  FN(PW,free)(pw);
487
0
  return res;
488
78
}
isl_aff.c:isl_pw_aff_grow
Line
Count
Source
457
242
{
458
242
  int i;
459
242
  isl_ctx *ctx;
460
242
  PW *res;
461
242
462
242
  if (!pw)
463
0
    return NULL;
464
242
  
if (242
pw->n + n <= pw->size242
)
465
0
    return pw;
466
242
  
ctx = 242
FN242
(PW,get_ctx)(pw);
467
242
  n += pw->n;
468
242
  if (
pw->ref == 1242
)
{242
469
242
    res = isl_realloc(ctx, pw, struct PW,
470
242
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
471
242
    if (!res)
472
0
      
return 0
FN0
(PW,free)(pw);
473
242
    res->size = n;
474
242
    return res;
475
242
  }
476
242
#ifdef HAS_TYPE
477
  res = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, n);
478
#else
479
0
  
res = 0
FN0
(PW,alloc_size)(isl_space_copy(pw->dim), n);
480
0
#endif
481
0
  if (!res)
482
0
    
return 0
FN0
(PW,free)(pw);
483
0
  
for (i = 0; 0
i < pw->n0
;
++i0
)
484
0
    
res = 0
FN0
(PW,add_piece)(res, isl_set_copy(pw->p[i].set),
485
0
              
FN0
(EL,copy)(pw->p[i].
FIELD0
));
486
0
  FN(PW,free)(pw);
487
0
  return res;
488
242
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_grow
489
490
static __isl_give PW *FN(PW,add_disjoint_aligned)(__isl_take PW *pw1,
491
  __isl_take PW *pw2)
492
{
493
  int i;
494
  isl_ctx *ctx;
495
496
  if (!pw1 || !pw2)
497
    goto error;
498
499
  if (pw1->size < pw1->n + pw2->n && pw1->n < pw2->n)
500
    return FN(PW,add_disjoint_aligned)(pw2, pw1);
501
502
  ctx = isl_space_get_ctx(pw1->dim);
503
#ifdef HAS_TYPE
504
  if (pw1->type != pw2->type)
505
    isl_die(ctx, isl_error_invalid,
506
      "fold types don't match", goto error);
507
#endif
508
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
509
510
  if (FN(PW,IS_ZERO)(pw1)) {
511
    FN(PW,free)(pw1);
512
    return pw2;
513
  }
514
515
  if (FN(PW,IS_ZERO)(pw2)) {
516
    FN(PW,free)(pw2);
517
    return pw1;
518
  }
519
520
  pw1 = FN(PW,grow)(pw1, pw2->n);
521
  if (!pw1)
522
    goto error;
523
524
  for (i = 0; i < pw2->n; ++i)
525
    pw1 = FN(PW,add_piece)(pw1,
526
        isl_set_copy(pw2->p[i].set),
527
        FN(EL,copy)(pw2->p[i].FIELD));
528
529
  FN(PW,free)(pw2);
530
531
  return pw1;
532
error:
533
  FN(PW,free)(pw1);
534
  FN(PW,free)(pw2);
535
  return NULL;
536
}
isl_aff.c:isl_pw_aff_add_disjoint_aligned
Line
Count
Source
492
1.68k
{
493
1.68k
  int i;
494
1.68k
  isl_ctx *ctx;
495
1.68k
496
1.68k
  if (
!pw1 || 1.68k
!pw21.68k
)
497
0
    goto error;
498
1.68k
499
1.68k
  
if (1.68k
pw1->size < pw1->n + pw2->n && 1.68k
pw1->n < pw2->n909
)
500
667
    
return 667
FN667
(PW,add_disjoint_aligned)(pw2, pw1);
501
1.68k
502
1.68k
  ctx = isl_space_get_ctx(pw1->dim);
503
1.01k
#ifdef HAS_TYPE
504
  if (pw1->type != pw2->type)
505
    isl_die(ctx, isl_error_invalid,
506
      "fold types don't match", goto error);
507
#endif
508
1.01k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
509
1.01k
510
1.01k
  
if (1.01k
FN1.01k
(PW,IS_ZERO)(pw1)1.01k
)
{84
511
84
    FN(PW,free)(pw1);
512
84
    return pw2;
513
1.01k
  }
514
1.01k
515
931
  
if (931
FN931
(PW,IS_ZERO)(pw2)931
)
{689
516
689
    FN(PW,free)(pw2);
517
689
    return pw1;
518
931
  }
519
931
520
242
  
pw1 = 242
FN242
(PW,grow)(pw1, pw2->n);
521
242
  if (!pw1)
522
0
    goto error;
523
242
524
484
  
for (i = 0; 242
i < pw2->n484
;
++i242
)
525
242
    
pw1 = 242
FN242
(PW,add_piece)(pw1,
526
242
        isl_set_copy(pw2->p[i].set),
527
242
        
FN242
(EL,copy)(pw2->p[i].
FIELD242
));
528
242
529
242
  FN(PW,free)(pw2);
530
242
531
242
  return pw1;
532
242
error:
533
0
  FN(PW,free)(pw1);
534
0
  FN(PW,free)(pw2);
535
242
  return NULL;
536
1.68k
}
isl_polynomial.c:isl_pw_qpolynomial_add_disjoint_aligned
Line
Count
Source
492
3
{
493
3
  int i;
494
3
  isl_ctx *ctx;
495
3
496
3
  if (
!pw1 || 3
!pw23
)
497
0
    goto error;
498
3
499
3
  
if (3
pw1->size < pw1->n + pw2->n && 3
pw1->n < pw2->n2
)
500
1
    
return 1
FN1
(PW,add_disjoint_aligned)(pw2, pw1);
501
3
502
3
  ctx = isl_space_get_ctx(pw1->dim);
503
2
#ifdef HAS_TYPE
504
  if (pw1->type != pw2->type)
505
    isl_die(ctx, isl_error_invalid,
506
      "fold types don't match", goto error);
507
#endif
508
2
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
509
2
510
2
  
if (2
FN2
(PW,IS_ZERO)(pw1)2
)
{0
511
0
    FN(PW,free)(pw1);
512
0
    return pw2;
513
2
  }
514
2
515
2
  
if (2
FN2
(PW,IS_ZERO)(pw2)2
)
{1
516
1
    FN(PW,free)(pw2);
517
1
    return pw1;
518
2
  }
519
2
520
1
  
pw1 = 1
FN1
(PW,grow)(pw1, pw2->n);
521
1
  if (!pw1)
522
0
    goto error;
523
1
524
2
  
for (i = 0; 1
i < pw2->n2
;
++i1
)
525
1
    
pw1 = 1
FN1
(PW,add_piece)(pw1,
526
1
        isl_set_copy(pw2->p[i].set),
527
1
        
FN1
(EL,copy)(pw2->p[i].
FIELD1
));
528
1
529
1
  FN(PW,free)(pw2);
530
1
531
1
  return pw1;
532
1
error:
533
0
  FN(PW,free)(pw1);
534
0
  FN(PW,free)(pw2);
535
1
  return NULL;
536
3
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_add_disjoint_aligned
isl_aff.c:isl_pw_multi_aff_add_disjoint_aligned
Line
Count
Source
492
4.81k
{
493
4.81k
  int i;
494
4.81k
  isl_ctx *ctx;
495
4.81k
496
4.81k
  if (
!pw1 || 4.81k
!pw24.81k
)
497
0
    goto error;
498
4.81k
499
4.81k
  
if (4.81k
pw1->size < pw1->n + pw2->n && 4.81k
pw1->n < pw2->n2.44k
)
500
2.36k
    
return 2.36k
FN2.36k
(PW,add_disjoint_aligned)(pw2, pw1);
501
4.81k
502
4.81k
  ctx = isl_space_get_ctx(pw1->dim);
503
2.44k
#ifdef HAS_TYPE
504
  if (pw1->type != pw2->type)
505
    isl_die(ctx, isl_error_invalid,
506
      "fold types don't match", goto error);
507
#endif
508
2.44k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
509
2.44k
510
2.44k
  
if (2.44k
FN2.44k
(PW,IS_ZERO)(pw1)2.44k
)
{0
511
0
    FN(PW,free)(pw1);
512
0
    return pw2;
513
2.44k
  }
514
2.44k
515
2.44k
  
if (2.44k
FN2.44k
(PW,IS_ZERO)(pw2)2.44k
)
{2.36k
516
2.36k
    FN(PW,free)(pw2);
517
2.36k
    return pw1;
518
2.44k
  }
519
2.44k
520
78
  
pw1 = 78
FN78
(PW,grow)(pw1, pw2->n);
521
78
  if (!pw1)
522
0
    goto error;
523
78
524
156
  
for (i = 0; 78
i < pw2->n156
;
++i78
)
525
78
    
pw1 = 78
FN78
(PW,add_piece)(pw1,
526
78
        isl_set_copy(pw2->p[i].set),
527
78
        
FN78
(EL,copy)(pw2->p[i].
FIELD78
));
528
78
529
78
  FN(PW,free)(pw2);
530
78
531
78
  return pw1;
532
78
error:
533
0
  FN(PW,free)(pw1);
534
0
  FN(PW,free)(pw2);
535
78
  return NULL;
536
4.81k
}
537
538
__isl_give PW *FN(PW,add_disjoint)(__isl_take PW *pw1, __isl_take PW *pw2)
539
{
540
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
541
            &FN(PW,add_disjoint_aligned));
542
}
isl_pw_aff_add_disjoint
Line
Count
Source
539
1.01k
{
540
1.01k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
541
1.01k
            &FN(PW,add_disjoint_aligned));
542
1.01k
}
isl_pw_multi_aff_add_disjoint
Line
Count
Source
539
2.44k
{
540
2.44k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
541
2.44k
            &FN(PW,add_disjoint_aligned));
542
2.44k
}
isl_pw_qpolynomial_add_disjoint
Line
Count
Source
539
2
{
540
2
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
541
2
            &FN(PW,add_disjoint_aligned));
542
2
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_add_disjoint
543
544
/* This function is currently only used from isl_aff.c
545
 */
546
static __isl_give PW *FN(PW,on_shared_domain_in)(__isl_take PW *pw1,
547
  __isl_take PW *pw2, __isl_take isl_space *space,
548
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
549
  __attribute__ ((unused));
550
551
/* Apply "fn" to pairs of elements from pw1 and pw2 on shared domains.
552
 * The result of "fn" (and therefore also of this function) lives in "space".
553
 */
554
static __isl_give PW *FN(PW,on_shared_domain_in)(__isl_take PW *pw1,
555
  __isl_take PW *pw2, __isl_take isl_space *space,
556
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
557
{
558
  int i, j, n;
559
  PW *res = NULL;
560
561
  if (!pw1 || !pw2)
562
    goto error;
563
564
  n = pw1->n * pw2->n;
565
#ifdef HAS_TYPE
566
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
567
#else
568
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
569
#endif
570
571
  for (i = 0; i < pw1->n; ++i) {
572
    for (j = 0; j < pw2->n; ++j) {
573
      isl_set *common;
574
      EL *res_ij;
575
      int empty;
576
577
      common = isl_set_intersect(
578
          isl_set_copy(pw1->p[i].set),
579
          isl_set_copy(pw2->p[j].set));
580
      empty = isl_set_plain_is_empty(common);
581
      if (empty < 0 || empty) {
582
        isl_set_free(common);
583
        if (empty < 0)
584
          goto error;
585
        continue;
586
      }
587
588
      res_ij = fn(FN(EL,copy)(pw1->p[i].FIELD),
589
            FN(EL,copy)(pw2->p[j].FIELD));
590
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
591
592
      res = FN(PW,add_piece)(res, common, res_ij);
593
    }
594
  }
595
596
  isl_space_free(space);
597
  FN(PW,free)(pw1);
598
  FN(PW,free)(pw2);
599
  return res;
600
error:
601
  isl_space_free(space);
602
  FN(PW,free)(pw1);
603
  FN(PW,free)(pw2);
604
  FN(PW,free)(res);
605
  return NULL;
606
}
isl_aff.c:isl_pw_multi_aff_on_shared_domain_in
Line
Count
Source
557
178
{
558
178
  int i, j, n;
559
178
  PW *res = NULL;
560
178
561
178
  if (
!pw1 || 178
!pw2178
)
562
0
    goto error;
563
178
564
178
  n = pw1->n * pw2->n;
565
178
#ifdef HAS_TYPE
566
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
567
#else
568
178
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
569
178
#endif
570
178
571
356
  for (i = 0; 
i < pw1->n356
;
++i178
)
{178
572
359
    for (j = 0; 
j < pw2->n359
;
++j181
)
{181
573
181
      isl_set *common;
574
181
      EL *res_ij;
575
181
      int empty;
576
181
577
181
      common = isl_set_intersect(
578
181
          isl_set_copy(pw1->p[i].set),
579
181
          isl_set_copy(pw2->p[j].set));
580
181
      empty = isl_set_plain_is_empty(common);
581
181
      if (
empty < 0 || 181
empty181
)
{0
582
0
        isl_set_free(common);
583
0
        if (empty < 0)
584
0
          goto error;
585
0
        continue;
586
181
      }
587
181
588
181
      
res_ij = fn(181
FN181
(EL,copy)(pw1->p[i].
FIELD181
),
589
181
            
FN181
(EL,copy)(pw2->p[j].
FIELD181
));
590
181
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
591
181
592
181
      res = FN(PW,add_piece)(res, common, res_ij);
593
181
    }
594
178
  }
595
178
596
178
  isl_space_free(space);
597
178
  FN(PW,free)(pw1);
598
178
  FN(PW,free)(pw2);
599
178
  return res;
600
178
error:
601
0
  isl_space_free(space);
602
0
  FN(PW,free)(pw1);
603
0
  FN(PW,free)(pw2);
604
0
  FN(PW,free)(res);
605
178
  return NULL;
606
178
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_on_shared_domain_in
isl_aff.c:isl_pw_aff_on_shared_domain_in
Line
Count
Source
557
72.5k
{
558
72.5k
  int i, j, n;
559
72.5k
  PW *res = NULL;
560
72.5k
561
72.5k
  if (
!pw1 || 72.5k
!pw272.5k
)
562
0
    goto error;
563
72.5k
564
72.5k
  n = pw1->n * pw2->n;
565
72.5k
#ifdef HAS_TYPE
566
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
567
#else
568
72.5k
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
569
72.5k
#endif
570
72.5k
571
147k
  for (i = 0; 
i < pw1->n147k
;
++i74.8k
)
{74.8k
572
152k
    for (j = 0; 
j < pw2->n152k
;
++j77.9k
)
{77.9k
573
77.9k
      isl_set *common;
574
77.9k
      EL *res_ij;
575
77.9k
      int empty;
576
77.9k
577
77.9k
      common = isl_set_intersect(
578
77.9k
          isl_set_copy(pw1->p[i].set),
579
77.9k
          isl_set_copy(pw2->p[j].set));
580
77.9k
      empty = isl_set_plain_is_empty(common);
581
77.9k
      if (
empty < 0 || 77.9k
empty77.9k
)
{2.96k
582
2.96k
        isl_set_free(common);
583
2.96k
        if (empty < 0)
584
0
          goto error;
585
2.96k
        continue;
586
77.9k
      }
587
77.9k
588
75.0k
      
res_ij = fn(75.0k
FN75.0k
(EL,copy)(pw1->p[i].
FIELD75.0k
),
589
75.0k
            
FN75.0k
(EL,copy)(pw2->p[j].
FIELD75.0k
));
590
75.0k
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
591
75.0k
592
75.0k
      res = FN(PW,add_piece)(res, common, res_ij);
593
75.0k
    }
594
74.8k
  }
595
72.5k
596
72.5k
  isl_space_free(space);
597
72.5k
  FN(PW,free)(pw1);
598
72.5k
  FN(PW,free)(pw2);
599
72.5k
  return res;
600
72.5k
error:
601
0
  isl_space_free(space);
602
0
  FN(PW,free)(pw1);
603
0
  FN(PW,free)(pw2);
604
0
  FN(PW,free)(res);
605
72.5k
  return NULL;
606
72.5k
}
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_on_shared_domain_in
607
608
/* This function is currently only used from isl_aff.c
609
 */
610
static __isl_give PW *FN(PW,on_shared_domain)(__isl_take PW *pw1,
611
  __isl_take PW *pw2,
612
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
613
  __attribute__ ((unused));
614
615
/* Apply "fn" to pairs of elements from pw1 and pw2 on shared domains.
616
 * The result of "fn" is assumed to live in the same space as "pw1" and "pw2".
617
 */
618
static __isl_give PW *FN(PW,on_shared_domain)(__isl_take PW *pw1,
619
  __isl_take PW *pw2,
620
  __isl_give EL *(*fn)(__isl_take EL *el1, __isl_take EL *el2))
621
{
622
  isl_space *space;
623
624
  if (!pw1 || !pw2)
625
    goto error;
626
627
  space = isl_space_copy(pw1->dim);
628
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
629
error:
630
  FN(PW,free)(pw1);
631
  FN(PW,free)(pw2);
632
  return NULL;
633
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_on_shared_domain
isl_aff.c:isl_pw_aff_on_shared_domain
Line
Count
Source
621
72.5k
{
622
72.5k
  isl_space *space;
623
72.5k
624
72.5k
  if (
!pw1 || 72.5k
!pw272.5k
)
625
0
    goto error;
626
72.5k
627
72.5k
  space = isl_space_copy(pw1->dim);
628
72.5k
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
629
72.5k
error:
630
0
  FN(PW,free)(pw1);
631
0
  FN(PW,free)(pw2);
632
72.5k
  return NULL;
633
72.5k
}
isl_aff.c:isl_pw_multi_aff_on_shared_domain
Line
Count
Source
621
1
{
622
1
  isl_space *space;
623
1
624
1
  if (
!pw1 || 1
!pw21
)
625
0
    goto error;
626
1
627
1
  space = isl_space_copy(pw1->dim);
628
1
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
629
1
error:
630
0
  FN(PW,free)(pw1);
631
0
  FN(PW,free)(pw2);
632
1
  return NULL;
633
1
}
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_on_shared_domain
634
635
#ifndef NO_NEG
636
__isl_give PW *FN(PW,neg)(__isl_take PW *pw)
637
{
638
  int i;
639
640
  if (!pw)
641
    return NULL;
642
643
  if (FN(PW,IS_ZERO)(pw))
644
    return pw;
645
646
  pw = FN(PW,cow)(pw);
647
  if (!pw)
648
    return NULL;
649
650
  for (i = 0; i < pw->n; ++i) {
651
    pw->p[i].FIELD = FN(EL,neg)(pw->p[i].FIELD);
652
    if (!pw->p[i].FIELD)
653
      return FN(PW,free)(pw);
654
  }
655
656
  return pw;
657
}
Unexecuted instantiation: isl_pw_multi_aff_neg
isl_pw_aff_neg
Line
Count
Source
637
22.7k
{
638
22.7k
  int i;
639
22.7k
640
22.7k
  if (!pw)
641
0
    return NULL;
642
22.7k
643
22.7k
  
if (22.7k
FN22.7k
(PW,IS_ZERO)(pw)22.7k
)
644
0
    return pw;
645
22.7k
646
22.7k
  
pw = 22.7k
FN22.7k
(PW,cow)(pw);
647
22.7k
  if (!pw)
648
0
    return NULL;
649
22.7k
650
46.3k
  
for (i = 0; 22.7k
i < pw->n46.3k
;
++i23.5k
)
{23.5k
651
23.5k
    pw->p[i].
FIELD23.5k
=
FN23.5k
(EL,neg)(pw->p[i].
FIELD23.5k
);
652
23.5k
    if (
!pw->p[i].23.5k
FIELD23.5k
)
653
0
      
return 0
FN0
(PW,free)(pw);
654
23.5k
  }
655
22.7k
656
22.7k
  return pw;
657
22.7k
}
isl_pw_qpolynomial_neg
Line
Count
Source
637
11
{
638
11
  int i;
639
11
640
11
  if (!pw)
641
0
    return NULL;
642
11
643
11
  
if (11
FN11
(PW,IS_ZERO)(pw)11
)
644
0
    return pw;
645
11
646
11
  
pw = 11
FN11
(PW,cow)(pw);
647
11
  if (!pw)
648
0
    return NULL;
649
11
650
23
  
for (i = 0; 11
i < pw->n23
;
++i12
)
{12
651
12
    pw->p[i].
FIELD12
=
FN12
(EL,neg)(pw->p[i].
FIELD12
);
652
12
    if (
!pw->p[i].12
FIELD12
)
653
0
      
return 0
FN0
(PW,free)(pw);
654
12
  }
655
11
656
11
  return pw;
657
11
}
658
#endif
659
660
#ifndef NO_SUB
661
__isl_give PW *FN(PW,sub)(__isl_take PW *pw1, __isl_take PW *pw2)
662
{
663
  return FN(PW,add)(pw1, FN(PW,neg)(pw2));
664
}
isl_pw_aff_sub
Line
Count
Source
662
6.75k
{
663
6.75k
  return 
FN6.75k
(PW,add)(pw1,
FN6.75k
(PW,neg)(pw2));
664
6.75k
}
isl_pw_qpolynomial_sub
Line
Count
Source
662
9
{
663
9
  return 
FN9
(PW,add)(pw1,
FN9
(PW,neg)(pw2));
664
9
}
665
#endif
666
667
#ifndef NO_EVAL
668
__isl_give isl_val *FN(PW,eval)(__isl_take PW *pw, __isl_take isl_point *pnt)
669
{
670
  int i;
671
  int found = 0;
672
  isl_ctx *ctx;
673
  isl_space *pnt_dim = NULL;
674
  isl_val *v;
675
676
  if (!pw || !pnt)
677
    goto error;
678
  ctx = isl_point_get_ctx(pnt);
679
  pnt_dim = isl_point_get_space(pnt);
680
  isl_assert(ctx, isl_space_is_domain_internal(pnt_dim, pw->dim),
681
        goto error);
682
683
  for (i = 0; i < pw->n; ++i) {
684
    found = isl_set_contains_point(pw->p[i].set, pnt);
685
    if (found < 0)
686
      goto error;
687
    if (found)
688
      break;
689
  }
690
  if (found)
691
    v = FN(EL,eval)(FN(EL,copy)(pw->p[i].FIELD),
692
              isl_point_copy(pnt));
693
  else
694
    v = isl_val_zero(ctx);
695
  FN(PW,free)(pw);
696
  isl_space_free(pnt_dim);
697
  isl_point_free(pnt);
698
  return v;
699
error:
700
  FN(PW,free)(pw);
701
  isl_space_free(pnt_dim);
702
  isl_point_free(pnt);
703
  return NULL;
704
}
isl_pw_qpolynomial_eval
Line
Count
Source
669
1
{
670
1
  int i;
671
1
  int found = 0;
672
1
  isl_ctx *ctx;
673
1
  isl_space *pnt_dim = NULL;
674
1
  isl_val *v;
675
1
676
1
  if (
!pw || 1
!pnt1
)
677
0
    goto error;
678
1
  ctx = isl_point_get_ctx(pnt);
679
1
  pnt_dim = isl_point_get_space(pnt);
680
1
  isl_assert(ctx, isl_space_is_domain_internal(pnt_dim, pw->dim),
681
1
        goto error);
682
1
683
1
  
for (i = 0; 1
i < pw->n1
;
++i0
)
{1
684
1
    found = isl_set_contains_point(pw->p[i].set, pnt);
685
1
    if (found < 0)
686
0
      goto error;
687
1
    
if (1
found1
)
688
1
      break;
689
1
  }
690
1
  
if (1
found1
)
691
1
    
v = 1
FN1
(EL,eval)(
FN1
(EL,copy)(pw->p[i].
FIELD1
),
692
1
              isl_point_copy(pnt));
693
1
  else
694
0
    v = isl_val_zero(ctx);
695
1
  FN(PW,free)(pw);
696
1
  isl_space_free(pnt_dim);
697
1
  isl_point_free(pnt);
698
1
  return v;
699
1
error:
700
0
  FN(PW,free)(pw);
701
0
  isl_space_free(pnt_dim);
702
0
  isl_point_free(pnt);
703
1
  return NULL;
704
1
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_eval
705
#endif
706
707
/* Return the parameter domain of "pw".
708
 */
709
__isl_give isl_set *FN(PW,params)(__isl_take PW *pw)
710
{
711
  return isl_set_params(FN(PW,domain)(pw));
712
}
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
713
714
__isl_give isl_set *FN(PW,domain)(__isl_take PW *pw)
715
{
716
  int i;
717
  isl_set *dom;
718
719
  if (!pw)
720
    return NULL;
721
722
  dom = isl_set_empty(FN(PW,get_domain_space)(pw));
723
  for (i = 0; i < pw->n; ++i)
724
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
725
726
  FN(PW,free)(pw);
727
728
  return dom;
729
}
isl_pw_multi_aff_domain
Line
Count
Source
715
225
{
716
225
  int i;
717
225
  isl_set *dom;
718
225
719
225
  if (!pw)
720
0
    return NULL;
721
225
722
225
  
dom = isl_set_empty(225
FN225
(PW,get_domain_space)(pw));
723
450
  for (i = 0; 
i < pw->n450
;
++i225
)
724
225
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
725
225
726
225
  FN(PW,free)(pw);
727
225
728
225
  return dom;
729
225
}
isl_pw_aff_domain
Line
Count
Source
715
49.8k
{
716
49.8k
  int i;
717
49.8k
  isl_set *dom;
718
49.8k
719
49.8k
  if (!pw)
720
0
    return NULL;
721
49.8k
722
49.8k
  
dom = isl_set_empty(49.8k
FN49.8k
(PW,get_domain_space)(pw));
723
101k
  for (i = 0; 
i < pw->n101k
;
++i51.4k
)
724
51.4k
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
725
49.8k
726
49.8k
  FN(PW,free)(pw);
727
49.8k
728
49.8k
  return dom;
729
49.8k
}
isl_pw_qpolynomial_domain
Line
Count
Source
715
1
{
716
1
  int i;
717
1
  isl_set *dom;
718
1
719
1
  if (!pw)
720
0
    return NULL;
721
1
722
1
  
dom = isl_set_empty(1
FN1
(PW,get_domain_space)(pw));
723
2
  for (i = 0; 
i < pw->n2
;
++i1
)
724
1
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
725
1
726
1
  FN(PW,free)(pw);
727
1
728
1
  return dom;
729
1
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_domain
730
731
/* Exploit the equalities in the domain of piece "i" of "pw"
732
 * to simplify the associated function.
733
 * If the domain of piece "i" is empty, then remove it entirely,
734
 * replacing it with the final piece.
735
 */
736
static int FN(PW,exploit_equalities_and_remove_if_empty)(__isl_keep PW *pw,
737
  int i)
738
{
739
  isl_basic_set *aff;
740
  int empty = isl_set_plain_is_empty(pw->p[i].set);
741
742
  if (empty < 0)
743
    return -1;
744
  if (empty) {
745
    isl_set_free(pw->p[i].set);
746
    FN(EL,free)(pw->p[i].FIELD);
747
    if (i != pw->n - 1)
748
      pw->p[i] = pw->p[pw->n - 1];
749
    pw->n--;
750
751
    return 0;
752
  }
753
754
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
755
  pw->p[i].FIELD = FN(EL,substitute_equalities)(pw->p[i].FIELD, aff);
756
  if (!pw->p[i].FIELD)
757
    return -1;
758
759
  return 0;
760
}
isl_polynomial.c:isl_pw_qpolynomial_exploit_equalities_and_remove_if_empty
Line
Count
Source
738
35
{
739
35
  isl_basic_set *aff;
740
35
  int empty = isl_set_plain_is_empty(pw->p[i].set);
741
35
742
35
  if (empty < 0)
743
0
    return -1;
744
35
  
if (35
empty35
)
{0
745
0
    isl_set_free(pw->p[i].set);
746
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
747
0
    if (i != pw->n - 1)
748
0
      pw->p[i] = pw->p[pw->n - 1];
749
0
    pw->n--;
750
0
751
0
    return 0;
752
35
  }
753
35
754
35
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
755
35
  pw->p[i].
FIELD35
=
FN35
(EL,substitute_equalities)(pw->p[i].
FIELD35
, aff);
756
35
  if (
!pw->p[i].35
FIELD35
)
757
0
    return -1;
758
35
759
35
  return 0;
760
35
}
isl_aff.c:isl_pw_multi_aff_exploit_equalities_and_remove_if_empty
Line
Count
Source
738
1.72k
{
739
1.72k
  isl_basic_set *aff;
740
1.72k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
741
1.72k
742
1.72k
  if (empty < 0)
743
0
    return -1;
744
1.72k
  
if (1.72k
empty1.72k
)
{1
745
1
    isl_set_free(pw->p[i].set);
746
1
    
FN1
(EL,free)(pw->p[i].
FIELD1
);
747
1
    if (i != pw->n - 1)
748
0
      pw->p[i] = pw->p[pw->n - 1];
749
1
    pw->n--;
750
1
751
1
    return 0;
752
1.72k
  }
753
1.72k
754
1.72k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
755
1.72k
  pw->p[i].
FIELD1.72k
=
FN1.72k
(EL,substitute_equalities)(pw->p[i].
FIELD1.72k
, aff);
756
1.72k
  if (
!pw->p[i].1.72k
FIELD1.72k
)
757
0
    return -1;
758
1.72k
759
1.72k
  return 0;
760
1.72k
}
isl_aff.c:isl_pw_aff_exploit_equalities_and_remove_if_empty
Line
Count
Source
738
34.5k
{
739
34.5k
  isl_basic_set *aff;
740
34.5k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
741
34.5k
742
34.5k
  if (empty < 0)
743
0
    return -1;
744
34.5k
  
if (34.5k
empty34.5k
)
{20
745
20
    isl_set_free(pw->p[i].set);
746
20
    
FN20
(EL,free)(pw->p[i].
FIELD20
);
747
20
    if (i != pw->n - 1)
748
0
      pw->p[i] = pw->p[pw->n - 1];
749
20
    pw->n--;
750
20
751
20
    return 0;
752
34.5k
  }
753
34.5k
754
34.5k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
755
34.4k
  pw->p[i].
FIELD34.4k
=
FN34.4k
(EL,substitute_equalities)(pw->p[i].
FIELD34.4k
, aff);
756
34.4k
  if (
!pw->p[i].34.4k
FIELD34.4k
)
757
0
    return -1;
758
34.4k
759
34.4k
  return 0;
760
34.5k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_exploit_equalities_and_remove_if_empty
761
762
/* Convert a piecewise expression defined over a parameter domain
763
 * into one that is defined over a zero-dimensional set.
764
 */
765
__isl_give PW *FN(PW,from_range)(__isl_take PW *pw)
766
{
767
  isl_space *space;
768
769
  if (!pw)
770
    return NULL;
771
  if (!isl_space_is_set(pw->dim))
772
    isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
773
      "not living in a set space", return FN(PW,free)(pw));
774
775
  space = FN(PW,get_space)(pw);
776
  space = isl_space_from_range(space);
777
  pw = FN(PW,reset_space)(pw, space);
778
779
  return pw;
780
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_from_range
Unexecuted instantiation: isl_pw_aff_from_range
Unexecuted instantiation: isl_pw_qpolynomial_from_range
Unexecuted instantiation: isl_pw_multi_aff_from_range
781
782
/* Fix the value of the given parameter or domain dimension of "pw"
783
 * to be equal to "value".
784
 */
785
__isl_give PW *FN(PW,fix_si)(__isl_take PW *pw, enum isl_dim_type type,
786
  unsigned pos, int value)
787
{
788
  int i;
789
790
  if (!pw)
791
    return NULL;
792
793
  if (type == isl_dim_out)
794
    isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
795
      "cannot fix output dimension", return FN(PW,free)(pw));
796
797
  if (pw->n == 0)
798
    return pw;
799
800
  if (type == isl_dim_in)
801
    type = isl_dim_set;
802
803
  pw = FN(PW,cow)(pw);
804
  if (!pw)
805
    return FN(PW,free)(pw);
806
807
  for (i = pw->n - 1; i >= 0; --i) {
808
    pw->p[i].set = isl_set_fix_si(pw->p[i].set, type, pos, value);
809
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
810
      return FN(PW,free)(pw);
811
  }
812
813
  return pw;
814
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_si
Unexecuted instantiation: isl_pw_multi_aff_fix_si
Unexecuted instantiation: isl_pw_aff_fix_si
Unexecuted instantiation: isl_pw_qpolynomial_fix_si
815
816
/* Restrict the domain of "pw" by combining each cell
817
 * with "set" through a call to "fn", where "fn" may be
818
 * isl_set_intersect, isl_set_intersect_params or isl_set_subtract.
819
 */
820
static __isl_give PW *FN(PW,restrict_domain_aligned)(__isl_take PW *pw,
821
  __isl_take isl_set *set,
822
  __isl_give isl_set *(*fn)(__isl_take isl_set *set1,
823
            __isl_take isl_set *set2))
824
{
825
  int i;
826
827
  if (!pw || !set)
828
    goto error;
829
830
  if (pw->n == 0) {
831
    isl_set_free(set);
832
    return pw;
833
  }
834
835
  pw = FN(PW,cow)(pw);
836
  if (!pw)
837
    goto error;
838
839
  for (i = pw->n - 1; i >= 0; --i) {
840
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
841
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
842
      goto error;
843
  }
844
  
845
  isl_set_free(set);
846
  return pw;
847
error:
848
  isl_set_free(set);
849
  FN(PW,free)(pw);
850
  return NULL;
851
}
isl_polynomial.c:isl_pw_qpolynomial_restrict_domain_aligned
Line
Count
Source
824
35
{
825
35
  int i;
826
35
827
35
  if (
!pw || 35
!set35
)
828
0
    goto error;
829
35
830
35
  
if (35
pw->n == 035
)
{1
831
1
    isl_set_free(set);
832
1
    return pw;
833
35
  }
834
35
835
34
  
pw = 34
FN34
(PW,cow)(pw);
836
34
  if (!pw)
837
0
    goto error;
838
34
839
68
  
for (i = pw->n - 1; 34
i >= 068
;
--i34
)
{34
840
34
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
841
34
    if (
FN34
(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 034
)
842
0
      goto error;
843
34
  }
844
34
  
845
34
  isl_set_free(set);
846
34
  return pw;
847
34
error:
848
0
  isl_set_free(set);
849
0
  FN(PW,free)(pw);
850
34
  return NULL;
851
35
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_restrict_domain_aligned
isl_aff.c:isl_pw_multi_aff_restrict_domain_aligned
Line
Count
Source
824
1.72k
{
825
1.72k
  int i;
826
1.72k
827
1.72k
  if (
!pw || 1.72k
!set1.72k
)
828
0
    goto error;
829
1.72k
830
1.72k
  
if (1.72k
pw->n == 01.72k
)
{0
831
0
    isl_set_free(set);
832
0
    return pw;
833
1.72k
  }
834
1.72k
835
1.72k
  
pw = 1.72k
FN1.72k
(PW,cow)(pw);
836
1.72k
  if (!pw)
837
0
    goto error;
838
1.72k
839
3.45k
  
for (i = pw->n - 1; 1.72k
i >= 03.45k
;
--i1.72k
)
{1.72k
840
1.72k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
841
1.72k
    if (
FN1.72k
(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 01.72k
)
842
0
      goto error;
843
1.72k
  }
844
1.72k
  
845
1.72k
  isl_set_free(set);
846
1.72k
  return pw;
847
1.72k
error:
848
0
  isl_set_free(set);
849
0
  FN(PW,free)(pw);
850
1.72k
  return NULL;
851
1.72k
}
isl_aff.c:isl_pw_aff_restrict_domain_aligned
Line
Count
Source
824
33.2k
{
825
33.2k
  int i;
826
33.2k
827
33.2k
  if (
!pw || 33.2k
!set33.2k
)
828
0
    goto error;
829
33.2k
830
33.2k
  
if (33.2k
pw->n == 033.2k
)
{0
831
0
    isl_set_free(set);
832
0
    return pw;
833
33.2k
  }
834
33.2k
835
33.2k
  
pw = 33.2k
FN33.2k
(PW,cow)(pw);
836
33.2k
  if (!pw)
837
0
    goto error;
838
33.2k
839
67.7k
  
for (i = pw->n - 1; 33.2k
i >= 067.7k
;
--i34.5k
)
{34.5k
840
34.5k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
841
34.5k
    if (
FN34.5k
(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 034.5k
)
842
0
      goto error;
843
34.5k
  }
844
33.2k
  
845
33.2k
  isl_set_free(set);
846
33.2k
  return pw;
847
33.2k
error:
848
0
  isl_set_free(set);
849
0
  FN(PW,free)(pw);
850
33.2k
  return NULL;
851
33.2k
}
852
853
static __isl_give PW *FN(PW,intersect_domain_aligned)(__isl_take PW *pw,
854
  __isl_take isl_set *set)
855
{
856
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
857
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_intersect_domain_aligned
isl_aff.c:isl_pw_multi_aff_intersect_domain_aligned
Line
Count
Source
855
1.72k
{
856
1.72k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
857
1.72k
}
isl_aff.c:isl_pw_aff_intersect_domain_aligned
Line
Count
Source
855
33.2k
{
856
33.2k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
857
33.2k
}
isl_polynomial.c:isl_pw_qpolynomial_intersect_domain_aligned
Line
Count
Source
855
35
{
856
35
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
857
35
}
858
859
__isl_give PW *FN(PW,intersect_domain)(__isl_take PW *pw,
860
  __isl_take isl_set *context)
861
{
862
  return FN(PW,align_params_pw_set_and)(pw, context,
863
          &FN(PW,intersect_domain_aligned));
864
}
isl_pw_multi_aff_intersect_domain
Line
Count
Source
861
1.72k
{
862
1.72k
  return FN(PW,align_params_pw_set_and)(pw, context,
863
1.72k
          &FN(PW,intersect_domain_aligned));
864
1.72k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_intersect_domain
isl_pw_qpolynomial_intersect_domain
Line
Count
Source
861
35
{
862
35
  return FN(PW,align_params_pw_set_and)(pw, context,
863
35
          &FN(PW,intersect_domain_aligned));
864
35
}
isl_pw_aff_intersect_domain
Line
Count
Source
861
33.2k
{
862
33.2k
  return FN(PW,align_params_pw_set_and)(pw, context,
863
33.2k
          &FN(PW,intersect_domain_aligned));
864
33.2k
}
865
866
static __isl_give PW *FN(PW,intersect_params_aligned)(__isl_take PW *pw,
867
  __isl_take isl_set *set)
868
{
869
  return FN(PW,restrict_domain_aligned)(pw, set,
870
          &isl_set_intersect_params);
871
}
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_intersect_params_aligned
Unexecuted instantiation: isl_aff.c:isl_pw_multi_aff_intersect_params_aligned
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_intersect_params_aligned
Unexecuted instantiation: isl_aff.c:isl_pw_aff_intersect_params_aligned
872
873
/* Intersect the domain of "pw" with the parameter domain "context".
874
 */
875
__isl_give PW *FN(PW,intersect_params)(__isl_take PW *pw,
876
  __isl_take isl_set *context)
877
{
878
  return FN(PW,align_params_pw_set_and)(pw, context,
879
          &FN(PW,intersect_params_aligned));
880
}
Unexecuted instantiation: isl_pw_qpolynomial_intersect_params
Unexecuted instantiation: isl_pw_qpolynomial_fold_intersect_params
Unexecuted instantiation: isl_pw_multi_aff_intersect_params
Unexecuted instantiation: isl_pw_aff_intersect_params
881
882
/* Subtract "domain' from the domain of "pw", assuming their
883
 * parameters have been aligned.
884
 */
885
static __isl_give PW *FN(PW,subtract_domain_aligned)(__isl_take PW *pw,
886
  __isl_take isl_set *domain)
887
{
888
  return FN(PW,restrict_domain_aligned)(pw, domain, &isl_set_subtract);
889
}
Unexecuted instantiation: isl_aff.c:isl_pw_aff_subtract_domain_aligned
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_subtract_domain_aligned
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_subtract_domain_aligned
isl_aff.c:isl_pw_multi_aff_subtract_domain_aligned
Line
Count
Source
887
3
{
888
3
  return FN(PW,restrict_domain_aligned)(pw, domain, &isl_set_subtract);
889
3
}
890
891
/* Subtract "domain' from the domain of "pw".
892
 */
893
__isl_give PW *FN(PW,subtract_domain)(__isl_take PW *pw,
894
  __isl_take isl_set *domain)
895
{
896
  return FN(PW,align_params_pw_set_and)(pw, domain,
897
          &FN(PW,subtract_domain_aligned));
898
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_subtract_domain
isl_pw_multi_aff_subtract_domain
Line
Count
Source
895
3
{
896
3
  return FN(PW,align_params_pw_set_and)(pw, domain,
897
3
          &FN(PW,subtract_domain_aligned));
898
3
}
Unexecuted instantiation: isl_pw_qpolynomial_subtract_domain
Unexecuted instantiation: isl_pw_aff_subtract_domain
899
900
/* Compute the gist of "pw" with respect to the domain constraints
901
 * of "context" for the case where the domain of the last element
902
 * of "pw" is equal to "context".
903
 * Call "fn_el" to compute the gist of this element, replace
904
 * its domain by the universe and drop all other elements
905
 * as their domains are necessarily disjoint from "context".
906
 */
907
static __isl_give PW *FN(PW,gist_last)(__isl_take PW *pw,
908
  __isl_take isl_set *context,
909
  __isl_give EL *(*fn_el)(__isl_take EL *el, __isl_take isl_set *set))
910
{
911
  int i;
912
  isl_space *space;
913
914
  for (i = 0; i < pw->n - 1; ++i) {
915
    isl_set_free(pw->p[i].set);
916
    FN(EL,free)(pw->p[i].FIELD);
917
  }
918
  pw->p[0].FIELD = pw->p[pw->n - 1].FIELD;
919
  pw->p[0].set = pw->p[pw->n - 1].set;
920
  pw->n = 1;
921
922
  space = isl_set_get_space(context);
923
  pw->p[0].FIELD = fn_el(pw->p[0].FIELD, context);
924
  context = isl_set_universe(space);
925
  isl_set_free(pw->p[0].set);
926
  pw->p[0].set = context;
927
928
  if (!pw->p[0].FIELD || !pw->p[0].set)
929
    return FN(PW,free)(pw);
930
931
  return pw;
932
}
isl_aff.c:isl_pw_aff_gist_last
Line
Count
Source
910
6.00k
{
911
6.00k
  int i;
912
6.00k
  isl_space *space;
913
6.00k
914
6.00k
  for (i = 0; 
i < pw->n - 16.00k
;
++i0
)
{0
915
0
    isl_set_free(pw->p[i].set);
916
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
917
6.00k
  }
918
6.00k
  pw->p[0].
FIELD6.00k
= pw->p[pw->n - 1].
FIELD6.00k
;
919
6.00k
  pw->p[0].set = pw->p[pw->n - 1].set;
920
6.00k
  pw->n = 1;
921
6.00k
922
6.00k
  space = isl_set_get_space(context);
923
6.00k
  pw->p[0].
FIELD6.00k
= fn_el(pw->p[0].
FIELD6.00k
, context);
924
6.00k
  context = isl_set_universe(space);
925
6.00k
  isl_set_free(pw->p[0].set);
926
6.00k
  pw->p[0].set = context;
927
6.00k
928
6.00k
  if (
!pw->p[0].6.00k
FIELD6.00k
||
!pw->p[0].set6.00k
)
929
0
    
return 0
FN0
(PW,free)(pw);
930
6.00k
931
6.00k
  return pw;
932
6.00k
}
isl_aff.c:isl_pw_multi_aff_gist_last
Line
Count
Source
910
1.46k
{
911
1.46k
  int i;
912
1.46k
  isl_space *space;
913
1.46k
914
1.46k
  for (i = 0; 
i < pw->n - 11.46k
;
++i0
)
{0
915
0
    isl_set_free(pw->p[i].set);
916
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
917
1.46k
  }
918
1.46k
  pw->p[0].
FIELD1.46k
= pw->p[pw->n - 1].
FIELD1.46k
;
919
1.46k
  pw->p[0].set = pw->p[pw->n - 1].set;
920
1.46k
  pw->n = 1;
921
1.46k
922
1.46k
  space = isl_set_get_space(context);
923
1.46k
  pw->p[0].
FIELD1.46k
= fn_el(pw->p[0].
FIELD1.46k
, context);
924
1.46k
  context = isl_set_universe(space);
925
1.46k
  isl_set_free(pw->p[0].set);
926
1.46k
  pw->p[0].set = context;
927
1.46k
928
1.46k
  if (
!pw->p[0].1.46k
FIELD1.46k
||
!pw->p[0].set1.46k
)
929
0
    
return 0
FN0
(PW,free)(pw);
930
1.46k
931
1.46k
  return pw;
932
1.46k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_last
isl_polynomial.c:isl_pw_qpolynomial_gist_last
Line
Count
Source
910
1
{
911
1
  int i;
912
1
  isl_space *space;
913
1
914
1
  for (i = 0; 
i < pw->n - 11
;
++i0
)
{0
915
0
    isl_set_free(pw->p[i].set);
916
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
917
1
  }
918
1
  pw->p[0].
FIELD1
= pw->p[pw->n - 1].
FIELD1
;
919
1
  pw->p[0].set = pw->p[pw->n - 1].set;
920
1
  pw->n = 1;
921
1
922
1
  space = isl_set_get_space(context);
923
1
  pw->p[0].
FIELD1
= fn_el(pw->p[0].
FIELD1
, context);
924
1
  context = isl_set_universe(space);
925
1
  isl_set_free(pw->p[0].set);
926
1
  pw->p[0].set = context;
927
1
928
1
  if (
!pw->p[0].1
FIELD1
||
!pw->p[0].set1
)
929
0
    
return 0
FN0
(PW,free)(pw);
930
1
931
1
  return pw;
932
1
}
933
934
/* Compute the gist of "pw" with respect to the domain constraints
935
 * of "context".  Call "fn_el" to compute the gist of the elements
936
 * and "fn_dom" to compute the gist of the domains.
937
 *
938
 * If the piecewise expression is empty or the context is the universe,
939
 * then nothing can be simplified.
940
 */
941
static __isl_give PW *FN(PW,gist_aligned)(__isl_take PW *pw,
942
  __isl_take isl_set *context,
943
  __isl_give EL *(*fn_el)(__isl_take EL *el,
944
            __isl_take isl_set *set),
945
  __isl_give isl_set *(*fn_dom)(__isl_take isl_set *set,
946
            __isl_take isl_basic_set *bset))
947
{
948
  int i;
949
  int is_universe;
950
  isl_bool aligned;
951
  isl_basic_set *hull = NULL;
952
953
  if (!pw || !context)
954
    goto error;
955
956
  if (pw->n == 0) {
957
    isl_set_free(context);
958
    return pw;
959
  }
960
961
  is_universe = isl_set_plain_is_universe(context);
962
  if (is_universe < 0)
963
    goto error;
964
  if (is_universe) {
965
    isl_set_free(context);
966
    return pw;
967
  }
968
969
  aligned = isl_set_space_has_equal_params(context, pw->dim);
970
  if (aligned < 0)
971
    goto error;
972
  if (!aligned) {
973
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
974
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
975
  }
976
977
  pw = FN(PW,cow)(pw);
978
  if (!pw)
979
    goto error;
980
981
  if (pw->n == 1) {
982
    int equal;
983
984
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
985
    if (equal < 0)
986
      goto error;
987
    if (equal)
988
      return FN(PW,gist_last)(pw, context, fn_el);
989
  }
990
991
  context = isl_set_compute_divs(context);
992
  hull = isl_set_simple_hull(isl_set_copy(context));
993
994
  for (i = pw->n - 1; i >= 0; --i) {
995
    isl_set *set_i;
996
    int empty;
997
998
    if (i == pw->n - 1) {
999
      int equal;
1000
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1001
      if (equal < 0)
1002
        goto error;
1003
      if (equal) {
1004
        isl_basic_set_free(hull);
1005
        return FN(PW,gist_last)(pw, context, fn_el);
1006
      }
1007
    }
1008
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1009
             isl_set_copy(context));
1010
    empty = isl_set_plain_is_empty(set_i);
1011
    pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
1012
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1013
    if (empty < 0 || !pw->p[i].FIELD || !pw->p[i].set)
1014
      goto error;
1015
    if (empty) {
1016
      isl_set_free(pw->p[i].set);
1017
      FN(EL,free)(pw->p[i].FIELD);
1018
      if (i != pw->n - 1)
1019
        pw->p[i] = pw->p[pw->n - 1];
1020
      pw->n--;
1021
    }
1022
  }
1023
1024
  isl_basic_set_free(hull);
1025
  isl_set_free(context);
1026
1027
  return pw;
1028
error:
1029
  FN(PW,free)(pw);
1030
  isl_basic_set_free(hull);
1031
  isl_set_free(context);
1032
  return NULL;
1033
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_aligned
isl_polynomial.c:isl_pw_qpolynomial_gist_aligned
Line
Count
Source
947
4
{
948
4
  int i;
949
4
  int is_universe;
950
4
  isl_bool aligned;
951
4
  isl_basic_set *hull = NULL;
952
4
953
4
  if (
!pw || 4
!context4
)
954
0
    goto error;
955
4
956
4
  
if (4
pw->n == 04
)
{0
957
0
    isl_set_free(context);
958
0
    return pw;
959
4
  }
960
4
961
4
  is_universe = isl_set_plain_is_universe(context);
962
4
  if (is_universe < 0)
963
0
    goto error;
964
4
  
if (4
is_universe4
)
{0
965
0
    isl_set_free(context);
966
0
    return pw;
967
4
  }
968
4
969
4
  aligned = isl_set_space_has_equal_params(context, pw->dim);
970
4
  if (aligned < 0)
971
0
    goto error;
972
4
  
if (4
!aligned4
)
{0
973
0
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
974
0
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
975
4
  }
976
4
977
4
  pw = FN(PW,cow)(pw);
978
4
  if (!pw)
979
0
    goto error;
980
4
981
4
  
if (4
pw->n == 14
)
{4
982
4
    int equal;
983
4
984
4
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
985
4
    if (equal < 0)
986
0
      goto error;
987
4
    
if (4
equal4
)
988
1
      
return 1
FN1
(PW,gist_last)(pw, context, fn_el);
989
4
  }
990
4
991
4
  context = isl_set_compute_divs(context);
992
3
  hull = isl_set_simple_hull(isl_set_copy(context));
993
3
994
6
  for (i = pw->n - 1; 
i >= 06
;
--i3
)
{3
995
3
    isl_set *set_i;
996
3
    int empty;
997
3
998
3
    if (
i == pw->n - 13
)
{3
999
3
      int equal;
1000
3
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1001
3
      if (equal < 0)
1002
0
        goto error;
1003
3
      
if (3
equal3
)
{0
1004
0
        isl_basic_set_free(hull);
1005
0
        return FN(PW,gist_last)(pw, context, fn_el);
1006
3
      }
1007
3
    }
1008
3
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1009
3
             isl_set_copy(context));
1010
3
    empty = isl_set_plain_is_empty(set_i);
1011
3
    pw->p[i].
FIELD3
= fn_el(pw->p[i].
FIELD3
, set_i);
1012
3
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1013
3
    if (
empty < 0 || 3
!pw->p[i].3
FIELD3
||
!pw->p[i].set3
)
1014
0
      goto error;
1015
3
    
if (3
empty3
)
{0
1016
0
      isl_set_free(pw->p[i].set);
1017
0
      
FN0
(EL,free)(pw->p[i].
FIELD0
);
1018
0
      if (i != pw->n - 1)
1019
0
        pw->p[i] = pw->p[pw->n - 1];
1020
0
      pw->n--;
1021
3
    }
1022
3
  }
1023
3
1024
3
  isl_basic_set_free(hull);
1025
3
  isl_set_free(context);
1026
3
1027
3
  return pw;
1028
3
error:
1029
0
  FN(PW,free)(pw);
1030
0
  isl_basic_set_free(hull);
1031
0
  isl_set_free(context);
1032
3
  return NULL;
1033
4
}
isl_aff.c:isl_pw_aff_gist_aligned
Line
Count
Source
947
8.92k
{
948
8.92k
  int i;
949
8.92k
  int is_universe;
950
8.92k
  isl_bool aligned;
951
8.92k
  isl_basic_set *hull = NULL;
952
8.92k
953
8.92k
  if (
!pw || 8.92k
!context8.92k
)
954
0
    goto error;
955
8.92k
956
8.92k
  
if (8.92k
pw->n == 08.92k
)
{0
957
0
    isl_set_free(context);
958
0
    return pw;
959
8.92k
  }
960
8.92k
961
8.92k
  is_universe = isl_set_plain_is_universe(context);
962
8.92k
  if (is_universe < 0)
963
0
    goto error;
964
8.92k
  
if (8.92k
is_universe8.92k
)
{1.03k
965
1.03k
    isl_set_free(context);
966
1.03k
    return pw;
967
8.92k
  }
968
8.92k
969
8.92k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
970
7.88k
  if (aligned < 0)
971
0
    goto error;
972
7.88k
  
if (7.88k
!aligned7.88k
)
{0
973
0
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
974
0
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
975
7.88k
  }
976
7.88k
977
7.88k
  pw = FN(PW,cow)(pw);
978
7.88k
  if (!pw)
979
0
    goto error;
980
7.88k
981
7.88k
  
if (7.88k
pw->n == 17.88k
)
{7.85k
982
7.85k
    int equal;
983
7.85k
984
7.85k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
985
7.85k
    if (equal < 0)
986
0
      goto error;
987
7.85k
    
if (7.85k
equal7.85k
)
988
6.00k
      
return 6.00k
FN6.00k
(PW,gist_last)(pw, context, fn_el);
989
7.88k
  }
990
7.88k
991
7.88k
  context = isl_set_compute_divs(context);
992
1.88k
  hull = isl_set_simple_hull(isl_set_copy(context));
993
1.88k
994
3.81k
  for (i = pw->n - 1; 
i >= 03.81k
;
--i1.92k
)
{1.92k
995
1.92k
    isl_set *set_i;
996
1.92k
    int empty;
997
1.92k
998
1.92k
    if (
i == pw->n - 11.92k
)
{1.88k
999
1.88k
      int equal;
1000
1.88k
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1001
1.88k
      if (equal < 0)
1002
0
        goto error;
1003
1.88k
      
if (1.88k
equal1.88k
)
{0
1004
0
        isl_basic_set_free(hull);
1005
0
        return FN(PW,gist_last)(pw, context, fn_el);
1006
1.88k
      }
1007
1.92k
    }
1008
1.92k
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1009
1.92k
             isl_set_copy(context));
1010
1.92k
    empty = isl_set_plain_is_empty(set_i);
1011
1.92k
    pw->p[i].
FIELD1.92k
= fn_el(pw->p[i].
FIELD1.92k
, set_i);
1012
1.92k
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1013
1.92k
    if (
empty < 0 || 1.92k
!pw->p[i].1.92k
FIELD1.92k
||
!pw->p[i].set1.92k
)
1014
0
      goto error;
1015
1.92k
    
if (1.92k
empty1.92k
)
{0
1016
0
      isl_set_free(pw->p[i].set);
1017
0
      
FN0
(EL,free)(pw->p[i].
FIELD0
);
1018
0
      if (i != pw->n - 1)
1019
0
        pw->p[i] = pw->p[pw->n - 1];
1020
0
      pw->n--;
1021
1.92k
    }
1022
1.92k
  }
1023
1.88k
1024
1.88k
  isl_basic_set_free(hull);
1025
1.88k
  isl_set_free(context);
1026
1.88k
1027
1.88k
  return pw;
1028
1.88k
error:
1029
0
  FN(PW,free)(pw);
1030
0
  isl_basic_set_free(hull);
1031
0
  isl_set_free(context);
1032
1.88k
  return NULL;
1033
8.92k
}
isl_aff.c:isl_pw_multi_aff_gist_aligned
Line
Count
Source
947
1.62k
{
948
1.62k
  int i;
949
1.62k
  int is_universe;
950
1.62k
  isl_bool aligned;
951
1.62k
  isl_basic_set *hull = NULL;
952
1.62k
953
1.62k
  if (
!pw || 1.62k
!context1.62k
)
954
0
    goto error;
955
1.62k
956
1.62k
  
if (1.62k
pw->n == 01.62k
)
{0
957
0
    isl_set_free(context);
958
0
    return pw;
959
1.62k
  }
960
1.62k
961
1.62k
  is_universe = isl_set_plain_is_universe(context);
962
1.62k
  if (is_universe < 0)
963
0
    goto error;
964
1.62k
  
if (1.62k
is_universe1.62k
)
{68
965
68
    isl_set_free(context);
966
68
    return pw;
967
1.62k
  }
968
1.62k
969
1.62k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
970
1.55k
  if (aligned < 0)
971
0
    goto error;
972
1.55k
  
if (1.55k
!aligned1.55k
)
{0
973
0
    pw = FN(PW,align_params)(pw, isl_set_get_space(context));
974
0
    context = isl_set_align_params(context, FN(PW,get_space)(pw));
975
1.55k
  }
976
1.55k
977
1.55k
  pw = FN(PW,cow)(pw);
978
1.55k
  if (!pw)
979
0
    goto error;
980
1.55k
981
1.55k
  
if (1.55k
pw->n == 11.55k
)
{1.55k
982
1.55k
    int equal;
983
1.55k
984
1.55k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
985
1.55k
    if (equal < 0)
986
0
      goto error;
987
1.55k
    
if (1.55k
equal1.55k
)
988
1.46k
      
return 1.46k
FN1.46k
(PW,gist_last)(pw, context, fn_el);
989
1.55k
  }
990
1.55k
991
1.55k
  context = isl_set_compute_divs(context);
992
89
  hull = isl_set_simple_hull(isl_set_copy(context));
993
89
994
178
  for (i = pw->n - 1; 
i >= 0178
;
--i89
)
{89
995
89
    isl_set *set_i;
996
89
    int empty;
997
89
998
89
    if (
i == pw->n - 189
)
{89
999
89
      int equal;
1000
89
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1001
89
      if (equal < 0)
1002
0
        goto error;
1003
89
      
if (89
equal89
)
{0
1004
0
        isl_basic_set_free(hull);
1005
0
        return FN(PW,gist_last)(pw, context, fn_el);
1006
89
      }
1007
89
    }
1008
89
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1009
89
             isl_set_copy(context));
1010
89
    empty = isl_set_plain_is_empty(set_i);
1011
89
    pw->p[i].
FIELD89
= fn_el(pw->p[i].
FIELD89
, set_i);
1012
89
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1013
89
    if (
empty < 0 || 89
!pw->p[i].89
FIELD89
||
!pw->p[i].set89
)
1014
0
      goto error;
1015
89
    
if (89
empty89
)
{0
1016
0
      isl_set_free(pw->p[i].set);
1017
0
      
FN0
(EL,free)(pw->p[i].
FIELD0
);
1018
0
      if (i != pw->n - 1)
1019
0
        pw->p[i] = pw->p[pw->n - 1];
1020
0
      pw->n--;
1021
89
    }
1022
89
  }
1023
89
1024
89
  isl_basic_set_free(hull);
1025
89
  isl_set_free(context);
1026
89
1027
89
  return pw;
1028
89
error:
1029
0
  FN(PW,free)(pw);
1030
0
  isl_basic_set_free(hull);
1031
0
  isl_set_free(context);
1032
89
  return NULL;
1033
1.62k
}
1034
1035
static __isl_give PW *FN(PW,gist_domain_aligned)(__isl_take PW *pw,
1036
  __isl_take isl_set *set)
1037
{
1038
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist),
1039
          &isl_set_gist_basic_set);
1040
}
isl_polynomial.c:isl_pw_qpolynomial_gist_domain_aligned
Line
Count
Source
1037
4
{
1038
4
  return 
FN4
(PW,gist_aligned)(pw, set, &
FN4
(EL,gist),
1039
4
          &isl_set_gist_basic_set);
1040
4
}
isl_aff.c:isl_pw_multi_aff_gist_domain_aligned
Line
Count
Source
1037
1.62k
{
1038
1.62k
  return 
FN1.62k
(PW,gist_aligned)(pw, set, &
FN1.62k
(EL,gist),
1039
1.62k
          &isl_set_gist_basic_set);
1040
1.62k
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_domain_aligned
isl_aff.c:isl_pw_aff_gist_domain_aligned
Line
Count
Source
1037
8.92k
{
1038
8.92k
  return 
FN8.92k
(PW,gist_aligned)(pw, set, &
FN8.92k
(EL,gist),
1039
8.92k
          &isl_set_gist_basic_set);
1040
8.92k
}
1041
1042
__isl_give PW *FN(PW,gist)(__isl_take PW *pw, __isl_take isl_set *context)
1043
{
1044
  return FN(PW,align_params_pw_set_and)(pw, context,
1045
            &FN(PW,gist_domain_aligned));
1046
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_gist
isl_pw_qpolynomial_gist
Line
Count
Source
1043
4
{
1044
4
  return FN(PW,align_params_pw_set_and)(pw, context,
1045
4
            &FN(PW,gist_domain_aligned));
1046
4
}
isl_pw_multi_aff_gist
Line
Count
Source
1043
1.62k
{
1044
1.62k
  return FN(PW,align_params_pw_set_and)(pw, context,
1045
1.62k
            &FN(PW,gist_domain_aligned));
1046
1.62k
}
isl_pw_aff_gist
Line
Count
Source
1043
8.92k
{
1044
8.92k
  return FN(PW,align_params_pw_set_and)(pw, context,
1045
8.92k
            &FN(PW,gist_domain_aligned));
1046
8.92k
}
1047
1048
static __isl_give PW *FN(PW,gist_params_aligned)(__isl_take PW *pw,
1049
  __isl_take isl_set *set)
1050
{
1051
  return FN(PW,gist_aligned)(pw, set, &FN(EL,gist_params),
1052
          &isl_set_gist_params_basic_set);
1053
}
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_gist_params_aligned
Unexecuted instantiation: isl_aff.c:isl_pw_multi_aff_gist_params_aligned
Unexecuted instantiation: isl_aff.c:isl_pw_aff_gist_params_aligned
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_gist_params_aligned
1054
1055
__isl_give PW *FN(PW,gist_params)(__isl_take PW *pw,
1056
  __isl_take isl_set *context)
1057
{
1058
  return FN(PW,align_params_pw_set_and)(pw, context,
1059
            &FN(PW,gist_params_aligned));
1060
}
Unexecuted instantiation: isl_pw_aff_gist_params
Unexecuted instantiation: isl_pw_qpolynomial_gist_params
Unexecuted instantiation: isl_pw_qpolynomial_fold_gist_params
Unexecuted instantiation: isl_pw_multi_aff_gist_params
1061
1062
/* Return -1 if the piece "p1" should be sorted before "p2"
1063
 * and 1 if it should be sorted after "p2".
1064
 * Return 0 if they do not need to be sorted in a specific order.
1065
 *
1066
 * The two pieces are compared on the basis of their function value expressions.
1067
 */
1068
static int FN(PW,sort_field_cmp)(const void *p1, const void *p2, void *arg)
1069
{
1070
  struct FN(PW,piece) const *pc1 = p1;
1071
  struct FN(PW,piece) const *pc2 = p2;
1072
1073
  return FN(EL,plain_cmp)(pc1->FIELD, pc2->FIELD);
1074
}
isl_polynomial.c:isl_pw_qpolynomial_sort_field_cmp
Line
Count
Source
1069
1
{
1070
1
  struct FN(PW,piece) const *pc1 = p1;
1071
1
  struct FN(PW,piece) const *pc2 = p2;
1072
1
1073
1
  return 
FN1
(EL,plain_cmp)(pc1->
FIELD1
, pc2->
FIELD1
);
1074
1
}
isl_aff.c:isl_pw_aff_sort_field_cmp
Line
Count
Source
1069
551
{
1070
551
  struct FN(PW,piece) const *pc1 = p1;
1071
551
  struct FN(PW,piece) const *pc2 = p2;
1072
551
1073
551
  return 
FN551
(EL,plain_cmp)(pc1->
FIELD551
, pc2->
FIELD551
);
1074
551
}
Unexecuted instantiation: isl_fold.c:isl_pw_qpolynomial_fold_sort_field_cmp
isl_aff.c:isl_pw_multi_aff_sort_field_cmp
Line
Count
Source
1069
1.16k
{
1070
1.16k
  struct FN(PW,piece) const *pc1 = p1;
1071
1.16k
  struct FN(PW,piece) const *pc2 = p2;
1072
1.16k
1073
1.16k
  return 
FN1.16k
(EL,plain_cmp)(pc1->
FIELD1.16k
, pc2->
FIELD1.16k
);
1074
1.16k
}
1075
1076
/* Sort the pieces of "pw" according to their function value
1077
 * expressions and then combine pairs of adjacent pieces with
1078
 * the same such expression.
1079
 *
1080
 * The sorting is performed in place because it does not
1081
 * change the meaning of "pw", but care needs to be
1082
 * taken not to change any possible other copies of "pw"
1083
 * in case anything goes wrong.
1084
 */
1085
__isl_give PW *FN(PW,sort)(__isl_take PW *pw)
1086
{
1087
  int i, j;
1088
  isl_set *set;
1089
1090
  if (!pw)
1091
    return NULL;
1092
  if (pw->n <= 1)
1093
    return pw;
1094
  if (isl_sort(pw->p, pw->n, sizeof(pw->p[0]),
1095
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
    return FN(PW,free)(pw);
1097
  for (i = pw->n - 1; i >= 1; --i) {
1098
    if (!FN(EL,plain_is_equal)(pw->p[i - 1].FIELD, pw->p[i].FIELD))
1099
      continue;
1100
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1101
            isl_set_copy(pw->p[i].set));
1102
    if (!set)
1103
      return FN(PW,free)(pw);
1104
    isl_set_free(pw->p[i].set);
1105
    FN(EL,free)(pw->p[i].FIELD);
1106
    isl_set_free(pw->p[i - 1].set);
1107
    pw->p[i - 1].set = set;
1108
    for (j = i + 1; j < pw->n; ++j)
1109
      pw->p[j - 1] = pw->p[j];
1110
    pw->n--;
1111
  }
1112
1113
  return pw;
1114
}
isl_pw_multi_aff_sort
Line
Count
Source
1086
3.35k
{
1087
3.35k
  int i, j;
1088
3.35k
  isl_set *set;
1089
3.35k
1090
3.35k
  if (!pw)
1091
0
    return NULL;
1092
3.35k
  
if (3.35k
pw->n <= 13.35k
)
1093
2.90k
    return pw;
1094
447
  
if (447
isl_sort(pw->p, pw->n, sizeof(pw->p[0]),447
1095
447
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
0
    
return 0
FN0
(PW,free)(pw);
1097
1.27k
  
for (i = pw->n - 1; 447
i >= 11.27k
;
--i830
)
{830
1098
830
    if (
!830
FN830
(EL,plain_is_equal)(pw->p[i - 1].
FIELD830
, pw->p[i].
FIELD830
))
1099
782
      continue;
1100
830
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1101
48
            isl_set_copy(pw->p[i].set));
1102
48
    if (!set)
1103
0
      
return 0
FN0
(PW,free)(pw);
1104
48
    isl_set_free(pw->p[i].set);
1105
48
    
FN48
(EL,free)(pw->p[i].
FIELD48
);
1106
48
    isl_set_free(pw->p[i - 1].set);
1107
48
    pw->p[i - 1].set = set;
1108
49
    for (j = i + 1; 
j < pw->n49
;
++j1
)
1109
1
      pw->p[j - 1] = pw->p[j];
1110
48
    pw->n--;
1111
447
  }
1112
447
1113
447
  return pw;
1114
3.35k
}
isl_pw_qpolynomial_sort
Line
Count
Source
1086
7
{
1087
7
  int i, j;
1088
7
  isl_set *set;
1089
7
1090
7
  if (!pw)
1091
0
    return NULL;
1092
7
  
if (7
pw->n <= 17
)
1093
6
    return pw;
1094
1
  
if (1
isl_sort(pw->p, pw->n, sizeof(pw->p[0]),1
1095
1
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
0
    
return 0
FN0
(PW,free)(pw);
1097
2
  
for (i = pw->n - 1; 1
i >= 12
;
--i1
)
{1
1098
1
    if (
!1
FN1
(EL,plain_is_equal)(pw->p[i - 1].
FIELD1
, pw->p[i].
FIELD1
))
1099
1
      continue;
1100
1
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1101
0
            isl_set_copy(pw->p[i].set));
1102
0
    if (!set)
1103
0
      
return 0
FN0
(PW,free)(pw);
1104
0
    isl_set_free(pw->p[i].set);
1105
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
1106
0
    isl_set_free(pw->p[i - 1].set);
1107
0
    pw->p[i - 1].set = set;
1108
0
    for (j = i + 1; 
j < pw->n0
;
++j0
)
1109
0
      pw->p[j - 1] = pw->p[j];
1110
0
    pw->n--;
1111
1
  }
1112
1
1113
1
  return pw;
1114
7
}
isl_pw_aff_sort
Line
Count
Source
1086
21.2k
{
1087
21.2k
  int i, j;
1088
21.2k
  isl_set *set;
1089
21.2k
1090
21.2k
  if (!pw)
1091
1
    return NULL;
1092
21.2k
  
if (21.2k
pw->n <= 121.2k
)
1093
20.9k
    return pw;
1094
293
  
if (293
isl_sort(pw->p, pw->n, sizeof(pw->p[0]),293
1095
293
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
0
    
return 0
FN0
(PW,free)(pw);
1097
713
  
for (i = pw->n - 1; 293
i >= 1713
;
--i420
)
{420
1098
420
    if (
!420
FN420
(EL,plain_is_equal)(pw->p[i - 1].
FIELD420
, pw->p[i].
FIELD420
))
1099
413
      continue;
1100
420
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1101
7
            isl_set_copy(pw->p[i].set));
1102
7
    if (!set)
1103
0
      
return 0
FN0
(PW,free)(pw);
1104
7
    isl_set_free(pw->p[i].set);
1105
7
    
FN7
(EL,free)(pw->p[i].
FIELD7
);
1106
7
    isl_set_free(pw->p[i - 1].set);
1107
7
    pw->p[i - 1].set = set;
1108
19
    for (j = i + 1; 
j < pw->n19
;
++j12
)
1109
12
      pw->p[j - 1] = pw->p[j];
1110
7
    pw->n--;
1111
293
  }
1112
293
1113
293
  return pw;
1114
21.2k
}
isl_pw_qpolynomial_fold_sort
Line
Count
Source
1086
2
{
1087
2
  int i, j;
1088
2
  isl_set *set;
1089
2
1090
2
  if (!pw)
1091
0
    return NULL;
1092
2
  
if (2
pw->n <= 12
)
1093
2
    return pw;
1094
0
  
if (0
isl_sort(pw->p, pw->n, sizeof(pw->p[0]),0
1095
0
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
0
    
return 0
FN0
(PW,free)(pw);
1097
0
  
for (i = pw->n - 1; 0
i >= 10
;
--i0
)
{0
1098
0
    if (
!0
FN0
(EL,plain_is_equal)(pw->p[i - 1].
FIELD0
, pw->p[i].
FIELD0
))
1099
0
      continue;
1100
0
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1101
0
            isl_set_copy(pw->p[i].set));
1102
0
    if (!set)
1103
0
      
return 0
FN0
(PW,free)(pw);
1104
0
    isl_set_free(pw->p[i].set);
1105
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
1106
0
    isl_set_free(pw->p[i - 1].set);
1107
0
    pw->p[i - 1].set = set;
1108
0
    for (j = i + 1; 
j < pw->n0
;
++j0
)
1109
0
      pw->p[j - 1] = pw->p[j];
1110
0
    pw->n--;
1111
0
  }
1112
0
1113
0
  return pw;
1114
2
}
1115
1116
/* Coalesce the domains of "pw".
1117
 *
1118
 * Prior to the actual coalescing, first sort the pieces such that
1119
 * pieces with the same function value expression are combined
1120
 * into a single piece, the combined domain of which can then
1121
 * be coalesced.
1122
 */
1123
__isl_give PW *FN(PW,coalesce)(__isl_take PW *pw)
1124
{
1125
  int i;
1126
1127
  pw = FN(PW,sort)(pw);
1128
  if (!pw)
1129
    return NULL;
1130
1131
  for (i = 0; i < pw->n; ++i) {
1132
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1133
    if (!pw->p[i].set)
1134
      goto error;
1135
  }
1136
1137
  return pw;
1138
error:
1139
  FN(PW,free)(pw);
1140
  return NULL;
1141
}
isl_pw_aff_coalesce
Line
Count
Source
1124
20.3k
{
1125
20.3k
  int i;
1126
20.3k
1127
20.3k
  pw = FN(PW,sort)(pw);
1128
20.3k
  if (!pw)
1129
1
    return NULL;
1130
20.3k
1131
41.1k
  
for (i = 0; 20.3k
i < pw->n41.1k
;
++i20.7k
)
{20.7k
1132
20.7k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1133
20.7k
    if (!pw->p[i].set)
1134
0
      goto error;
1135
20.7k
  }
1136
20.3k
1137
20.3k
  return pw;
1138
20.3k
error:
1139
0
  FN(PW,free)(pw);
1140
20.3k
  return NULL;
1141
20.3k
}
isl_pw_multi_aff_coalesce
Line
Count
Source
1124
988
{
1125
988
  int i;
1126
988
1127
988
  pw = FN(PW,sort)(pw);
1128
988
  if (!pw)
1129
0
    return NULL;
1130
988
1131
2.04k
  
for (i = 0; 988
i < pw->n2.04k
;
++i1.05k
)
{1.05k
1132
1.05k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1133
1.05k
    if (!pw->p[i].set)
1134
0
      goto error;
1135
1.05k
  }
1136
988
1137
988
  return pw;
1138
988
error:
1139
0
  FN(PW,free)(pw);
1140
988
  return NULL;
1141
988
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_coalesce
isl_pw_qpolynomial_coalesce
Line
Count
Source
1124
1
{
1125
1
  int i;
1126
1
1127
1
  pw = FN(PW,sort)(pw);
1128
1
  if (!pw)
1129
0
    return NULL;
1130
1
1131
3
  
for (i = 0; 1
i < pw->n3
;
++i2
)
{2
1132
2
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1133
2
    if (!pw->p[i].set)
1134
0
      goto error;
1135
2
  }
1136
1
1137
1
  return pw;
1138
1
error:
1139
0
  FN(PW,free)(pw);
1140
1
  return NULL;
1141
1
}
1142
1143
isl_ctx *FN(PW,get_ctx)(__isl_keep PW *pw)
1144
{
1145
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1146
}
isl_pw_multi_aff_get_ctx
Line
Count
Source
1144
2.41k
{
1145
2.41k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1146
2.41k
}
isl_pw_qpolynomial_get_ctx
Line
Count
Source
1144
1
{
1145
1
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1146
1
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_get_ctx
isl_pw_aff_get_ctx
Line
Count
Source
1144
21.9k
{
1145
21.9k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1146
21.9k
}
1147
1148
#ifndef NO_INVOLVES_DIMS
1149
isl_bool FN(PW,involves_dims)(__isl_keep PW *pw, enum isl_dim_type type,
1150
  unsigned first, unsigned n)
1151
{
1152
  int i;
1153
  enum isl_dim_type set_type;
1154
1155
  if (!pw)
1156
    return isl_bool_error;
1157
  if (pw->n == 0 || n == 0)
1158
    return isl_bool_false;
1159
1160
  set_type = type == isl_dim_in ? isl_dim_set : type;
1161
1162
  for (i = 0; i < pw->n; ++i) {
1163
    isl_bool involves = FN(EL,involves_dims)(pw->p[i].FIELD,
1164
              type, first, n);
1165
    if (involves < 0 || involves)
1166
      return involves;
1167
    involves = isl_set_involves_dims(pw->p[i].set,
1168
              set_type, first, n);
1169
    if (involves < 0 || involves)
1170
      return involves;
1171
  }
1172
  return isl_bool_false;
1173
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_involves_dims
Unexecuted instantiation: isl_pw_qpolynomial_involves_dims
isl_pw_aff_involves_dims
Line
Count
Source
1151
91
{
1152
91
  int i;
1153
91
  enum isl_dim_type set_type;
1154
91
1155
91
  if (!pw)
1156
0
    return isl_bool_error;
1157
91
  
if (91
pw->n == 0 || 91
n == 091
)
1158
0
    return isl_bool_false;
1159
91
1160
91
  
set_type = type == isl_dim_in ? 91
isl_dim_set91
:
type0
;
1161
91
1162
182
  for (i = 0; 
i < pw->n182
;
++i91
)
{91
1163
91
    isl_bool involves = 
FN91
(EL,involves_dims)(pw->p[i].
FIELD91
,
1164
91
              type, first, n);
1165
91
    if (
involves < 0 || 91
involves91
)
1166
0
      return involves;
1167
91
    involves = isl_set_involves_dims(pw->p[i].set,
1168
91
              set_type, first, n);
1169
91
    if (
involves < 0 || 91
involves91
)
1170
0
      return involves;
1171
91
  }
1172
91
  return isl_bool_false;
1173
91
}
1174
#endif
1175
1176
__isl_give PW *FN(PW,set_dim_name)(__isl_take PW *pw,
1177
  enum isl_dim_type type, unsigned pos, const char *s)
1178
{
1179
  int i;
1180
  enum isl_dim_type set_type;
1181
1182
  pw = FN(PW,cow)(pw);
1183
  if (!pw)
1184
    return NULL;
1185
1186
  set_type = type == isl_dim_in ? isl_dim_set : type;
1187
1188
  pw->dim = isl_space_set_dim_name(pw->dim, type, pos, s);
1189
  if (!pw->dim)
1190
    goto error;
1191
1192
  for (i = 0; i < pw->n; ++i) {
1193
    pw->p[i].set = isl_set_set_dim_name(pw->p[i].set,
1194
              set_type, pos, s);
1195
    if (!pw->p[i].set)
1196
      goto error;
1197
    pw->p[i].FIELD = FN(EL,set_dim_name)(pw->p[i].FIELD, type, pos, s);
1198
    if (!pw->p[i].FIELD)
1199
      goto error;
1200
  }
1201
1202
  return pw;
1203
error:
1204
  FN(PW,free)(pw);
1205
  return NULL;
1206
}
Unexecuted instantiation: isl_pw_multi_aff_set_dim_name
Unexecuted instantiation: isl_pw_aff_set_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_set_dim_name
Unexecuted instantiation: isl_pw_qpolynomial_fold_set_dim_name
1207
1208
#ifndef NO_DROP_DIMS
1209
__isl_give PW *FN(PW,drop_dims)(__isl_take PW *pw,
1210
  enum isl_dim_type type, unsigned first, unsigned n)
1211
{
1212
  int i;
1213
  enum isl_dim_type set_type;
1214
1215
  if (!pw)
1216
    return NULL;
1217
  if (n == 0 && !isl_space_get_tuple_name(pw->dim, type))
1218
    return pw;
1219
1220
  set_type = type == isl_dim_in ? isl_dim_set : type;
1221
1222
  pw = FN(PW,cow)(pw);
1223
  if (!pw)
1224
    return NULL;
1225
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1226
  if (!pw->dim)
1227
    goto error;
1228
  for (i = 0; i < pw->n; ++i) {
1229
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1230
    if (!pw->p[i].FIELD)
1231
      goto error;
1232
    if (type == isl_dim_out)
1233
      continue;
1234
    pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
1235
    if (!pw->p[i].set)
1236
      goto error;
1237
  }
1238
1239
  return pw;
1240
error:
1241
  FN(PW,free)(pw);
1242
  return NULL;
1243
}
Unexecuted instantiation: isl_pw_qpolynomial_drop_dims
isl_pw_multi_aff_drop_dims
Line
Count
Source
1211
529
{
1212
529
  int i;
1213
529
  enum isl_dim_type set_type;
1214
529
1215
529
  if (!pw)
1216
0
    return NULL;
1217
529
  
if (529
n == 0 && 529
!isl_space_get_tuple_name(pw->dim, type)0
)
1218
0
    return pw;
1219
529
1220
529
  
set_type = type == isl_dim_in ? 529
isl_dim_set0
:
type529
;
1221
529
1222
529
  pw = FN(PW,cow)(pw);
1223
529
  if (!pw)
1224
0
    return NULL;
1225
529
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1226
529
  if (!pw->dim)
1227
0
    goto error;
1228
1.05k
  
for (i = 0; 529
i < pw->n1.05k
;
++i529
)
{529
1229
529
    pw->p[i].
FIELD529
=
FN529
(EL,drop_dims)(pw->p[i].
FIELD529
, type, first, n);
1230
529
    if (
!pw->p[i].529
FIELD529
)
1231
0
      goto error;
1232
529
    
if (529
type == isl_dim_out529
)
1233
529
      continue;
1234
529
    pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
1235
0
    if (!pw->p[i].set)
1236
0
      goto error;
1237
529
  }
1238
529
1239
529
  return pw;
1240
529
error:
1241
0
  FN(PW,free)(pw);
1242
529
  return NULL;
1243
529
}
isl_pw_aff_drop_dims
Line
Count
Source
1211
91
{
1212
91
  int i;
1213
91
  enum isl_dim_type set_type;
1214
91
1215
91
  if (!pw)
1216
0
    return NULL;
1217
91
  
if (91
n == 0 && 91
!isl_space_get_tuple_name(pw->dim, type)0
)
1218
0
    return pw;
1219
91
1220
91
  
set_type = type == isl_dim_in ? 91
isl_dim_set91
:
type0
;
1221
91
1222
91
  pw = FN(PW,cow)(pw);
1223
91
  if (!pw)
1224
0
    return NULL;
1225
91
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1226
91
  if (!pw->dim)
1227
0
    goto error;
1228
182
  
for (i = 0; 91
i < pw->n182
;
++i91
)
{91
1229
91
    pw->p[i].
FIELD91
=
FN91
(EL,drop_dims)(pw->p[i].
FIELD91
, type, first, n);
1230
91
    if (
!pw->p[i].91
FIELD91
)
1231
0
      goto error;
1232
91
    
if (91
type == isl_dim_out91
)
1233
0
      continue;
1234
91
    pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
1235
91
    if (!pw->p[i].set)
1236
0
      goto error;
1237
91
  }
1238
91
1239
91
  return pw;
1240
91
error:
1241
0
  FN(PW,free)(pw);
1242
91
  return NULL;
1243
91
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_drop_dims
1244
1245
/* This function is very similar to drop_dims.
1246
 * The only difference is that the cells may still involve
1247
 * the specified dimensions.  They are removed using
1248
 * isl_set_project_out instead of isl_set_drop.
1249
 */
1250
__isl_give PW *FN(PW,project_out)(__isl_take PW *pw,
1251
  enum isl_dim_type type, unsigned first, unsigned n)
1252
{
1253
  int i;
1254
  enum isl_dim_type set_type;
1255
1256
  if (!pw)
1257
    return NULL;
1258
  if (n == 0 && !isl_space_get_tuple_name(pw->dim, type))
1259
    return pw;
1260
1261
  set_type = type == isl_dim_in ? isl_dim_set : type;
1262
1263
  pw = FN(PW,cow)(pw);
1264
  if (!pw)
1265
    return NULL;
1266
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1267
  if (!pw->dim)
1268
    goto error;
1269
  for (i = 0; i < pw->n; ++i) {
1270
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1271
              set_type, first, n);
1272
    if (!pw->p[i].set)
1273
      goto error;
1274
    pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
1275
    if (!pw->p[i].FIELD)
1276
      goto error;
1277
  }
1278
1279
  return pw;
1280
error:
1281
  FN(PW,free)(pw);
1282
  return NULL;
1283
}
isl_pw_qpolynomial_fold_project_out
Line
Count
Source
1252
1
{
1253
1
  int i;
1254
1
  enum isl_dim_type set_type;
1255
1
1256
1
  if (!pw)
1257
0
    return NULL;
1258
1
  
if (1
n == 0 && 1
!isl_space_get_tuple_name(pw->dim, type)1
)
1259
0
    return pw;
1260
1
1261
1
  
set_type = type == isl_dim_in ? 1
isl_dim_set1
:
type0
;
1262
1
1263
1
  pw = FN(PW,cow)(pw);
1264
1
  if (!pw)
1265
0
    return NULL;
1266
1
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1267
1
  if (!pw->dim)
1268
0
    goto error;
1269
2
  
for (i = 0; 1
i < pw->n2
;
++i1
)
{1
1270
1
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1271
1
              set_type, first, n);
1272
1
    if (!pw->p[i].set)
1273
0
      goto error;
1274
1
    
pw->p[i].1
FIELD1
=
FN1
(EL,drop_dims)(pw->p[i].
FIELD1
, type, first, n);
1275
1
    if (
!pw->p[i].1
FIELD1
)
1276
0
      goto error;
1277
1
  }
1278
1
1279
1
  return pw;
1280
1
error:
1281
0
  FN(PW,free)(pw);
1282
1
  return NULL;
1283
1
}
Unexecuted instantiation: isl_pw_aff_project_out
Unexecuted instantiation: isl_pw_qpolynomial_project_out
isl_pw_multi_aff_project_out
Line
Count
Source
1252
68
{
1253
68
  int i;
1254
68
  enum isl_dim_type set_type;
1255
68
1256
68
  if (!pw)
1257
0
    return NULL;
1258
68
  
if (68
n == 0 && 68
!isl_space_get_tuple_name(pw->dim, type)0
)
1259
0
    return pw;
1260
68
1261
68
  
set_type = type == isl_dim_in ? 68
isl_dim_set68
:
type0
;
1262
68
1263
68
  pw = FN(PW,cow)(pw);
1264
68
  if (!pw)
1265
0
    return NULL;
1266
68
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1267
68
  if (!pw->dim)
1268
0
    goto error;
1269
204
  
for (i = 0; 68
i < pw->n204
;
++i136
)
{136
1270
136
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1271
136
              set_type, first, n);
1272
136
    if (!pw->p[i].set)
1273
0
      goto error;
1274
136
    
pw->p[i].136
FIELD136
=
FN136
(EL,drop_dims)(pw->p[i].
FIELD136
, type, first, n);
1275
136
    if (
!pw->p[i].136
FIELD136
)
1276
0
      goto error;
1277
136
  }
1278
68
1279
68
  return pw;
1280
68
error:
1281
0
  FN(PW,free)(pw);
1282
68
  return NULL;
1283
68
}
1284
1285
/* Project the domain of pw onto its parameter space.
1286
 */
1287
__isl_give PW *FN(PW,project_domain_on_params)(__isl_take PW *pw)
1288
{
1289
  isl_space *space;
1290
  unsigned n;
1291
1292
  n = FN(PW,dim)(pw, isl_dim_in);
1293
  pw = FN(PW,project_out)(pw, isl_dim_in, 0, n);
1294
  space = FN(PW,get_domain_space)(pw);
1295
  space = isl_space_params(space);
1296
  pw = FN(PW,reset_domain_space)(pw, space);
1297
  return pw;
1298
}
Unexecuted instantiation: isl_pw_qpolynomial_project_domain_on_params
isl_pw_qpolynomial_fold_project_domain_on_params
Line
Count
Source
1288
1
{
1289
1
  isl_space *space;
1290
1
  unsigned n;
1291
1
1292
1
  n = FN(PW,dim)(pw, isl_dim_in);
1293
1
  pw = FN(PW,project_out)(pw, isl_dim_in, 0, n);
1294
1
  space = FN(PW,get_domain_space)(pw);
1295
1
  space = isl_space_params(space);
1296
1
  pw = FN(PW,reset_domain_space)(pw, space);
1297
1
  return pw;
1298
1
}
Unexecuted instantiation: isl_pw_multi_aff_project_domain_on_params
Unexecuted instantiation: isl_pw_aff_project_domain_on_params
1299
#endif
1300
1301
#ifndef NO_INSERT_DIMS
1302
__isl_give PW *FN(PW,insert_dims)(__isl_take PW *pw, enum isl_dim_type type,
1303
  unsigned first, unsigned n)
1304
{
1305
  int i;
1306
  enum isl_dim_type set_type;
1307
1308
  if (!pw)
1309
    return NULL;
1310
  if (n == 0 && !isl_space_is_named_or_nested(pw->dim, type))
1311
    return pw;
1312
1313
  set_type = type == isl_dim_in ? isl_dim_set : type;
1314
1315
  pw = FN(PW,cow)(pw);
1316
  if (!pw)
1317
    return NULL;
1318
1319
  pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
1320
  if (!pw->dim)
1321
    goto error;
1322
1323
  for (i = 0; i < pw->n; ++i) {
1324
    pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1325
                  set_type, first, n);
1326
    if (!pw->p[i].set)
1327
      goto error;
1328
    pw->p[i].FIELD = FN(EL,insert_dims)(pw->p[i].FIELD,
1329
                type, first, n);
1330
    if (!pw->p[i].FIELD)
1331
      goto error;
1332
  }
1333
1334
  return pw;
1335
error:
1336
  FN(PW,free)(pw);
1337
  return NULL;
1338
}
isl_pw_aff_insert_dims
Line
Count
Source
1304
3.32k
{
1305
3.32k
  int i;
1306
3.32k
  enum isl_dim_type set_type;
1307
3.32k
1308
3.32k
  if (!pw)
1309
0
    return NULL;
1310
3.32k
  
if (3.32k
n == 0 && 3.32k
!isl_space_is_named_or_nested(pw->dim, type)0
)
1311
0
    return pw;
1312
3.32k
1313
3.32k
  
set_type = type == isl_dim_in ? 3.32k
isl_dim_set3.32k
:
type0
;
1314
3.32k
1315
3.32k
  pw = FN(PW,cow)(pw);
1316
3.32k
  if (!pw)
1317
0
    return NULL;
1318
3.32k
1319
3.32k
  pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
1320
3.32k
  if (!pw->dim)
1321
0
    goto error;
1322
3.32k
1323
6.65k
  
for (i = 0; 3.32k
i < pw->n6.65k
;
++i3.32k
)
{3.32k
1324
3.32k
    pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1325
3.32k
                  set_type, first, n);
1326
3.32k
    if (!pw->p[i].set)
1327
0
      goto error;
1328
3.32k
    
pw->p[i].3.32k
FIELD3.32k
=
FN3.32k
(EL,insert_dims)(pw->p[i].
FIELD3.32k
,
1329
3.32k
                type, first, n);
1330
3.32k
    if (
!pw->p[i].3.32k
FIELD3.32k
)
1331
0
      goto error;
1332
3.32k
  }
1333
3.32k
1334
3.32k
  return pw;
1335
3.32k
error:
1336
0
  FN(PW,free)(pw);
1337
3.32k
  return NULL;
1338
3.32k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_insert_dims
Unexecuted instantiation: isl_pw_qpolynomial_insert_dims
1339
#endif
1340
1341
__isl_give PW *FN(PW,fix_dim)(__isl_take PW *pw,
1342
  enum isl_dim_type type, unsigned pos, isl_int v)
1343
{
1344
  int i;
1345
1346
  if (!pw)
1347
    return NULL;
1348
1349
  if (type == isl_dim_in)
1350
    type = isl_dim_set;
1351
1352
  pw = FN(PW,cow)(pw);
1353
  if (!pw)
1354
    return NULL;
1355
  for (i = 0; i < pw->n; ++i) {
1356
    pw->p[i].set = isl_set_fix(pw->p[i].set, type, pos, v);
1357
    if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
1358
      return FN(PW,free)(pw);
1359
  }
1360
1361
  return pw;
1362
}
Unexecuted instantiation: isl_pw_multi_aff_fix_dim
isl_pw_qpolynomial_fix_dim
Line
Count
Source
1343
1
{
1344
1
  int i;
1345
1
1346
1
  if (!pw)
1347
0
    return NULL;
1348
1
1349
1
  
if (1
type == isl_dim_in1
)
1350
0
    type = isl_dim_set;
1351
1
1352
1
  pw = FN(PW,cow)(pw);
1353
1
  if (!pw)
1354
0
    return NULL;
1355
2
  
for (i = 0; 1
i < pw->n2
;
++i1
)
{1
1356
1
    pw->p[i].set = isl_set_fix(pw->p[i].set, type, pos, v);
1357
1
    if (
FN1
(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 01
)
1358
0
      
return 0
FN0
(PW,free)(pw);
1359
1
  }
1360
1
1361
1
  return pw;
1362
1
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_dim
Unexecuted instantiation: isl_pw_aff_fix_dim
1363
1364
/* Fix the value of the variable at position "pos" of type "type" of "pw"
1365
 * to be equal to "v".
1366
 */
1367
__isl_give PW *FN(PW,fix_val)(__isl_take PW *pw,
1368
  enum isl_dim_type type, unsigned pos, __isl_take isl_val *v)
1369
{
1370
  if (!v)
1371
    return FN(PW,free)(pw);
1372
  if (!isl_val_is_int(v))
1373
    isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
1374
      "expecting integer value", goto error);
1375
1376
  pw = FN(PW,fix_dim)(pw, type, pos, v->n);
1377
  isl_val_free(v);
1378
1379
  return pw;
1380
error:
1381
  isl_val_free(v);
1382
  return FN(PW,free)(pw);
1383
}
Unexecuted instantiation: isl_pw_aff_fix_val
isl_pw_qpolynomial_fix_val
Line
Count
Source
1369
1
{
1370
1
  if (!v)
1371
0
    
return 0
FN0
(PW,free)(pw);
1372
1
  
if (1
!isl_val_is_int(v)1
)
1373
0
    isl_die(FN(PW,get_ctx)(pw), isl_error_invalid,
1374
1
      "expecting integer value", goto error);
1375
1
1376
1
  
pw = 1
FN1
(PW,fix_dim)(pw, type, pos, v->n);
1377
1
  isl_val_free(v);
1378
1
1379
1
  return pw;
1380
1
error:
1381
0
  isl_val_free(v);
1382
0
  return FN(PW,free)(pw);
1383
1
}
Unexecuted instantiation: isl_pw_multi_aff_fix_val
Unexecuted instantiation: isl_pw_qpolynomial_fold_fix_val
1384
1385
unsigned FN(PW,dim)(__isl_keep PW *pw, enum isl_dim_type type)
1386
{
1387
  return pw ? isl_space_dim(pw->dim, type) : 0;
1388
}
isl_pw_aff_dim
Line
Count
Source
1386
3.32k
{
1387
3.32k
  return pw ? 
isl_space_dim(pw->dim, type)3.32k
:
00
;
1388
3.32k
}
isl_pw_multi_aff_dim
Line
Count
Source
1386
17.3k
{
1387
17.3k
  return pw ? 
isl_space_dim(pw->dim, type)17.3k
:
00
;
1388
17.3k
}
isl_pw_qpolynomial_fold_dim
Line
Count
Source
1386
3
{
1387
3
  return pw ? 
isl_space_dim(pw->dim, type)3
:
00
;
1388
3
}
Unexecuted instantiation: isl_pw_qpolynomial_dim
1389
1390
__isl_give PW *FN(PW,split_dims)(__isl_take PW *pw,
1391
  enum isl_dim_type type, unsigned first, unsigned n)
1392
{
1393
  int i;
1394
1395
  if (!pw)
1396
    return NULL;
1397
  if (n == 0)
1398
    return pw;
1399
1400
  if (type == isl_dim_in)
1401
    type = isl_dim_set;
1402
1403
  pw = FN(PW,cow)(pw);
1404
  if (!pw)
1405
    return NULL;
1406
  if (!pw->dim)
1407
    goto error;
1408
  for (i = 0; i < pw->n; ++i) {
1409
    pw->p[i].set = isl_set_split_dims(pw->p[i].set, type, first, n);
1410
    if (!pw->p[i].set)
1411
      goto error;
1412
  }
1413
1414
  return pw;
1415
error:
1416
  FN(PW,free)(pw);
1417
  return NULL;
1418
}
Unexecuted instantiation: isl_pw_aff_split_dims
Unexecuted instantiation: isl_pw_qpolynomial_split_dims
Unexecuted instantiation: isl_pw_multi_aff_split_dims
Unexecuted instantiation: isl_pw_qpolynomial_fold_split_dims
1419
1420
#ifndef NO_OPT
1421
/* Compute the maximal value attained by the piecewise quasipolynomial
1422
 * on its domain or zero if the domain is empty.
1423
 * In the worst case, the domain is scanned completely,
1424
 * so the domain is assumed to be bounded.
1425
 */
1426
__isl_give isl_val *FN(PW,opt)(__isl_take PW *pw, int max)
1427
{
1428
  int i;
1429
  isl_val *opt;
1430
1431
  if (!pw)
1432
    return NULL;
1433
1434
  if (pw->n == 0) {
1435
    opt = isl_val_zero(FN(PW,get_ctx)(pw));
1436
    FN(PW,free)(pw);
1437
    return opt;
1438
  }
1439
1440
  opt = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[0].FIELD),
1441
          isl_set_copy(pw->p[0].set), max);
1442
  for (i = 1; i < pw->n; ++i) {
1443
    isl_val *opt_i;
1444
    opt_i = FN(EL,opt_on_domain)(FN(EL,copy)(pw->p[i].FIELD),
1445
            isl_set_copy(pw->p[i].set), max);
1446
    if (max)
1447
      opt = isl_val_max(opt, opt_i);
1448
    else
1449
      opt = isl_val_min(opt, opt_i);
1450
  }
1451
1452
  FN(PW,free)(pw);
1453
  return opt;
1454
}
Unexecuted instantiation: isl_pw_qpolynomial_opt
isl_pw_qpolynomial_fold_opt
Line
Count
Source
1427
7
{
1428
7
  int i;
1429
7
  isl_val *opt;
1430
7
1431
7
  if (!pw)
1432
0
    return NULL;
1433
7
1434
7
  
if (7
pw->n == 07
)
{0
1435
0
    opt = isl_val_zero(FN(PW,get_ctx)(pw));
1436
0
    FN(PW,free)(pw);
1437
0
    return opt;
1438
7
  }
1439
7
1440
7
  
opt = 7
FN7
(EL,opt_on_domain)(
FN7
(EL,copy)(pw->p[0].
FIELD7
),
1441
7
          isl_set_copy(pw->p[0].set), max);
1442
7
  for (i = 1; 
i < pw->n7
;
++i0
)
{0
1443
0
    isl_val *opt_i;
1444
0
    opt_i = 
FN0
(EL,opt_on_domain)(
FN0
(EL,copy)(pw->p[i].
FIELD0
),
1445
0
            isl_set_copy(pw->p[i].set), max);
1446
0
    if (max)
1447
0
      opt = isl_val_max(opt, opt_i);
1448
0
    else
1449
0
      opt = isl_val_min(opt, opt_i);
1450
7
  }
1451
7
1452
7
  FN(PW,free)(pw);
1453
7
  return opt;
1454
7
}
1455
1456
__isl_give isl_val *FN(PW,max)(__isl_take PW *pw)
1457
{
1458
  return FN(PW,opt)(pw, 1);
1459
}
Unexecuted instantiation: isl_pw_qpolynomial_max
isl_pw_qpolynomial_fold_max
Line
Count
Source
1457
2
{
1458
2
  return FN(PW,opt)(pw, 1);
1459
2
}
1460
1461
__isl_give isl_val *FN(PW,min)(__isl_take PW *pw)
1462
{
1463
  return FN(PW,opt)(pw, 0);
1464
}
isl_pw_qpolynomial_fold_min
Line
Count
Source
1462
5
{
1463
5
  return FN(PW,opt)(pw, 0);
1464
5
}
Unexecuted instantiation: isl_pw_qpolynomial_min
1465
#endif
1466
1467
__isl_give isl_space *FN(PW,get_space)(__isl_keep PW *pw)
1468
{
1469
  return pw ? isl_space_copy(pw->dim) : NULL;
1470
}
isl_pw_qpolynomial_fold_get_space
Line
Count
Source
1468
1
{
1469
1
  return pw ? isl_space_copy(pw->dim) : NULL;
1470
1
}
isl_pw_aff_get_space
Line
Count
Source
1468
113k
{
1469
113k
  return pw ? isl_space_copy(pw->dim) : NULL;
1470
113k
}
isl_pw_multi_aff_get_space
Line
Count
Source
1468
44.4k
{
1469
44.4k
  return pw ? isl_space_copy(pw->dim) : NULL;
1470
44.4k
}
isl_pw_qpolynomial_get_space
Line
Count
Source
1468
9
{
1469
9
  return pw ? isl_space_copy(pw->dim) : NULL;
1470
9
}
1471
1472
__isl_give isl_space *FN(PW,get_domain_space)(__isl_keep PW *pw)
1473
{
1474
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1475
}
isl_pw_qpolynomial_fold_get_domain_space
Line
Count
Source
1473
5
{
1474
5
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1475
5
}
isl_pw_qpolynomial_get_domain_space
Line
Count
Source
1473
2
{
1474
2
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1475
2
}
isl_pw_multi_aff_get_domain_space
Line
Count
Source
1473
263
{
1474
263
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1475
263
}
isl_pw_aff_get_domain_space
Line
Count
Source
1473
99.6k
{
1474
99.6k
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1475
99.6k
}
1476
1477
/* Return the position of the dimension of the given type and name
1478
 * in "pw".
1479
 * Return -1 if no such dimension can be found.
1480
 */
1481
int FN(PW,find_dim_by_name)(__isl_keep PW *pw,
1482
  enum isl_dim_type type, const char *name)
1483
{
1484
  if (!pw)
1485
    return -1;
1486
  return isl_space_find_dim_by_name(pw->dim, type, name);
1487
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_find_dim_by_name
Unexecuted instantiation: isl_pw_multi_aff_find_dim_by_name
Unexecuted instantiation: isl_pw_qpolynomial_find_dim_by_name
Unexecuted instantiation: isl_pw_aff_find_dim_by_name
1488
1489
#ifndef NO_RESET_DIM
1490
/* Reset the space of "pw".  Since we don't know if the elements
1491
 * represent the spaces themselves or their domains, we pass along
1492
 * both when we call their reset_space_and_domain.
1493
 */
1494
static __isl_give PW *FN(PW,reset_space_and_domain)(__isl_take PW *pw,
1495
  __isl_take isl_space *space, __isl_take isl_space *domain)
1496
{
1497
  int i;
1498
1499
  pw = FN(PW,cow)(pw);
1500
  if (!pw || !space || !domain)
1501
    goto error;
1502
1503
  for (i = 0; i < pw->n; ++i) {
1504
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1505
             isl_space_copy(domain));
1506
    if (!pw->p[i].set)
1507
      goto error;
1508
    pw->p[i].FIELD = FN(EL,reset_space_and_domain)(pw->p[i].FIELD,
1509
            isl_space_copy(space), isl_space_copy(domain));
1510
    if (!pw->p[i].FIELD)
1511
      goto error;
1512
  }
1513
1514
  isl_space_free(domain);
1515
1516
  isl_space_free(pw->dim);
1517
  pw->dim = space;
1518
1519
  return pw;
1520
error:
1521
  isl_space_free(domain);
1522
  isl_space_free(space);
1523
  FN(PW,free)(pw);
1524
  return NULL;
1525
}
isl_aff.c:isl_pw_aff_reset_space_and_domain
Line
Count
Source
1496
51.3k
{
1497
51.3k
  int i;
1498
51.3k
1499
51.3k
  pw = FN(PW,cow)(pw);
1500
51.3k
  if (
!pw || 51.3k
!space51.3k
||
!domain51.3k
)
1501
0
    goto error;
1502
51.3k
1503
103k
  
for (i = 0; 51.3k
i < pw->n103k
;
++i51.8k
)
{51.8k
1504
51.8k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1505
51.8k
             isl_space_copy(domain));
1506
51.8k
    if (!pw->p[i].set)
1507
0
      goto error;
1508
51.8k
    
pw->p[i].51.8k
FIELD51.8k
=
FN51.8k
(EL,reset_space_and_domain)(pw->p[i].
FIELD51.8k
,
1509
51.8k
            isl_space_copy(space), isl_space_copy(domain));
1510
51.8k
    if (
!pw->p[i].51.8k
FIELD51.8k
)
1511
0
      goto error;
1512
51.8k
  }
1513
51.3k
1514
51.3k
  isl_space_free(domain);
1515
51.3k
1516
51.3k
  isl_space_free(pw->dim);
1517
51.3k
  pw->dim = space;
1518
51.3k
1519
51.3k
  return pw;
1520
51.3k
error:
1521
0
  isl_space_free(domain);
1522
0
  isl_space_free(space);
1523
0
  FN(PW,free)(pw);
1524
51.3k
  return NULL;
1525
51.3k
}
Unexecuted instantiation: isl_polynomial.c:isl_pw_qpolynomial_reset_space_and_domain
isl_aff.c:isl_pw_multi_aff_reset_space_and_domain
Line
Count
Source
1496
1.79k
{
1497
1.79k
  int i;
1498
1.79k
1499
1.79k
  pw = FN(PW,cow)(pw);
1500
1.79k
  if (
!pw || 1.79k
!space1.79k
||
!domain1.79k
)
1501
0
    goto error;
1502
1.79k
1503
3.65k
  
for (i = 0; 1.79k
i < pw->n3.65k
;
++i1.86k
)
{1.86k
1504
1.86k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1505
1.86k
             isl_space_copy(domain));
1506
1.86k
    if (!pw->p[i].set)
1507
0
      goto error;
1508
1.86k
    
pw->p[i].1.86k
FIELD1.86k
=
FN1.86k
(EL,reset_space_and_domain)(pw->p[i].
FIELD1.86k
,
1509
1.86k
            isl_space_copy(space), isl_space_copy(domain));
1510
1.86k
    if (
!pw->p[i].1.86k
FIELD1.86k
)
1511
0
      goto error;
1512
1.86k
  }
1513
1.79k
1514
1.79k
  isl_space_free(domain);
1515
1.79k
1516
1.79k
  isl_space_free(pw->dim);
1517
1.79k
  pw->dim = space;
1518
1.79k
1519
1.79k
  return pw;
1520
1.79k
error:
1521
0
  isl_space_free(domain);
1522
0
  isl_space_free(space);
1523
0
  FN(PW,free)(pw);
1524
1.79k
  return NULL;
1525
1.79k
}
isl_fold.c:isl_pw_qpolynomial_fold_reset_space_and_domain
Line
Count
Source
1496
4
{
1497
4
  int i;
1498
4
1499
4
  pw = FN(PW,cow)(pw);
1500
4
  if (
!pw || 4
!space4
||
!domain4
)
1501
0
    goto error;
1502
4
1503
7
  
for (i = 0; 4
i < pw->n7
;
++i3
)
{3
1504
3
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1505
3
             isl_space_copy(domain));
1506
3
    if (!pw->p[i].set)
1507
0
      goto error;
1508
3
    
pw->p[i].3
FIELD3
=
FN3
(EL,reset_space_and_domain)(pw->p[i].
FIELD3
,
1509
3
            isl_space_copy(space), isl_space_copy(domain));
1510
3
    if (
!pw->p[i].3
FIELD3
)
1511
0
      goto error;
1512
4
  }
1513
4
1514
4
  isl_space_free(domain);
1515
4
1516
4
  isl_space_free(pw->dim);
1517
4
  pw->dim = space;
1518
4
1519
4
  return pw;
1520
4
error:
1521
0
  isl_space_free(domain);
1522
0
  isl_space_free(space);
1523
0
  FN(PW,free)(pw);
1524
4
  return NULL;
1525
4
}
1526
1527
__isl_give PW *FN(PW,reset_domain_space)(__isl_take PW *pw,
1528
  __isl_take isl_space *domain)
1529
{
1530
  isl_space *space;
1531
1532
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1533
               FN(PW,get_space)(pw));
1534
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1535
}
isl_pw_qpolynomial_fold_reset_domain_space
Line
Count
Source
1529
1
{
1530
1
  isl_space *space;
1531
1
1532
1
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1533
1
               FN(PW,get_space)(pw));
1534
1
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1535
1
}
Unexecuted instantiation: isl_pw_multi_aff_reset_domain_space
isl_pw_aff_reset_domain_space
Line
Count
Source
1529
41.4k
{
1530
41.4k
  isl_space *space;
1531
41.4k
1532
41.4k
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1533
41.4k
               FN(PW,get_space)(pw));
1534
41.4k
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1535
41.4k
}
Unexecuted instantiation: isl_pw_qpolynomial_reset_domain_space
1536
1537
__isl_give PW *FN(PW,reset_space)(__isl_take PW *pw, __isl_take isl_space *dim)
1538
{
1539
  isl_space *domain;
1540
1541
  domain = isl_space_domain(isl_space_copy(dim));
1542
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1543
}
isl_pw_aff_reset_space
Line
Count
Source
1538
9.94k
{
1539
9.94k
  isl_space *domain;
1540
9.94k
1541
9.94k
  domain = isl_space_domain(isl_space_copy(dim));
1542
9.94k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1543
9.94k
}
Unexecuted instantiation: isl_pw_qpolynomial_reset_space
isl_pw_multi_aff_reset_space
Line
Count
Source
1538
1.79k
{
1539
1.79k
  isl_space *domain;
1540
1.79k
1541
1.79k
  domain = isl_space_domain(isl_space_copy(dim));
1542
1.79k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1543
1.79k
}
isl_pw_qpolynomial_fold_reset_space
Line
Count
Source
1538
3
{
1539
3
  isl_space *domain;
1540
3
1541
3
  domain = isl_space_domain(isl_space_copy(dim));
1542
3
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1543
3
}
1544
1545
__isl_give PW *FN(PW,set_tuple_id)(__isl_take PW *pw, enum isl_dim_type type,
1546
  __isl_take isl_id *id)
1547
{
1548
  isl_space *space;
1549
1550
  pw = FN(PW,cow)(pw);
1551
  if (!pw)
1552
    goto error;
1553
1554
  space = FN(PW,get_space)(pw);
1555
  space = isl_space_set_tuple_id(space, type, id);
1556
1557
  return FN(PW,reset_space)(pw, space);
1558
error:
1559
  isl_id_free(id);
1560
  return FN(PW,free)(pw);
1561
}
isl_pw_aff_set_tuple_id
Line
Count
Source
1547
537
{
1548
537
  isl_space *space;
1549
537
1550
537
  pw = FN(PW,cow)(pw);
1551
537
  if (!pw)
1552
0
    goto error;
1553
537
1554
537
  
space = 537
FN537
(PW,get_space)(pw);
1555
537
  space = isl_space_set_tuple_id(space, type, id);
1556
537
1557
537
  return FN(PW,reset_space)(pw, space);
1558
537
error:
1559
0
  isl_id_free(id);
1560
0
  return FN(PW,free)(pw);
1561
537
}
Unexecuted instantiation: isl_pw_qpolynomial_set_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_set_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_set_tuple_id
1562
1563
/* Drop the id on the specified tuple.
1564
 */
1565
__isl_give PW *FN(PW,reset_tuple_id)(__isl_take PW *pw, enum isl_dim_type type)
1566
{
1567
  isl_space *space;
1568
1569
  if (!pw)
1570
    return NULL;
1571
  if (!FN(PW,has_tuple_id)(pw, type))
1572
    return pw;
1573
1574
  pw = FN(PW,cow)(pw);
1575
  if (!pw)
1576
    return NULL;
1577
1578
  space = FN(PW,get_space)(pw);
1579
  space = isl_space_reset_tuple_id(space, type);
1580
1581
  return FN(PW,reset_space)(pw, space);
1582
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_reset_tuple_id
Unexecuted instantiation: isl_pw_multi_aff_reset_tuple_id
Unexecuted instantiation: isl_pw_aff_reset_tuple_id
Unexecuted instantiation: isl_pw_qpolynomial_reset_tuple_id
1583
1584
__isl_give PW *FN(PW,set_dim_id)(__isl_take PW *pw,
1585
  enum isl_dim_type type, unsigned pos, __isl_take isl_id *id)
1586
{
1587
  pw = FN(PW,cow)(pw);
1588
  if (!pw)
1589
    goto error;
1590
  pw->dim = isl_space_set_dim_id(pw->dim, type, pos, id);
1591
  return FN(PW,reset_space)(pw, isl_space_copy(pw->dim));
1592
error:
1593
  isl_id_free(id);
1594
  return FN(PW,free)(pw);
1595
}
Unexecuted instantiation: isl_pw_aff_set_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_fold_set_dim_id
Unexecuted instantiation: isl_pw_qpolynomial_set_dim_id
Unexecuted instantiation: isl_pw_multi_aff_set_dim_id
1596
#endif
1597
1598
/* Reset the user pointer on all identifiers of parameters and tuples
1599
 * of the space of "pw".
1600
 */
1601
__isl_give PW *FN(PW,reset_user)(__isl_take PW *pw)
1602
{
1603
  isl_space *space;
1604
1605
  space = FN(PW,get_space)(pw);
1606
  space = isl_space_reset_user(space);
1607
1608
  return FN(PW,reset_space)(pw, space);
1609
}
Unexecuted instantiation: isl_pw_multi_aff_reset_user
Unexecuted instantiation: isl_pw_aff_reset_user
Unexecuted instantiation: isl_pw_qpolynomial_fold_reset_user
Unexecuted instantiation: isl_pw_qpolynomial_reset_user
1610
1611
isl_bool FN(PW,has_equal_space)(__isl_keep PW *pw1, __isl_keep PW *pw2)
1612
{
1613
  if (!pw1 || !pw2)
1614
    return isl_bool_error;
1615
1616
  return isl_space_is_equal(pw1->dim, pw2->dim);
1617
}
Unexecuted instantiation: isl_pw_multi_aff_has_equal_space
Unexecuted instantiation: isl_pw_aff_has_equal_space
Unexecuted instantiation: isl_pw_qpolynomial_fold_has_equal_space
isl_pw_qpolynomial_has_equal_space
Line
Count
Source
1612
4
{
1613
4
  if (
!pw1 || 4
!pw24
)
1614
0
    return isl_bool_error;
1615
4
1616
4
  return isl_space_is_equal(pw1->dim, pw2->dim);
1617
4
}
1618
1619
#ifndef NO_MORPH
1620
__isl_give PW *FN(PW,morph_domain)(__isl_take PW *pw,
1621
  __isl_take isl_morph *morph)
1622
{
1623
  int i;
1624
  isl_ctx *ctx;
1625
1626
  if (!pw || !morph)
1627
    goto error;
1628
1629
  ctx = isl_space_get_ctx(pw->dim);
1630
  isl_assert(ctx, isl_space_is_domain_internal(morph->dom->dim, pw->dim),
1631
    goto error);
1632
1633
  pw = FN(PW,cow)(pw);
1634
  if (!pw)
1635
    goto error;
1636
  pw->dim = isl_space_extend_domain_with_range(
1637
      isl_space_copy(morph->ran->dim), pw->dim);
1638
  if (!pw->dim)
1639
    goto error;
1640
1641
  for (i = 0; i < pw->n; ++i) {
1642
    pw->p[i].set = isl_morph_set(isl_morph_copy(morph), pw->p[i].set);
1643
    if (!pw->p[i].set)
1644
      goto error;
1645
    pw->p[i].FIELD = FN(EL,morph_domain)(pw->p[i].FIELD,
1646
            isl_morph_copy(morph));
1647
    if (!pw->p[i].FIELD)
1648
      goto error;
1649
  }
1650
1651
  isl_morph_free(morph);
1652
1653
  return pw;
1654
error:
1655
  FN(PW,free)(pw);
1656
  isl_morph_free(morph);
1657
  return NULL;
1658
}
isl_pw_qpolynomial_fold_morph_domain
Line
Count
Source
1622
2
{
1623
2
  int i;
1624
2
  isl_ctx *ctx;
1625
2
1626
2
  if (
!pw || 2
!morph2
)
1627
0
    goto error;
1628
2
1629
2
  ctx = isl_space_get_ctx(pw->dim);
1630
2
  isl_assert(ctx, isl_space_is_domain_internal(morph->dom->dim, pw->dim),
1631
2
    goto error);
1632
2
1633
2
  
pw = 2
FN2
(PW,cow)(pw);
1634
2
  if (!pw)
1635
0
    goto error;
1636
2
  pw->dim = isl_space_extend_domain_with_range(
1637
2
      isl_space_copy(morph->ran->dim), pw->dim);
1638
2
  if (!pw->dim)
1639
0
    goto error;
1640
2
1641
3
  
for (i = 0; 2
i < pw->n3
;
++i1
)
{1
1642
1
    pw->p[i].set = isl_morph_set(isl_morph_copy(morph), pw->p[i].set);
1643
1
    if (!pw->p[i].set)
1644
0
      goto error;
1645
1
    
pw->p[i].1
FIELD1
=
FN1
(EL,morph_domain)(pw->p[i].
FIELD1
,
1646
1
            isl_morph_copy(morph));
1647
1
    if (
!pw->p[i].1
FIELD1
)
1648
0
      goto error;
1649
2
  }
1650
2
1651
2
  isl_morph_free(morph);
1652
2
1653
2
  return pw;
1654
2
error:
1655
0
  FN(PW,free)(pw);
1656
0
  isl_morph_free(morph);
1657
2
  return NULL;
1658
2
}
Unexecuted instantiation: isl_pw_qpolynomial_morph_domain
1659
#endif
1660
1661
int FN(PW,n_piece)(__isl_keep PW *pw)
1662
{
1663
  return pw ? pw->n : 0;
1664
}
Unexecuted instantiation: isl_pw_qpolynomial_n_piece
isl_pw_aff_n_piece
Line
Count
Source
1662
8.71k
{
1663
8.71k
  return pw ? 
pw->n8.71k
:
00
;
1664
8.71k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_n_piece
Unexecuted instantiation: isl_pw_multi_aff_n_piece
1665
1666
isl_stat FN(PW,foreach_piece)(__isl_keep PW *pw,
1667
  isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el, void *user),
1668
  void *user)
1669
{
1670
  int i;
1671
1672
  if (!pw)
1673
    return isl_stat_error;
1674
1675
  for (i = 0; i < pw->n; ++i)
1676
    if (fn(isl_set_copy(pw->p[i].set),
1677
        FN(EL,copy)(pw->p[i].FIELD), user) < 0)
1678
      return isl_stat_error;
1679
1680
  return isl_stat_ok;
1681
}
isl_pw_qpolynomial_foreach_piece
Line
Count
Source
1669
1
{
1670
1
  int i;
1671
1
1672
1
  if (!pw)
1673
0
    return isl_stat_error;
1674
1
1675
3
  
for (i = 0; 1
i < pw->n3
;
++i2
)
1676
2
    
if (2
fn(isl_set_copy(pw->p[i].set),2
1677
2
        
FN2
(EL,copy)(pw->p[i].
FIELD2
), user) < 0)
1678
0
      return isl_stat_error;
1679
1
1680
1
  return isl_stat_ok;
1681
1
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_foreach_piece
isl_pw_aff_foreach_piece
Line
Count
Source
1669
9.84k
{
1670
9.84k
  int i;
1671
9.84k
1672
9.84k
  if (!pw)
1673
0
    return isl_stat_error;
1674
9.84k
1675
17.1k
  
for (i = 0; 9.84k
i < pw->n17.1k
;
++i7.35k
)
1676
10.1k
    
if (10.1k
fn(isl_set_copy(pw->p[i].set),10.1k
1677
10.1k
        
FN10.1k
(EL,copy)(pw->p[i].
FIELD10.1k
), user) < 0)
1678
2.75k
      return isl_stat_error;
1679
9.84k
1680
7.09k
  return isl_stat_ok;
1681
9.84k
}
isl_pw_multi_aff_foreach_piece
Line
Count
Source
1669
2
{
1670
2
  int i;
1671
2
1672
2
  if (!pw)
1673
0
    return isl_stat_error;
1674
2
1675
4
  
for (i = 0; 2
i < pw->n4
;
++i2
)
1676
2
    
if (2
fn(isl_set_copy(pw->p[i].set),2
1677
2
        
FN2
(EL,copy)(pw->p[i].
FIELD2
), user) < 0)
1678
0
      return isl_stat_error;
1679
2
1680
2
  return isl_stat_ok;
1681
2
}
1682
1683
#ifndef NO_LIFT
1684
static isl_bool any_divs(__isl_keep isl_set *set)
1685
{
1686
  int i;
1687
1688
  if (!set)
1689
    return isl_bool_error;
1690
1691
  for (i = 0; i < set->n; ++i)
1692
    if (set->p[i]->n_div > 0)
1693
      return isl_bool_true;
1694
1695
  return isl_bool_false;
1696
}
Unexecuted instantiation: isl_polynomial.c:any_divs
isl_fold.c:any_divs
Line
Count
Source
1685
2
{
1686
2
  int i;
1687
2
1688
2
  if (!set)
1689
0
    return isl_bool_error;
1690
2
1691
3
  
for (i = 0; 2
i < set->n3
;
++i1
)
1692
2
    
if (2
set->p[i]->n_div > 02
)
1693
1
      return isl_bool_true;
1694
2
1695
1
  return isl_bool_false;
1696
2
}
1697
1698
static isl_stat foreach_lifted_subset(__isl_take isl_set *set,
1699
  __isl_take EL *el,
1700
  isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el,
1701
    void *user), void *user)
1702
{
1703
  int i;
1704
1705
  if (!set || !el)
1706
    goto error;
1707
1708
  for (i = 0; i < set->n; ++i) {
1709
    isl_set *lift;
1710
    EL *copy;
1711
1712
    lift = isl_set_from_basic_set(isl_basic_set_copy(set->p[i]));
1713
    lift = isl_set_lift(lift);
1714
1715
    copy = FN(EL,copy)(el);
1716
    copy = FN(EL,lift)(copy, isl_set_get_space(lift));
1717
1718
    if (fn(lift, copy, user) < 0)
1719
      goto error;
1720
  }
1721
1722
  isl_set_free(set);
1723
  FN(EL,free)(el);
1724
1725
  return isl_stat_ok;
1726
error:
1727
  isl_set_free(set);
1728
  FN(EL,free)(el);
1729
  return isl_stat_error;
1730
}
Unexecuted instantiation: isl_polynomial.c:foreach_lifted_subset
isl_fold.c:foreach_lifted_subset
Line
Count
Source
1702
1
{
1703
1
  int i;
1704
1
1705
1
  if (
!set || 1
!el1
)
1706
0
    goto error;
1707
1
1708
2
  
for (i = 0; 1
i < set->n2
;
++i1
)
{1
1709
1
    isl_set *lift;
1710
1
    EL *copy;
1711
1
1712
1
    lift = isl_set_from_basic_set(isl_basic_set_copy(set->p[i]));
1713
1
    lift = isl_set_lift(lift);
1714
1
1715
1
    copy = FN(EL,copy)(el);
1716
1
    copy = FN(EL,lift)(copy, isl_set_get_space(lift));
1717
1
1718
1
    if (fn(lift, copy, user) < 0)
1719
0
      goto error;
1720
1
  }
1721
1
1722
1
  isl_set_free(set);
1723
1
  FN(EL,free)(el);
1724
1
1725
1
  return isl_stat_ok;
1726
1
error:
1727
0
  isl_set_free(set);
1728
0
  FN(EL,free)(el);
1729
1
  return isl_stat_error;
1730
1
}
1731
1732
isl_stat FN(PW,foreach_lifted_piece)(__isl_keep PW *pw,
1733
  isl_stat (*fn)(__isl_take isl_set *set, __isl_take EL *el,
1734
        void *user), void *user)
1735
{
1736
  int i;
1737
1738
  if (!pw)
1739
    return isl_stat_error;
1740
1741
  for (i = 0; i < pw->n; ++i) {
1742
    isl_bool any;
1743
    isl_set *set;
1744
    EL *el;
1745
1746
    any = any_divs(pw->p[i].set);
1747
    if (any < 0)
1748
      return isl_stat_error;
1749
    set = isl_set_copy(pw->p[i].set);
1750
    el = FN(EL,copy)(pw->p[i].FIELD);
1751
    if (!any) {
1752
      if (fn(set, el, user) < 0)
1753
        return isl_stat_error;
1754
      continue;
1755
    }
1756
    if (foreach_lifted_subset(set, el, fn, user) < 0)
1757
      return isl_stat_error;
1758
  }
1759
1760
  return isl_stat_ok;
1761
}
isl_pw_qpolynomial_fold_foreach_lifted_piece
Line
Count
Source
1735
2
{
1736
2
  int i;
1737
2
1738
2
  if (!pw)
1739
0
    return isl_stat_error;
1740
2
1741
4
  
for (i = 0; 2
i < pw->n4
;
++i2
)
{2
1742
2
    isl_bool any;
1743
2
    isl_set *set;
1744
2
    EL *el;
1745
2
1746
2
    any = any_divs(pw->p[i].set);
1747
2
    if (any < 0)
1748
0
      return isl_stat_error;
1749
2
    set = isl_set_copy(pw->p[i].set);
1750
2
    el = 
FN2
(EL,copy)(pw->p[i].
FIELD2
);
1751
2
    if (
!any2
)
{1
1752
1
      if (fn(set, el, user) < 0)
1753
0
        return isl_stat_error;
1754
1
      continue;
1755
2
    }
1756
1
    
if (1
foreach_lifted_subset(set, el, fn, user) < 01
)
1757
0
      return isl_stat_error;
1758
2
  }
1759
2
1760
2
  return isl_stat_ok;
1761
2
}
Unexecuted instantiation: isl_pw_qpolynomial_foreach_lifted_piece
1762
#endif