From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1AYF-0003ZW-2D for qemu-devel@nongnu.org; Wed, 07 Sep 2011 01:19:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1AYD-0003uz-NT for qemu-devel@nongnu.org; Wed, 07 Sep 2011 01:19:55 -0400 Received: from mail-pz0-f42.google.com ([209.85.210.42]:44397) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1AYD-0003uf-BB for qemu-devel@nongnu.org; Wed, 07 Sep 2011 01:19:53 -0400 Received: by pzk37 with SMTP id 37so13026032pzk.29 for ; Tue, 06 Sep 2011 22:19:52 -0700 (PDT) Sender: Richard Henderson Message-ID: <4E66FEEA.2060703@twiddle.net> Date: Wed, 07 Sep 2011 10:49:38 +0530 From: Richard Henderson MIME-Version: 1.0 References: <4E62E214.4080400@twiddle.net> <4E6632D7.6070008@twiddle.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] TCG sar UB (fwd) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: malc Cc: qemu-devel@nongnu.org On 09/06/2011 08:50 PM, malc wrote: > Correct me if i'm wrong, previously the code worked like this: > > mov tmp, 0 > sub tmp, 1 > sar r, r, tmp > > Still UB as far as TCG is concerned but since no immediates are involved > things worked, now, with constant folding, we are asked to sar by -1 > directly. You are exactly correct. That's why I thought my patch to re-arrange the order of operations and only perform the subtraction inside the %cl != 0 test was a good idea. No point in performing the shift if we're not going to use the result. > I did that when first hit this problem, but decided not to push it. I think pushing it is a good idea. Just because the result is not defined, according to tcg/README, is no reason to SIGILL. r~