Skip to content

Instantly share code, notes, and snippets.

@jckarter
Created September 29, 2013 23:52
Show Gist options
  • Save jckarter/6757629 to your computer and use it in GitHub Desktop.
Save jckarter/6757629 to your computer and use it in GitHub Desktop.
#include <vector>
struct vec4 {
float __attribute__((vector_size(16))) elts;
};
void putVec4(vec4 *out, const std::vector<float> &v) {
*out = {{v[0], v[1], v[2], v[3]}};
}
/*
$ clang++ -DNDEBUG -O3 -std=c++11 -S ~/foo.cpp
__Z7putVec4P4vec4RKSt6vectorIfSaIfEE: ## @_Z7putVec4P4vec4RKSt6vectorIfSaIfEE
pushq %rbp
movq %rsp, %rbp
movq (%rsi), %rax
movups (%rax), %xmm0
movaps %xmm0, (%rdi)
popq %rbp
ret
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment