<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 -licm -dse (due to bad memoryssa?)"
   href="https://bugs.llvm.org/show_bug.cgi?id=49859">49859</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Miscompile with opt -licm -dse (due to bad memoryssa?)
          </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=24721" name="attach_24721" title="bbi-54825_man_red.ll reproducer">attachment 24721</a> <a href="attachment.cgi?id=24721&action=edit" title="bbi-54825_man_red.ll reproducer">[details]</a></span>
bbi-54825_man_red.ll reproducer

Running
 opt -enable-new-pm=0 -licm -dse bbi-54825_man_red.ll -S -o -
all stores to %sum are removed by dse. this then makes
  %3 = load i8, i8* %sum, align 1
get the wrong value.

If we instead run
 opt -enable-new-pm=0 -licm bbi-54825_man_red.ll -S -o - | opt -enable-new-pm=0
-dse -S -o -
several stores to %sum remains.

The same thing happens if we remove 
      AU.addPreserved<MemorySSAWrapperPass>();
from LICM.cpp.

Thus I think that LICM doesn't update memoryssa information as it should.

This looks very similar to an old bug:
<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Incorrect MemorySSA result after LICM"
   href="show_bug.cgi?id=45927">https://bugs.llvm.org/show_bug.cgi?id=45927</a></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>