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

    <tr>
        <th>Summary</th>
        <td>
            Weaken `xor` to `or` under `nand`
        </td>
    </tr>

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

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

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

<pre>
    Alive2 proof: <https://alive2.llvm.org/ce/z/tMGuKE>
```llvm
define i1 @src(i1 %x, i1 %y) denormal-fp-math=ieee,ieee {
%start:
  %_4 = and i1 %x, %y
  %_3 = xor i1 %_4, 1
  assume i1 %_3 ; <-- because we know !(X & Y)
  %0 = xor i1 %x, %y ; <-- this X^Y
  ret i1 %0
}
=>
define i1 @tgt(i1 %x, i1 %y) denormal-fp-math=ieee,ieee {
%start:
  %_4 = and i1 %x, %y
  %_3 = xor i1 %_4, 1
  assume i1 %_3
  %0 = or i1 %x, %y ; <-- can be just X|Y
  ret i1 %0
}
Transformation seems to be correct!
```

It's also possible that, for normalization, this shouldn't always happen, so here's my non-minimized example: <https://alive2.llvm.org/ce/z/_c36CA>

In that one, replacing the `xor` with an `or` opened up a bunch of additional possibilities that ended up making a huge improvement in the generated assembly:
```diff
        test    edi, edi
        je      .LBB0_3
        test    esi, esi
        je      .LBB0_3
        cmp     edi, esi
        sete    al
        ret
 .LBB0_3:                                # %other
-       test    esi, esi
-       setne   cl
-       test    edi, edi
-       setne   al
-       xor     al, cl
-       xor     al, 1
+       or      edi, esi
+       sete    al
        ret
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVVUuTmzgQ_jXiorILhMH4wGFsT1Kp3b1t1SanKQGN0YweFBLj8fz6bQnssZ1KsjkuhZHU7_66W65McyofpHgFRvvBmJakD5Sku8653uKesE_48iCwlPJVLc1wQEoN-HnHn_vr8_jHI0kfSbwn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