From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id C52A73858D39 for ; Sun, 30 Apr 2023 22:53:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C52A73858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=fv6EnsAWsmXqoZJkkt/5jC5gHh7vsinSFVlfv6ABtXg=; b=TA/xgr4pG4cfKydq/g8wM0kgCX GafQGHq3uxnR7WkdYGFcfZfsvm26P0emiHIsDMsXTg0u/WIHLsES7/e2eKV2BLgXq8JTJOjwsZb3U yl83aWaw2JGxQgl1+ppjwOM/HLOSno05gXjOJQIAMihfNnwkugcSlIwNzwvk+mGi/rBkEcISTLMow URshYIfjXA3Kk9hisXV4MNBsB41Cx1bAaLooY1GD8J8a/CmchIfd1yu7vekzKwBjsNkPwgOGnWCST taailMDvFH2fIlNSWrPYWTSLIpMA2iR7UVrshhkfsr3IdctyelRUxj6ohx/lKN8//+98b8mc7eHui 5lLYy0Sw==; Received: from host86-169-41-81.range86-169.btcentralplus.com ([86.169.41.81]:61606 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ptFvP-0005Sw-03; Sun, 30 Apr 2023 18:53:47 -0400 From: "Roger Sayle" To: "'GCC Patches'" Cc: "'Jeff Law'" Subject: [Committed] Update xstormy16's neghi2 pattern to not clobber the carry flag. Date: Sun, 30 Apr 2023 23:53:46 +0100 Message-ID: <001901d97bb6$a001ff10$e005fd30$@nextmovesoftware.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_001A_01D97BBF.01C66710" X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adl7th9B1mRaPcayR+2ambq56n84sw== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_BARRACUDACENTRAL,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: This is a multipart message in MIME format. ------=_NextPart_000_001A_01D97BBF.01C66710 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit When I converted xstormy16's neghi2 pattern from a define_expand to a define_insn, I forgot that define_expand implicitly produces a sequence of instructions, but a define_insn is an implicit parallel, thereby messing up the clobber (reg:BI CARRY_REG), which can then cause an ICE in the auto-generated added_clobbers_hard_reg_p. Whilst stripping the superfluous PARALLEL resolves this issue, an even better fix is to use xstormy16's INC instruction, that (like NOT) doesn't affect the carry flag, resulting in a neghi2 implementation that can more easily be CSE'd and scheduled. Many thanks (again) to Jeff Law for testing/reporting this issue. This patch has been tested by building a cross compiler to xstormy16-elf from x86_64-pc-linux-gnu. Committed as obvious (in hindsight). 2023-04-30 Roger Sayle gcc/ChangeLog * config/stormy16/stormy16.md (neghi2): Rewrite pattern using inc to avoid clobbering the carry flag. gcc/testsuite/ChangeLog * gcc.target/xstormy16/neghi2.c: Update expected implementation. Sorry for any inconvenience. Roger -- ------=_NextPart_000_001A_01D97BBF.01C66710 Content-Type: text/plain; name="patchxs.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patchxs.txt" diff --git a/gcc/config/stormy16/stormy16.md = b/gcc/config/stormy16/stormy16.md=0A= index be1ee04..91e4bb1 100644=0A= --- a/gcc/config/stormy16/stormy16.md=0A= +++ b/gcc/config/stormy16/stormy16.md=0A= @@ -519,11 +519,10 @@=0A= ;; Negation=0A= =0A= (define_insn "neghi2"=0A= - [(parallel [(set (match_operand:HI 0 "register_operand" "=3Dr")=0A= - (neg:HI (match_operand:HI 1 "register_operand" "0")))=0A= - (clobber (reg:BI CARRY_REG))])]=0A= + [(set (match_operand:HI 0 "register_operand" "=3Dr")=0A= + (neg:HI (match_operand:HI 1 "register_operand" "0")))]=0A= ""=0A= - "not %0 | add %0,#1"=0A= + "not %0 | inc %0"=0A= [(set_attr "length" "4")])=0A= =0C=0A= ;; ::::::::::::::::::::=0A= diff --git a/gcc/testsuite/gcc.target/xstormy16/neghi2.c = b/gcc/testsuite/gcc.target/xstormy16/neghi2.c=0A= index dd3dd1e..101c6da 100644=0A= --- a/gcc/testsuite/gcc.target/xstormy16/neghi2.c=0A= +++ b/gcc/testsuite/gcc.target/xstormy16/neghi2.c=0A= @@ -5,4 +5,4 @@ short neg(short x)=0A= {=0A= return -x;=0A= }=0A= -/* { dg-final { scan-assembler "not r2 | add r2,#1" } } */=0A= +/* { dg-final { scan-assembler "not r2 | inc r2" } } */=0A= ------=_NextPart_000_001A_01D97BBF.01C66710--