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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] shoudn't set `exact` on `shr (shl ...)` for undefined inputs
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    https://github.com/llvm/llvm-project/blob/6bf214b7c6d74ec581bc52a9142756a1d1df6df0/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp#L991-L995

Alive2 report: https://alive2.llvm.org/ce/z/q2vHmJ

```llvm
----------------------------------------
define i32 @t6_twoshifts.2(i32 %x, i8 %shamt) {
bb:
  %#0 = ctpop i8 %shamt
  %shamt_wide = sext i8 %#0 to i32
  br label %work

work:
  %n0 = shl i32 %x, %shamt_wide
  %r = ashr i32 %n0, %shamt_wide
  br label %end

end:
  ret i32 %r
}
=>
define i32 @t6_twoshifts.2(i32 %x, i8 %shamt) {
bb:
 br label %work

work:
  br label %end

end:
  %#0 = ctpop i8 %shamt
  %#range_0_%#0 = !range i8 %#0, i8 0, i8 9
  %shamt_wide = zext nneg i8 %#range_0_%#0 to i32
  %n0 = shl i32 %x, %shamt_wide
  %r = ashr exact i32 %n0, %shamt_wide
  ret i32 %r
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

Example:
i32 %x = #x00000002 (2)
i8 %shamt = undef

Source:
i8 %#0 = #x00 (0)       [based on undef value]
i32 %shamt_wide = #x00000000 (0)
  >> Jump to %work
i32 %n0 = #x00000002 (2)
i32 %r = #x00000002 (2) [based on undef value]
  >> Jump to %end

Target:
  >> Jump to %work
  >> Jump to %end
i8 %#0 = #x00 (0)
i8 %#range_0_%#0 = #x00 (0)
i32 %shamt_wide = #x00000000 (0)
i32 %n0 = #x00000002 (2)
i32 %r = poison
Source value: #x00000002 (2)
Target value: poison

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vl9vq7gT_TSTF6uRGfMnPPDQ3jT6_a6utFLvfa8MmMRdsFnbpO399CsbkkLVpu2uFkUBm-PjmTnjYbi1cq-EKCC5gWS74oM7aFOUWu0fBvWwKnX9XByc6y2wa8Ad4G4v3WEo15XuAHdtezzdrnqjH0TlAHdlq0vAXVo2GMVlVqV1Fosq2URllSDPoxizJOVRHdVNWjd0xiP9ul-GK9to01nA3f-Vdd90V0ollqOfB9k4u676HpD9yPPo6keeJ0C3QK_H_-tWHgUSI3ptHLBrsnSEh9drv_Vamz3grvJb_Abc_YXH_3Xf51yQ0vEXLA1TV5-8RnQtGqkEkQwJxNSl9-5R29EFBNyEeUyeAL8RufGP9sA7B5gTyG5GirL0todH4hGAjBJgW1K5XveLZS-gML5_lLUIUCue3IQMy532Jp3wpSEtL0XrXz9q8-c8AmG82F-Nu9tDS-bmLzadwU1Ac3swJ7ii7-LnlghVzw3xwxc7jHAnOjOhsu30wLbAbv-T8H8hUJ_25LOKAjLD1V7c0_v5EsAoTM_Unbw53fP30-K3TwulxP5l9es9lpnyr-QXT7xyn0iCC9qeawR3UitSa2EVYObIURjZPANG80Df3t39cecrwC9u9p7Ukk4bQXotrVZ6sMQduCJWD6YSi4VPvOtbcVbp5OgUcfZEx8vPbhBwCvFMuIAcVC2aOe_Pcacz7YYspfTEnpIGyhySm5JbUROtRi5y5O0gINkuzHol6sy-GdkkCLsFdku-D13vlV2k8VmYj7ycpLkA-9Dytyx5dUpGzeYH5YLtF_k-CPMC8vYRe2PBF0P_j4I75uk8daYwsusLFFOyn5Fzlolr6DpunmexpaTSxojKEbc4YfYEiIhUH0AoabhsRX3ltG8KjuJ94PSJFsZoY199aVd1weqc5XwliihjlMV5EuerQ5GKtKFxTlkSb5BHgrI0TSOM6yzPeLZJVrJAinFEWURjltN8XTKeVyU2ZZIhzzmFmIqOy_b88V9JawdRRFHMElyFem1DT4SoxCMJbwHRt0imCN1OOewtxLSV1tkXGiddG5qpeduS-CKph3osUFY4AikNNRBS6g8GpNSXRcCNL6br9dpLmFLSaDMeGqlETaTqB2dXg2m_3pEFB3w7NXl4LPDvAAAA__9gj77U">