From patchwork Thu Jul 13 17:10:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 120055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1967024vqm; Thu, 13 Jul 2023 10:11:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlGfBGSEhSyiOyTh2kasph0N/3eu7jx0hUyKFOVP/wi1JV2j+z4b7VGUIctMD5YjzVS/34Bb X-Received: by 2002:aa7:c505:0:b0:51d:b0a4:1d44 with SMTP id o5-20020aa7c505000000b0051db0a41d44mr2144108edq.29.1689268288718; Thu, 13 Jul 2023 10:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689268288; cv=none; d=google.com; s=arc-20160816; b=jTXND8oWG27cvpbqNz6UfLvix1hsz39R1IwTZUN4I5V2awJXk9xIgL3KTu1SUE3qTj MEJ2gBehLjytkv65QZxTyHrzNGNTGD15ymP+/qV+HWJlqC8KxAilEzF7/9hulzk4/mTE 9WiCWLBzOO4IwA8CPEKHuIhlFqEQyXWIYxxA9lkDMbHzH7JxKe5j2Btrt/JGjLz5xouA m9pxWUGLFD7HhPvuylD4Qz50oiYR81Sis2ukM+m36muuhGCM2nOmtoFv/hxADK3+rT7u uyWrKvYipYyCRMKGZsiRwj3Mk1PrYu7azW+l+la8kicbPJp+g48ZkCPssWTzxbGJRokb ZMew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-language:thread-index :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=WoXtpE23j3lgSs7y/5u/4FgxIm4JfjHClgjZRLAzr5A=; fh=UAbSimdGpojL/e9wL4Po0hjwO3sT24dauJYSxjnq65Y=; b=I+3oTYiTwxY/IDZqxznY9HfkLo89/n4cUAE+jsbMMN1gyLP4LL0fh1hjG3Q5VyOgIs X1CrTJU8V+5exqodMgTNFbhUdPyer4AgNr7/NUy10DaOG4rnSCOXsdDdjxSR+k7qpP3D ZhLi2CPMOviOdWL9rmxC49pOOuzcBG3grW4nmvLCb1VozlMTBp3AvlkFBK0Se97n1EEn 32QtEUcsSBPOlhxhj06oJj8HiyyLKg7kejAv3tnqRcUfJiDy9SPfeZiU2raLnHAf+gUy C7/eKEoDyVhbHxDKGh1sy7t6vTKDpICmOoms5sPQ5e0YYtvIWT5H5sQVUV7/4G/rRxXy hOyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=KCLhmK4D; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g18-20020a056402181200b0051d9bf91280si7664913edy.541.2023.07.13.10.11.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 10:11:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=KCLhmK4D; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 529C33858418 for ; Thu, 13 Jul 2023 17:11:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 7FB043858D1E for ; Thu, 13 Jul 2023 17:10:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FB043858D1E 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=WoXtpE23j3lgSs7y/5u/4FgxIm4JfjHClgjZRLAzr5A=; b=KCLhmK4D7alj+sQG8LU5MX/nRc dO81fgeswEDsYQ9fW2i3myWTmDYYz6JRHOmJAI/M+Q8LK2f6Il4584Nvc8jjHvtBPz76zqyWNBhhr rBJGnzm+KM5nLUqEI3pKRFrKZIfTm7QOLQwMxJi9vjrc3AldMWPrGLVH/Q2gkwVzcs6rUKZnKHBis VI+fZhPL/w47rXZPYkcuJw4/XKaWiQYF0NO05J9eFY7PK6kDQAv3ZNCK/RbMqRiM2IWnCpFpJfY14 qowzsGV55YqFSb2zscYdZ5Ho/yS+zPOgv8cx3S50F9kQ8xC8t6ZThsgr3kkhjkYr9ErPXxhzRk5Js haePwICw==; Received: from [185.62.158.67] (port=61250 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 1qJzq6-0005e8-14; Thu, 13 Jul 2023 13:10:50 -0400 From: "Roger Sayle" To: Cc: "'Uros Bizjak'" Subject: [x86 PATCH] PR target/110588: Add *bt_setncqi_2 to generate btl Date: Thu, 13 Jul 2023 18:10:47 +0100 Message-ID: <042301d9b5ac$f84e3e60$e8eabb20$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adm1rKx60fRtYDRmRxufYQVIzNp5tA== 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=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771326185163031666 X-GMAIL-MSGID: 1771326185163031666 This patch resolves PR target/110588 to catch another case in combine where the i386 backend should be generating a btl instruction. This adds another define_insn_and_split to recognize the RTL representation for this case. I also noticed that two related define_insn_and_split weren't using the preferred string style for single statement preparation-statements, so I've reformatted these to be consistent in style with the new one. This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and make -k check, both with and without --target_board=unix{-m32} with no new failures. Ok for mainline? 2023-07-13 Roger Sayle gcc/ChangeLog PR target/110588 * config/i386/i386.md (*bt_setcqi): Prefer string form preparation statement over braces for a single statement. (*bt_setncqi): Likewise. (*bt_setncqi_2): New define_insn_and_split. gcc/testsuite/ChangeLog PR target/110588 * gcc.target/i386/pr110588.c: New test case. Thanks again, Roger diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index e47ced1..04eca049 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -16170,9 +16170,7 @@ (const_int 0))) (set (match_dup 0) (eq:QI (reg:CCC FLAGS_REG) (const_int 0)))] -{ - operands[2] = lowpart_subreg (SImode, operands[2], QImode); -}) + "operands[2] = lowpart_subreg (SImode, operands[2], QImode);") ;; Help combine recognize bt followed by setnc (define_insn_and_split "*bt_setncqi" @@ -16193,9 +16191,7 @@ (const_int 0))) (set (match_dup 0) (ne:QI (reg:CCC FLAGS_REG) (const_int 0)))] -{ - operands[2] = lowpart_subreg (SImode, operands[2], QImode); -}) + "operands[2] = lowpart_subreg (SImode, operands[2], QImode);") (define_insn_and_split "*bt_setnc" [(set (match_operand:SWI48 0 "register_operand") @@ -16219,6 +16215,27 @@ operands[2] = lowpart_subreg (SImode, operands[2], QImode); operands[3] = gen_reg_rtx (QImode); }) + +;; Help combine recognize bt followed by setnc (PR target/110588) +(define_insn_and_split "*bt_setncqi_2" + [(set (match_operand:QI 0 "register_operand") + (eq:QI + (zero_extract:SWI48 + (match_operand:SWI48 1 "register_operand") + (const_int 1) + (zero_extend:SI (match_operand:QI 2 "register_operand"))) + (const_int 0))) + (clobber (reg:CC FLAGS_REG))] + "TARGET_USE_BT && ix86_pre_reload_split ()" + "#" + "&& 1" + [(set (reg:CCC FLAGS_REG) + (compare:CCC + (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)) + (const_int 0))) + (set (match_dup 0) + (ne:QI (reg:CCC FLAGS_REG) (const_int 0)))] + "operands[2] = lowpart_subreg (SImode, operands[2], QImode);") ;; Store-flag instructions. diff --git a/gcc/testsuite/gcc.target/i386/pr110588.c b/gcc/testsuite/gcc.target/i386/pr110588.c new file mode 100644 index 0000000..4505c87 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr110588.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mtune=core2" } */ + +unsigned char foo (unsigned char x, int y) +{ + int _1 = (int) x; + int _2 = _1 >> y; + int _3 = _2 & 1; + unsigned char _8 = (unsigned char) _3; + unsigned char _6 = _8 ^ 1; + return _6; +} + +/* { dg-final { scan-assembler "btl" } } */ +/* { dg-final { scan-assembler "setnc" } } */ +/* { dg-final { scan-assembler-not "sarl" } } */ +/* { dg-final { scan-assembler-not "andl" } } */ +/* { dg-final { scan-assembler-not "xorl" } } */