target/riscv: Add a property to set vl to ceil(AVL/2)
PATCH 1/1 target/riscv: Add a property to set vl to ceil(AVL/2)
RVV spec allows implementations to set vl with values within [ceil(AVL/2),VLMAX] when VLMAX < AVL < 2*VLMAX. This commit adds a property "rvv_vl_half_avl" to enable setting vl = ceil(AVL/2). This behavior helps identify compiler issues and bugs.
--- target/riscv/cpu.c | 1 + target/riscv/cpu_cfg.h | 1 + target/riscv/vector_helper.c | 2 ++ 3 files changed, 4 insertions(+)
target/riscv/cpu.c +1 -0
@@ -2687,6 +2687,7 @@ static Property riscv_cpu_properties[] = {DEFINE_PROP_BOOL ("rvv_ta_all_1s" ,RISCVCPU , cfg.rvv_ta_all_1s, false),DEFINE_PROP_BOOL ("rvv_ma_all_1s" ,RISCVCPU , cfg.rvv_ma_all_1s, false), + DEFINE_PROP_BOOL("rvv_vl_half_avl", RISCVCPU, cfg.rvv_vl_half_avl, false),/* * write_misa() is marked as experimental for now so mark
target/riscv/cpu_cfg.h +1 -0
@@ -127,6 +127,7 @@ struct RISCVCPUConfig {bool ext_smepmp;bool rvv_ta_all_1s;bool rvv_ma_all_1s; +bool rvv_vl_half_avl;uint32_t mvendorid;uint64_t marchid;
target/riscv/vector_helper.c +2 -0
@@ -75,6 +75,8 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, vlmax =vext_get_vlmax (cpu->cfg.vlenb, vsew, lmul);if (s1 <= vlmax) { vl = s1; + }else if (s1 <2 * vlmax && cpu->cfg.rvv_vl_half_avl) { + vl = (s1 +1 ) >>1 ; }else { vl = vlmax; }
Signature · 1 line
2.43.2
Jason Chien <[email protected]> 於 2024年7月23日 週二 上午1:51寫道:
Quoted 54 lines
RVV spec allows implementations to set vl with values within [ceil(AVL/2),VLMAX] when VLMAX < AVL < 2*VLMAX. This commit adds a property "
rvv_vl_half_avl" to enable setting vl = ceil(AVL/2). This behavior helps identify compiler issues and bugs.Signed-off-by Jason Chien <[email protected]>--- target/riscv/cpu.c | 1 + target/riscv/cpu_cfg.h | 1 + target/riscv/vector_helper.c | 2 ++ 3 files changed, 4 insertions(+)target/riscv/cpu.c +1
-0@@ -2687,6 +2687,7 @@ static Property riscv_cpu_properties[] = {DEFINE_PROP_BOOL ("rvv_ta_all_1s" ,RISCVCPU , cfg.rvv_ta_all_1s, false),DEFINE_PROP_BOOL ("rvv_ma_all_1s" ,RISCVCPU , cfg.rvv_ma_all_1s, false), + DEFINE_PROP_BOOL("rvv_vl_half_avl", RISCVCPU, cfg.rvv_vl_half_avl, false),/* * write_misa() is marked as experimental for now so mark target/riscv/cpu_cfg.h +1
-0@@ -127,6 +127,7 @@ struct RISCVCPUConfig {bool ext_smepmp;bool rvv_ta_all_1s;bool rvv_ma_all_1s; +bool rvv_vl_half_avl;uint32_t mvendorid;uint64_t marchid;target/riscv/vector_helper.c +2
-1@@ -75,6 +75,8 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, vlmax =vext_get_vlmax (cpu->cfg.vlenb, vsew, lmul);if (s1 <= vlmax) { vl = s1; + }else if (s1 <2 * vlmax && cpu->cfg.rvv_vl_half_avl) { + vl = (s1 +1 ) >>1 ; }else { vl = vlmax; } --2.43.2
ping
Jason Chien <[email protected]> 於 2024年7月23日 週二 上午1:50寫道:
Quoted 55 lines
RVV spec allows implementations to set vl with values within [ceil(AVL/2),VLMAX] when VLMAX < AVL < 2*VLMAX. This commit adds a property "
rvv_vl_half_avl" to enable setting vl = ceil(AVL/2). This behavior helps identify compiler issues and bugs.Signed-off-by Jason Chien <[email protected]>--- target/riscv/cpu.c | 1 + target/riscv/cpu_cfg.h | 1 + target/riscv/vector_helper.c | 2 ++ 3 files changed, 4 insertions(+)target/riscv/cpu.c +1
-0@@ -2687,6 +2687,7 @@ static Property riscv_cpu_properties[] = {DEFINE_PROP_BOOL ("rvv_ta_all_1s" ,RISCVCPU , cfg.rvv_ta_all_1s, false),DEFINE_PROP_BOOL ("rvv_ma_all_1s" ,RISCVCPU , cfg.rvv_ma_all_1s, false), +DEFINE_PROP_BOOL ("rvv_vl_half_avl" ,RISCVCPU , cfg.rvv_vl_half_avl, false),/* *
write_misa()is marked as experimental for now so marktarget/riscv/cpu_cfg.h +1
-0@@ -127,6 +127,7 @@ struct RISCVCPUConfig {bool ext_smepmp;bool rvv_ta_all_1s;bool rvv_ma_all_1s; +bool rvv_vl_half_avl;uint32_t mvendorid;uint64_t marchid;target/riscv/vector_helper.c +2
-0@@ -75,6 +75,8 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env,target_ulong s1, vlmax =vext_get_vlmax (cpu->cfg.vlenb, vsew, lmul);if (s1 <= vlmax) { vl = s1; + }else if (s1 <2 * vlmax && cpu->cfg.rvv_vl_half_avl) { + vl = (s1 +1 ) >>1 ; }else { vl = vlmax;}--
2.43.2
Alistair Francis
AppliedQuoted 7 lines · Jason Chien
RVV spec allows implementations to set vl with values within [ceil(AVL/2),VLMAX] when VLMAX < AVL < 2*VLMAX. This commit adds a property "
rvv_vl_half_avl" to enable setting vl = ceil(AVL/2). This behavior helps identify compiler issues and bugs.Signed-off-by Jason Chien <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 47 lines
--- target/riscv/cpu.c | 1 + target/riscv/cpu_cfg.h | 1 + target/riscv/vector_helper.c | 2 ++ 3 files changed, 4 insertions(+)target/riscv/cpu.c +1
-0@@ -2687,6 +2687,7 @@ static Property riscv_cpu_properties[] = {DEFINE_PROP_BOOL ("rvv_ta_all_1s" ,RISCVCPU , cfg.rvv_ta_all_1s, false),DEFINE_PROP_BOOL ("rvv_ma_all_1s" ,RISCVCPU , cfg.rvv_ma_all_1s, false), + DEFINE_PROP_BOOL("rvv_vl_half_avl", RISCVCPU, cfg.rvv_vl_half_avl, false),/* * write_misa() is marked as experimental for now so mark target/riscv/cpu_cfg.h +1
-0@@ -127,6 +127,7 @@ struct RISCVCPUConfig {bool ext_smepmp;bool rvv_ta_all_1s;bool rvv_ma_all_1s; +bool rvv_vl_half_avl;uint32_t mvendorid;uint64_t marchid;target/riscv/vector_helper.c +2
-1@@ -75,6 +75,8 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, vlmax =vext_get_vlmax (cpu->cfg.vlenb, vsew, lmul);if (s1 <= vlmax) { vl = s1; + }else if (s1 <2 * vlmax && cpu->cfg.rvv_vl_half_avl) { + vl = (s1 +1 ) >>1 ; }else { vl = vlmax; } --2.43.2