<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 - [ScalarEvolution] Seems to have un-updated data structures."
   href="https://bugs.llvm.org/show_bug.cgi?id=43545">43545</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ScalarEvolution]  Seems to have un-updated data structures.
          </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>Global Analyses
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>paulsson@linux.vnet.ibm.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=22625" name="attach_22625" title="reduced testcase">attachment 22625</a> <a href="attachment.cgi?id=22625&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase

During recent experiments involving SCEV (<a href="https://reviews.llvm.org/D68281">https://reviews.llvm.org/D68281</a>), I
found that the SCEV "cache" seems to not always reflect the current IR as I was
expecting.

In fact, when adding this:

diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 852bbef..7d188ad 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -5737,6 +5737,7 @@ bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager
& /*LPM*/) {

   auto &IU = getAnalysis<IVUsersWrapperPass>().getIU();
   auto &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
+  SE.forgetAllLoops();
   auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
   auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
   const auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(

, I see a lot of files changing in benchmarks.

It says that recomputation can be "potentially expensive for large loop
bodies." in ScalarEvolution.h. I wonder if there has been some decisions to
allow a very small amount of differences to reduce compile time? Would it be
possible to find the places to update the right SCEVs instead of accepting
output differences? Having these differences in output makes it harder to work
with other passes since then unrelated changes to a pass affect code generation
in unpredictible ways.

The attached reduced test case has on trunk three phi instructions after LSR,
but with the above LSR patch to forgetAllLoops(), it has only two...

llc -mtriple=s390x-linux-gnu -mcpu=z14 -o - -O3 ./tc_lsr_scev.ll
-stop-after=loop-reduce</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>