From: Richard Henderson <richard.henderson@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH 4/4] tcg/optimize: optimize TSTNE using smask and zmask
Date: Thu, 29 Feb 2024 07:17:48 -1000 [thread overview]
Message-ID: <08b4d72a-4a76-4faa-a7fd-a507c1345b6a@linaro.org> (raw)
In-Reply-To: <8c623e70-80ab-4058-b898-8eb38e95f1e3@redhat.com>
On 2/28/24 23:35, Paolo Bonzini wrote:
> On 2/29/24 00:10, Richard Henderson wrote:
>> On 2/28/24 01:11, Paolo Bonzini wrote:
>>> - /* TSTNE x,sign -> LT x,0 */
>>> - if (arg_is_const_val(*p2, (ctx->type == TCG_TYPE_I32
>>> - ? INT32_MIN : INT64_MIN))) {
>>> + /* TSTNE x,i -> LT x,0 if i only includes sign bit copies */
>>> + if (arg_is_const(*p2) && (arg_info(*p2)->val & ~i1->s_mask) == 0) {
>>
>> This is a good idea, but s_mask isn't defined like you think -- it is *repetitions* of
>> the sign bit, but not including the sign bit itself. For INT64_MIN, s_mask == 0.
>>
>> So for TSTNE min,min, (min & ~0) != 0, so the test won't pass.
>
> Oh! So I have to squash:
>
> diff --git a/tcg/optimize.c b/tcg/optimize.c
> index ab976a5bbe7..44d1b1a6d8a 100644
> --- a/tcg/optimize.c
> +++ b/tcg/optimize.c
> @@ -140,6 +140,12 @@ static inline bool arg_is_const_val(TCGArg arg, uint64_t val)
> return ts_is_const_val(arg_temp(arg), val);
> }
>
> +/* Calculate all the copies of the sign bit, both redundant and not. */
> +static inline uint64_t all_sign_bit_copies(TempOptInfo *info)
> +{
> + return (info->s_mask >> 1) | INT64_MIN;
> +}
You need to care about type too -- for TCG_TYPE_I32, you'll want to OR in INT32_MIN. The
high bits of s_mask will be unknown (might be 1's from fold_masks, might be 0 from reset_ts).
But otherwise that's a good solution.
r~
prev parent reply other threads:[~2024-02-29 17:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 11:11 [PATCH 0/4] target/i386: use TSTEQ/TSTNE in x86 frontend Paolo Bonzini
2024-02-28 11:11 ` [PATCH 1/4] target/i386: use TSTEQ/TSTNE to test low bits Paolo Bonzini
2024-02-28 22:28 ` Richard Henderson
2024-02-28 11:11 ` [PATCH 2/4] target/i386: use TSTEQ/TSTNE to check flags Paolo Bonzini
2024-02-28 22:34 ` Richard Henderson
2024-02-28 11:11 ` [PATCH 3/4] target/i386: remove mask from CCPrepare Paolo Bonzini
2024-02-28 22:36 ` Richard Henderson
2024-02-28 11:11 ` [PATCH 4/4] tcg/optimize: optimize TSTNE using smask and zmask Paolo Bonzini
2024-02-28 23:10 ` Richard Henderson
2024-02-29 9:35 ` Paolo Bonzini
2024-02-29 17:17 ` Richard Henderson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08b4d72a-4a76-4faa-a7fd-a507c1345b6a@linaro.org \
--to=richard.henderson@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).