From: Richard Henderson <rth@twiddle.net>
To: Laurent Desnogues <laurent.desnogues@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Re: [PATCH 3/6] tcg-x86_64: Implement setcond and movcond.
Date: Fri, 18 Dec 2009 09:11:31 -0800 [thread overview]
Message-ID: <4B2BB7C3.2040203@twiddle.net> (raw)
In-Reply-To: <761ea48b0912180339k18573822wea90289345c58a84@mail.gmail.com>
On 12/18/2009 03:39 AM, Laurent Desnogues wrote:
>> +static void tcg_out_setcond(TCGContext *s, int cond, TCGArg arg0,
>> + TCGArg arg1, TCGArg arg2, int const_arg2, int rexw)
>
> Perhaps renaming arg0 to dest would make things slightly
> more readable.
Ok.
> Also note that tcg_out_modrm will generate an unneeded prefix
> for some registers. cf. the patch I sent to the list months ago.
Huh. Didn't notice since the disassembler printed what I expected to
see. Is fixing this at the same time a requirement for acceptance?
I'd prefer to tackle that separately, since no doubt it affects every
use of P_REXB.
>> + tgen_arithi32(s, ARITH_AND, arg0, 0xff);
>
> Wouldn't movzbl be better?
Handled inside tgen_arithi32:
} else if (c == ARITH_AND && val == 0xffu) {
/* movzbl */
tcg_out_modrm(s, 0xb6 | P_EXT | P_REXB, r0, r0);
I didn't feel the need to replicate that.
> Regarding the xor optimization, I tested it on my i7 and it was
> (very) slightly slower running a 64-bit SPEC2k gcc.
Huh. It used to be recommended. The partial word store used to stall
the pipeline until the old value was ready, and the XOR was
special-cased as a clear, which broke both the input dependency and also
prevented a partial-register stall on the output.
Actually, this recommendation is still present: Section 3.5.1.6 in the
November 2009 revision of the Intel Optimization Reference Manual.
If it's all the same, I'd prefer to keep what I have there. All other
things being equal, the XOR is 2 bytes and the MOVZBL is 3.
>> +static void tcg_out_movcond(TCGContext *s, int cond, TCGArg arg0,
>> + TCGArg arg1, TCGArg arg2, int const_arg2,
>> + TCGArg arg3, TCGArg arg4, int rexw)
>
> Perhaps renaming arg0 to dest would make things slightly
> more readable.
Ok.
> You should also add a note stating that arg3 != arg4.
I don't believe that's true though. It's caught immediately when we
emit the movcond opcode, but there's no check later once
copy-propagation has been done within TCG.
I check for that in the i386 and sparc backends, because dest==arg3 &&
dest==arg4 would actually generate incorrect code. Here in the x86_64
backend, where we always use cmov it doesn't generate incorrect code,
merely inefficient.
I could add an early out for that case, if you prefer.
>> + { INDEX_op_setcond_i32, { "r", "r", "re" } },
>> + { INDEX_op_setcond_i64, { "r", "r", "re" } },
>> +
>> + { INDEX_op_movcond_i32, { "r", "r", "re", "r", "r" } },
>> + { INDEX_op_movcond_i64, { "r", "r", "re", "r", "r" } },
>
> For the i32 variants, "ri" instead of "re" is enough.
Ah, quite right.
r~
next prev parent reply other threads:[~2009-12-18 17:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <761ea48b0912170620l534dcb02m8ea6b59524d76dbe@mail.gmail.com>
2009-12-17 19:32 ` [Qemu-devel] [PATCH 0/6] tcg conditional set/move, round 2 Richard Henderson
2009-12-17 17:27 ` [Qemu-devel] [PATCH 1/6] tcg: Generic support for conditional set and conditional move Richard Henderson
2009-12-17 20:50 ` malc
2009-12-18 11:38 ` [Qemu-devel] " Laurent Desnogues
2009-12-17 17:28 ` [Qemu-devel] [PATCH 2/6] tcg: Add tcg_invert_cond Richard Henderson
2009-12-18 11:39 ` [Qemu-devel] " Laurent Desnogues
2009-12-17 17:32 ` [Qemu-devel] [PATCH 3/6] tcg-x86_64: Implement setcond and movcond Richard Henderson
2009-12-18 11:39 ` [Qemu-devel] " Laurent Desnogues
2009-12-18 17:11 ` Richard Henderson [this message]
2009-12-18 17:41 ` Laurent Desnogues
2009-12-17 17:55 ` [Qemu-devel] [PATCH 4/6] tcg-i386: Implement small forward branches Richard Henderson
2009-12-18 11:39 ` [Qemu-devel] " Laurent Desnogues
2009-12-18 17:16 ` Richard Henderson
2009-12-17 18:38 ` [Qemu-devel] [PATCH 5/6] tcg-i386: Simplify brcond2 Richard Henderson
2009-12-18 11:40 ` [Qemu-devel] " Laurent Desnogues
2009-12-18 17:45 ` Richard Henderson
2009-12-17 19:08 ` [Qemu-devel] [PATCH 6/6] tcg-i386: Implement setcond, movcond, setcond2 Richard Henderson
2009-12-18 11:37 ` [Qemu-devel] Re: [PATCH 0/6] tcg conditional set/move, round 2 Laurent Desnogues
2009-12-18 21:38 ` [Qemu-devel] tcg conditional set/move, round 3 Richard Henderson
2009-12-19 11:40 ` [Qemu-devel] " Laurent Desnogues
2009-12-19 16:09 ` Richard Henderson
2009-12-19 12:09 ` [Qemu-devel] " Andreas Färber
2009-12-19 13:03 ` Aurelien Jarno
2009-12-19 13:32 ` Aurelien Jarno
2009-12-19 16:19 ` Richard Henderson
2009-12-19 23:02 ` Aurelien Jarno
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=4B2BB7C3.2040203@twiddle.net \
--to=rth@twiddle.net \
--cc=laurent.desnogues@gmail.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).