<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Condition not evaluated correctly on integer (long long) overflow for optimized builds"
   href="https://llvm.org/bugs/show_bug.cgi?id=25385">25385</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Condition not evaluated correctly on integer (long long) overflow for optimized builds
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.5
          </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>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>compiler-rt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jhallmann@tableau.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=15205" name="attach_15205" title="Code to repo the defect">attachment 15205</a> <a href="attachment.cgi?id=15205&action=edit" title="Code to repo the defect">[details]</a></span>
Code to repo the defect

Staring with llvm 3.5 the optimizer is not correctly evaluation the condition
if an overflow happens.

# Compile
clang++ test.cpp -O3 -o testr && clang++ test.cpp -o testd

# Run and the outputs should match
./testd && ./testr
overflows 1
overflows 0

llvm 3.4

.Ltmp16:
    #DEBUG_VALUE: delta <- ECX
    .loc    1 24 0
    setl    r9b
    setg    r10b
    .loc    1 21 0
    test    ecx, ecx
    .loc    1 22 0
    setg    al
    .loc    1 23 0
    shr    ecx, 31

llvm 3.5 - 3.7

.Ltmp13:
    #DEBUG_VALUE: value <- R8D
    .loc    6 22 17
    mov    ecx, r8d
    sub    ecx, r9d
    setg    r9b
    .loc    6 24 17
    setl    al
    .loc    6 23 17
    shr    ecx, 31</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>