<html>
    <head>
      <base href="http://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 --- - [SCEV] New Trip Count Computation cause Overflow assertion in MachineBlockFrequency"
   href="http://llvm.org/bugs/show_bug.cgi?id=21622">21622</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[SCEV] New Trip Count Computation cause Overflow assertion in MachineBlockFrequency
          </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>Global Analyses
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>zhaoshiz@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>apazos@codeaurora.org, chandlerc@gmail.com, llvmbugs@cs.uiuc.edu, mcrosier@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13380" name="attach_13380" title="C Test case">attachment 13380</a> <a href="attachment.cgi?id=13380&action=edit" title="C Test case">[details]</a></span>
C Test case

<span class="quote">> clang --target=aarch64-linux-gnu  -mcpu=cortex-a57 -Ofast test.c -mllvm -unroll-allow-partial -mllvm -unroll-threshold=1000 -c -o test.o
> clang-3.6: /prj/llvm-arm/home/nightly/src/community-mainline/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp:125: void combineWeight({anonymous}::Weight&, const Weight&): Assertion `W.Amount < W.Amount + OtherW.Amount && "Unexpected overflow"' failed.</span >

The commit below changes how SCEV computes loop trip count:

<span class="quote">> -    dyn_cast<SCEVConstant>(getBackedgeTakenCount(L));
> +      dyn_cast<SCEVConstant>(getExitCount(L, ExitingBlock));</span >

This results in a loop previously considered runtime (trip count is 0) becomes
a compile time loop (trip count is 255).

With '-unroll-allow-partial' and '-unroll-threshold=1000', loop unroll pass
chooses to unroll this loop by a factor of 85.

As a result, a substantial number of branches are targeting the same landing
block, eventually overflow BlockFrequency calculation.


commit ed05e3703e07dfeae33acdd3cc5ad07b5f5b86c6
Author: Mark Heffernan <<a href="mailto:meheff@google.com">meheff@google.com</a>>
Date:   Fri Oct 10 10:39:11 2014

    This patch de-pessimizes the calculation of loop trip counts in
    ScalarEvolution in the presence of multiple exits. Previously all
    loops exits had to have identical counts for a loop trip count to be
    considered computable. This pessimization was implemented by calling
    getBackedgeTakenCount(L) rather than getExitCount(L, ExitingBlock)
    inside of ScalarEvolution::getSmallConstantTripCount() (see the FIXME
    in the comments of that function). The pessimization was added to fix
    a corner case involving undefined behavior (pr/16130). This patch more
    precisely handles the undefined behavior case allowing the pessimization
    to be removed.

    ControlsExit replaces IsSubExpr to more precisely track the case where
    undefined behavior is expected to occur. Because undefined behavior is
    tracked more precisely we can remove MustExit from ExitLimit. MustExit
    was used to track the case where the limit was computed potentially
    assuming undefined behavior even if undefined behavior didn't necessarily
    occur.


    git-svn-id: <a href="https://llvm.org/svn/llvm-project/llvm/trunk@219517">https://llvm.org/svn/llvm-project/llvm/trunk@219517</a>
91177308-0d34-0410-b5e6-96231b3b80d8</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>