mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-30 05:21:55 -06:00
plugins: optimize cpu_index code generation
When running with a single vcpu, we can return a constant instead of a load when accessing cpu_index. A side effect is that all tcg operations using it are optimized, most notably scoreboard access. When running a simple loop in user-mode, the speedup is around 20%. Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20241128213843.1023080-1-pierrick.bouvier@linaro.org>
This commit is contained in:
parent
0ccbac336b
commit
dbf408b667
1 changed files with 9 additions and 0 deletions
|
@ -102,6 +102,15 @@ static void gen_disable_mem_helper(void)
|
||||||
|
|
||||||
static TCGv_i32 gen_cpu_index(void)
|
static TCGv_i32 gen_cpu_index(void)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Optimize when we run with a single vcpu. All values using cpu_index,
|
||||||
|
* including scoreboard index, will be optimized out.
|
||||||
|
* User-mode calls tb_flush when setting this flag. In system-mode, all
|
||||||
|
* vcpus are created before generating code.
|
||||||
|
*/
|
||||||
|
if (!tcg_cflags_has(current_cpu, CF_PARALLEL)) {
|
||||||
|
return tcg_constant_i32(current_cpu->cpu_index);
|
||||||
|
}
|
||||||
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
|
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
|
||||||
tcg_gen_ld_i32(cpu_index, tcg_env,
|
tcg_gen_ld_i32(cpu_index, tcg_env,
|
||||||
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
|
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue