From patchwork Thu Oct 5 18:20:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 1844104 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=n9dlbFCV; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=n9dlbFCV; 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 4S1fy846H9z1yqD for ; Fri, 6 Oct 2023 05:21:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 71DBB3857C43 for ; Thu, 5 Oct 2023 18:21:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2068.outbound.protection.outlook.com [40.107.6.68]) by sourceware.org (Postfix) with ESMTPS id 1EECD385B532 for ; Thu, 5 Oct 2023 18:20:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EECD385B532 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=crn6B+8L60ebwvWUITSuDXTTerX75TTMalKIg2M7vKU=; b=n9dlbFCVh4Od2WKujvAwwA0qXNUaJUezuskdjbwUhwfqoEEt9eJxKKjtXvjF55JvLJh/1PPa0wcX1TNlZp0ohXJakpJv5SCW5eOpAjA/2S/PNLPojzZxuwvsJgqis6XPeFNyCmBu0ZvjhNm+aRBPiC+qaxDJpuzKJyzVSlS9xh0= Received: from DUZPR01CA0153.eurprd01.prod.exchangelabs.com (2603:10a6:10:4bd::6) by VE1PR08MB5581.eurprd08.prod.outlook.com (2603:10a6:800:1a0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Thu, 5 Oct 2023 18:20:20 +0000 Received: from DBAEUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4bd:cafe::32) by DUZPR01CA0153.outlook.office365.com (2603:10a6:10:4bd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.29 via Frontend Transport; Thu, 5 Oct 2023 18:20:19 +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 DBAEUR03FT039.mail.protection.outlook.com (100.127.142.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.29 via Frontend Transport; Thu, 5 Oct 2023 18:20:19 +0000 Received: ("Tessian outbound ee9c7f88acf7:v211"); Thu, 05 Oct 2023 18:20:19 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: cc567970d81da9cd X-CR-MTA-TID: 64aa7808 Received: from 4df9400bd227.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9D332A99-1C63-4A7F-B88E-D0E083E1DCE3.1; Thu, 05 Oct 2023 18:20:13 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4df9400bd227.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 05 Oct 2023 18:20:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OBLkHyEwBSu8sNILWBXljcGCf4sEdgdFq1XitL6zlIdHeAmN6+qAP6wWW+T7PF/6ETUMcGfUg3d9KSbY6nvn8xvxOmMH82XP1JRQXVEpdbpYylawxKFCLNrcgnhdFcX7cV3EL7WT/HLYHkYhrn0nXXw8QsSbOORKODYm5vD47zuQvu+0IIijiqA1JfxWXitlvWpU4WdJxCJOnC8LJLNYB91ByuhnYfDDgWpZ358Ry+YRJIkENHmtBpA76+0caLC3P64N8iNX+Nm9uW8Oa6x3xsi97pPQv3KhJQePM2G1w7z7elqLQ6ER9kQ21FivibwCg4se4nIUVHfcAUznNQtp7w== 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=crn6B+8L60ebwvWUITSuDXTTerX75TTMalKIg2M7vKU=; b=DuBVg4S5fZwxyCVn3dz4no+A3+2/ZlVH1LvVILFgphhlNlTVSZDcL1+HEuIEUy4p+jqXewdu6QuHNDy/P1IZC3XeY9g1eL+HsrxiMKPm8MFMC8XRQV6gSwdnce8a09DrIqWWLjpKwRye1W+VV4uFMKF/bq5pQcT2L7lfboZCZY8AMNAlAwpdoUj63EU2gSr6OF4XtkkDrmnV+4ekfXjKQkAwB+AB6ZzE4DiYQSAdpYD7LurJnHqe2ZvjSeIvHhjyRZhN7K8fokTJBPPU5+3+xuc1wIHhFUVX/HDOFDeFXLwzkQBxqOvXRhx6m4bv6urGfw+/f3TTMMqw3QuL2RRihw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=crn6B+8L60ebwvWUITSuDXTTerX75TTMalKIg2M7vKU=; b=n9dlbFCVh4Od2WKujvAwwA0qXNUaJUezuskdjbwUhwfqoEEt9eJxKKjtXvjF55JvLJh/1PPa0wcX1TNlZp0ohXJakpJv5SCW5eOpAjA/2S/PNLPojzZxuwvsJgqis6XPeFNyCmBu0ZvjhNm+aRBPiC+qaxDJpuzKJyzVSlS9xh0= 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 DU0PR08MB9203.eurprd08.prod.outlook.com (2603:10a6:10:417::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.29; Thu, 5 Oct 2023 18:20:11 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::662f:8e26:1bf8:aaa1]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::662f:8e26:1bf8:aaa1%7]) with mapi id 15.20.6838.033; Thu, 5 Oct 2023 18:20:11 +0000 Date: Thu, 5 Oct 2023 19:20:03 +0100 From: Tamar Christina To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, rguenther@suse.de, jlaw@ventanamicro.com Subject: [PATCH]middle-end ifcvt: Allow any const IFN in conditional blocks Message-ID: Content-Disposition: inline X-ClientProxiedBy: SN4PR0501CA0064.namprd05.prod.outlook.com (2603:10b6:803:41::41) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|DU0PR08MB9203:EE_|DBAEUR03FT039:EE_|VE1PR08MB5581:EE_ X-MS-Office365-Filtering-Correlation-Id: 1bdb1445-bad1-47f4-9664-08dbc5cfbb55 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: ZtopGxM1I5KnmmH76VC+/NVJWbrd9OyePecwZL14U3PbXMVAkVva5sHfvKtMLcY6yiE2sdJT6cii73Q8wvfPKvibKg+Mo8lfvsFHEo9sfe0SNrD0H2LvRL6hP6aCY+1q03kdbdYMDXKlil3yGXVlWU8Ue+IjB7OqDtaSy6DN6YQAwFinjNmeG9POvsEoBlCvT7qbk9qh2E1q/tBhmP8nHAnQH+I6TamsVDniU3wzaYj6hep9LzMt8fqUMkevZSJKjsac8qFqejFnSx6ea68BVgOusmQCjoNtgcxNmkWvN5xC7Ux9FOm/4Y/B5FZ81O0V3rSyGP1psvvkbx7QDXboPsA9QI6mK8AVl2kQqrRZ13LOL5OvKZ6UcLtdcCs7Tbxwgi6DKcEIQOT+XIH0TZd8gs9ZiKZtXocV5Obz/x5jK/+0clCUnGUnOnOIHHkWAdQy/osVSQv+5cVm3wQbBC7f+x4FNpu4kIKVANZKmhd3zg+edAaB3R82Nvo0g4ihhsFNDyWYa2ZHLXiMgOAlgSJdSNM02ihN4ePXfCBuwTPYfBcvnxaXyf1x3e8skhaJqi5dn+Pz8m3VWj+ZOuB/BJ0qBZvFDkw1hL4BDcYTCWZKY2IRjNz74MOHKuLBLgWgCxyT95p2Z6h5IjByuQ7glNUGOQ== 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:(13230031)(39860400002)(396003)(346002)(366004)(136003)(376002)(230922051799003)(64100799003)(186009)(451199024)(1800799009)(44832011)(6916009)(316002)(8936002)(8676002)(235185007)(66476007)(66946007)(66556008)(41300700001)(83380400001)(4743002)(2906002)(5660300002)(4326008)(478600001)(6666004)(66899024)(44144004)(33964004)(6512007)(36756003)(26005)(2616005)(6486002)(6506007)(38100700002)(86362001)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9203 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: DBAEUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 09cb6e10-a478-4391-c1ac-08dbc5cfb647 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DIUH8qVSUdL9sMzhX1Te85Wle1OPs6ugfKOCAymbQtvMlYluMDO/d77kiiBWpqN013m0Qly+IOYH5g90VZnr9knFCBR5sA8lHEk8xhUGQ93A5pwQaQJaTkz1k4sWjYeVpy4sErI1JnRmqyUlSZ9kVmnmhLI3gADRa3GslGmbR8xk2OtG39+P5DHKxiIIq6btvQL6OdZlmDSRIDdQ7OGMBqB6f1ym/9I4hA8ecpR5jDQ9H+4GNtVQhLUN++Fxy0QvkhCIC9ZLqzvWiatCHtsPee6cuvaI2SNXUCvji24+8+3KxSNOvSQhysuVhtcOdzSAhpidPCvxevf0Eyi7xj5jRO1qaBj9lq0Qi5C+ZYicY8tT9qLjamtAFBp7eQ9bcFScynTV4v/bA4Z/cGQyokJ4gLFztL2fipPdyifdFpPIfTU15ien2zp2/nV/oZVFGMrIJdh7UWkbWx/03GozNSiBzc2Q3T/dfrtW7oTn/BezciBQFLKpcGu9VMsSbsX98l47aLlNISPBUMfdZPS6Xd39wEKMyKdpdhVs98dJ5sw+xNWwasCzYf5sOBFQFvvgR2vfjo026pV9DZE18QIM2l2dwAcxWjV4NyHGm4/rT9VStfK/Yz51ahkJBP5vOIs1wG2DpvRUqSmTqg7rnYtUWMcK0Gg41hV0HNaWTL18b2ieWnaWllORkTaYKx6s/2mw/dhVKNcAMo4p7+9TLbnyY+hc3tZnh/zZAnsky6oVtm1JiQ+54uT2+RqYeRVWqk4COLphrOCcCP2h1PsAvLSE8zauP+8vHa64RrfGGh4bcbvtP5o= 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:(13230031)(4636009)(136003)(346002)(396003)(39850400004)(376002)(230922051799003)(64100799003)(82310400011)(451199024)(186009)(1800799009)(46966006)(40470700004)(36840700001)(47076005)(2906002)(44832011)(6666004)(235185007)(8676002)(8936002)(83380400001)(4326008)(5660300002)(81166007)(86362001)(36860700001)(36756003)(41300700001)(70206006)(26005)(2616005)(4743002)(336012)(70586007)(316002)(356005)(82740400003)(66899024)(40480700001)(44144004)(33964004)(478600001)(6506007)(6916009)(40460700003)(6512007)(107886003)(6486002)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2023 18:20:19.4907 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1bdb1445-bad1-47f4-9664-08dbc5cfbb55 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: DBAEUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5581 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, TXREP, T_SPF_TEMPERROR, UNPARSEABLE_RELAY, URIBL_BLOCKED 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 Hi All, When ifcvt was initially added masking was not a thing and as such it was rather conservative in what it supported. For builtins it only allowed C99 builtin functions which it knew it can fold away. These days the vectorizer is able to deal with needing to mask IFNs itself. vectorizable_call is able vectorize the IFN by emitting a VEC_PERM_EXPR after the operation to emulate the masking. This is then used by match.pd to conver the IFN into a masked variant if it's available. For these reasons the restriction in ifconvert is no longer require and we needless block vectorization when we can effectively handle the operations. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Note: This patch is part of a testseries and tests for it are added in the AArch64 patch that adds supports for the optab. Ok for master? Thanks, Tamar gcc/ChangeLog: PR tree-optimization/109154 * tree-if-conv.cc (if_convertible_stmt_p): Allow any const IFN. --- inline copy of patch -- diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc index a8c915913aed267edfb3ebd2c530aeca7cf51832..f76e0d8f2e6e0f59073fa8484b0b2c7a6cdc9783 100644 --- diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc index a8c915913aed267edfb3ebd2c530aeca7cf51832..f76e0d8f2e6e0f59073fa8484b0b2c7a6cdc9783 100644 --- a/gcc/tree-if-conv.cc +++ b/gcc/tree-if-conv.cc @@ -1129,6 +1129,16 @@ if_convertible_stmt_p (gimple *stmt, vec refs) return true; } } + + /* There are some IFN_s that are used to replace builtins but have the + same semantics. Even if MASK_CALL cannot handle them vectorable_call + will insert the proper selection, so do not block conversion. */ + int flags = gimple_call_flags (stmt); + if ((flags & ECF_CONST) + && !(flags & ECF_LOOPING_CONST_OR_PURE) + && gimple_call_combined_fn (stmt) != CFN_LAST) + return true; + return false; } --- a/gcc/tree-if-conv.cc +++ b/gcc/tree-if-conv.cc @@ -1129,6 +1129,16 @@ if_convertible_stmt_p (gimple *stmt, vec refs) return true; } } + + /* There are some IFN_s that are used to replace builtins but have the + same semantics. Even if MASK_CALL cannot handle them vectorable_call + will insert the proper selection, so do not block conversion. */ + int flags = gimple_call_flags (stmt); + if ((flags & ECF_CONST) + && !(flags & ECF_LOOPING_CONST_OR_PURE) + && gimple_call_combined_fn (stmt) != CFN_LAST) + return true; + return false; }