From: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
To: Richard Henderson <rth@twiddle.net>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH v2 4/4] target-tricore: Add instructions of RCR opcode format
Date: Wed, 19 Nov 2014 13:35:47 +0000 [thread overview]
Message-ID: <546C9CB3.4030509@mail.uni-paderborn.de> (raw)
In-Reply-To: <54660622.1020106@twiddle.net>
On 11/14/2014 01:39 PM, Richard Henderson wrote:
> On 11/13/2014 06:12 PM, Bastian Koppelmann wrote:
>> + tcg_gen_ext_i32_i64(t3, r3);
>> + tcg_gen_concat_i32_i64(t2, r2_low, r2_high);
>> + /* extend the sign for r2 to high 64 bits */
>> + tcg_gen_sari_i64(t4, t2, 63);
>> + tcg_gen_ext_i32_i64(t1, r1);
>> +
>> + tcg_gen_muls2_i64(t1, t3, t1, t3);
>> + tcg_gen_add2_i64(t1, t3, t2, t4, t1, t3);
>> +
> I don't believe that you need 128 bit arithemetic for multiply-accumulate,
> either here or elsewhere (e.g. msub).
>
> Looking at unsigned, the maximum result of the multiply is 2*(2^n-1), or 2^(2n)
> - 2^(n+1). Which means that the accumulate with a 2^n-1 value cannot overflow
> a double-word intermediate result.
Madd.u has the following signature 64 + (32 * 32) --> 64, as far as I
read the documentation, and would result as you described in a max
result of 2^(2n) - 2^(n+1) for the multiplication, but it would
accumulate with 2^(2n) -1, which can definitly overflow, with n = 32.
However for signed multiply accumulate I don't need 128 bit arithmetic,
because only the add/sub operation of those two can overflow. Thanks for
the tip!
Cheers,
Bastian
next prev parent reply other threads:[~2014-11-19 12:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-13 17:12 [Qemu-devel] [PATCH v2 0/4] Add TriCore RCPW, RCRR, RCRW, RLC and RCR instructions Bastian Koppelmann
2014-11-13 17:12 ` [Qemu-devel] [PATCH v2 1/4] target-tricore: Make TRICORE_FEATURES implying others Bastian Koppelmann
2014-11-13 17:12 ` [Qemu-devel] [PATCH v2 2/4] target-tricore: Add instructions of RCPW, RCRR and RCRW opcode format Bastian Koppelmann
2014-11-13 17:12 ` [Qemu-devel] [PATCH v2 3/4] target-tricore: Add instructions of RLC " Bastian Koppelmann
2014-11-13 17:12 ` [Qemu-devel] [PATCH v2 4/4] target-tricore: Add instructions of RCR " Bastian Koppelmann
2014-11-14 13:39 ` Richard Henderson
2014-11-19 13:35 ` Bastian Koppelmann [this message]
2014-11-14 13:41 ` [Qemu-devel] [PATCH v2 0/4] Add TriCore RCPW, RCRR, RCRW, RLC and RCR instructions Richard Henderson
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=546C9CB3.4030509@mail.uni-paderborn.de \
--to=kbastian@mail.uni-paderborn.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).