<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 --- - Pathological register allocation within gigantic single basic block function (x86-64)"
   href="http://llvm.org/bugs/show_bug.cgi?id=20014">20014</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Pathological register allocation within gigantic single basic block function (x86-64)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>vlad@drpetric.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The code in question is from an Othello minimax engine. 
<a href="https://github.com/vladpetric/ntest/branches">https://github.com/vladpetric/ntest/branches</a> (jmobs2 branch)

The static evaluation function of ntest is a huge basic block, of around 550
instructions. It's a complex basic block, with a lot of live values.

Unfortunately, clang produces no fewer than 75 spills! I count a spill as a
store/load pair to the stack, which includes pushes, pops, moves and other
instructions with an operand in memory and using %rsp (callee-managed registers
are included here as well). At the same time gcc 4.8.2 generates 9, and icc
only 4. Given that this is a single linear basic block, all instructions are
executed exactly the same number of times.

Instruction statistics for the function CEvaluator::EvalMobs :

gcc 4.8.2:
    Total st stores     loads  st loads     moves       alu      mult    popcnt 
      547         9       122         9       117       261        28         1 

icc:
    Total st stores     loads  st loads     moves       alu      mult    popcnt 
      541         4       122         4       122       260        28         1

clang (3.5 trunk):
    Total st stores     loads  st loads     moves       alu      mult    popcnt 
      704        76       122        75        81       321        28         1

A few notes:

* there are no branches or non-stack stores. st loads mean stack loads, st
stores mean stack stores.

* non-stack loads are loads from evaluation tables. The mults come primarily
from the "magic multiplier" bit gather trick. popcnt - well, that's explicitly
called. There's a constant number of them.

* an x86_64 ALU instruction that has a memory operand is counted twice - both
ALU and load. Such operations are likely broken into two micro-ops, generally
speaking (one load and one alu).

The code can be compiled by fetching the sourcecode, then a straightfoward
cmake project, but I've also attached the .ll file which includes the
pathological function (CEvaluator::EvalMobs).</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>