<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 - Incorrect result with -O3 -march=skx"
   href="https://bugs.llvm.org/show_bug.cgi?id=42833">42833</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect result with -O3 -march=skx
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>Vsevolod.Livinskij@frtk.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang produces incorrect result with -O3 -march=skx

Reproducer:
#include <stdio.h>

int b;
unsigned c[49];
int d[49];

void i() {
  for (int g = 32; g <= 48; g++) {
    d[g] -= c[g] + b;
    c[g] += c[g] + b;
    b -= b;
  }
}

int main() {
  for (int g = 0; g < 49; ++g)
    c[g] = 3;
  i();
  printf("%d\n", d[36]);
}

Error:
<span class="quote">>$ clang -O3 -march=skx small.c ; ./a.out</span >
0
<span class="quote">>$ clang -O0 -march=skx small.c ; ./a.out</span >
-3

LLVM version:
clang version 10.0.0 (trunk 367162)
Target: x86_64-unknown-linux-gnu
Thread model: posix</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>