From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id C9F703858C50 for ; Sat, 29 Apr 2023 16:42:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9F703858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-528c2c89493so486088a12.0 for ; Sat, 29 Apr 2023 09:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682786532; x=1685378532; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=mLPwsBw34tJ+oj5KSZVIlfHctPVDAcIi1eQPM68D078=; b=fwwKkriroHc+iQP+nn8cl1uUtfDa0nx9ZY4aJD18f3THLaRK+rbYhYlNYGiogwUtKs K4OQQmR5kOqY+M5EUDL3YD5rM7HUHuC2xMyHTl/SRB/srM879YEE/HGNaK9whN9Jt6PY ps0sw0lOq04aUeq8uxxf9ojsdCcBYfcJLy8BFUO/sWyHJ/NSfJL9lBANrGpaF6NyYFIU WTkIqrLVPMtMeRYo24M27F0BkCyVEjDEN0apNjfH3EopI1WcWJMLJfH5Twz+XkcghYY2 DuIdvV1DylJcuJDJfAtmusCQgN/je/6Ob80dNlvfu91VhNUywnZ0g4ndlSrj+E9GwJjo GcaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682786532; x=1685378532; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mLPwsBw34tJ+oj5KSZVIlfHctPVDAcIi1eQPM68D078=; b=klU7y0jpdu7N9LFVNlMJFTyFrA5UeTCAKzIhSELrTOF6eEaA/Z7j8KaJWVH7dC0Efw NNy7lwek6A8519iSgXV7rTJFMsL2c4zq7y5/xWRuyUro8x+Xf4xX3PdixXtEMhUEITxr MxsWH0GL2YXB4LPnAj7K0pncn0H8MgHRCU2M0MkpvFSj0oObr2tODTzcLUqX8+OYD7y9 Zb+3RiBPbYE6p81Ejm1BzqWMRI+AomMSY0EpoA++IL/7WfTz5WvU9dq/U2Pa+LC3gwcS goXitk8p28q8JZ4vtQehVV1Wrn/Ve9Cm0B/6/ypJ2F25CGjSgt1z86B4Fh20G+BPgzhz 6AYA== X-Gm-Message-State: AC+VfDyowom5OO1fvYtViRnYFvv1IkXopRHsqY489uXDKpJq5rRjR3ha CwNfPTtQpkzDy12Sd90+NMSr+0SZfnPNyQ== X-Google-Smtp-Source: ACHHUZ449TT3aGNZzlbgOuZN1USfXGJuqbxkyzsFeutk8mRHmYDJamYRC7Vbfjb9eCzB0w8iiBBjqQ== X-Received: by 2002:a17:902:d48b:b0:1a6:ef75:3c53 with SMTP id c11-20020a170902d48b00b001a6ef753c53mr11228353plg.11.1682786532396; Sat, 29 Apr 2023 09:42:12 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::99f? ([2601:681:8600:13d0::99f]) by smtp.gmail.com with ESMTPSA id q5-20020a170902dac500b00199203a4fa3sm3607043plx.203.2023.04.29.09.42.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 29 Apr 2023 09:42:11 -0700 (PDT) Message-ID: Date: Sat, 29 Apr 2023 10:42:10 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [xstormy16 PATCH] Efficient HImode rotate left by a single bit. Content-Language: en-US To: Roger Sayle , 'GCC Patches' References: <004a01d97ab7$42722140$c75663c0$@nextmovesoftware.com> From: Jeff Law In-Reply-To: <004a01d97ab7$42722140$c75663c0$@nextmovesoftware.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 4/29/23 10:25, Roger Sayle wrote: > This patch contains some minor tweak to xstormy16's machine description > most significantly providing a pattern for HImode rotate left by a single > bit that requires only two instructions. > > unsigned short foo(unsigned short x) > { > return (x << 1) | (x >> 15); > } > > currently with -O2 generates: > foo: mov r7,r2 > shr r7,#15 > shl r2,#1 > or r2,r7 > ret > > with this patch, GCC now generates: > foo: shl r2,#1 | adc r2,#0 > ret > > Additionally neghi2 is converted to a define_insn (so that the RTL > optimizers see the negation semantics), and HImode rotations by > 8-bits can now be recognized and implemented using swpb. > > This patch has been tested by building a cross-compiler to xstormy16-elf > from x86_64-pc-linux-gnu and confirming the new test cases pass. > Ok for mainline? > > > 2023-04-29 Roger Sayle > > gcc/ChangeLog > * config/stormy16/stormy16.md (neghi2): Convert from a define_expand > to a define_insn. > (*rotatehi_1): New define_insn for efficient 2 insn sequence. > (*rotatehi_8, *rotaterthi_8): New define_insn to emit a swpb. > > gcc/testsuite/ChangeLog > * gcc.target/xstormy16/neghi2.c: New test case. > * gcc.target/rotatehi-1.c: Likewise. It may be the case that exposing negation as a not + add sequence was thought to potentially produce better code by exposing the component instructions. Or it may have simply been the case that nobody considered the tradeoffs. Either way, I think the patch is fine. As is always the case, figure ~24hrs after committing we'll have test results. jeff