<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 - Miscompile with opt -correlated-propagation"
   href="https://bugs.llvm.org/show_bug.cgi?id=50399">50399</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Miscompile with opt -correlated-propagation
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mikael.holmen@ericsson.com
          </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=24873" name="attach_24873" title="bbi-56214_2.ll reproducer">attachment 24873</a> <a href="attachment.cgi?id=24873&action=edit" title="bbi-56214_2.ll reproducer">[details]</a></span>
bbi-56214_2.ll reproducer

Reproduce with
 opt -correlated-propagation -S -o - bbi-56214_2.ll

The store in %cond.end32 is changed from
  store i64 %i10, i64* %arrayidx12, align 1                          ; store 0
to
  store i64 %sub18, i64* %arrayidx12, align 1
which I think is wrong.

In the last iteration of the loop the value 0 chould be written but now we
instead write %sub18 which actually is a poison value!

I've done some annotations in the input ll-file about the value of different
temporaries which I think shows that the change done by the pass is wrong.

I suspect that the fact that %sub18 is poison isn't handled correctly.

This starts happening with commit a917fb89dc28:

    [LVI] Simplify and generalize handling of clamp patterns

    Instead of handling a number of special cases for selects, handle
    this generally when inferring ranges from conditions. We already
    infer ranges from `x + C pred C2` to `x`, so doing the same for
    `x pred C2` to `x + C` is straightforward.</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>