<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 - InstCombine does invalid transformation"
   href="https://bugs.llvm.org/show_bug.cgi?id=33695">33695</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>InstCombine does invalid transformation
          </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>All
          </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>babokin@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>clang trunk (also reproducible with 4.0, not reproducible with 3.9), x86_64.

<span class="quote">> cat f.cpp</span >
#include <stdio.h>

unsigned char uc = 170;
unsigned char var_1 = 252;
unsigned int var_33 = 1346838541U;
unsigned char var_36;
void foo() {
  var_36 = (((var_33 | (0xaf2597a4 | uc)) << 26) - var_1) * 70983U;
}

int main() {
  foo();
  printf("result: %d\n", var_36);
  return 0;
}

<span class="quote">> clang++ -O0 f.cpp -o out0
> ./out0</span >
result: 28

<span class="quote">> clang++ -O2 f.cpp -o out2
> ./out2</span >
result: 0

Opt-bisect points to "Combine redundant instructions on function", which
removes the calculations and foo() and stores 0 to var_36, which is incorrect
value.</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>