Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x86 backend emits bswap when -march=i386 is used #63531

Closed
jckarter opened this issue Jun 26, 2023 · 2 comments
Closed

x86 backend emits bswap when -march=i386 is used #63531

jckarter opened this issue Jun 26, 2023 · 2 comments
Labels
backend:X86 duplicate Resolved as duplicate

Comments

@jckarter
Copy link
Contributor

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.

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 26, 2023

@llvm/issue-subscribers-backend-x86

@efriedma-quic
Copy link
Collaborator

Duplicate of #58470

@efriedma-quic efriedma-quic marked this as a duplicate of #58470 Jun 27, 2023
@efriedma-quic efriedma-quic closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2023
@EugeneZelenko EugeneZelenko added the duplicate Resolved as duplicate label Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

4 participants