<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 - Missed opportunity for loop unswitching - indirect calls (h264)"
   href="https://bugs.llvm.org/show_bug.cgi?id=43572">43572</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missed opportunity for loop unswitching - indirect calls (h264)
          </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>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Seen in the hot code of h264.

PelYline_11 is a static global pointer to a function.

...
 for (pos = 0; pos < max_pos; pos++) {
    //if (pos > 1) abort();
    abs_y = offset_y + spiral_search_y[pos];
    abs_x = offset_x + spiral_search_x[pos];

    if (range_partly_outside) {
      if (abs_y >= 0 && abs_y <= max_height && abs_x >= 0 &&
          abs_x <= max_width) {
        PelYline_11 = FastLine16Y_11;
      } else {
        PelYline_11 = UMVLine16Y_11;
      }
    }

    orgptr = orig_blocks;
    bindex = 0;
    for (blky = 0; blky < 4; blky++) {
      LineSadBlk0 = LineSadBlk1 = LineSadBlk2 = LineSadBlk3 = 0;
      for (y = 0; y < 4; y++) {
        refptr = PelYline_11(ref_pic, abs_y++, abs_x, img_height, img_width);
...


With LTO and unswitched loop, we could fully inline FastLine16Y_11 and/or
UMVLine16Y_11, which could help a lot here since FastLine16Y_11 is a very small
function; see:

pel_t *FastLine16Y_11 (pel_t *Pic, int y, int x, int height, int width)
{
  return &Pic [y*width+x];
}

UMVLine16Y_11 is a bit bigger function.</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>