From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPvAq-0002Mm-Pm for qemu-devel@nongnu.org; Tue, 18 Mar 2014 10:39:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WPvAi-0006Bs-Cr for qemu-devel@nongnu.org; Tue, 18 Mar 2014 10:39:24 -0400 Received: from mail-qc0-x22b.google.com ([2607:f8b0:400d:c01::22b]:51442) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPvAi-0006Bb-88 for qemu-devel@nongnu.org; Tue, 18 Mar 2014 10:39:16 -0400 Received: by mail-qc0-f171.google.com with SMTP id c9so2000737qcz.2 for ; Tue, 18 Mar 2014 07:39:15 -0700 (PDT) Sender: Richard Henderson Message-ID: <53285A90.6040300@twiddle.net> Date: Tue, 18 Mar 2014 07:39:12 -0700 From: Richard Henderson MIME-Version: 1.0 References: <5328564A.8060409@twiddle.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] target-i386: guest variable shift by 0 provokes shift by -1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Developers 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~