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

    <tr>
        <th>Summary</th>
        <td>
            [ValueTracking] computeKnownBitsFromOperator - improve Instruction::BitCast handling to match SelectionDAG
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            good first issue,
            missed-optimization,
            llvm:analysis
      </td>
    </tr>

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

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

<pre>
    The middle end computeKnownBitsFromOperator can merge bitcasts from narrow vector elements to wider types, but fails to perform this in the reverse case:

https://github.com/llvm/llvm-project/blob/85d417564b5f959f7434f2657cc9e1ab3575311f/llvm/lib/Analysis/ValueTracking.cpp#L1328:L1361

The SelectionDAG implementation handles both so hopefully its just a case of reusing the additional code over and adding any missing test coverage:

https://github.com/llvm/llvm-project/blob/46befd720995647485c516ba94a49eee5548283a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp#L3662:L3706
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykk0-r3TYQxT-NvBlysSTLfxZe3PceN5QECk3ofiSNbaWyZCT5Pm4_fbFfkyZZFErBYOQ5Hka_OQdzdnMgGpl6Yuqlwr0sMY2_ffjk1hgqHe1j_LwQrM5aT0DBgonrthf6EOJreHIl31Jcf90oYYkJDAZYKc0E2hWDuWSYUlwhYErxFe5kDhV5WimUDCXCq7OUoDw2ykw8g94LTOj8WdsoTTGtUBaXwQUoC0GiO6VMYDATk1dWH89SypaPk7gxcZtdWXZ9MXFl4ub9_evr3ZbiFzKFiZv2UTNx65VteKfaRqtpUMPUNbKZRKs6YwbiqKXqlOR8-q6PO_67BvSP7DITt9_R7_Q5ofnDhflito0J-ZFL0TN5_chly98mPCB-Ik-muBheru_BrdsbBTy-wILBesqgY1kgR1jiRtPu_QNcyfBlzwXwvDPECRLt2YX55IHWuqMDejDREsQ7JcBgz0KYAcMDVpff9JQLmEOB8_-H17SaJtuJehhU23RNr4zircahwWYgIqWaXvQSf4b3HC29p8DE7XsgPx2_kpRtKw6Ssqvbyo7SDnLAikbeyV5KoTpRLSO1tRGT5m2tuO2HGnEwbY_ToHStJxKVG0UtVM0l5009iP7CterM1EhLyHuOxJqaVnT-ckx6iWmuXM47jVwoIfrKoyafz5AIMcdoYXIpFzhFTAgmnpkQB2ay7-JW3Or-PPf6rXYSkFf8ZhxxxC2NJ1q9z5k1tXe55H8mKK74M5g_WIypl3-P4LvDWineCX4JuaT9JHqsV16fXHnGXN7MdhoiworFLD9Ys9qTH_-zKU4URyD-RnYfxV8BAAD__2EpcSg">