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

    <tr>
        <th>Summary</th>
        <td>
            [DebugInfo][LoopStrengthReduce] Delete the cmp instruction without salvaging its debug value
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            loopoptim,
            debuginfo,
            llvm:transforms
      </td>
    </tr>

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

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

<pre>
    In `LSRInstance::OptimizeMax()`, the condition of the deleted select instruction is also deleted, but its debug value (which could be salvaged) is not salvaged.

https://github.com/llvm/llvm-project/blob/3f33e7ba5b08a97939280e539ad20a34d54b2719/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp#L2559-L2563

Here is an example: https://godbolt.org/z/dsvP787zc
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUksFu3CwQx59mfEFZ4cEs5uDDJivri7SfWiV9ATCzNhVrLIM3aZ6-stOkaXrqCWkEf2Z-8zMp-X4kakDegjwWZslDnJvDFLuBxlTY6H409yODPT89PtyPKZuxIxAHEIcvU_YX_0L_m2fAGlDDngPesTwQ6-LofPZxZPG8FRwFyuRYokBdZn5MeV667YZPzIQU366sEXbJzOfEHNmlZ1cTFmKA9dPgu4F1cQmOWWLJhKvp1xd6DRljfi_tgB-AH4acp7R2iy1g2_s8LHbXxQtgG8L17biZ5vidugzY2hAtYCvOQpCyRlpeG6200FhzkkIbh9yIysnKoir1hxy_vvs2mzGd43xJgO1jZ4KZAdtTjNNjnmns8_BAbulo100ToDihlPrmhHIvXvv9j2baeIyMns1lCitq9mmK6GwMeRfnHrB9AWxdun5VtXrpCtcIp4U2BTWlkmW9V7wUxdBoW6qa67NDZSup91LXtrSltcJRVXaq8A1ylFxxxWUlhNgpzrl1Na9LfS65klBxuhgfduu869-FT2mhpqwUiroIxlJIm0WIIcYprnIAIuAdIG579OM5vlc2bOKQPwDDVcC52TZilz5BxYNPOf3-MvscNlWPa979miePIG__BgzyyI6bT686XqY_lHvyeYjLmy5-7D_bVixzaP7Zng3JuvpfVK4N_gwAAP__HJkW4A">