提交 5959e257 编写于 作者: W Will Deacon 提交者: Catalin Marinas

arm64: fpsimd: avoid restoring fpcr if the contents haven't changed

Writing to the FPCR is commonly implemented as a self-synchronising
operation in the CPU, so avoid writing to the register when the saved
value matches that in the hardware already.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: NWill Deacon <will.deacon@arm.com>
Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
上级 ad789ba5
...@@ -40,6 +40,19 @@ ...@@ -40,6 +40,19 @@
str w\tmpnr, [\state, #16 * 2 + 4] str w\tmpnr, [\state, #16 * 2 + 4]
.endm .endm
.macro fpsimd_restore_fpcr state, tmp
/*
* Writes to fpcr may be self-synchronising, so avoid restoring
* the register if it hasn't changed.
*/
mrs \tmp, fpcr
cmp \tmp, \state
b.eq 9999f
msr fpcr, \state
9999:
.endm
/* Clobbers \state */
.macro fpsimd_restore state, tmpnr .macro fpsimd_restore state, tmpnr
ldp q0, q1, [\state, #16 * 0] ldp q0, q1, [\state, #16 * 0]
ldp q2, q3, [\state, #16 * 2] ldp q2, q3, [\state, #16 * 2]
...@@ -60,7 +73,7 @@ ...@@ -60,7 +73,7 @@
ldr w\tmpnr, [\state, #16 * 2] ldr w\tmpnr, [\state, #16 * 2]
msr fpsr, x\tmpnr msr fpsr, x\tmpnr
ldr w\tmpnr, [\state, #16 * 2 + 4] ldr w\tmpnr, [\state, #16 * 2 + 4]
msr fpcr, x\tmpnr fpsimd_restore_fpcr x\tmpnr, \state
.endm .endm
.altmacro .altmacro
...@@ -84,7 +97,7 @@ ...@@ -84,7 +97,7 @@
.macro fpsimd_restore_partial state, tmpnr1, tmpnr2 .macro fpsimd_restore_partial state, tmpnr1, tmpnr2
ldp w\tmpnr1, w\tmpnr2, [\state] ldp w\tmpnr1, w\tmpnr2, [\state]
msr fpsr, x\tmpnr1 msr fpsr, x\tmpnr1
msr fpcr, x\tmpnr2 fpsimd_restore_fpcr x\tmpnr2, x\tmpnr1
adr x\tmpnr1, 0f adr x\tmpnr1, 0f
ldr w\tmpnr2, [\state, #8] ldr w\tmpnr2, [\state, #8]
add \state, \state, x\tmpnr2, lsl #4 add \state, \state, x\tmpnr2, lsl #4
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册