From patchwork Wed Jun 14 05:57:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 107706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1022258vqr; Tue, 13 Jun 2023 22:58:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ40lxAFJw7egMx9RaWLA7Z3kcdLSGY5XtkthSrdl4cxtbCcBu3F5ERlpem68oSKnX30a3xx X-Received: by 2002:a17:906:9b84:b0:982:227e:1a16 with SMTP id dd4-20020a1709069b8400b00982227e1a16mr7863544ejc.13.1686722308530; Tue, 13 Jun 2023 22:58:28 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id kq19-20020a170906abd300b00965cf8f1be1si5338421ejb.617.2023.06.13.22.58.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 22:58:28 -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=kZLaPcO4; arc=fail (signature failed); 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 365A13858421 for ; Wed, 14 Jun 2023 05:58:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 365A13858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686722307; bh=wp47N0/i0ILjSUjqFrZibDRppGZB9CxqRsUKWQ5sLBM=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=kZLaPcO4l7mwD5NfJNFfdt73Ks1mQKb24qRaSdLjm+bma8KPXijvWsqmjEI41gcGQ Gzjz2uGfSfcOukY0A7b63j2a5NDqNkTj/2OFqYyaWZ80xAEqYBqZoReDic6uc9gYhk M/Y2+O3xMESZtQq5WOz/ZXIs9f3rvDZ9sb2EiMDc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2059.outbound.protection.outlook.com [40.107.13.59]) by sourceware.org (Postfix) with ESMTPS id E85C73858C53 for ; Wed, 14 Jun 2023 05:57:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E85C73858C53 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gKIJgsJcBl979UVYYdfAeaV1SluTNViLwz8tk9lwtSRt8XtyaEuVUY7uRIJRGSUGLHVyKgEN1h8DqTqcwfOkq40VdZ6VOfMcGar07oqhoByp5iTmBPWTx1Xu8YR/abh56ZoNFUfeuKpYmTNziasGTzuK4M3ZTPN+ehKNjSltVyo6kmjTgq6tTzVapNEjPTowVIo13MZmVzmB9uNxszdx2IZ2QEVA3wU3azt6F7pfCvpQWm6wluEqEKbKNz2dm/MWkskLgnybs7oqTJ9ebsZWN7uAsv5SK5vtt49BEVnZwXh7/EQa9ioNth2OVjSyM7oqOBaGlk2Vho2ISMtxPpnhbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wp47N0/i0ILjSUjqFrZibDRppGZB9CxqRsUKWQ5sLBM=; b=dgecmROXAWUjk1C94+s36uw/HtIYsEZYmH/62LfdvZb4fsra5nW39S5/WM25nETOVtKF0wUMnL7W2a2VzN4T265huDmuQt0uzxHawf2E9Jiq/fq9j6jTY7tM1eLc38y+72DqjSV6i7ZQ12D62/p0mf09NRWZFej1JIYbzrG0GsC2UXiPdPmY5VEdg5Clwx4dR9YR/Snp2lw634GB4fB9Q1cn5btSV2WGRmz4HCuIX8kLZQANbbPq8YMwRajLxsQl/DcVP2fLRKq3WMKKJQwI6jAnPeZQJgSnJ4VmOpuJu8NsXHObOvh3/8Ndf/MU2+N8p9trhRWHWBId7GhsbveJsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by GVXPR04MB9902.eurprd04.prod.outlook.com (2603:10a6:150:116::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Wed, 14 Jun 2023 05:57:41 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::e442:306f:7711:e24c]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::e442:306f:7711:e24c%5]) with mapi id 15.20.6455.039; Wed, 14 Jun 2023 05:57:40 +0000 Message-ID: <48be2ae1-66d7-f87f-5997-b5307bd25fbc@suse.com> Date: Wed, 14 Jun 2023 07:57:38 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Content-Language: en-US To: "gcc-patches@gcc.gnu.org" Cc: Kirill Yukhin , Hongtao Liu Subject: [PATCH] x86: make better use of VBROADCASTSS / VPBROADCASTD X-ClientProxiedBy: FR3P281CA0155.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::16) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|GVXPR04MB9902:EE_ X-MS-Office365-Filtering-Correlation-Id: a8ce4d66-f929-476e-6b8f-08db6c9c4399 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yH7MCzLACWJFeEpBTuAvxQNgGploRmf1iPfMktECGkFGw3s1TusGtHnOt47oMLk4WarmkQG/jmtxhHS39gYDCrGKGzdEBKxfVhWzLJMDjBZdjg4qHS6pfPQkyFzGAYb3q8PQOAu4A0TvjLcwF03ClP9S2wPxOwzTDAPtdLL3WdjywXKsFRENv4aVvFIV06nXpYxiibPdyjqey/z6RoVAsglY7DA6zd2tn41k9Tw27teEvdj8eIlesHR19qhx3uoOVNKalDrnirAAO5FOQ/DSonNbzCCvRk07cM++O+cHfubneWIWph9Hx5Q/dJDG1gZ2hRyS8PeIIjW0Dzy1Je/PtYFkZ/2FIepeUlQzKZCvVXjAAdxiLw9jkE32mzfVMrSlwdHGMXyw+tPb9NTJGm+tjejLnNHQojJD2rrSV0r71leTyleVXQgPD2cTAJSQndBE25Fd2DIA0u3M6PeWpVfVEv+YWgSwA9jpL0ZpZDfyiOfTBVDPAoLT/SIKgE7V4OJl+0O2Q/UN2UIg7/1GXEb9SLOYcG4mVY3fwRVppziK8W2KW6WhBoDSdWMcCvolKkj4hoz7FKJ856DdH2CjuP49SY6x47Ov+2oVkz0aXAdCNUb2pKqMAFSDrA1iiWw9W9XvJ7lP5YMMDH9psQymy3wAaQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6560.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(366004)(136003)(396003)(346002)(39860400002)(376002)(451199021)(4326008)(6916009)(66476007)(316002)(31686004)(41300700001)(186003)(54906003)(2906002)(5660300002)(66556008)(478600001)(8676002)(8936002)(66946007)(6486002)(6506007)(6512007)(26005)(36756003)(86362001)(2616005)(38100700002)(31696002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?NSWb/NHn2r6YI3q5YrzBgFlD504D?= =?utf-8?q?PO87zOlIpn0M3ig3tKLJp68ydtfhkaVXknYEzWZqlgLg6tL+f7lAx1uB42jbXOz3z?= =?utf-8?q?/FV5ss2dU7BgCeUqUKrNPC7zxgrNg/vR2bFjmfnt6xn3OYC3nDU4CxZiuNWJK2qtH?= =?utf-8?q?kvCGHWsYygIYA/bcDKCmA0RRNq/rbfXKf2DzWCRHt24wsjthRTGfzQmhDc8XRUMbJ?= =?utf-8?q?vVQDcz1FNSnoXv8LdWVfVS+IbWiG35xavg2DqHyiqW7X0eoFHU2uLZdI+7zRSHD36?= =?utf-8?q?Cz9Lz1tciu2nulDwwvxNTDbq512D1TiR9vCGZGpRRLJ8pmzVh5VmqGnCF5J3L9hAf?= =?utf-8?q?pICj86v+F5J9waZm23wotp35riYTKIxnuHjIWmFWe9YkP4OO8ru3emokpY14T9IZ/?= =?utf-8?q?0Hvkh6O8QLOOcEaWSAenzXYsP+PGif0ggd7PdF9kD8CPyNCIzJ+e0/+wdEQjVbGmK?= =?utf-8?q?L26Oa+8iYD2/xiHsLrWGRuJWfFSzIEV06l/Yml1nQwkQJFZcSuz1UpiV+pkAU+MDd?= =?utf-8?q?CASSNPaG7/YfRjOCyFOid9TYnZR92TWK2QT6pyznKobIFG3/t44XeO030S9hTZLx/?= =?utf-8?q?gyAYNj1VYbM9B9O4Jyloi7vvbx1SSaRTVcRo6zq0V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ptciaKkXaks2Hwba+ovkM6ROv7cV6oRPJ6?= =?utf-8?q?VK1lqrtbJqbY?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8ce4d66-f929-476e-6b8f-08db6c9c4399 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 05:57:40.8901 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vv/kHFaK5Fh5abeyAGGWirM+XvuXvHsWcE91kUelpu88UDVbS0FjYFEYsIPAp2AsKOtDDmZdkmG82Z43l1lqaw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB9902 X-Spam-Status: No, score=-3027.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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: , X-Patchwork-Original-From: Jan Beulich via Gcc-patches From: Jan Beulich Reply-To: Jan Beulich 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?1768656531248137312?= X-GMAIL-MSGID: =?utf-8?q?1768656531248137312?= ... in vec_dupv4sf / *vec_dupv4si. The respective broadcast insns are never longer (yet sometimes shorter) than the corresponding VSHUFPS / VPSHUFD, due to the immediate operand of the shuffle insns balancing the need for VEX3 in the broadcast ones. When EVEX encoding is required the broadcast insns are always shorter. Add two new alternatives each, one covering the AVX2 case and one covering AVX512. gcc/ * config/i386/sse.md (vec_dupv4sf): New AVX2 and AVX512F alternatives using vbroadcastss. (*vec_dupv4si): New AVX2 and AVX512F alternatives using vpbroadcastd. --- I'm working from the assumption that the isa attributes to the original 1st and 2nd alternatives don't need further restricting (to sse2_noavx2 or avx_noavx2 as applicable), as the new earlier alternatives cover all operand forms already when at least AVX2 is enabled. Isn't prefix_extra use bogus here? What extra prefix does vbroadcastss use? (Same further down in *vec_dupv4si and avx2_vbroadcasti128_ and elsewhere.) Is use of Yv for the source operand really necessary in *vec_dupv4si? I.e. would scalar integer values be put in XMM{16...31} when AVX512VL isn't enabled? If so (*movsi_internal / *movdi_internal suggest they might), wouldn't *vec_dupv2di need to use Yv as well in its 3rd alternative (or just m, as Yv is already covered by the 2nd one)? --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -25798,38 +25798,42 @@ (const_int 1)))]) (define_insn "vec_dupv4sf" - [(set (match_operand:V4SF 0 "register_operand" "=v,v,x") + [(set (match_operand:V4SF 0 "register_operand" "=Yv,v,v,v,x") (vec_duplicate:V4SF - (match_operand:SF 1 "nonimmediate_operand" "Yv,m,0")))] + (match_operand:SF 1 "nonimmediate_operand" "v,vm,Yv,m,0")))] "TARGET_SSE" "@ + vbroadcastss\t{%1, %0|%0, %1} + vbroadcastss\t{%1, %g0|%g0, %1} vshufps\t{$0, %1, %1, %0|%0, %1, %1, 0} vbroadcastss\t{%1, %0|%0, %1} shufps\t{$0, %0, %0|%0, %0, 0}" - [(set_attr "isa" "avx,avx,noavx") - (set_attr "type" "sseshuf1,ssemov,sseshuf1") - (set_attr "length_immediate" "1,0,1") - (set_attr "prefix_extra" "0,1,*") - (set_attr "prefix" "maybe_evex,maybe_evex,orig") - (set_attr "mode" "V4SF")]) + [(set_attr "isa" "avx2,avx512f,avx,avx,noavx") + (set_attr "type" "ssemov,ssemov,sseshuf1,ssemov,sseshuf1") + (set_attr "length_immediate" "0,0,1,0,1") + (set_attr "prefix_extra" "*,*,0,1,*") + (set_attr "prefix" "maybe_evex,evex,maybe_evex,maybe_evex,orig") + (set_attr "mode" "V4SF,V16SF,V4SF,V4SF,V4SF")]) (define_insn "*vec_dupv4si" - [(set (match_operand:V4SI 0 "register_operand" "=v,v,x") + [(set (match_operand:V4SI 0 "register_operand" "=Yv,v,v,v,x") (vec_duplicate:V4SI - (match_operand:SI 1 "nonimmediate_operand" "Yv,m,0")))] + (match_operand:SI 1 "nonimmediate_operand" "vm,vm,Yv,m,0")))] "TARGET_SSE" "@ + vpbroadcastd\t{%1, %0|%0, %1} + vpbroadcastd\t{%1, %g0|%g0, %1} %vpshufd\t{$0, %1, %0|%0, %1, 0} vbroadcastss\t{%1, %0|%0, %1} shufps\t{$0, %0, %0|%0, %0, 0}" - [(set_attr "isa" "sse2,avx,noavx") - (set_attr "type" "sselog1,ssemov,sselog1") - (set_attr "length_immediate" "1,0,1") - (set_attr "prefix_extra" "0,1,*") - (set_attr "prefix" "maybe_vex,maybe_evex,orig") - (set_attr "mode" "TI,V4SF,V4SF") + [(set_attr "isa" "avx2,avx512f,sse2,avx,noavx") + (set_attr "type" "ssemov,ssemov,sselog1,ssemov,sselog1") + (set_attr "length_immediate" "0,0,1,0,1") + (set_attr "prefix_extra" "*,*,0,1,*") + (set_attr "prefix" "maybe_evex,evex,maybe_vex,maybe_evex,orig") + (set_attr "mode" "TI,XI,TI,V4SF,V4SF") (set (attr "preferred_for_speed") - (cond [(eq_attr "alternative" "1") + (cond [(eq_attr "alternative" "3") (symbol_ref "!TARGET_INTER_UNIT_MOVES_TO_VEC") ] (symbol_ref "true")))])