<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 --- - [loop vectorizer] failure to vectorize int to fp conversions for <256 bit vectors"
   href="http://llvm.org/bugs/show_bug.cgi?id=21356">21356</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[loop vectorizer] failure to vectorize int to fp conversions for <256 bit vectors
          </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>All
          </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>spatel+llvm@rotateright.com
          </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>Using clang/tools built from r220352:

Original C source:

void foo(int *x, float *y) {
        int i;
        for (i=0; i<1024; i++) {
                y[i] = x[i];
        }
}

-----------------------------------------------------------------

Reduced IR test case:

$ cat lvbug.ll 
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.9.0"

define void @foo(i32* nocapture readonly %x, float* nocapture %y) {
entry:
  br label %for.body

for.body:
  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
  %arrayidx = getelementptr inbounds i32* %x, i64 %indvars.iv
  %0 = load i32* %arrayidx, align 4
  %conv = sitofp i32 %0 to float
  %arrayidx2 = getelementptr inbounds float* %y, i64 %indvars.iv
  store float %conv, float* %arrayidx2, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv, 1023
  br i1 %exitcond, label %for.end, label %for.body

for.end:
  ret void
}

----------------------------------------------------------------

$ ./opt -mcpu=core2  -loop-vectorize lvbug.ll -S | grep sitofp
  %conv = sitofp i32 %0 to float

But with 256-bit vectors available:

$ ./opt -mcpu=core-avx2  -loop-vectorize lvbug.ll -S | grep sitofp
  %104 = sitofp <8 x i32> %wide.load to <8 x float>
  %105 = sitofp <8 x i32> %wide.load9 to <8 x float>
  %106 = sitofp <8 x i32> %wide.load10 to <8 x float>
  %107 = sitofp <8 x i32> %wide.load11 to <8 x float>
  %conv = sitofp i32 %189 to float</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>