From patchwork Mon Oct 31 11:57:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 59646 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E4DD385DC00 for ; Mon, 31 Oct 2022 11:58:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E4DD385DC00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667217490; bh=zCFtO2cA+eRp9a8JuRzQLFoJcbjwpEihJmCNQxZU1IU=; h=Date:To:Subject:In-Reply-To:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=lijaPM63vqSj5qu7C/41jAQvGWU7QCfku4RPvECb0GiaHQCS+6u8LxJHD0ntvnhdk gmeT5obQjN3MFusucNs/xTnOicoIHb+zGaNYLIGT4WShhMYZQC8Tz7f0UUiOzRhqsv bg9WWFkGxDcuuCl3UbsUg7smL1KMBEG8zRyrcfTM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2065.outbound.protection.outlook.com [40.107.20.65]) by sourceware.org (Postfix) with ESMTPS id BACA33854838 for ; Mon, 31 Oct 2022 11:57:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BACA33854838 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=EpgbRQc8Xt1M6Rp1bq5O62vlp0ELoMkVb6hjYsxrzEUqv6+uT+BtSh1Fxp1XS3EVl0iGOT1cumI26igwyvgb12PEg/PaIkD8JlgsHOi2zs11mgqLahDQJN3qkWWImZzo9ByzDBlsZRHrz+HZuUft7DjYi5VKGquP+3sV4QvIF+nybV9aA2r3m5VU2pgr8OuhqEEdaI4wpuMJ0OD5o1BhtDKh9RKEVtLb/OQBQi6b/978+eNHgi9rbkAhTjS92a81GZA5MEA9x9tYOlICLCj79JHIBp0MR49q8F1sW6k94CkPtcQo/AH+Uh3tK2SyP7fDJryZgPu4n6G4p1zm1xVYDQ== ARC-Message-Signature: i=2; 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=zCFtO2cA+eRp9a8JuRzQLFoJcbjwpEihJmCNQxZU1IU=; b=YDgHs/H/RCyagBFX7+SboyzFu+PN3iCRq0Q3gkGgsx7+cA2vtf959hu3lbwpRUc8+esFkNctMUXPsrK7Fa3VaE/6k0SCo1eT2jD7Qb8x85oROaf+tp98dPkvs7vJ1g/BACLUonqZn2KrpO1XMGXrA++CpFU4MDlKZ3vXXWgYqXPupmL+zQWL2E3geaoEajNwZ4AEheFJi3YLrL0dPugYtyqBmXBuNv58TaFXDrBYTpQLIZyEFiUuRNTNkP2LHPdE46l861t5sDdQmxGKzkj/onHYUqGIUxWsNjc/xdAof+XrKJViP7DE0i0JeezrVJqhGs/oepAnwjEFG6HPc5TNYg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from DB6PR0202CA0011.eurprd02.prod.outlook.com (2603:10a6:4:29::21) by PAXPR08MB6655.eurprd08.prod.outlook.com (2603:10a6:102:15d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.19; Mon, 31 Oct 2022 11:57:30 +0000 Received: from DBAEUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:29:cafe::dd) by DB6PR0202CA0011.outlook.office365.com (2603:10a6:4:29::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.16 via Frontend Transport; Mon, 31 Oct 2022 11:57:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT063.mail.protection.outlook.com (100.127.142.255) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.14 via Frontend Transport; Mon, 31 Oct 2022 11:57:30 +0000 Received: ("Tessian outbound 58faf9791229:v130"); Mon, 31 Oct 2022 11:57:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 968f3eed71563821 X-CR-MTA-TID: 64aa7808 Received: from b6e485f884c1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BABE0E2A-D6AC-4E16-AF1C-84AEA68790A2.1; Mon, 31 Oct 2022 11:57:22 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b6e485f884c1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 31 Oct 2022 11:57:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WktOn7a1MWvxHYivIuMX1XSyP9eVr6phW52k+b7cBZHYL7bcgcgqj+0Nfgzn7AkNHm9dtGWavnSiWU6o+2a33wv1DRzdPkNtGy+zbluIy6Zban0YhD0YfoZkfrmWEzOGdm4U/izBAP45DyFVZut6cq+8YUAPIrN3GaRpeocjgx94ZmRg3KJCo/J0whcpmBG72NXhwEXRFWki31IqYN/+eHmXC5F4Gfbt4EPAZ2Le9wsJyrAEtI8uAiDbImWBWKSf4tyC3hanlOaNNPcbBn1SaWYrYz3pvjtWuWp+cNF3z9aJm3/8H5/Uq3zimnYroZ0Ngg03R1wuJpHs3zRmbrJcow== 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=zCFtO2cA+eRp9a8JuRzQLFoJcbjwpEihJmCNQxZU1IU=; b=DHgZzoU3Xxk1Axn9vUCRas0d7vaqG1LX/U1zZJ3gULvCP9rUFL7gosNIADCFOakMadPj8aWAtNhivAxfDSGd84NK8hb11MzFmrB0gNzwjxZdK0zhlfjscRFvmgLgMp2M5CtlHlxsD++G2OkSGbwSqpNP/thPb8rbA1YwoR8vpaMMeaanMhcI9mZeWV/WHZxgT0z2tSo2y6Jh+slRxJ+AThRbt2kNAfTm7Wm3Q40tg20ZhKCUa1asB2hiB020dlasmyozKLl2MPepvdoBQS8RfouK4535EsLbRQtV71gUcd/gy6aX3CpwPZ7E4gE5HjN4IAMPzejEofjSxTeSiwyoZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by AS2PR08MB8717.eurprd08.prod.outlook.com (2603:10a6:20b:55d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.14; Mon, 31 Oct 2022 11:57:20 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::c57d:50c2:3502:a52]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::c57d:50c2:3502:a52%4]) with mapi id 15.20.5769.019; Mon, 31 Oct 2022 11:57:19 +0000 Date: Mon, 31 Oct 2022 11:57:12 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/8]middle-end: Recognize scalar widening reductions Message-ID: Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SA1P222CA0074.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:2c1::20) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|AS2PR08MB8717:EE_|DBAEUR03FT063:EE_|PAXPR08MB6655:EE_ X-MS-Office365-Filtering-Correlation-Id: 189bdc31-6b7c-4796-b8ef-08dabb3716aa x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 7Gq7iRX5VFNjQeqE6OCoxD1xbxRtXtwmk57Q5gqJJcjNrklN0CNKwUlblYqmr5gwDqTopDgrFe/Dd4JmrQ3VzESHWI6dQw98cegHktFcR8IvE3JyAE2RC+3vlOxgeJT/4BDrna4Vj0IhGbTeuoqYE9qlq/VFELW0N4WF7FeN8dZP9GerYguPByYylNDh36sQcrAZhZknwZxG0bruuw7LBWtHLDvDKVravzvIQou07o3aALI1vNGmKa/kN/8MFZz/POiLyggM94qge1ZycuJOMehTkF3MbkymTV2quEJorJw8pB5qqo4RBqLIOrOleNKBn/0P/GAOa0zfZq+Edo4BIYx87F96HZvcwecSkDnZOfd0b/K8RIXVZWGnoD0lC/OP00vuSrTchxdc/QxSkjINw7+VEkCKqmWQmCkDYp3Fy2Rwl9wesU/oMy8hm6Bs6d40CLLFQh0c1VBHk4fnsGvjteMtjcqg8fyDeoR5EHhBMHp2YVGJW6HhzTAFrbskuPjgTn1mk5lKhA1mI4em8ZSsKqefFL4X7XvwWV8ErYYHs6f3eQabKTCoQvv3dMdRDKr/lJWoJej8shRm2bqktfzmV04Lqo8+8AlMudd9hIYGDlUvhhTY+2FjrhvVomXyIFmJousGxIQBffBlzSYqDkeqHj7Vvv3shcYG0CGSOjweowmiv3KP27YyOx1RrUMoDUArlJz8JhJlvOBT0O0CDL2C3StOsqFzmeZEBH/NhcD8GX9IqkPvRO+2qG1YKbz1eHvjb2JwfuCH5S/XhkEjbrtTyL/nq4vD3AxdrbysUuXXWUk= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB5325.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(346002)(376002)(39860400002)(136003)(396003)(366004)(451199015)(478600001)(8676002)(38100700002)(6486002)(316002)(6666004)(86362001)(6512007)(26005)(4743002)(66476007)(4326008)(41300700001)(186003)(235185007)(2906002)(33964004)(66946007)(2616005)(8936002)(6916009)(66556008)(36756003)(5660300002)(44832011)(44144004)(6506007)(67856001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8717 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 87578d1b-655c-4f7d-f979-08dabb371055 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1RDKzcoUK+iNXv9aejZ0Wl/fgOQ6HKqumG+iTrrebVX2duuxqPyMw2j6Qqy9OYWEJ9uo7bYxVyZVwqJl1wkM/KC60A/2V8Ev9dn9OTxXhQzKnQN2R+tXNxYyGGE/mM65rC+hlQ0n9wDGL73KUonJuNlANYPBHf+bukZ/tuiPe0/4NFsAhvznatDWtd12eabE3SQb2c90Vd2aMLBQv9zYjBrAOlkBOvDZ7kmowqHhE6uwvWUD0DPKWCWR2Lz/ZVie1sbHh+57J+TAKrebd97jMn0gF9SBLkAnjFwv2B5in/lQCFKt/pj06htLPu0XEjJKEM52Fw1PePAOf+e0otJy3RDQeX2GogHtgH99C8kuwantr7BawqwjtzivxNS/Vu1VJTjeEElD5/10EEtMdIn4x5PNxm2rRG9uZiYCdUhMiR5iNrMOG8L1bFsJaueisJxOarsfx0shdUDpYs50R2DgsofmqS3Lgpb1FXOdZReRG2Rt9WwGf4bhWxqOXJGXlTQQ8AuQ5EbB75xo/EoUDc8gDPuWFY3+4RXkmuborqailB/1j6SObwuckXwUEw9KOTTsY8XVDT8WIRtAX4x+JoDnVoTN2TPF9QDGudbF2ggprMwFWsw1He+tAX0ELW//lda10Obm8x2dlXzlntNv73ZB7eNS8fZewI1H3f0P3KShPUNBRzhVvbbrd+NW7RliQfkXxoHxLhj9kTM4WgadCXTp66XmXS/q3FQcOxlEK5Vz+P7Fc7vNDrK+FVocK+23VTcj4EzQ059pLMlC8o05wtWWIi1Iz4ytJU8sI3N7fXXYm/Ky7I4Hsr5SieNE5No4NOnkFUiAUaxsKOYLo5cK2LTxGA== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230022)(4636009)(346002)(376002)(39860400002)(136003)(396003)(451199015)(46966006)(40470700004)(36840700001)(36860700001)(47076005)(86362001)(82310400005)(356005)(81166007)(82740400003)(41300700001)(2906002)(6506007)(235185007)(44832011)(8676002)(40480700001)(4326008)(70586007)(70206006)(5660300002)(8936002)(316002)(6916009)(4743002)(6512007)(40460700003)(2616005)(26005)(336012)(186003)(107886003)(6486002)(478600001)(33964004)(44144004)(6666004)(36756003)(2700100001)(67856001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2022 11:57:30.4229 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 189bdc31-6b7c-4796-b8ef-08dabb3716aa X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6655 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY 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: Tamar Christina via Gcc-patches From: Tamar Christina Reply-To: Tamar Christina Cc: nd@arm.com, rguenther@suse.de Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi All, This adds a new optab and IFNs for REDUC_PLUS_WIDEN where the resulting scalar reduction has twice the precision of the input elements. At some point in a later patch I will also teach the vectorizer to recognize this builtin once I figure out how the various bits of reductions work. For now it's generated only by the match.pd pattern. Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: * internal-fn.def (REDUC_PLUS_WIDEN): New. * doc/md.texi: Document it. * match.pd: Recognize widening plus. * optabs.def (reduc_splus_widen_scal_optab, reduc_uplus_widen_scal_optab): New. --- inline copy of patch -- diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 34825549ed4e315b07d36dc3d63bae0cc0a3932d..c08691ab4c9a4bfe55ae81e5e228a414d6242d78 100644 --- diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 34825549ed4e315b07d36dc3d63bae0cc0a3932d..c08691ab4c9a4bfe55ae81e5e228a414d6242d78 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -5284,6 +5284,20 @@ Compute the sum of the elements of a vector. The vector is operand 1, and operand 0 is the scalar result, with mode equal to the mode of the elements of the input vector. +@cindex @code{reduc_uplus_widen_scal_@var{m}} instruction pattern +@item @samp{reduc_uplus_widen_scal_@var{m}} +Compute the sum of the elements of a vector and zero-extend @var{m} to a mode +that has twice the precision of @var{m}.. The vector is operand 1, and +operand 0 is the scalar result, with mode equal to twice the precision of the +mode of the elements of the input vector. + +@cindex @code{reduc_splus_widen_scal_@var{m}} instruction pattern +@item @samp{reduc_splus_widen_scal_@var{m}} +Compute the sum of the elements of a vector and sign-extend @var{m} to a mode +that has twice the precision of @var{m}.. The vector is operand 1, and +operand 0 is the scalar result, with mode equal to twice the precision of the +mode of the elements of the input vector. + @cindex @code{reduc_and_scal_@var{m}} instruction pattern @item @samp{reduc_and_scal_@var{m}} @cindex @code{reduc_ior_scal_@var{m}} instruction pattern diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def index 5e672183f4def9d0cdc29cf12fe17e8cff928f9f..f64a8421b1087b6c0f3602dc556876b0fd15c7ad 100644 --- a/gcc/internal-fn.def +++ b/gcc/internal-fn.def @@ -215,6 +215,9 @@ DEF_INTERNAL_OPTAB_FN (RSQRT, ECF_CONST, rsqrt, unary) DEF_INTERNAL_OPTAB_FN (REDUC_PLUS, ECF_CONST | ECF_NOTHROW, reduc_plus_scal, unary) +DEF_INTERNAL_SIGNED_OPTAB_FN (REDUC_PLUS_WIDEN, ECF_CONST | ECF_NOTHROW, + first, reduc_splus_widen_scal, + reduc_uplus_widen_scal, unary) DEF_INTERNAL_SIGNED_OPTAB_FN (REDUC_MAX, ECF_CONST | ECF_NOTHROW, first, reduc_smax_scal, reduc_umax_scal, unary) DEF_INTERNAL_SIGNED_OPTAB_FN (REDUC_MIN, ECF_CONST | ECF_NOTHROW, first, diff --git a/gcc/match.pd b/gcc/match.pd index aecaa3520b36e770d11ea9a10eb18db23c0cd9f7..1d407414bee278c64c00d425d9f025c1c58d853d 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7237,6 +7237,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (ifnf (BIT_FIELD_REF:ntype { src; } { size; } { pos; })) (ifni (BIT_FIELD_REF:ntype { src; } { size; } { pos; })))))))) +/* Widening reduction conversions. */ +(simplify + (convert (IFN_REDUC_PLUS @0)) + (if (element_precision (TREE_TYPE (@0)) * 2 == element_precision (type) + && TYPE_UNSIGNED (type) == TYPE_UNSIGNED (TREE_TYPE (@0)) + && ANY_INTEGRAL_TYPE_P (type) && ANY_INTEGRAL_TYPE_P (TREE_TYPE(@0))) + (IFN_REDUC_PLUS_WIDEN @0))) + (simplify (BIT_FIELD_REF (BIT_FIELD_REF @0 @1 @2) @3 @4) (BIT_FIELD_REF @0 @3 { const_binop (PLUS_EXPR, bitsizetype, @2, @4); })) diff --git a/gcc/optabs.def b/gcc/optabs.def index a6db2342bed6baf13ecbd84112c8432c6972e6fe..9947aed67fb8a3b675cb0aab9aeb059f89644106 100644 --- a/gcc/optabs.def +++ b/gcc/optabs.def @@ -346,6 +346,8 @@ OPTAB_D (reduc_fmin_scal_optab, "reduc_fmin_scal_$a") OPTAB_D (reduc_smax_scal_optab, "reduc_smax_scal_$a") OPTAB_D (reduc_smin_scal_optab, "reduc_smin_scal_$a") OPTAB_D (reduc_plus_scal_optab, "reduc_plus_scal_$a") +OPTAB_D (reduc_splus_widen_scal_optab, "reduc_splus_widen_scal_$a") +OPTAB_D (reduc_uplus_widen_scal_optab, "reduc_uplus_widen_scal_$a") OPTAB_D (reduc_umax_scal_optab, "reduc_umax_scal_$a") OPTAB_D (reduc_umin_scal_optab, "reduc_umin_scal_$a") OPTAB_D (reduc_and_scal_optab, "reduc_and_scal_$a") --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -5284,6 +5284,20 @@ Compute the sum of the elements of a vector. The vector is operand 1, and operand 0 is the scalar result, with mode equal to the mode of the elements of the input vector. +@cindex @code{reduc_uplus_widen_scal_@var{m}} instruction pattern +@item @samp{reduc_uplus_widen_scal_@var{m}} +Compute the sum of the elements of a vector and zero-extend @var{m} to a mode +that has twice the precision of @var{m}.. The vector is operand 1, and +operand 0 is the scalar result, with mode equal to twice the precision of the +mode of the elements of the input vector. + +@cindex @code{reduc_splus_widen_scal_@var{m}} instruction pattern +@item @samp{reduc_splus_widen_scal_@var{m}} +Compute the sum of the elements of a vector and sign-extend @var{m} to a mode +that has twice the precision of @var{m}.. The vector is operand 1, and +operand 0 is the scalar result, with mode equal to twice the precision of the +mode of the elements of the input vector. + @cindex @code{reduc_and_scal_@var{m}} instruction pattern @item @samp{reduc_and_scal_@var{m}} @cindex @code{reduc_ior_scal_@var{m}} instruction pattern diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def index 5e672183f4def9d0cdc29cf12fe17e8cff928f9f..f64a8421b1087b6c0f3602dc556876b0fd15c7ad 100644 --- a/gcc/internal-fn.def +++ b/gcc/internal-fn.def @@ -215,6 +215,9 @@ DEF_INTERNAL_OPTAB_FN (RSQRT, ECF_CONST, rsqrt, unary) DEF_INTERNAL_OPTAB_FN (REDUC_PLUS, ECF_CONST | ECF_NOTHROW, reduc_plus_scal, unary) +DEF_INTERNAL_SIGNED_OPTAB_FN (REDUC_PLUS_WIDEN, ECF_CONST | ECF_NOTHROW, + first, reduc_splus_widen_scal, + reduc_uplus_widen_scal, unary) DEF_INTERNAL_SIGNED_OPTAB_FN (REDUC_MAX, ECF_CONST | ECF_NOTHROW, first, reduc_smax_scal, reduc_umax_scal, unary) DEF_INTERNAL_SIGNED_OPTAB_FN (REDUC_MIN, ECF_CONST | ECF_NOTHROW, first, diff --git a/gcc/match.pd b/gcc/match.pd index aecaa3520b36e770d11ea9a10eb18db23c0cd9f7..1d407414bee278c64c00d425d9f025c1c58d853d 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7237,6 +7237,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (ifnf (BIT_FIELD_REF:ntype { src; } { size; } { pos; })) (ifni (BIT_FIELD_REF:ntype { src; } { size; } { pos; })))))))) +/* Widening reduction conversions. */ +(simplify + (convert (IFN_REDUC_PLUS @0)) + (if (element_precision (TREE_TYPE (@0)) * 2 == element_precision (type) + && TYPE_UNSIGNED (type) == TYPE_UNSIGNED (TREE_TYPE (@0)) + && ANY_INTEGRAL_TYPE_P (type) && ANY_INTEGRAL_TYPE_P (TREE_TYPE(@0))) + (IFN_REDUC_PLUS_WIDEN @0))) + (simplify (BIT_FIELD_REF (BIT_FIELD_REF @0 @1 @2) @3 @4) (BIT_FIELD_REF @0 @3 { const_binop (PLUS_EXPR, bitsizetype, @2, @4); })) diff --git a/gcc/optabs.def b/gcc/optabs.def index a6db2342bed6baf13ecbd84112c8432c6972e6fe..9947aed67fb8a3b675cb0aab9aeb059f89644106 100644 --- a/gcc/optabs.def +++ b/gcc/optabs.def @@ -346,6 +346,8 @@ OPTAB_D (reduc_fmin_scal_optab, "reduc_fmin_scal_$a") OPTAB_D (reduc_smax_scal_optab, "reduc_smax_scal_$a") OPTAB_D (reduc_smin_scal_optab, "reduc_smin_scal_$a") OPTAB_D (reduc_plus_scal_optab, "reduc_plus_scal_$a") +OPTAB_D (reduc_splus_widen_scal_optab, "reduc_splus_widen_scal_$a") +OPTAB_D (reduc_uplus_widen_scal_optab, "reduc_uplus_widen_scal_$a") OPTAB_D (reduc_umax_scal_optab, "reduc_umax_scal_$a") OPTAB_D (reduc_umin_scal_optab, "reduc_umin_scal_$a") OPTAB_D (reduc_and_scal_optab, "reduc_and_scal_$a")