<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Different unrolling behavior with manual hoisting"
   href="https://bugs.llvm.org/show_bug.cgi?id=34775">34775</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Different unrolling behavior with manual hoisting
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>5.0
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>opt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>piotr.padlewski@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hey,
I am not sure if this is a bug or it is by design, but I recently found out
that
clang unrolls these two loops in different way:

#include <vector>

void bar(std::vector<int> &v, int* p) {
  auto size = v.size();
  for (int i = 0 ; i < size; i++)
    p[i] = v[i];
}

void bar2(std::vector<int> &v, int* p) {
  for (int i = 0 ; i < v.size(); i++)
    p[i] = v[i];
}

<a href="https://godbolt.org/g/U1kH8P">https://godbolt.org/g/U1kH8P</a>

I would probably guess that LICM hoists the size after the unrolling, but I
haven't checked that and also have no idea which one is faster. It is just
weird to me that we were able to hoist v.size() in the bar2, but did not
perform the same unrolling.</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>