<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 --- - LICM Store promotion when store found in preheader"
   href="https://llvm.org/bugs/show_bug.cgi?id=26429">26429</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LICM Store promotion when store found in preheader
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>listmail@philipreames.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>When doing store promotion, we have to satisfy a legality constraint which
prevents us from inserting any new stores to locations visible to other threads
along any dynamic path.  Today, we do this by finding a store inside the loop
guaranteed to execute on all paths through the loop.  We could also satisfy
this legality constraint by finding a store immediately before the loop and
removing that one as part of the transformation.  

Motivating example:
int location;
void foo() {
  int start = location;
  for (int i = 0; i < 1000; i++) {
    // Key point is we can't establish the store in the loop to always exit
    if (volatile load) break;
    location = start + i;
  }
}

In general, any store outside the loop which is post-dominated by the loop
header and dominates the loop header without intervening memory access would be
legal, but in practice, we probably want to limit the search to the preheader
and possible one or two immediately preceding blocks.  (This might also be
interesting to express over the newly added MemorySSA form!)

Note that the same argument applies to a store which post-dominates all exits
from the loop.  Without any real evidence, I suspect that case might be more
rare.</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>