All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] target-i386: guest variable shift by 0 provokes shift by -1
Date: Tue, 18 Mar 2014 07:39:12 -0700	[thread overview]
Message-ID: <53285A90.6040300@twiddle.net> (raw)
In-Reply-To: <CAFEAcA_K-K0P7obL6BdFrqJu7=gPzAEtVvq7oYa9aqsRdYmk_g@mail.gmail.com>

On 03/18/2014 07:25 AM, Peter Maydell wrote:
> Why do you think this? tcg/README says out of
> range shifts are undefined behaviour. That means we
> mustn't execute them, and this code doesn't attempt
> to branch around or otherwise avoid the shift by -1.

Bah.  Stuff and nonsense.  None of our backends are so stupid as to start WWIII
with an out of range input.

For most backends, the shift count gets (partially) masked as it is inserted
into the immediate field.  Then either the cpu considers a large shift as
producing zero (arm), or fully masks the input (everyone else).

Though indeed, Sparc considers an out of range shift immediate as an illegal
instruction, so we have an extra step in the backend for exactly this case:

    do_shift32:
        /* Limit immediate shift count lest we create an illegal insn.  */
        tcg_out_arithc(s, args[0], args[1], args[2] & 31, const_args[2], c);
        break;

> The docs say undefined behaviour, not undefined
> result value... (Is there a C standard term for
> the latter?)

The README is hardly standard-ese.  Don't read it like it's been written that way.

The term from C you're looking for is unspecified behaviour.



r~

  reply	other threads:[~2014-03-18 14:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-18 12:33 [Qemu-devel] target-i386: guest variable shift by 0 provokes shift by -1 Peter Maydell
2014-03-18 14:20 ` Richard Henderson
2014-03-18 14:25   ` Peter Maydell
2014-03-18 14:39     ` Richard Henderson [this message]
2014-03-18 14:47       ` Peter Maydell
2014-03-18 14:52         ` Peter Maydell
2014-03-18 14:56         ` Richard Henderson
2014-03-18 15:01           ` Peter Maydell
2014-03-18 15:19             ` Richard Henderson
2014-03-18 16:34             ` Paolo Bonzini

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=53285A90.6040300@twiddle.net \
    --to=rth@twiddle.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.