<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 - O2 and O2 lto result differ"
   href="https://bugs.llvm.org/show_bug.cgi?id=40373">40373</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>O2 and O2 lto result differ
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>6.0
          </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>Interprocedural Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>konstantin.vladimirov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Simple test (after creduce):

---
unsigned b, c, d, e, f;

int main() {
  unsigned h[15] = {3, 12, 2, 10, 6, 11, 7, 9, 8, 14, 3, 5, 1, 4, 0};
  unsigned long i[15] = {0}, j[15] = {0};
  for (; e < 7; e++) {
    for (d = 0; d < 15; d += 3) {
      f = 305 ^ j[d] >> 5;
      j[d] = (104 * j[d] ^ d) - (-j[d] < 8) & 906;
    }
    for (c = 1; c < 15; c++) {
      b = i[h[c]];
      i[h[c]] = 3 - i[h[c]];
    }
  }
  return b;
}
---

clang -O2 test.c -o corr
clang -O2 -flto test.c -o wrong

<span class="quote">> wrong
> echo $?</span >
238
<span class="quote">> corr
> echo $?</span >
0


<span class="quote">> clang -v</span >
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/i586-suse-linux/2.95.3
Found candidate GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.3
Selected GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.3
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64</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>