Stride detection fails in AST generation in presence of floordiv expression

3 views
Skip to first unread message

Vimal Patel

unread,
Apr 26, 2026, 6:35:46 AM (3 days ago) Apr 26
to isl Development
Hi,

I have two schedule maps:

[N] -> { S[i0] -> [i0] : exists (e0 : i0 = N + 6*e0 and 0 <= e0 <= 1) }
and,
[N] -> { S[i0] -> [i0] : exists (e0 : i0 = floor(N/2) + 6*e0 and 0 <= e0 <= 1) }

I'm trying to generate ASTs for these maps, but stride detection fails
to detect the stride of i0. The generated ASTs with ISL version
01147343-GMP are as follows:

for (int c0 = N; c0 <= N + 6; c0 += 6)
S(c0);

for (int c0 = floord(N, 2); c0 <= floord(N, 2) + 6; c0 += 1)
if ((-N + 2 * c0 + 11) % 12 >= 10)
S(c0);

I want to avoid the `if` condition in the second AST. Is there any
transformation that can be applied to the schedule so that the stride
gets detected, so that the if condition in the AST could be avoided?

I would really appreciate any help in this matter.

Thanks & Regards,
Vimal Patel,
Staff AI Compiler Engineer,
Polymage Labs.

Sven Verdoolaege

unread,
Apr 26, 2026, 5:25:03 PM (3 days ago) Apr 26
to Vimal Patel, isl Development
On Sun, Apr 26, 2026 at 04:05:08PM +0530, Vimal Patel wrote:
> Hi,
>
> I have two schedule maps:
>
> [N] -> { S[i0] -> [i0] : exists (e0 : i0 = N + 6*e0 and 0 <= e0 <= 1) }
> and,
> [N] -> { S[i0] -> [i0] : exists (e0 : i0 = floor(N/2) + 6*e0 and 0 <= e0 <= 1) }
>
> I'm trying to generate ASTs for these maps, but stride detection fails
> to detect the stride of i0. The generated ASTs with ISL version
> 01147343-GMP are as follows:

I'm guessing this is a local version of yours because I don't have that.

> for (int c0 = N; c0 <= N + 6; c0 += 6)
> S(c0);
>
> for (int c0 = floord(N, 2); c0 <= floord(N, 2) + 6; c0 += 1)
> if ((-N + 2 * c0 + 11) % 12 >= 10)
> S(c0);
>
> I want to avoid the `if` condition in the second AST. Is there any
> transformation that can be applied to the schedule so that the stride
> gets detected, so that the if condition in the AST could be avoided?

If you somehow now in advance that this is going to happen,
then you could an extra parameter, say T, with constraint T = floor(N/2)
in the context and then the loop should get generated in terms of T,
at which point you can just plug in T = floor(N/2) in the generated AST.

However, isl should be able to detect such cases with some modifications.
I'll see if I can do that next weekend.

skimo

Vimal Patel

unread,
Apr 26, 2026, 10:53:55 PM (3 days ago) Apr 26
to sven.ver...@gmail.com, isl Development
Hi Sven,

Thanks for the reply. Yeah, seems like I missed checking the latest version. Also, I think it should be possible to preprocess the constraints, as you suggested, so that there is no floordivs.

> However, isl should be able to detect such cases with some modifications. I'll see if I can do that next weekend.

Thanks, that would be very helpful. Looking forward to it.

Thanks & Regards,
Vimal Patel,
Staff Compiler Engineer,
Polymage Labs.
Reply all
Reply to author
Forward
0 new messages