dse: Use SUBREG_REG for copy_to_mode_reg in DSE replace_read for WORD_REGISTER_OPERATIONS targets [PR109040]
Message ID | ZD5dlaIu4zph3Opc@tucnak |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2695473vqo; Tue, 18 Apr 2023 02:07:31 -0700 (PDT) X-Google-Smtp-Source: AKy350Z0p5BQ7cBQ4TcMwT5WhcxB9vTuo/oN7W2d3MJw+tdkL6ihDfSLhnMBL6onUYSVCGd8M2g5 X-Received: by 2002:aa7:c502:0:b0:502:20f0:3ee1 with SMTP id o2-20020aa7c502000000b0050220f03ee1mr1372908edq.31.1681808851144; Tue, 18 Apr 2023 02:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681808851; cv=none; d=google.com; s=arc-20160816; b=OBkqpa3pH6z85EHg1oBI8pdGCH7caeObevqw5Y6Pb1zXUG4dFGRPi880ta/tg5h7oV c/zdaALDf4TTVobTbjKPf9SkZM+CcL8oqdVs6h71V+hBVITdU9q3N6Y54kmN+zEz/mpL PKUrghYMJh+xSUgYoOcvlucAohKMVI7h9t/vkf+hs356Q1htr2S2KwTipFl5bODrlDhW 65kSTcRW1dRRy65++ErFHJt1+YpNbLFldqXKNkHbCHTY/bprWtoggUJBYxk0JB4/EXog FpSN07AP5MJGvoRMgdSowHHAsBHY4aIy74STtq5ZNdK8w++7/0g7ypokQ5lKwoh9qruY V8DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=XS4V+/5aytsVb7r7+Xtfwyc5Qfni4egL8eu4iSJNeiQ=; b=opxmTPVAqClsniNch0YSMwfmnc2BxXDUfb62KaQ8mjUvQ9200umpPY+eR0N6X/4O7B 1fvq5Ef+iyHP5CBsxLPrv6anrNiYEplRESYIfLm1tjxpke85GoqVIbaqaoXSIBdLGpmu LBiPKQEhmLUFugFLQNVr0gxEDFiyxfoKg3Dj5xN/yO7Uki3qEAcrntpJ08QvT+5sCGia mjVdPMpGPBTatVnmQ/uod//6yAjQp4sQvVKZHpjr9Hn5AjDpzKfoKRzJe48KfSB98p7E 3lh9+vQ1pbXBIB6ncu80Z6o9N1GyMun78jy1Q/gC1ldeBhDfd++L4uwpXlVQkb3yiOGi qM7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="CEv0/5Ni"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id n17-20020aa7c791000000b005068d7657f1si7632215eds.599.2023.04.18.02.07.30 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 02:07:31 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="CEv0/5Ni"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0C1E2385843E for <ouuuleilei@gmail.com>; Tue, 18 Apr 2023 09:07:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C1E2385843E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681808843; bh=XS4V+/5aytsVb7r7+Xtfwyc5Qfni4egL8eu4iSJNeiQ=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=CEv0/5NiepXyL4UBd++kJGeqv2kn+43KhqU5yuAzFGltFY9SaJPa9fXoPg86cK/yi 6fVZyhZqlxJjUHNCe6i/EOCXC6QyUjbS6rMCAEmx4ndraVWgIVoPPfwudhQVwoJHNG Ra1/DMaX962SGCpBinECany081YZSW5lhtV8gpHk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 2369B3858D1E for <gcc-patches@gcc.gnu.org>; Tue, 18 Apr 2023 09:06:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2369B3858D1E Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-350-hLOPHxKJNrapZCnTyL8D2w-1; Tue, 18 Apr 2023 05:06:33 -0400 X-MC-Unique: hLOPHxKJNrapZCnTyL8D2w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AAB84185A790; Tue, 18 Apr 2023 09:06:32 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 708AE14171B8; Tue, 18 Apr 2023 09:06:32 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 33I96TAP108488 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 18 Apr 2023 11:06:30 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 33I96TCM108487; Tue, 18 Apr 2023 11:06:29 +0200 Date: Tue, 18 Apr 2023 11:06:29 +0200 To: Jeff Law <jeffreyalaw@gmail.com> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] dse: Use SUBREG_REG for copy_to_mode_reg in DSE replace_read for WORD_REGISTER_OPERATIONS targets [PR109040] Message-ID: <ZD5dlaIu4zph3Opc@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763504398057732718?= X-GMAIL-MSGID: =?utf-8?q?1763504398057732718?= |
Series |
dse: Use SUBREG_REG for copy_to_mode_reg in DSE replace_read for WORD_REGISTER_OPERATIONS targets [PR109040]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
April 18, 2023, 9:06 a.m. UTC
Hi! While we've agreed this is not the right fix for the PR109040 bug, the patch clearly improves generated code (at least on the testcase from the PR), so I'd like to propose this as optimization heuristics improvement for GCC 14. Ok for trunk? 2023-04-18 Jakub Jelinek <jakub@redhat.com> PR target/109040 * dse.cc (replace_read): If read_reg is a SUBREG of a word mode REG, for WORD_REGISTER_OPERATIONS copy SUBREG_REG of it into a new REG rather than the SUBREG. Jakub
Comments
On 4/18/23 03:06, Jakub Jelinek wrote: > Hi! > > While we've agreed this is not the right fix for the PR109040 bug, > the patch clearly improves generated code (at least on the testcase from the > PR), so I'd like to propose this as optimization heuristics improvement > for GCC 14. > > Ok for trunk? > > 2023-04-18 Jakub Jelinek <jakub@redhat.com> > > PR target/109040 > * dse.cc (replace_read): If read_reg is a SUBREG of a word mode > REG, for WORD_REGISTER_OPERATIONS copy SUBREG_REG of it into > a new REG rather than the SUBREG. Doesn't the new behavior need to be conditional on can_create_pseudos_p since the call to copy_to_mode_reg can ultimately call gen_reg_rtx. jeff
On 4/18/23 03:06, Jakub Jelinek wrote: > Hi! > > While we've agreed this is not the right fix for the PR109040 bug, > the patch clearly improves generated code (at least on the testcase from the > PR), so I'd like to propose this as optimization heuristics improvement > for GCC 14. > > Ok for trunk? > > 2023-04-18 Jakub Jelinek <jakub@redhat.com> > > PR target/109040 > * dse.cc (replace_read): If read_reg is a SUBREG of a word mode > REG, for WORD_REGISTER_OPERATIONS copy SUBREG_REG of it into > a new REG rather than the SUBREG. And OK after updating the conditional. jeff
On Tue, Apr 18, 2023 at 07:35:44AM -0600, Jeff Law wrote: > > > On 4/18/23 03:06, Jakub Jelinek wrote: > > Hi! > > > > While we've agreed this is not the right fix for the PR109040 bug, > > the patch clearly improves generated code (at least on the testcase from the > > PR), so I'd like to propose this as optimization heuristics improvement > > for GCC 14. > > > > Ok for trunk? > > > > 2023-04-18 Jakub Jelinek <jakub@redhat.com> > > > > PR target/109040 > > * dse.cc (replace_read): If read_reg is a SUBREG of a word mode > > REG, for WORD_REGISTER_OPERATIONS copy SUBREG_REG of it into > > a new REG rather than the SUBREG. > Doesn't the new behavior need to be conditional on can_create_pseudos_p > since the call to copy_to_mode_reg can ultimately call gen_reg_rtx. Why? copy_to_mode_reg was used before as well and it unconditionally does rtx temp = gen_reg_rtx (mode); as the first thing in the function. So, if replace_read is used during post-RA DSE instance, it would already ICE before. All the patch changes is it will in some cases do copy_to_mode_reg on SUBREG_REG and create a new SUBREG instead of doing copy_to_mode_reg on the original. I think /* No place to keep the value after ra. */ && !reload_completed in record_store prevents recording the rhs values in DSE2 and so replace_read should never trigger there. Jakub
On 4/18/23 07:47, Jakub Jelinek wrote: > On Tue, Apr 18, 2023 at 07:35:44AM -0600, Jeff Law wrote: >> >> >> On 4/18/23 03:06, Jakub Jelinek wrote: >>> Hi! >>> >>> While we've agreed this is not the right fix for the PR109040 bug, >>> the patch clearly improves generated code (at least on the testcase from the >>> PR), so I'd like to propose this as optimization heuristics improvement >>> for GCC 14. >>> >>> Ok for trunk? >>> >>> 2023-04-18 Jakub Jelinek <jakub@redhat.com> >>> >>> PR target/109040 >>> * dse.cc (replace_read): If read_reg is a SUBREG of a word mode >>> REG, for WORD_REGISTER_OPERATIONS copy SUBREG_REG of it into >>> a new REG rather than the SUBREG. >> Doesn't the new behavior need to be conditional on can_create_pseudos_p >> since the call to copy_to_mode_reg can ultimately call gen_reg_rtx. > > Why? copy_to_mode_reg was used before as well and it unconditionally does > rtx temp = gen_reg_rtx (mode); > as the first thing in the function. So something must be guarding earlier, which is fine. It was a general question as it wasn't obvious what would happen post-reload. OK for the trunk. jeff
--- gcc/dse.cc.jj 2023-01-02 09:32:50.369880943 +0100 +++ gcc/dse.cc 2023-04-04 22:17:22.906347794 +0200 @@ -2012,7 +2012,19 @@ replace_read (store_info *store_info, in } /* Force the value into a new register so that it won't be clobbered between the store and the load. */ - read_reg = copy_to_mode_reg (read_mode, read_reg); + if (WORD_REGISTER_OPERATIONS + && GET_CODE (read_reg) == SUBREG + && REG_P (SUBREG_REG (read_reg)) + && GET_MODE (SUBREG_REG (read_reg)) == word_mode) + { + /* For WORD_REGISTER_OPERATIONS with subreg of word_mode register + force SUBREG_REG into a new register rather than the SUBREG. */ + rtx r = copy_to_mode_reg (word_mode, SUBREG_REG (read_reg)); + read_reg = shallow_copy_rtx (read_reg); + SUBREG_REG (read_reg) = r; + } + else + read_reg = copy_to_mode_reg (read_mode, read_reg); insns = get_insns (); end_sequence ();