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

    <tr>
        <th>Summary</th>
        <td>
            x86 backend emits `bswap` when `-march=i386` is used
        </td>
    </tr>

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

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

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

<pre>
    If you compile `clang -S -o - ~/foo.c -O3 -target i386-pc-linux -march=i386`:

```
unsigned bswap(unsigned num) {
    union {
        unsigned n;
        char b[4];
    } bytes = {.n = num}, rev = {
      .b[0] = bytes.b[3],
      .b[1] = bytes.b[2],
      .b[2] = bytes.b[1], 
      .b[3] = bytes.b[0]
 };
    return rev.num;
}
```

then clang generates:

```
bswap:                                  # @bswap
        .cfi_startproc
# %bb.0:
        movl    4(%esp), %eax
        bswapl  %eax
        retl
.Lfunc_end0:
        .size   bswap, .Lfunc_end0-bswap
        .cfi_endproc
```

even though `bswapl` is only available with `-march=i486` or later.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8lMGO4ygQhp-mfCnZImCT-ODD9kSRVlppD_sAI4zLMTMEIsDp7j3ss6-wk55k0jNRRELVx09VUaBiNEdH1EHzAs2-UHOafOi-6e8qJApF74f37s8R3_2M2p_OxhKCZNoqd8TyHyw9lvgf8MPofaWx_FtgmVQ4UkIjdrI869IaN79heVJBTyD22QySgfgD2B7YbZTs-l2ms1vCGrCPr-oMfPdhcPMJeIuwfVlJRMTZGe8eTav5tgbETy49qYA9NC81NPsHL2z32L8nighinzUrt_zL-273wL9goMvNdy9aZTkGzX5xLhKLSeQd-JcndPOM8l-g_BndrCg-seKZzUFduZzCfbaB0hxcTqnKCd5cGfvsWNYxTeRw7YAjOQoqUfz9ca6nKD7K_-sPcIFQs3XBVbCt9Gi-xqRCOgevr-YM8qbvq_tWak_-YoG1NfAd8IbiGXi71Ik3pN4-sEU_gz_ZAyW7Tqq_xtnpr-SGB_0qmn_pJpCF77jyk6jJDXcxf1ZNupDDNPn5OOWbdY1MMjQRvbPvqC7KWNVbwleTFubHXaqXu4Q-oFWJQlUMnRha0aqCuo3cbXebzabeFlO3a2Qr2q1UwyBrzVopBi20HPVIdTuKsTAdZ1wwySVnvKm3FZcbXQ9b3Ywtk7VuoWZ0UsZW1l5OlQ_HwsQ4UydFIzaFVT3ZuLwinDt6xcUJPLduEbq8puznY4SaWRNT_KGSTLLUve0k9kp_JzcgnUyKH7XI-b3mjntIfH1Eco3mSEMxB9tNKZ2XPuQH4IejSdPcV9qfgB_yZtef8hz8N9IJ-GEJMQI_LCn8HwAA__-lCmKp">