Skip to content

Commit

Permalink
Vector: Remove now unnecessary uses of undefined
Browse files Browse the repository at this point in the history
Sail 0.18 contains the vector_init primitive, to make initialising
vectors with defined values easier. We can use this in some places
where the vector code was creating an uninitalised vector, only to
then initialize it later.

Second, we can remove some uses of undefined by refactoring slightly
how init_masked_result is used, which has the added benefit of making
mask immutable.

Some additional constraints need to be added to use the vector_init
primitive.

Sail's pattern completeness checker is now smarter than before, so
some wildcard cases can also be safely removed.
  • Loading branch information
Alasdair authored Sep 20, 2024
1 parent bdf95b0 commit 6dd6464
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 270 deletions.
4 changes: 3 additions & 1 deletion model/prelude.sail
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ val sub_vec_int = pure {c: "sub_bits_int", _: "sub_vec_int"} : forall 'n. (bits(

overload operator - = {sub_vec, sub_vec_int}

val quot_positive_round_zero = pure {interpreter: "quot_round_zero", lem: "hardware_quot", c: "tdiv_int", coq: "Z.quot"} : forall 'n 'm, 'n >= 0 & 'm > 0. (int('n), int('m)) -> int(div('n, 'm))

val quot_round_zero = pure {interpreter: "quot_round_zero", lem: "hardware_quot", c: "tdiv_int", coq: "Z.quot"} : (int, int) -> int
val rem_round_zero = pure {interpreter: "rem_round_zero", lem: "hardware_mod", c: "tmod_int", coq: "Z.rem"} : (int, int) -> int

Expand Down Expand Up @@ -196,7 +198,7 @@ function reverse_bits_in_byte (xs : bits(8)) -> bits(8) = {

overload reverse = {reverse_bits_in_byte}

overload operator / = {quot_round_zero}
overload operator / = {quot_positive_round_zero, quot_round_zero}
overload operator * = {mult_atom, mult_int}

/* helper for vector extension
Expand Down
152 changes: 61 additions & 91 deletions model/riscv_insts_vext_arith.sail

Large diffs are not rendered by default.

82 changes: 33 additions & 49 deletions model/riscv_insts_vext_fp.sail
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ function clause execute(FVVTYPE(funct6, vm, vs2, vs1, vd)) = {
let vs1_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, dec, bits('m)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -121,10 +120,9 @@ function clause execute(FVVMATYPE(funct6, vm, vs2, vs1, vd)) = {
let vs1_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, dec, bits('m)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -194,10 +192,9 @@ function clause execute(FWVVTYPE(funct6, vm, vs2, vs1, vd)) = {
let vd_val : vector('n, dec, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let vs1_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
var result : vector('n, dec, bits('o)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -259,10 +256,9 @@ function clause execute(FWVVMATYPE(funct6, vm, vs1, vs2, vd)) = {
let vd_val : vector('n, dec, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let vs1_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
var result : vector('n, dec, bits('o)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -322,10 +318,9 @@ function clause execute(FWVTYPE(funct6, vm, vs2, vs1, vd)) = {
let vd_val : vector('n, dec, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let vs1_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1);
let vs2_val : vector('n, dec, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vs2);
var result : vector('n, dec, bits('o)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -379,10 +374,9 @@ function clause execute(VFUNARY0(vm, vs2, vfunary0, vd)) = {
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, dec, bits('m)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -498,10 +492,9 @@ function clause execute(VFWUNARY0(vm, vs2, vfwunary0, vd)) = {
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, dec, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
var result : vector('n, dec, bits('o)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -628,10 +621,9 @@ function clause execute(VFNUNARY0(vm, vs2, vfnunary0, vd)) = {
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, dec, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vs2);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, dec, bits('m)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -759,10 +751,9 @@ function clause execute(VFUNARY1(vm, vs2, vfunary1, vd)) = {
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, dec, bits('m)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -884,10 +875,9 @@ function clause execute(FVFTYPE(funct6, vm, vs2, rs1, vd)) = {
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, dec, bits('m)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -974,10 +964,9 @@ function clause execute(FVFMATYPE(funct6, vm, vs2, rs1, vd)) = {
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, dec, bits('m)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -1046,10 +1035,9 @@ function clause execute(FWVFTYPE(funct6, vm, vs2, rs1, vd)) = {
let vd_val : vector('n, dec, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
var result : vector('n, dec, bits('o)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -1110,10 +1098,9 @@ function clause execute(FWVFMATYPE(funct6, vm, rs1, vs2, vd)) = {
let vd_val : vector('n, dec, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
var result : vector('n, dec, bits('o)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -1172,10 +1159,9 @@ function clause execute(FWFTYPE(funct6, vm, vs2, rs1, vd)) = {
let vd_val : vector('n, dec, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vd);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, dec, bits('o)) = read_vreg(num_elem, SEW_widen, LMUL_pow_widen, vs2);
var result : vector('n, dec, bits('o)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW_widen, LMUL_pow_widen, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -1225,7 +1211,7 @@ function clause execute(VFMERGE(vs2, rs1, vd)) = {
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, dec, bits('m)) = undefined;
var result : vector('n, dec, bits('m)) = vector_init(zeros());

let tail_ag : agtype = get_vtype_vta();
foreach (i from 0 to (num_elem - 1)) {
Expand Down Expand Up @@ -1272,10 +1258,9 @@ function clause execute(VFMV(rs1, vd)) = {
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, 0b1, 0b00000);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, dec, bits('m)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then result[i] = rs1_val
Expand Down Expand Up @@ -1309,10 +1294,9 @@ function clause execute(VFMVSF(rs1, vd)) = {
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, 0b1, 0b00000);
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, 0, vd);
var result : vector('n, dec, bits('m)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW, 0, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW, 0, vd_val, vm_val);
var result = initial_result;

/* one body element */
if mask[0] then result[0] = rs1_val;
Expand Down
10 changes: 4 additions & 6 deletions model/riscv_insts_vext_fp_vm.sail
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ function clause execute(FVVMTYPE(funct6, vm, vs2, vs1, vd)) = {
let vs1_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs1);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vd);
var result : vector('n, dec, bool) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result_cmp(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result_cmp(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -105,10 +104,9 @@ function clause execute(FVFMTYPE(funct6, vm, vs2, rs1, vd)) = {
let rs1_val : bits('m) = get_scalar_fp(rs1, 'm);
let vs2_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vs2);
let vd_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vd);
var result : vector('n, dec, bool) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result_cmp(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result_cmp(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down
40 changes: 16 additions & 24 deletions model/riscv_insts_vext_mask.sail
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ function clause execute(MMTYPE(funct6, vs2, vs1, vd)) = {
let vs1_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vs1);
let vs2_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vs2);
let vd_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vd);
var result : vector('n, dec, bool) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result_carry(num_elem, SEW, 0, vd_val);
let (initial_result, mask) = init_masked_result_carry(num_elem, SEW, 0, vd_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then {
Expand Down Expand Up @@ -98,10 +97,9 @@ function clause execute(VCPOP_M(vm, vs2, rd)) = {

let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vs2);
var result : vector('n, dec, bool) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result_cmp(num_elem, SEW, 0, vs2_val, vm_val);
let (initial_result, mask) = init_masked_result_cmp(num_elem, SEW, 0, vs2_val, vm_val);
var result = initial_result;

var count : nat = 0;
foreach (i from 0 to (num_elem - 1)) {
Expand Down Expand Up @@ -134,10 +132,9 @@ function clause execute(VFIRST_M(vm, vs2, rd)) = {

let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vs2);
var result : vector('n, dec, bool) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result_cmp(num_elem, SEW, 0, vs2_val, vm_val);
let (initial_result, mask) = init_masked_result_cmp(num_elem, SEW, 0, vs2_val, vm_val);
var result = initial_result;

var index : int = -1;
foreach (i from 0 to (num_elem - 1)) {
Expand Down Expand Up @@ -174,10 +171,9 @@ function clause execute(VMSBF_M(vm, vs2, vd)) = {
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vs2);
let vd_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vd);
var result : vector('n, dec, bool) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result_cmp(num_elem, SEW, 0, vd_val, vm_val);
let (initial_result, mask) = init_masked_result_cmp(num_elem, SEW, 0, vd_val, vm_val);
var result = initial_result;

var found_elem : bool = false;
foreach (i from 0 to (num_elem - 1)) {
Expand Down Expand Up @@ -215,10 +211,9 @@ function clause execute(VMSIF_M(vm, vs2, vd)) = {
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vs2);
let vd_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vd);
var result : vector('n, dec, bool) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result_cmp(num_elem, SEW, 0, vd_val, vm_val);
let (initial_result, mask) = init_masked_result_cmp(num_elem, SEW, 0, vd_val, vm_val);
var result = initial_result;

var found_elem : bool = false;
foreach (i from 0 to (num_elem - 1)) {
Expand Down Expand Up @@ -256,10 +251,9 @@ function clause execute(VMSOF_M(vm, vs2, vd)) = {
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vs2);
let vd_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vd);
var result : vector('n, dec, bool) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result_cmp(num_elem, SEW, 0, vd_val, vm_val);
let (initial_result, mask) = init_masked_result_cmp(num_elem, SEW, 0, vd_val, vm_val);
var result = initial_result;

var found_elem : bool = false;
foreach (i from 0 to (num_elem - 1)) {
Expand Down Expand Up @@ -301,10 +295,9 @@ function clause execute(VIOTA_M(vm, vs2, vd)) = {
let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vs2_val : vector('n, dec, bool) = read_vmask(num_elem, 0b0, vs2);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, dec, bits('m)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

var sum : int = 0;
foreach (i from 0 to (num_elem - 1)) {
Expand Down Expand Up @@ -340,10 +333,9 @@ function clause execute(VID_V(vm, vd)) = {

let vm_val : vector('n, dec, bool) = read_vmask(num_elem, vm, 0b00000);
let vd_val : vector('n, dec, bits('m)) = read_vreg(num_elem, SEW, LMUL_pow, vd);
var result : vector('n, dec, bits('m)) = undefined;
var mask : vector('n, dec, bool) = undefined;

(result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
let (initial_result, mask) = init_masked_result(num_elem, SEW, LMUL_pow, vd_val, vm_val);
var result = initial_result;

foreach (i from 0 to (num_elem - 1)) {
if mask[i] then result[i] = to_bits(SEW, i)
Expand Down
Loading

0 comments on commit 6dd6464

Please sign in to comment.