aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/vclmul_vv.h
blob: 8957738adc09df7ca96790f84531245fedda7490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// vclmul.vv vd, vs2, vs1, vm

#include "zvk_ext_macros.h"

require_zvbc;
require(P.VU.vsew == 64);

VI_VV_ULOOP
({
  // Perform a carryless multiplication 64bx64b on each 64b element,
  // return the low 64b of the 128b product.
  //   <https://en.wikipedia.org/wiki/Carry-less_product>
  vd = 0;
  for (std::size_t bit_idx = 0; bit_idx < sew; ++bit_idx) {
    const reg_t mask = ((reg_t) 1) << bit_idx;
    if ((vs1 & mask) != 0) {
      vd ^= vs2 << bit_idx;
    }
  }
})