[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/9] tcg: Use extract2 in tcg_gen_deposit_{i32,
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-devel] [PATCH 4/9] tcg: Use extract2 in tcg_gen_deposit_{i32, i64} |
Date: |
Sat, 9 Mar 2019 01:36:45 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 |
On 3/7/19 3:41 PM, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <address@hidden>
> ---
> tcg/tcg-op.c | 28 ++++++++++++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
> index 34e0dbc6e0..caee80235e 100644
> --- a/tcg/tcg-op.c
> +++ b/tcg/tcg-op.c
> @@ -614,6 +614,18 @@ void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1,
> TCGv_i32 arg2,
> mask = (1u << len) - 1;
FWIW you can move 'mask' ...
> t1 = tcg_temp_new_i32();
>
> + if (TCG_TARGET_HAS_extract2_i32) {
> + if (ofs + len == 32) {
> + tcg_gen_shli_i32(t1, arg1, len);
> + tcg_gen_extract2_i32(ret, t1, arg2, len);
> + goto done;
> + }
> + if (ofs == 0) {
> + tcg_gen_extract2_i32(ret, arg1, arg2, len);
> + tcg_gen_rotli_i32(ret, ret, len);
> + goto done;
> + }
> + }
... here, saving few instr if TCG_TARGET_HAS_extract2_i32 ;)
> if (ofs + len < 32) {
> tcg_gen_andi_i32(t1, arg2, mask);
> tcg_gen_shli_i32(t1, t1, ofs);
> @@ -622,7 +634,7 @@ void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1,
> TCGv_i32 arg2,
> }
> tcg_gen_andi_i32(ret, arg1, ~(mask << ofs));
> tcg_gen_or_i32(ret, ret, t1);
> -
> + done:
> tcg_temp_free_i32(t1);
> }
>
> @@ -2027,6 +2039,18 @@ void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1,
> TCGv_i64 arg2,
> mask = (1ull << len) - 1;
> t1 = tcg_temp_new_i64();
>
> + if (TCG_TARGET_HAS_extract2_i64) {
> + if (ofs + len == 64) {
> + tcg_gen_shli_i64(t1, arg1, len);
> + tcg_gen_extract2_i64(ret, t1, arg2, len);
> + goto done;
> + }
> + if (ofs == 0) {
> + tcg_gen_extract2_i64(ret, arg1, arg2, len);
> + tcg_gen_rotli_i64(ret, ret, len);
> + goto done;
> + }
> + }
Ditto.
> if (ofs + len < 64) {
> tcg_gen_andi_i64(t1, arg2, mask);
> tcg_gen_shli_i64(t1, t1, ofs);
> @@ -2035,7 +2059,7 @@ void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1,
> TCGv_i64 arg2,
> }
> tcg_gen_andi_i64(ret, arg1, ~(mask << ofs));
> tcg_gen_or_i64(ret, ret, t1);
> -
> + done:
> tcg_temp_free_i64(t1);
> }
>
>
- [Qemu-devel] [PATCH 0/9] tcg: Add tcg_gen_extract2_{i32,i64}, Richard Henderson, 2019/03/07
- [Qemu-devel] [PATCH 1/9] tcg: Implement tcg_gen_extract2_{i32, i64}, Richard Henderson, 2019/03/07
- [Qemu-devel] [PATCH 3/9] tcg: Use extract2 in tcg_gen_shifti_i64, Richard Henderson, 2019/03/07
- [Qemu-devel] [PATCH 4/9] tcg: Use extract2 in tcg_gen_deposit_{i32, i64}, Richard Henderson, 2019/03/07
- Re: [Qemu-devel] [PATCH 4/9] tcg: Use extract2 in tcg_gen_deposit_{i32, i64},
Philippe Mathieu-Daudé <=
- [Qemu-devel] [PATCH 2/9] tcg: Add INDEX_op_extract2_{i32,i64}, Richard Henderson, 2019/03/07
- [Qemu-devel] [PATCH 5/9] tcg/i386: Support INDEX_op_extract2_{i32, i64}, Richard Henderson, 2019/03/07
- [Qemu-devel] [PATCH 6/9] tcg/arm: Support INDEX_op_extract2_i32, Richard Henderson, 2019/03/07
- [Qemu-devel] [PATCH 7/9] tcg/aarch64: Support INDEX_op_extract2_{i32, i64}, Richard Henderson, 2019/03/07