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

    <tr>
        <th>Summary</th>
        <td>
            Suboptimal codegen for comparison of trivially equality comparable types
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    Right now `eqcompare_T` has good codegen but `eqcompare_U` and `eqcompare_O` have worse codegen. Ideally, they'd all have the same codegen, since the comparison semantics for each of them are identical.

https://godbolt.org/z/GYdGc6xqa
```
#include <compare>

struct T {
    int i;
    int j;
    friend auto operator<=>(const T&, const T&) = default;
};
static_assert(__is_trivially_equality_comparable(T));

struct U {
    int i;
    short a, b;
    friend auto operator<=>(const U&, const U&) = default;
};
static_assert(__is_trivially_equality_comparable(U));

struct ObjRep {
    alignas(T) char data[sizeof(T)];
    friend auto operator<=>(const ObjRep&, const ObjRep&) = default;
};
static_assert(__is_trivially_equality_comparable(ObjRep));

// Since all three are trivially equality-comparable, these should have the same codegen.
// Clang fails to optimize.
bool eqcompare_T(T *a, T *b) { return *a == *b; }
bool eqcompare_U(U *a, U *b) { return *a == *b; }
bool eqcompare_O(ObjRep *a, ObjRep *b) { return *a == *b; }

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VU1v4zYQ_TXUZRBDIf2lgw5xXC96KFLs2oeejCE5khjQokNS2Tq_vqBkK3YatOgWCwi2OJx5w_c0M8QQTN0SlWy2YrN1hl1snC8ffvu9KIpMOn0qv5q6idC678DmOb0odziip_2WzXNoMEDtnAblNNXUguzirdsuuWGrb61PQ_ArwXfnA13CJ_CrJrT2xPgjxIZOjC80oLWDb2wIAh5G9-QVTKuGnQHbBNdCoAO20agAlfNAqBpwVXI6AHoCoyntop2wfM3yh-G3ifEYmHhgfMP4pnZaOhsnzteMb94Y33z5Q39R8z9f8Bw0z8_PsOTCtMp2moCJxzNPJn65zhCi71SELbDFarAAAJg2gmHig-X5xlJ5Q60G7KIDdySP0XkmHplYpxR8qVwbImwZnydNrlcFMLEGTRV2No6YbLEe30PEaNQeQyAfGV_u9ybsozevJn2JPb10aE087QdOKC0xvtwyXqRnBLwmuPs3gqFxPgKms8of4Lm74bn7mTx3_8TzST5_peMtWbSmbjGcJQLVoAeNEdlsFcwbueoi3mz9A8yHjDf0r0w_SYNLhk-EGHoFvvVNmPo0Np6ob7IRFS6od9eofX8HSqXQWf15f09ukjxabGuo0NgAvUjRHMwbnZ2kcxaupxNfboHxh77I-jfZC7RYgafY-bbfhF7f9bAtVpC0-gxul0phhNv9X7inUdUR8335n4A_zKJMl0IXosCMyvvFvShyMZ0WWVOqgtNseq-qvJJSipxzKjQt8kqpSgqxzEzJcz7Np1zw_H7Bl5MFSYFIswo1nxEqNs3pgMZOrH09pLGYmRA6KpfFkueZRUk2XG4RXyanO9nVgU1za0IM72HRREvlt072XxDteHekWX01xNPE_lsNwXsNQTwdKWSdt-WH0W1i08mJcgfGNynt-e_u6N0zqcj4pj96YHzTn_6vAAAA__9g1yWv">