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

    <tr>
        <th>Summary</th>
        <td>
            Wrong `nsw`, `nuw` flag set on undefined values
        </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>
    Alive2 report: https://alive2.llvm.org/ce/z/9Mdkez

```llvm
----------------------------------------
define i16 @fold_add_udiv_urem_without_noundef.2(i16 %val) {
entry:
  %#0 = srem i16 %val, 10
  %#1 = mul i16 %#0, %#0
  %rem = urem i16 %val, 10
  %add = add i16 %#1, %rem
  ret i16 %add
}
=>
define i16 @fold_add_udiv_urem_without_noundef.2(i16 %val) {
entry:
  %#0 = srem i16 %val, 10
  %#1 = mul nsw i16 %#0, %#0
  %rem = urem i16 %val, 10
  %add = add nsw nuw i16 %#1, %rem
  ret i16 %add
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

Example:
i16 %val = undef

Source:
i16 %#0 = #x0000 (0)    [based on undef value]
i16 %#1 = #x0000 (0)
i16 %rem = #x0000 (0)   [based on undef value]
i16 %add = #x0000 (0)

Target:
i16 %#0 = #xfff7 (65527, -9)
i16 %#1 = #xfff7 (65527, -9)
i16 %rem = #x0009 (9)
i16 %add = poison
Source value: #x0000 (0)
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/eJzMlVuP6jYUhX_NzosFcpwbecgDUw5vVaXpkfqITLwDnjo28gXOnF9fORdu7fSMWlUqQiQhn1e81na8uXPyoBEbKF6g2CQ8-KOxzd7ow1vQb8neiPdmreQZGbF4MtZDtiZH708OsjWwLbAtH24vlTr3S2MPwLYtAtt-B7atfxa_43egG6Dr6bek4zfi41-LT35GWmAnNRKZlgRy2hkldlyIXRDyvAsW-91F-qMJfqdN0AK7JQO2GmhWnLkCVhOoXkYt1N6-Rx_DFYkIsIwSyDbEWezJ_bifSEofwXQA-6BmLg6O4Hx6o6NYhMMPVLkQAxePN9F0ErXYz6xFPwNciCnbajOdZBvIvvyP89Lu8t9kFoV1uPyL7L5arl1nbM-9NJoIg04Dqzw5o5XdO7D0fjl_eX395TW-El-5PURZR3pjkZyMdEab4Ig_ck2cCbbFh4HfeH9SeA3z5m_0HEtxz_86Kjzh1_SBZd8opZQAW1FgNdAaipc9dyiI0aMcOXMVEIrNs0T6gcQdNdfinz9nrtJfP2bKfgjxb012XVfFoWVRsCqWdlE_z_XB0Sf4J291xP8EzdMfC3tfk8lutv7A2rQyrtS9wqQT-p4_vFiUtMZabD3xD8vRzUBKpP4BQknHpUKx8GZxsuaMH4PTBo_WGuue9ulENJmos5on2KRVRmld0KxOjk1ddXnJ8oKLfF93JcW2a9u0ajHPeIkdT2TDKMtTyla0KKq0XhaszOmKsw5TzOm-hJxiz6W6to5EOhewSdNsVRaJ4ntUbuhMjGm8kOEuMBYblW3ioMU-HBzkVEnn3U3GS6-w-c0afSBQUu0u0UvcB0qqQ7wgneIH4tBfV63UKMYiuSRY1Tz2uIP0x7BftqYHth1a13iIyb5h64Fth9k5YNtp-ueG_REAAP__aCUFkQ">