<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 - Nested loop unroll bug on skylake avx512"
   href="https://bugs.llvm.org/show_bug.cgi?id=44544">44544</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Nested loop unroll bug on skylake avx512
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jakobschwarz@yahoo.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I think, I found a bug in clang, tested on local machines and on godbolt with
clang 7, 8 and 9. It only occurs with -O3 optimization and
-march=skylake-avx512. With GCC and Intel the code produces correct results.

Disabling loop nesting in the example is also fine with Clang. The code should
return just zeros in the cout print.

#include <iostream>

int main(int argc, char *argv[])
{
    static constexpr uint32_t mult = 4u;
    static constexpr uint64_t MASK_H = 0x000000000000FFFFull;
    uint64_t arr2[16][4];
    for(auto i=0; i<16; i++) for(auto j=0; j<4; j++) arr2[i][j] = ~uint64_t(0);

    uint64_t* mm =&arr2[0][0];
    for(uint32_t zz=0; zz<16; zz++){
// #pragma clang loop unroll(disable)
        for(uint32_t yy=0; yy<16; yy++){
            const uint32_t ID   = yy+zz*16;
            const uint64_t mask = ~(MASK_H<<(ID%mult*16));
            mm[ID/mult] &= mask;
        }
    }
    for(auto i=0; i<16; i++) {
        for(auto j=0; j<4; j++) std::cout << arr2[i][j] << " ";
        std::cout << std::endl;
    }
    return 0;
}</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>