From patchwork Mon Nov 6 10:20:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 161922 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2558327vqu; Mon, 6 Nov 2023 02:20:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmLL5vWc6IGoDiD69Io+DBT5seXtKU+MLmBJix7EgR7UNI119tkR4a5spgz6yUDMIWsHyd X-Received: by 2002:ac8:57c2:0:b0:41e:3eef:736d with SMTP id w2-20020ac857c2000000b0041e3eef736dmr33214905qta.5.1699266051077; Mon, 06 Nov 2023 02:20:51 -0800 (PST) ARC-Seal: i=4; a=rsa-sha256; t=1699266051; cv=pass; d=google.com; s=arc-20160816; b=Fq6Dkh5cRaBya/3fnt4mWx2+bZ/ZZHz8eNYdnaMnssRyY5DeF4S/lQBpqzhizEYRqe sY0znvHTu/gDzY99OAieils/+QvqcSffYA3CdkzPRU/Cy0jt70uX70uMHEPPu+9QzRD4 ggc10sOjmc2ymlYLW5NMZLQWzUAggniZZJP5TtlZ2wILfphiNzInxYnrmpFAlyJ8qboG 2FIvtpOF7i/PEr1JIq8UABgpG303dLMcW/btDz1h9rATFWo6PXVIeWL2ATHyCvQ6+l1O nUqWkWyEHiELu85iqIv9oxDXarKAgyYodb4oWduZBdjHt+Ss3z5BBqyLCcEcHo3MVULL 7ASQ== ARC-Message-Signature: i=4; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:original-authentication-results :nodisclaimer:mime-version:content-disposition:message-id:subject:cc :to:from:date:authentication-results-original:dkim-signature :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=USB+lSpy2eOPaUuF6/uJOxkKawNSv+LnwHMP66a8afI=; fh=6lLuKcPp5JwcfhLsQ40FQN1vJS1KxlKbf2GiViQwbCM=; b=C8Mjr5Ren7UBUTHVhHwVeV0IJUh0szVlqll8SPQ24XefduCPDvZdbVBk7TrRsdk9t7 TFVp82Ymyl7bOvHSJhZq4QtVPyMihhmvdcobipis1PN5Ers+g9mnEjP8dBIP3mNRyfzV f3m0pprOrEs8M2+d08jScGMDfz7x7cEsjHLtCc2lXkfDUziRjhXUhOKtp9pTqzmX5UNl irWmqP13TL2VEyU8FRkICbQwkbnxsir4o/aYhhhsDLrsBXN69hPknt5PvipHmO7fhhVX kRx+aRrPz2C3IeLQau4ocy5VhaTJyfDKrCt0aZFhrLjvics+qMKi29pqr47ggCmQ5rq3 ovjA== ARC-Authentication-Results: i=4; mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=AG6NDL0a; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=AG6NDL0a; arc=pass (i=3); 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u7-20020a05622a198700b0041e8d67072bsi5324036qtc.560.2023.11.06.02.20.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 02:20:51 -0800 (PST) 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=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=AG6NDL0a; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=AG6NDL0a; arc=pass (i=3); 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A7E75385B81D for ; Mon, 6 Nov 2023 10:20:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2067.outbound.protection.outlook.com [40.107.247.67]) by sourceware.org (Postfix) with ESMTPS id 39CB23858D28 for ; Mon, 6 Nov 2023 10:20:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 39CB23858D28 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 39CB23858D28 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.247.67 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1699266025; cv=pass; b=wTJ6ePG+2ssX8NY58awwZlhX1fsOyeHEvVEiHBojdz9iKGE/f2gtRX8e0FV6y+/+LQLirofPmxXCszaUXUh+TCrLc+KeVCGjuQFTps478s5o+uFeBl7rHZoa/dA9X9eqpu9SBBotaWakukIuK8lOcZ91ivP6L033eNmCIlEasdw= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1699266025; c=relaxed/simple; bh=NqCPJvL55C8ehTdxMTJEgq37dtARR0kj1nGyTNsc3uE=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=QkZUdGaNuhAFXdD4LDcGCDNI+cyxsPoo8cvyZUoSw7Q4sguEPkHLdNW1G2FjEHXbWQUw023a5tT659zE+c67SpXq6vyeSqbAERNyO0kvdSxMfFeVyQlMmOgOk87U8bAI3Q1lLZBBeLX41ocOZELGubTWHYHkSdM7wymdptV85hQ= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=YMed8lBqLqu/D3gPftc7eD0t++1opXSNqEeQZ211rM8RtqC/30HeYVaBF5zd3hyCq9WHPcAFLE9au7zI3rRpbs4X8HHal23KEzpWuJQYOyNF7yTV/JLloBspvQYZ8KWxooLmkU4LfTmk4hIA0P6Msp5S7fTuEPdXF5UICX6qoC7xN4g0Ea7bdZPVyqnltmab8JzoDIHfewfuQjDenZx5TvEV+EAw2xCvX+F7TMr/88r5g4R/76jy4/M4i2lw/Gj8jTuiOOrnMbbnYLddhUY9egXr9KBmrYrQi3TugS7X+36+O5va6iJpW1IavRdqgCTNID4hbP2NPYFwkzoGhtWZ1w== 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=USB+lSpy2eOPaUuF6/uJOxkKawNSv+LnwHMP66a8afI=; b=O/qPo0mrlDql1jpSaCRDQFMCzAcmF+qrXHaJ8WEWVtUNz9hESrwYvuMkBnP5kEoazRcPtT7roHiNY7OeqLzrrb6ZW6/9BqT8AMUTfldu3Cv2WogqzxTiH6yClVleUkZKlUECR6M5hLTS3a7pkj4hF43N/8nZljV2+l2XaIGSP024EMir3ljAGA6e+lvQ3YScS8bklotlpmKp7Mxfe+IzoorGXAIlzLiNc0O2sL4+KUZs11uA7yTby9D4brcPHuo8MG25pfp+p/O6Uzua7lLCvyI9SWrLHTIxgBkwNySfuEUp6LTUIIZd/mhBmxFwGeHjq8cjJjjBA3Kj96cV2+GKWg== 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=USB+lSpy2eOPaUuF6/uJOxkKawNSv+LnwHMP66a8afI=; b=AG6NDL0ahHZUNC7ueWIBPuQTqvIeQODNvMJGHo52x/PMnFsSGy9u79S6liSiFy1TJ8/X+Ub3OfRV0vwbhk8n44c9q69Z5567KPB+XuplSt7MemDMQ3Pr7fCiY8zVOgvMdFGb8quvdi93eMolTSO0ZRJqxYTQaGHQoX+k/K3XZSM= Received: from AM9P192CA0015.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::20) by DB9PR08MB8358.eurprd08.prod.outlook.com (2603:10a6:10:3da::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.27; Mon, 6 Nov 2023 10:20:17 +0000 Received: from AMS0EPF000001AC.eurprd05.prod.outlook.com (2603:10a6:20b:21d:cafe::80) by AM9P192CA0015.outlook.office365.com (2603:10a6:20b:21d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.27 via Frontend Transport; Mon, 6 Nov 2023 10:20:17 +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 AMS0EPF000001AC.mail.protection.outlook.com (10.167.16.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.16 via Frontend Transport; Mon, 6 Nov 2023 10:20:16 +0000 Received: ("Tessian outbound 7c4ecdadb9e7:v228"); Mon, 06 Nov 2023 10:20:16 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 27b4043cfdfd220f X-CR-MTA-TID: 64aa7808 Received: from d9c12637e8d5.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 65F4E35E-3DDE-46D9-A2FE-E9B769846610.1; Mon, 06 Nov 2023 10:20:09 +0000 Received: from EUR02-AM0-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d9c12637e8d5.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 06 Nov 2023 10:20:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bt1gAsO8Cs3tP7tiwcBs1pWYiJC0QDpf5m8E74QhsbN3wk6QhPY+pv5+NSblQnmxhCZEBMlFZ5clyB6tJWyQjyAZZacRFtnP89YcOAbrimMl7sRnz9pPB7SkqnNMDRNc3qh38lYZ0d2NyruF54kQLTsZWGoKvpNfUc2DKnFbCBk5Ml1mDYuWt3UTxgQ4Ijk6BkEbbLaPbd+YAisa4mwfoajSvp7y104s31Eu9rzpXDs4bZE/LJkYz96GLl2j9LyXCvXj8YGrpID1ns508jhSKvh8btYb3/4aLjxpSrsFwaE/P1U/vMnkzY58e7yfc9D5qJfPcZkN2XYcEk63saYGAg== 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=USB+lSpy2eOPaUuF6/uJOxkKawNSv+LnwHMP66a8afI=; b=mzxnII+vGEelHMY2KnaQrgM9kWiD9HWMNPNA5x0eeb7OGer44g+iBYipVxJvonEPgJt4goW/u/UnupZGUA6l3YZ68rKuZAk91qVkrlUIX42Vj2F+KV8fmVK5HScMxDdpPOR/j/MJXaqeDtDZLHHi87l0YzABHbUQ6wIbJx/5JBJoT/OU6uCY2hlsZKGbsZr83MVSiU4CDjFVes1eWOMNaQHn3TLBquUb/7KEuPm9im8buFZYNQoh+cZ3121QRbTFTlW8cmp05qpeC1XswWNInfDCHykp7qS0eZuBJK2y6n3EssTXgWkn4ZthP6PwMCQBCaHfarmvlu/HamGUuSavVQ== 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=USB+lSpy2eOPaUuF6/uJOxkKawNSv+LnwHMP66a8afI=; b=AG6NDL0ahHZUNC7ueWIBPuQTqvIeQODNvMJGHo52x/PMnFsSGy9u79S6liSiFy1TJ8/X+Ub3OfRV0vwbhk8n44c9q69Z5567KPB+XuplSt7MemDMQ3Pr7fCiY8zVOgvMdFGb8quvdi93eMolTSO0ZRJqxYTQaGHQoX+k/K3XZSM= 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 DU0PR08MB9679.eurprd08.prod.outlook.com (2603:10a6:10:445::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 10:20:05 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::26aa:efdd:a74a:27d0]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::26aa:efdd:a74a:27d0%5]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 10:20:05 +0000 Date: Mon, 6 Nov 2023 10:20:01 +0000 From: Tamar Christina To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, rguenther@suse.de, jlaw@ventanamicro.com Subject: [PATCH v3 1/2]middle-end: expand copysign handling from lockstep to nested iters Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO4P265CA0075.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2bd::16) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|DU0PR08MB9679:EE_|AMS0EPF000001AC:EE_|DB9PR08MB8358:EE_ X-MS-Office365-Filtering-Correlation-Id: b51b6dc5-f918-46e7-8738-08dbdeb1f8e6 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: o8ruevTH0oqSx/1dEbknpk9I50S5zgcuj5DjqXiLKQTzogNMrObON4vutYO1rkwPdT+ZLNbSP5lMjyjHJhTFvdVnHTxqpGewIFE+I68I69a2P38Ea1Thw5BRcprdtVXBMbqtIcnOXG5MQo69azX0/09n8kZl+gbvaY8LuDOEgi5fmD1W36ucccVrwJ8oO2NWEijzKli2f8Qc1DcK2U5ntF4Ri/GPysD7tz6HJoVpVIV8dwrM3KkB1qGFE/UTUsdMYgOT6d/hWUjc0ZyI4CCL908vDtPHt4hYxGFFE2YmOaPISRlzPpA/PTXKS2QkLEbAoz6pR6vK/72UpTvQ0iZDKf7bAdbSZ/AOJdGzD3U0xjB8fQCKzWlTaqY0dGdzkKv8tspK/EURA65fD3nzz5dkYPWIKvXIApCIaF+hmDvN+GgDS4Rto86d1fAuj7e+uCjExiEW7bXZvyJov65Z8lzl7jY7h8ZtY3nGcIEyeOQhcIVUbwoR7YvGB4OjeIGN2rMYIhkLra7ytgoJ2hh+vUKqSbYudYuzpgoW3MhAyAB7F/akkqFIEIWwcfPyghcVfgqWE3tlekLQ1xcWSSNPmdSed4LT3Qyneh8eLNZl85yXVQt14K3Qvcdrff/kNuvagGP5UWC+L2l6oH64QBvpudWuRA== 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)(136003)(366004)(396003)(376002)(346002)(39860400002)(230922051799003)(64100799003)(1800799009)(451199024)(186009)(83380400001)(36756003)(4326008)(8936002)(44832011)(86362001)(41300700001)(2906002)(8676002)(478600001)(6666004)(33964004)(44144004)(6486002)(6506007)(38100700002)(316002)(6916009)(5660300002)(235185007)(66476007)(66556008)(6512007)(26005)(2616005)(66946007)(4216001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9679 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: AMS0EPF000001AC.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 21612f24-2042-48e7-6b58-08dbdeb1f0e5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +QAF7p9GSpLVTDIZQyCB+MdN5SkLC60BKRqUsssT30Bp9IATKD/YhWcMVw4QEgmbWxjWWL4wmbRsMa4PbPEKugLoSBJnNepIHG6PgSZqNZ2/QyEQCD9ejDuUCxn7BAZoiLHk/ZVwN2l2nChd30JVMMlIttev6RbnO4slvr5t4yBm+w8/eHuNKdU1semgO89cb19QB5aScKdUxYOzyF0axT5qSH+VdFF3Ru8G5eH6ItttprPpu+S4csVN2t07oObkSi9Es4KBz8DPK8yYMkYy0cejSLJneag4/1SkRnbt9KO2c7oI50o0izRFBEOkeQhwhjhf85VPZuuJHx2is3QlPNToBA2blTW9bNAYbH0M9AjymTaEWpaab59BIfdGR0F8it0xV3vel6neym4ZOT+obCZL6NChc6VCS4NNLDgjrQvjEFRF29PCV3XCYtddPwFSzM87WD74O4aPdh52Z4yvMOovMS5sRG7ZzZ93ew0b8Go+p7cdGo2Dvosex/Jd4YOndW37iMaiFLoGqqPuFP7XKJaqohzPLiamCnm1T+zqGcGryUb9IMYWoCspNy7U2w+eADrJj6pEk3tMcu1Dycj0grtruXoEvhHLM3u7S+EgQ3OB8pTrQ2xayR1vHz0k3319oS+NRTzS/snPhe3HlPHvwkqOMg3EZow8kKLw+kvObjEha6UI7EXNQvKew/mxN6vzSoswhpYu6/CVH334JXVmAR/HuZQ/AfgVxr3uMZE2e/XFBtWZtA0x6QZZXFcqwbiq4jGvVLGLvRrWTYzJfOpOJ/rM1kyL/PSDBSt7OaypRss= 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)(346002)(136003)(376002)(39860400002)(396003)(230922051799003)(1800799009)(186009)(82310400011)(64100799003)(451199024)(36840700001)(40470700004)(46966006)(2906002)(36860700001)(8676002)(41300700001)(6916009)(478600001)(316002)(70586007)(8936002)(70206006)(4326008)(36756003)(356005)(6486002)(47076005)(40480700001)(5660300002)(44832011)(235185007)(86362001)(81166007)(83380400001)(336012)(40460700003)(82740400003)(107886003)(2616005)(6506007)(6666004)(26005)(44144004)(33964004)(6512007)(4216001)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 10:20:16.8867 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b51b6dc5-f918-46e7-8738-08dbdeb1f8e6 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: AMS0EPF000001AC.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB8358 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781809598361473276 X-GMAIL-MSGID: 1781809598361473276 Hi All, various optimizations in match.pd only happened on COPYSIGN in lock step which means they exclude IFN_COPYSIGN. COPYSIGN however is restricted to only the C99 builtins and so doesn't work for vectors. The patch expands these optimizations to work as nested iters. This is needed for the second patch which will add the testcase. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: PR tree-optimization/109154 * match.pd: expand existing copysign optimizations. --- inline copy of patch -- diff --git a/gcc/match.pd b/gcc/match.pd index 7d651a6582d169793cca4f9a70e334dd80014d92..db95931df0672cf4ef08cca36085c3aa6831519e 100644 --- diff --git a/gcc/match.pd b/gcc/match.pd index 7d651a6582d169793cca4f9a70e334dd80014d92..db95931df0672cf4ef08cca36085c3aa6831519e 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1074,37 +1074,37 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* cos(copysign(x, y)) -> cos(x). Similarly for cosh. */ (for coss (COS COSH) - copysigns (COPYSIGN) - (simplify - (coss (copysigns @0 @1)) - (coss @0))) + (for copysigns (COPYSIGN) + (simplify + (coss (copysigns @0 @1)) + (coss @0)))) /* pow(copysign(x, y), z) -> pow(x, z) if z is an even integer. */ (for pows (POW) - copysigns (COPYSIGN) - (simplify - (pows (copysigns @0 @2) REAL_CST@1) - (with { HOST_WIDE_INT n; } - (if (real_isinteger (&TREE_REAL_CST (@1), &n) && (n & 1) == 0) - (pows @0 @1))))) + (for copysigns (COPYSIGN) + (simplify + (pows (copysigns @0 @2) REAL_CST@1) + (with { HOST_WIDE_INT n; } + (if (real_isinteger (&TREE_REAL_CST (@1), &n) && (n & 1) == 0) + (pows @0 @1)))))) /* Likewise for powi. */ (for pows (POWI) - copysigns (COPYSIGN) - (simplify - (pows (copysigns @0 @2) INTEGER_CST@1) - (if ((wi::to_wide (@1) & 1) == 0) - (pows @0 @1)))) + (for copysigns (COPYSIGN) + (simplify + (pows (copysigns @0 @2) INTEGER_CST@1) + (if ((wi::to_wide (@1) & 1) == 0) + (pows @0 @1))))) (for hypots (HYPOT) - copysigns (COPYSIGN) - /* hypot(copysign(x, y), z) -> hypot(x, z). */ - (simplify - (hypots (copysigns @0 @1) @2) - (hypots @0 @2)) - /* hypot(x, copysign(y, z)) -> hypot(x, y). */ - (simplify - (hypots @0 (copysigns @1 @2)) - (hypots @0 @1))) + (for copysigns (COPYSIGN) + /* hypot(copysign(x, y), z) -> hypot(x, z). */ + (simplify + (hypots (copysigns @0 @1) @2) + (hypots @0 @2)) + /* hypot(x, copysign(y, z)) -> hypot(x, y). */ + (simplify + (hypots @0 (copysigns @1 @2)) + (hypots @0 @1)))) /* copysign(x, CST) -> [-]abs (x). */ (for copysigns (COPYSIGN_ALL) --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1074,37 +1074,37 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* cos(copysign(x, y)) -> cos(x). Similarly for cosh. */ (for coss (COS COSH) - copysigns (COPYSIGN) - (simplify - (coss (copysigns @0 @1)) - (coss @0))) + (for copysigns (COPYSIGN) + (simplify + (coss (copysigns @0 @1)) + (coss @0)))) /* pow(copysign(x, y), z) -> pow(x, z) if z is an even integer. */ (for pows (POW) - copysigns (COPYSIGN) - (simplify - (pows (copysigns @0 @2) REAL_CST@1) - (with { HOST_WIDE_INT n; } - (if (real_isinteger (&TREE_REAL_CST (@1), &n) && (n & 1) == 0) - (pows @0 @1))))) + (for copysigns (COPYSIGN) + (simplify + (pows (copysigns @0 @2) REAL_CST@1) + (with { HOST_WIDE_INT n; } + (if (real_isinteger (&TREE_REAL_CST (@1), &n) && (n & 1) == 0) + (pows @0 @1)))))) /* Likewise for powi. */ (for pows (POWI) - copysigns (COPYSIGN) - (simplify - (pows (copysigns @0 @2) INTEGER_CST@1) - (if ((wi::to_wide (@1) & 1) == 0) - (pows @0 @1)))) + (for copysigns (COPYSIGN) + (simplify + (pows (copysigns @0 @2) INTEGER_CST@1) + (if ((wi::to_wide (@1) & 1) == 0) + (pows @0 @1))))) (for hypots (HYPOT) - copysigns (COPYSIGN) - /* hypot(copysign(x, y), z) -> hypot(x, z). */ - (simplify - (hypots (copysigns @0 @1) @2) - (hypots @0 @2)) - /* hypot(x, copysign(y, z)) -> hypot(x, y). */ - (simplify - (hypots @0 (copysigns @1 @2)) - (hypots @0 @1))) + (for copysigns (COPYSIGN) + /* hypot(copysign(x, y), z) -> hypot(x, z). */ + (simplify + (hypots (copysigns @0 @1) @2) + (hypots @0 @2)) + /* hypot(x, copysign(y, z)) -> hypot(x, y). */ + (simplify + (hypots @0 (copysigns @1 @2)) + (hypots @0 @1)))) /* copysign(x, CST) -> [-]abs (x). */ (for copysigns (COPYSIGN_ALL) From patchwork Mon Nov 6 10:20:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 161923 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2558419vqu; Mon, 6 Nov 2023 02:21:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHH9UpPM0AcOqiQ8ves0uZ1/B7H6tAzzRB7ww0mFIcd5MRJWP1RdFukzPBhau7hnTzUlpb7 X-Received: by 2002:a05:620a:1998:b0:773:a028:71b6 with SMTP id bm24-20020a05620a199800b00773a02871b6mr31789400qkb.65.1699266065125; Mon, 06 Nov 2023 02:21:05 -0800 (PST) ARC-Seal: i=4; a=rsa-sha256; t=1699266065; cv=pass; d=google.com; s=arc-20160816; b=axYBOEuN6BcAtY/18R5puCuIgROVLpeAl+U4jtb00hx87RXLVThhKWmpoGEcVkn+hL 7LwhUjZYBef6RieT+fGJTH737dQCuYolUi4sN6clfBuPOK/pXjdJFj2xq6d8o03t2rvJ EKP0zqT7R+Ho+4Do7EJUOeT9vcWRk7PW/ocl2UYJ/x4AbSIPg4jDBGf5RLtA/XsO5l/c PXxKR4lw7Tf8UJgRmZqbALsvABntltLlTUd5rg89+VH+DxzUGojMAiHRyYQYjHDBdX5j T8/j2WhRlI+LauiJwIR/t0Lmt4XFYeEZnd0vU+vjShgggnazB/gqzTyQtGXU9KhqcexS bNiw== ARC-Message-Signature: i=4; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:original-authentication-results :nodisclaimer:mime-version:in-reply-to:content-disposition :message-id:subject:cc:to:from:date:authentication-results-original :dkim-signature:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=FZkXBVoA5o/ZAEhElb9HqOsDDsdOydepMGOLV7p4x3Y=; fh=6lLuKcPp5JwcfhLsQ40FQN1vJS1KxlKbf2GiViQwbCM=; b=V+xw9I85w1yyWXo6Vbxd5PRIEzMG0jaAZxfMDeoeqF7f7CSyEw3liC0KcpgmU78dW0 lpJtXraZc5aP1k4mKg+eV+B0hW8qudC0Xr28Qbz9xbNm7x+oClNv+nE5OCuxfyxPAFz4 RAAoOrDDYOMlk4QRzXooDswg/U5HuM5JmEhVIPWaLScVGfwXySRNzaNqRCLe0N3VcldB 4gtMQMGC1/y+2J+IuBvO+uSPSjSqoql+CjVuWU/owdBgfBgnqfIOH6X0dNd8g2bOcYSG M/tsB2tmuQzz99UPZu92HwddHTwYZRh5hTosxxKsn2hIGLXddLhHz0RgsD2FVE7mCE3b 253Q== ARC-Authentication-Results: i=4; mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=u4sYxAYf; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=u4sYxAYf; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id a40-20020a05620a43a800b007743448d7ddsi5713543qkp.212.2023.11.06.02.21.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 02:21:05 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=u4sYxAYf; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=u4sYxAYf; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D9E0A3856DD0 for ; Mon, 6 Nov 2023 10:21:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2070.outbound.protection.outlook.com [40.107.104.70]) by sourceware.org (Postfix) with ESMTPS id CE8BF3856092 for ; Mon, 6 Nov 2023 10:20:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE8BF3856092 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 CE8BF3856092 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.104.70 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1699266038; cv=pass; b=MQ6us0BDbxqNJlZFEIv9ltwd2vlqC2Szk5uTlXUBBUx4/82N55Bh19vTXZP1GNQBzw6dFDTLW2TzeYfktigr+bUYqCxxwPVpkMk9mhzaRA3a+2HWBcQjBeogxM9rscv4kPFdzX0y9vSdZ7kjW9itGpebTC0lssp1CuZvNEtNco8= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1699266038; c=relaxed/simple; bh=uxVm/UKRF8Tkg7n3j7/J56LM4FtuZ6tr+9nJnwymz+0=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=tbS4mozgu8e0nhxkEbpcIzlsFbio6kjwzu9oxawXiJPLPm6VBf8Rrac/rWIX/KFJGXL/lW5XCn/UWR5a8Vs3vdq+KmStiP5qOO9Svp35X1f9zPB+ZsnMa1/DLoheeBnTaIo9q/EaJHdJTd4wBeEO8g8uwPmP1atCPeg2Ppuc1to= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=iagzdVDjn0aYh65Wd1YizOCpuZIi9C8NWZPQyegp8Uw4UhLPxd08VxlZjyfXMGSyKYsoo2wIRFjFa77qS53/TlYy2vzG7OjWSLGx/JE1NtLXXGrlGFOSW5Px2eDl6zry1yxoBFMx11fyQ298BiwLs8Blzr80FPyR7KI1M8hqNHj5jLmJkiBqNEuPJeN+7GbrEDONYL9r5d3FTghHvgkTqcLk3XSrWKcJKnNAJRkq5En9DK5aWbzHiDo58OLb2eU6MYLGrCmFLZij4ePFamtkFq/kXNbW7xunP2priY2WOQfrof0Ja8RDeGbbZO+2SSDmq2Jo8GLqhyDDicI/K1B/Dw== 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=FZkXBVoA5o/ZAEhElb9HqOsDDsdOydepMGOLV7p4x3Y=; b=gEegJdzLwfKnBFC2eI8pfXigFjrCcNQI3mF1relz6nHto3g1Ij8/NAcgQymF64qTtvwqMsZwhglYck7NRjxENeHAAIfejBeicCznP6vxqI5Wh22TTMOiq/gZYB8UVPc1Xal1wLwxhg78510dquCFLBegMATUO7u379kN6I0Yx7cjEYFzaGpSYGL10DHpW2APd8i3lAeCfxZDxd8rg5RU3lUDiQrCs1FDhMTx9PXAUZ4Uy9JNa+KNasXK28f61T1+UZ8NOwlaFlHTqfPPx3zJfZA6HRxFFpWiP7cmIsgZQdulYd1jZ2vv5U2dgnxsJ1G4cwfrWfu1+flq0v0hFP1J8w== 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=FZkXBVoA5o/ZAEhElb9HqOsDDsdOydepMGOLV7p4x3Y=; b=u4sYxAYf0s9wc8NKP/VCUfLstHWEuUmLHr/dPfbyfcyeQ/EVNWFSDXzlUQtMdQGxTlJZej1Sx2+0vvELStR/7LmKwxE7mBYmwRUL2hS2ZhrxvMU6SZ+a1gLJs1dZp69Msfa2RdR0yekLRnTydeWJerEIn3UtpE5hydWw5fSuJvs= Received: from DB9PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:10:1d9::23) by DU0PR08MB9417.eurprd08.prod.outlook.com (2603:10a6:10:420::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 10:20:29 +0000 Received: from DB1PEPF00039231.eurprd03.prod.outlook.com (2603:10a6:10:1d9:cafe::f2) by DB9PR02CA0018.outlook.office365.com (2603:10a6:10:1d9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.27 via Frontend Transport; Mon, 6 Nov 2023 10:20:29 +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 DB1PEPF00039231.mail.protection.outlook.com (10.167.8.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.16 via Frontend Transport; Mon, 6 Nov 2023 10:20:29 +0000 Received: ("Tessian outbound 5d213238733f:v228"); Mon, 06 Nov 2023 10:20:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e3e55b8d3308606e X-CR-MTA-TID: 64aa7808 Received: from 79a7f003afde.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 134A0786-E665-41F4-A8C7-CCEB01F1B059.1; Mon, 06 Nov 2023 10:20:22 +0000 Received: from EUR02-AM0-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 79a7f003afde.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 06 Nov 2023 10:20:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A8wMvYTwxPe2qxIg7jZn21kUTCXKfmzm5bX4j/hTttq07eTOyykFb8rKH2DBra11F8eJwOp5edNCuQJakLCxHOljSTy1OKQoZODLnjKnrW06MKSIcuPo51ukwXg9+c+LhqefNjL0ePKyRwRcrXg8dIOQw8uM5/d8Dn46vMniXL2z2D9E0yf2txGDt3jBYm4mQ18gXZJplzy3qsTwisvWCeJklRDAfVgBIKcQAhM/h2HF8PlPive5ByeoTrs8mtzFDFyRnoMd9MFO3Pq71V0PUZ2Fv5XhY0B5JUeIQK6uCHMbfH8EFnuViHZ/pVw/IYWrA6decqhA7bft5qktBPTBNg== 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=FZkXBVoA5o/ZAEhElb9HqOsDDsdOydepMGOLV7p4x3Y=; b=fHtureHSi8C7s32D5KD1gdFu0qANM74hjX42zxOwHQ/lTGPE8bAo7jk5eG3FFNWfZok8DCPTmYT2CMlgBZy9w9qbJ2T1aAmWr5IxYRiO2t+jQ4ep4IBf744gJ94ncxwzqSQg9PEN11pcWVI2vy2q7KlZZemWST7nrDZIpDIFO84fcGdQmOrru1nd4vVdcDUtaq5Y8dgCL+6wDyujPUgTLcjgGg7cn2wn+P0BwM88d5MXEh40Mdi1LhWk45DVfHFNq5X7vbylW2yxGlIvJndTDrhJHlz5yrWnWe2iKxOYKX+3mdbyV6zPb22Hc+mpUwOWI2BwIbf7xDwAhDlyjHdHvg== 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=FZkXBVoA5o/ZAEhElb9HqOsDDsdOydepMGOLV7p4x3Y=; b=u4sYxAYf0s9wc8NKP/VCUfLstHWEuUmLHr/dPfbyfcyeQ/EVNWFSDXzlUQtMdQGxTlJZej1Sx2+0vvELStR/7LmKwxE7mBYmwRUL2hS2ZhrxvMU6SZ+a1gLJs1dZp69Msfa2RdR0yekLRnTydeWJerEIn3UtpE5hydWw5fSuJvs= 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 DU0PR08MB9679.eurprd08.prod.outlook.com (2603:10a6:10:445::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 10:20:19 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::26aa:efdd:a74a:27d0]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::26aa:efdd:a74a:27d0%5]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 10:20:19 +0000 Date: Mon, 6 Nov 2023 10:20:17 +0000 From: Tamar Christina To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, rguenther@suse.de, jlaw@ventanamicro.com Subject: [PATCH v3 2/2]middle-end match.pd: optimize fneg (fabs (x)) to copysign (x, -1) [PR109154] Message-ID: Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: LO4P123CA0096.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:191::11) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|DU0PR08MB9679:EE_|DB1PEPF00039231:EE_|DU0PR08MB9417:EE_ X-MS-Office365-Filtering-Correlation-Id: 8724d2a7-e2e8-4d86-c92b-08dbdeb20055 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: E3+UAaxnnMxO/0gqBRQv4SdsyEMEWgiOJRRMVqOmUzZ5EY1tE8bBk+PhX6npcY0MUWK5UoqEfINL3z2X4CDN/0K3O8GaQQ3d0Nwii1QHDb9q9vylpg+PtAeK/0Od2E8t50TruBxJrXYH57GcKLLuzsqAgum+gjFJdX8HEOZWmKGNjYKj/4tD84im1lpYZ4za3FBsA9h49ari46YuhbE4K+DDqFCzYoL54FGYBqSrMEnTQicfYXFz0Q44WJ+fKrfmBvEA0FgEnBgnn82R+yzKA4Y2EmlHCsiO9yPX244dM9OaX5elNhE3aFCOANPhR9GK4eeuSBmvoeqzTq/XABJtuehWYCEzUqsx+PJCix63iqIXx+CykQbYgze64Q8kQQyy4B7tTuloSAy4qn4Ea4/fxnBlo90FZYPCYh5u6c4iTsF0URs9z/5FhjWniMqrpSQvPmGnJu9okU/pZKyLPGapNHtxv4oAIYfV7+G87ZN2k46LGp5ogaJUBSh4MRXZcOUBy0epQ9VnzTLn4im5ytkBBdHzwDTuhMPcWwPhMMYXd9AME4XOzEQZlP8Ct2tVwsXvY5Wov1oJzbpFccIKlwWai870Xc5+xq4JQW4ITO4iW+pAWHucJjrydFgac4oYY+zOypXLMu3PZHAqRVF9cE0YiND0wn0YPCdjqfbiKbPUsEY= 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)(136003)(366004)(396003)(376002)(346002)(39860400002)(230922051799003)(64100799003)(1800799009)(451199024)(186009)(84970400001)(83380400001)(36756003)(4326008)(8936002)(44832011)(86362001)(41300700001)(2906002)(8676002)(30864003)(478600001)(33964004)(44144004)(6486002)(6506007)(38100700002)(316002)(6916009)(5660300002)(235185007)(66476007)(66556008)(6512007)(26005)(2616005)(66946007)(2700100001)(357404004); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9679 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: DB1PEPF00039231.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4052f693-5e3e-43cf-2894-08dbdeb1fa38 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qvy0XkAXnCWhULByEeiMuDl/XIS2prFZFuDg87oC8EA4P4phiiO3QLM8SyMAOiWQAFdNJMIAIKChsPZhcyt9BCntMuLR43YmElBY+pcZh+51VyAFxB/YxYj6iq28A51CmOQhnERrh2FWtP7SJopGkbIGBnx4JRSAoMizGOqHBP1SNpVL0B8YUYpDlM5eRFOx2ArLm4KpCWlRsOQoFcVeDBPSLjeKXba4f3l++2+iC//dMiM2/+3XNnFvEQNzlsJu2Om2T0gu2T+asdWFD5GYkVgHezSnad0RL919NEHvQ2Ie3Ir6YrWJplMe05KP0877pRZU17PuNmUIPLMOFMZaBUwqdfiv4eJDmEWn6NJ0+aAhr5rl34LFgzwzR6xJSi+h8bxtIqT5Rrkv/Yrst2qqHQ5dK2A+E8FPETU2RUIHyMyGH0c/5okUFlfzhrGalVKlClEqG9Lkp3JlyeA9paPYCPPUKrVjj+ZVdE9CcuaWlR8Jxymx5s6nvhaji1ZTGsA0vPX/07Pifc4SPLOSPtzLv1SX8oHVbk6QaIycaTDLUF35kHoFjmxZVzTSKEPUOG+LqOaU7TJtZN8jtCdgHrstWTqhwKH0M32ex47YnV7dQ5cPZUDHIjkiIkhIHZwcJU0IHnekIUO+WfOiVA3ZH21/v/4CyYHabQ346m4+06SqYz+P9mEvbAMPyHNYOYGdLAriIBibcY7wJA8A+uucnUu5R3zdTWwIylCPahORE8hXjhUctUNLKfjFrMhI7dImA0lZJN74MqjE6EtRVx7ZsmZ4gTQ8YxBpTkkDCdq9epVoeqpdkf+ZImbETQiX2v7rzwTed9sYee1W+C7V6Vgcp9txxg== 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)(376002)(39860400002)(346002)(396003)(230922051799003)(186009)(1800799009)(64100799003)(82310400011)(451199024)(46966006)(36840700001)(40470700004)(47076005)(8936002)(8676002)(4326008)(6506007)(2616005)(235185007)(33964004)(44144004)(5660300002)(6512007)(6486002)(30864003)(107886003)(40480700001)(336012)(2906002)(83380400001)(26005)(84970400001)(478600001)(41300700001)(82740400003)(36860700001)(6916009)(70586007)(70206006)(316002)(44832011)(81166007)(356005)(86362001)(40460700003)(36756003)(2700100001)(357404004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 10:20:29.4224 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8724d2a7-e2e8-4d86-c92b-08dbdeb20055 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: DB1PEPF00039231.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9417 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781809613296434042 X-GMAIL-MSGID: 1781809613296434042 Hi All, This patch transforms fneg (fabs (x)) into copysign (x, -1) which is more canonical and allows a target to expand this sequence efficiently. Such sequences are common in scientific code working with gradients. There is an existing canonicalization of copysign (x, -1) to fneg (fabs (x)) which I remove since this is a less efficient form. The testsuite is also updated in light of this. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: PR tree-optimization/109154 * match.pd: Add new neg+abs rule, remove inverse copysign rule. gcc/testsuite/ChangeLog: PR tree-optimization/109154 * gcc.dg/fold-copysign-1.c: Updated. * gcc.dg/pr55152-2.c: Updated. * gcc.dg/tree-ssa/abs-4.c: Updated. * gcc.dg/tree-ssa/backprop-6.c: Updated. * gcc.dg/tree-ssa/copy-sign-2.c: Updated. * gcc.dg/tree-ssa/mult-abs-2.c: Updated. * gcc.target/aarch64/fneg-abs_1.c: New test. * gcc.target/aarch64/fneg-abs_2.c: New test. * gcc.target/aarch64/fneg-abs_3.c: New test. * gcc.target/aarch64/fneg-abs_4.c: New test. * gcc.target/aarch64/sve/fneg-abs_1.c: New test. * gcc.target/aarch64/sve/fneg-abs_2.c: New test. * gcc.target/aarch64/sve/fneg-abs_3.c: New test. * gcc.target/aarch64/sve/fneg-abs_4.c: New test. --- inline copy of patch -- diff --git a/gcc/match.pd b/gcc/match.pd index db95931df0672cf4ef08cca36085c3aa6831519e..7a023d510c283c43a87b1795a74761b8af979b53 100644 --- diff --git a/gcc/match.pd b/gcc/match.pd index db95931df0672cf4ef08cca36085c3aa6831519e..7a023d510c283c43a87b1795a74761b8af979b53 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1106,13 +1106,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (hypots @0 (copysigns @1 @2)) (hypots @0 @1)))) -/* copysign(x, CST) -> [-]abs (x). */ -(for copysigns (COPYSIGN_ALL) - (simplify - (copysigns @0 REAL_CST@1) - (if (REAL_VALUE_NEGATIVE (TREE_REAL_CST (@1))) - (negate (abs @0)) - (abs @0)))) +/* Transform fneg (fabs (X)) -> copysign (X, -1). */ + +(simplify + (negate (abs @0)) + (IFN_COPYSIGN @0 { build_minus_one_cst (type); })) /* copysign(copysign(x, y), z) -> copysign(x, z). */ (for copysigns (COPYSIGN_ALL) diff --git a/gcc/testsuite/gcc.dg/fold-copysign-1.c b/gcc/testsuite/gcc.dg/fold-copysign-1.c index f17d65c24ee4dca9867827d040fe0a404c515e7b..f9cafd14ab05f5e8ab2f6f68e62801d21c2df6a6 100644 --- a/gcc/testsuite/gcc.dg/fold-copysign-1.c +++ b/gcc/testsuite/gcc.dg/fold-copysign-1.c @@ -12,5 +12,5 @@ double bar (double x) return __builtin_copysign (x, minuszero); } -/* { dg-final { scan-tree-dump-times "= -" 1 "cddce1" } } */ -/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 2 "cddce1" } } */ +/* { dg-final { scan-tree-dump-times "__builtin_copysign" 1 "cddce1" } } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 1 "cddce1" } } */ diff --git a/gcc/testsuite/gcc.dg/pr55152-2.c b/gcc/testsuite/gcc.dg/pr55152-2.c index 54db0f2062da105a829d6690ac8ed9891fe2b588..605f202ed6bc7aa8fe921457b02ff0b88cc63ce6 100644 --- a/gcc/testsuite/gcc.dg/pr55152-2.c +++ b/gcc/testsuite/gcc.dg/pr55152-2.c @@ -10,4 +10,5 @@ int f(int a) return (a<-a)?a:-a; } -/* { dg-final { scan-tree-dump-times "ABS_EXPR" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\.COPYSIGN" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c index 6197519faf7b55aed7bc162cd0a14dd2145210ca..e1b825f37f69ac3c4666b3a52d733368805ad31d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c @@ -9,5 +9,6 @@ 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" 3 "optimized"} } */ -/* { dg-final { scan-tree-dump-times "= -" 3 "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"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c b/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c index 31f05716f1498dc709cac95fa20fb5796642c77e..c3a138642d6ff7be984e91fa1343cb2718db7ae1 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c @@ -26,5 +26,6 @@ TEST_FUNCTION (float, f) TEST_FUNCTION (double, ) TEST_FUNCTION (long double, l) -/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = -} 6 "backprop" } } */ -/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = ABS_EXPR <} 3 "backprop" } } */ +/* { 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" } } */ 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 de52c5f7c8062958353d91f5031193defc9f3f91..e5d565c4b9832c00106588ef411fbd8c292a5cad 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c @@ -10,4 +10,5 @@ float f1(float x) float t = __builtin_copysignf (1.0f, -x); return x * t; } -/* { dg-final { scan-tree-dump-times "ABS" 2 "optimized"} } */ +/* { dg-final { scan-tree-dump-times "ABS" 1 "optimized"} } */ +/* { dg-final { scan-tree-dump-times ".COPYSIGN" 1 "optimized"} } */ 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 a41f1baf25669a4fd301a586a49ba5e3c5b966ab..a22896b21c8b5a4d5d8e28bd8ae0db896e63ade0 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c @@ -34,4 +34,5 @@ float i1(float x) { return x * (x <= 0.f ? 1.f : -1.f); } -/* { dg-final { scan-tree-dump-times "ABS" 8 "gimple"} } */ +/* { dg-final { scan-tree-dump-times "ABS" 4 "gimple"} } */ +/* { dg-final { scan-tree-dump-times "\.COPYSIGN" 4 "gimple"} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/fneg-abs_1.c b/gcc/testsuite/gcc.target/aarch64/fneg-abs_1.c new file mode 100644 index 0000000000000000000000000000000000000000..f823013c3ddf6b3a266c3abfcbf2642fc2a75fa6 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fneg-abs_1.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#pragma GCC target "+nosve" + +#include + +/* +** t1: +** orr v[0-9]+.2s, #128, lsl #24 +** ret +*/ +float32x2_t t1 (float32x2_t a) +{ + return vneg_f32 (vabs_f32 (a)); +} + +/* +** t2: +** orr v[0-9]+.4s, #128, lsl #24 +** ret +*/ +float32x4_t t2 (float32x4_t a) +{ + return vnegq_f32 (vabsq_f32 (a)); +} + +/* +** t3: +** adrp x0, .LC[0-9]+ +** ldr q[0-9]+, \[x0, #:lo12:.LC0\] +** orr v[0-9]+.16b, v[0-9]+.16b, v[0-9]+.16b +** ret +*/ +float64x2_t t3 (float64x2_t a) +{ + return vnegq_f64 (vabsq_f64 (a)); +} diff --git a/gcc/testsuite/gcc.target/aarch64/fneg-abs_2.c b/gcc/testsuite/gcc.target/aarch64/fneg-abs_2.c new file mode 100644 index 0000000000000000000000000000000000000000..141121176b309e4b2aa413dc55271a6e3c93d5e1 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fneg-abs_2.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#pragma GCC target "+nosve" + +#include +#include + +/* +** f1: +** movi v[0-9]+.2s, 0x80, lsl 24 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float32_t f1 (float32_t a) +{ + return -fabsf (a); +} + +/* +** f2: +** mov x0, -9223372036854775808 +** fmov d[0-9]+, x0 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float64_t f2 (float64_t a) +{ + return -fabs (a); +} diff --git a/gcc/testsuite/gcc.target/aarch64/fneg-abs_3.c b/gcc/testsuite/gcc.target/aarch64/fneg-abs_3.c new file mode 100644 index 0000000000000000000000000000000000000000..b4652173a95d104ddfa70c497f0627a61ea89d3b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fneg-abs_3.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#pragma GCC target "+nosve" + +#include +#include + +/* +** f1: +** ... +** ldr q[0-9]+, \[x0\] +** orr v[0-9]+.4s, #128, lsl #24 +** str q[0-9]+, \[x0\], 16 +** ... +*/ +void f1 (float32_t *a, int n) +{ + for (int i = 0; i < (n & -8); i++) + a[i] = -fabsf (a[i]); +} + +/* +** f2: +** ... +** ldr q[0-9]+, \[x0\] +** orr v[0-9]+.16b, v[0-9]+.16b, v[0-9]+.16b +** str q[0-9]+, \[x0\], 16 +** ... +*/ +void f2 (float64_t *a, int n) +{ + for (int i = 0; i < (n & -8); i++) + a[i] = -fabs (a[i]); +} diff --git a/gcc/testsuite/gcc.target/aarch64/fneg-abs_4.c b/gcc/testsuite/gcc.target/aarch64/fneg-abs_4.c new file mode 100644 index 0000000000000000000000000000000000000000..10879dea74462d34b26160eeb0bd54ead063166b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fneg-abs_4.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#pragma GCC target "+nosve" + +#include + +/* +** negabs: +** mov x0, -9223372036854775808 +** fmov d[0-9]+, x0 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +double negabs (double x) +{ + unsigned long long y; + memcpy (&y, &x, sizeof(double)); + y = y | (1UL << 63); + memcpy (&x, &y, sizeof(double)); + return x; +} + +/* +** negabsf: +** movi v[0-9]+.2s, 0x80, lsl 24 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float negabsf (float x) +{ + unsigned int y; + memcpy (&y, &x, sizeof(float)); + y = y | (1U << 31); + memcpy (&x, &y, sizeof(float)); + return x; +} + diff --git a/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_1.c b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_1.c new file mode 100644 index 0000000000000000000000000000000000000000..0c7664e6de77a497682952653ffd417453854d52 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_1.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#include + +/* +** t1: +** orr v[0-9]+.2s, #128, lsl #24 +** ret +*/ +float32x2_t t1 (float32x2_t a) +{ + return vneg_f32 (vabs_f32 (a)); +} + +/* +** t2: +** orr v[0-9]+.4s, #128, lsl #24 +** ret +*/ +float32x4_t t2 (float32x4_t a) +{ + return vnegq_f32 (vabsq_f32 (a)); +} + +/* +** t3: +** adrp x0, .LC[0-9]+ +** ldr q[0-9]+, \[x0, #:lo12:.LC0\] +** orr v[0-9]+.16b, v[0-9]+.16b, v[0-9]+.16b +** ret +*/ +float64x2_t t3 (float64x2_t a) +{ + return vnegq_f64 (vabsq_f64 (a)); +} diff --git a/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_2.c b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_2.c new file mode 100644 index 0000000000000000000000000000000000000000..a60cd31b9294af2dac69eed1c93f899bd5c78fca --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_2.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#include +#include + +/* +** f1: +** movi v[0-9]+.2s, 0x80, lsl 24 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float32_t f1 (float32_t a) +{ + return -fabsf (a); +} + +/* +** f2: +** mov x0, -9223372036854775808 +** fmov d[0-9]+, x0 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float64_t f2 (float64_t a) +{ + return -fabs (a); +} diff --git a/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_3.c b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_3.c new file mode 100644 index 0000000000000000000000000000000000000000..1bf34328d8841de8e6b0a5458562a9f00e31c275 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_3.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#include +#include + +/* +** f1: +** ... +** ld1w z[0-9]+.s, p[0-9]+/z, \[x0, x2, lsl 2\] +** orr z[0-9]+.s, z[0-9]+.s, #0x80000000 +** st1w z[0-9]+.s, p[0-9]+, \[x0, x2, lsl 2\] +** ... +*/ +void f1 (float32_t *a, int n) +{ + for (int i = 0; i < (n & -8); i++) + a[i] = -fabsf (a[i]); +} + +/* +** f2: +** ... +** ld1d z[0-9]+.d, p[0-9]+/z, \[x0, x2, lsl 3\] +** orr z[0-9]+.d, z[0-9]+.d, #0x8000000000000000 +** st1d z[0-9]+.d, p[0-9]+, \[x0, x2, lsl 3\] +** ... +*/ +void f2 (float64_t *a, int n) +{ + for (int i = 0; i < (n & -8); i++) + a[i] = -fabs (a[i]); +} diff --git a/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_4.c b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_4.c new file mode 100644 index 0000000000000000000000000000000000000000..21f2a8da2a5d44e3d01f6604ca7be87e3744d494 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_4.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#include + +/* +** negabs: +** mov x0, -9223372036854775808 +** fmov d[0-9]+, x0 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +double negabs (double x) +{ + unsigned long long y; + memcpy (&y, &x, sizeof(double)); + y = y | (1UL << 63); + memcpy (&x, &y, sizeof(double)); + return x; +} + +/* +** negabsf: +** movi v[0-9]+.2s, 0x80, lsl 24 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float negabsf (float x) +{ + unsigned int y; + memcpy (&y, &x, sizeof(float)); + y = y | (1U << 31); + memcpy (&x, &y, sizeof(float)); + return x; +} + --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1106,13 +1106,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (hypots @0 (copysigns @1 @2)) (hypots @0 @1)))) -/* copysign(x, CST) -> [-]abs (x). */ -(for copysigns (COPYSIGN_ALL) - (simplify - (copysigns @0 REAL_CST@1) - (if (REAL_VALUE_NEGATIVE (TREE_REAL_CST (@1))) - (negate (abs @0)) - (abs @0)))) +/* Transform fneg (fabs (X)) -> copysign (X, -1). */ + +(simplify + (negate (abs @0)) + (IFN_COPYSIGN @0 { build_minus_one_cst (type); })) /* copysign(copysign(x, y), z) -> copysign(x, z). */ (for copysigns (COPYSIGN_ALL) diff --git a/gcc/testsuite/gcc.dg/fold-copysign-1.c b/gcc/testsuite/gcc.dg/fold-copysign-1.c index f17d65c24ee4dca9867827d040fe0a404c515e7b..f9cafd14ab05f5e8ab2f6f68e62801d21c2df6a6 100644 --- a/gcc/testsuite/gcc.dg/fold-copysign-1.c +++ b/gcc/testsuite/gcc.dg/fold-copysign-1.c @@ -12,5 +12,5 @@ double bar (double x) return __builtin_copysign (x, minuszero); } -/* { dg-final { scan-tree-dump-times "= -" 1 "cddce1" } } */ -/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 2 "cddce1" } } */ +/* { dg-final { scan-tree-dump-times "__builtin_copysign" 1 "cddce1" } } */ +/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 1 "cddce1" } } */ diff --git a/gcc/testsuite/gcc.dg/pr55152-2.c b/gcc/testsuite/gcc.dg/pr55152-2.c index 54db0f2062da105a829d6690ac8ed9891fe2b588..605f202ed6bc7aa8fe921457b02ff0b88cc63ce6 100644 --- a/gcc/testsuite/gcc.dg/pr55152-2.c +++ b/gcc/testsuite/gcc.dg/pr55152-2.c @@ -10,4 +10,5 @@ int f(int a) return (a<-a)?a:-a; } -/* { dg-final { scan-tree-dump-times "ABS_EXPR" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "\.COPYSIGN" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c index 6197519faf7b55aed7bc162cd0a14dd2145210ca..e1b825f37f69ac3c4666b3a52d733368805ad31d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c @@ -9,5 +9,6 @@ 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" 3 "optimized"} } */ -/* { dg-final { scan-tree-dump-times "= -" 3 "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"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c b/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c index 31f05716f1498dc709cac95fa20fb5796642c77e..c3a138642d6ff7be984e91fa1343cb2718db7ae1 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c @@ -26,5 +26,6 @@ TEST_FUNCTION (float, f) TEST_FUNCTION (double, ) TEST_FUNCTION (long double, l) -/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = -} 6 "backprop" } } */ -/* { dg-final { scan-tree-dump-times {Deleting[^\n]* = ABS_EXPR <} 3 "backprop" } } */ +/* { 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" } } */ 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 de52c5f7c8062958353d91f5031193defc9f3f91..e5d565c4b9832c00106588ef411fbd8c292a5cad 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c @@ -10,4 +10,5 @@ float f1(float x) float t = __builtin_copysignf (1.0f, -x); return x * t; } -/* { dg-final { scan-tree-dump-times "ABS" 2 "optimized"} } */ +/* { dg-final { scan-tree-dump-times "ABS" 1 "optimized"} } */ +/* { dg-final { scan-tree-dump-times ".COPYSIGN" 1 "optimized"} } */ 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 a41f1baf25669a4fd301a586a49ba5e3c5b966ab..a22896b21c8b5a4d5d8e28bd8ae0db896e63ade0 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c @@ -34,4 +34,5 @@ float i1(float x) { return x * (x <= 0.f ? 1.f : -1.f); } -/* { dg-final { scan-tree-dump-times "ABS" 8 "gimple"} } */ +/* { dg-final { scan-tree-dump-times "ABS" 4 "gimple"} } */ +/* { dg-final { scan-tree-dump-times "\.COPYSIGN" 4 "gimple"} } */ diff --git a/gcc/testsuite/gcc.target/aarch64/fneg-abs_1.c b/gcc/testsuite/gcc.target/aarch64/fneg-abs_1.c new file mode 100644 index 0000000000000000000000000000000000000000..f823013c3ddf6b3a266c3abfcbf2642fc2a75fa6 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fneg-abs_1.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#pragma GCC target "+nosve" + +#include + +/* +** t1: +** orr v[0-9]+.2s, #128, lsl #24 +** ret +*/ +float32x2_t t1 (float32x2_t a) +{ + return vneg_f32 (vabs_f32 (a)); +} + +/* +** t2: +** orr v[0-9]+.4s, #128, lsl #24 +** ret +*/ +float32x4_t t2 (float32x4_t a) +{ + return vnegq_f32 (vabsq_f32 (a)); +} + +/* +** t3: +** adrp x0, .LC[0-9]+ +** ldr q[0-9]+, \[x0, #:lo12:.LC0\] +** orr v[0-9]+.16b, v[0-9]+.16b, v[0-9]+.16b +** ret +*/ +float64x2_t t3 (float64x2_t a) +{ + return vnegq_f64 (vabsq_f64 (a)); +} diff --git a/gcc/testsuite/gcc.target/aarch64/fneg-abs_2.c b/gcc/testsuite/gcc.target/aarch64/fneg-abs_2.c new file mode 100644 index 0000000000000000000000000000000000000000..141121176b309e4b2aa413dc55271a6e3c93d5e1 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fneg-abs_2.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#pragma GCC target "+nosve" + +#include +#include + +/* +** f1: +** movi v[0-9]+.2s, 0x80, lsl 24 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float32_t f1 (float32_t a) +{ + return -fabsf (a); +} + +/* +** f2: +** mov x0, -9223372036854775808 +** fmov d[0-9]+, x0 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float64_t f2 (float64_t a) +{ + return -fabs (a); +} diff --git a/gcc/testsuite/gcc.target/aarch64/fneg-abs_3.c b/gcc/testsuite/gcc.target/aarch64/fneg-abs_3.c new file mode 100644 index 0000000000000000000000000000000000000000..b4652173a95d104ddfa70c497f0627a61ea89d3b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fneg-abs_3.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#pragma GCC target "+nosve" + +#include +#include + +/* +** f1: +** ... +** ldr q[0-9]+, \[x0\] +** orr v[0-9]+.4s, #128, lsl #24 +** str q[0-9]+, \[x0\], 16 +** ... +*/ +void f1 (float32_t *a, int n) +{ + for (int i = 0; i < (n & -8); i++) + a[i] = -fabsf (a[i]); +} + +/* +** f2: +** ... +** ldr q[0-9]+, \[x0\] +** orr v[0-9]+.16b, v[0-9]+.16b, v[0-9]+.16b +** str q[0-9]+, \[x0\], 16 +** ... +*/ +void f2 (float64_t *a, int n) +{ + for (int i = 0; i < (n & -8); i++) + a[i] = -fabs (a[i]); +} diff --git a/gcc/testsuite/gcc.target/aarch64/fneg-abs_4.c b/gcc/testsuite/gcc.target/aarch64/fneg-abs_4.c new file mode 100644 index 0000000000000000000000000000000000000000..10879dea74462d34b26160eeb0bd54ead063166b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fneg-abs_4.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#pragma GCC target "+nosve" + +#include + +/* +** negabs: +** mov x0, -9223372036854775808 +** fmov d[0-9]+, x0 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +double negabs (double x) +{ + unsigned long long y; + memcpy (&y, &x, sizeof(double)); + y = y | (1UL << 63); + memcpy (&x, &y, sizeof(double)); + return x; +} + +/* +** negabsf: +** movi v[0-9]+.2s, 0x80, lsl 24 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float negabsf (float x) +{ + unsigned int y; + memcpy (&y, &x, sizeof(float)); + y = y | (1U << 31); + memcpy (&x, &y, sizeof(float)); + return x; +} + diff --git a/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_1.c b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_1.c new file mode 100644 index 0000000000000000000000000000000000000000..0c7664e6de77a497682952653ffd417453854d52 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_1.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#include + +/* +** t1: +** orr v[0-9]+.2s, #128, lsl #24 +** ret +*/ +float32x2_t t1 (float32x2_t a) +{ + return vneg_f32 (vabs_f32 (a)); +} + +/* +** t2: +** orr v[0-9]+.4s, #128, lsl #24 +** ret +*/ +float32x4_t t2 (float32x4_t a) +{ + return vnegq_f32 (vabsq_f32 (a)); +} + +/* +** t3: +** adrp x0, .LC[0-9]+ +** ldr q[0-9]+, \[x0, #:lo12:.LC0\] +** orr v[0-9]+.16b, v[0-9]+.16b, v[0-9]+.16b +** ret +*/ +float64x2_t t3 (float64x2_t a) +{ + return vnegq_f64 (vabsq_f64 (a)); +} diff --git a/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_2.c b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_2.c new file mode 100644 index 0000000000000000000000000000000000000000..a60cd31b9294af2dac69eed1c93f899bd5c78fca --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_2.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#include +#include + +/* +** f1: +** movi v[0-9]+.2s, 0x80, lsl 24 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float32_t f1 (float32_t a) +{ + return -fabsf (a); +} + +/* +** f2: +** mov x0, -9223372036854775808 +** fmov d[0-9]+, x0 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float64_t f2 (float64_t a) +{ + return -fabs (a); +} diff --git a/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_3.c b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_3.c new file mode 100644 index 0000000000000000000000000000000000000000..1bf34328d8841de8e6b0a5458562a9f00e31c275 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_3.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#include +#include + +/* +** f1: +** ... +** ld1w z[0-9]+.s, p[0-9]+/z, \[x0, x2, lsl 2\] +** orr z[0-9]+.s, z[0-9]+.s, #0x80000000 +** st1w z[0-9]+.s, p[0-9]+, \[x0, x2, lsl 2\] +** ... +*/ +void f1 (float32_t *a, int n) +{ + for (int i = 0; i < (n & -8); i++) + a[i] = -fabsf (a[i]); +} + +/* +** f2: +** ... +** ld1d z[0-9]+.d, p[0-9]+/z, \[x0, x2, lsl 3\] +** orr z[0-9]+.d, z[0-9]+.d, #0x8000000000000000 +** st1d z[0-9]+.d, p[0-9]+, \[x0, x2, lsl 3\] +** ... +*/ +void f2 (float64_t *a, int n) +{ + for (int i = 0; i < (n & -8); i++) + a[i] = -fabs (a[i]); +} diff --git a/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_4.c b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_4.c new file mode 100644 index 0000000000000000000000000000000000000000..21f2a8da2a5d44e3d01f6604ca7be87e3744d494 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/fneg-abs_4.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-final { check-function-bodies "**" "" "" { target lp64 } } } */ + +#include + +/* +** negabs: +** mov x0, -9223372036854775808 +** fmov d[0-9]+, x0 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +double negabs (double x) +{ + unsigned long long y; + memcpy (&y, &x, sizeof(double)); + y = y | (1UL << 63); + memcpy (&x, &y, sizeof(double)); + return x; +} + +/* +** negabsf: +** movi v[0-9]+.2s, 0x80, lsl 24 +** orr v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b +** ret +*/ +float negabsf (float x) +{ + unsigned int y; + memcpy (&y, &x, sizeof(float)); + y = y | (1U << 31); + memcpy (&x, &y, sizeof(float)); + return x; +} +