On Mon, Apr 06, 2026 at 08:08:15AM +0530, Uday K Bondhugula wrote:
> With barvinok at its latest tip barvinok-0.41.8, code generation for this
> spec below yields an AST with guards '1 == 0' a couple of times in the 'if'
> nodes. Would be good to simplify these away. Updated isl submodule
> to dc16f8e3d62c9e808ef86ffe82c2b93ac1446da3 and this is solved - update
> barvinok?
If you need that, then you should indeed use a newer version of isl.
> $ ./iscc
> codegen [p0] -> { C0[i0, i1, i2, i3] -> [i0, i1, i2, i3] : exists (e0, e1,
> e2: 0 <= p0 <= 48 and 0 <= i3 <= 127 and -2 + i1 <= 2e0 <= i1 and e2 >= 0
> and e2 >= -128p0 + 784i0 + 28e0 and e2 >= -128p0 + 784i0 and -128p0 + 28e1
> <= e2 <= 27 - 128p0 + 28e1 and e2 <= 783 - 128p0 + 784i0 and e2 <= 27 -
> 128p0 + 784i0 + 28e0 and e2 <= 127 and -2 - 256p0 + i2 + 56e1 <= 2e2 <=
> -256p0 + i2 + 56e1)};
[..]
>
> While on this, is there a way (through the interactive tool) to set options
> to fully separate and avoid all 'if' conditionals here? Programmatically,
Is the set you are trying to iterate over convex?
If not, it may not even be possible to generate iteration code
without if-statements.
Do you have any additional information about this particular set that
makes you believe it should be possible to generate an AST in this way?
> using the following still leads to the above AST with conditionals, i.e.,
> the separation isn't happening.
>
> isl_union_map *optionsMap =
>
> isl_union_map_empty(isl_space_range(isl_union_map_get_space(schedule)));
> // Avoid the generation of guards by splitting the domain of the schedule
> // dimensions into pieces with a fixed set of statements.
> optionsMap = setUniverse(optionsMap, schedule, "separate");
> isl_ast_build *build =
> isl_ast_build_alloc(isl_union_map_get_ctx(schedule));
> build = isl_ast_build_set_options(build, optionsMap);
> isl_ast_node *tree = isl_ast_build_node_from_schedule_map(build,
> schedule);
> isl_ast_dump(tree);
AFAICT, there is only one statement involved, so the generated AST
is always "separate".
On Mon, Apr 06, 2026 at 08:19:13AM +0530, Uday K Bondhugula wrote:
> It may be useful to explicitly specify in the manual that separation isn't
> guaranteed. For example, here: 32 * p0 + 7 * (c1 / 2) + 38 >= 196 * c0 + 7
> * c1 would appear to be a blocker for separation on `c1`.
[..]
The AST again appears to involve only a single statement,
so it is trivially "separate".
Hmm... maybe you are confused by this description of the schedule map
ast generation option:
This is a single-dimensional space representing the schedule dimension(s)
to which ``separation'' should be applied. Separation tries to split
a loop into several pieces if this can avoid the generation of guards
inside the loop.
I guess this is a bit vague.
The corresponding option for schedule trees has a better explanation:
When this option is specified, the AST generator will
split the domain of the specified schedule dimension
into pieces with a fixed set of statements for which
instances need to be executed by the iterations in
the schedule domain part. This option tends to avoid
the generation of guards inside the corresponding loops.
AFAIR, the two have essentially the same meaning, but the description
of the second is a bit better.
skimo