From patchwork Sun Jun 16 07:20:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Xue OS X-Patchwork-Id: 1948262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.a=rsa-sha256 header.s=selector2 header.b=D/ntsra0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W24FS2dLdz20Ws for ; Sun, 16 Jun 2024 17:21:30 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2AF083858C32 for ; Sun, 16 Jun 2024 07:21:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20705.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::705]) by sourceware.org (Postfix) with ESMTPS id 67DF73858D26 for ; Sun, 16 Jun 2024 07:21:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 67DF73858D26 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=os.amperecomputing.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=os.amperecomputing.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 67DF73858D26 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f400:7e88::705 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1718522466; cv=pass; b=UFYxBxDFGvl6seKOUfMN0wUbpcs6GP3GCXBeDgGzWUaCZpioY71MIV3Hs8YU4Qub05V02URrMcOnSNUthW4CKwd23v60uZ30uwuzk/mgjhcUzQygDQB3XphxJRpcFeDf2CIbrEmo2SyceQL0GFpCfylTBt7VAIUvpb0NsSiGdCo= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1718522466; c=relaxed/simple; bh=1DC6i/m7eEZX+QNfiE9Ah2xNfUiFv9cTbw8/AGxacjk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GtT62OV/4SEXfnS1foutPRz6FXJ+bhHu7ngNtTmFoyknyXKwt+1tZLAqvMR2j/oHtB5SPVlwUHISwJjf1BslYBzM31LWZKwk6wogFRywXwPnvOtRwRoF/GUOhw24QQc8e39G+tNQfihP1JNBJ4Ai/BXNHD3gfm1TexPxhoDVtWg= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BZmIsOcMVW5DDZeYgfZLRepEi5+etgbJ63S/2QJYepKkvU6LWShtgj9AdqoiRzzTTWe0yXLZSWHl3VXsdfpVMsDl7iWgfw96hWXjr/h3120iC+G/VwApB+glcMdqFtcCTGJle1hwzzkwUDDr0q3ezk6VIrstGSvBj5N7MIxzGssma9PIverSKNj9c1jsfFmIdTiZiBhr3wT7O82oBv2GCuK/UjeiuIn3lIXD+9GHvhIHx60PWO0z9TzOmg9Oe3e8sBtVBqqvMqxO0rSmkFeJCBVTRjfEVw2fqabYOMbFJSkGJy9wOzmE/3XeHM8Z5ur/La6JV/q2raXQ/8VN1fW7hg== 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=2vfLCQE2xaDaMRdlxI5kuE7yW40x5OZKuNC6WAmg9/s=; b=Tiwe8JRVbH+u3vM16sSyLvpDPUyuOMsi1Q5Vgv16k1dsIidQ+sfKwjGX+tkAr8CzZMNd9QxLy9S7q16sQuXeGYXXy9lm5OesAKAKQQMZ5nSZ5eSwSAkACYE3RN+wTbyVIYTBfpigIcZ+GwUaBULOVSwh6I6POboN65as2FnvxKW+oF4eHJcjArZGnRtZruVdD8it9fbqJ4wurWESKslZPzwfiBBtTj60PUaWFMzHgRPssrqleqtb7bdUcbclSZVANbSBcicmjAKzGEp7XMhmOqOtREdmy1OMGdaPR5kxt5nHD/806GH6XuQa7ZGKp9G0k79pWoGLxT8W/qlhUJA9sQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2vfLCQE2xaDaMRdlxI5kuE7yW40x5OZKuNC6WAmg9/s=; b=D/ntsra0bJtc2G9Er/k5tlFPBwTy5hoA3UnYbhn2EldUmgiQzdc6VLIzcYQi2unlOwg648fe8HmzIzXVVscfSRU+Ib/qynAqsivHlEGKbdJjw++PY1hWZRtcqHY5ezDp4ATEQhilLNq4fhTuShjQ0VI4o/W68zORFHct4f6R3mg= Received: from LV2PR01MB7839.prod.exchangelabs.com (2603:10b6:408:14f::13) by SA6PR01MB9024.prod.exchangelabs.com (2603:10b6:806:42f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.28; Sun, 16 Jun 2024 07:20:57 +0000 Received: from LV2PR01MB7839.prod.exchangelabs.com ([fe80::2ac3:5a77:36fd:9c63]) by LV2PR01MB7839.prod.exchangelabs.com ([fe80::2ac3:5a77:36fd:9c63%4]) with mapi id 15.20.7677.029; Sun, 16 Jun 2024 07:20:57 +0000 From: Feng Xue OS To: Richard Biener CC: "gcc-patches@gcc.gnu.org" Subject: [PATH 1/8] vect: Add a function to check lane-reducing stmt Thread-Topic: [PATH 1/8] vect: Add a function to check lane-reducing stmt Thread-Index: AQHav7vvD1oKwveQlkSUExRcrisCgA== Date: Sun, 16 Jun 2024 07:20:57 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: msip_labels: MSIP_Label_5b82cb1d-c2e0-4643-920a-bbe7b2d7cc47_Enabled=True; MSIP_Label_5b82cb1d-c2e0-4643-920a-bbe7b2d7cc47_SiteId=3bc2b170-fd94-476d-b0ce-4229bdc904a7; MSIP_Label_5b82cb1d-c2e0-4643-920a-bbe7b2d7cc47_SetDate=2024-06-16T07:20:56.896Z; MSIP_Label_5b82cb1d-c2e0-4643-920a-bbe7b2d7cc47_Name=Confidential; MSIP_Label_5b82cb1d-c2e0-4643-920a-bbe7b2d7cc47_ContentBits=0; MSIP_Label_5b82cb1d-c2e0-4643-920a-bbe7b2d7cc47_Method=Standard; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: LV2PR01MB7839:EE_|SA6PR01MB9024:EE_ x-ms-office365-filtering-correlation-id: e79bb5b2-f4d2-4c9d-effe-08dc8dd4ddbc x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230037|366013|376011|1800799021|38070700015; x-microsoft-antispam-message-info: =?i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maFfA3pnRS?= =?iso-8859-1?q?lJCT7eLez1zaEgaYsbX/L47v1TIeoM1AyJCe4JzOxLfA0jOyolJRqPrAYsOH?= =?iso-8859-1?q?iPXR/43ffciWS23GS5aIEivfp5I352wJ5GBTxf0sLD15nwkjFkP38v2xo7ws?= =?iso-8859-1?q?1M/LwUSFhxN5bAhSdHIWYOTT/Kl0J/iAMMVvyLw0lcM+mpYT60wKmVFF9EYu?= =?iso-8859-1?q?j5I2uaPz+nwo9qVgvZVn4YxMRSOMit8nVPw6h4WeCxGTVgRRiNV1vjNlFa8y?= =?iso-8859-1?q?dJCsqsyz1z4x4v6/E/S4eD8gXoBAZWHB+YJ29b2zr5KQWOM/VdcizOcAif57?= =?iso-8859-1?q?5trGo7d1GDi9YT1+1J9QFNGi8yGXNtm+b7FcRG2aChVF+MFmOAuL5LN4oNt8?= =?iso-8859-1?q?uffC3l66JigWZYXq9ulmNlHXaB0fGCy18zKw/n0ROI61QDo1FQApXwv+ydy7?= =?iso-8859-1?q?dHr13mVtmHyvGjMMv21YIo2swb0ynF4weBhRGKY+/Y2IWAhlq8aCSy0RYNdU?= =?iso-8859-1?q?ka5Wkyqwl/Q2VYaxN/YE756dxplVP2bTgNmWuEB8hplNA1Np84Et8p/EE7F4?= =?iso-8859-1?q?ET?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:LV2PR01MB7839.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230037)(366013)(376011)(1800799021)(38070700015); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?Z3BgUytJUSfTzaWBHNSIXE/?= =?iso-8859-1?q?icXExek/uoHPFjJfv2xodH3Y+5MwqifiRwb2SPNJPeXL308xS6EsKETH/tN6?= =?iso-8859-1?q?TsKU3MEOAws/9ehEJJtdjlkGB/s3tqe/z71gTzpX92SrmzXei4pFT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1?q?vjHoa9XThJw4Fzv1irxACt6Nx6bPRRronag/4+Kd6vIB+XjoFm2foFz7qQrC?= =?iso-8859-1?q?bTQfiiSLDJrr4lW3uTBJyXrq9KZmY5D125uUidvGVxkChb240uc/v0P5BqPb?= =?iso-8859-1?q?5z79npl+XvKAlYRZSHlKpxmljDpIm285aTwFlC6YsuIrh6JgrUuFFt5kFTvI?= =?iso-8859-1?q?f4/SW3pSEoh94d8E8sEGIL6Rg/cNCsdlTNL9oYmRhcBhvQ0WqSaRQaL/fnSd?= =?iso-8859-1?q?jDUIZKWz0iVut3ukW3gDLQlKDKuhfKN9knBXOU6GKKG/YrO7hIiStmBI3b/M?= =?iso-8859-1?q?67bMGyPmAHwx7oFrq2/oKT/nQjUze+G4RB3I4h094UV+m3wHvYMSNqyxN+FN?= =?iso-8859-1?q?WNwVckjCK7EhyHhTq7BHzpx45Aw2g/4fbDBiFVdv4q5fNBPatQBPU2AJoALN?= =?iso-8859-1?q?JIjvE86wf1/mDW2STzuLpEHNlNczwG5hganFR1J0eiezTqbnOENL0gS6puQV?= =?iso-8859-1?q?GZcGZq0R0bIgZqccku46Vmovv9B9DLeWuaIjQRFqH5WgRh2q9y8IJCaI4ldw?= =?iso-8859-1?q?MAyTDDxuuX89M9Nw2wIQRdW8qwWH7d06QEF0e0uC3wPvZzCE5j6B2PPDj1TI?= =?iso-8859-1?q?SQcu8PzoN+ZSsRKmV?= MIME-Version: 1.0 X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: LV2PR01MB7839.prod.exchangelabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: e79bb5b2-f4d2-4c9d-effe-08dc8dd4ddbc X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jun 2024 07:20:57.1869 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: +TSXfUvl3xjLdTZlmWlj1lcGSMJRGjV61bnDcIzJ8SZKvowtMC0WwSL9J3C6sT0OZzyKm+/ih5ikpLIe0KuBCK/oSQ2VOUHLXiGgaQ0ruqA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA6PR01MB9024 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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.30 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 The series of patches are meant to support multiple lane-reducing reduction statements. Since the original ones conflicted with the new single-lane slp node patches, I have reworked most of the patches, and split them as small as possible, which may make code review easier. In the 1st one, I add a utility function to check if a statement is lane-reducing operation, which could simplify some existing code. Thanks, Feng --- gcc/ * tree-vectorizer.h (lane_reducing_stmt_p): New function. * tree-vect-slp.cc (vect_analyze_slp): Use new function lane_reducing_stmt_p to check statement. --- gcc/tree-vect-slp.cc | 4 +--- gcc/tree-vectorizer.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) From 0a90550b4ed3addfb2a36c40085bfa9b4bb05b7c Mon Sep 17 00:00:00 2001 From: Feng Xue Date: Sat, 15 Jun 2024 23:17:10 +0800 Subject: [PATCH 1/8] vect: Add a function to check lane-reducing stmt Add a utility function to check if a statement is lane-reducing operation, which could simplify some existing code. 2024-06-16 Feng Xue gcc/ * tree-vectorizer.h (lane_reducing_stmt_p): New function. * tree-vect-slp.cc (vect_analyze_slp): Use new function lane_reducing_stmt_p to check statement. --- gcc/tree-vect-slp.cc | 4 +--- gcc/tree-vectorizer.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 7e3d0107b4e..b4ea2e18f00 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -3919,7 +3919,6 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size) scalar_stmts.create (loop_vinfo->reductions.length ()); for (auto next_info : loop_vinfo->reductions) { - gassign *g; next_info = vect_stmt_to_vectorize (next_info); if ((STMT_VINFO_RELEVANT_P (next_info) || STMT_VINFO_LIVE_P (next_info)) @@ -3931,8 +3930,7 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size) { /* Do not discover SLP reductions combining lane-reducing ops, that will fail later. */ - if (!(g = dyn_cast (STMT_VINFO_STMT (next_info))) - || !lane_reducing_op_p (gimple_assign_rhs_code (g))) + if (!lane_reducing_stmt_p (STMT_VINFO_STMT (next_info))) scalar_stmts.quick_push (next_info); else { diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 6bb0f5c3a56..60224f4e284 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -2169,12 +2169,24 @@ vect_apply_runtime_profitability_check_p (loop_vec_info loop_vinfo) && th >= vect_vf_for_cost (loop_vinfo)); } +/* Return true if CODE is a lane-reducing opcode. */ + inline bool lane_reducing_op_p (code_helper code) { return code == DOT_PROD_EXPR || code == WIDEN_SUM_EXPR || code == SAD_EXPR; } +/* Return true if STMT is a lane-reducing statement. */ + +inline bool +lane_reducing_stmt_p (gimple *stmt) +{ + if (auto *assign = dyn_cast (stmt)) + return lane_reducing_op_p (gimple_assign_rhs_code (assign)); + return false; +} + /* Source location + hotness information. */ extern dump_user_location_t vect_location; -- 2.17.1