Last active
December 19, 2017 10:15
-
-
Save kaityo256/ab6f4a4d1820357a4ac5c2421dd171de to your computer and use it in GitHub Desktop.
sample of alignas
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
| #include <iostream> | |
| struct myv4df{ | |
| alignas(32) double v[4]; | |
| }; | |
| void | |
| func(myv4df &a, myv4df &b){ | |
| for(int i=0;i<4;i++){ | |
| a.v[i] += b.v[i]; | |
| } | |
| } | |
| int | |
| main(int argc, char**argv){ | |
| double d1 = atof(argv[1]); | |
| double d2 = atof(argv[2]); | |
| myv4df a,b; | |
| for(int i=0;i<4;i++){ | |
| a.v[i] = d1; | |
| b.v[i] = d2; | |
| } | |
| func(a,b); | |
| for(int i=0;i<4;i++){ | |
| printf("%f\n",a.v[i]); | |
| } | |
| } |
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
| # strtod(const char *, char **) | |
| # double d1 = atof(argv[1]);をやってるところ | |
| call strtod #16.15 | |
| # LOE rbx r12 r13 r14 r15 xmm0 | |
| ..B1.10: # Preds ..B1.11 | |
| vmovsd %xmm0, 32(%rsp) #16.15 | |
| # LOE rbx r12 r13 r14 r15 | |
| ..B1.2: # Preds ..B1.10 | |
| xorl %esi, %esi #17.15 | |
| movq 16(%r14), %rdi #17.15 | |
| # double d2 = atof(argv[1]);をやってるところ | |
| # strtod(const char *, char **) | |
| call strtod #17.15 | |
| # LOE rbx r12 r13 r15 xmm0 | |
| # a.v[i] = d1, b.v[i] = d2をvbroadcastsdでやっている | |
| ..B1.3: # Preds ..B1.2 | |
| vbroadcastsd %xmm0, %ymm2 #17.15 | |
| movl $.L_2__STRING.0, %edi #26.5 | |
| vbroadcastsd 32(%rsp), %ymm1 #16.15 | |
| # 構造体の和はvaddpd一発 | |
| vaddpd %ymm2, %ymm1, %ymm3 #24.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment