<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:sanjay3.0.0.0@gmail.com" title="Sanjay <sanjay3.0.0.0@gmail.com>"> <span class="fn">Sanjay</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - loop increment/compare/branch should be removed for vectorized and unrolled code"
   href="http://llvm.org/bugs/show_bug.cgi?id=17803">bug 17803</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>sanjay3.0.0.0@gmail.com
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>FIXED
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - loop increment/compare/branch should be removed for vectorized and unrolled code"
   href="http://llvm.org/bugs/show_bug.cgi?id=17803#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - loop increment/compare/branch should be removed for vectorized and unrolled code"
   href="http://llvm.org/bugs/show_bug.cgi?id=17803">bug 17803</a>
              from <span class="vcard"><a class="email" href="mailto:sanjay3.0.0.0@gmail.com" title="Sanjay <sanjay3.0.0.0@gmail.com>"> <span class="fn">Sanjay</span></a>
</span></b>
        <pre>This looks ideal with clang 3.5 (r205798):

bin$ ./clang -v
clang version 3.5.0 (trunk 205798) (llvm/trunk 205792)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
bin$ ./clang xor.c -O3 -fomit-frame-pointer -o - -S -march=core-avx2
...
## BB#0:                                ## %entry
    vmovaps    LCPI0_0(%rip), %ymm0
    vxorps    (%rdi), %ymm0, %ymm1
    vxorps    32(%rdi), %ymm0, %ymm2
    vxorps    64(%rdi), %ymm0, %ymm3
    vxorps    96(%rdi), %ymm0, %ymm0
    vmovups    %ymm1, (%rdi)
    vmovups    %ymm2, 32(%rdi)
    vmovups    %ymm3, 64(%rdi)
    vmovups    %ymm0, 96(%rdi)
    vzeroupper
    retq


With a plain 'avx' target rather than 'avx2', we go through all kinds of
gymnastics to avoid unaligned 32-bit load or store, but the leftover loop
problem is still fixed:

$ ./clang xor.c -O3 -fomit-frame-pointer -o - -S -march=corei7-avx
...
## BB#0:                                ## %entry
    vmovups    (%rdi), %xmm0
    vmovups    32(%rdi), %xmm1
    vmovups    64(%rdi), %xmm2
    vmovups    96(%rdi), %xmm3
    vinsertf128    $1, 16(%rdi), %ymm0, %ymm0
    vinsertf128    $1, 48(%rdi), %ymm1, %ymm1
    vinsertf128    $1, 80(%rdi), %ymm2, %ymm2
    vinsertf128    $1, 112(%rdi), %ymm3, %ymm3
    vmovaps    LCPI0_0(%rip), %ymm4
    vxorps    %ymm4, %ymm0, %ymm0
    vxorps    %ymm4, %ymm1, %ymm1
    vxorps    %ymm4, %ymm2, %ymm2
    vxorps    %ymm4, %ymm3, %ymm3
    vextractf128    $1, %ymm0, %xmm4
    vmovups    %xmm4, 16(%rdi)
    vmovups    %xmm0, (%rdi)
    vextractf128    $1, %ymm1, %xmm0
    vmovups    %xmm0, 48(%rdi)
    vmovups    %xmm1, 32(%rdi)
    vextractf128    $1, %ymm2, %xmm0
    vmovups    %xmm0, 80(%rdi)
    vmovups    %xmm2, 64(%rdi)
    vextractf128    $1, %ymm3, %xmm0
    vmovups    %xmm0, 112(%rdi)
    vmovups    %xmm3, 96(%rdi)
    vzeroupper
    retq</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>