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

LLVM doesn't properly optimize swap of larger structs #115510

Open
philnik777 opened this issue Nov 8, 2024 · 0 comments
Open

LLVM doesn't properly optimize swap of larger structs #115510

philnik777 opened this issue Nov 8, 2024 · 0 comments

Comments

@philnik777
Copy link
Contributor

This code gets properly optimized to load the values into registers and then stores them back. When changing the buffer size to e.g. 16 bytes the data is moved to the stack instead, even though it could be swapped in the same way with XMM registers, which are used anyways.

struct S {
  char buffer[8];
};

auto test(S& lhs, S& rhs) {
  S tmp(lhs);
  lhs = rhs;
  rhs = tmp;
}

(https://godbolt.org/z/o5vYY7Ea5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant