~ubuntu-branches/ubuntu/trusty/cloog/trusty

« back to all changes in this revision

Viewing changes to isl/isl_flow.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-10-17 15:54:24 UTC
  • mfrom: (3.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20131017155424-3q1gw7yhddylfkpj
Tags: 0.18.1-1
* New upstream version.
* Add a comment to build-depend on libpod-latex-perl | perl (<< 5.17.0),
  when the documentation is built. Closes: #711681.
* Use dh_autotools-dev to update config.{sub,guess}. Closes: #719957.

Show diffs side-by-side

added added

removed removed

Lines of Context:
373
373
 */
374
374
static __isl_give isl_flow *isl_flow_alloc(__isl_keep isl_access_info *acc)
375
375
{
376
 
        int i;
 
376
        int i, n;
377
377
        struct isl_ctx *ctx;
378
378
        struct isl_flow *dep;
379
379
 
385
385
        if (!dep)
386
386
                return NULL;
387
387
 
388
 
        dep->dep = isl_calloc_array(ctx, struct isl_labeled_map,
389
 
                                        2 * acc->n_must + acc->n_may);
390
 
        if (!dep->dep)
 
388
        n = 2 * acc->n_must + acc->n_may;
 
389
        dep->dep = isl_calloc_array(ctx, struct isl_labeled_map, n);
 
390
        if (n && !dep->dep)
391
391
                goto error;
392
392
 
393
 
        dep->n_source = 2 * acc->n_must + acc->n_may;
 
393
        dep->n_source = n;
394
394
        for (i = 0; i < acc->n_must; ++i) {
395
395
                isl_space *dim;
396
396
                dim = space_align_and_join(
1127
1127
        isl_space *dim;
1128
1128
        struct isl_sched_info *info;
1129
1129
        int i, n;
1130
 
        isl_int v;
1131
1130
 
1132
1131
        if (!map)
1133
1132
                return NULL;
1144
1143
                return NULL;
1145
1144
        info->is_cst = isl_alloc_array(ctx, int, n);
1146
1145
        info->cst = isl_vec_alloc(ctx, n);
1147
 
        if (!info->is_cst || !info->cst)
 
1146
        if (n && (!info->is_cst || !info->cst))
1148
1147
                goto error;
1149
1148
 
1150
 
        isl_int_init(v);
1151
1149
        for (i = 0; i < n; ++i) {
1152
 
                info->is_cst[i] = isl_map_plain_is_fixed(map, isl_dim_in, i,
1153
 
                                                         &v);
1154
 
                info->cst = isl_vec_set_element(info->cst, i, v);
 
1150
                isl_val *v;
 
1151
 
 
1152
                v = isl_map_plain_get_val_if_fixed(map, isl_dim_in, i);
 
1153
                if (!v)
 
1154
                        goto error;
 
1155
                info->is_cst[i] = !isl_val_is_nan(v);
 
1156
                if (info->is_cst[i])
 
1157
                        info->cst = isl_vec_set_element_val(info->cst, i, v);
 
1158
                else
 
1159
                        isl_val_free(v);
1155
1160
        }
1156
 
        isl_int_clear(v);
1157
1161
 
1158
1162
        return info;
1159
1163
error:
1254
1258
        struct isl_sched_info *info2 = second;
1255
1259
        int n1, n2;
1256
1260
        int i;
1257
 
        isl_int v1, v2;
1258
1261
 
1259
1262
        n1 = isl_vec_size(info1->cst);
1260
1263
        n2 = isl_vec_size(info2->cst);
1262
1265
        if (n2 < n1)
1263
1266
                n1 = n2;
1264
1267
 
1265
 
        isl_int_init(v1);
1266
 
        isl_int_init(v2);
1267
1268
        for (i = 0; i < n1; ++i) {
1268
1269
                int r;
 
1270
                int cmp;
1269
1271
 
1270
1272
                if (!info1->is_cst[i])
1271
1273
                        continue;
1272
1274
                if (!info2->is_cst[i])
1273
1275
                        continue;
1274
 
                isl_vec_get_element(info1->cst, i, &v1);
1275
 
                isl_vec_get_element(info2->cst, i, &v2);
1276
 
                if (isl_int_eq(v1, v2))
 
1276
                cmp = isl_vec_cmp_element(info1->cst, info2->cst, i);
 
1277
                if (cmp == 0)
1277
1278
                        continue;
1278
1279
 
1279
 
                r = 2 * i + isl_int_lt(v1, v2);
 
1280
                r = 2 * i + (cmp < 0);
1280
1281
 
1281
 
                isl_int_clear(v1);
1282
 
                isl_int_clear(v2);
1283
1282
                return r;
1284
1283
        }
1285
 
        isl_int_clear(v1);
1286
 
        isl_int_clear(v2);
1287
1284
 
1288
1285
        return 2 * n1;
1289
1286
}
1322
1319
 
1323
1320
        data->accesses = isl_access_info_alloc(isl_map_copy(map),
1324
1321
                                data->sink_info, &before, data->count);
1325
 
        if (!data->sink_info || !data->source_info || !data->accesses)
 
1322
        if (!data->sink_info || (data->count && !data->source_info) ||
 
1323
            !data->accesses)
1326
1324
                goto error;
1327
1325
        data->count = 0;
1328
1326
        data->must = 1;