incorrect generated code with negative iterators and modulo

6 views
Skip to first unread message

Sven Verdoolaege

unread,
Sep 29, 2012, 7:35:37 AM9/29/12
to cloog-de...@googlegroups.com, Cédric Bastoul, Tobias Grosser, Albert Cohen
FYI,

CLooG seems to assume that the '%' operator in C always
returns a non-negative number, whereas in fact it returns
a number of the same sign as the first argument.

The attached input illustrates the problem.

$ ./cloog /tmp/mod.cloog
/* Generated from /tmp/mod.cloog by CLooG 0.17.0-14-g633a9e1 gmp bits in 0.00s. */
for (i=-100;i<=100;i++) {
if (i%5 <= 1) {
S1(i);
}
}
$ ./cloog -compilable 1 /tmp/mod.cloog > /tmp/mod.c
$ gcc -o /tmp/mod /tmp/mod.c
$ /tmp/mod | tail
S1 80
S1 81
S1 85
S1 86
S1 90
S1 91
S1 95
S1 96
S1 100
Number of integral points: 141.

In fact the input only contains 81 points:

$ ./iscc
card
4 4 1 0 1 0
1 1 0 100
1 -1 0 100
1 1 -5 0
1 -1 5 1
;
$0 := { 81 }


(It's not entirely impossible that I may have been the one to introduce
this problem.)

skimo
mod.cloog

Cédric Bastoul

unread,
Sep 29, 2012, 7:50:25 AM9/29/12
to sk...@kotnet.org, cloog-de...@googlegroups.com, Tobias Grosser, Albert Cohen
Thanks for reporting,
the problem is there since forever as I totally forgot that point...

Ced. (ashamed)
Reply all
Reply to author
Forward
0 new messages