title: LLVM fails to detect very simple loop trip count
body: <p>I'm trying to understand how the loop trip count calculation happens in LLVM using the Scalar Evolution analysis. However, I can't get a simple test case to work.</p>
  
  <p>I have the following test program:</p>
  
  <pre><code>// bug.cpp
  int main()
  {
    for (int i = 0; i &lt; 16; i++) {
      // do nothing
    }
    return 0;
  }
  </code></pre>
  
  <p>Which I compile like this:</p>
  
  <pre><code>$ clang++ -O0 -emit-llvm -c -o bug.bc bug.cpp
  </code></pre>
  
  <p>And analyze like this:</p>
  
  <pre><code>$ opt -analyze -indvars -loop-simplify -scalar-evolution &lt; bug.bc
  </code></pre>
  
  <p>But the output of the scalar evolution is this:</p>
  
  <pre><code>...
  Determining loop execution counts for: @main
  Loop %for.cond: Unpredictable backedge-taken count.
  Loop %for.cond: Unpredictable max backedge-taken count.
  </code></pre>
  
  <p>Why is this very simple loop have an unpredictable trip count? Am I doing something wrong in invoking the analysis? This is LLVM 3.4.</p>