<html>
    <head>
      <base href="https://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 fails to maximize the use of __builtin_assume()"
   href="https://llvm.org/bugs/show_bug.cgi?id=26167">26167</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Loop vectorizer fails to maximize the use of __builtin_assume()
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.7
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </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>opt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>marksl@synopsys.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I've been able to get the loop vectorizer to understand that the number of
iterations is positive, but I can't get it to understand it's both positive and
will iterate an even number of times. A scalar loop is produced for each of the
following test cases.

void vcpy1(short* restrict d, const char* restrict l, const char* restrict r,
int N) {
  __builtin_assume( (N > 1) && (N%2 == 0) );
#pragma clang loop vectorize(enable) vectorize_width(2)
  for (int j=0;j<N;j++)
    d[j] = l[j] + r[j];
}
void vcpy2(short* restrict d, const char* restrict l, const char* restrict r,
int N) {
  __builtin_assume( (N > 1) && ((N&1) == 0) );
#pragma clang loop vectorize(enable) vectorize_width(2)
  for (int j=0;j<N;j++)
    d[j] = l[j] + r[j];
}
void vcpy3(short* restrict d, const char* restrict l, const char* restrict r,
int N) {
  __builtin_assume(N > 1);
  __builtin_assume(N%2 == 0);
#pragma clang loop vectorize(enable) vectorize_width(2)
  for (int j=0;j<N;j++)
    d[j] = l[j] + r[j];
}
void vcpy4(short* restrict d, const char* restrict l, const char* restrict r,
int N) {
  __builtin_assume(N > 1);
  __builtin_assume((N&1) == 0);
#pragma clang loop vectorize(enable) vectorize_width(2)
  for (int j=0;j<N;j++)
    d[j] = l[j] + r[j];
}</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>