From patchwork Tue Jun 8 14:16:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 1489461 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=VafPl2Nx; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fzskt2dFtz9sRN for ; Wed, 9 Jun 2021 00:17:25 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C4DAF3955409 for ; Tue, 8 Jun 2021 14:17:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C4DAF3955409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623161841; bh=aU94RLw8nwgxZB79+kSG1hoOvSMOa+8YrhHTO5O1OVc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VafPl2NxxwwiKLf4lG8l2EjkSNlX8FMHP4Fs/j2UL7ZHUVoOSMubHS1Pf06Yd3mkn f8L/KopV5LLnnuwWZwJTFLiC3roDXgyXZmmwT/mJ1rGRes3ou+49oouZ/n7sILL7L4 E9urmEDVyx6J/v+pcgEY9aLVWZRajXTq4hp/cbN4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id 2CB0439574E0 for ; Tue, 8 Jun 2021 14:16:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2CB0439574E0 Received: by mail-pj1-x1036.google.com with SMTP id md2-20020a17090b23c2b029016de4440381so2389313pjb.1 for ; Tue, 08 Jun 2021 07:16:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:message-id:date:user-agent :mime-version:content-language; bh=aU94RLw8nwgxZB79+kSG1hoOvSMOa+8YrhHTO5O1OVc=; b=Q0oFl/Zt3Dw/Ak2f8Ocq4Z2gW32PhLHeAhsNqU9rWpmqhxnYqETnbXhwtqeesPkMau 8Cmu8mo1iCFDsGru4fhS+j7rcun938kSkbN9Uh6ipqkwxSuP3v/NMPu70AMACJIvHTIj P8bE9P7ZhL/1yMIX7Mvyl0yRqXnmXf0jJJDbwpwlEbRlyDUm0m5YJOTAlDZhIFvCHumn kvvoSz/BJ7pFHBM4rX0fjeuHoZZ/OFpVch/bmwpHwQz52aCw9Ij4hcbKFryXSzc3l2DN uGpgJ42X5C2h68AnnGrZ7XQLaP0rPsE1GMETb0++99TOGWJ1tzLsWZcFYZRy096U6B3K xh/g== X-Gm-Message-State: AOAM533iSieTD1vwpw0Em5PlV7YKsh2FQbNeFdoDA0867i0LC+nHMB8O hxiUn1fReoVSKI+zhMDeT7bDb4yGQHD5rg== X-Google-Smtp-Source: ABdhPJyGu8x8BQBDsAQL5E2I+2RqP1oGKumZvGFy9hCzTjog2IXWwosZWqkLPr/Ds1bHsZd/yG/EFg== X-Received: by 2002:a17:903:2403:b029:ef:9419:b914 with SMTP id e3-20020a1709032403b02900ef9419b914mr229681plo.59.1623161787765; Tue, 08 Jun 2021 07:16:27 -0700 (PDT) Received: from [172.31.0.175] (c-98-202-48-222.hsd1.ut.comcast.net. [98.202.48.222]) by smtp.gmail.com with ESMTPSA id b6sm6406054pgw.67.2021.06.08.07.16.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Jun 2021 07:16:27 -0700 (PDT) To: GCC Patches Subject: [committed] Further improve redundant test/compare removal on the H8 Message-ID: <00e0cd36-42d7-fe8c-d97b-7eb9614da187@gmail.com> Date: Tue, 8 Jun 2021 08:16:24 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , X-Patchwork-Original-From: Jeff Law via Gcc-patches From: Jeff Law Reply-To: Jeff Law Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This is another minor patch for elimination of redundant test/compares on the H8.  In particular it allows the compiler to use the result of a byte sized AND instruction to eliminate a compare/test.  The only "trick" here is we have to distinguish between BCLR which clears a bit, but does not set condition codes and AND which does set condition codes. This patch also fixes a minor goof in the length computation of such instructions.  The prior patterns had the length computation backwards.  Byte sized ANDs are always 2 bytes while a BCLR can be from 2 to 8 bytes long depending on the target operand. Finally this patch also merges the H8SX BSET/BNOT for QI and HI mode. This is about 9 hours into the 22 hour test cycle (my timeouts are dramatically longer than the defaults to improve test coverage and stability).   I'm not expecting any issues. Committed to the trunk, Jeff commit 941aa24ca9553b422dba6e267448ddd952bc52d1 Author: Jeff Law Date: Tue Jun 8 10:10:23 2021 -0400 Further improve redundant test/compare removal on the H8 gcc/ * config/h8300/logical.md (andqi3_1): Move BCLR case into define_insn_and_split. Create length attribute on define_insn_and_split. Only split for cases which we know will use AND. (andqi3_1): Renamed from andqi3_1_clobber_flags. Only handle AND here and fix length computation. (bmsx): Combine QImode and HImode H8/SX patterns using iterator. diff --git a/gcc/config/h8300/logical.md b/gcc/config/h8300/logical.md index 34cf74e24ee..fae3c7cd0c5 100644 --- a/gcc/config/h8300/logical.md +++ b/gcc/config/h8300/logical.md @@ -62,22 +62,21 @@ (match_operand:QI 2 "h8300_src_operand" "Y0,rn")))] "register_operand (operands[0], QImode) || single_zero_operand (operands[2], QImode)" - "#" - "&& reload_completed" + "bclr %W2,%R0" + "&& reload_completed && !single_zero_operand (operands[2], QImode)" [(parallel [(set (match_dup 0) (and:QI (match_dup 1) (match_dup 2))) - (clobber (reg:CC CC_REG))])]) + (clobber (reg:CC CC_REG))])] + "" + [(set_attr "length" "8,2")]) -(define_insn "andqi3_1_clobber_flags" - [(set (match_operand:QI 0 "bit_operand" "=U,r") - (and:QI (match_operand:QI 1 "bit_operand" "%0,0") - (match_operand:QI 2 "h8300_src_operand" "Y0,rn"))) +(define_insn "*andqi3_1" + [(set (match_operand:QI 0 "register_operand" "=r") + (and:QI (match_operand:QI 1 "register_operand" "%0") + (match_operand:QI 2 "h8300_src_operand" "rn"))) (clobber (reg:CC CC_REG))] - "register_operand (operands[0], QImode) - || single_zero_operand (operands[2], QImode)" - "@ - bclr %W2,%R0 - and %X2,%X0" - [(set_attr "length" "2,8")]) + "" + "and %X2,%X0" + [(set_attr "length" "2")]) (define_insn_and_split "*andor3" [(set (match_operand:QHSI 0 "register_operand" "=r") @@ -166,22 +165,14 @@ ;; OR/XOR INSTRUCTIONS ;; ---------------------------------------------------------------------- -(define_insn "bqi_msx" - [(set (match_operand:QI 0 "bit_register_indirect_operand" "=WU") - (ors:QI (match_operand:QI 1 "bit_register_indirect_operand" "%0") - (match_operand:QI 2 "single_one_operand" "Y2")))] +(define_insn "b_msx" + [(set (match_operand:QHI 0 "bit_register_indirect_operand" "=WU") + (ors:QHI (match_operand:QHI 1 "bit_register_indirect_operand" "%0") + (match_operand:QHI 2 "single_one_operand" "Y2")))] "TARGET_H8300SX && rtx_equal_p (operands[0], operands[1])" { return == IOR ? "bset\\t%V2,%0" : "bnot\\t%V2,%0"; } [(set_attr "length" "8")]) -(define_insn "bhi_msx" - [(set (match_operand:HI 0 "bit_register_indirect_operand" "=m") - (ors:HI (match_operand:HI 1 "bit_register_indirect_operand" "%0") - (match_operand:HI 2 "single_one_operand" "Y2")))] - "TARGET_H8300SX" - { return == IOR ? "bset\\t%V2,%0" : "bnot\\t%V2,%0"; } - [(set_attr "length" "8")]) - (define_insn_and_split "qi3_1" [(set (match_operand:QI 0 "bit_operand" "=U,rQ") (ors:QI (match_operand:QI 1 "bit_operand" "%0,0")