Skip to content

Commit

Permalink
riscv: Optimize task switch codes of vector
Browse files Browse the repository at this point in the history
This patch replacees 2 instructions with 1 instruction to do the same thing
. rs1=x0 with rd != x0 is a special form of the instruction that sets vl to
MAXVL.

Suggested-by: Andrew Waterman <andrew@sifive.com>
Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
  • Loading branch information
greentime authored and intel-lab-lkp committed Sep 10, 2020
1 parent ffc0423 commit 687d8fe
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions arch/riscv/kernel/vector.S
Expand Up @@ -27,8 +27,7 @@
#define x_vl t2
#define x_vcsr t3
#define incr t4
#define m_one t5
#define status t6
#define status t5

ENTRY(__vstate_save)
li status, SR_VS
Expand All @@ -38,8 +37,7 @@ ENTRY(__vstate_save)
csrr x_vtype, CSR_VTYPE
csrr x_vl, CSR_VL
csrr x_vcsr, CSR_VCSR
li m_one, -1
vsetvli incr, m_one, e8, m8
vsetvli incr, x0, e8, m8
vse8.v v0, (datap)
add datap, datap, incr
vse8.v v8, (datap)
Expand All @@ -61,8 +59,7 @@ ENTRY(__vstate_restore)
li status, SR_VS
csrs CSR_STATUS, status

li m_one, -1
vsetvli incr, m_one, e8, m8
vsetvli incr, x0, e8, m8
vle8.v v0, (datap)
add datap, datap, incr
vle8.v v8, (datap)
Expand Down

0 comments on commit 687d8fe

Please sign in to comment.