From patchwork Thu Jan 4 18:20:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 1882573 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=l/NabpAV; 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=l/NabpAV; 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 4T5ZfT1xJPz1ydd for ; Fri, 5 Jan 2024 05:21:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 43EB1385771A for ; Thu, 4 Jan 2024 18:21:19 +0000 (GMT) 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-he1eur01on2055.outbound.protection.outlook.com [40.107.13.55]) by sourceware.org (Postfix) with ESMTPS id 9250C3857BAE for ; Thu, 4 Jan 2024 18:20:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9250C3857BAE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9250C3857BAE Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.13.55 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1704392452; cv=pass; b=GGPsru76K9HnN6533m1PMH6zdFWJ/N85zTWlP/TxlyjY/CMyn3SV4n22+Bt2k8jXVgJSdsr9DPmc6l1toZ95JZth27/17gtYIersetH6IHsI8oigprNRuMweFy0uPS4sAgQb0cxjc5WFBeLm38U4bl9vbUTOyQ9guqSeN/jO7X0= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1704392452; c=relaxed/simple; bh=9W3TZTkKBOEtdFnyqsk6iR9whS0JqluLvsHNPXGQkE4=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=yAWKQ99Ba1MGyX795Z8J12apT9e4QzXeQWQ8BLrq0GSqak7co5+jV9Xcgxk+k8NZ/pKI4mgff/U9Z5bP5YUAG5SQlyumTdTEw0uxbDtgN0k1BM4H85b+grCy0F7zoOFxpg6X1/8bQp2zjMcQiCZ90HGKlYobZT8fmTzCmv53oAM= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=VfPumgVpv8LMhHsF9dDrx6HSuZ7g7EybEt8LY91ADsngN5cG8UZiDV1ZZ0v56FIHwKQMex8m10ueJLZcX65eQ0qy8jxsOh9VOfTaLCAxYbXv/Pm1G9wkyTewlf3LiEUOQXybpI5TxJh97FzVC7+UfY5kP7+bktP7vZ0zS+UvUHpDEy9neelc/A/ie0zkatHLhQV/SJvmwhOhaeRhOK1/0UNKC7Mhk0GMqwN6IOEjX4Ibja+cAtLzQGdd6t9/cIhvx/EjDcuU4+cQ8PDlAzuid97ceWDtsxxbFWxW3+TTGECEkBMfl/e5GtYUzE4yQRRBKzCAs3BaT/mHnnWJMtLrsg== 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=V6RTnI8yE/vjTtMjLSnImXNV5jSKzVOyhGIgjRhH5fE=; b=bTWFfVMTm94xPSBGywpF3WxfGslYZhoX648ur8v4r456hOrwEwrjbJz0AFTG8D26l0VlMgKwVSaqERrTlT9cnGk44YlOuD3KJKoPHiyMlhjerrkFu9f3b3aKqeItpPXmH2cIqqmJ5Oim5tH1GsZ06eTFERhvbRUlhRcoGxW6oV0Niq/Mq2+g/Ew2x3nD6r677Hi0B4yQvMcyZDzO8/QRJTecyncTLMl3iBFl74cHXFNsuddWEYnqnjcSuzDeW2+4xO0KN8cOpycDhYeFWfk7nVRoez47bX0t+uDtaZDMSxDlrEOdoptH99CeVwOapuJu0n3ISU0lOHwlVBzQIj5iZg== 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]) 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=V6RTnI8yE/vjTtMjLSnImXNV5jSKzVOyhGIgjRhH5fE=; b=l/NabpAVvPRBUFeaTkYGjsUVLFGDxDsedxB1hioJ6/3pmKvCfkgdereeqACNiiSZJTju+G92qisJJOLJPQM8vby/gtCahghk3OgMGhSICgB7RO4Qz05QQiUDxQ7phFXe5grD24ESpshEx3hvBrdbAfcmNNNLhJvaHNzno+OVzQY= Received: from AS9PR06CA0433.eurprd06.prod.outlook.com (2603:10a6:20b:49e::11) by PAVPR08MB9484.eurprd08.prod.outlook.com (2603:10a6:102:315::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.25; Thu, 4 Jan 2024 18:20:40 +0000 Received: from AM2PEPF0001C716.eurprd05.prod.outlook.com (2603:10a6:20b:49e:cafe::6e) by AS9PR06CA0433.outlook.office365.com (2603:10a6:20b:49e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.15 via Frontend Transport; Thu, 4 Jan 2024 18:20:40 +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 AM2PEPF0001C716.mail.protection.outlook.com (10.167.16.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.9 via Frontend Transport; Thu, 4 Jan 2024 18:20:40 +0000 Received: ("Tessian outbound 968ce956f8b7:v239"); Thu, 04 Jan 2024 18:20:40 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0146dae672b067bb X-CR-MTA-TID: 64aa7808 Received: from 128c4f6830b2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2C59E443-14B5-48F4-984B-DB728C9079E3.1; Thu, 04 Jan 2024 18:20:33 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 128c4f6830b2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Jan 2024 18:20:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EWLbQLiOstoKKkFDxt/ORCxsYcvE6ybr7YTI4SDnfEldmU0cTj00PshW75nYbKwyzcRP8mX9e7W6I+AKk64rdWVCbBP8P1HOg++sZc12Xb8PEzTB1WpMIVAEwaJEdGN35WYnbKCRnB3KgrcJszloq7J3Bn411mHl+P6UMHrsqHXSpAvSwc+EivFhxpRg2oCu5ZnnPB0CsKGtnHc+amqXF1Lg3+Q+4K9AWthXypLzQrQc1IBqcrKrG/Zuy9NVbyO8WeRcQ8za6s25bI3f5lVsvsXylYyiXA/iVSw4aBU/FUOAtGJTV+nxVleIXsCSpb3BN9+BVqpMoY3fuH0BDBvy7g== 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=V6RTnI8yE/vjTtMjLSnImXNV5jSKzVOyhGIgjRhH5fE=; b=Tp3pnYZz5IpBUimJAPwul+cu87B7gfII+FITL5pL+usqRm3WNW4n+GAqk2HODZnX/9Ealt5oG1Vw8LWAgK7ZdvHPZ6LFGQV6MnvM1DuClFVoJhCUZbdarQpXRKE6NPPvs6epmJuaWFEj6l5mAonVKbZ13Iu1v/4EiFV3yWgttxz8NV44e/zYGfD2vDcDaUODC0YavhJ8FziAU4eFq2VYxX28XyMjhV9yluaWS19mkpNBwPmy095R1HENKtFCstLkar7qPi7fVRAx1wory7/xoO6uqg+HNb66V9AaeqJo+PzPiZ1N/+5xUZ9Gbokf097HndAgKAmPPUBmEXlszdFk9w== 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=V6RTnI8yE/vjTtMjLSnImXNV5jSKzVOyhGIgjRhH5fE=; b=l/NabpAVvPRBUFeaTkYGjsUVLFGDxDsedxB1hioJ6/3pmKvCfkgdereeqACNiiSZJTju+G92qisJJOLJPQM8vby/gtCahghk3OgMGhSICgB7RO4Qz05QQiUDxQ7phFXe5grD24ESpshEx3hvBrdbAfcmNNNLhJvaHNzno+OVzQY= 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 PR3PR08MB5753.eurprd08.prod.outlook.com (2603:10a6:102:87::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.15; Thu, 4 Jan 2024 18:20:28 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::9679:2ab0:99c6:54a3]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::9679:2ab0:99c6:54a3%6]) with mapi id 15.20.7159.013; Thu, 4 Jan 2024 18:20:28 +0000 Date: Thu, 4 Jan 2024 18:20:25 +0000 From: Tamar Christina To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, rguenther@suse.de, jlaw@ventanamicro.com Subject: [PATCH]middle-end: Don't apply copysign optimization if target does not implement optab [PR112468] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO4P265CA0281.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:37a::13) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|PR3PR08MB5753:EE_|AM2PEPF0001C716:EE_|PAVPR08MB9484:EE_ X-MS-Office365-Filtering-Correlation-Id: 0fdf27f8-3fb6-43c8-ed03-08dc0d51db5a 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: 2FkHA3WlKGIDoSMFpHPnTs5AAqKDsj05eJAR9r6fE3GQeI77UrU4ZmARCgrYmk3lR5JtNXihs62/xvvn4S1xMSIY0tpj1iitFI63huNejkzDUvvlXa8ZtrJW/ZMFUhhaYplQ17ybrlY89oSCSgF4t3eUqu/RUDWr8G9jFE5254OO0iK5jhFXVgrLcLaWolAIrFWhGSut01gQZkJL+/N7Q7SW27pO4EyoyzZsIQMfNEH++WMnlrmGItulks2A66YTm4IbWV4/p1a2FYFtfHntsQFpbiyFVN0XRzV/kuQkqa4cd03o4/9zWr52kZYb03FNGaKw3qUb8+Xu8rYyVXeyORhclD0G2y4KpsIg762NQJN3JOUHiyABVKfDKJd8ufM/uGY2qFWp3EvWWRWtrl5iY6LSM/bk+TerfMX1Svo3SM/t7eBmyWZgHWeTnXlZI+2oVo/XNaqd/IXPFPz8DnEafazKYip9U6F/FoFpChK1SdONiWT35Vb8dEm4MP+EfULHwEc+z9c16aqjy0NqCAVumMyJLBGXeBrWXvzHwZjJ25DKqXesnBa5WoN355b6w0k2VxVbLIBRFZwz0UGtmq4zXydd+3JQU0PYTB+uqjpbmanStkbG+qLwrgNDeOVIAHjgGvz0yJG7E9aACXdiOIi5BeEn0q884z/2axjuCko14bA= 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)(376002)(396003)(346002)(136003)(39860400002)(366004)(230922051799003)(186009)(1800799012)(64100799003)(451199024)(33964004)(6512007)(6506007)(2616005)(44144004)(478600001)(6666004)(86362001)(66476007)(6916009)(66946007)(66556008)(316002)(6486002)(84970400001)(83380400001)(4743002)(26005)(38100700002)(5660300002)(235185007)(30864003)(44832011)(8676002)(4326008)(8936002)(36756003)(2906002)(41300700001)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5753 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: AM2PEPF0001C716.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 45628a39-5c37-4a6e-cb1e-08dc0d51d3e0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jktcRoooG6JNcFD31ZS7jl8Dj4+W6KIdZMQY8W0qbli/EXkJ5qhPijyAXZfLtcQ5pm4IdrStMkPfTDcXi9+FVWOMa4bkmyS1gKG0bjJ5nbeyLQ6Q7J35MdXyRoQm3/CeaLS50W/am0Qm7sbJAme9m+70+U//vYL414eL/QPMbZvL2dsTZIgkbrpr1lQGp2aYMNPTgbRT/bJI4puNzpj5A/36QpTItdQQj9C0EHKBq6tLJYlDBLmMtNgY/RQsZXmzXqUDrJXapdgsbRDTPLF39Z4o3RsYnLmd6MM5kZazrxCSq4OpGEKAwMiYbtsOoon9ERiJfozo9ObXJ7b6o/j08HGOW+Zqas9Mc9A4uSgLcEE5TgShI6S4hyDwTLS97apR/RZWgVMcZrt/sJg5qLnTBSdGqGyHE4lJEQKlSEHLhUXrlW6+DIaq+15cwPs78/hugeeW+m+2Uua+rAytssniAOEl+uO5isl3KbA6x5fjVYQpxywqji7j+yLsn2PHs/Hk1OqW76VaSrcjzxEWUD2RDhMCXRK80tJlM4OtOFhi3ucU/pnfc46eMWUN8ToV2iwptZHQtQanbI600p3vD4hfRJeBDM9AfUz63aJcrUl3uIDdXTRCR1xacihYeUsa45jDGPMQPUuNn70C3z+bO9idqyvXwJjqOLbPXEFJwm1fur3slNC0kkncLDsNpBLjixUYtnby32mN5+HaCioKf18E7kgzyWRCkhLc994ikP+r+vk8FOGw9IwdvrDiA7MP24rDHUV4OxY3NoucO+B4w9Xleu1NvwW7k3pYZMvTAVUkuK0LQfqJPX9PC5/SBGgRy30S 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)(376002)(136003)(396003)(39860400002)(346002)(230922051799003)(186009)(1800799012)(82310400011)(451199024)(64100799003)(46966006)(36840700001)(40470700004)(30864003)(8936002)(235185007)(2906002)(8676002)(44832011)(4326008)(478600001)(6916009)(36756003)(86362001)(5660300002)(6486002)(40480700001)(84970400001)(40460700003)(41300700001)(44144004)(6666004)(6512007)(33964004)(6506007)(316002)(107886003)(336012)(4743002)(2616005)(26005)(83380400001)(356005)(81166007)(70206006)(70586007)(47076005)(82740400003)(36860700001)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2024 18:20:40.2667 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0fdf27f8-3fb6-43c8-ed03-08dc0d51db5a 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: AM2PEPF0001C716.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9484 X-Spam-Status: No, score=-12.0 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, T_SCC_BODY_TEXT_LINE, 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.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, currently GCC does not treat IFN_COPYSIGN the same as the copysign tree expr. The latter has a libcall fallback and the IFN can only do optabs. Because of this the change I made to optimize copysign only works if the target has impemented the optab, but it should work for those that have the libcall too. More annoyingly if a target has vector versions of ABS and NEG but not COPYSIGN then the change made them lose vectorization. The proper fix for this is to treat the IFN the same as the tree EXPR and to enhance expand_COPYSIGN to also support vector calls. I have such a patch for GCC 15 but it's quite big and too invasive for stage-4. As such this is a minimal fix, just don't apply the transformation and leave targets which don't have the optab unoptimized. Targets list for check_effective_target_ifn_copysign was gotten by grepping for copysign and looking at the optab. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Tests ran in x86_64-pc-linux-gnu -m64/-m32 and tests no longer fail. Ok for master? Thanks, Tamar gcc/ChangeLog: PR tree-optimization/112468 * doc/sourcebuild.texi: Document ifn_copysign. * match.pd: Only apply transformation if target supports the IFN. gcc/testsuite/ChangeLog: PR tree-optimization/112468 * gcc.dg/fold-copysign-1.c: Modify tests based on if target supports IFN_COPYSIGN. * gcc.dg/pr55152-2.c: Likewise. * gcc.dg/tree-ssa/abs-4.c: Likewise. * gcc.dg/tree-ssa/backprop-6.c: Likewise. * gcc.dg/tree-ssa/copy-sign-2.c: Likewise. * gcc.dg/tree-ssa/mult-abs-2.c: Likewise. * lib/target-supports.exp (check_effective_target_ifn_copysign): New. --- inline copy of patch -- diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 4be67daedb20d394857c02739389cabf23c0d533..f4847dafe65cbbf8c9de34905f614ef6957658b4 100644 --- diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 4be67daedb20d394857c02739389cabf23c0d533..f4847dafe65cbbf8c9de34905f614ef6957658b4 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2664,6 +2664,10 @@ Target requires a command line argument to enable a SIMD instruction set. @item xorsign Target supports the xorsign optab expansion. +@item ifn_copysign +Target supports the IFN_COPYSIGN optab expansion for both scalar and vector +types. + @end table @subsubsection Environment attributes diff --git a/gcc/match.pd b/gcc/match.pd index d57e29bfe1d68afd4df4dda20fecc2405ff05332..87d13e7e3e1aa6d89119142b614890dc4729b521 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1159,13 +1159,22 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (simplify (copysigns @0 REAL_CST@1) (if (!REAL_VALUE_NEGATIVE (TREE_REAL_CST (@1))) - (abs @0)))) + (abs @0) +#if GIMPLE + (if (!direct_internal_fn_supported_p (IFN_COPYSIGN, type, + OPTIMIZE_FOR_BOTH)) + (negate (abs @0))) +#endif + ))) +#if GIMPLE /* Transform fneg (fabs (X)) -> copysign (X, -1). */ (simplify (negate (abs @0)) - (IFN_COPYSIGN @0 { build_minus_one_cst (type); })) - + (if (direct_internal_fn_supported_p (IFN_COPYSIGN, type, + OPTIMIZE_FOR_BOTH)) + (IFN_COPYSIGN @0 { build_minus_one_cst (type); }))) +#endif /* copysign(copysign(x, y), z) -> copysign(x, z). */ (for copysigns (COPYSIGN_ALL) (simplify diff --git a/gcc/testsuite/gcc.dg/fold-copysign-1.c b/gcc/testsuite/gcc.dg/fold-copysign-1.c index f9cafd14ab05f5e8ab2f6f68e62801d21c2df6a6..96b80c733794fffada1b08274ef39cc8f6e442ce 100644 --- a/gcc/testsuite/gcc.dg/fold-copysign-1.c +++ b/gcc/testsuite/gcc.dg/fold-copysign-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O -fdump-tree-cddce1" } */ +/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ double foo (double x) { @@ -12,5 +13,7 @@ double bar (double x) return __builtin_copysign (x, minuszero); } -/* { dg-final { scan-tree-dump-times "__builtin_copysign" 1 "cddce1" } } */ -/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 1 "cddce1" } } */ +/* { dg-final { scan-tree-dump-times "__builtin_copysign" 1 "cddce1" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 1 "cddce1" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "= -" 1 "cddce1" { target { ! ifn_copysign } } } } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 2 "cddce1" { target { ! ifn_copysign } } } } */ diff --git a/gcc/testsuite/gcc.dg/pr55152-2.c b/gcc/testsuite/gcc.dg/pr55152-2.c index 605f202ed6bc7aa8fe921457b02ff0b88cc63ce6..24068cffa4a8e2807ba7d16c4ed3def4f736e797 100644 --- a/gcc/testsuite/gcc.dg/pr55152-2.c +++ b/gcc/testsuite/gcc.dg/pr55152-2.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O -ffinite-math-only -fno-signed-zeros -fstrict-overflow -fdump-tree-optimized" } */ +/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ double g (double a) { @@ -10,5 +11,6 @@ int f(int a) return (a<-a)?a:-a; } -/* { dg-final { scan-tree-dump-times "\.COPYSIGN" 1 "optimized" } } */ -/* { dg-final { scan-tree-dump-times "ABS_EXPR" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\.COPYSIGN" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 2 "optimized" { target { ! ifn_copysign } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c index e1b825f37f69ac3c4666b3a52d733368805ad31d..80fa448df1259c7dba406797f4198205783a2fba 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O1 -fdump-tree-optimized" } */ +/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ /* PR tree-optimization/109829 */ float abs_f(float x) { return __builtin_signbit(x) ? x : -x; } @@ -9,6 +10,8 @@ long double abs_ld(long double x) { return __builtin_signbit(x) ? x : -x; } /* __builtin_signbit(x) ? x : -x. Should be convert into - ABS_EXP */ /* { dg-final { scan-tree-dump-not "signbit" "optimized"} } */ -/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 1 "optimized"} } */ -/* { dg-final { scan-tree-dump-times "= -" 1 "optimized"} } */ -/* { dg-final { scan-tree-dump-times "= \.COPYSIGN" 2 "optimized"} } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "= -" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "= \.COPYSIGN" 2 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 3 "optimized" { target { ! ifn_copysign } } } } */ +/* { dg-final { scan-tree-dump-times "= -" 3 "optimized" { target { ! ifn_copysign } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c b/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c index c3a138642d6ff7be984e91fa1343cb2718db7ae1..4087ba93018bb71710102eb379460bc760020081 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O -fdump-tree-backprop-details" } */ +/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ void start (void *); void end (void *); @@ -26,6 +27,8 @@ TEST_FUNCTION (float, f) TEST_FUNCTION (double, ) TEST_FUNCTION (long double, l) -/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = -} 4 "backprop" } } */ -/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = \.COPYSIGN} 2 "backprop" } } */ -/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = ABS_EXPR <} 1 "backprop" } } */ +/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = -} 4 "backprop" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = \.COPYSIGN} 2 "backprop" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = ABS_EXPR <} 1 "backprop" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = -} 6 "backprop" { target { ! ifn_copysign } } } } */ +/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = ABS_EXPR <} 3 "backprop" { target { ! ifn_copysign } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c index e5d565c4b9832c00106588ef411fbd8c292a5cad..e43bc315bef2bd11c11cfd2685f5088e792b7bf7 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c @@ -1,4 +1,5 @@ /* { dg-options "-O2 -ffast-math -fdump-tree-optimized" } */ +/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ /* { dg-do compile } */ float f(float x) { @@ -10,5 +11,6 @@ float f1(float x) float t = __builtin_copysignf (1.0f, -x); return x * t; } -/* { dg-final { scan-tree-dump-times "ABS" 1 "optimized"} } */ -/* { dg-final { scan-tree-dump-times ".COPYSIGN" 1 "optimized"} } */ +/* { dg-final { scan-tree-dump-times "ABS" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times ".COPYSIGN" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "ABS" 2 "optimized" { target { ! ifn_copysign } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c b/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c index a22896b21c8b5a4d5d8e28bd8ae0db896e63ade0..675127cfe56b2e9aa9d4c06e2bdce62b59545a08 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c @@ -34,5 +34,5 @@ float i1(float x) { return x * (x <= 0.f ? 1.f : -1.f); } -/* { dg-final { scan-tree-dump-times "ABS" 4 "gimple"} } */ -/* { dg-final { scan-tree-dump-times "\.COPYSIGN" 4 "gimple"} } */ + +/* { dg-final { scan-tree-dump-times "ABS" 8 "gimple" } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 7f13ff0ca565efdf19065811f3301db897329073..64a081cfafd78e5ccb7322d3b382f800b30bbe70 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -7830,6 +7830,29 @@ proc check_effective_target_xorsign { } { || [istarget aarch64*-*-*] || [istarget arm*-*-*] }}] } +# Return 1 if the target plus current options supports folding of +# copysign into IFN_COPYSIGN. +# +# This won't change for different subtargets so cache the result. + +proc check_effective_target_ifn_copysign { } { + return [check_cached_effective_target_indexed ifn_copysign { + expr { + (([istarget i?86-*-*] || [istarget x86_64-*-*]) + && [is-effective-target sse]) + || ([istarget loongarch*-*-*] && [check_effective_target_loongarch_sx]) + || ([istarget powerpc*-*-*] + && ![istarget powerpc-*-linux*paired*]) + || [istarget alpha*-*-*] + || [istarget aarch64*-*-*] + || [is-effective-target arm_neon] + || ([istarget s390*-*-*] + && [check_effective_target_s390_vx]) + || ([istarget riscv*-*-*] + && [check_effective_target_riscv_v]) + }}] +} + # Return 1 if the target plus current options supports a vector # widening summation of *short* args into *int* result, 0 otherwise. # --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2664,6 +2664,10 @@ Target requires a command line argument to enable a SIMD instruction set. @item xorsign Target supports the xorsign optab expansion. +@item ifn_copysign +Target supports the IFN_COPYSIGN optab expansion for both scalar and vector +types. + @end table @subsubsection Environment attributes diff --git a/gcc/match.pd b/gcc/match.pd index d57e29bfe1d68afd4df4dda20fecc2405ff05332..87d13e7e3e1aa6d89119142b614890dc4729b521 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1159,13 +1159,22 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (simplify (copysigns @0 REAL_CST@1) (if (!REAL_VALUE_NEGATIVE (TREE_REAL_CST (@1))) - (abs @0)))) + (abs @0) +#if GIMPLE + (if (!direct_internal_fn_supported_p (IFN_COPYSIGN, type, + OPTIMIZE_FOR_BOTH)) + (negate (abs @0))) +#endif + ))) +#if GIMPLE /* Transform fneg (fabs (X)) -> copysign (X, -1). */ (simplify (negate (abs @0)) - (IFN_COPYSIGN @0 { build_minus_one_cst (type); })) - + (if (direct_internal_fn_supported_p (IFN_COPYSIGN, type, + OPTIMIZE_FOR_BOTH)) + (IFN_COPYSIGN @0 { build_minus_one_cst (type); }))) +#endif /* copysign(copysign(x, y), z) -> copysign(x, z). */ (for copysigns (COPYSIGN_ALL) (simplify diff --git a/gcc/testsuite/gcc.dg/fold-copysign-1.c b/gcc/testsuite/gcc.dg/fold-copysign-1.c index f9cafd14ab05f5e8ab2f6f68e62801d21c2df6a6..96b80c733794fffada1b08274ef39cc8f6e442ce 100644 --- a/gcc/testsuite/gcc.dg/fold-copysign-1.c +++ b/gcc/testsuite/gcc.dg/fold-copysign-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O -fdump-tree-cddce1" } */ +/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ double foo (double x) { @@ -12,5 +13,7 @@ double bar (double x) return __builtin_copysign (x, minuszero); } -/* { dg-final { scan-tree-dump-times "__builtin_copysign" 1 "cddce1" } } */ -/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 1 "cddce1" } } */ +/* { dg-final { scan-tree-dump-times "__builtin_copysign" 1 "cddce1" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 1 "cddce1" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "= -" 1 "cddce1" { target { ! ifn_copysign } } } } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 2 "cddce1" { target { ! ifn_copysign } } } } */ diff --git a/gcc/testsuite/gcc.dg/pr55152-2.c b/gcc/testsuite/gcc.dg/pr55152-2.c index 605f202ed6bc7aa8fe921457b02ff0b88cc63ce6..24068cffa4a8e2807ba7d16c4ed3def4f736e797 100644 --- a/gcc/testsuite/gcc.dg/pr55152-2.c +++ b/gcc/testsuite/gcc.dg/pr55152-2.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O -ffinite-math-only -fno-signed-zeros -fstrict-overflow -fdump-tree-optimized" } */ +/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ double g (double a) { @@ -10,5 +11,6 @@ int f(int a) return (a<-a)?a:-a; } -/* { dg-final { scan-tree-dump-times "\.COPYSIGN" 1 "optimized" } } */ -/* { dg-final { scan-tree-dump-times "ABS_EXPR" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\.COPYSIGN" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 2 "optimized" { target { ! ifn_copysign } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c index e1b825f37f69ac3c4666b3a52d733368805ad31d..80fa448df1259c7dba406797f4198205783a2fba 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O1 -fdump-tree-optimized" } */ +/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ /* PR tree-optimization/109829 */ float abs_f(float x) { return __builtin_signbit(x) ? x : -x; } @@ -9,6 +10,8 @@ long double abs_ld(long double x) { return __builtin_signbit(x) ? x : -x; } /* __builtin_signbit(x) ? x : -x. Should be convert into - ABS_EXP */ /* { dg-final { scan-tree-dump-not "signbit" "optimized"} } */ -/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 1 "optimized"} } */ -/* { dg-final { scan-tree-dump-times "= -" 1 "optimized"} } */ -/* { dg-final { scan-tree-dump-times "= \.COPYSIGN" 2 "optimized"} } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "= -" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "= \.COPYSIGN" 2 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 3 "optimized" { target { ! ifn_copysign } } } } */ +/* { dg-final { scan-tree-dump-times "= -" 3 "optimized" { target { ! ifn_copysign } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c b/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c index c3a138642d6ff7be984e91fa1343cb2718db7ae1..4087ba93018bb71710102eb379460bc760020081 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O -fdump-tree-backprop-details" } */ +/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ void start (void *); void end (void *); @@ -26,6 +27,8 @@ TEST_FUNCTION (float, f) TEST_FUNCTION (double, ) TEST_FUNCTION (long double, l) -/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = -} 4 "backprop" } } */ -/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = \.COPYSIGN} 2 "backprop" } } */ -/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = ABS_EXPR <} 1 "backprop" } } */ +/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = -} 4 "backprop" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = \.COPYSIGN} 2 "backprop" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = ABS_EXPR <} 1 "backprop" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = -} 6 "backprop" { target { ! ifn_copysign } } } } */ +/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = ABS_EXPR <} 3 "backprop" { target { ! ifn_copysign } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c index e5d565c4b9832c00106588ef411fbd8c292a5cad..e43bc315bef2bd11c11cfd2685f5088e792b7bf7 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c @@ -1,4 +1,5 @@ /* { dg-options "-O2 -ffast-math -fdump-tree-optimized" } */ +/* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ /* { dg-do compile } */ float f(float x) { @@ -10,5 +11,6 @@ float f1(float x) float t = __builtin_copysignf (1.0f, -x); return x * t; } -/* { dg-final { scan-tree-dump-times "ABS" 1 "optimized"} } */ -/* { dg-final { scan-tree-dump-times ".COPYSIGN" 1 "optimized"} } */ +/* { dg-final { scan-tree-dump-times "ABS" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times ".COPYSIGN" 1 "optimized" { target ifn_copysign } } } */ +/* { dg-final { scan-tree-dump-times "ABS" 2 "optimized" { target { ! ifn_copysign } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c b/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c index a22896b21c8b5a4d5d8e28bd8ae0db896e63ade0..675127cfe56b2e9aa9d4c06e2bdce62b59545a08 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c @@ -34,5 +34,5 @@ float i1(float x) { return x * (x <= 0.f ? 1.f : -1.f); } -/* { dg-final { scan-tree-dump-times "ABS" 4 "gimple"} } */ -/* { dg-final { scan-tree-dump-times "\.COPYSIGN" 4 "gimple"} } */ + +/* { dg-final { scan-tree-dump-times "ABS" 8 "gimple" } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 7f13ff0ca565efdf19065811f3301db897329073..64a081cfafd78e5ccb7322d3b382f800b30bbe70 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -7830,6 +7830,29 @@ proc check_effective_target_xorsign { } { || [istarget aarch64*-*-*] || [istarget arm*-*-*] }}] } +# Return 1 if the target plus current options supports folding of +# copysign into IFN_COPYSIGN. +# +# This won't change for different subtargets so cache the result. + +proc check_effective_target_ifn_copysign { } { + return [check_cached_effective_target_indexed ifn_copysign { + expr { + (([istarget i?86-*-*] || [istarget x86_64-*-*]) + && [is-effective-target sse]) + || ([istarget loongarch*-*-*] && [check_effective_target_loongarch_sx]) + || ([istarget powerpc*-*-*] + && ![istarget powerpc-*-linux*paired*]) + || [istarget alpha*-*-*] + || [istarget aarch64*-*-*] + || [is-effective-target arm_neon] + || ([istarget s390*-*-*] + && [check_effective_target_s390_vx]) + || ([istarget riscv*-*-*] + && [check_effective_target_riscv_v]) + }}] +} + # Return 1 if the target plus current options supports a vector # widening summation of *short* args into *int* result, 0 otherwise. #