Hi Daniel,

According the v spec section 15.2 & 15.3.

"The vcpop.m instruction writes x[rd] even if vl=0 (with the value 0, since no mask elements are active).   Traps on vcpop.m are always reported with a vstart of 0. The vcpop.m instruction will raise an illegal instruction exception if vstart is non-zero."

"The vfirst.m instruction writes x[rd] even if vl=0 (with the value -1, since no mask elements are active).  Traps on vfirst are always reported with a vstart of 0. The vfirst instruction will raise an illegal instruction exception if vstart is non-zero."

Both the vcpop.m and vfirst.m instructions will raise illegal instruction exception with non-zero vstart.

And currently both the trans_vcpop_m and trans_vfirst_m translate functions check the vstart_eq_zero flag. So I think the early exit checking in the vcpop.m and vfirstm helper functions may be redundant.

@@ -4585,6 +4641,11 @@ target_ulong HELPER(vcpop_m)(void *v0, void *vs2, 
CPURISCVState *env,
      uint32_t vl = env->vl;
      int i;
+ if (env->vstart >= env->vl) {
+        env->vstart = 0;
+        return 0;
+    }
+
      for (i = env->vstart; i < vl; i++) {
          if (vm || vext_elem_mask(v0, i)) {
              if (vext_elem_mask(vs2, i)) {

According v spec section 15.3

""The vfirst.m instruction writes x[rd] even if vl=0 (with the value -1, since no mask elements are active)."

If both the vstart and vl are 0 here, the early exit checking will return the wrong value 0 (the return value should be -1) here.

@@ -4604,6 +4665,11 @@ target_ulong HELPER(vfirst_m)(void *v0, void *vs2, 
CPURISCVState *env,
      uint32_t vl = env->vl;
      int i;
+ if (env->vstart >= env->vl) {
+        env->vstart = 0;
+        return 0;
+    }
+
      for (i = env->vstart; i < vl; i++) {
          if (vm || vext_elem_mask(v0, i)) {
              if (vext_elem_mask(vs2, i)) {

Reply via email to