<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 --- - making zeros the hard way: scalar load into zero vector (AVX)"
   href="http://llvm.org/bugs/show_bug.cgi?id=22685">22685</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>making zeros the hard way: scalar load into zero vector (AVX)
          </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>Backend: X86
          </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>$ cat insert.ll
define <8 x float> @mov00(float* %ptr) {
  %val = load float* %ptr
  %vec = insertelement <8 x float> zeroinitializer, float %val, i32 0
  ret <8 x float> %vec
}

Using llc built from r230234:

$ ./llc insert.ll -o - -mattr=avx
...
    vxorps    %xmm0, %xmm0, %xmm0
    vinsertps    $0, (%rdi), %xmm0, %xmm0 ## xmm0 = mem[0],xmm0[1,2,3]
    vxorps    %ymm1, %ymm1, %ymm1
    vinsertf128    $0, %xmm0, %ymm1, %ymm0
    retq


But if we change the vector to be undef initialized:
  %vec = insertelement <8 x float> undef, float %val, i32 0

We get the expected:
    vmovss    (%rdi), %xmm0           ## xmm0 = mem[0],zero,zero,zero
    retq

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

This may be complicated by the fact that a non-VEX prefix 'movss' leaves the
upper 128-bit undef. 

But with AVX, the Intel manual says:

VMOVSS (VEX.NDS.128.F3.0F 10 /r when the source operand is memory and the
destination is an XMM register)

DEST[31:0] <- SRC[31:0] 
DEST[VLMAX-1:32] <- 0</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>