crc32-vpmsum_core.S 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. /*
  2. * Core of the accelerated CRC algorithm.
  3. * In your file, define the constants and CRC_FUNCTION_NAME
  4. * Then include this file.
  5. *
  6. * Calculate the checksum of data that is 16 byte aligned and a multiple of
  7. * 16 bytes.
  8. *
  9. * The first step is to reduce it to 1024 bits. We do this in 8 parallel
  10. * chunks in order to mask the latency of the vpmsum instructions. If we
  11. * have more than 32 kB of data to checksum we repeat this step multiple
  12. * times, passing in the previous 1024 bits.
  13. *
  14. * The next step is to reduce the 1024 bits to 64 bits. This step adds
  15. * 32 bits of 0s to the end - this matches what a CRC does. We just
  16. * calculate constants that land the data in this 32 bits.
  17. *
  18. * We then use fixed point Barrett reduction to compute a mod n over GF(2)
  19. * for n = CRC using POWER8 instructions. We use x = 32.
  20. *
  21. * http://en.wikipedia.org/wiki/Barrett_reduction
  22. *
  23. * Copyright (C) 2015 Anton Blanchard <anton@au.ibm.com>, IBM
  24. *
  25. * This program is free software; you can redistribute it and/or
  26. * modify it under the terms of the GNU General Public License
  27. * as published by the Free Software Foundation; either version
  28. * 2 of the License, or (at your option) any later version.
  29. */
  30. #include <asm/ppc_asm.h>
  31. #include <asm/ppc-opcode.h>
  32. #define MAX_SIZE 32768
  33. .text
  34. #if defined(__BIG_ENDIAN__) && defined(REFLECT)
  35. #define BYTESWAP_DATA
  36. #elif defined(__LITTLE_ENDIAN__) && !defined(REFLECT)
  37. #define BYTESWAP_DATA
  38. #else
  39. #undef BYTESWAP_DATA
  40. #endif
  41. #define off16 r25
  42. #define off32 r26
  43. #define off48 r27
  44. #define off64 r28
  45. #define off80 r29
  46. #define off96 r30
  47. #define off112 r31
  48. #define const1 v24
  49. #define const2 v25
  50. #define byteswap v26
  51. #define mask_32bit v27
  52. #define mask_64bit v28
  53. #define zeroes v29
  54. #ifdef BYTESWAP_DATA
  55. #define VPERM(A, B, C, D) vperm A, B, C, D
  56. #else
  57. #define VPERM(A, B, C, D)
  58. #endif
  59. /* unsigned int CRC_FUNCTION_NAME(unsigned int crc, void *p, unsigned long len) */
  60. FUNC_START(CRC_FUNCTION_NAME)
  61. std r31,-8(r1)
  62. std r30,-16(r1)
  63. std r29,-24(r1)
  64. std r28,-32(r1)
  65. std r27,-40(r1)
  66. std r26,-48(r1)
  67. std r25,-56(r1)
  68. li off16,16
  69. li off32,32
  70. li off48,48
  71. li off64,64
  72. li off80,80
  73. li off96,96
  74. li off112,112
  75. li r0,0
  76. /* Enough room for saving 10 non volatile VMX registers */
  77. subi r6,r1,56+10*16
  78. subi r7,r1,56+2*16
  79. stvx v20,0,r6
  80. stvx v21,off16,r6
  81. stvx v22,off32,r6
  82. stvx v23,off48,r6
  83. stvx v24,off64,r6
  84. stvx v25,off80,r6
  85. stvx v26,off96,r6
  86. stvx v27,off112,r6
  87. stvx v28,0,r7
  88. stvx v29,off16,r7
  89. mr r10,r3
  90. vxor zeroes,zeroes,zeroes
  91. vspltisw v0,-1
  92. vsldoi mask_32bit,zeroes,v0,4
  93. vsldoi mask_64bit,zeroes,v0,8
  94. /* Get the initial value into v8 */
  95. vxor v8,v8,v8
  96. MTVRD(v8, R3)
  97. #ifdef REFLECT
  98. vsldoi v8,zeroes,v8,8 /* shift into bottom 32 bits */
  99. #else
  100. vsldoi v8,v8,zeroes,4 /* shift into top 32 bits */
  101. #endif
  102. #ifdef BYTESWAP_DATA
  103. addis r3,r2,.byteswap_constant@toc@ha
  104. addi r3,r3,.byteswap_constant@toc@l
  105. lvx byteswap,0,r3
  106. addi r3,r3,16
  107. #endif
  108. cmpdi r5,256
  109. blt .Lshort
  110. rldicr r6,r5,0,56
  111. /* Checksum in blocks of MAX_SIZE */
  112. 1: lis r7,MAX_SIZE@h
  113. ori r7,r7,MAX_SIZE@l
  114. mr r9,r7
  115. cmpd r6,r7
  116. bgt 2f
  117. mr r7,r6
  118. 2: subf r6,r7,r6
  119. /* our main loop does 128 bytes at a time */
  120. srdi r7,r7,7
  121. /*
  122. * Work out the offset into the constants table to start at. Each
  123. * constant is 16 bytes, and it is used against 128 bytes of input
  124. * data - 128 / 16 = 8
  125. */
  126. sldi r8,r7,4
  127. srdi r9,r9,3
  128. subf r8,r8,r9
  129. /* We reduce our final 128 bytes in a separate step */
  130. addi r7,r7,-1
  131. mtctr r7
  132. addis r3,r2,.constants@toc@ha
  133. addi r3,r3,.constants@toc@l
  134. /* Find the start of our constants */
  135. add r3,r3,r8
  136. /* zero v0-v7 which will contain our checksums */
  137. vxor v0,v0,v0
  138. vxor v1,v1,v1
  139. vxor v2,v2,v2
  140. vxor v3,v3,v3
  141. vxor v4,v4,v4
  142. vxor v5,v5,v5
  143. vxor v6,v6,v6
  144. vxor v7,v7,v7
  145. lvx const1,0,r3
  146. /*
  147. * If we are looping back to consume more data we use the values
  148. * already in v16-v23.
  149. */
  150. cmpdi r0,1
  151. beq 2f
  152. /* First warm up pass */
  153. lvx v16,0,r4
  154. lvx v17,off16,r4
  155. VPERM(v16,v16,v16,byteswap)
  156. VPERM(v17,v17,v17,byteswap)
  157. lvx v18,off32,r4
  158. lvx v19,off48,r4
  159. VPERM(v18,v18,v18,byteswap)
  160. VPERM(v19,v19,v19,byteswap)
  161. lvx v20,off64,r4
  162. lvx v21,off80,r4
  163. VPERM(v20,v20,v20,byteswap)
  164. VPERM(v21,v21,v21,byteswap)
  165. lvx v22,off96,r4
  166. lvx v23,off112,r4
  167. VPERM(v22,v22,v22,byteswap)
  168. VPERM(v23,v23,v23,byteswap)
  169. addi r4,r4,8*16
  170. /* xor in initial value */
  171. vxor v16,v16,v8
  172. 2: bdz .Lfirst_warm_up_done
  173. addi r3,r3,16
  174. lvx const2,0,r3
  175. /* Second warm up pass */
  176. VPMSUMD(v8,v16,const1)
  177. lvx v16,0,r4
  178. VPERM(v16,v16,v16,byteswap)
  179. ori r2,r2,0
  180. VPMSUMD(v9,v17,const1)
  181. lvx v17,off16,r4
  182. VPERM(v17,v17,v17,byteswap)
  183. ori r2,r2,0
  184. VPMSUMD(v10,v18,const1)
  185. lvx v18,off32,r4
  186. VPERM(v18,v18,v18,byteswap)
  187. ori r2,r2,0
  188. VPMSUMD(v11,v19,const1)
  189. lvx v19,off48,r4
  190. VPERM(v19,v19,v19,byteswap)
  191. ori r2,r2,0
  192. VPMSUMD(v12,v20,const1)
  193. lvx v20,off64,r4
  194. VPERM(v20,v20,v20,byteswap)
  195. ori r2,r2,0
  196. VPMSUMD(v13,v21,const1)
  197. lvx v21,off80,r4
  198. VPERM(v21,v21,v21,byteswap)
  199. ori r2,r2,0
  200. VPMSUMD(v14,v22,const1)
  201. lvx v22,off96,r4
  202. VPERM(v22,v22,v22,byteswap)
  203. ori r2,r2,0
  204. VPMSUMD(v15,v23,const1)
  205. lvx v23,off112,r4
  206. VPERM(v23,v23,v23,byteswap)
  207. addi r4,r4,8*16
  208. bdz .Lfirst_cool_down
  209. /*
  210. * main loop. We modulo schedule it such that it takes three iterations
  211. * to complete - first iteration load, second iteration vpmsum, third
  212. * iteration xor.
  213. */
  214. .balign 16
  215. 4: lvx const1,0,r3
  216. addi r3,r3,16
  217. ori r2,r2,0
  218. vxor v0,v0,v8
  219. VPMSUMD(v8,v16,const2)
  220. lvx v16,0,r4
  221. VPERM(v16,v16,v16,byteswap)
  222. ori r2,r2,0
  223. vxor v1,v1,v9
  224. VPMSUMD(v9,v17,const2)
  225. lvx v17,off16,r4
  226. VPERM(v17,v17,v17,byteswap)
  227. ori r2,r2,0
  228. vxor v2,v2,v10
  229. VPMSUMD(v10,v18,const2)
  230. lvx v18,off32,r4
  231. VPERM(v18,v18,v18,byteswap)
  232. ori r2,r2,0
  233. vxor v3,v3,v11
  234. VPMSUMD(v11,v19,const2)
  235. lvx v19,off48,r4
  236. VPERM(v19,v19,v19,byteswap)
  237. lvx const2,0,r3
  238. ori r2,r2,0
  239. vxor v4,v4,v12
  240. VPMSUMD(v12,v20,const1)
  241. lvx v20,off64,r4
  242. VPERM(v20,v20,v20,byteswap)
  243. ori r2,r2,0
  244. vxor v5,v5,v13
  245. VPMSUMD(v13,v21,const1)
  246. lvx v21,off80,r4
  247. VPERM(v21,v21,v21,byteswap)
  248. ori r2,r2,0
  249. vxor v6,v6,v14
  250. VPMSUMD(v14,v22,const1)
  251. lvx v22,off96,r4
  252. VPERM(v22,v22,v22,byteswap)
  253. ori r2,r2,0
  254. vxor v7,v7,v15
  255. VPMSUMD(v15,v23,const1)
  256. lvx v23,off112,r4
  257. VPERM(v23,v23,v23,byteswap)
  258. addi r4,r4,8*16
  259. bdnz 4b
  260. .Lfirst_cool_down:
  261. /* First cool down pass */
  262. lvx const1,0,r3
  263. addi r3,r3,16
  264. vxor v0,v0,v8
  265. VPMSUMD(v8,v16,const1)
  266. ori r2,r2,0
  267. vxor v1,v1,v9
  268. VPMSUMD(v9,v17,const1)
  269. ori r2,r2,0
  270. vxor v2,v2,v10
  271. VPMSUMD(v10,v18,const1)
  272. ori r2,r2,0
  273. vxor v3,v3,v11
  274. VPMSUMD(v11,v19,const1)
  275. ori r2,r2,0
  276. vxor v4,v4,v12
  277. VPMSUMD(v12,v20,const1)
  278. ori r2,r2,0
  279. vxor v5,v5,v13
  280. VPMSUMD(v13,v21,const1)
  281. ori r2,r2,0
  282. vxor v6,v6,v14
  283. VPMSUMD(v14,v22,const1)
  284. ori r2,r2,0
  285. vxor v7,v7,v15
  286. VPMSUMD(v15,v23,const1)
  287. ori r2,r2,0
  288. .Lsecond_cool_down:
  289. /* Second cool down pass */
  290. vxor v0,v0,v8
  291. vxor v1,v1,v9
  292. vxor v2,v2,v10
  293. vxor v3,v3,v11
  294. vxor v4,v4,v12
  295. vxor v5,v5,v13
  296. vxor v6,v6,v14
  297. vxor v7,v7,v15
  298. #ifdef REFLECT
  299. /*
  300. * vpmsumd produces a 96 bit result in the least significant bits
  301. * of the register. Since we are bit reflected we have to shift it
  302. * left 32 bits so it occupies the least significant bits in the
  303. * bit reflected domain.
  304. */
  305. vsldoi v0,v0,zeroes,4
  306. vsldoi v1,v1,zeroes,4
  307. vsldoi v2,v2,zeroes,4
  308. vsldoi v3,v3,zeroes,4
  309. vsldoi v4,v4,zeroes,4
  310. vsldoi v5,v5,zeroes,4
  311. vsldoi v6,v6,zeroes,4
  312. vsldoi v7,v7,zeroes,4
  313. #endif
  314. /* xor with last 1024 bits */
  315. lvx v8,0,r4
  316. lvx v9,off16,r4
  317. VPERM(v8,v8,v8,byteswap)
  318. VPERM(v9,v9,v9,byteswap)
  319. lvx v10,off32,r4
  320. lvx v11,off48,r4
  321. VPERM(v10,v10,v10,byteswap)
  322. VPERM(v11,v11,v11,byteswap)
  323. lvx v12,off64,r4
  324. lvx v13,off80,r4
  325. VPERM(v12,v12,v12,byteswap)
  326. VPERM(v13,v13,v13,byteswap)
  327. lvx v14,off96,r4
  328. lvx v15,off112,r4
  329. VPERM(v14,v14,v14,byteswap)
  330. VPERM(v15,v15,v15,byteswap)
  331. addi r4,r4,8*16
  332. vxor v16,v0,v8
  333. vxor v17,v1,v9
  334. vxor v18,v2,v10
  335. vxor v19,v3,v11
  336. vxor v20,v4,v12
  337. vxor v21,v5,v13
  338. vxor v22,v6,v14
  339. vxor v23,v7,v15
  340. li r0,1
  341. cmpdi r6,0
  342. addi r6,r6,128
  343. bne 1b
  344. /* Work out how many bytes we have left */
  345. andi. r5,r5,127
  346. /* Calculate where in the constant table we need to start */
  347. subfic r6,r5,128
  348. add r3,r3,r6
  349. /* How many 16 byte chunks are in the tail */
  350. srdi r7,r5,4
  351. mtctr r7
  352. /*
  353. * Reduce the previously calculated 1024 bits to 64 bits, shifting
  354. * 32 bits to include the trailing 32 bits of zeros
  355. */
  356. lvx v0,0,r3
  357. lvx v1,off16,r3
  358. lvx v2,off32,r3
  359. lvx v3,off48,r3
  360. lvx v4,off64,r3
  361. lvx v5,off80,r3
  362. lvx v6,off96,r3
  363. lvx v7,off112,r3
  364. addi r3,r3,8*16
  365. VPMSUMW(v0,v16,v0)
  366. VPMSUMW(v1,v17,v1)
  367. VPMSUMW(v2,v18,v2)
  368. VPMSUMW(v3,v19,v3)
  369. VPMSUMW(v4,v20,v4)
  370. VPMSUMW(v5,v21,v5)
  371. VPMSUMW(v6,v22,v6)
  372. VPMSUMW(v7,v23,v7)
  373. /* Now reduce the tail (0 - 112 bytes) */
  374. cmpdi r7,0
  375. beq 1f
  376. lvx v16,0,r4
  377. lvx v17,0,r3
  378. VPERM(v16,v16,v16,byteswap)
  379. VPMSUMW(v16,v16,v17)
  380. vxor v0,v0,v16
  381. bdz 1f
  382. lvx v16,off16,r4
  383. lvx v17,off16,r3
  384. VPERM(v16,v16,v16,byteswap)
  385. VPMSUMW(v16,v16,v17)
  386. vxor v0,v0,v16
  387. bdz 1f
  388. lvx v16,off32,r4
  389. lvx v17,off32,r3
  390. VPERM(v16,v16,v16,byteswap)
  391. VPMSUMW(v16,v16,v17)
  392. vxor v0,v0,v16
  393. bdz 1f
  394. lvx v16,off48,r4
  395. lvx v17,off48,r3
  396. VPERM(v16,v16,v16,byteswap)
  397. VPMSUMW(v16,v16,v17)
  398. vxor v0,v0,v16
  399. bdz 1f
  400. lvx v16,off64,r4
  401. lvx v17,off64,r3
  402. VPERM(v16,v16,v16,byteswap)
  403. VPMSUMW(v16,v16,v17)
  404. vxor v0,v0,v16
  405. bdz 1f
  406. lvx v16,off80,r4
  407. lvx v17,off80,r3
  408. VPERM(v16,v16,v16,byteswap)
  409. VPMSUMW(v16,v16,v17)
  410. vxor v0,v0,v16
  411. bdz 1f
  412. lvx v16,off96,r4
  413. lvx v17,off96,r3
  414. VPERM(v16,v16,v16,byteswap)
  415. VPMSUMW(v16,v16,v17)
  416. vxor v0,v0,v16
  417. /* Now xor all the parallel chunks together */
  418. 1: vxor v0,v0,v1
  419. vxor v2,v2,v3
  420. vxor v4,v4,v5
  421. vxor v6,v6,v7
  422. vxor v0,v0,v2
  423. vxor v4,v4,v6
  424. vxor v0,v0,v4
  425. .Lbarrett_reduction:
  426. /* Barrett constants */
  427. addis r3,r2,.barrett_constants@toc@ha
  428. addi r3,r3,.barrett_constants@toc@l
  429. lvx const1,0,r3
  430. lvx const2,off16,r3
  431. vsldoi v1,v0,v0,8
  432. vxor v0,v0,v1 /* xor two 64 bit results together */
  433. #ifdef REFLECT
  434. /* shift left one bit */
  435. vspltisb v1,1
  436. vsl v0,v0,v1
  437. #endif
  438. vand v0,v0,mask_64bit
  439. #ifndef REFLECT
  440. /*
  441. * Now for the Barrett reduction algorithm. The idea is to calculate q,
  442. * the multiple of our polynomial that we need to subtract. By
  443. * doing the computation 2x bits higher (ie 64 bits) and shifting the
  444. * result back down 2x bits, we round down to the nearest multiple.
  445. */
  446. VPMSUMD(v1,v0,const1) /* ma */
  447. vsldoi v1,zeroes,v1,8 /* q = floor(ma/(2^64)) */
  448. VPMSUMD(v1,v1,const2) /* qn */
  449. vxor v0,v0,v1 /* a - qn, subtraction is xor in GF(2) */
  450. /*
  451. * Get the result into r3. We need to shift it left 8 bytes:
  452. * V0 [ 0 1 2 X ]
  453. * V0 [ 0 X 2 3 ]
  454. */
  455. vsldoi v0,v0,zeroes,8 /* shift result into top 64 bits */
  456. #else
  457. /*
  458. * The reflected version of Barrett reduction. Instead of bit
  459. * reflecting our data (which is expensive to do), we bit reflect our
  460. * constants and our algorithm, which means the intermediate data in
  461. * our vector registers goes from 0-63 instead of 63-0. We can reflect
  462. * the algorithm because we don't carry in mod 2 arithmetic.
  463. */
  464. vand v1,v0,mask_32bit /* bottom 32 bits of a */
  465. VPMSUMD(v1,v1,const1) /* ma */
  466. vand v1,v1,mask_32bit /* bottom 32bits of ma */
  467. VPMSUMD(v1,v1,const2) /* qn */
  468. vxor v0,v0,v1 /* a - qn, subtraction is xor in GF(2) */
  469. /*
  470. * Since we are bit reflected, the result (ie the low 32 bits) is in
  471. * the high 32 bits. We just need to shift it left 4 bytes
  472. * V0 [ 0 1 X 3 ]
  473. * V0 [ 0 X 2 3 ]
  474. */
  475. vsldoi v0,v0,zeroes,4 /* shift result into top 64 bits of */
  476. #endif
  477. /* Get it into r3 */
  478. MFVRD(R3, v0)
  479. .Lout:
  480. subi r6,r1,56+10*16
  481. subi r7,r1,56+2*16
  482. lvx v20,0,r6
  483. lvx v21,off16,r6
  484. lvx v22,off32,r6
  485. lvx v23,off48,r6
  486. lvx v24,off64,r6
  487. lvx v25,off80,r6
  488. lvx v26,off96,r6
  489. lvx v27,off112,r6
  490. lvx v28,0,r7
  491. lvx v29,off16,r7
  492. ld r31,-8(r1)
  493. ld r30,-16(r1)
  494. ld r29,-24(r1)
  495. ld r28,-32(r1)
  496. ld r27,-40(r1)
  497. ld r26,-48(r1)
  498. ld r25,-56(r1)
  499. blr
  500. .Lfirst_warm_up_done:
  501. lvx const1,0,r3
  502. addi r3,r3,16
  503. VPMSUMD(v8,v16,const1)
  504. VPMSUMD(v9,v17,const1)
  505. VPMSUMD(v10,v18,const1)
  506. VPMSUMD(v11,v19,const1)
  507. VPMSUMD(v12,v20,const1)
  508. VPMSUMD(v13,v21,const1)
  509. VPMSUMD(v14,v22,const1)
  510. VPMSUMD(v15,v23,const1)
  511. b .Lsecond_cool_down
  512. .Lshort:
  513. cmpdi r5,0
  514. beq .Lzero
  515. addis r3,r2,.short_constants@toc@ha
  516. addi r3,r3,.short_constants@toc@l
  517. /* Calculate where in the constant table we need to start */
  518. subfic r6,r5,256
  519. add r3,r3,r6
  520. /* How many 16 byte chunks? */
  521. srdi r7,r5,4
  522. mtctr r7
  523. vxor v19,v19,v19
  524. vxor v20,v20,v20
  525. lvx v0,0,r4
  526. lvx v16,0,r3
  527. VPERM(v0,v0,v16,byteswap)
  528. vxor v0,v0,v8 /* xor in initial value */
  529. VPMSUMW(v0,v0,v16)
  530. bdz .Lv0
  531. lvx v1,off16,r4
  532. lvx v17,off16,r3
  533. VPERM(v1,v1,v17,byteswap)
  534. VPMSUMW(v1,v1,v17)
  535. bdz .Lv1
  536. lvx v2,off32,r4
  537. lvx v16,off32,r3
  538. VPERM(v2,v2,v16,byteswap)
  539. VPMSUMW(v2,v2,v16)
  540. bdz .Lv2
  541. lvx v3,off48,r4
  542. lvx v17,off48,r3
  543. VPERM(v3,v3,v17,byteswap)
  544. VPMSUMW(v3,v3,v17)
  545. bdz .Lv3
  546. lvx v4,off64,r4
  547. lvx v16,off64,r3
  548. VPERM(v4,v4,v16,byteswap)
  549. VPMSUMW(v4,v4,v16)
  550. bdz .Lv4
  551. lvx v5,off80,r4
  552. lvx v17,off80,r3
  553. VPERM(v5,v5,v17,byteswap)
  554. VPMSUMW(v5,v5,v17)
  555. bdz .Lv5
  556. lvx v6,off96,r4
  557. lvx v16,off96,r3
  558. VPERM(v6,v6,v16,byteswap)
  559. VPMSUMW(v6,v6,v16)
  560. bdz .Lv6
  561. lvx v7,off112,r4
  562. lvx v17,off112,r3
  563. VPERM(v7,v7,v17,byteswap)
  564. VPMSUMW(v7,v7,v17)
  565. bdz .Lv7
  566. addi r3,r3,128
  567. addi r4,r4,128
  568. lvx v8,0,r4
  569. lvx v16,0,r3
  570. VPERM(v8,v8,v16,byteswap)
  571. VPMSUMW(v8,v8,v16)
  572. bdz .Lv8
  573. lvx v9,off16,r4
  574. lvx v17,off16,r3
  575. VPERM(v9,v9,v17,byteswap)
  576. VPMSUMW(v9,v9,v17)
  577. bdz .Lv9
  578. lvx v10,off32,r4
  579. lvx v16,off32,r3
  580. VPERM(v10,v10,v16,byteswap)
  581. VPMSUMW(v10,v10,v16)
  582. bdz .Lv10
  583. lvx v11,off48,r4
  584. lvx v17,off48,r3
  585. VPERM(v11,v11,v17,byteswap)
  586. VPMSUMW(v11,v11,v17)
  587. bdz .Lv11
  588. lvx v12,off64,r4
  589. lvx v16,off64,r3
  590. VPERM(v12,v12,v16,byteswap)
  591. VPMSUMW(v12,v12,v16)
  592. bdz .Lv12
  593. lvx v13,off80,r4
  594. lvx v17,off80,r3
  595. VPERM(v13,v13,v17,byteswap)
  596. VPMSUMW(v13,v13,v17)
  597. bdz .Lv13
  598. lvx v14,off96,r4
  599. lvx v16,off96,r3
  600. VPERM(v14,v14,v16,byteswap)
  601. VPMSUMW(v14,v14,v16)
  602. bdz .Lv14
  603. lvx v15,off112,r4
  604. lvx v17,off112,r3
  605. VPERM(v15,v15,v17,byteswap)
  606. VPMSUMW(v15,v15,v17)
  607. .Lv15: vxor v19,v19,v15
  608. .Lv14: vxor v20,v20,v14
  609. .Lv13: vxor v19,v19,v13
  610. .Lv12: vxor v20,v20,v12
  611. .Lv11: vxor v19,v19,v11
  612. .Lv10: vxor v20,v20,v10
  613. .Lv9: vxor v19,v19,v9
  614. .Lv8: vxor v20,v20,v8
  615. .Lv7: vxor v19,v19,v7
  616. .Lv6: vxor v20,v20,v6
  617. .Lv5: vxor v19,v19,v5
  618. .Lv4: vxor v20,v20,v4
  619. .Lv3: vxor v19,v19,v3
  620. .Lv2: vxor v20,v20,v2
  621. .Lv1: vxor v19,v19,v1
  622. .Lv0: vxor v20,v20,v0
  623. vxor v0,v19,v20
  624. b .Lbarrett_reduction
  625. .Lzero:
  626. mr r3,r10
  627. b .Lout
  628. FUNC_END(CRC_FUNCTION_NAME)