Bugzilla – Bug 194
[indvars] Induction variable canonicalization always makes 32-bit indvars
Last modified: 2003-12-21 22:01:24
You need to log in before you can comment on or make changes to this bug.
The induction variable canonicalization pass inserts new canonical induction variables if a loop is lacking one, but it always chooses to insert a 32-bit induction variable. This can turn legal loops into infinite loops, such as this one: --- long long V; int main() { long long X; for (X = 1; X < (1ULL << 33); ++X) V = X; printf("%lld\n", V); // erroneously not reached } --- Though always introducing 64-bit induction variables would be acceptable, the right approach is to insert a variable which is the largest of the existing auxillary induction variables. -Chris
Ugh, this gets worse. The indvars pass is attempting to take an existing canonical induction variable if it exists, instead of introducing a new one (a nobel goal). However, since it's ignoring the size of the existing variable, it can cause neat miscompilations is cases like this: void test() { int I; unsigned char C; for (C = 0, I = 1; I != 12300; ++C, ++I) foo(I); } Luckily, it appears extremely uncommon for programs to use loops with mixed sized induction variables. -Chris
Fixed. Testcase here: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20031215/010403.html Patch here: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20031215/010409.html -Chris