<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 wrong code with -O1 (Combine redundant instructions on function)"
   href="https://bugs.llvm.org/show_bug.cgi?id=46561">46561</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang produces wrong code with -O1 (Combine redundant instructions on function)
          </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>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>opt-bisect limit points to Combine redundant instructions on function

<span class="quote">>$ clang++ -w -O1 driver.cpp func.cpp && ./a.out </span >
42
<span class="quote">>$ clang++ -w -O0 driver.cpp func.cpp && ./a.out </span >
0

Reproducer:
Func.cpp 
extern const bool tf_4_var_4;
extern const int tf_4_var_72;
extern unsigned long long int tf_4_var_124;
extern bool tf_4_array_3;
extern const bool tf_4_ptr_1;

void tf_4_foo() {
    if (~(tf_4_var_72 ? tf_4_ptr_1 * tf_4_array_3 ^ ~tf_4_var_4 : 0))
        tf_4_var_124 = 0;
}

Driver.cpp 
#include <stdio.h>
#include "init.h"

const bool tf_4_var_4 = true;
const int tf_4_var_72 = 2085646722;
unsigned long long int tf_4_var_124 = 42;
bool tf_4_array_3 = false;
const bool tf_4_ptr_1 = true;

extern void tf_4_foo();

int main() {
    tf_4_foo();
    printf("%llu\n", tf_4_var_124);
    return 0;
}

Init.h 
extern const bool tf_4_var_4;
extern const int tf_4_var_72;
extern unsigned long long int tf_4_var_124;
extern bool tf_4_array_3;
extern const bool tf_4_ptr_1;

Clang version:
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
565e37c7702d181804c12d36b6010c513c9b3417)</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>