From: Richard Henderson <rth@twiddle.net>
To: Aurelien Jarno <aurelien@aurel32.net>
Cc: qemu-devel@nongnu.org, proljc@gmail.com
Subject: Re: [Qemu-devel] [PATCH v2] target-mips: Implement Loongson Multimedia Instructions
Date: Mon, 17 Sep 2012 11:54:59 -0700 [thread overview]
Message-ID: <50577203.2070300@twiddle.net> (raw)
In-Reply-To: <20120908003216.GL6791@ohm.aurel32.net>
On 09/07/2012 05:32 PM, Aurelien Jarno wrote:
>> + do_shift:
>> + switch (opc) {
>> + case OPC_SLL_CP2:
>> + case OPC_DSLL_CP2:
>> + tcg_gen_shl_i64(t0, t0, t1);
>> + break;
>> + case OPC_SRA_CP2:
>> + case OPC_DSRA_CP2:
>> + /* Since SRA is UndefinedResult without sign-extended inputs,
>> + we can treat SRA and DSRA the same. */
>> + tcg_gen_sar_i64(t0, t0, t1);
>> + break;
>> + case OPC_SRL_CP2:
>> + /* We want to shift in zeros for SRL; zero-extend first. */
>> + tcg_gen_ext32u_i64(t0, t0);
>> + /* FALLTHRU */
>> + case OPC_DSRL_CP2:
>> + tcg_gen_shr_i64(t0, t0, t1);
>> + break;
>> + }
>
> You probably want to and t1 with 0x3f, to make sure to not have a shift
> larger then 64.
Done. Though as discussed elsewhere today I think we ought to make this
merely undefined results as opposed to undefined behaviour in TCG.
>> + /* Shifts larger than MAX produce zero. */
>> + tcg_gen_setcondi_i64(TCG_COND_LTU, t1, t1, shift_max);
>> + tcg_gen_neg_i64(t1, t1);
>
> I guess you want tcg_gen_subi_i64(t1, t1, 1);
No. You're confusing the computations of
(x >= 32) - 1
and
-(x < 32)
Logically the same results but the computation is different.
And the later will of course be smaller on i386 due to neg insn.
>> + case OPC_ADD_CP2:
>> + case OPC_DADD_CP2:
>> + {
>> + /* Since ADD is UndefinedResult without sign-extended inputs,
>> + we can treat both ADD and DADD the same. */
>
> I don't think this is correct. For ADD, the result has to be signed
> extended. Also the exception condition is not the same for ADD and DADD.
Fixed the sign extension here and SUB.
The exception condition *is* the same, after the sign extension is done.
Please go back and compare the code in the existing ADD/DADD expansion.
r~
next prev parent reply other threads:[~2012-09-17 18:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-30 17:13 [Qemu-devel] [PATCH v2] target-mips: Implement Loongson Multimedia Instructions Richard Henderson
2012-09-08 0:32 ` Aurelien Jarno
2012-09-17 18:54 ` Richard Henderson [this message]
2012-09-17 19:03 ` 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=50577203.2070300@twiddle.net \
--to=rth@twiddle.net \
--cc=aurelien@aurel32.net \
--cc=proljc@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).