From patchwork Sat May 6 12:57:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 90755 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1037226vqo; Sat, 6 May 2023 05:58:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fclL8xZobpvwuS/9Rx/y5WHe6Wj560wv4kkveJtp+fkckX/2H5ZMuiQgKd2V+2AyJMLJk X-Received: by 2002:a17:906:4791:b0:94a:8ead:c7f with SMTP id cw17-20020a170906479100b0094a8ead0c7fmr4146073ejc.23.1683377897838; Sat, 06 May 2023 05:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683377897; cv=none; d=google.com; s=arc-20160816; b=G/I5cpbMIDUAq3w7D0cKnDbrV6oqjuIAxQ8mcihgzeet+n4h9JGXNzV/SnXUY3+oQV +Y4thuwDtJ7jM+IScvRJ64N7Z/kr+rrJECCzVghOhzoNRQ1jfbQIXwkFPC3gArxkSsVJ z/LAPaFV2pLvBF1KlSHPLaKqAlRBPJ4Fl9/c0djRVzAF+xgjV0/rjH/4BCkL8aBThbW0 /LNzvsH5JwUbf1wpVFW18pQ5dbRbXZhZQD9MMz35Y7Q1RDHsIok9Vvm8Yt8q9snzT2LZ jKEH+zbcdqXcPyJ8u+xpQ+U8liarjAP+KO6gCeqolZ3DOvWFizHWirIeZL1G7F8rQgY7 QkyA== 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:to:from:dkim-signature :dmarc-filter:delivered-to; bh=vLeTm7heDnTbdYrQuPVrsw/vnlqogmWRXIX0zteqSwQ=; b=w7TnqNr+8I4BBYo2R0LK/yN1wqH+yvBJ2Rr0QcQFWoK7Go5dzx5uXu8Xscc8iFgp/Z lb1IRDIlabGZArWjYCkp0P6aa43VypPcnynI40kUryoQ647U9zZJr5VS8vyLsQOokmW6 2O76UTbbhjF+ecY0sCUbFhOQI349lAu5mMstBmWEkhFw2v/yLyD3OCGSzWU/hVE9/97v 9qijEABWtrAannn0gT1HbnIskyEbzMMpBOKZ4GKIoojDnprccZtJ9O7RA2Ui1bPS61Kx orXBi4+JxCwVICmPv2Gatq6cFZ+RtHKUKEqxbW9FcklpDODyQtvJWTv3Rbxj/OzvdZEZ /2Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=pDxqmIWm; 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id b23-20020a170906039700b00956f9b9ee73si2683901eja.938.2023.05.06.05.58.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 May 2023 05:58:17 -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=fail header.i=@nextmovesoftware.com header.s=default header.b=pDxqmIWm; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 731463857345 for ; Sat, 6 May 2023 12:58:06 +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 D656A3858D1E for ; Sat, 6 May 2023 12:57:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D656A3858D1E 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:To:From:Sender:Reply-To:Cc: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=vLeTm7heDnTbdYrQuPVrsw/vnlqogmWRXIX0zteqSwQ=; b=pDxqmIWmnNITmoEKTQrLNwvKs8 q8MfvPAsl4qhJ+BhOyRKpSLcQ5PeBXl4Ll1X+RD4uqMEIVxLbCyU3rcoUjPpfG9dkJlT4PFG0O2fS 2G5FbrWnAih2RjZ5ngzSk/VgGvE3iMi9QusARmZ2HM6zEUNuMNE9y4ofXvcNifqFl5b+3O+um6WpK LHTZth1W9ihJTgmkZ9+XqpoKid8cmYLwpSKLAHP3EPI7dHnQ81Tz+BeTcgWqkjNMhdolKNH2h89wh knWA682rwTxmh7t/ko0wxerSc80B3IbghC562bcUlJnAFX+DJudvdBOzt8PaROQQgoyS0iGwbStBp 5NY5bgJQ==; Received: from host86-169-41-81.range86-169.btcentralplus.com ([86.169.41.81]:49869 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 1pvHTo-0005tA-3B for gcc-patches@gcc.gnu.org; Sat, 06 May 2023 08:57:41 -0400 From: "Roger Sayle" To: "'GCC Patches'" Subject: [PATCH] Don't call emit_clobber in lower-subreg.cc's resolve_simple_move. Date: Sat, 6 May 2023 13:57:38 +0100 Message-ID: <009901d9801a$57573ba0$0605b2e0$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdmAGUner1JuIPK+Qwu6LE549LbUKA== 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 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765149662347809084?= X-GMAIL-MSGID: =?utf-8?q?1765149662347809084?= Following up on posts/reviews by Segher and Uros, there's some question over why the middle-end's lower subreg pass emits a clobber (of a multi-word register) into the instruction stream before emitting the sequence of moves of the word-sized parts. This clobber interferes with (LRA) register allocation, preventing the multi-word pseudo to remain in the same hard registers. This patch eliminates this (presumably superfluous) clobber and thereby improves register allocation. A concrete example of the observed improvement is PR target/43644. For the test case: __int128 foo(__int128 x, __int128 y) { return x+y; } on x86_64-pc-linux-gnu, gcc -O2 currently generates: foo: movq %rsi, %rax movq %rdi, %r8 movq %rax, %rdi movq %rdx, %rax movq %rcx, %rdx addq %r8, %rax adcq %rdi, %rdx ret with this patch, we now generate the much improved: foo: movq %rdx, %rax movq %rcx, %rdx addq %rdi, %rax adcq %rsi, %rdx ret 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-05-06 Roger Sayle gcc/ChangeLog PR target/43644 * lower-subreg.cc (resolve_simple_move): Don't emit a clobber immediately before moving a multi-word register by parts. gcc/testsuite/ChangeLog PR target/43644 * gcc.target/i386/pr43644.c: New test case. Thanks in advance, Roger diff --git a/gcc/lower-subreg.cc b/gcc/lower-subreg.cc index 81fc5380..7c9cc3c 100644 --- a/gcc/lower-subreg.cc +++ b/gcc/lower-subreg.cc @@ -1086,9 +1086,6 @@ resolve_simple_move (rtx set, rtx_insn *insn) { unsigned int i; - if (REG_P (dest) && !HARD_REGISTER_NUM_P (REGNO (dest))) - emit_clobber (dest); - for (i = 0; i < words; ++i) { rtx t = simplify_gen_subreg_concatn (word_mode, dest, diff --git a/gcc/testsuite/gcc.target/i386/pr43644.c b/gcc/testsuite/gcc.target/i386/pr43644.c new file mode 100644 index 0000000..ffdf31c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr43644.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2" } */ + +__int128 foo(__int128 x, __int128 y) +{ + return x+y; +} + +/* { dg-final { scan-assembler-times "movq" 2 } } */ +/* { dg-final { scan-assembler-not "push" } } */ +/* { dg-final { scan-assembler-not "pop" } } */