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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] fshl(x, 0, y) with in-range y not converted to shl x, y
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:instcombine,
            missed-optimization
      </td>
    </tr>

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

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

<pre>
    https://alive2.llvm.org/ce/z/k4SnKK
```llvm
define i32 @src(i32 %x, i32 range(i32 0, 32) %y) {
    %res = call i32 @llvm.fshl(i32 %x, i32 0, i32 %y)
    ret i32 %res
}

define i32 @tgt(i32 %x, i32 range(i32 0, 32) %y) {
    %res = shl i32 %x, %y
    ret i32 %res
}
```
We currently only do this if the shift amount is constant, but not for a dynamic shift amount that is < bitwidth based on known bits.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysU0-Poz4M_TThYrUKDpRy4NBphfTTHH-HPQcIxTshGSWms8ynX5Fp989otaeVEIEX--U5ftYx0tUZ04jySZSXTC88-dA4eqE-6_ywNhPzaxTqJLAV2GpLN4N7a2_z3oerwLY3Att3ge1L8b97fhbyJA7y49mihDwNZiRngBSCKGQMvcBj-sHym8Bz2gjaXc0dlxuoUGC9haxprZ6EPAHAhgQTQagL9NraB2sSNMbJ_oFbPj7ubHemYPiBBhM33dVle38WzFf-R4LjZOFXnhT8dzGPqxTy9MVAv4RgHNsVvLMrDB54ogg0Ak8G4kQjg5794hgoQu9dZO14O6pbGJxnGH0ADcPq9Ez97xk86ZQm1Bk64jcaeIJORzOAd_Di_Jvb8LjPhkYNtap1Zpq8UociV3ldZ1NTqe6oi2NZ6KpSeae7Ms_1OBb5sZb5sThk1KDEUuaylseyLuv9IIvxYA5V2UvUBxxFIc2syf4wWEYxLqbJEVGVmdWdsTF5FTG5S53IRe793JEzAlHgWSDOFKMZdv6VaaZ3zeTdtldestBsabtuucbNNRQ5_jyLiW2ahP9c5POds7zA3VepZ6nXqcVvxBOQ2yUnwJqut_fuZgKbAdindqecNVuC_TRIV-Jp6fa9nwW2qZSPZfca_FfTs8A2lR4Ftvfqbw1-DwAA__-VGxcf">