Skip to content

Instantly share code, notes, and snippets.

@trast
Created May 17, 2013 13:13
Show Gist options
  • Select an option

  • Save trast/5598945 to your computer and use it in GitHub Desktop.

Select an option

Save trast/5598945 to your computer and use it in GitHub Desktop.
#ifndef __AVX__
#error "You need to compile this with -mavx"
#endif
typedef float v32float __attribute__((vector_size(32)));
v32float sqrt_right(v32float x) {
v32float r;
__asm__ __volatile__ ("vsqrtps %1, %0"
: "=x"(r) : "xm"(x));
return r;
}
v32float sqrt_wrong(v32float x) {
v32float r;
__asm__ __volatile__ ("vsqrtps %0, %1"
: "=x"(r) : "xm"(x));
return r;
}
int main ()
{
v32float a = {0.0};
a = sqrt_right(a);
a = sqrt_wrong(a);
}
/*
* result:
* $ gcc -mavx -o avxorder avxorder.c
* avxorder.c: Assembler messages:
* avxorder.c:16: Error: operand size mismatch for `vsqrtps'
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment