Guest User

Untitled

a guest
Feb 26th, 2012
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.06 KB | None | 0 0
  1. rpg@rpg$ cat test.c
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. typedef float v4sf __attribute__ ((vector_size (16)));
  6.  
  7. union f4vector
  8. {
  9. v4sf v;
  10. float f[4];
  11. };
  12.  
  13. const v4sf half = {0.5,0.5,0.5,0.5};
  14. int main()
  15. {
  16. union f4vector b = {(float)rand(),(float)rand(),(float)rand(),(float)rand()};
  17. union f4vector c = {(float)rand(),(float)rand(),(float)rand(),(float)rand()};
  18. union f4vector data = {0.34, 0.29, 0.97, 0.0};
  19. union f4vector data2 = {0.0, 0.0, 0.0, 0.0};
  20. int i;
  21. for (i=0;i<1024*1024*100;i++)
  22. {
  23. //~ b = (float)clock();
  24. data2.v = (data.v+half)*c.v+b.v-half;
  25. }
  26. //~ float data3[4];
  27. //~ data3 = data2;
  28. printf("%f %f %f\n", data2.f[0],data2.f[1],data2.f[2]);
  29.  
  30. }rpg@rpg$ gcc -S -O2 test.c
  31. rpg@rpg$ cat test.s
  32. .file "test.c"
  33. .section .rodata.str1.1,"aMS",@progbits,1
  34. .LC4:
  35. .string "%f %f %f\n"
  36. .text
  37. .p2align 4,,15
  38. .globl main
  39. .type main, @function
  40. main:
  41. pushl %ebp
  42. movl %esp, %ebp
  43. andl $-16, %esp
  44. pushl %edi
  45. pushl %esi
  46. pushl %ebx
  47. subl $164, %esp
  48. call rand
  49. movl %eax, %edi
  50. call rand
  51. movl %eax, %esi
  52. call rand
  53. movl %eax, %ebx
  54. call rand
  55. movl %edi, 44(%esp)
  56. fildl 44(%esp)
  57. fstps 48(%esp)
  58. movl %esi, 44(%esp)
  59. fildl 44(%esp)
  60. fstps 52(%esp)
  61. movl %ebx, 44(%esp)
  62. fildl 44(%esp)
  63. movl %eax, 44(%esp)
  64. movl 48(%esp), %eax
  65. fstps 56(%esp)
  66. fildl 44(%esp)
  67. fstps 60(%esp)
  68. movl %eax, 144(%esp)
  69. movl 52(%esp), %eax
  70. movl %eax, 148(%esp)
  71. movl 56(%esp), %eax
  72. movl %eax, 152(%esp)
  73. movl 60(%esp), %eax
  74. movl %eax, 156(%esp)
  75. call rand
  76. movl %eax, %edi
  77. call rand
  78. movl %eax, %esi
  79. call rand
  80. movl %eax, %ebx
  81. call rand
  82. movl %edi, 44(%esp)
  83. fildl 44(%esp)
  84. fstps 48(%esp)
  85. movl %esi, 44(%esp)
  86. fildl 44(%esp)
  87. fstps 52(%esp)
  88. movl %ebx, 44(%esp)
  89. fildl 44(%esp)
  90. movl %eax, 44(%esp)
  91. movl 48(%esp), %eax
  92. fstps 56(%esp)
  93. fildl 44(%esp)
  94. fstps 60(%esp)
  95. movl %eax, 128(%esp)
  96. movl 52(%esp), %eax
  97. movl %eax, 132(%esp)
  98. movl 56(%esp), %eax
  99. flds 132(%esp)
  100. movl %eax, 136(%esp)
  101. movl 60(%esp), %eax
  102. flds 136(%esp)
  103. movl %eax, 140(%esp)
  104. flds 140(%esp)
  105. flds .LC0
  106. fmuls 128(%esp)
  107. fstps 48(%esp)
  108. fxch %st(2)
  109. movl 48(%esp), %eax
  110. fmuls .LC1
  111. fstps 52(%esp)
  112. fmuls .LC2
  113. fstps 56(%esp)
  114. flds .LC3
  115. fmul %st, %st(1)
  116. fxch %st(1)
  117. fstps 60(%esp)
  118. movl %eax, 112(%esp)
  119. flds 112(%esp)
  120. fadds 144(%esp)
  121. movl 52(%esp), %eax
  122. fstps 48(%esp)
  123. movl %eax, 116(%esp)
  124. flds 148(%esp)
  125. fadds 116(%esp)
  126. movl 56(%esp), %eax
  127. fstps 52(%esp)
  128. movl %eax, 120(%esp)
  129. flds 152(%esp)
  130. fadds 120(%esp)
  131. movl 60(%esp), %eax
  132. fstps 56(%esp)
  133. movl %eax, 124(%esp)
  134. flds 156(%esp)
  135. fadds 124(%esp)
  136. movl 48(%esp), %eax
  137. fstps 60(%esp)
  138. movl %eax, 96(%esp)
  139. movl 52(%esp), %eax
  140. flds 96(%esp)
  141. fsub %st(1), %st
  142. movl %eax, 100(%esp)
  143. movl 56(%esp), %eax
  144. fstps 48(%esp)
  145. flds 100(%esp)
  146. fsub %st(1), %st
  147. movl %eax, 104(%esp)
  148. movl 60(%esp), %eax
  149. fstps 52(%esp)
  150. flds 104(%esp)
  151. fsub %st(1), %st
  152. movl %eax, 108(%esp)
  153. fstps 56(%esp)
  154. fsubrs 108(%esp)
  155. fstps 60(%esp)
  156. movl 48(%esp), %eax
  157. movl $.LC4, 4(%esp)
  158. movl $1, (%esp)
  159. movl %eax, 64(%esp)
  160. movl 52(%esp), %eax
  161. movl %eax, 68(%esp)
  162. movl 56(%esp), %eax
  163. movl %eax, 72(%esp)
  164. movl 60(%esp), %eax
  165. flds 72(%esp)
  166. fstpl 24(%esp)
  167. movl %eax, 76(%esp)
  168. flds 68(%esp)
  169. fstpl 16(%esp)
  170. flds 64(%esp)
  171. fstpl 8(%esp)
  172. call __printf_chk
  173. addl $164, %esp
  174. popl %ebx
  175. popl %esi
  176. popl %edi
  177. movl %ebp, %esp
  178. popl %ebp
  179. ret
  180. .size main, .-main
  181. .globl half
  182. .section .rodata
  183. .align 16
  184. .type half, @object
  185. .size half, 16
  186. half:
  187. .long 1056964608
  188. .long 1056964608
  189. .long 1056964608
  190. .long 1056964608
  191. .section .rodata.cst4,"aM",@progbits,4
  192. .align 4
  193. .LC0:
  194. .long 1062668862
  195. .align 4
  196. .LC1:
  197. .long 1061830000
  198. .align 4
  199. .LC2:
  200. .long 1069295862
  201. .align 4
  202. .LC3:
  203. .long 1056964608
  204. .ident "GCC: (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2"
  205. .section .note.GNU-stack,"",@progbits
  206. rpg@rpg$ gcc -S -O2 -msse test.c
  207. rpg@rpg$ cat test.s
  208. .file "test.c"
  209. .section .rodata.str1.1,"aMS",@progbits,1
  210. .LC2:
  211. .string "%f %f %f\n"
  212. .text
  213. .p2align 4,,15
  214. .globl main
  215. .type main, @function
  216. main:
  217. pushl %ebp
  218. movl %esp, %ebp
  219. andl $-16, %esp
  220. pushl %edi
  221. pushl %esi
  222. pushl %ebx
  223. subl $100, %esp
  224. call rand
  225. movl %eax, %ebx
  226. call rand
  227. movl %eax, 48(%esp)
  228. call rand
  229. movl %eax, 72(%esp)
  230. call rand
  231. movl %eax, 68(%esp)
  232. call rand
  233. movl %eax, 44(%esp)
  234. call rand
  235. movl %eax, %edi
  236. call rand
  237. movl %eax, %esi
  238. call rand
  239. movl 44(%esp), %edx
  240. movl 48(%esp), %ecx
  241. movl %edx, 76(%esp)
  242. fildl 76(%esp)
  243. fstps 64(%esp)
  244. movl %edi, 76(%esp)
  245. fildl 76(%esp)
  246. fstps 60(%esp)
  247. movl %esi, 76(%esp)
  248. fildl 76(%esp)
  249. fstps 56(%esp)
  250. movl %eax, 76(%esp)
  251. fildl 76(%esp)
  252. fstps 52(%esp)
  253. movl %ebx, 76(%esp)
  254. fildl 76(%esp)
  255. movss 64(%esp), %xmm3
  256. movl %ecx, 76(%esp)
  257. fstps 64(%esp)
  258. movss 60(%esp), %xmm4
  259. movss 52(%esp), %xmm2
  260. movss 56(%esp), %xmm1
  261. fildl 76(%esp)
  262. unpcklps %xmm4, %xmm3
  263. fstps 60(%esp)
  264. fildl 72(%esp)
  265. unpcklps %xmm2, %xmm1
  266. fstps 72(%esp)
  267. fildl 68(%esp)
  268. fstps 68(%esp)
  269. movaps %xmm1, %xmm0
  270. movaps %xmm3, %xmm1
  271. movlhps %xmm0, %xmm1
  272. movss 68(%esp), %xmm3
  273. movss 72(%esp), %xmm0
  274. movss 64(%esp), %xmm4
  275. mulps .LC0, %xmm1
  276. unpcklps %xmm3, %xmm0
  277. movss 60(%esp), %xmm3
  278. movaps %xmm0, %xmm2
  279. unpcklps %xmm3, %xmm4
  280. movaps %xmm4, %xmm0
  281. movlhps %xmm2, %xmm0
  282. addps %xmm1, %xmm0
  283. subps .LC1, %xmm0
  284. movaps %xmm0, 80(%esp)
  285. flds 88(%esp)
  286. fstpl 24(%esp)
  287. movl $.LC2, 4(%esp)
  288. flds 84(%esp)
  289. fstpl 16(%esp)
  290. movl $1, (%esp)
  291. flds 80(%esp)
  292. fstpl 8(%esp)
  293. call __printf_chk
  294. addl $100, %esp
  295. popl %ebx
  296. popl %esi
  297. popl %edi
  298. movl %ebp, %esp
  299. popl %ebp
  300. ret
  301. .size main, .-main
  302. .globl half
  303. .section .rodata
  304. .align 16
  305. .type half, @object
  306. .size half, 16
  307. half:
  308. .long 1056964608
  309. .long 1056964608
  310. .long 1056964608
  311. .long 1056964608
  312. .section .rodata.cst16,"aM",@progbits,16
  313. .align 16
  314. .LC0:
  315. .long 1062668862
  316. .long 1061830000
  317. .long 1069295862
  318. .long 1056964608
  319. .align 16
  320. .LC1:
  321. .long 1056964608
  322. .long 1056964608
  323. .long 1056964608
  324. .long 1056964608
  325. .ident "GCC: (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2"
  326. .section .note.GNU-stack,"",@progbits
  327. rpg@rpg$
Advertisement
Add Comment
Please, Sign In to add comment