|
From: | Richard Henderson |
Subject: | Re: [PATCH v7 09/14] target/riscv: Add orc.b instruction for Zbb, removing gorc/gorci |
Date: | Tue, 31 Aug 2021 09:19:43 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
On 8/30/21 4:15 AM, Philipp Tomsich wrote:
+ TCGv tmp = tcg_temp_new(); + + /* Set msb in each byte if the byte was zero. */ + tcg_gen_subi_tl(tmp, source1, dup_const(MO_8, 0x01)); + tcg_gen_andc_tl(tmp, tmp, source1); + tcg_gen_andi_tl(tmp, tmp, dup_const(MO_8, 0x80)); + + /* Replicate the msb of each byte across the byte. */ + tcg_gen_shri_tl(tmp, tmp, 7); + tcg_gen_muli_tl(tmp, tmp, 0xff); + + /* Negate */ + tcg_gen_not_tl(ret, tmp);
It just occurred to me that we can swap the shift/andi and re-use the same constant, and we can fold in the negate with andc.
TCGv ones = tcg_constant_tl(dup_const(MO_8, 1)); TCGv tmp = tcg_temp_new(); tcg_gen_sub_tl(tmp, src1, ones); tcg_gen_andc_tl(tmp, tmp, src1); tcg_gen_shri_tl(tmp, tmp, 7); tcg_gen_andc_tl(tmp, ones, tmp); tcg_gen_muli_tl(tmp, tmp, 0xff); tcg_temp_free(tmp); r~
[Prev in Thread] | Current Thread | [Next in Thread] |