Coverage Report

Created: 2017-08-18 19:41

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/External/isl/isl_map_lexopt_templ.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2010      INRIA Saclay
3
 * Copyright 2012      Ecole Normale Superieure
4
 *
5
 * Use of this software is governed by the MIT license
6
 *
7
 * Written by Sven Verdoolaege,
8
 * INRIA Saclay - Ile-de-France, Parc Club Orsay Universite,
9
 * ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France
10
 * and Ecole Normale Superieure, 45 rue d’Ulm, 75230 Paris, France
11
 */
12
13
/* Function for computing the lexicographic optimum of a map
14
 * in the form of either an isl_map or an isl_pw_multi_aff.
15
 */
16
17
27.0k
#define xSF(TYPE,SUFFIX) TYPE ## SUFFIX
18
27.0k
#define SF(TYPE,SUFFIX) xSF(TYPE,SUFFIX)
19
20
/* Compute the lexicographic minimum (or maximum if "flags" includes
21
 * ISL_OPT_MAX) of "bmap" over the domain "dom" and return the result.
22
 * If "empty" is not NULL, then *empty is assigned a set that
23
 * contains those parts of the domain where there is no solution.
24
 * If "flags" includes ISL_OPT_FULL, then "dom" is NULL and the optimum
25
 * should be computed over the domain of "bmap".  "empty" is also NULL
26
 * in this case.
27
 * If "bmap" is marked as rational (ISL_BASIC_MAP_RATIONAL),
28
 * then the rational optimum is computed.  Otherwise, the integral optimum
29
 * is computed.
30
 */
31
static __isl_give TYPE *SF(isl_basic_map_partial_lexopt,SUFFIX)(
32
  __isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
33
  __isl_give isl_set **empty, unsigned flags)
34
5.97k
{
35
5.97k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
5.97k
                  flags);
37
5.97k
}
isl_map.c:isl_basic_map_partial_lexopt_pw_multi_aff
Line
Count
Source
34
3.02k
{
35
3.02k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
3.02k
                  flags);
37
3.02k
}
isl_map.c:isl_basic_map_partial_lexopt
Line
Count
Source
34
2.95k
{
35
2.95k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
2.95k
                  flags);
37
2.95k
}
38
39
__isl_give TYPE *SF(isl_basic_map_partial_lexmax,SUFFIX)(
40
  __isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
41
  __isl_give isl_set **empty)
42
0
{
43
0
  unsigned flags = ISL_OPT_MAX;
44
0
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty, flags);
45
0
}
Unexecuted instantiation: isl_basic_map_partial_lexmax_pw_multi_aff
Unexecuted instantiation: isl_basic_map_partial_lexmax
46
47
__isl_give TYPE *SF(isl_basic_map_partial_lexmin,SUFFIX)(
48
  __isl_take isl_basic_map *bmap, __isl_take isl_basic_set *dom,
49
  __isl_give isl_set **empty)
50
1
{
51
1
  unsigned flags = 0;
52
1
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty, flags);
53
1
}
Unexecuted instantiation: isl_basic_map_partial_lexmin_pw_multi_aff
isl_basic_map_partial_lexmin
Line
Count
Source
50
1
{
51
1
  unsigned flags = 0;
52
1
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty, flags);
53
1
}
54
55
__isl_give TYPE *SF(isl_basic_set_partial_lexmin,SUFFIX)(
56
  __isl_take isl_basic_set *bset, __isl_take isl_basic_set *dom,
57
  __isl_give isl_set **empty)
58
0
{
59
0
  return SF(isl_basic_map_partial_lexmin,SUFFIX)(bset, dom, empty);
60
0
}
Unexecuted instantiation: isl_basic_set_partial_lexmin_pw_multi_aff
Unexecuted instantiation: isl_basic_set_partial_lexmin
61
62
__isl_give TYPE *SF(isl_basic_set_partial_lexmax,SUFFIX)(
63
  __isl_take isl_basic_set *bset, __isl_take isl_basic_set *dom,
64
  __isl_give isl_set **empty)
65
0
{
66
0
  return SF(isl_basic_map_partial_lexmax,SUFFIX)(bset, dom, empty);
67
0
}
Unexecuted instantiation: isl_basic_set_partial_lexmax_pw_multi_aff
Unexecuted instantiation: isl_basic_set_partial_lexmax
68
69
/* Given a basic map "bmap", compute the lexicographically minimal
70
 * (or maximal) image element for each domain element in dom.
71
 * If empty is not NULL, then set *empty to those elements in dom
72
 * that do not have an image element.
73
 * If "flags" includes ISL_OPT_FULL, then "dom" is NULL and the optimum
74
 * should be computed over the domain of "bmap".  "empty" is also NULL
75
 * in this case.
76
 *
77
 * We first make sure the basic sets in dom are disjoint and then
78
 * simply collect the results over each of the basic sets separately.
79
 * We could probably improve the efficiency a bit by moving the union
80
 * domain down into the parametric integer programming.
81
 *
82
 * If a full optimum is being computed (i.e., "flags" includes ISL_OPT_FULL),
83
 * then no domain is given and there is then also no need to consider
84
 * the disjuncts of the domain.
85
 */
86
static __isl_give TYPE *SF(basic_map_partial_lexopt,SUFFIX)(
87
  __isl_take isl_basic_map *bmap, __isl_take isl_set *dom,
88
  __isl_give isl_set **empty, unsigned flags)
89
7.17k
{
90
7.17k
  int i;
91
7.17k
  TYPE *res;
92
7.17k
  isl_set *all_empty;
93
7.17k
94
7.17k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
2.46k
    
return 2.46k
SF2.46k
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
7.17k
                empty, flags);
97
7.17k
98
7.17k
  dom = isl_set_make_disjoint(dom);
99
4.70k
  if (!dom)
100
0
    goto error;
101
4.70k
102
4.70k
  
if (4.70k
isl_set_plain_is_empty(dom)4.70k
)
{2.32k
103
2.32k
    isl_space *space = isl_basic_map_get_space(bmap);
104
2.32k
    if (empty)
105
2.32k
      *empty = dom;
106
2.32k
    else
107
0
      isl_set_free(dom);
108
2.32k
    isl_basic_map_free(bmap);
109
2.32k
    return EMPTY(space);
110
4.70k
  }
111
4.70k
112
2.37k
  
res = 2.37k
SF2.37k
(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
2.37k
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
2.37k
115
2.37k
  if (empty)
116
2.37k
    all_empty = *empty;
117
3.27k
  for (i = 1; 
i < dom->n3.27k
;
++i898
)
{898
118
898
    TYPE *res_i;
119
898
120
898
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
898
        isl_basic_map_copy(bmap),
122
898
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
898
124
898
    res = ADD(res, res_i);
125
898
    if (empty)
126
898
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
2.37k
  }
128
2.37k
129
2.37k
  if (empty)
130
2.37k
    *empty = all_empty;
131
2.37k
  isl_set_free(dom);
132
2.37k
  isl_basic_map_free(bmap);
133
4.70k
  return res;
134
4.70k
error:
135
0
  if (empty)
136
0
    *empty = NULL;
137
0
  isl_set_free(dom);
138
0
  isl_basic_map_free(bmap);
139
4.70k
  return NULL;
140
7.17k
}
isl_map.c:basic_map_partial_lexopt_pw_multi_aff
Line
Count
Source
89
2.43k
{
90
2.43k
  int i;
91
2.43k
  TYPE *res;
92
2.43k
  isl_set *all_empty;
93
2.43k
94
2.43k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
1.90k
    
return 1.90k
SF1.90k
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
2.43k
                empty, flags);
97
2.43k
98
2.43k
  dom = isl_set_make_disjoint(dom);
99
536
  if (!dom)
100
0
    goto error;
101
536
102
536
  
if (536
isl_set_plain_is_empty(dom)536
)
{268
103
268
    isl_space *space = isl_basic_map_get_space(bmap);
104
268
    if (empty)
105
268
      *empty = dom;
106
268
    else
107
0
      isl_set_free(dom);
108
268
    isl_basic_map_free(bmap);
109
268
    return EMPTY(space);
110
536
  }
111
536
112
268
  
res = 268
SF268
(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
268
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
268
115
268
  if (empty)
116
268
    all_empty = *empty;
117
1.05k
  for (i = 1; 
i < dom->n1.05k
;
++i788
)
{788
118
788
    TYPE *res_i;
119
788
120
788
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
788
        isl_basic_map_copy(bmap),
122
788
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
788
124
788
    res = ADD(res, res_i);
125
788
    if (empty)
126
788
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
788
  }
128
268
129
268
  if (empty)
130
268
    *empty = all_empty;
131
268
  isl_set_free(dom);
132
268
  isl_basic_map_free(bmap);
133
536
  return res;
134
536
error:
135
0
  if (empty)
136
0
    *empty = NULL;
137
0
  isl_set_free(dom);
138
0
  isl_basic_map_free(bmap);
139
536
  return NULL;
140
2.43k
}
isl_map.c:basic_map_partial_lexopt
Line
Count
Source
89
4.73k
{
90
4.73k
  int i;
91
4.73k
  TYPE *res;
92
4.73k
  isl_set *all_empty;
93
4.73k
94
4.73k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
564
    
return 564
SF564
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
4.73k
                empty, flags);
97
4.73k
98
4.73k
  dom = isl_set_make_disjoint(dom);
99
4.16k
  if (!dom)
100
0
    goto error;
101
4.16k
102
4.16k
  
if (4.16k
isl_set_plain_is_empty(dom)4.16k
)
{2.05k
103
2.05k
    isl_space *space = isl_basic_map_get_space(bmap);
104
2.05k
    if (empty)
105
2.05k
      *empty = dom;
106
2.05k
    else
107
0
      isl_set_free(dom);
108
2.05k
    isl_basic_map_free(bmap);
109
2.05k
    return EMPTY(space);
110
4.16k
  }
111
4.16k
112
2.10k
  
res = 2.10k
SF2.10k
(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
2.10k
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
2.10k
115
2.10k
  if (empty)
116
2.10k
    all_empty = *empty;
117
2.21k
  for (i = 1; 
i < dom->n2.21k
;
++i110
)
{110
118
110
    TYPE *res_i;
119
110
120
110
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
110
        isl_basic_map_copy(bmap),
122
110
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
110
124
110
    res = ADD(res, res_i);
125
110
    if (empty)
126
110
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
2.10k
  }
128
2.10k
129
2.10k
  if (empty)
130
2.10k
    *empty = all_empty;
131
2.10k
  isl_set_free(dom);
132
2.10k
  isl_basic_map_free(bmap);
133
4.16k
  return res;
134
4.16k
error:
135
0
  if (empty)
136
0
    *empty = NULL;
137
0
  isl_set_free(dom);
138
0
  isl_basic_map_free(bmap);
139
4.16k
  return NULL;
140
4.73k
}
141
142
/* Compute the lexicographic minimum (or maximum if "flags" includes
143
 * ISL_OPT_MAX) of "bmap" over its domain.
144
 */
145
__isl_give TYPE *SF(isl_basic_map_lexopt,SUFFIX)(
146
  __isl_take isl_basic_map *bmap, unsigned flags)
147
234
{
148
234
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
234
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
234
}
isl_basic_map_lexopt
Line
Count
Source
147
172
{
148
172
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
172
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
172
}
isl_basic_map_lexopt_pw_multi_aff
Line
Count
Source
147
62
{
148
62
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
62
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
62
}
151
152
__isl_give TYPE *SF(isl_basic_map_lexmin,SUFFIX)(__isl_take isl_basic_map *bmap)
153
62
{
154
62
  return SF(isl_basic_map_lexopt,SUFFIX)(bmap, 0);
155
62
}
Unexecuted instantiation: isl_basic_map_lexmin
isl_basic_map_lexmin_pw_multi_aff
Line
Count
Source
153
62
{
154
62
  return SF(isl_basic_map_lexopt,SUFFIX)(bmap, 0);
155
62
}
156
157
static __isl_give TYPE *SF(isl_map_partial_lexopt_aligned,SUFFIX)(
158
  __isl_take isl_map *map, __isl_take isl_set *dom,
159
  __isl_give isl_set **empty, unsigned flags);
160
/* This function is currently only used when TYPE is defined as isl_map. */
161
static __isl_give TYPE *SF(isl_map_partial_lexopt,SUFFIX)(
162
  __isl_take isl_map *map, __isl_take isl_set *dom,
163
  __isl_give isl_set **empty, unsigned flags)
164
  __attribute__ ((unused));
165
166
/* Given a map "map", compute the lexicographically minimal
167
 * (or maximal) image element for each domain element in dom.
168
 * Set *empty to those elements in dom that do not have an image element.
169
 *
170
 * Align parameters if needed and then call isl_map_partial_lexopt_aligned.
171
 */
172
static __isl_give TYPE *SF(isl_map_partial_lexopt,SUFFIX)(
173
  __isl_take isl_map *map, __isl_take isl_set *dom,
174
  __isl_give isl_set **empty, unsigned flags)
175
10.4k
{
176
10.4k
  isl_bool aligned;
177
10.4k
178
10.4k
  aligned = isl_map_set_has_equal_params(map, dom);
179
10.4k
  if (aligned < 0)
180
0
    goto error;
181
10.4k
  
if (10.4k
aligned10.4k
)
182
10.4k
    
return 10.4k
SF10.4k
(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom,
183
10.4k
                empty, flags);
184
0
  
if (0
!isl_space_has_named_params(map->dim) ||0
185
0
      !isl_space_has_named_params(dom->dim))
186
0
    isl_die(map->ctx, isl_error_invalid,
187
0
      "unaligned unnamed parameters", goto error);
188
0
  map = isl_map_align_params(map, isl_map_get_space(dom));
189
0
  dom = isl_map_align_params(dom, isl_map_get_space(map));
190
0
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom, empty,
191
0
              flags);
192
0
error:
193
0
  if (empty)
194
0
    *empty = NULL;
195
0
  isl_set_free(dom);
196
0
  isl_map_free(map);
197
0
  return NULL;
198
10.4k
}
isl_map.c:isl_map_partial_lexopt
Line
Count
Source
175
10.4k
{
176
10.4k
  isl_bool aligned;
177
10.4k
178
10.4k
  aligned = isl_map_set_has_equal_params(map, dom);
179
10.4k
  if (aligned < 0)
180
0
    goto error;
181
10.4k
  
if (10.4k
aligned10.4k
)
182
10.4k
    
return 10.4k
SF10.4k
(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom,
183
10.4k
                empty, flags);
184
0
  
if (0
!isl_space_has_named_params(map->dim) ||0
185
0
      !isl_space_has_named_params(dom->dim))
186
0
    isl_die(map->ctx, isl_error_invalid,
187
0
      "unaligned unnamed parameters", goto error);
188
0
  map = isl_map_align_params(map, isl_map_get_space(dom));
189
0
  dom = isl_map_align_params(dom, isl_map_get_space(map));
190
0
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom, empty,
191
0
              flags);
192
0
error:
193
0
  if (empty)
194
0
    *empty = NULL;
195
0
  isl_set_free(dom);
196
0
  isl_map_free(map);
197
0
  return NULL;
198
10.4k
}
Unexecuted instantiation: isl_map.c:isl_map_partial_lexopt_pw_multi_aff
199
200
/* Compute the lexicographic minimum (or maximum if "flags" includes
201
 * ISL_OPT_MAX) of "map" over its domain.
202
 */
203
__isl_give TYPE *SF(isl_map_lexopt,SUFFIX)(__isl_take isl_map *map,
204
  unsigned flags)
205
1.74k
{
206
1.74k
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
1.74k
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
1.74k
              flags);
209
1.74k
}
isl_map_lexopt
Line
Count
Source
205
784
{
206
784
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
784
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
784
              flags);
209
784
}
isl_map_lexopt_pw_multi_aff
Line
Count
Source
205
965
{
206
965
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
965
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
965
              flags);
209
965
}
210
211
__isl_give TYPE *SF(isl_map_lexmin,SUFFIX)(__isl_take isl_map *map)
212
1.09k
{
213
1.09k
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
1.09k
}
isl_map_lexmin_pw_multi_aff
Line
Count
Source
212
483
{
213
483
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
483
}
isl_map_lexmin
Line
Count
Source
212
613
{
213
613
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
613
}
215
216
__isl_give TYPE *SF(isl_map_lexmax,SUFFIX)(__isl_take isl_map *map)
217
653
{
218
653
  return 
SF653
(isl_map_lexopt,SUFFIX)(map,
ISL_OPT_MAX653
);
219
653
}
isl_map_lexmax_pw_multi_aff
Line
Count
Source
217
482
{
218
482
  return 
SF482
(isl_map_lexopt,SUFFIX)(map,
ISL_OPT_MAX482
);
219
482
}
isl_map_lexmax
Line
Count
Source
217
171
{
218
171
  return 
SF171
(isl_map_lexopt,SUFFIX)(map,
ISL_OPT_MAX171
);
219
171
}
220
221
__isl_give TYPE *SF(isl_set_lexmin,SUFFIX)(__isl_take isl_set *set)
222
613
{
223
613
  return SF(isl_map_lexmin,SUFFIX)(set);
224
613
}
isl_set_lexmin
Line
Count
Source
222
130
{
223
130
  return SF(isl_map_lexmin,SUFFIX)(set);
224
130
}
isl_set_lexmin_pw_multi_aff
Line
Count
Source
222
483
{
223
483
  return SF(isl_map_lexmin,SUFFIX)(set);
224
483
}
225
226
__isl_give TYPE *SF(isl_set_lexmax,SUFFIX)(__isl_take isl_set *set)
227
483
{
228
483
  return SF(isl_map_lexmax,SUFFIX)(set);
229
483
}
isl_set_lexmax
Line
Count
Source
227
1
{
228
1
  return SF(isl_map_lexmax,SUFFIX)(set);
229
1
}
isl_set_lexmax_pw_multi_aff
Line
Count
Source
227
482
{
228
482
  return SF(isl_map_lexmax,SUFFIX)(set);
229
482
}