5 * ternlogi <https://bugs.libre-soc.org/show_bug.cgi?id=745>
6 * grev <https://bugs.libre-soc.org/show_bug.cgi?id=755>
7 * remove Rc=1 from ternlog due to conflicts in encoding as well
8 as saving space <https://bugs.libre-soc.org/show_bug.cgi?id=753#c5>
14 this extension amalgamates bitmanipulation primitives from many sources, including RISC-V bitmanip, Packed SIMD, AVX-512 and OpenPOWER VSX. Vectorisation and SIMD are removed: these are straight scalar (element) operations making them suitable for embedded applications.
15 Vectorisation Context is provided by [[openpower/sv]].
17 When combined with SV, scalar variants of bitmanip operations found in VSX are added so that VSX may be retired as "legacy" in the far future (10 to 20 years). Also, VSX is hundreds of opcodes, requires 128 bit pathways, and is wholly unsuited to low power or embedded scenarios.
19 ternlogv is experimental and is the only operation that may be considered a "Packed SIMD". It is added as a variant of the already well-justified ternlog operation (done in AVX512 as an immediate only) "because it looks fun". As it is based on the LUT4 concept it will allow accelerated emulation of FPGAs. Other vendors of ISAs are buying FPGA companies to achieve similar objectives.
21 general-purpose Galois Field operations are added so as to avoid huge custom opcode proliferation across many areas of Computer Science. however for convenience and also to avoid setup costs, some of the more common operations (clmul, crc32) are also added. The expectation is that these operations would all be covered by the same pipeline.
23 note that there are brownfield spaces below that could incorporate some of the set-before-first and other scalar operations listed in [[sv/vector_ops]], and
24 the [[sv/av_opcodes]] as well as [[sv/setvl]]
28 * <https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders>
29 * <https://maths-people.anu.edu.au/~brent/pd/rpb232tr.pdf>
33 minor opcode allocation
36 | ------ |--| --------- |
43 | 101 |0 | ternlogcr |
49 | dest | src1 | subop | op |
50 | ---- | ---- | ----- | -------- |
51 | RT | RA | .. | bmatflip |
55 | dest | src1 | src2 | subop | op |
56 | ---- | ---- | ---- | ----- | -------- |
57 | RT | RA | RB | or | bmatflip |
58 | RT | RA | RB | xor | bmatflip |
59 | RT | RA | RB | | grev |
60 | RT | RA | RB | | clmul* |
61 | RT | RA | RB | | gorc |
62 | RT | RA | RB | shuf | shuffle |
63 | RT | RA | RB | unshuf| shuffle |
64 | RT | RA | RB | width | xperm |
65 | RT | RA | RB | type | minmax |
66 | RT | RA | RB | | av abs avgadd |
67 | RT | RA | RB | type | vmask ops |
76 | 0.5|6.10|11.15|16.20|21..25 | 26....30 |31| name |
77 | -- | -- | --- | --- | ----- | -------- |--| ------ |
78 | NN | RT | RA | RB | RC | mode 000 |1 | ternlog |
79 | NN | RT | RA | RB | im0-4 | im5-7 00 |0 | ternlogi |
80 | NN | RS | RA | RB | RC | 00 011 |Rc| gfmul |
81 | NN | RS | RA | RB | RC | 01 011 |Rc| gfadd |
82 | NN | RT | RA | RB | deg | 10 011 |Rc| gfinv |
83 | NN | RS | RA | RB | deg | 11 011 |Rc| gfmuli |
84 | NN | RS | RA | RB | deg | 11 111 |Rc| gfaddi |
86 | 0.5|6.10|11.15| 16.23 |24.27 | 28.30 |31| name |
87 | -- | -- | --- | ----- | ---- | ----- |--| ------ |
88 | NN | RT | RA | imm | mask | 101 |1 | ternlogv |
90 | 0.5|6.8 | 9.11|12.14|15|16.23|24.27 | 28.30|31| name |
91 | -- | -- | --- | --- |- |-----|----- | -----|--| -------|
92 | NN | BA | BB | BC |0 |imm | mask | 101 |0 | ternlogcr |
94 ops (note that av avg and abs as well as vec scalar mask
97 | 0.5|6.10|11.15|16.20| 21.22 | 23 | 24....30 |31| name |
98 | -- | -- | --- | --- | ----- | -- | -------- |--| ---- |
99 | NN | RA | RB | | | 0 | 0000 110 |Rc| rsvd |
100 | NN | RA | RB | RC | itype | 1 | 0000 110 |Rc| xperm |
101 | NN | RA | RB | RC | itype | 0 | 0100 110 |Rc| minmax |
102 | NN | RA | RB | RC | 00 | 1 | 0100 110 |Rc| av avgadd |
103 | NN | RA | RB | RC | 01 | 1 | 0100 110 |Rc| av abs |
104 | NN | RA | RB | | 10 | 1 | 0100 110 |Rc| rsvd |
105 | NN | RA | RB | | 11 | 1 | 0100 110 |Rc| rsvd |
106 | NN | RA | RB | sh | itype | SH | 1000 110 |Rc| bmopsi |
107 | NN | RA | RB | | | | 1100 110 |Rc| rsvd |
108 | NN | RA | RB | | | 1 | 0001 110 |Rc| rsvd |
109 | NN | RA | RB | RC | 00 | 0 | 0001 110 |Rc| vec sbfm |
110 | NN | RA | RB | RC | 01 | 0 | 0001 110 |Rc| vec sofm |
111 | NN | RA | RB | RC | 10 | 0 | 0001 110 |Rc| vec sifm |
112 | NN | RA | RB | RC | 11 | 0 | 0001 110 |Rc| vec cprop |
113 | NN | RA | RB | | | 0 | 0101 110 |Rc| rsvd |
114 | NN | RA | RB | RC | 00 | 0 | 0010 110 |Rc| gorc |
115 | NN | RA | RB | sh | 00 | SH | 1010 110 |Rc| gorci |
116 | NN | RA | RB | RC | 00 | 0 | 0110 110 |Rc| gorcw |
117 | NN | RA | RB | sh | 00 | 0 | 1110 110 |Rc| gorcwi |
118 | NN | RA | RB | RC | 00 | 1 | 1110 110 |Rc| bmator |
119 | NN | RA | RB | RC | 01 | 0 | 0010 110 |Rc| grev |
120 | NN | RA | RB | RC | 01 | 1 | 0010 110 |Rc| clmul |
121 | NN | RA | RB | sh | 01 | SH | 1010 110 |Rc| grevi |
122 | NN | RA | RB | RC | 01 | 0 | 0110 110 |Rc| grevw |
123 | NN | RA | RB | sh | 01 | 0 | 1110 110 |Rc| grevwi |
124 | NN | RA | RB | RC | 01 | 1 | 1110 110 |Rc| bmatxor |
125 | NN | RA | RB | RC | 10 | 0 | 0010 110 |Rc| shfl |
126 | NN | RA | RB | sh | 10 | SH | 1010 110 |Rc| shfli |
127 | NN | RA | RB | RC | 10 | 0 | 0110 110 |Rc| shflw |
128 | NN | RA | RB | RC | 10 | | 1110 110 |Rc| rsvd |
129 | NN | RA | RB | RC | 11 | 0 | 1110 110 |Rc| clmulr |
130 | NN | RA | RB | RC | 11 | 1 | 1110 110 |Rc| clmulh |
131 | NN | | | | | | --11 110 |Rc| setvl |
133 # count leading/trailing zeros with mask
139 do i = 0 to 63 if((RB)i=1) then do
140 if((RS)i=1) then break end end count ← count + 1
144 # bit to byte permute
146 similar to matrix permute in RV bitmanip, which has XOR and OR variants
150 b = VSR[VRB+32].dword[i].byte[k].bit[j]
151 VSR[VRT+32].dword[i].byte[j].bit[k] = b
155 vpdepd VRT,VRA,VRB, identical to RV bitmamip bdep, found already in v3.1 p106
158 if VSR[VRB+32].dword[i].bit[63-m]=1 then do
159 result = VSR[VRA+32].dword[i].bit[63-k]
160 VSR[VRT+32].dword[i].bit[63-m] = result
166 uint_xlen_t bdep(uint_xlen_t RA, uint_xlen_t RB)
169 for (int i = 0, j = 0; i < XLEN; i++)
172 r |= uint_xlen_t(1) << i;
182 other way round: identical to RV bext, found in v3.1 p196
185 uint_xlen_t bext(uint_xlen_t RA, uint_xlen_t RB)
188 for (int i = 0, j = 0; i < XLEN; i++)
191 r |= uint_xlen_t(1) << j;
200 found in v3.1 p106 so not to be added here
210 if((RB)63-i==1) then do
211 result63-ptr1 = (RS)63-i
219 signed and unsigned min/max for integer. this is sort-of partly synthesiseable in [[sv/svp64]] with pred-result as long as the dest reg is one of the sources, but not both signed and unsigned. when the dest is also one of the srces and the mv fails due to the CR bittest failing this will only overwrite the dest where the src is greater (or less).
221 signed/unsigned min/max gives more flexibility.
224 uint_xlen_t min(uint_xlen_t rs1, uint_xlen_t rs2)
225 { return (int_xlen_t)rs1 < (int_xlen_t)rs2 ? rs1 : rs2;
227 uint_xlen_t max(uint_xlen_t rs1, uint_xlen_t rs2)
228 { return (int_xlen_t)rs1 > (int_xlen_t)rs2 ? rs1 : rs2;
230 uint_xlen_t minu(uint_xlen_t rs1, uint_xlen_t rs2)
231 { return rs1 < rs2 ? rs1 : rs2;
233 uint_xlen_t maxu(uint_xlen_t rs1, uint_xlen_t rs2)
234 { return rs1 > rs2 ? rs1 : rs2;
241 Similar to FPGA LUTs: for every bit perform a lookup into a table using an 8bit immediate, or in another register.
243 Like the x86 AVX512F [vpternlogd/vpternlogq](https://www.felixcloutier.com/x86/vpternlogd:vpternlogq) instructions.
247 | 0.5|6.10|11.15|16.20| 21..25| 26..30 |31|
248 | -- | -- | --- | --- | ----- | -------- |--|
249 | NN | RT | RA | RB | im0-4 | im5-7 00 |0 |
252 idx = RT[i] << 2 | RA[i] << 1 | RB[i]
253 RT[i] = (imm & (1<<idx)) != 0
255 bits 21..22 may be used to specify a mode, such as treating the whole integer zero/nonzero and putting 1/0 in the result, rather than bitwise test.
259 a 4 operand variant which becomes more along the lines of an FPGA:
261 | 0.5|6.10|11.15|16.20|21.25| 26...30 |31|
262 | -- | -- | --- | --- | --- | -------- |--|
263 | NN | RT | RA | RB | RC | mode 100 |1 |
266 idx = RT[i] << 2 | RA[i] << 1 | RB[i]
267 RT[i] = (RC & (1<<idx)) != 0
269 mode (2 bit) may be used to do inversion of ordering, similar to carryless mul,
274 also, another possible variant involving swizzle and vec4:
276 | 0.5|6.10|11.15| 16.23 |24.27 | 28.30 |31|
277 | -- | -- | --- | ----- | ---- | ----- |--|
278 | NN | RT | RA | imm | mask | 101 |1 |
281 idx = RA.x[i] << 2 | RA.y[i] << 1 | RA.z[i]
282 res = (imm & (1<<idx)) != 0
284 if mask[j]: RT[i+j*8] = res
288 another mode selection would be CRs not Ints.
290 | 0.5|6.8 | 9.11|12.14|15|16.23|24.27 | 28.30|31|
291 | -- | -- | --- | --- |- |-----|----- | -----|--|
292 | NN | BA | BB | BC |0 |imm | mask | 101 |0 |
295 if not mask[i] continue
296 idx = crregs[BA][i] << 2 |
299 crregs[BA][i] = (imm & (1<<idx)) != 0
303 based on RV bitmanip singlebit set, instruction format similar to shift
304 [[isa/fixedshift]]. bmext is actually covered already (shift-with-mask rldicl but only immediate version).
305 however bitmask-invert is not, and set/clr are not covered, although they can use the same Shift ALU.
307 bmext (RB) version is not the same as rldicl because bmext is a right shift by RC, where rldicl is a left rotate. for the immediate version this does not matter, so a bmexti is not required.
308 bmrev however there is no direct equivalent and consequently a bmrevi is required.
310 bmset (register for mask amount) is particularly useful for creating
311 predicate masks where the length is a dynamic runtime quantity.
312 bmset(RA=0, RB=0, RC=mask) will produce a run of ones of length "mask" in a single instruction without needing to initialise or depend on any other registers.
314 | 0.5|6.10|11.15|16.20|21.25| 26..30 |31| name |
315 | -- | -- | --- | --- | --- | ------- |--| ----- |
316 | NN | RT | RA | RB | RC | mode 010 |Rc| bm* |
317 | NN | RT | RA | RB | RC | 0 1 111 |Rc| bmrev |
321 uint_xlen_t bmset(RA, RB, sh)
323 int shamt = RB & (XLEN - 1);
325 return RA | (mask << shamt);
328 uint_xlen_t bmclr(RA, RB, sh)
330 int shamt = RB & (XLEN - 1);
332 return RA & ~(mask << shamt);
335 uint_xlen_t bminv(RA, RB, sh)
337 int shamt = RB & (XLEN - 1);
339 return RA ^ (mask << shamt);
342 uint_xlen_t bmext(RA, RB, sh)
344 int shamt = RB & (XLEN - 1);
346 return mask & (RA >> shamt);
350 bitmask extract with reverse. can be done by bitinverting all of RA and getting bits of RA from the opposite end.
354 rev[0:msb] = ra[msb:0];
357 uint_xlen_t bmextrev(RA, RB, sh)
359 int shamt = (RB & (XLEN - 1));
360 shamt = (XLEN-1)-shamt; # shift other end
361 bra = bitreverse(RA) # swap LSB-MSB
363 return mask & (bra >> shamt);
367 | 0.5|6.10|11.15|16.20|21.26| 27..30 |31| name |
368 | -- | -- | --- | --- | --- | ------- |--| ------ |
369 | NN | RT | RA | RB | sh | 0 111 |Rc| bmrevi |
378 uint64_t grev64(uint64_t RA, uint64_t RB)
382 if (shamt & 1) x = ((x & 0x5555555555555555LL) << 1) |
383 ((x & 0xAAAAAAAAAAAAAAAALL) >> 1);
384 if (shamt & 2) x = ((x & 0x3333333333333333LL) << 2) |
385 ((x & 0xCCCCCCCCCCCCCCCCLL) >> 2);
386 if (shamt & 4) x = ((x & 0x0F0F0F0F0F0F0F0FLL) << 4) |
387 ((x & 0xF0F0F0F0F0F0F0F0LL) >> 4);
388 if (shamt & 8) x = ((x & 0x00FF00FF00FF00FFLL) << 8) |
389 ((x & 0xFF00FF00FF00FF00LL) >> 8);
390 if (shamt & 16) x = ((x & 0x0000FFFF0000FFFFLL) << 16) |
391 ((x & 0xFFFF0000FFFF0000LL) >> 16);
392 if (shamt & 32) x = ((x & 0x00000000FFFFFFFFLL) << 32) |
393 ((x & 0xFFFFFFFF00000000LL) >> 32);
399 # shuffle / unshuffle
404 uint32_t shfl32(uint32_t RA, uint32_t RB)
408 if (shamt & 8) x = shuffle32_stage(x, 0x00ff0000, 0x0000ff00, 8);
409 if (shamt & 4) x = shuffle32_stage(x, 0x0f000f00, 0x00f000f0, 4);
410 if (shamt & 2) x = shuffle32_stage(x, 0x30303030, 0x0c0c0c0c, 2);
411 if (shamt & 1) x = shuffle32_stage(x, 0x44444444, 0x22222222, 1);
414 uint32_t unshfl32(uint32_t RA, uint32_t RB)
418 if (shamt & 1) x = shuffle32_stage(x, 0x44444444, 0x22222222, 1);
419 if (shamt & 2) x = shuffle32_stage(x, 0x30303030, 0x0c0c0c0c, 2);
420 if (shamt & 4) x = shuffle32_stage(x, 0x0f000f00, 0x00f000f0, 4);
421 if (shamt & 8) x = shuffle32_stage(x, 0x00ff0000, 0x0000ff00, 8);
425 uint64_t shuffle64_stage(uint64_t src, uint64_t maskL, uint64_t maskR, int N)
427 uint64_t x = src & ~(maskL | maskR);
428 x |= ((src << N) & maskL) | ((src >> N) & maskR);
431 uint64_t shfl64(uint64_t RA, uint64_t RB)
435 if (shamt & 16) x = shuffle64_stage(x, 0x0000ffff00000000LL,
436 0x00000000ffff0000LL, 16);
437 if (shamt & 8) x = shuffle64_stage(x, 0x00ff000000ff0000LL,
438 0x0000ff000000ff00LL, 8);
439 if (shamt & 4) x = shuffle64_stage(x, 0x0f000f000f000f00LL,
440 0x00f000f000f000f0LL, 4);
441 if (shamt & 2) x = shuffle64_stage(x, 0x3030303030303030LL,
442 0x0c0c0c0c0c0c0c0cLL, 2);
443 if (shamt & 1) x = shuffle64_stage(x, 0x4444444444444444LL,
444 0x2222222222222222LL, 1);
447 uint64_t unshfl64(uint64_t RA, uint64_t RB)
451 if (shamt & 1) x = shuffle64_stage(x, 0x4444444444444444LL,
452 0x2222222222222222LL, 1);
453 if (shamt & 2) x = shuffle64_stage(x, 0x3030303030303030LL,
454 0x0c0c0c0c0c0c0c0cLL, 2);
455 if (shamt & 4) x = shuffle64_stage(x, 0x0f000f000f000f00LL,
456 0x00f000f000f000f0LL, 4);
457 if (shamt & 8) x = shuffle64_stage(x, 0x00ff000000ff0000LL,
458 0x0000ff000000ff00LL, 8);
459 if (shamt & 16) x = shuffle64_stage(x, 0x0000ffff00000000LL,
460 0x00000000ffff0000LL, 16);
470 uint_xlen_t xperm(uint_xlen_t RA, uint_xlen_t RB, int sz_log2)
473 uint_xlen_t sz = 1LL << sz_log2;
474 uint_xlen_t mask = (1LL << sz) - 1;
475 for (int i = 0; i < XLEN; i += sz) {
476 uint_xlen_t pos = ((RB >> i) & mask) << sz_log2;
478 r |= ((RA >> pos) & mask) << i;
482 uint_xlen_t xperm_n (uint_xlen_t RA, uint_xlen_t RB)
483 { return xperm(RA, RB, 2); }
484 uint_xlen_t xperm_b (uint_xlen_t RA, uint_xlen_t RB)
485 { return xperm(RA, RB, 3); }
486 uint_xlen_t xperm_h (uint_xlen_t RA, uint_xlen_t RB)
487 { return xperm(RA, RB, 4); }
488 uint_xlen_t xperm_w (uint_xlen_t RA, uint_xlen_t RB)
489 { return xperm(RA, RB, 5); }
497 uint32_t gorc32(uint32_t RA, uint32_t RB)
501 if (shamt & 1) x |= ((x & 0x55555555) << 1) | ((x & 0xAAAAAAAA) >> 1);
502 if (shamt & 2) x |= ((x & 0x33333333) << 2) | ((x & 0xCCCCCCCC) >> 2);
503 if (shamt & 4) x |= ((x & 0x0F0F0F0F) << 4) | ((x & 0xF0F0F0F0) >> 4);
504 if (shamt & 8) x |= ((x & 0x00FF00FF) << 8) | ((x & 0xFF00FF00) >> 8);
505 if (shamt & 16) x |= ((x & 0x0000FFFF) << 16) | ((x & 0xFFFF0000) >> 16);
508 uint64_t gorc64(uint64_t RA, uint64_t RB)
512 if (shamt & 1) x |= ((x & 0x5555555555555555LL) << 1) |
513 ((x & 0xAAAAAAAAAAAAAAAALL) >> 1);
514 if (shamt & 2) x |= ((x & 0x3333333333333333LL) << 2) |
515 ((x & 0xCCCCCCCCCCCCCCCCLL) >> 2);
516 if (shamt & 4) x |= ((x & 0x0F0F0F0F0F0F0F0FLL) << 4) |
517 ((x & 0xF0F0F0F0F0F0F0F0LL) >> 4);
518 if (shamt & 8) x |= ((x & 0x00FF00FF00FF00FFLL) << 8) |
519 ((x & 0xFF00FF00FF00FF00LL) >> 8);
520 if (shamt & 16) x |= ((x & 0x0000FFFF0000FFFFLL) << 16) |
521 ((x & 0xFFFF0000FFFF0000LL) >> 16);
522 if (shamt & 32) x |= ((x & 0x00000000FFFFFFFFLL) << 32) |
523 ((x & 0xFFFFFFFF00000000LL) >> 32);
531 based on RV bitmanip, covered by ternlog bitops
534 uint_xlen_t cmix(uint_xlen_t RA, uint_xlen_t RB, uint_xlen_t RC) {
535 return (RA & RB) | (RC & ~RB);
542 see https://en.wikipedia.org/wiki/CLMUL_instruction_set
545 uint_xlen_t clmul(uint_xlen_t RA, uint_xlen_t RB)
548 for (int i = 0; i < XLEN; i++)
553 uint_xlen_t clmulh(uint_xlen_t RA, uint_xlen_t RB)
556 for (int i = 1; i < XLEN; i++)
561 uint_xlen_t clmulr(uint_xlen_t RA, uint_xlen_t RB)
564 for (int i = 0; i < XLEN; i++)
566 x ^= RA >> (XLEN-i-1);
572 see <https://courses.csail.mit.edu/6.857/2016/files/ffield.py>
576 this requires 3 parameters and a "degree"
578 RT = GFMUL(RA, RB, gfdegree, modulo=RC)
580 realistically with the degree also needing to be an immediate it should be brought down to an overwrite version:
582 RS = GFMUL(RS, RA, gfdegree, modulo=RC)
583 RS = GFMUL(RS, RA, gfdegree=RB, modulo=RC)
585 | 0.5|6.10|11.15|16.20|21.25| 26..30 |31|
586 | -- | -- | --- | --- | --- | ------- |--|
587 | NN | RS | RA | deg | RC | 00 011 |Rc|
588 | NN | RS | RA | RB | RC | 11 011 |Rc|
590 where the SimpleV variant may override RS-as-src differently from RS-as-dest
595 from functools import reduce
597 # constants used in the multGF2 function
598 mask1 = mask2 = polyred = None
600 def setGF2(degree, irPoly):
601 """Define parameters of binary finite field GF(2^m)/g(x)
602 - degree: extension degree of binary field
603 - irPoly: coefficients of irreducible polynomial g(x)
606 """Convert an integer into a polynomial"""
607 return [(sInt >> i) & 1
608 for i in reversed(range(sInt.bit_length()))]
610 global mask1, mask2, polyred
611 mask1 = mask2 = 1 << degree
613 polyred = reduce(lambda x, y: (x << 1) + y, i2P(irPoly)[1:])
616 """Multiply two polynomials in GF(2^m)/g(x)"""
627 if __name__ == "__main__":
629 # Define binary field GF(2^3)/x^3 + x + 1
632 # Evaluate the product (x^2 + x + 1)(x^2 + 1)
633 print("{:02x}".format(multGF2(0b111, 0b101)))
635 # Define binary field GF(2^8)/x^8 + x^4 + x^3 + x + 1
636 # (used in the Advanced Encryption Standard-AES)
637 setGF2(8, 0b100011011)
639 # Evaluate the product (x^7)(x^7 + x + 1)
640 print("{:02x}".format(multGF2(0b10000000, 0b10000011)))
644 RS = GFADDI(RS, RA|0, gfdegree, modulo=RC)
645 RS = GFADD(RS, RA|0, gfdegree=RB, modulo=RC)
647 | 0.5|6.10|11.15|16.20|21.25| 26..30 |31| name |
648 | -- | -- | --- | --- | --- | ------- |--| ----- |
649 | NN | RS | RA | deg | RC | 0 1 011 |Rc| gfaddi |
650 | NN | RS | RA | RB | RC | 1 1 111 |Rc| gfadd |
652 GFMOD is a pseudo-op where RA=0
665 def gf_invert(a, mod=0x1B) :
680 a %= 256 # Emulating 8-bit overflow
681 g1 %= 256 # Emulating 8-bit overflow
683 j = gf_degree(a) - gf_degree(v)
691 uint64_t bmatflip(uint64_t RA)
699 uint64_t bmatxor(uint64_t RA, uint64_t RB)
702 uint64_t RBt = bmatflip(RB);
703 uint8_t u[8]; // rows of RA
704 uint8_t v[8]; // cols of RB
705 for (int i = 0; i < 8; i++) {
710 for (int i = 0; i < 64; i++) {
711 if (pcnt(u[i / 8] & v[i % 8]) & 1)
716 uint64_t bmator(uint64_t RA, uint64_t RB)
719 uint64_t RBt = bmatflip(RB);
720 uint8_t u[8]; // rows of RA
721 uint8_t v[8]; // cols of RB
722 for (int i = 0; i < 8; i++) {
727 for (int i = 0; i < 64; i++) {
728 if ((u[i / 8] & v[i % 8]) != 0)