<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 - #pragma clang loop unroll(enable) has no limit for fixed iteration loops"
   href="https://bugs.llvm.org/show_bug.cgi?id=41106">41106</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>#pragma clang loop unroll(enable) has no limit for fixed iteration loops
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </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>husseydevin@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>LLVM will unroll every fixed iteration loop entirely with the unroll(enable)
pragma, no matter how ridiculous it is. 

unsigned foo(const unsigned *x)
{
    unsigned acc = 0;
#pragma clang loop unroll(enable)
    for (int i = 0; i < 100; i++) {
        acc += *x++;
    }
    return acc;
}

Stumbled upon this code.

Compile it with -O3. Clang will unroll this loop 100 times. Change it to 500
times, it will unroll it 500 times. Change it to 10000, it will unroll it 10000
times.

How is that useful?

LLVM shouldn't take the unroll pragma so damn literally. Anything above 32-64
iterations is waaaaaaaaay too much, and that is what unroll_count should be
for, to override this limit.</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>