From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 12FD43858C2B for ; Wed, 19 Jul 2023 20:07:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 12FD43858C2B 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=q9A1tLFF/7k0IyuDukd5iLg4kaaBs+OcF3RqHH+2Np0=; b=hw/AJMZwnwjjk0zAkMRiKWMfaG OTlDd0J4jnNmtwQIx7Xy0ZdipF8mk8bIfuoaSYYAJ1Daf4fJMDqQIomNT4XgbdX3WBExFNtf1yKG/ 59gebDw8FOEzIxfds+XZwhybMLjQwyP5kZElah50tuEEtpHleyYBIiN0TOyDISrGkvAJdZtB8zC5A EJw2mwkI6ewx2KqKsTw2rjtadXQv8y7GjPf7eVSmK64f+WLNrhF/7RFVrjN4nsge2zioyBUaZh5IL Gf6ggeMiSXY45UpcKtF1uASBA3nAE1/M5qJ7fvu7nVFP/kRjy8MGJPaTt53omc6wCsYu1OZi2ykeR /v1UThlQ==; Received: from host86-161-68-50.range86-161.btcentralplus.com ([86.161.68.50]:58324 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 1qMDSM-0005m3-1R; Wed, 19 Jul 2023 16:07:30 -0400 From: "Roger Sayle" To: Cc: "'Uros Bizjak'" Subject: [x86_64 PATCH] More TImode parameter passing improvements. Date: Wed, 19 Jul 2023 21:07:29 +0100 Message-ID: <009201d9ba7c$a64374d0$f2ca5e70$@nextmovesoftware.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0093_01D9BA85.0807DCD0" X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adm6ezcOzKiKzwUtQCqTWeXKIg6ltw== 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.9 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 List-Id: This is a multipart message in MIME format. ------=_NextPart_000_0093_01D9BA85.0807DCD0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This patch is the next piece of a solution to the x86_64 ABI issues in PR 88873. This splits the *concat3_3 define_insn_and_split into two patterns, a TARGET_64BIT *concatditi3_3 and a !TARGET_64BIT *concatsidi3_3. This allows us to add an additional alternative to the the 64-bit version, enabling the register allocator to perform this operation using SSE registers, which is implemented/split after reload using vec_concatv2di. To demonstrate the improvement, the test case from PR88873: typedef struct { double x, y; } s_t; s_t foo (s_t a, s_t b, s_t c) { return (s_t){ __builtin_fma(a.x, b.x, c.x), __builtin_fma (a.y, b.y, c.y) }; } when compiled with -O2 -march=cascadelake, currently generates: foo: vmovq %xmm2, -56(%rsp) movq -56(%rsp), %rax vmovq %xmm3, -48(%rsp) vmovq %xmm4, -40(%rsp) movq -48(%rsp), %rcx vmovq %xmm5, -32(%rsp) vmovq %rax, %xmm6 movq -40(%rsp), %rax movq -32(%rsp), %rsi vpinsrq $1, %rcx, %xmm6, %xmm6 vmovq %xmm0, -24(%rsp) vmovq %rax, %xmm7 vmovq %xmm1, -16(%rsp) vmovapd %xmm6, %xmm2 vpinsrq $1, %rsi, %xmm7, %xmm7 vfmadd132pd -24(%rsp), %xmm7, %xmm2 vmovapd %xmm2, -56(%rsp) vmovsd -48(%rsp), %xmm1 vmovsd -56(%rsp), %xmm0 ret with this change, we avoid many of the reloads via memory, foo: vpunpcklqdq %xmm3, %xmm2, %xmm7 vpunpcklqdq %xmm1, %xmm0, %xmm6 vpunpcklqdq %xmm5, %xmm4, %xmm2 vmovdqa %xmm7, -24(%rsp) vmovdqa %xmm6, %xmm1 movq -16(%rsp), %rax vpinsrq $1, %rax, %xmm7, %xmm4 vmovapd %xmm4, %xmm6 vfmadd132pd %xmm1, %xmm2, %xmm6 vmovapd %xmm6, -24(%rsp) vmovsd -16(%rsp), %xmm1 vmovsd -24(%rsp), %xmm0 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-07-19 Roger Sayle gcc/ChangeLog * config/i386/i386-expand.cc (ix86_expand_move): Don't call force_reg, to use SUBREG rather than create a new pseudo when inserting DFmode fields into TImode with insvti_{high,low}part. (*concat3_3): Split into two define_insn_and_split... (*concatditi3_3): 64-bit implementation. Provide alternative that allows register allocation to use SSE registers that is split into vec_concatv2di after reload. (*concatsidi3_3): 32-bit implementation. gcc/testsuite/ChangeLog * gcc.target/i386/pr88873.c: New test case. Thanks in advance, Roger -- ------=_NextPart_000_0093_01D9BA85.0807DCD0 Content-Type: text/plain; name="patchti5.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patchti5.txt" diff --git a/gcc/config/i386/i386-expand.cc = b/gcc/config/i386/i386-expand.cc=0A= index f9b0dc6..9c3febe 100644=0A= --- a/gcc/config/i386/i386-expand.cc=0A= +++ b/gcc/config/i386/i386-expand.cc=0A= @@ -558,7 +558,7 @@ ix86_expand_move (machine_mode mode, rtx operands[])=0A= op0 =3D SUBREG_REG (op0);=0A= tmp =3D gen_rtx_AND (TImode, copy_rtx (op0), tmp);=0A= if (mode =3D=3D DFmode)=0A= - op1 =3D force_reg (DImode, gen_lowpart (DImode, op1));=0A= + op1 =3D gen_lowpart (DImode, op1);=0A= op1 =3D gen_rtx_ZERO_EXTEND (TImode, op1);=0A= op1 =3D gen_rtx_IOR (TImode, tmp, op1);=0A= }=0A= @@ -570,7 +570,7 @@ ix86_expand_move (machine_mode mode, rtx operands[])=0A= op0 =3D SUBREG_REG (op0);=0A= tmp =3D gen_rtx_AND (TImode, copy_rtx (op0), tmp);=0A= if (mode =3D=3D DFmode)=0A= - op1 =3D force_reg (DImode, gen_lowpart (DImode, op1));=0A= + op1 =3D gen_lowpart (DImode, op1);=0A= op1 =3D gen_rtx_ZERO_EXTEND (TImode, op1);=0A= op1 =3D gen_rtx_ASHIFT (TImode, op1, GEN_INT (64));=0A= op1 =3D gen_rtx_IOR (TImode, tmp, op1);=0A= diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md=0A= index 47ea050..8c54aa5 100644=0A= --- a/gcc/config/i386/i386.md=0A= +++ b/gcc/config/i386/i386.md=0A= @@ -12408,21 +12408,47 @@=0A= DONE;=0A= })=0A= =0A= -(define_insn_and_split "*concat3_3"=0A= - [(set (match_operand: 0 "nonimmediate_operand" "=3Dro,r,r,&r")=0A= - (any_or_plus:=0A= - (ashift:=0A= - (zero_extend:=0A= - (match_operand:DWIH 1 "nonimmediate_operand" "r,m,r,m"))=0A= +(define_insn_and_split "*concatditi3_3"=0A= + [(set (match_operand:TI 0 "nonimmediate_operand" "=3Dro,r,r,&r,x")=0A= + (any_or_plus:TI=0A= + (ashift:TI=0A= + (zero_extend:TI=0A= + (match_operand:DI 1 "nonimmediate_operand" "r,m,r,m,x"))=0A= (match_operand:QI 2 "const_int_operand"))=0A= - (zero_extend:=0A= - (match_operand:DWIH 3 "nonimmediate_operand" "r,r,m,m"))))]=0A= - "INTVAL (operands[2]) =3D=3D * BITS_PER_UNIT"=0A= + (zero_extend:TI=0A= + (match_operand:DI 3 "nonimmediate_operand" "r,r,m,m,0"))))]=0A= + "TARGET_64BIT=0A= + && INTVAL (operands[2]) =3D=3D 64"=0A= + "#"=0A= + "&& reload_completed"=0A= + [(const_int 0)]=0A= +{=0A= + if (SSE_REG_P (operands[0]))=0A= + {=0A= + rtx tmp =3D gen_rtx_REG (V2DImode, REGNO (operands[0]));=0A= + emit_insn (gen_vec_concatv2di (tmp, operands[3], operands[1]));=0A= + }=0A= + else=0A= + split_double_concat (TImode, operands[0], operands[3], operands[1]);=0A= + DONE;=0A= +})=0A= +=0A= +(define_insn_and_split "*concatsidi3_3"=0A= + [(set (match_operand:DI 0 "nonimmediate_operand" "=3Dro,r,r,&r")=0A= + (any_or_plus:DI=0A= + (ashift:DI=0A= + (zero_extend:DI=0A= + (match_operand:SI 1 "nonimmediate_operand" "r,m,r,m"))=0A= + (match_operand:QI 2 "const_int_operand"))=0A= + (zero_extend:DI=0A= + (match_operand:SI 3 "nonimmediate_operand" "r,r,m,m"))))]=0A= + "!TARGET_64BIT=0A= + && INTVAL (operands[2]) =3D=3D 32"=0A= "#"=0A= "&& reload_completed"=0A= [(const_int 0)]=0A= {=0A= - split_double_concat (mode, operands[0], operands[3], = operands[1]);=0A= + split_double_concat (DImode, operands[0], operands[3], operands[1]);=0A= DONE;=0A= })=0A= =0A= ------=_NextPart_000_0093_01D9BA85.0807DCD0--