Created
May 17, 2013 13:13
-
-
Save trast/5598945 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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