Received: from eggs.gnu.org ([2001:4830:134:3::10]:44008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4p2o-00075o-4J for qemu-devel@nongnu.org; Thu, 10 Nov 2016 08:05:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4p2k-0004h5-65 for qemu-devel@nongnu.org; Thu, 10 Nov 2016 08:05:30 -0500 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]:35027) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c4p2j-0004gr-V3 for qemu-devel@nongnu.org; Thu, 10 Nov 2016 08:05:26 -0500 Received: by mail-wm0-x22a.google.com with SMTP id a197so366779175wmd.0 for ; Thu, 10 Nov 2016 05:05:25 -0800 (PST) Sender: Richard Henderson References: <1478712603-18286-1-git-send-email-laurent@vivier.eu> From: Richard Henderson Message-ID: <9fe7f416-300a-9656-ef87-341fd38ab77d@twiddle.net> Date: Thu, 10 Nov 2016 14:05:20 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] target-m68k: add rol/ror/roxl/roxr instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier , qemu-devel@nongnu.org On 11/09/2016 09:22 PM, Laurent Vivier wrote: > Le 09/11/2016 à 20:39, Richard Henderson a écrit : >> On 11/09/2016 07:47 PM, Richard Henderson wrote: >>> On 11/09/2016 06:30 PM, Laurent Vivier wrote: >>>> + /* create [src:X:..] */ >>>> + >>>> + tcg_gen_deposit_i32(t0, QREG_CC_X, src, 1, size); >>>> + tcg_gen_shli_i32(t0, t0, 31 - size); >>>> + >>>> + /* rotate */ >>>> + >>>> + tcg_gen_rotl_i32(t0, t0, shift); >>>> + >>>> + /* result is [src:..:src:X] */ >>>> + >>>> + tcg_gen_andi_i32(X, t0, 1); >>>> + tcg_gen_shri_i32(t0, t0, 1); >>> >>> I don't see how this is supposed to work. If you form [src:x:...], >>> and rotate >>> by 0, then X gets garbage. Of course, you're actually forming > > The result is ignored in the case of a rotate by 0 (see movcond in > rotate_reg()). > >>> [0:src:x]. But >>> for a rol of 2, the lsb of src gets 0's instead of the msb of src. > > for a rol of 2 on an 8bit value [12345678]: > > tcg_gen_deposit_i32(t0, QREG_CC_X, src, 1, size); > tcg_gen_shli_i32(t0, t0, 31 - size); > > t0 = [12345678x00000000000000000000000] > > tcg_gen_rotl_i32(t0, t0, shift); > > t0 = [345678x0000000000000000000000012] > > tcg_gen_andi_i32(X, t0, 1); > > X = 2 > > tcg_gen_shri_i32(t0, t0, 1); > > t0 = [0345678x000000000000000000000001] > > tcg_gen_shri_i32(t1, t0, 31 - size); > > t1 = [000000000000000000000000345678x0] > > tcg_gen_or_i32(dest, t0, t1); > > dest = [0345678x0000000000000000345678x1] > > -> we keep only 8 bits: [345678x1] > > Where am I wrong? You aren't. I simply misread this. But still we must only perform this rotate modulo size+1. r~