From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Richard Henderson <richard.henderson@linaro.org>,
"Janeczek, Craig" <jancraig@amazon.com>
Cc: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>,
Stefan Markovic <smarkovic@wavecomp.com>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
Aleksandar Markovic <aleksandar.m.mail@gmail.com>,
Aleksandar Markovic <amarkovic@wavecomp.com>
Subject: Re: [Qemu-devel] [PATCH 5/6] target/mips: MXU: Add handlers for max/min instructions
Date: Mon, 15 Mar 2021 22:26:01 +0100 [thread overview]
Message-ID: <CAAdtpL7_m3t1dPz3DVoj612VdShuL71GPuERvz+4R9HYNUQvuQ@mail.gmail.com> (raw)
In-Reply-To: <eface3ff-cafd-da6f-3f6d-30496f168cd9@linaro.org>
On Tue, Dec 25, 2018 at 8:35 PM Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Sorry I missed the original post, but:
>
> > + } else if (unlikely((XRb == 0) && (XRc == 0))) {
> > + /* both operands zero registers -> just set destination to zero */
> > + tcg_gen_movi_i32(mxu_gpr[XRa - 1], 0);
> > + } else if (unlikely((XRb == 0) || (XRc == 0))) {
> > + /* exactly one operand is zero register - find which one is not...*/
> > + uint32_t XRx = XRb ? XRb : XRc;
> > + /* ...and do max/min operation with one operand 0 */
> > + if (opc == OPC_MXU_S32MAX) {
> > + tcg_gen_smax_i32(mxu_gpr[XRa - 1], mxu_gpr[XRx - 1], 0);
> > + } else {
> > + tcg_gen_smin_i32(mxu_gpr[XRa - 1], mxu_gpr[XRx - 1], 0);
> > + }
> > + } else if (unlikely(XRb == XRc)) {
> > + /* both operands same -> just set destination to one of them */
> > + tcg_gen_mov_i32(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1]);
>
> You should not special case unlikely events, especially when ...
>
> > + } else {
> > + /* the most general case */
> > + if (opc == OPC_MXU_S32MAX) {
> > + tcg_gen_smax_i32(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1],
> > + mxu_gpr[XRc - 1]);
> > + } else {
> > + tcg_gen_smin_i32(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1],
> > + mxu_gpr[XRc - 1]);
> > + }
>
> ... the normal case will handle those special cases just fine.
Also because we have now 3 Coverity CID:
*** CID 1450831: (OVERRUN)
in gen_mxu_D16MAX_D16MIN()
1107 TCGv_i32 t0 = tcg_temp_new();
1108 TCGv_i32 t1 = tcg_const_i32(0);
1109
1110 /* the left half-word first */
1111 tcg_gen_andi_i32(t0, mxu_gpr[XRx - 1], 0xFFFF0000);
1112 if (opc == OPC_MXU_D16MAX) {
>>> CID 1450831: (OVERRUN)
>>> Overrunning array "mxu_gpr" of 15 8-byte elements at element index 4294967295 (byte offset 34359738367) using index "XRa - 1U" (which evaluates to 4294967295).
1113 tcg_gen_smax_i32(mxu_gpr[XRa - 1], t0, t1);
>>> CID 1450831: (OVERRUN)
>>> Overrunning array "mxu_gpr" of 15 8-byte elements at element index 4294967295 (byte offset 34359738367) using index "XRa - 1U" (which evaluates to 4294967295).
1114 } else {
1115 tcg_gen_smin_i32(mxu_gpr[XRa - 1], t0, t1);
1116 }
1117
1118 /* the right half-word */
1119 tcg_gen_andi_i32(t0, mxu_gpr[XRx - 1], 0x0000FFFF);
1125 } else {
1126 tcg_gen_smin_i32(t0, t0, t1);
1127 }
1128 /* return resulting half-words to its original position */
1129 tcg_gen_shri_i32(t0, t0, 16);
1130 /* finally update the destination */
>>> CID 1450831: (OVERRUN)
>>> Overrunning array "mxu_gpr" of 15 8-byte elements at element index 4294967295 (byte offset 34359738367) using index "XRa - 1U" (which evaluates to 4294967295).
1131 tcg_gen_or_i32(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t0);
1132
1133 tcg_temp_free(t1);
1134 tcg_temp_free(t0);
1135 } else if (unlikely(XRb == XRc)) {
1136 /* both operands same -> just set destination to one of them */
next prev parent reply other threads:[~2021-03-15 21:27 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-17 20:04 [Qemu-devel] [PATCH 0/6] target/mips: Amend MXU support Aleksandar Markovic
2018-12-17 20:04 ` [Qemu-devel] [PATCH 1/6] target/mips: MXU: Add missing opcodes/decoding for LX* instructions Aleksandar Markovic
2018-12-18 14:21 ` Stefan Markovic
2018-12-27 17:15 ` Janeczek, Craig
2018-12-27 18:44 ` Aleksandar Markovic
2018-12-27 18:50 ` Janeczek, Craig
2018-12-27 19:23 ` Aleksandar Markovic
2018-12-27 19:37 ` Janeczek, Craig
2018-12-27 20:12 ` Aleksandar Markovic
2018-12-17 20:04 ` [Qemu-devel] [PATCH 2/6] target/mips: MXU: Add generic naming for optn2 constants Aleksandar Markovic
2018-12-17 20:04 ` [Qemu-devel] [PATCH 3/6] target/mips: MXU: Improve textual description Aleksandar Markovic
2018-12-18 14:30 ` Stefan Markovic
2018-12-17 20:04 ` [Qemu-devel] [PATCH 4/6] target/mips: MXU: Add handlers for logic instructions Aleksandar Markovic
2018-12-18 14:39 ` Stefan Markovic
2018-12-17 20:04 ` [Qemu-devel] [PATCH 5/6] target/mips: MXU: Add handlers for max/min instructions Aleksandar Markovic
2018-12-18 15:05 ` Stefan Markovic
2018-12-27 17:18 ` Janeczek, Craig
2018-12-27 20:14 ` Aleksandar Markovic
2018-12-23 17:22 ` Aleksandar Markovic
2018-12-25 19:34 ` Richard Henderson
2021-03-15 21:26 ` Philippe Mathieu-Daudé [this message]
2018-12-17 20:04 ` [Qemu-devel] [PATCH 6/6] target/mips: MXU: Add handlers for an align instruction Aleksandar Markovic
2018-12-18 15:19 ` Stefan Markovic
2018-12-27 21:27 ` [Qemu-devel] [PATCH 0/6] target/mips: Amend MXU support Aleksandar Markovic
2018-12-31 14:40 ` Aleksandar Markovic
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=CAAdtpL7_m3t1dPz3DVoj612VdShuL71GPuERvz+4R9HYNUQvuQ@mail.gmail.com \
--to=f4bug@amsat.org \
--cc=aleksandar.m.mail@gmail.com \
--cc=aleksandar.markovic@rt-rk.com \
--cc=amarkovic@wavecomp.com \
--cc=jancraig@amazon.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=smarkovic@wavecomp.com \
/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).