<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/85073>85073</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Analysis] Remove getFPOpCost and use getInstructionCost/getArithmeticInstrCost directly?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:analysis,
            llvm:transforms
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          RKSimon
      </td>
    </tr>
</table>

<pre>
    TTI.getFPOpCost is only used in InlineCost and it appears to be (mainly) looking for libcalls.

https://github.com/llvm/llvm-project/blob/9e406ef4f4b089f88e74b2713f0fbee51b9537d6/llvm/lib/Analysis/InlineCost.cpp#L1782-L1797

https://github.com/llvm/llvm-project/blob/9e406ef4f4b089f88e74b2713f0fbee51b9537d6/llvm/lib/Analysis/InlineCost.cpp#L2138-L2145

1. Testing for `TTI.getFPOpCost(I.getType()) == TargetTransformInfo::TCC_Expensive` isn't great as many costs exceed TCC_Expensive (its not a specific cost limit) - at the very least this should be `TTI.getFPOpCost(I.getType()) >= TargetTransformInfo::TCC_Expensive`

2. Could we consider tweaking InstructionCost to include a flag indicating that a libcall will be made as part of the cost? Would that then allow us to replace getFPOpCost  with getInstructionCost in these cases?

3. If we did just use getInstructionCost - should we still limit the InlineCost call penalty to fp ops or any libcall?

No intree targets appear to override the default implementation which is:

https://github.com/llvm/llvm-project/blob/9e406ef4f4b089f88e74b2713f0fbee51b9537d6/llvm/include/llvm/CodeGen/BasicTTIImpl.h#L539-L547

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVc2O2zYQfhr6MrAgkZJlH3xw7KgwumiL1ECPBSWNrEkpUiBH6_jtC7K7WWeRQ3NqLzZEasjvb0Y6BLpaxL2oPojqtNILj87vP_38O03OrlrX3_eXyzm7Ije__TofXWCgAM6aOywBeyALZ2vIYtrStgdi0POM2g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