<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 --- - Implement Pragma Vectorize - Choice/Parameters"
   href="http://llvm.org/bugs/show_bug.cgi?id=18086">18086</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Implement Pragma Vectorize - Choice/Parameters
          </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>Linux
          </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>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>renato.golin@linaro.org
          </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>Implementing pragmas to control vectorization is important to work around
deficiencies in the compiler, language or to create specific tests without
confusing boilerplate or specific target defined.

These pragmas are also great for probing what the compiler is able to do, and
to pick and chose widths and unroll factors that the compiler gets the cost
wrong. Hopefully, users will use them to report improvements to the compiler.

The simplest vectorization pragmas to implement:

#pragma vectorize enable/disable

Simply turns the vectorizer on/off on that loop. This doesn't guarantee that
the loop will get vectorized if it's not legal, but it will enable the
vectorizer even if the optimization level is too low or if the cost model
thinks it's a bad idea.

#pragma vectorize width(4)

for (i = 0; i < N; ++i) {
  A[i] = B[i];
}
=>    
for (i = 0; i < N; i +=4) {
  A[i:i+3] = B[i:i+3];
}

#pragma vectorize unroll(2)

for (i = 0; i < N; ++i) {
  A[i] = B[i];
}
=>    
for (i = 0; i < N; i +=2) {
  A[i] = B[i];
  A[i+1] = B[i+1];
}

Ultimately, the pragmas need to trigger warnings to the user, explaining why,
if some of the instructions could not be followed, for instance if:

- The target doesn't support the specified width
- The loop cannot be vectorized because of memory dependencies</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>