<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Failure to compute loop count (and, thus, vectorize)"
   href="http://llvm.org/bugs/show_bug.cgi?id=19394">19394</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Failure to compute loop count (and, thus, vectorize)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Loop Optimizer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hfinkel@anl.gov
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12363" name="attach_12363" title="test case">attachment 12363</a> <a href="attachment.cgi?id=12363&action=edit" title="test case">[details]</a></span>
test case

We currently are unable to vectorize (or do much of anything else) with the
following loop:

omp.lb.le.global_ub..lr.ph.split.us:              ; preds = %entry
  %12 = sext i32 %7 to i64
  br label %omp.lb.le.global_ub..us

omp.lb.le.global_ub..us:                          ; preds =
%omp.lb_ub.check_pass.us, %omp.lb.le.global_ub..lr.ph.split.us
  %indvars.iv14 = phi i64 [ %indvars.iv.next15, %omp.lb_ub.check_pass.us ], [
%12, %omp.lb.le.global_ub..lr.ph.split.us ]
  %13 = trunc i64 %indvars.iv14 to i32
  %omp.idx.le.ub.us = icmp sgt i32 %13, %10
  br i1 %omp.idx.le.ub.us, label %omp.loop.end.loopexit, label
%omp.lb_ub.check_pass.us

omp.lb_ub.check_pass.us:                          ; preds =
%omp.lb.le.global_ub..us
  %14 = load double* %ref3, align 8, !tbaa !4
  %arrayidx.us = getelementptr inbounds [10000000 x double]* @c, i64 0, i64
%indvars.iv14
  %15 = load double* %arrayidx.us, align 8, !tbaa !4
  %mul5.us = fmul double %14, %15
  %arrayidx6.us = getelementptr inbounds [10000000 x double]* @b, i64 0, i64
%indvars.iv14
  store double %mul5.us, double* %arrayidx6.us, align 8, !tbaa !4
  %indvars.iv.next15 = add nsw i64 %indvars.iv14, 1
  br label %omp.lb.le.global_ub..us

omp.loop.end.loopexit:                            ; preds =
%omp.lb.le.global_ub..us
  br label %omp.loop.end


this is important because this is what is generated by Intel's OpenMP branch
(after optimization) from this basic loop (the outlined portion):

        ssize_t j;
#pragma omp parallel for
        for (j=0; j<STREAM_ARRAY_SIZE; j++)
            c[j] = a[j];

running opt -analyze -scalar-evolution -S < /tmp/stream_omt35.ll demonstrates
the problem. SE seems to understand the loop induction variable well enough:

  %indvars.iv.next15 = add nsw i64 %indvars.iv14, 1
  -->  {(1 + (sext i32 %7 to i64)),+,1}<nsw><%omp.lb.le.global_ub..us>       
Exits: <<Unknown>>

but it cannot compute an expression for the backedge count:

Determining loop execution counts for: @.omp_microtask.35
Loop %omp.lb.le.global_ub..us: Unpredictable backedge-taken count. 
Loop %omp.lb.le.global_ub..us: Unpredictable max backedge-taken count. 

We should either enhance SE, or maybe there is a different want to formulate
the loop in the frontend that will be friendlier to the existing SE
implementation.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>