qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: Laurent Desnogues <laurent.desnogues@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [Qemu-devel] [PATCH 3/5] target-arm: convert shl and shr helpers to TCG
Date: Tue, 18 Sep 2012 23:12:14 +0200	[thread overview]
Message-ID: <20120918211214.GA29439@zapo> (raw)
In-Reply-To: <CABoDooPb+-rzgBvQ0Qc0v6KeTEDy-5NWU6FshCvS3fVByAqPkw@mail.gmail.com>

On Mon, Sep 17, 2012 at 03:36:46PM +0200, Laurent Desnogues wrote:
> On Mon, Sep 17, 2012 at 11:43 AM, Peter Maydell
> <peter.maydell@linaro.org> wrote:
> > On 17 September 2012 10:30, Laurent Desnogues
> > <laurent.desnogues@gmail.com> wrote:
> >> On Mon, Sep 17, 2012 at 1:08 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> >>> +#define GEN_SHIFT(name)                                \
> >>> +static void gen_##name(TCGv dest, TCGv t0, TCGv t1)    \
> >>> +{                                                      \
> >>> +    TCGv tmp1, tmp2;                                   \
> >>> +    tmp1 = tcg_temp_new_i32();                         \
> >>> +    tcg_gen_andi_i32(tmp1, t1, 0xff);                  \
> >>> +    tmp2 = tcg_temp_new_i32();                         \
> >>> +    tcg_gen_setcondi_i32(TCG_COND_GE, tmp2, tmp1, 32); \
> >>> +    tcg_gen_andi_i32(tmp1, tmp1, 0x1f);                \
> >>
> >> I don't think the 'and 0x1f' is needed given that later you'll and
> >> with 0 if the shift amount is >= 32.
> >
> > The TCG shift operations are undefined behaviour (not merely
> > undefined result) if the shift is >= 32, so we must avoid
> > doing that even if we're going to throw away the answer.
> 
> That's odd that it doesn't just state that the result is undefined.
> I wonder what "undefined behavior" means.  I understand
> what undefined behavior (as opposed tu undefined result)
> means for divisions by 0, but not for a shift larger than data
> type width.
> 
> Anyway that makes my comment about removing the & 0x1f
> pointless.

Hi,

I'm a bit late with email but I don't think your comment is
irrelevant. It sounds like if we are optimizing for very odd
or nonexisting archs. Is there any modern arch that has
undefined behaviour (in reality and not only in theoretical
specs) these days?

Cheers,
E

  parent reply	other threads:[~2012-09-18 21:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-16 23:08 [Qemu-devel] [PATCH 0/5] target-arm: misc optimizations Aurelien Jarno
2012-09-16 23:08 ` [Qemu-devel] [PATCH 1/5] target-arm: use globals for CC flags Aurelien Jarno
2012-09-16 23:08 ` [Qemu-devel] [PATCH 2/5] target-arm: convert add_cc and sub_cc helpers to TCG Aurelien Jarno
2012-09-16 23:08 ` [Qemu-devel] [PATCH 3/5] target-arm: convert shl and shr " Aurelien Jarno
2012-09-17  9:30   ` Laurent Desnogues
2012-09-17  9:43     ` Peter Maydell
2012-09-17 13:36       ` Laurent Desnogues
2012-09-17 13:50         ` Peter Maydell
2012-09-18 21:12         ` Edgar E. Iglesias [this message]
2012-09-17 15:34       ` Richard Henderson
2012-09-17 15:41         ` Peter Maydell
2012-09-17 15:44           ` Richard Henderson
2012-09-17 15:36   ` Richard Henderson
2012-09-17 18:09     ` Aurelien Jarno
2012-09-17 18:47       ` Richard Henderson
2012-09-17 20:03         ` Aurelien Jarno
2012-09-16 23:08 ` [Qemu-devel] [PATCH 4/5] target-arm: optimize helper_sar Aurelien Jarno
2012-09-16 23:08 ` [Qemu-devel] [PATCH 5/5] target-arm: mark a few integer helpers const and pure 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=20120918211214.GA29439@zapo \
    --to=edgar.iglesias@gmail.com \
    --cc=aurelien@aurel32.net \
    --cc=laurent.desnogues@gmail.com \
    --cc=peter.maydell@linaro.org \
    --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).