<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - can't delete empty, terminating, strided loop"
   href="http://llvm.org/bugs/show_bug.cgi?id=19183">bug 19183</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>RESOLVED
           </td>
           <td>REOPENED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>FIXED
           </td>
           <td>---
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - can't delete empty, terminating, strided loop"
   href="http://llvm.org/bugs/show_bug.cgi?id=19183#c2">Comment # 2</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - can't delete empty, terminating, strided loop"
   href="http://llvm.org/bugs/show_bug.cgi?id=19183">bug 19183</a>
              from <span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span></b>
        <pre>Thanks!

Sadly, this isn't enough to clean up the mess left behind by the vectorizer
(presumably because the vectorization happens too late). This testcase still
leaves behind a do-nothing loop:

#include <memory>
#include <cstring>

long test(int iters, int len, int sticky)
{
  const int block_size = 0x1000;
  const int blocks = len / block_size;
  std::unique_ptr<char[]> source(new char[blocks * block_size]);
  std::unique_ptr<char[]> destination(new char[blocks * block_size]);

  for (int i = 0; i < iters; ++i) {
    char *psrc = source.get();
    char *pdst = destination.get();
    for (int block = 0; block < blocks; ++block) {
      memcpy(psrc, pdst, block_size);
      psrc += block_size;
      pdst += block_size;
      if (sticky) {
        psrc -= block_size;
        pdst -= block_size;
      }
    }
  }

  return long(iters) * blocks * block_size;
}

Running opt a second time on the output of clang -O3 -emit-llvm does remove the
do-nothing loop now, though.

(We should really be able to delete the entire function body, but that's a
separate issue...)</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>