Coverage Report

Created: 2017-11-23 03:11

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/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
31.6k
#define xSF(TYPE,SUFFIX) TYPE ## SUFFIX
18
31.6k
#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
7.23k
{
35
7.23k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
7.23k
                  flags);
37
7.23k
}
isl_map.c:isl_basic_map_partial_lexopt_pw_multi_aff
Line
Count
Source
34
3.74k
{
35
3.74k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
3.74k
                  flags);
37
3.74k
}
isl_map.c:isl_basic_map_partial_lexopt
Line
Count
Source
34
3.48k
{
35
3.48k
  return SF(isl_tab_basic_map_partial_lexopt,SUFFIX)(bmap, dom, empty,
36
3.48k
                  flags);
37
3.48k
}
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
8.81k
{
90
8.81k
  int i;
91
8.81k
  TYPE *res;
92
8.81k
  isl_set *all_empty;
93
8.81k
94
8.81k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
8.81k
    
return 3.24k
SF3.24k
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
3.24k
                empty, flags);
97
5.57k
98
5.57k
  dom = isl_set_make_disjoint(dom);
99
5.57k
  if (!dom)
100
0
    goto error;
101
5.57k
102
5.57k
  if (isl_set_plain_is_empty(dom)) {
103
2.76k
    isl_space *space = isl_basic_map_get_space(bmap);
104
2.76k
    if (empty)
105
2.76k
      *empty = dom;
106
0
    else
107
0
      isl_set_free(dom);
108
2.76k
    isl_basic_map_free(bmap);
109
2.76k
    return EMPTY(space);
110
2.76k
  }
111
2.81k
112
2.81k
  res = SF(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
2.81k
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
2.81k
115
2.81k
  if (empty)
116
2.81k
    all_empty = *empty;
117
3.74k
  for (i = 1; i < dom->n; 
++i935
) {
118
935
    TYPE *res_i;
119
935
120
935
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
935
        isl_basic_map_copy(bmap),
122
935
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
935
124
935
    res = ADD(res, res_i);
125
935
    if (empty)
126
935
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
935
  }
128
2.81k
129
2.81k
  if (empty)
130
2.81k
    *empty = all_empty;
131
2.81k
  isl_set_free(dom);
132
2.81k
  isl_basic_map_free(bmap);
133
2.81k
  return res;
134
2.81k
error:
135
0
  if (empty)
136
0
    *empty = NULL;
137
0
  isl_set_free(dom);
138
0
  isl_basic_map_free(bmap);
139
0
  return NULL;
140
8.81k
}
isl_map.c:basic_map_partial_lexopt_pw_multi_aff
Line
Count
Source
89
3.16k
{
90
3.16k
  int i;
91
3.16k
  TYPE *res;
92
3.16k
  isl_set *all_empty;
93
3.16k
94
3.16k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
3.16k
    
return 2.56k
SF2.56k
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
2.56k
                empty, flags);
97
596
98
596
  dom = isl_set_make_disjoint(dom);
99
596
  if (!dom)
100
0
    goto error;
101
596
102
596
  if (isl_set_plain_is_empty(dom)) {
103
298
    isl_space *space = isl_basic_map_get_space(bmap);
104
298
    if (empty)
105
298
      *empty = dom;
106
0
    else
107
0
      isl_set_free(dom);
108
298
    isl_basic_map_free(bmap);
109
298
    return EMPTY(space);
110
298
  }
111
298
112
298
  res = SF(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
298
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
298
115
298
  if (empty)
116
298
    all_empty = *empty;
117
1.11k
  for (i = 1; i < dom->n; 
++i816
) {
118
816
    TYPE *res_i;
119
816
120
816
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
816
        isl_basic_map_copy(bmap),
122
816
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
816
124
816
    res = ADD(res, res_i);
125
816
    if (empty)
126
816
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
816
  }
128
298
129
298
  if (empty)
130
298
    *empty = all_empty;
131
298
  isl_set_free(dom);
132
298
  isl_basic_map_free(bmap);
133
298
  return res;
134
298
error:
135
0
  if (empty)
136
0
    *empty = NULL;
137
0
  isl_set_free(dom);
138
0
  isl_basic_map_free(bmap);
139
0
  return NULL;
140
3.16k
}
isl_map.c:basic_map_partial_lexopt
Line
Count
Source
89
5.65k
{
90
5.65k
  int i;
91
5.65k
  TYPE *res;
92
5.65k
  isl_set *all_empty;
93
5.65k
94
5.65k
  if (ISL_FL_ISSET(flags, ISL_OPT_FULL))
95
5.65k
    
return 673
SF673
(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL,
96
673
                empty, flags);
97
4.98k
98
4.98k
  dom = isl_set_make_disjoint(dom);
99
4.98k
  if (!dom)
100
0
    goto error;
101
4.98k
102
4.98k
  if (isl_set_plain_is_empty(dom)) {
103
2.46k
    isl_space *space = isl_basic_map_get_space(bmap);
104
2.46k
    if (empty)
105
2.46k
      *empty = dom;
106
0
    else
107
0
      isl_set_free(dom);
108
2.46k
    isl_basic_map_free(bmap);
109
2.46k
    return EMPTY(space);
110
2.46k
  }
111
2.51k
112
2.51k
  res = SF(isl_basic_map_partial_lexopt,SUFFIX)(isl_basic_map_copy(bmap),
113
2.51k
      isl_basic_set_copy(dom->p[0]), empty, flags);
114
2.51k
115
2.51k
  if (empty)
116
2.51k
    all_empty = *empty;
117
2.63k
  for (i = 1; i < dom->n; 
++i119
) {
118
119
    TYPE *res_i;
119
119
120
119
    res_i = SF(isl_basic_map_partial_lexopt,SUFFIX)(
121
119
        isl_basic_map_copy(bmap),
122
119
        isl_basic_set_copy(dom->p[i]), empty, flags);
123
119
124
119
    res = ADD(res, res_i);
125
119
    if (empty)
126
119
      all_empty = isl_set_union_disjoint(all_empty, *empty);
127
119
  }
128
2.51k
129
2.51k
  if (empty)
130
2.51k
    *empty = all_empty;
131
2.51k
  isl_set_free(dom);
132
2.51k
  isl_basic_map_free(bmap);
133
2.51k
  return res;
134
2.51k
error:
135
0
  if (empty)
136
0
    *empty = NULL;
137
0
  isl_set_free(dom);
138
0
  isl_basic_map_free(bmap);
139
0
  return NULL;
140
5.65k
}
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
242
{
148
242
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
242
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
242
}
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
}
isl_basic_map_lexopt
Line
Count
Source
147
180
{
148
180
  ISL_FL_SET(flags, ISL_OPT_FULL);
149
180
  return SF(isl_basic_map_partial_lexopt,SUFFIX)(bmap, NULL, NULL, flags);
150
180
}
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
}
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
}
Unexecuted instantiation: isl_basic_map_lexmin
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
11.6k
{
176
11.6k
  isl_bool aligned;
177
11.6k
178
11.6k
  aligned = isl_map_set_has_equal_params(map, dom);
179
11.6k
  if (aligned < 0)
180
0
    goto error;
181
11.6k
  if (aligned)
182
11.6k
    return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom,
183
11.6k
                empty, flags);
184
0
  if (!isl_space_has_named_params(map->dim) ||
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
11.6k
}
isl_map.c:isl_map_partial_lexopt
Line
Count
Source
175
11.6k
{
176
11.6k
  isl_bool aligned;
177
11.6k
178
11.6k
  aligned = isl_map_set_has_equal_params(map, dom);
179
11.6k
  if (aligned < 0)
180
0
    goto error;
181
11.6k
  if (aligned)
182
11.6k
    return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, dom,
183
11.6k
                empty, flags);
184
0
  if (!isl_space_has_named_params(map->dim) ||
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
11.6k
}
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
2.11k
{
206
2.11k
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
2.11k
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
2.11k
              flags);
209
2.11k
}
isl_map_lexopt_pw_multi_aff
Line
Count
Source
205
1.06k
{
206
1.06k
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
1.06k
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
1.06k
              flags);
209
1.06k
}
isl_map_lexopt
Line
Count
Source
205
1.05k
{
206
1.05k
  ISL_FL_SET(flags, ISL_OPT_FULL);
207
1.05k
  return SF(isl_map_partial_lexopt_aligned,SUFFIX)(map, NULL, NULL,
208
1.05k
              flags);
209
1.05k
}
210
211
__isl_give TYPE *SF(isl_map_lexmin,SUFFIX)(__isl_take isl_map *map)
212
1.30k
{
213
1.30k
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
1.30k
}
isl_map_lexmin_pw_multi_aff
Line
Count
Source
212
531
{
213
531
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
531
}
isl_map_lexmin
Line
Count
Source
212
777
{
213
777
  return SF(isl_map_lexopt,SUFFIX)(map, 0);
214
777
}
215
216
__isl_give TYPE *SF(isl_map_lexmax,SUFFIX)(__isl_take isl_map *map)
217
806
{
218
806
  return SF(isl_map_lexopt,SUFFIX)(map, ISL_OPT_MAX);
219
806
}
isl_map_lexmax_pw_multi_aff
Line
Count
Source
217
530
{
218
530
  return SF(isl_map_lexopt,SUFFIX)(map, ISL_OPT_MAX);
219
530
}
isl_map_lexmax
Line
Count
Source
217
276
{
218
276
  return SF(isl_map_lexopt,SUFFIX)(map, ISL_OPT_MAX);
219
276
}
220
221
__isl_give TYPE *SF(isl_set_lexmin,SUFFIX)(__isl_take isl_set *set)
222
666
{
223
666
  return SF(isl_map_lexmin,SUFFIX)(set);
224
666
}
isl_set_lexmin_pw_multi_aff
Line
Count
Source
222
531
{
223
531
  return SF(isl_map_lexmin,SUFFIX)(set);
224
531
}
isl_set_lexmin
Line
Count
Source
222
135
{
223
135
  return SF(isl_map_lexmin,SUFFIX)(set);
224
135
}
225
226
__isl_give TYPE *SF(isl_set_lexmax,SUFFIX)(__isl_take isl_set *set)
227
531
{
228
531
  return SF(isl_map_lexmax,SUFFIX)(set);
229
531
}
isl_set_lexmax_pw_multi_aff
Line
Count
Source
227
530
{
228
530
  return SF(isl_map_lexmax,SUFFIX)(set);
229
530
}
isl_set_lexmax
Line
Count
Source
227
1
{
228
1
  return SF(isl_map_lexmax,SUFFIX)(set);
229
1
}