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

    <tr>
        <th>Summary</th>
        <td>
            [ConstraintElim] `icmp spred x, y` implies `icmp samesign upred x, y`
        </td>
    </tr>

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

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

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

<pre>
    Alive2: https://alive2.llvm.org/ce/z/ZNNbj_
```
define i1 @src(i32 %x, i32 %y) {
entry:
  %cond = icmp sgt i32 %x, %y
  br i1 %cond, label %if.then, label %if.else

if.then:
  %cmp = icmp samesign ugt i32 %x, %y
  ret i1 %cmp

if.else:
  ret i1 false
}

define i1 @tgt(i32 %x, i32 %y) {
entry:
  %cond = icmp sgt i32 %x, %y
  br i1 %cond, label %if.then, label %if.else

if.then:
  ret i1 true

if.else:
  ret i1 false
}
```
We already perform similar optimizations in https://github.com/llvm/llvm-project/pull/115893.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMU7FupDAU_JpHY2VlnoFdCgqSPcq0J11zsvGDdWQDsk0u5OtPsCTZRLoi3UlIoPfGHmY0I0Mw_UBUQX4PiDq2L6_LH0CE_JzIOV5GX-3DRI16qWprnglB1OwS4xRA1IANYCO3-cHaZ3cYfQ_YtATYvAI2vx4f1dNv4DUUfH94rakzAzGTMsh48C3gyQhkgPkL4APbvxfAksHxHnhNQ_TLSsdrtq7acdAMxJmZ1k0s9JHdnt_OrkjlN44rft1YqciuA9Md4oWGrzOygdZ_5fUb4IbTTTeU0tFqHpv_xe0pvpG76f3OjWC_c0d0cic9nq-wT-7EPv7_7uxKop_pG0pvAvGTmLSepF7YRL4bvWPBOGOlZ-MUjTOvMppxCMwMX6LXm3iZ1aEdHWCzBnB_3U1-fKI2AjbTbC1gk6b5qRQH4HWiK6FLUcqEqvQoMpGXRVoml6oTba5Um2tNaZ63nVIFllkhyyMhqaNKTIUcsxTTIs2EEMcDoTxxJWWhy6LLMg0ZJyeNfe9CYkKYqUqR81OZbG6GvW_OhED67lbg2j18AMRNiaijl0NY7Qh7K321iVNzHyDj1oQYPqiiiXYr88M4hOilGeIPaxzkZwYFv4Zh8qTZloMFCs6Mm6yh8LF_z_VnYDJ7W33b-U17WL2_yn-u8G8AAAD__1qMVKc">