<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 - Cost modelling for load-cast"
   href="https://bugs.llvm.org/show_bug.cgi?id=51975">51975</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Cost modelling for load-cast
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>lebedev.ri@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We currently don't costmodel the fact that some casts
(mainly sext/zext, but also  nt<->fp) can be folded into the load:
<a href="https://godbolt.org/z/vs7sx4nWz">https://godbolt.org/z/vs7sx4nWz</a>

This leads to rather pessimistic cost estimates,
and e.g. potentially affects LV.

Preceding question: does `X86TTIImpl::getCastInstrCost()`
have the right costs for e.g. `sext <8 x i16> to <8 x i32>`?
All `ISD::SIGN_EXTEND` in `AVX2ConversionTbl` are 2+,
for which target is that true?
I'd expect at least the s/zext's to cost 1.

Roughly, i suppose the solution matches that of the LOAD+BSWAP modelling,
i.e. if the cast is a single user of the load, then model it as free,
and when modelling the load which has a single cast user, then do ${MAGIC},

Where ${MAGIC} depends on the answer to the "Preceding question":
if the casts should cost 1, then we only need to adjust the load op sizes,
without increasing the load cost,
else i guess we need to report `max(load cost, cast cost)`?

Does this make sense?</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>