<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 --- - Block Frequencies for loop seem incorrect"
   href="https://llvm.org/bugs/show_bug.cgi?id=27791">27791</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Block Frequencies for loop seem incorrect
          </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>All
          </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>k.alexis.perry@gmail.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>Created <span class=""><a href="attachment.cgi?id=16380" name="attach_16380" title="source file">attachment 16380</a> <a href="attachment.cgi?id=16380&action=edit" title="source file">[details]</a></span>
source file

$ clang++ -O2 -fprofile-instr-generate ProfileTester.cpp -o ProfileTester
-fno-vectorize -fno-unroll-loops
$ LLVM_PROFILE_FILE="profiletester-%p.profraw" ./ProfileTester
Number of entries into the if statement: 11
The new x value is: 2.07692
The new c value is: 2.69231
$ llvm-profdata merge -output=profiletester.profdata profiletester-*.profraw
$ clang++ -O2 -fprofile-instr-use=profiletester.profdata ProfileTester.cpp -S
-emit-llvm -o ProfileTester-with-pd.ll -fno-vectorize -fno-unroll-loops
$ opt -analyze -block-freq < ProfileTester-with-pd.ll
Printing analysis 'Block Frequency Analysis' for function 'main':
block-frequency-info: main
 - entry: float = 1.0, int = 8388624
 - for.cond.cleanup: float = 1.0, int = 8388624
 - if.then.i145: float = 0.00000095367, int = 8
 - _ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit: float = 1.0, int = 8388616
 - if.then.i: float = 0.8, int = 6710892
 - if.end.i: float = 0.2, int = 1677723
 - _ZNKSt5ctypeIcE5widenEc.exit: float = 1.0, int = 8388616
 - if.then.i148: float = 0.00000095367, int = 8
 - _ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit150: float = 1.0, int = 8388607
 - if.then.i125: float = 0.8, int = 6710886
 - if.end.i129: float = 0.2, int = 1677721
 - _ZNKSt5ctypeIcE5widenEc.exit131: float = 1.0, int = 8388607
 - if.then.i152: float = 0.00000095367, int = 8
 - _ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit154: float = 1.0, int = 8388599
 - if.then.i137: float = 0.8, int = 6710879
 - if.end.i141: float = 0.2, int = 1677720
 - _ZNKSt5ctypeIcE5widenEc.exit143: float = 1.0, int = 8388599
 - for.body: float = 5001.5, int = 41955695043
 - for.body7: float = 55012.0, int = 461475390211
 - for.cond.cleanup25: float = 55012.0, int = 461475390211
 - for.body26: float = 275030036.0, int = 2307123560708599
 - if.end.loopexit: float = 6.0006, int = 50336765
 - if.end: float = 5001.5, int = 41955695043

Printing analysis 'Block Frequency Analysis' for function
'_GLOBAL__sub_I_ProfileTester.cpp':
block-frequency-info: _GLOBAL__sub_I_ProfileTester.cpp
 - entry: float = 1.0, int = 8

Please note:
 - for.body: float = 5001.5, int = 41955695043

This is a top-level loop with a static trip count of 10000. Thus, its loop
header should execute 10000 times as frequently as the function entry block.
The reported frequency is ~5000 times. This seems off by a factor of 2.</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>