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

    <tr>
        <th>Summary</th>
        <td>
            Worse code gen when integer is wrapped in struct
        </td>
    </tr>

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

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

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

<pre>
    Compiling with `-std=c2x -O3`

```c
typedef struct {
        signed char m;
} schar;
typedef struct {
        unsigned char m;
} uchar;
bool a(signed char x, unsigned char y) {
        return x == y;
}
bool a2(schar x, uchar y) {
        return x.m == y.m;
}

typedef struct {
        short m;
} sshort;
typedef struct {
        unsigned short m;
} ushort;
bool b(short x, unsigned short y) {
        return x == y;
}
bool b2(sshort x, ushort y) {
        return x.m == y.m;
}

typedef struct {
        int m;
} sint;
typedef struct {
        unsigned m;
} uint;
bool c(int x, unsigned y) {
        return x == y;
}
bool c2(sint x, uint y) {
        return x.m == y.m;
}
```

causes clang to generate

```asm
a:                                      # @a
 cmp     edi, esi
        sete    al
        ret
a2: # @a2
        movsx   eax, dil
        movzx ecx, sil
        cmp     eax, ecx
        sete    al
 ret
b:                                      # @b
        cmp     edi, esi
        sete    al
        ret
b2: # @b2
        movsx   eax, di
        movzx   ecx, si
 cmp     eax, ecx
        sete    al
        ret
c: # @c
        cmp     edi, esi
        sete    al
 ret
c2:                                     # @c2
        cmp edi, esi
        sete    al
        ret
```

See it live: https://godbolt.org/z/hbvEcjj6W

It's surprising to me that wrapping an integer in a struct causes worse code gen and hopefully this is just an optimization bug.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklktvqzoQgH-N2YwaEZuQsGDRc3Ij3dVd3MVZ-zEFVwYj2-TRX39kSFpIc_rIQVVJxvY3Mx-aCO69rlrEkqx-kNU24X2orSsV32vlg20xEVadyp-26bTRbQUHHWogefrggyJsK-kRHv5jJE9JuiXp4_l_no5_cvweTh0qfAIfXC8DkPWPy-5iSK9A1txBQ9hlYb0FH2OvkQ8QfftnSD-DCGsNcEI30wNHQn_CnHEitJilcBh618IRCNsStoXTNMmUTSN8gv0Yt2hegYvmPfJzebV14VrbEPyWt1uYfo4ZuhOxuWHv3NkYu1uaGKRNwZ8A_1abbt9J0-33lF3Jmh4fepKEbmKauai7FclB0Rswfrpbz2U4p7Yk7z16kIa3FQQLFbboeMCbU819M0Y4YY_wpYtQBiRL-XgOZNMNYVQ69oNenxfOl8eA8c7NPO4wnDPTmPpCpfNdjd37Y6TzwZbS5t36yxFQDqv-evW1tvF03PZxba9Fie_qEH_IfK8VMbUiPrNySwq8abl-VF_VcV2UnNQk_7LhNyj9qutLZvo-9d2eb47Q_4igAxi9x1hbHULnCXskdEforrJKWBMW1lWE7l4I3dVi_498fs5_TRn_BkLXHnzvOqe9HmexQQg1D3BwvOtijLeg24AVOtAt8MsP1XmGD9Z5BGkVxikG3iqobYdPvTEnCLX2oD089z5Eju2CbvQLD9q2IPpqkaiSqYIVPMFymRerTcby5SqpS8nyJ8Hz5Wq5wRVS3Kj1E-PIlkylQm5ookuaUpYWdL0ssnSZLWShWEY5EzxbF5tMkSzFhmuzMGbfRBOJ9r7HMl-vinViuEDjh_cQSls8wLBIKI2vJa6MZx5EX3mSpUb74N8oQQeD5a9524caJ5b8KA9VFDbqSnpnyquHpEPdi4W0DaG7iD_fHjpnn1EGQndDUZ7Q3VD07wAAAP__CD2KEw">