From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1251) id EECCF3858D39; Sun, 30 Apr 2023 22:48:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EECCF3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682894907; bh=s4i6sXR86pZMoPpWfIAydAL5Ggcn84XXYPgfpU1MIBQ=; h=From:To:Subject:Date:From; b=ad1sqL0TqphuQT14Wf4E+pQkgOx1rRGk0piStQZTTwWUz1JousVTkJZzUrTFm3S3D VK2e+qDtR3LcRARQrSvHjBiyskCqYgNPC/f+WBvT9Kc4TKwd3MKBORIlXnLpQsos+4 eOzMWKaLRrel4y7MyGvcbw/zw4Wi9/3vOrKxp1sg= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Roger Sayle To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-365] [Committed] Update xstormy16's neghi2 pattern to not clobber the carry flag. X-Act-Checkin: gcc X-Git-Author: Roger Sayle X-Git-Refname: refs/heads/master X-Git-Oldrev: d56af02fb1fd6eb50beb8a1689cf646bc567dbfc X-Git-Newrev: b159026b739f46e6d552bb23e8f51f03e291f51e Message-Id: <20230430224827.EECCF3858D39@sourceware.org> Date: Sun, 30 Apr 2023 22:48:27 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b159026b739f46e6d552bb23e8f51f03e291f51e commit r14-365-gb159026b739f46e6d552bb23e8f51f03e291f51e Author: Roger Sayle Date: Sun Apr 30 23:47:13 2023 +0100 [Committed] Update xstormy16's neghi2 pattern to not clobber the carry flag. When I converted xstormy'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. 2024-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. Diff: --- gcc/config/stormy16/stormy16.md | 7 +++---- gcc/testsuite/gcc.target/xstormy16/neghi2.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gcc/config/stormy16/stormy16.md b/gcc/config/stormy16/stormy16.md index be1ee04e5b5..91e4bb1cff7 100644 --- a/gcc/config/stormy16/stormy16.md +++ b/gcc/config/stormy16/stormy16.md @@ -519,11 +519,10 @@ ;; Negation (define_insn "neghi2" - [(parallel [(set (match_operand:HI 0 "register_operand" "=r") - (neg:HI (match_operand:HI 1 "register_operand" "0"))) - (clobber (reg:BI CARRY_REG))])] + [(set (match_operand:HI 0 "register_operand" "=r") + (neg:HI (match_operand:HI 1 "register_operand" "0")))] "" - "not %0 | add %0,#1" + "not %0 | inc %0" [(set_attr "length" "4")]) ;; :::::::::::::::::::: diff --git a/gcc/testsuite/gcc.target/xstormy16/neghi2.c b/gcc/testsuite/gcc.target/xstormy16/neghi2.c index dd3dd1e60fb..101c6da279f 100644 --- a/gcc/testsuite/gcc.target/xstormy16/neghi2.c +++ b/gcc/testsuite/gcc.target/xstormy16/neghi2.c @@ -5,4 +5,4 @@ short neg(short x) { return -x; } -/* { dg-final { scan-assembler "not r2 | add r2,#1" } } */ +/* { dg-final { scan-assembler "not r2 | inc r2" } } */