/gcc/testsuite/gcc.dg/vect/complex/complex-operations.c

https://gitlab.com/adotout/gcc · C · 358 lines · 273 code · 69 blank · 16 comment · 44 complexity · b663bc81b4270defc2534ee4b697c313 MD5 · raw file

  1. #include <stdio.h>
  2. #include <complex.h>
  3. #ifndef PREF
  4. #define PREF c
  5. #endif
  6. #define FX(N,P) P ## _ ## N
  7. #define MK(N,P) FX(P,N)
  8. #define N 32
  9. #define TYPE double
  10. // ------ FMA
  11. // Complex FMA instructions rotating the result
  12. __attribute__((noinline,noipa))
  13. void MK(fma0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  14. {
  15. for (int i=0; i < N; i++)
  16. c[i] += a[i] * b[i];
  17. }
  18. __attribute__((noinline,noipa))
  19. void MK(fma90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  20. {
  21. for (int i=0; i < N; i++)
  22. c[i] += a[i] * b[i] * I;
  23. }
  24. __attribute__((noinline,noipa))
  25. void MK(fma180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  26. {
  27. for (int i=0; i < N; i++)
  28. c[i] += a[i] * b[i] * I * I;
  29. }
  30. __attribute__((noinline,noipa))
  31. void MK(fma270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  32. {
  33. for (int i=0; i < N; i++)
  34. c[i] += a[i] * b[i] * I * I * I;
  35. }
  36. // Complex FMA instructions rotating the second parameter.
  37. __attribute__((noinline,noipa))
  38. void MK(fma0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  39. {
  40. for (int i=0; i < N; i++)
  41. c[i] += a[i] * b[i];
  42. }
  43. __attribute__((noinline,noipa))
  44. void MK(fma90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  45. {
  46. for (int i=0; i < N; i++)
  47. c[i] += a[i] * (b[i] * I);
  48. }
  49. __attribute__((noinline,noipa))
  50. void MK(fma180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  51. {
  52. for (int i=0; i < N; i++)
  53. c[i] += a[i] * (b[i] * I * I);
  54. }
  55. __attribute__((noinline,noipa))
  56. void MK(fma270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  57. {
  58. for (int i=0; i < N; i++)
  59. c[i] += a[i] * (b[i] * I * I * I);
  60. }
  61. // Complex FMA instructions with conjucated values.
  62. __attribute__((noinline,noipa))
  63. void MK(fma_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  64. {
  65. for (int i=0; i < N; i++)
  66. c[i] += conj (a[i]) * b[i];
  67. }
  68. __attribute__((noinline,noipa))
  69. void MK(fma_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  70. {
  71. for (int i=0; i < N; i++)
  72. c[i] += a[i] * conj (b[i]);
  73. }
  74. __attribute__((noinline,noipa))
  75. void MK(fma_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  76. {
  77. for (int i=0; i < N; i++)
  78. c[i] += conj (a[i]) * conj (b[i]);
  79. }
  80. // ----- FMS
  81. // Complex FMS instructions rotating the result
  82. __attribute__((noinline,noipa))
  83. void MK(fms0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  84. {
  85. for (int i=0; i < N; i++)
  86. c[i] -= a[i] * b[i];
  87. }
  88. __attribute__((noinline,noipa))
  89. void MK(fms90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  90. {
  91. for (int i=0; i < N; i++)
  92. c[i] -= a[i] * b[i] * I;
  93. }
  94. __attribute__((noinline,noipa))
  95. void MK(fms180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  96. {
  97. for (int i=0; i < N; i++)
  98. c[i] -= a[i] * b[i] * I * I;
  99. }
  100. __attribute__((noinline,noipa))
  101. void MK(fms270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  102. {
  103. for (int i=0; i < N; i++)
  104. c[i] -= a[i] * b[i] * I * I * I;
  105. }
  106. // Complex FMS instructions rotating the second parameter.
  107. __attribute__((noinline,noipa))
  108. void MK(fms0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  109. {
  110. for (int i=0; i < N; i++)
  111. c[i] -= a[i] * b[i];
  112. }
  113. __attribute__((noinline,noipa))
  114. void MK(fms90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  115. {
  116. for (int i=0; i < N; i++)
  117. c[i] -= a[i] * (b[i] * I);
  118. }
  119. __attribute__((noinline,noipa))
  120. void MK(fms180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  121. {
  122. for (int i=0; i < N; i++)
  123. c[i] -= a[i] * (b[i] * I * I);
  124. }
  125. __attribute__((noinline,noipa))
  126. void MK(fms270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  127. {
  128. for (int i=0; i < N; i++)
  129. c[i] -= a[i] * (b[i] * I * I * I);
  130. }
  131. // Complex FMS instructions with conjucated values.
  132. __attribute__((noinline,noipa))
  133. void MK(fms_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  134. {
  135. for (int i=0; i < N; i++)
  136. c[i] -= conj (a[i]) * b[i];
  137. }
  138. __attribute__((noinline,noipa))
  139. void MK(fms_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  140. {
  141. for (int i=0; i < N; i++)
  142. c[i] -= a[i] * conj (b[i]);
  143. }
  144. __attribute__((noinline,noipa))
  145. void MK(fms_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  146. {
  147. for (int i=0; i < N; i++)
  148. c[i] -= conj (a[i]) * conj (b[i]);
  149. }
  150. // ----- MUL
  151. // Complex MUL instructions rotating the result
  152. __attribute__((noinline,noipa))
  153. void MK(mul0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  154. {
  155. for (int i=0; i < N; i++)
  156. c[i] = a[i] * b[i];
  157. }
  158. __attribute__((noinline,noipa))
  159. void MK(mul90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  160. {
  161. for (int i=0; i < N; i++)
  162. c[i] = a[i] * b[i] * I;
  163. }
  164. __attribute__((noinline,noipa))
  165. void MK(mul180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  166. {
  167. for (int i=0; i < N; i++)
  168. c[i] = a[i] * b[i] * I * I;
  169. }
  170. __attribute__((noinline,noipa))
  171. void MK(mul270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  172. {
  173. for (int i=0; i < N; i++)
  174. c[i] = a[i] * b[i] * I * I * I;
  175. }
  176. // Complex MUL instructions rotating the second parameter.
  177. __attribute__((noinline,noipa))
  178. void MK(mul0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  179. {
  180. for (int i=0; i < N; i++)
  181. c[i] = a[i] * b[i];
  182. }
  183. __attribute__((noinline,noipa))
  184. void MK(mul90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  185. {
  186. for (int i=0; i < N; i++)
  187. c[i] = a[i] * (b[i] * I);
  188. }
  189. __attribute__((noinline,noipa))
  190. void MK(mul180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  191. {
  192. for (int i=0; i < N; i++)
  193. c[i] = a[i] * (b[i] * I * I);
  194. }
  195. __attribute__((noinline,noipa))
  196. void MK(mul270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  197. {
  198. for (int i=0; i < N; i++)
  199. c[i] = a[i] * (b[i] * I * I * I);
  200. }
  201. // Complex FMS instructions with conjucated values.
  202. __attribute__((noinline,noipa))
  203. void MK(mul_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  204. {
  205. for (int i=0; i < N; i++)
  206. c[i] = conj (a[i]) * b[i];
  207. }
  208. __attribute__((noinline,noipa))
  209. void MK(mul_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  210. {
  211. for (int i=0; i < N; i++)
  212. c[i] = a[i] * conj (b[i]);
  213. }
  214. __attribute__((noinline,noipa))
  215. void MK(mul_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  216. {
  217. for (int i=0; i < N; i++)
  218. c[i] = conj (a[i]) * conj (b[i]);
  219. }
  220. // ----- ADD
  221. // Complex ADD instructions rotating the result
  222. __attribute__((noinline,noipa))
  223. void MK(add0, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  224. {
  225. for (int i=0; i < N; i++)
  226. c[i] = a[i] + b[i];
  227. }
  228. __attribute__((noinline,noipa))
  229. void MK(add90, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  230. {
  231. for (int i=0; i < N; i++)
  232. c[i] = (a[i] + b[i]) * I;
  233. }
  234. __attribute__((noinline,noipa))
  235. void MK(add180, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  236. {
  237. for (int i=0; i < N; i++)
  238. c[i] = (a[i] + b[i]) * I * I;
  239. }
  240. __attribute__((noinline,noipa))
  241. void MK(add270, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  242. {
  243. for (int i=0; i < N; i++)
  244. c[i] = (a[i] + b[i]) * I * I * I;
  245. }
  246. // Complex ADD instructions rotating the second parameter.
  247. __attribute__((noinline,noipa))
  248. void MK(add0_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  249. {
  250. for (int i=0; i < N; i++)
  251. c[i] = a[i] + b[i];
  252. }
  253. __attribute__((noinline,noipa))
  254. void MK(add90_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  255. {
  256. for (int i=0; i < N; i++)
  257. c[i] = a[i] + (b[i] * I);
  258. }
  259. __attribute__((noinline,noipa))
  260. void MK(add180_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  261. {
  262. for (int i=0; i < N; i++)
  263. c[i] = a[i] + (b[i] * I * I);
  264. }
  265. __attribute__((noinline,noipa))
  266. void MK(add270_snd, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  267. {
  268. for (int i=0; i < N; i++)
  269. c[i] = a[i] + (b[i] * I * I * I);
  270. }
  271. // Complex ADD instructions with conjucated values.
  272. __attribute__((noinline,noipa))
  273. void MK(add_conj_first, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  274. {
  275. for (int i=0; i < N; i++)
  276. c[i] = conj (a[i]) + b[i];
  277. }
  278. __attribute__((noinline,noipa))
  279. void MK(add_conj_second, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  280. {
  281. for (int i=0; i < N; i++)
  282. c[i] = a[i] + conj (b[i]);
  283. }
  284. __attribute__((noinline,noipa))
  285. void MK(add_conj_both, PREF) (TYPE complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
  286. {
  287. for (int i=0; i < N; i++)
  288. c[i] = conj (a[i]) + conj (b[i]);
  289. }