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

    <tr>
        <th>Summary</th>
        <td>
            constraint elimination missing a case related to != and ==
        </td>
    </tr>

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

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

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

<pre>
    consider this code:
```c
extern void side_effect(void);
void f(int v0, int v1, int v2) {
  if (v2 != v0) return;
  if (v0 < v1) return;
  if (v1 > v2) side_effect();
}
```
we compile this to:
```llvm
define void @f(i32 noundef %v0, i32 noundef %v1, i32 noundef %v2)  {
entry:
  %cmp.not = icmp eq i32 %v2, %v0
  %cmp1 = icmp sge i32 %v0, %v1
  %or.cond.not11 = and i1 %cmp1, %cmp.not
  %cmp4 = icmp sgt i32 %v1, %v2
  %or.cond10 = and i1 %cmp4, %or.cond.not11
  br i1 %or.cond10, label %if.then5, label %if.end6

if.then5:                                         ; preds = %entry
  tail call void @side_effect() #2
  br label %if.end6

if.end6: ; preds = %entry, %if.then5
  ret void
}
```
but that last conditional is always false: https://alive2.llvm.org/ce/z/LaLygS

this issue seems to involve both `icmp eq` and `icmp ne`: https://gcc.godbolt.org/z/MK4xhMna6

cc @fhahn @dtcxzyw 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVN1u6jgQfprJzajIsZMAF7lIy3Kz51ztA6ycZEK8cmzWNrT06Vd2QtpDT6VFSJjxN_N98-OR3quTIaqhfIbykMlLGK2rHZ1odFlr-1vdWeNVTw7DqDx2ticQDbAGKjZ_O2ANvQVyBq9W9RjRf9MwUBeA76IJ-B7EM7Am3Q_Ad8oEvDLgL5hO-XriwPcI2whGVAPGCByB5yAOyWOPjsLFmTngimEI4iUF-gaQI4g_lvi_KlzVwfbwOS9gzSthZ6ez0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