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: 1777984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nextmovesoftware.com header.i=@nextmovesoftware.com header.a=rsa-sha256 header.s=default header.b=pDxqmIWm; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QD6zR4Mj3z20fl for ; Sat, 6 May 2023 22:57:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8462E3858D28 for ; Sat, 6 May 2023 12:57:53 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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" } } */