First Last Prev Next    No search results available
Details
: [indvars] Induction variable canonicalization always make...
Bug#: 194
: libraries
: Scalar Optimizations
Status: RESOLVED
Resolution: FIXED
: All
: All
: 1.0
: P2
: normal
: 1.2

:
: code-quality, miscompilation
:
:
  Show dependency tree - Show dependency graph
People
Reporter: Chris Lattner <sabre@nondot.org>
Assigned To: Chris Lattner <sabre@nondot.org>

Attachments


Note

You need to log in before you can comment on or make changes to this bug.

Related actions


Description:   Opened: 2003-12-20 20:52
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
------- Comment #1 From Chris Lattner 2003-12-21 14:28:35 -------
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

First Last Prev Next    No search results available