Coverage Report

Created: 2017-03-27 23:01

/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
191k
{
27
191k
  isl_ctx *ctx;
28
191k
  struct PW *pw;
29
191k
30
191k
  if (!dim)
31
0
    return NULL;
32
191k
  ctx = isl_space_get_ctx(dim);
33
191k
  isl_assert(ctx, n >= 0, goto error);
34
191k
  
pw = 191k
isl_alloc191k
(ctx, struct PW,
35
191k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
191k
  if (!pw)
37
0
    goto error;
38
191k
39
191k
  pw->ref = 1;
40
191k
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
191k
  pw->size = n;
44
191k
  pw->n = 0;
45
191k
  pw->dim = dim;
46
191k
  return pw;
47
0
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
191k
}
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
0
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
35
}
isl_pw_multi_aff_alloc_size
Line
Count
Source
26
15.3k
{
27
15.3k
  isl_ctx *ctx;
28
15.3k
  struct PW *pw;
29
15.3k
30
15.3k
  if (!dim)
31
0
    return NULL;
32
15.3k
  ctx = isl_space_get_ctx(dim);
33
15.3k
  isl_assert(ctx, n >= 0, goto error);
34
15.3k
  
pw = 15.3k
isl_alloc15.3k
(ctx, struct PW,
35
15.3k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
15.3k
  if (!pw)
37
0
    goto error;
38
15.3k
39
15.3k
  pw->ref = 1;
40
15.3k
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
15.3k
  pw->size = n;
44
15.3k
  pw->n = 0;
45
15.3k
  pw->dim = dim;
46
15.3k
  return pw;
47
0
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
15.3k
}
isl_pw_aff_alloc_size
Line
Count
Source
26
175k
{
27
175k
  isl_ctx *ctx;
28
175k
  struct PW *pw;
29
175k
30
175k
  if (!dim)
31
0
    return NULL;
32
175k
  ctx = isl_space_get_ctx(dim);
33
175k
  isl_assert(ctx, n >= 0, goto error);
34
175k
  
pw = 175k
isl_alloc175k
(ctx, struct PW,
35
175k
      sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
36
175k
  if (!pw)
37
0
    goto error;
38
175k
39
175k
  pw->ref = 1;
40
175k
#ifdef HAS_TYPE
41
  pw->type = type;
42
#endif
43
175k
  pw->size = n;
44
175k
  pw->n = 0;
45
175k
  pw->dim = dim;
46
175k
  return pw;
47
0
error:
48
0
  isl_space_free(dim);
49
0
  return NULL;
50
175k
}
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
0
error:
48
0
  isl_space_free(dim);
49
0
  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
4.56k
{
60
4.56k
  return FN(PW,alloc_size)(dim, 0);
61
4.56k
}
isl_pw_multi_aff_empty
Line
Count
Source
59
1.92k
{
60
1.92k
  return FN(PW,alloc_size)(dim, 0);
61
1.92k
}
isl_pw_aff_empty
Line
Count
Source
59
2.63k
{
60
2.63k
  return FN(PW,alloc_size)(dim, 0);
61
2.63k
}
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
191k
{
67
191k
  isl_ctx *ctx;
68
191k
  isl_space *el_dim = NULL;
69
191k
70
191k
  if (
!pw || 191k
!set191k
||
!el191k
)
71
0
    goto error;
72
191k
73
191k
  
if (191k
isl_set_plain_is_empty(set) || 191k
FN191k
(EL,EL_IS_ZERO)(el)191k
)
{327
74
327
    isl_set_free(set);
75
327
    FN(EL,free)(el);
76
327
    return pw;
77
327
  }
78
191k
79
191k
  ctx = isl_set_get_ctx(set);
80
191k
#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
191k
  
el_dim = 18
FN191k
(EL,get_space(el));
86
191k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
191k
  
isl_assert191k
(ctx, pw->n < pw->size, goto error);191k
88
191k
89
191k
  pw->p[pw->n].set = set;
90
191k
  pw->p[pw->n].FIELD = el;
91
191k
  pw->n++;
92
191k
  
93
191k
  isl_space_free(el_dim);
94
191k
  return pw;
95
0
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
0
  return NULL;
101
191k
}
isl_pw_multi_aff_add_piece
Line
Count
Source
66
14.3k
{
67
14.3k
  isl_ctx *ctx;
68
14.3k
  isl_space *el_dim = NULL;
69
14.3k
70
14.3k
  if (
!pw || 14.3k
!set14.3k
||
!el14.3k
)
71
0
    goto error;
72
14.3k
73
14.3k
  
if (14.3k
isl_set_plain_is_empty(set) || 14.3k
FN14.1k
(EL,EL_IS_ZERO)(el)14.1k
)
{181
74
181
    isl_set_free(set);
75
181
    FN(EL,free)(el);
76
181
    return pw;
77
181
  }
78
14.3k
79
14.1k
  ctx = isl_set_get_ctx(set);
80
14.1k
#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
14.1k
  el_dim = FN(EL,get_space(el));
86
14.1k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
14.1k
  
isl_assert14.1k
(ctx, pw->n < pw->size, goto error);14.1k
88
14.1k
89
14.1k
  pw->p[pw->n].set = set;
90
14.1k
  pw->p[pw->n].FIELD = el;
91
14.1k
  pw->n++;
92
14.1k
  
93
14.1k
  isl_space_free(el_dim);
94
14.1k
  return pw;
95
0
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
0
  return NULL;
101
14.1k
}
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
6
  }
78
24
79
18
  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
0
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
0
  return NULL;
101
18
}
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
53
  }
78
151
79
98
  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
0
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
0
  return NULL;
101
98
}
isl_pw_aff_add_piece
Line
Count
Source
66
176k
{
67
176k
  isl_ctx *ctx;
68
176k
  isl_space *el_dim = NULL;
69
176k
70
176k
  if (
!pw || 176k
!set176k
||
!el176k
)
71
0
    goto error;
72
176k
73
176k
  
if (176k
isl_set_plain_is_empty(set) || 176k
FN176k
(EL,EL_IS_ZERO)(el)176k
)
{87
74
87
    isl_set_free(set);
75
87
    FN(EL,free)(el);
76
87
    return pw;
77
87
  }
78
176k
79
176k
  ctx = isl_set_get_ctx(set);
80
176k
#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
176k
  el_dim = FN(EL,get_space(el));
86
176k
  isl_assert(ctx, isl_space_is_equal(pw->dim, el_dim), goto error);
87
176k
  
isl_assert176k
(ctx, pw->n < pw->size, goto error);176k
88
176k
89
176k
  pw->p[pw->n].set = set;
90
176k
  pw->p[pw->n].FIELD = el;
91
176k
  pw->n++;
92
176k
  
93
176k
  isl_space_free(el_dim);
94
176k
  return pw;
95
0
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
0
  return NULL;
101
176k
}
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
77.2k
{
110
77.2k
  PW *pw;
111
77.2k
112
77.2k
  if (
!set || 77.2k
!el77.2k
)
113
0
    goto error;
114
77.2k
115
77.2k
#ifdef HAS_TYPE
116
12
  
pw = 12
FN12
(PW,alloc_size)(
FN12
(EL,get_space)(el), type, 1);
117
12
#else
118
77.1k
  
pw = 77.1k
FN77.1k
(PW,alloc_size)(
FN77.1k
(EL,get_space)(el), 1);
119
77.1k
#endif
120
77.1k
121
77.2k
  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
65.0k
{
110
65.0k
  PW *pw;
111
65.0k
112
65.0k
  if (
!set || 65.0k
!el65.0k
)
113
0
    goto error;
114
65.0k
115
65.0k
#ifdef HAS_TYPE
116
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
117
#else
118
65.0k
  
pw = 65.0k
FN65.0k
(PW,alloc_size)(
FN65.0k
(EL,get_space)(el), 1);
119
65.0k
#endif
120
65.0k
121
65.0k
  return FN(PW,add_piece)(pw, set, el);
122
0
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
0
  return NULL;
126
65.0k
}
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
0
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
0
  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
0
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
0
  return NULL;
126
12
}
isl_pw_multi_aff_alloc
Line
Count
Source
109
12.0k
{
110
12.0k
  PW *pw;
111
12.0k
112
12.0k
  if (
!set || 12.0k
!el12.0k
)
113
0
    goto error;
114
12.0k
115
12.0k
#ifdef HAS_TYPE
116
  pw = FN(PW,alloc_size)(FN(EL,get_space)(el), type, 1);
117
#else
118
12.0k
  
pw = 12.0k
FN12.0k
(PW,alloc_size)(
FN12.0k
(EL,get_space)(el), 1);
119
12.0k
#endif
120
12.0k
121
12.0k
  return FN(PW,add_piece)(pw, set, el);
122
0
error:
123
0
  isl_set_free(set);
124
0
  FN(EL,free)(el);
125
0
  return NULL;
126
12.0k
}
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
37.0k
{
130
37.0k
  int i;
131
37.0k
  PW *dup;
132
37.0k
133
37.0k
  if (!pw)
134
0
    return NULL;
135
37.0k
136
37.0k
#ifdef HAS_TYPE
137
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
138
#else
139
37.0k
  
dup = 37.0k
FN37.0k
(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
140
37.0k
#endif
141
37.0k
  if (!dup)
142
0
    return NULL;
143
37.0k
144
75.2k
  
for (i = 0; 37.0k
i < pw->n75.2k
;
++i38.1k
)
145
38.1k
    
dup = 38.1k
FN38.1k
(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
146
38.1k
              
FN38.1k
(EL,copy)(pw->p[i].
FIELD38.1k
));
147
37.0k
148
37.0k
  return dup;
149
37.0k
}
Unexecuted instantiation: isl_pw_qpolynomial_fold_dup
isl_pw_multi_aff_dup
Line
Count
Source
129
66
{
130
66
  int i;
131
66
  PW *dup;
132
66
133
66
  if (!pw)
134
0
    return NULL;
135
66
136
66
#ifdef HAS_TYPE
137
  dup = FN(PW,alloc_size)(isl_space_copy(pw->dim), pw->type, pw->n);
138
#else
139
66
  
dup = 66
FN66
(PW,alloc_size)(isl_space_copy(pw->dim), pw->n);
140
66
#endif
141
66
  if (!dup)
142
0
    return NULL;
143
66
144
133
  
for (i = 0; 66
i < pw->n133
;
++i67
)
145
67
    
dup = 67
FN67
(PW,add_piece)(dup, isl_set_copy(pw->p[i].set),
146
67
              
FN67
(EL,copy)(pw->p[i].
FIELD67
));
147
66
148
66
  return dup;
149
66
}
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
6
{
153
6
  if (!pw)
154
0
    return NULL;
155
6
156
6
  
if (6
pw->ref == 16
)
157
6
    return pw;
158
0
  pw->ref--;
159
0
  return FN(PW,dup)(pw);
160
6
}
isl_pw_multi_aff_cow
Line
Count
Source
152
5.14k
{
153
5.14k
  if (!pw)
154
0
    return NULL;
155
5.14k
156
5.14k
  
if (5.14k
pw->ref == 15.14k
)
157
5.07k
    return pw;
158
66
  pw->ref--;
159
66
  return FN(PW,dup)(pw);
160
5.14k
}
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
1
  pw->ref--;
159
1
  return FN(PW,dup)(pw);
160
51
}
isl_pw_aff_cow
Line
Count
Source
152
116k
{
153
116k
  if (!pw)
154
0
    return NULL;
155
116k
156
116k
  
if (116k
pw->ref == 1116k
)
157
79.6k
    return pw;
158
37.0k
  pw->ref--;
159
37.0k
  return FN(PW,dup)(pw);
160
116k
}
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
135k
{
164
135k
  if (!pw)
165
16.3k
    return NULL;
166
135k
167
119k
  pw->ref++;
168
119k
  return pw;
169
135k
}
isl_pw_multi_aff_copy
Line
Count
Source
163
16.6k
{
164
16.6k
  if (!pw)
165
0
    return NULL;
166
16.6k
167
16.6k
  pw->ref++;
168
16.6k
  return pw;
169
16.6k
}
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
18
  }
184
35
  isl_space_free(pw->dim);
185
35
  free(pw);
186
35
187
35
  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
98
  }
184
104
  isl_space_free(pw->dim);
185
104
  free(pw);
186
104
187
104
  return NULL;
188
113
}
isl_pw_aff_free
Line
Count
Source
172
288k
{
173
288k
  int i;
174
288k
175
288k
  if (!pw)
176
30.1k
    return NULL;
177
258k
  
if (258k
--pw->ref > 0258k
)
178
82.3k
    return NULL;
179
258k
180
352k
  
for (i = 0; 175k
i < pw->n352k
;
++i176k
)
{176k
181
176k
    isl_set_free(pw->p[i].set);
182
176k
    
FN176k
(EL,free)(pw->p[i].
FIELD176k
);
183
176k
  }
184
175k
  isl_space_free(pw->dim);
185
175k
  free(pw);
186
175k
187
175k
  return NULL;
188
258k
}
isl_pw_multi_aff_free
Line
Count
Source
172
31.9k
{
173
31.9k
  int i;
174
31.9k
175
31.9k
  if (!pw)
176
0
    return NULL;
177
31.9k
  
if (31.9k
--pw->ref > 031.9k
)
178
16.5k
    return NULL;
179
31.9k
180
29.5k
  
for (i = 0; 15.3k
i < pw->n29.5k
;
++i14.1k
)
{14.1k
181
14.1k
    isl_set_free(pw->p[i].set);
182
14.1k
    
FN14.1k
(EL,free)(pw->p[i].
FIELD14.1k
);
183
14.1k
  }
184
15.3k
  isl_space_free(pw->dim);
185
15.3k
  free(pw);
186
15.3k
187
15.3k
  return NULL;
188
31.9k
}
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
Unexecuted instantiation: isl_pw_aff_get_dim_id
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
11.6k
{
230
11.6k
  if (!pw)
231
0
    return isl_bool_error;
232
11.6k
233
11.6k
  return pw->n == 0;
234
11.6k
}
isl_pw_aff_is_empty
Line
Count
Source
229
28.2k
{
230
28.2k
  if (!pw)
231
0
    return isl_bool_error;
232
28.2k
233
28.2k
  return pw->n == 0;
234
28.2k
}
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
7.25k
{
240
7.25k
  int i;
241
7.25k
242
7.25k
  pw = FN(PW,cow)(pw);
243
7.25k
  if (
!pw || 7.25k
!exp7.25k
)
244
0
    goto error;
245
7.25k
246
14.8k
  
for (i = 0; 7.25k
i < pw->n14.8k
;
++i7.62k
)
{7.62k
247
7.62k
    pw->p[i].set = isl_set_realign(pw->p[i].set,
248
7.62k
                isl_reordering_copy(exp));
249
7.62k
    if (!pw->p[i].set)
250
0
      goto error;
251
7.62k
    
pw->p[i].7.62k
FIELD7.62k
=
FN7.62k
(EL,realign_domain)(pw->p[i].
FIELD7.62k
,
252
7.62k
                isl_reordering_copy(exp));
253
7.62k
    if (
!pw->p[i].7.62k
FIELD7.62k
)
254
0
      goto error;
255
7.62k
  }
256
7.25k
257
7.25k
  
pw = 7.25k
FN7.25k
(PW,reset_domain_space)(pw, isl_space_copy(exp->dim));
258
7.25k
259
7.25k
  isl_reordering_free(exp);
260
7.25k
  return pw;
261
0
error:
262
0
  isl_reordering_free(exp);
263
0
  FN(PW,free)(pw);
264
0
  return NULL;
265
7.25k
}
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
0
  }
299
5
300
5
  isl_space_free(model);
301
5
  return pw;
302
0
error:
303
0
  isl_space_free(model);
304
0
  FN(PW,free)(pw);
305
0
  return NULL;
306
5
}
isl_pw_aff_align_params
Line
Count
Source
270
12.3k
{
271
12.3k
  isl_ctx *ctx;
272
12.3k
  isl_bool equal_params;
273
12.3k
274
12.3k
  if (
!pw || 12.3k
!model12.3k
)
275
0
    goto error;
276
12.3k
277
12.3k
  ctx = isl_space_get_ctx(model);
278
12.3k
  if (!isl_space_has_named_params(model))
279
0
    isl_die(ctx, isl_error_invalid,
280
12.3k
      "model has unnamed parameters", goto error);
281
12.3k
  
if (12.3k
!isl_space_has_named_params(pw->dim)12.3k
)
282
0
    isl_die(ctx, isl_error_invalid,
283
12.3k
      "input has unnamed parameters", goto error);
284
12.3k
  equal_params = isl_space_has_equal_params(pw->dim, model);
285
12.3k
  if (equal_params < 0)
286
0
    goto error;
287
12.3k
  
if (12.3k
!equal_params12.3k
)
{7.10k
288
7.10k
    isl_reordering *exp;
289
7.10k
290
7.10k
    model = isl_space_drop_dims(model, isl_dim_in,
291
7.10k
          0, isl_space_dim(model, isl_dim_in));
292
7.10k
    model = isl_space_drop_dims(model, isl_dim_out,
293
7.10k
          0, isl_space_dim(model, isl_dim_out));
294
7.10k
    exp = isl_parameter_alignment_reordering(pw->dim, model);
295
7.10k
    exp = isl_reordering_extend_space(exp,
296
7.10k
          FN(PW,get_domain_space)(pw));
297
7.10k
    pw = FN(PW,realign_domain)(pw, exp);
298
7.10k
  }
299
12.3k
300
12.3k
  isl_space_free(model);
301
12.3k
  return pw;
302
0
error:
303
0
  isl_space_free(model);
304
0
  FN(PW,free)(pw);
305
0
  return NULL;
306
12.3k
}
isl_pw_multi_aff_align_params
Line
Count
Source
270
9.45k
{
271
9.45k
  isl_ctx *ctx;
272
9.45k
  isl_bool equal_params;
273
9.45k
274
9.45k
  if (
!pw || 9.45k
!model9.45k
)
275
0
    goto error;
276
9.45k
277
9.45k
  ctx = isl_space_get_ctx(model);
278
9.45k
  if (!isl_space_has_named_params(model))
279
0
    isl_die(ctx, isl_error_invalid,
280
9.45k
      "model has unnamed parameters", goto error);
281
9.45k
  
if (9.45k
!isl_space_has_named_params(pw->dim)9.45k
)
282
0
    isl_die(ctx, isl_error_invalid,
283
9.45k
      "input has unnamed parameters", goto error);
284
9.45k
  equal_params = isl_space_has_equal_params(pw->dim, model);
285
9.45k
  if (equal_params < 0)
286
0
    goto error;
287
9.45k
  
if (9.45k
!equal_params9.45k
)
{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
0
  }
299
9.45k
300
9.45k
  isl_space_free(model);
301
9.45k
  return pw;
302
0
error:
303
0
  isl_space_free(model);
304
0
  FN(PW,free)(pw);
305
0
  return NULL;
306
9.45k
}
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
2.62k
{
312
2.62k
  isl_ctx *ctx;
313
2.62k
  isl_bool equal_params;
314
2.62k
315
2.62k
  if (
!pw1 || 2.62k
!pw22.62k
)
316
0
    goto error;
317
2.62k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
318
2.62k
  if (equal_params < 0)
319
0
    goto error;
320
2.62k
  
if (2.62k
equal_params2.62k
)
321
2.62k
    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
0
}
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
0
}
isl_aff.c:isl_pw_aff_align_params_pw_pw_and
Line
Count
Source
311
67.0k
{
312
67.0k
  isl_ctx *ctx;
313
67.0k
  isl_bool equal_params;
314
67.0k
315
67.0k
  if (
!pw1 || 67.0k
!pw267.0k
)
316
1
    goto error;
317
67.0k
  equal_params = isl_space_has_equal_params(pw1->dim, pw2->dim);
318
67.0k
  if (equal_params < 0)
319
0
    goto error;
320
67.0k
  
if (67.0k
equal_params67.0k
)
321
64.4k
    return fn(pw1, pw2);
322
2.69k
  
ctx = 2.69k
FN2.69k
(PW,get_ctx)(pw1);
323
2.69k
  if (!isl_space_has_named_params(pw1->dim) ||
324
2.69k
      !isl_space_has_named_params(pw2->dim))
325
0
    isl_die(ctx, isl_error_invalid,
326
2.69k
      "unaligned unnamed parameters", goto error);
327
2.69k
  
pw1 = 2.69k
FN2.69k
(PW,align_params)(pw1,
FN2.69k
(PW,get_space)(pw2));
328
2.69k
  pw2 = 
FN2.69k
(PW,align_params)(pw2,
FN2.69k
(PW,get_space)(pw1));
329
2.69k
  return fn(pw1, pw2);
330
1
error:
331
1
  FN(PW,free)(pw1);
332
1
  FN(PW,free)(pw2);
333
1
  return NULL;
334
2.69k
}
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
2.35k
{
340
2.35k
  isl_ctx *ctx;
341
2.35k
  isl_bool aligned;
342
2.35k
343
2.35k
  if (
!pw || 2.35k
!set2.35k
)
344
0
    goto error;
345
2.35k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
346
2.35k
  if (aligned < 0)
347
0
    goto error;
348
2.35k
  
if (2.35k
aligned2.35k
)
349
2.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
0
}
isl_aff.c:isl_pw_aff_align_params_pw_set_and
Line
Count
Source
339
35.6k
{
340
35.6k
  isl_ctx *ctx;
341
35.6k
  isl_bool aligned;
342
35.6k
343
35.6k
  if (
!pw || 35.6k
!set35.6k
)
344
0
    goto error;
345
35.6k
  aligned = isl_set_space_has_equal_params(set, pw->dim);
346
35.6k
  if (aligned < 0)
347
0
    goto error;
348
35.6k
  
if (35.6k
aligned35.6k
)
349
35.6k
    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
0
error:
359
0
  FN(PW,free)(pw);
360
0
  isl_set_free(set);
361
0
  return NULL;
362
2
}
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
0
}
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
0
  }
388
24
389
24
  
if (24
FN24
(PW,IS_ZERO)(pw2)24
)
{0
390
0
    FN(PW,free)(pw2);
391
0
    return pw1;
392
0
  }
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
5
      }
412
22
      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
22
    }
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
0
error:
437
0
  FN(PW,free)(pw1);
438
0
  FN(PW,free)(pw2);
439
0
  return NULL;
440
24
}
isl_aff.c:isl_pw_aff_union_add_aligned
Line
Count
Source
367
2.47k
{
368
2.47k
  int i, j, n;
369
2.47k
  struct PW *res;
370
2.47k
  isl_ctx *ctx;
371
2.47k
  isl_set *set;
372
2.47k
373
2.47k
  if (
!pw1 || 2.47k
!pw22.47k
)
374
0
    goto error;
375
2.47k
376
2.47k
  ctx = isl_space_get_ctx(pw1->dim);
377
2.47k
#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.47k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
383
2.47k
384
2.47k
  
if (2.47k
FN2.47k
(PW,IS_ZERO)(pw1)2.47k
)
{2.44k
385
2.44k
    FN(PW,free)(pw1);
386
2.44k
    return pw2;
387
2.44k
  }
388
2.47k
389
23
  
if (23
FN23
(PW,IS_ZERO)(pw2)23
)
{0
390
0
    FN(PW,free)(pw2);
391
0
    return pw1;
392
0
  }
393
23
394
23
  n = (pw1->n + 1) * (pw2->n + 1);
395
23
#ifdef HAS_TYPE
396
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
397
#else
398
23
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
399
23
#endif
400
23
401
46
  for (i = 0; 
i < pw1->n46
;
++i23
)
{23
402
23
    set = isl_set_copy(pw1->p[i].set);
403
46
    for (j = 0; 
j < pw2->n46
;
++j23
)
{23
404
23
      struct isl_set *common;
405
23
      EL *sum;
406
23
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
407
23
            isl_set_copy(pw2->p[j].set));
408
23
      if (
isl_set_plain_is_empty(common)23
)
{23
409
23
        isl_set_free(common);
410
23
        continue;
411
23
      }
412
0
      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
0
    }
421
23
    res = 
FN23
(PW,add_piece)(res, set,
FN23
(EL,copy)(pw1->p[i].
FIELD23
));
422
23
  }
423
23
424
46
  for (j = 0; 
j < pw2->n46
;
++j23
)
{23
425
23
    set = isl_set_copy(pw2->p[j].set);
426
46
    for (i = 0; 
i < pw1->n46
;
++i23
)
427
23
      set = isl_set_subtract(set,
428
23
          isl_set_copy(pw1->p[i].set));
429
23
    res = 
FN23
(PW,add_piece)(res, set,
FN23
(EL,copy)(pw2->p[j].
FIELD23
));
430
23
  }
431
23
432
23
  FN(PW,free)(pw1);
433
23
  FN(PW,free)(pw2);
434
23
435
23
  return res;
436
0
error:
437
0
  FN(PW,free)(pw1);
438
0
  FN(PW,free)(pw2);
439
0
  return NULL;
440
23
}
isl_aff.c:isl_pw_multi_aff_union_add_aligned
Line
Count
Source
367
338
{
368
338
  int i, j, n;
369
338
  struct PW *res;
370
338
  isl_ctx *ctx;
371
338
  isl_set *set;
372
338
373
338
  if (
!pw1 || 338
!pw2338
)
374
0
    goto error;
375
338
376
338
  ctx = isl_space_get_ctx(pw1->dim);
377
338
#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
338
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
383
338
384
338
  
if (338
FN338
(PW,IS_ZERO)(pw1)338
)
{35
385
35
    FN(PW,free)(pw1);
386
35
    return pw2;
387
35
  }
388
338
389
303
  
if (303
FN303
(PW,IS_ZERO)(pw2)303
)
{280
390
280
    FN(PW,free)(pw2);
391
280
    return pw1;
392
280
  }
393
303
394
23
  n = (pw1->n + 1) * (pw2->n + 1);
395
23
#ifdef HAS_TYPE
396
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), pw1->type, n);
397
#else
398
23
  res = FN(PW,alloc_size)(isl_space_copy(pw1->dim), n);
399
23
#endif
400
23
401
63
  for (i = 0; 
i < pw1->n63
;
++i40
)
{40
402
40
    set = isl_set_copy(pw1->p[i].set);
403
80
    for (j = 0; 
j < pw2->n80
;
++j40
)
{40
404
40
      struct isl_set *common;
405
40
      EL *sum;
406
40
      common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
407
40
            isl_set_copy(pw2->p[j].set));
408
40
      if (
isl_set_plain_is_empty(common)40
)
{38
409
38
        isl_set_free(common);
410
38
        continue;
411
38
      }
412
2
      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
2
    }
421
40
    res = 
FN40
(PW,add_piece)(res, set,
FN40
(EL,copy)(pw1->p[i].
FIELD40
));
422
40
  }
423
23
424
46
  for (j = 0; 
j < pw2->n46
;
++j23
)
{23
425
23
    set = isl_set_copy(pw2->p[j].set);
426
63
    for (i = 0; 
i < pw1->n63
;
++i40
)
427
40
      set = isl_set_subtract(set,
428
40
          isl_set_copy(pw1->p[i].set));
429
23
    res = 
FN23
(PW,add_piece)(res, set,
FN23
(EL,copy)(pw2->p[j].
FIELD23
));
430
23
  }
431
23
432
23
  FN(PW,free)(pw1);
433
23
  FN(PW,free)(pw2);
434
23
435
23
  return res;
436
0
error:
437
0
  FN(PW,free)(pw1);
438
0
  FN(PW,free)(pw2);
439
0
  return NULL;
440
303
}
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.47k
{
447
2.47k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
448
2.47k
            &FN(PW,union_add_aligned));
449
2.47k
}
isl_aff.c:isl_pw_multi_aff_union_add_
Line
Count
Source
446
338
{
447
338
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
448
338
            &FN(PW,union_add_aligned));
449
338
}
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
0
}
isl_aff.c:isl_pw_multi_aff_grow
Line
Count
Source
457
43
{
458
43
  int i;
459
43
  isl_ctx *ctx;
460
43
  PW *res;
461
43
462
43
  if (!pw)
463
0
    return NULL;
464
43
  
if (43
pw->n + n <= pw->size43
)
465
0
    return pw;
466
43
  
ctx = 43
FN43
(PW,get_ctx)(pw);
467
43
  n += pw->n;
468
43
  if (
pw->ref == 143
)
{43
469
43
    res = isl_realloc(ctx, pw, struct PW,
470
43
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
471
43
    if (!res)
472
0
      
return 0
FN0
(PW,free)(pw);
473
43
    res->size = n;
474
43
    return res;
475
43
  }
476
43
#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
0
}
isl_aff.c:isl_pw_aff_grow
Line
Count
Source
457
168
{
458
168
  int i;
459
168
  isl_ctx *ctx;
460
168
  PW *res;
461
168
462
168
  if (!pw)
463
0
    return NULL;
464
168
  
if (168
pw->n + n <= pw->size168
)
465
0
    return pw;
466
168
  
ctx = 168
FN168
(PW,get_ctx)(pw);
467
168
  n += pw->n;
468
168
  if (
pw->ref == 1168
)
{168
469
168
    res = isl_realloc(ctx, pw, struct PW,
470
168
          sizeof(struct PW) + (n - 1) * sizeof(S(PW,piece)));
471
168
    if (!res)
472
0
      
return 0
FN0
(PW,free)(pw);
473
168
    res->size = n;
474
168
    return res;
475
168
  }
476
168
#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
0
}
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
596
{
493
596
  int i;
494
596
  isl_ctx *ctx;
495
596
496
596
  if (
!pw1 || 596
!pw2596
)
497
0
    goto error;
498
596
499
596
  
if (596
pw1->size < pw1->n + pw2->n && 596
pw1->n < pw2->n354
)
500
186
    
return 186
FN186
(PW,add_disjoint_aligned)(pw2, pw1);
501
596
502
410
  ctx = isl_space_get_ctx(pw1->dim);
503
410
#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
410
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
509
410
510
410
  
if (410
FN410
(PW,IS_ZERO)(pw1)410
)
{34
511
34
    FN(PW,free)(pw1);
512
34
    return pw2;
513
34
  }
514
410
515
376
  
if (376
FN376
(PW,IS_ZERO)(pw2)376
)
{208
516
208
    FN(PW,free)(pw2);
517
208
    return pw1;
518
208
  }
519
376
520
168
  
pw1 = 168
FN168
(PW,grow)(pw1, pw2->n);
521
168
  if (!pw1)
522
0
    goto error;
523
168
524
336
  
for (i = 0; 168
i < pw2->n336
;
++i168
)
525
168
    
pw1 = 168
FN168
(PW,add_piece)(pw1,
526
168
        isl_set_copy(pw2->p[i].set),
527
168
        
FN168
(EL,copy)(pw2->p[i].
FIELD168
));
528
168
529
168
  FN(PW,free)(pw2);
530
168
531
168
  return pw1;
532
0
error:
533
0
  FN(PW,free)(pw1);
534
0
  FN(PW,free)(pw2);
535
0
  return NULL;
536
168
}
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
2
  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
0
  }
514
2
515
2
  
if (2
FN2
(PW,IS_ZERO)(pw2)2
)
{1
516
1
    FN(PW,free)(pw2);
517
1
    return pw1;
518
1
  }
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
0
error:
533
0
  FN(PW,free)(pw1);
534
0
  FN(PW,free)(pw2);
535
0
  return NULL;
536
1
}
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
2.97k
{
493
2.97k
  int i;
494
2.97k
  isl_ctx *ctx;
495
2.97k
496
2.97k
  if (
!pw1 || 2.97k
!pw22.97k
)
497
0
    goto error;
498
2.97k
499
2.97k
  
if (2.97k
pw1->size < pw1->n + pw2->n && 2.97k
pw1->n < pw2->n1.51k
)
500
1.46k
    
return 1.46k
FN1.46k
(PW,add_disjoint_aligned)(pw2, pw1);
501
2.97k
502
1.51k
  ctx = isl_space_get_ctx(pw1->dim);
503
1.51k
#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.51k
  isl_assert(ctx, isl_space_is_equal(pw1->dim, pw2->dim), goto error);
509
1.51k
510
1.51k
  
if (1.51k
FN1.51k
(PW,IS_ZERO)(pw1)1.51k
)
{0
511
0
    FN(PW,free)(pw1);
512
0
    return pw2;
513
0
  }
514
1.51k
515
1.51k
  
if (1.51k
FN1.51k
(PW,IS_ZERO)(pw2)1.51k
)
{1.46k
516
1.46k
    FN(PW,free)(pw2);
517
1.46k
    return pw1;
518
1.46k
  }
519
1.51k
520
43
  
pw1 = 43
FN43
(PW,grow)(pw1, pw2->n);
521
43
  if (!pw1)
522
0
    goto error;
523
43
524
86
  
for (i = 0; 43
i < pw2->n86
;
++i43
)
525
43
    
pw1 = 43
FN43
(PW,add_piece)(pw1,
526
43
        isl_set_copy(pw2->p[i].set),
527
43
        
FN43
(EL,copy)(pw2->p[i].
FIELD43
));
528
43
529
43
  FN(PW,free)(pw2);
530
43
531
43
  return pw1;
532
0
error:
533
0
  FN(PW,free)(pw1);
534
0
  FN(PW,free)(pw2);
535
0
  return NULL;
536
43
}
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
410
{
540
410
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
541
410
            &FN(PW,add_disjoint_aligned));
542
410
}
isl_pw_multi_aff_add_disjoint
Line
Count
Source
539
1.51k
{
540
1.51k
  return FN(PW,align_params_pw_pw_and)(pw1, pw2,
541
1.51k
            &FN(PW,add_disjoint_aligned));
542
1.51k
}
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
154
{
558
154
  int i, j, n;
559
154
  PW *res = NULL;
560
154
561
154
  if (
!pw1 || 154
!pw2154
)
562
0
    goto error;
563
154
564
154
  n = pw1->n * pw2->n;
565
154
#ifdef HAS_TYPE
566
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
567
#else
568
154
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
569
154
#endif
570
154
571
308
  for (i = 0; 
i < pw1->n308
;
++i154
)
{154
572
311
    for (j = 0; 
j < pw2->n311
;
++j157
)
{157
573
157
      isl_set *common;
574
157
      EL *res_ij;
575
157
      int empty;
576
157
577
157
      common = isl_set_intersect(
578
157
          isl_set_copy(pw1->p[i].set),
579
157
          isl_set_copy(pw2->p[j].set));
580
157
      empty = isl_set_plain_is_empty(common);
581
157
      if (
empty < 0 || 157
empty157
)
{0
582
0
        isl_set_free(common);
583
0
        if (empty < 0)
584
0
          goto error;
585
0
        continue;
586
0
      }
587
157
588
157
      
res_ij = fn(157
FN157
(EL,copy)(pw1->p[i].
FIELD157
),
589
157
            
FN157
(EL,copy)(pw2->p[j].
FIELD157
));
590
157
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
591
157
592
157
      res = FN(PW,add_piece)(res, common, res_ij);
593
157
    }
594
154
  }
595
154
596
154
  isl_space_free(space);
597
154
  FN(PW,free)(pw1);
598
154
  FN(PW,free)(pw2);
599
154
  return res;
600
0
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
0
  return NULL;
606
154
}
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
64.0k
{
558
64.0k
  int i, j, n;
559
64.0k
  PW *res = NULL;
560
64.0k
561
64.0k
  if (
!pw1 || 64.0k
!pw264.0k
)
562
0
    goto error;
563
64.0k
564
64.0k
  n = pw1->n * pw2->n;
565
64.0k
#ifdef HAS_TYPE
566
  res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
567
#else
568
64.0k
  res = FN(PW,alloc_size)(isl_space_copy(space), n);
569
64.0k
#endif
570
64.0k
571
130k
  for (i = 0; 
i < pw1->n130k
;
++i66.0k
)
{66.0k
572
135k
    for (j = 0; 
j < pw2->n135k
;
++j69.0k
)
{69.0k
573
69.0k
      isl_set *common;
574
69.0k
      EL *res_ij;
575
69.0k
      int empty;
576
69.0k
577
69.0k
      common = isl_set_intersect(
578
69.0k
          isl_set_copy(pw1->p[i].set),
579
69.0k
          isl_set_copy(pw2->p[j].set));
580
69.0k
      empty = isl_set_plain_is_empty(common);
581
69.0k
      if (
empty < 0 || 69.0k
empty69.0k
)
{2.78k
582
2.78k
        isl_set_free(common);
583
2.78k
        if (empty < 0)
584
0
          goto error;
585
2.78k
        continue;
586
2.78k
      }
587
69.0k
588
66.2k
      
res_ij = fn(66.2k
FN66.2k
(EL,copy)(pw1->p[i].
FIELD66.2k
),
589
66.2k
            
FN66.2k
(EL,copy)(pw2->p[j].
FIELD66.2k
));
590
66.2k
      res_ij = FN(EL,gist)(res_ij, isl_set_copy(common));
591
66.2k
592
66.2k
      res = FN(PW,add_piece)(res, common, res_ij);
593
66.2k
    }
594
66.0k
  }
595
64.0k
596
64.0k
  isl_space_free(space);
597
64.0k
  FN(PW,free)(pw1);
598
64.0k
  FN(PW,free)(pw2);
599
64.0k
  return res;
600
0
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
0
  return NULL;
606
64.0k
}
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
64.0k
{
622
64.0k
  isl_space *space;
623
64.0k
624
64.0k
  if (
!pw1 || 64.0k
!pw264.0k
)
625
0
    goto error;
626
64.0k
627
64.0k
  space = isl_space_copy(pw1->dim);
628
64.0k
  return FN(PW,on_shared_domain_in)(pw1, pw2, space, fn);
629
0
error:
630
0
  FN(PW,free)(pw1);
631
0
  FN(PW,free)(pw2);
632
0
  return NULL;
633
64.0k
}
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
0
error:
630
0
  FN(PW,free)(pw1);
631
0
  FN(PW,free)(pw2);
632
0
  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
20.5k
{
638
20.5k
  int i;
639
20.5k
640
20.5k
  if (!pw)
641
0
    return NULL;
642
20.5k
643
20.5k
  
if (20.5k
FN20.5k
(PW,IS_ZERO)(pw)20.5k
)
644
0
    return pw;
645
20.5k
646
20.5k
  
pw = 20.5k
FN20.5k
(PW,cow)(pw);
647
20.5k
  if (!pw)
648
0
    return NULL;
649
20.5k
650
41.8k
  
for (i = 0; 20.5k
i < pw->n41.8k
;
++i21.2k
)
{21.2k
651
21.2k
    pw->p[i].
FIELD21.2k
=
FN21.2k
(EL,neg)(pw->p[i].
FIELD21.2k
);
652
21.2k
    if (
!pw->p[i].21.2k
FIELD21.2k
)
653
0
      
return 0
FN0
(PW,free)(pw);
654
21.2k
  }
655
20.5k
656
20.5k
  return pw;
657
20.5k
}
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.08k
{
663
6.08k
  return 
FN6.08k
(PW,add)(pw1,
FN6.08k
(PW,neg)(pw2));
664
6.08k
}
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
0
error:
700
0
  FN(PW,free)(pw);
701
0
  isl_space_free(pnt_dim);
702
0
  isl_point_free(pnt);
703
0
  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
15
{
716
15
  int i;
717
15
  isl_set *dom;
718
15
719
15
  if (!pw)
720
0
    return NULL;
721
15
722
15
  
dom = isl_set_empty(15
FN15
(PW,get_domain_space)(pw));
723
31
  for (i = 0; 
i < pw->n31
;
++i16
)
724
16
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
725
15
726
15
  FN(PW,free)(pw);
727
15
728
15
  return dom;
729
15
}
isl_pw_aff_domain
Line
Count
Source
715
40.6k
{
716
40.6k
  int i;
717
40.6k
  isl_set *dom;
718
40.6k
719
40.6k
  if (!pw)
720
0
    return NULL;
721
40.6k
722
40.6k
  
dom = isl_set_empty(40.6k
FN40.6k
(PW,get_domain_space)(pw));
723
82.6k
  for (i = 0; 
i < pw->n82.6k
;
++i41.9k
)
724
41.9k
    dom = isl_set_union_disjoint(dom, isl_set_copy(pw->p[i].set));
725
40.6k
726
40.6k
  FN(PW,free)(pw);
727
40.6k
728
40.6k
  return dom;
729
40.6k
}
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
0
  }
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.22k
{
739
1.22k
  isl_basic_set *aff;
740
1.22k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
741
1.22k
742
1.22k
  if (empty < 0)
743
0
    return -1;
744
1.22k
  
if (1.22k
empty1.22k
)
{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
  }
753
1.22k
754
1.22k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
755
1.22k
  pw->p[i].
FIELD1.22k
=
FN1.22k
(EL,substitute_equalities)(pw->p[i].
FIELD1.22k
, aff);
756
1.22k
  if (
!pw->p[i].1.22k
FIELD1.22k
)
757
0
    return -1;
758
1.22k
759
1.22k
  return 0;
760
1.22k
}
isl_aff.c:isl_pw_aff_exploit_equalities_and_remove_if_empty
Line
Count
Source
738
30.8k
{
739
30.8k
  isl_basic_set *aff;
740
30.8k
  int empty = isl_set_plain_is_empty(pw->p[i].set);
741
30.8k
742
30.8k
  if (empty < 0)
743
0
    return -1;
744
30.8k
  
if (30.8k
empty30.8k
)
{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
20
  }
753
30.8k
754
30.7k
  aff = isl_set_affine_hull(isl_set_copy(pw->p[i].set));
755
30.7k
  pw->p[i].
FIELD30.7k
=
FN30.7k
(EL,substitute_equalities)(pw->p[i].
FIELD30.7k
, aff);
756
30.7k
  if (
!pw->p[i].30.7k
FIELD30.7k
)
757
0
    return -1;
758
30.7k
759
30.7k
  return 0;
760
30.7k
}
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
1
  }
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
0
error:
848
0
  isl_set_free(set);
849
0
  FN(PW,free)(pw);
850
0
  return NULL;
851
34
}
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.22k
{
825
1.22k
  int i;
826
1.22k
827
1.22k
  if (
!pw || 1.22k
!set1.22k
)
828
0
    goto error;
829
1.22k
830
1.22k
  
if (1.22k
pw->n == 01.22k
)
{0
831
0
    isl_set_free(set);
832
0
    return pw;
833
0
  }
834
1.22k
835
1.22k
  
pw = 1.22k
FN1.22k
(PW,cow)(pw);
836
1.22k
  if (!pw)
837
0
    goto error;
838
1.22k
839
2.44k
  
for (i = pw->n - 1; 1.22k
i >= 02.44k
;
--i1.22k
)
{1.22k
840
1.22k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
841
1.22k
    if (
FN1.22k
(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 01.22k
)
842
0
      goto error;
843
1.22k
  }
844
1.22k
  
845
1.22k
  isl_set_free(set);
846
1.22k
  return pw;
847
0
error:
848
0
  isl_set_free(set);
849
0
  FN(PW,free)(pw);
850
0
  return NULL;
851
1.22k
}
isl_aff.c:isl_pw_aff_restrict_domain_aligned
Line
Count
Source
824
29.7k
{
825
29.7k
  int i;
826
29.7k
827
29.7k
  if (
!pw || 29.7k
!set29.7k
)
828
0
    goto error;
829
29.7k
830
29.7k
  
if (29.7k
pw->n == 029.7k
)
{0
831
0
    isl_set_free(set);
832
0
    return pw;
833
0
  }
834
29.7k
835
29.7k
  
pw = 29.7k
FN29.7k
(PW,cow)(pw);
836
29.7k
  if (!pw)
837
0
    goto error;
838
29.7k
839
60.5k
  
for (i = pw->n - 1; 29.7k
i >= 060.5k
;
--i30.8k
)
{30.8k
840
30.8k
    pw->p[i].set = fn(pw->p[i].set, isl_set_copy(set));
841
30.8k
    if (
FN30.8k
(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 030.8k
)
842
0
      goto error;
843
30.8k
  }
844
29.7k
  
845
29.7k
  isl_set_free(set);
846
29.7k
  return pw;
847
0
error:
848
0
  isl_set_free(set);
849
0
  FN(PW,free)(pw);
850
0
  return NULL;
851
29.7k
}
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.21k
{
856
1.21k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
857
1.21k
}
isl_aff.c:isl_pw_aff_intersect_domain_aligned
Line
Count
Source
855
29.7k
{
856
29.7k
  return FN(PW,restrict_domain_aligned)(pw, set, &isl_set_intersect);
857
29.7k
}
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.21k
{
862
1.21k
  return FN(PW,align_params_pw_set_and)(pw, context,
863
1.21k
          &FN(PW,intersect_domain_aligned));
864
1.21k
}
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
29.7k
{
862
29.7k
  return FN(PW,align_params_pw_set_and)(pw, context,
863
29.7k
          &FN(PW,intersect_domain_aligned));
864
29.7k
}
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
3.42k
{
911
3.42k
  int i;
912
3.42k
  isl_space *space;
913
3.42k
914
3.42k
  for (i = 0; 
i < pw->n - 13.42k
;
++i0
)
{0
915
0
    isl_set_free(pw->p[i].set);
916
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
917
0
  }
918
3.42k
  pw->p[0].
FIELD3.42k
= pw->p[pw->n - 1].
FIELD3.42k
;
919
3.42k
  pw->p[0].set = pw->p[pw->n - 1].set;
920
3.42k
  pw->n = 1;
921
3.42k
922
3.42k
  space = isl_set_get_space(context);
923
3.42k
  pw->p[0].
FIELD3.42k
= fn_el(pw->p[0].
FIELD3.42k
, context);
924
3.42k
  context = isl_set_universe(space);
925
3.42k
  isl_set_free(pw->p[0].set);
926
3.42k
  pw->p[0].set = context;
927
3.42k
928
3.42k
  if (
!pw->p[0].3.42k
FIELD3.42k
||
!pw->p[0].set3.42k
)
929
0
    
return 0
FN0
(PW,free)(pw);
930
3.42k
931
3.42k
  return pw;
932
3.42k
}
isl_aff.c:isl_pw_multi_aff_gist_last
Line
Count
Source
910
980
{
911
980
  int i;
912
980
  isl_space *space;
913
980
914
980
  for (i = 0; 
i < pw->n - 1980
;
++i0
)
{0
915
0
    isl_set_free(pw->p[i].set);
916
0
    
FN0
(EL,free)(pw->p[i].
FIELD0
);
917
0
  }
918
980
  pw->p[0].
FIELD980
= pw->p[pw->n - 1].
FIELD980
;
919
980
  pw->p[0].set = pw->p[pw->n - 1].set;
920
980
  pw->n = 1;
921
980
922
980
  space = isl_set_get_space(context);
923
980
  pw->p[0].
FIELD980
= fn_el(pw->p[0].
FIELD980
, context);
924
980
  context = isl_set_universe(space);
925
980
  isl_set_free(pw->p[0].set);
926
980
  pw->p[0].set = context;
927
980
928
980
  if (
!pw->p[0].980
FIELD980
||
!pw->p[0].set980
)
929
0
    
return 0
FN0
(PW,free)(pw);
930
980
931
980
  return pw;
932
980
}
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
0
  }
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
0
  }
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
0
  }
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
0
  }
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
3
  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
0
      }
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
0
    }
1022
3
  }
1023
3
1024
3
  isl_basic_set_free(hull);
1025
3
  isl_set_free(context);
1026
3
1027
3
  return pw;
1028
0
error:
1029
0
  FN(PW,free)(pw);
1030
0
  isl_basic_set_free(hull);
1031
0
  isl_set_free(context);
1032
0
  return NULL;
1033
3
}
isl_aff.c:isl_pw_aff_gist_aligned
Line
Count
Source
947
5.95k
{
948
5.95k
  int i;
949
5.95k
  int is_universe;
950
5.95k
  isl_bool aligned;
951
5.95k
  isl_basic_set *hull = NULL;
952
5.95k
953
5.95k
  if (
!pw || 5.95k
!context5.95k
)
954
0
    goto error;
955
5.95k
956
5.95k
  
if (5.95k
pw->n == 05.95k
)
{0
957
0
    isl_set_free(context);
958
0
    return pw;
959
0
  }
960
5.95k
961
5.95k
  is_universe = isl_set_plain_is_universe(context);
962
5.95k
  if (is_universe < 0)
963
0
    goto error;
964
5.95k
  
if (5.95k
is_universe5.95k
)
{890
965
890
    isl_set_free(context);
966
890
    return pw;
967
890
  }
968
5.95k
969
5.06k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
970
5.06k
  if (aligned < 0)
971
0
    goto error;
972
5.06k
  
if (5.06k
!aligned5.06k
)
{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
0
  }
976
5.06k
977
5.06k
  pw = FN(PW,cow)(pw);
978
5.06k
  if (!pw)
979
0
    goto error;
980
5.06k
981
5.06k
  
if (5.06k
pw->n == 15.06k
)
{5.03k
982
5.03k
    int equal;
983
5.03k
984
5.03k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
985
5.03k
    if (equal < 0)
986
0
      goto error;
987
5.03k
    
if (5.03k
equal5.03k
)
988
3.42k
      
return 3.42k
FN3.42k
(PW,gist_last)(pw, context, fn_el);
989
5.03k
  }
990
5.06k
991
1.63k
  context = isl_set_compute_divs(context);
992
1.63k
  hull = isl_set_simple_hull(isl_set_copy(context));
993
1.63k
994
3.31k
  for (i = pw->n - 1; 
i >= 03.31k
;
--i1.67k
)
{1.67k
995
1.67k
    isl_set *set_i;
996
1.67k
    int empty;
997
1.67k
998
1.67k
    if (
i == pw->n - 11.67k
)
{1.63k
999
1.63k
      int equal;
1000
1.63k
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1001
1.63k
      if (equal < 0)
1002
0
        goto error;
1003
1.63k
      
if (1.63k
equal1.63k
)
{0
1004
0
        isl_basic_set_free(hull);
1005
0
        return FN(PW,gist_last)(pw, context, fn_el);
1006
0
      }
1007
1.63k
    }
1008
1.67k
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1009
1.67k
             isl_set_copy(context));
1010
1.67k
    empty = isl_set_plain_is_empty(set_i);
1011
1.67k
    pw->p[i].
FIELD1.67k
= fn_el(pw->p[i].
FIELD1.67k
, set_i);
1012
1.67k
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1013
1.67k
    if (
empty < 0 || 1.67k
!pw->p[i].1.67k
FIELD1.67k
||
!pw->p[i].set1.67k
)
1014
0
      goto error;
1015
1.67k
    
if (1.67k
empty1.67k
)
{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
0
    }
1022
1.67k
  }
1023
1.63k
1024
1.63k
  isl_basic_set_free(hull);
1025
1.63k
  isl_set_free(context);
1026
1.63k
1027
1.63k
  return pw;
1028
0
error:
1029
0
  FN(PW,free)(pw);
1030
0
  isl_basic_set_free(hull);
1031
0
  isl_set_free(context);
1032
0
  return NULL;
1033
1.63k
}
isl_aff.c:isl_pw_multi_aff_gist_aligned
Line
Count
Source
947
1.13k
{
948
1.13k
  int i;
949
1.13k
  int is_universe;
950
1.13k
  isl_bool aligned;
951
1.13k
  isl_basic_set *hull = NULL;
952
1.13k
953
1.13k
  if (
!pw || 1.13k
!context1.13k
)
954
0
    goto error;
955
1.13k
956
1.13k
  
if (1.13k
pw->n == 01.13k
)
{0
957
0
    isl_set_free(context);
958
0
    return pw;
959
0
  }
960
1.13k
961
1.13k
  is_universe = isl_set_plain_is_universe(context);
962
1.13k
  if (is_universe < 0)
963
0
    goto error;
964
1.13k
  
if (1.13k
is_universe1.13k
)
{68
965
68
    isl_set_free(context);
966
68
    return pw;
967
68
  }
968
1.13k
969
1.06k
  aligned = isl_set_space_has_equal_params(context, pw->dim);
970
1.06k
  if (aligned < 0)
971
0
    goto error;
972
1.06k
  
if (1.06k
!aligned1.06k
)
{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
0
  }
976
1.06k
977
1.06k
  pw = FN(PW,cow)(pw);
978
1.06k
  if (!pw)
979
0
    goto error;
980
1.06k
981
1.06k
  
if (1.06k
pw->n == 11.06k
)
{1.06k
982
1.06k
    int equal;
983
1.06k
984
1.06k
    equal = isl_set_plain_is_equal(pw->p[0].set, context);
985
1.06k
    if (equal < 0)
986
0
      goto error;
987
1.06k
    
if (1.06k
equal1.06k
)
988
980
      
return 980
FN980
(PW,gist_last)(pw, context, fn_el);
989
1.06k
  }
990
1.06k
991
88
  context = isl_set_compute_divs(context);
992
88
  hull = isl_set_simple_hull(isl_set_copy(context));
993
88
994
176
  for (i = pw->n - 1; 
i >= 0176
;
--i88
)
{88
995
88
    isl_set *set_i;
996
88
    int empty;
997
88
998
88
    if (
i == pw->n - 188
)
{88
999
88
      int equal;
1000
88
      equal = isl_set_plain_is_equal(pw->p[i].set, context);
1001
88
      if (equal < 0)
1002
0
        goto error;
1003
88
      
if (88
equal88
)
{0
1004
0
        isl_basic_set_free(hull);
1005
0
        return FN(PW,gist_last)(pw, context, fn_el);
1006
0
      }
1007
88
    }
1008
88
    set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
1009
88
             isl_set_copy(context));
1010
88
    empty = isl_set_plain_is_empty(set_i);
1011
88
    pw->p[i].
FIELD88
= fn_el(pw->p[i].
FIELD88
, set_i);
1012
88
    pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
1013
88
    if (
empty < 0 || 88
!pw->p[i].88
FIELD88
||
!pw->p[i].set88
)
1014
0
      goto error;
1015
88
    
if (88
empty88
)
{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
0
    }
1022
88
  }
1023
88
1024
88
  isl_basic_set_free(hull);
1025
88
  isl_set_free(context);
1026
88
1027
88
  return pw;
1028
0
error:
1029
0
  FN(PW,free)(pw);
1030
0
  isl_basic_set_free(hull);
1031
0
  isl_set_free(context);
1032
0
  return NULL;
1033
88
}
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.13k
{
1038
1.13k
  return 
FN1.13k
(PW,gist_aligned)(pw, set, &
FN1.13k
(EL,gist),
1039
1.13k
          &isl_set_gist_basic_set);
1040
1.13k
}
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
5.95k
{
1038
5.95k
  return 
FN5.95k
(PW,gist_aligned)(pw, set, &
FN5.95k
(EL,gist),
1039
5.95k
          &isl_set_gist_basic_set);
1040
5.95k
}
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.13k
{
1044
1.13k
  return FN(PW,align_params_pw_set_and)(pw, context,
1045
1.13k
            &FN(PW,gist_domain_aligned));
1046
1.13k
}
isl_pw_aff_gist
Line
Count
Source
1043
5.95k
{
1044
5.95k
  return FN(PW,align_params_pw_set_and)(pw, context,
1045
5.95k
            &FN(PW,gist_domain_aligned));
1046
5.95k
}
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
463
{
1070
463
  struct FN(PW,piece) const *pc1 = p1;
1071
463
  struct FN(PW,piece) const *pc2 = p2;
1072
463
1073
463
  return 
FN463
(EL,plain_cmp)(pc1->
FIELD463
, pc2->
FIELD463
);
1074
463
}
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
958
{
1070
958
  struct FN(PW,piece) const *pc1 = p1;
1071
958
  struct FN(PW,piece) const *pc2 = p2;
1072
958
1073
958
  return 
FN958
(EL,plain_cmp)(pc1->
FIELD958
, pc2->
FIELD958
);
1074
958
}
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
2.14k
{
1087
2.14k
  int i, j;
1088
2.14k
  isl_set *set;
1089
2.14k
1090
2.14k
  if (!pw)
1091
0
    return NULL;
1092
2.14k
  
if (2.14k
pw->n <= 12.14k
)
1093
1.91k
    return pw;
1094
226
  
if (226
isl_sort(pw->p, pw->n, sizeof(pw->p[0]),226
1095
226
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
0
    
return 0
FN0
(PW,free)(pw);
1097
786
  
for (i = pw->n - 1; 226
i >= 1786
;
--i560
)
{560
1098
560
    if (
!560
FN560
(EL,plain_is_equal)(pw->p[i - 1].
FIELD560
, pw->p[i].
FIELD560
))
1099
543
      continue;
1100
17
    set = isl_set_union(isl_set_copy(pw->p[i - 1].set),
1101
17
            isl_set_copy(pw->p[i].set));
1102
17
    if (!set)
1103
0
      
return 0
FN0
(PW,free)(pw);
1104
17
    isl_set_free(pw->p[i].set);
1105
17
    
FN17
(EL,free)(pw->p[i].
FIELD17
);
1106
17
    isl_set_free(pw->p[i - 1].set);
1107
17
    pw->p[i - 1].set = set;
1108
17
    for (j = i + 1; 
j < pw->n17
;
++j0
)
1109
0
      pw->p[j - 1] = pw->p[j];
1110
17
    pw->n--;
1111
17
  }
1112
226
1113
226
  return pw;
1114
226
}
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
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
1
1113
1
  return pw;
1114
1
}
isl_pw_aff_sort
Line
Count
Source
1086
15.7k
{
1087
15.7k
  int i, j;
1088
15.7k
  isl_set *set;
1089
15.7k
1090
15.7k
  if (!pw)
1091
1
    return NULL;
1092
15.7k
  
if (15.7k
pw->n <= 115.7k
)
1093
15.5k
    return pw;
1094
217
  
if (217
isl_sort(pw->p, pw->n, sizeof(pw->p[0]),217
1095
217
        &FN(PW,sort_field_cmp), NULL) < 0)
1096
0
    
return 0
FN0
(PW,free)(pw);
1097
555
  
for (i = pw->n - 1; 217
i >= 1555
;
--i338
)
{338
1098
338
    if (
!338
FN338
(EL,plain_is_equal)(pw->p[i - 1].
FIELD338
, pw->p[i].
FIELD338
))
1099
331
      continue;
1100
7
    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
7
  }
1112
217
1113
217
  return pw;
1114
217
}
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
0
}
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
15.4k
{
1125
15.4k
  int i;
1126
15.4k
1127
15.4k
  pw = FN(PW,sort)(pw);
1128
15.4k
  if (!pw)
1129
1
    return NULL;
1130
15.4k
1131
31.2k
  
for (i = 0; 15.4k
i < pw->n31.2k
;
++i15.7k
)
{15.7k
1132
15.7k
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1133
15.7k
    if (!pw->p[i].set)
1134
0
      goto error;
1135
15.7k
  }
1136
15.4k
1137
15.4k
  return pw;
1138
0
error:
1139
0
  FN(PW,free)(pw);
1140
0
  return NULL;
1141
15.4k
}
isl_pw_multi_aff_coalesce
Line
Count
Source
1124
782
{
1125
782
  int i;
1126
782
1127
782
  pw = FN(PW,sort)(pw);
1128
782
  if (!pw)
1129
0
    return NULL;
1130
782
1131
1.64k
  
for (i = 0; 782
i < pw->n1.64k
;
++i858
)
{858
1132
858
    pw->p[i].set = isl_set_coalesce(pw->p[i].set);
1133
858
    if (!pw->p[i].set)
1134
0
      goto error;
1135
858
  }
1136
782
1137
782
  return pw;
1138
0
error:
1139
0
  FN(PW,free)(pw);
1140
0
  return NULL;
1141
782
}
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
0
error:
1139
0
  FN(PW,free)(pw);
1140
0
  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
1.38k
{
1145
1.38k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1146
1.38k
}
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
18.0k
{
1145
18.0k
  return pw ? isl_space_get_ctx(pw->dim) : NULL;
1146
18.0k
}
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
438
{
1212
438
  int i;
1213
438
  enum isl_dim_type set_type;
1214
438
1215
438
  if (!pw)
1216
0
    return NULL;
1217
438
  
if (438
n == 0 && 438
!isl_space_get_tuple_name(pw->dim, type)0
)
1218
0
    return pw;
1219
438
1220
438
  
set_type = type == isl_dim_in ? 438
isl_dim_set0
:
type438
;
1221
438
1222
438
  pw = FN(PW,cow)(pw);
1223
438
  if (!pw)
1224
0
    return NULL;
1225
438
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1226
438
  if (!pw->dim)
1227
0
    goto error;
1228
876
  
for (i = 0; 438
i < pw->n876
;
++i438
)
{438
1229
438
    pw->p[i].
FIELD438
=
FN438
(EL,drop_dims)(pw->p[i].
FIELD438
, type, first, n);
1230
438
    if (
!pw->p[i].438
FIELD438
)
1231
0
      goto error;
1232
438
    
if (438
type == isl_dim_out438
)
1233
438
      continue;
1234
0
    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
0
  }
1238
438
1239
438
  return pw;
1240
0
error:
1241
0
  FN(PW,free)(pw);
1242
0
  return NULL;
1243
438
}
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
0
error:
1241
0
  FN(PW,free)(pw);
1242
0
  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
1
    return pw;
1260
1
1261
0
  
set_type = type == isl_dim_in ? 0
isl_dim_set0
:
type0
;
1262
0
1263
0
  pw = FN(PW,cow)(pw);
1264
0
  if (!pw)
1265
0
    return NULL;
1266
0
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1267
0
  if (!pw->dim)
1268
0
    goto error;
1269
0
  
for (i = 0; 0
i < pw->n0
;
++i0
)
{0
1270
0
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1271
0
              set_type, first, n);
1272
0
    if (!pw->p[i].set)
1273
0
      goto error;
1274
0
    
pw->p[i].0
FIELD0
=
FN0
(EL,drop_dims)(pw->p[i].
FIELD0
, type, first, n);
1275
0
    if (
!pw->p[i].0
FIELD0
)
1276
0
      goto error;
1277
0
  }
1278
0
1279
0
  return pw;
1280
0
error:
1281
0
  FN(PW,free)(pw);
1282
0
  return NULL;
1283
0
}
Unexecuted instantiation: isl_pw_aff_project_out
Unexecuted instantiation: isl_pw_qpolynomial_project_out
isl_pw_multi_aff_project_out
Line
Count
Source
1252
18
{
1253
18
  int i;
1254
18
  enum isl_dim_type set_type;
1255
18
1256
18
  if (!pw)
1257
0
    return NULL;
1258
18
  
if (18
n == 0 && 18
!isl_space_get_tuple_name(pw->dim, type)0
)
1259
0
    return pw;
1260
18
1261
18
  
set_type = type == isl_dim_in ? 18
isl_dim_set18
:
type0
;
1262
18
1263
18
  pw = FN(PW,cow)(pw);
1264
18
  if (!pw)
1265
0
    return NULL;
1266
18
  pw->dim = isl_space_drop_dims(pw->dim, type, first, n);
1267
18
  if (!pw->dim)
1268
0
    goto error;
1269
54
  
for (i = 0; 18
i < pw->n54
;
++i36
)
{36
1270
36
    pw->p[i].set = isl_set_project_out(pw->p[i].set,
1271
36
              set_type, first, n);
1272
36
    if (!pw->p[i].set)
1273
0
      goto error;
1274
36
    
pw->p[i].36
FIELD36
=
FN36
(EL,drop_dims)(pw->p[i].
FIELD36
, type, first, n);
1275
36
    if (
!pw->p[i].36
FIELD36
)
1276
0
      goto error;
1277
36
  }
1278
18
1279
18
  return pw;
1280
0
error:
1281
0
  FN(PW,free)(pw);
1282
0
  return NULL;
1283
18
}
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
2.80k
{
1305
2.80k
  int i;
1306
2.80k
  enum isl_dim_type set_type;
1307
2.80k
1308
2.80k
  if (!pw)
1309
0
    return NULL;
1310
2.80k
  
if (2.80k
n == 0 && 2.80k
!isl_space_is_named_or_nested(pw->dim, type)0
)
1311
0
    return pw;
1312
2.80k
1313
2.80k
  
set_type = type == isl_dim_in ? 2.80k
isl_dim_set2.80k
:
type0
;
1314
2.80k
1315
2.80k
  pw = FN(PW,cow)(pw);
1316
2.80k
  if (!pw)
1317
0
    return NULL;
1318
2.80k
1319
2.80k
  pw->dim = isl_space_insert_dims(pw->dim, type, first, n);
1320
2.80k
  if (!pw->dim)
1321
0
    goto error;
1322
2.80k
1323
5.61k
  
for (i = 0; 2.80k
i < pw->n5.61k
;
++i2.80k
)
{2.80k
1324
2.80k
    pw->p[i].set = isl_set_insert_dims(pw->p[i].set,
1325
2.80k
                  set_type, first, n);
1326
2.80k
    if (!pw->p[i].set)
1327
0
      goto error;
1328
2.80k
    
pw->p[i].2.80k
FIELD2.80k
=
FN2.80k
(EL,insert_dims)(pw->p[i].
FIELD2.80k
,
1329
2.80k
                type, first, n);
1330
2.80k
    if (
!pw->p[i].2.80k
FIELD2.80k
)
1331
0
      goto error;
1332
2.80k
  }
1333
2.80k
1334
2.80k
  return pw;
1335
0
error:
1336
0
  FN(PW,free)(pw);
1337
0
  return NULL;
1338
2.80k
}
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
0
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
2.80k
{
1387
2.80k
  return pw ? 
isl_space_dim(pw->dim, type)2.80k
:
00
;
1388
2.80k
}
isl_pw_multi_aff_dim
Line
Count
Source
1386
11.5k
{
1387
11.5k
  return pw ? 
isl_space_dim(pw->dim, type)11.5k
:
00
;
1388
11.5k
}
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
0
  }
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
0
  }
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
75.9k
{
1469
75.9k
  return pw ? isl_space_copy(pw->dim) : NULL;
1470
75.9k
}
isl_pw_multi_aff_get_space
Line
Count
Source
1468
29.8k
{
1469
29.8k
  return pw ? isl_space_copy(pw->dim) : NULL;
1470
29.8k
}
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
50
{
1474
50
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1475
50
}
isl_pw_aff_get_domain_space
Line
Count
Source
1473
84.2k
{
1474
84.2k
  return pw ? isl_space_domain(isl_space_copy(pw->dim)) : NULL;
1475
84.2k
}
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
31.5k
{
1497
31.5k
  int i;
1498
31.5k
1499
31.5k
  pw = FN(PW,cow)(pw);
1500
31.5k
  if (
!pw || 31.5k
!space31.5k
||
!domain31.5k
)
1501
0
    goto error;
1502
31.5k
1503
63.5k
  
for (i = 0; 31.5k
i < pw->n63.5k
;
++i31.9k
)
{31.9k
1504
31.9k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1505
31.9k
             isl_space_copy(domain));
1506
31.9k
    if (!pw->p[i].set)
1507
0
      goto error;
1508
31.9k
    
pw->p[i].31.9k
FIELD31.9k
=
FN31.9k
(EL,reset_space_and_domain)(pw->p[i].
FIELD31.9k
,
1509
31.9k
            isl_space_copy(space), isl_space_copy(domain));
1510
31.9k
    if (
!pw->p[i].31.9k
FIELD31.9k
)
1511
0
      goto error;
1512
31.9k
  }
1513
31.5k
1514
31.5k
  isl_space_free(domain);
1515
31.5k
1516
31.5k
  isl_space_free(pw->dim);
1517
31.5k
  pw->dim = space;
1518
31.5k
1519
31.5k
  return pw;
1520
0
error:
1521
0
  isl_space_free(domain);
1522
0
  isl_space_free(space);
1523
0
  FN(PW,free)(pw);
1524
0
  return NULL;
1525
31.5k
}
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.24k
{
1497
1.24k
  int i;
1498
1.24k
1499
1.24k
  pw = FN(PW,cow)(pw);
1500
1.24k
  if (
!pw || 1.24k
!space1.24k
||
!domain1.24k
)
1501
0
    goto error;
1502
1.24k
1503
2.51k
  
for (i = 0; 1.24k
i < pw->n2.51k
;
++i1.26k
)
{1.26k
1504
1.26k
    pw->p[i].set = isl_set_reset_space(pw->p[i].set,
1505
1.26k
             isl_space_copy(domain));
1506
1.26k
    if (!pw->p[i].set)
1507
0
      goto error;
1508
1.26k
    
pw->p[i].1.26k
FIELD1.26k
=
FN1.26k
(EL,reset_space_and_domain)(pw->p[i].
FIELD1.26k
,
1509
1.26k
            isl_space_copy(space), isl_space_copy(domain));
1510
1.26k
    if (
!pw->p[i].1.26k
FIELD1.26k
)
1511
0
      goto error;
1512
1.26k
  }
1513
1.24k
1514
1.24k
  isl_space_free(domain);
1515
1.24k
1516
1.24k
  isl_space_free(pw->dim);
1517
1.24k
  pw->dim = space;
1518
1.24k
1519
1.24k
  return pw;
1520
0
error:
1521
0
  isl_space_free(domain);
1522
0
  isl_space_free(space);
1523
0
  FN(PW,free)(pw);
1524
0
  return NULL;
1525
1.24k
}
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
3
  }
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
0
error:
1521
0
  isl_space_free(domain);
1522
0
  isl_space_free(space);
1523
0
  FN(PW,free)(pw);
1524
0
  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
25.4k
{
1530
25.4k
  isl_space *space;
1531
25.4k
1532
25.4k
  space = isl_space_extend_domain_with_range(isl_space_copy(domain),
1533
25.4k
               FN(PW,get_space)(pw));
1534
25.4k
  return FN(PW,reset_space_and_domain)(pw, space, domain);
1535
25.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
6.13k
{
1539
6.13k
  isl_space *domain;
1540
6.13k
1541
6.13k
  domain = isl_space_domain(isl_space_copy(dim));
1542
6.13k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1543
6.13k
}
Unexecuted instantiation: isl_pw_qpolynomial_reset_space
isl_pw_multi_aff_reset_space
Line
Count
Source
1538
1.24k
{
1539
1.24k
  isl_space *domain;
1540
1.24k
1541
1.24k
  domain = isl_space_domain(isl_space_copy(dim));
1542
1.24k
  return FN(PW,reset_space_and_domain)(pw, dim, domain);
1543
1.24k
}
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
466
{
1548
466
  isl_space *space;
1549
466
1550
466
  pw = FN(PW,cow)(pw);
1551
466
  if (!pw)
1552
0
    goto error;
1553
466
1554
466
  
space = 466
FN466
(PW,get_space)(pw);
1555
466
  space = isl_space_set_tuple_id(space, type, id);
1556
466
1557
466
  return FN(PW,reset_space)(pw, space);
1558
0
error:
1559
0
  isl_id_free(id);
1560
0
  return FN(PW,free)(pw);
1561
466
}
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
1
  }
1650
2
1651
2
  isl_morph_free(morph);
1652
2
1653
2
  return pw;
1654
0
error:
1655
0
  FN(PW,free)(pw);
1656
0
  isl_morph_free(morph);
1657
0
  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
5.76k
{
1663
5.76k
  return pw ? 
pw->n5.76k
:
00
;
1664
5.76k
}
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
6.70k
{
1670
6.70k
  int i;
1671
6.70k
1672
6.70k
  if (!pw)
1673
0
    return isl_stat_error;
1674
6.70k
1675
11.9k
  
for (i = 0; 6.70k
i < pw->n11.9k
;
++i5.21k
)
1676
6.96k
    
if (6.96k
fn(isl_set_copy(pw->p[i].set),6.96k
1677
6.96k
        
FN6.96k
(EL,copy)(pw->p[i].
FIELD6.96k
), user) < 0)
1678
1.75k
      return isl_stat_error;
1679
6.70k
1680
4.95k
  return isl_stat_ok;
1681
6.70k
}
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
0
error:
1727
0
  isl_set_free(set);
1728
0
  FN(EL,free)(el);
1729
0
  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
1
    }
1756
1
    
if (1
foreach_lifted_subset(set, el, fn, user) < 01
)
1757
0
      return isl_stat_error;
1758
1
  }
1759
2
1760
2
  return isl_stat_ok;