<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/90929>90929</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Inline] Improving `getExpectedNumberOfCompare` for scenarios with no default branch.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:optimizations
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DianQK
</td>
</tr>
</table>
<pre>
The compare instruction count should be less than the branch count when default branch is undefined: https://llvm.godbolt.org/z/x6ETdfY79.
Related code:
https://github.com/llvm/llvm-project/blob/fd3e7e3a1e661482f46cd0347d0fa62adef30177/llvm/lib/Analysis/InlineCost.cpp#L524-L541
Perhaps we can do these things:
1. Reduce one comparison for the default branch that is undefined.
2. The number of comparison instructions can be linear or even fewer.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUkk1vozAQhn-NuYyKjAETDhyyTSNVW-1H1csejT3GXjk2sk3T9tevQtLdtLe9GAnwq5nnfURKdvKIA2m_kHZXiCWbEIedFf7n12IM6nV4MggyHGYREaxPOS4y2-BBhsVnSCYsTsGI4DAlyEZ4yAZhjMJLc_npaNCDQi0Wl9-_2ASLV6itR0XqLZic50TqLWF7wvbOPR_KKagxuFyGOBG2fyNs_8LvnpT-1fUloTtCt-fzEZ3IqEAGhaeE9eXHvMlms4ylDIdL-OVxM8fwG2UmbD-6MBK216rGDmtRIedVs2G64VLRuukU1YIzoVDXtOq6qxx7urf1wr0mmwjb33tnPd6GlEs5z4TVDy1rbh7aprqe-gdGI-YERwQpPKhw4pYQsrF-Sn_3OJ9VCY-oFokQ_HsdNgUPOsSV9ye62Yj8AfEFGCvh1KdfDiNGCPo66qrctI50KtV6FBFCBHxGDxqPGMtCDbXq614UOFRd1XS0qjgrzNBJzkfJeSMbutHjiJRXDesa2uvNhnNa2IFR1tCW1rRqWcNKqdq-2kjOaV9tmK5JQ_EgrCtXAUKcCpvSgkNPe9YXTozo0uoqYyv9ehvmbA_2TaxjE8ZOFsdh7XZcpkQa6mzK6V9gttmtvp9rIu0O7g9zDM_WT0A4nTDfvcwoM6pvK6bv-vasP-F05Z0kehFtSHC02YAPn-iXxRLd8N8Crpue_FmX_RMAAP__RUgs7w">