<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 - Clang produces incorrect code with -O2 and higher"
   href="https://bugs.llvm.org/show_bug.cgi?id=32830">32830</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang produces incorrect code with -O2 and higher
          </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>Linux
          </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>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18373" name="attach_18373" title="Reproducer.">attachment 18373</a> <a href="attachment.cgi?id=18373&action=edit" title="Reproducer.">[details]</a></span>
Reproducer.

Reproducer:
<span class="quote">>$ cat repr.c </span >
extern const long int var_47;
extern const long int var_53;
extern const long long int var_58;
extern long int var_579;

void foo() { 
    var_579 = ((var_58 | var_53) ^ ~var_58) & (var_47 | ~var_58);
}

<span class="quote">>$ cat main.c </span >
#include <stdio.h>

extern void foo ();

const long int var_47 = 6664195969892517546L;
const long int var_53 = 1679594420099092216L;
const long long int var_58 = 1515497576132836640LL;
long int var_579 = -7475619439701949757L;

int main () {
    foo ();
    printf ("%ld\n", var_579);
    return 0;
}

Error:
<span class="quote">>$ clang -O0 main.c repr.c; ./a.out </span >
-236191838907956185
<span class="quote">>$ clang -O2 main.c repr.c; ./a.out </span >
-5292815780869864331

LLVM version:
<span class="quote">>$ clang -vclang version 5.0.0 (trunk 301477)</span >
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/vsevolod/workspace/llvm/bin-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
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>