From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01hn2231.outbound.protection.outlook.com [52.100.6.231]) by sourceware.org (Postfix) with ESMTPS id 6D5AB3858D1E for ; Fri, 13 Oct 2023 04:02:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D5AB3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=axis.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BmQgUNFyYiQJ6WXPpRTgSEEHQZMQjulg0I4dAmfA3KaoHuPI0sFquaKsgULE4L+h+s4rKawf255i5hoDfcbSLk21qxMabOyPl15ZDXOElkHZzGhErxBM6DHge+IJuGtMLTfZwPWoQRHuSwNoIeiMHUh2sMByJkkNUY+JDlQEt8RR5hUg8QKhfwlHpavg7kMRmDcZW+zXlNfkZ2ja6qaRuRks5g8fhEhiiWGES58LpskiF6pjNm4uz2yQ3OjZgN0R/OpUztoH/POKRd+vuNDicH+Sn8ZHxznV24B2n+YW/0VeLwprKpEkMKSiqNgMgEtDnOXIlXW22yIehGYdoHJvbA== 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=+MrKy4VQ427TB1O3LuHprl26kTtAAl/GqFR8BYrfswY=; b=RcVRxcBzU1K4o9EINBcbReHzBG5zcFd8aJpJqcSRN1ErDCVyccuZeO//PNi2s78xV3maL4yY+V4LV+ZuaYj6Qk5XWBI+KeiFSR8hydJkZ8B8KPl5Klj/zWPRXW2Hq5XH9u71R8K/Y87R8sOdkZiUeXTPoMYmDm0oVVTy+pfexzDjPKnnXtSrsy8nO1eXDgQxMGd7xN3TYJkgUvpjalqxADdKVNIQlUEsbXNgVf9GnJq6AAgxDfmHhWHy3JUz99gP1M89lQJmJvXXT3E4Mt9YlE4q5CKcD4BaJbBRVRXdwEvxDkqsw3xQpiH4pYHnW3zqfJiPPycE9oZJaCzhxe/0lg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 195.60.68.100) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=axis.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+MrKy4VQ427TB1O3LuHprl26kTtAAl/GqFR8BYrfswY=; b=fs0t1Zzo958KTdnjqRKXMvJEJWhirAZj+vO4s4+dfaSxaSrkWsYZbdthDRZJ+cSgXdoZUxubDIBYxi07QLx8H7YykebplYUvpucAE/2YUjPpewjGZeTsPNzZhKOOH5AsVmSYw6WbfLHVuS/uXbWfyA29+YEkd3daKThHimakGQc= Received: from AM6P193CA0052.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::29) by PAWPR02MB9687.eurprd02.prod.outlook.com (2603:10a6:102:2e5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.45; Fri, 13 Oct 2023 04:02:35 +0000 Received: from AMS0EPF000001B6.eurprd05.prod.outlook.com (2603:10a6:209:8e:cafe::d9) by AM6P193CA0052.outlook.office365.com (2603:10a6:209:8e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.27 via Frontend Transport; Fri, 13 Oct 2023 04:02:35 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=axis.com; Received-SPF: Fail (protection.outlook.com: domain of axis.com does not designate 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001B6.mail.protection.outlook.com (10.167.16.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 04:02:34 +0000 Received: from se-mail01w.axis.com (10.20.40.7) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 13 Oct 2023 06:02:31 +0200 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 13 Oct 2023 06:02:31 +0200 Received: from pchp3.se.axis.com (pchp3.se.axis.com [10.88.21.53]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id DBECC3539; Fri, 13 Oct 2023 06:02:31 +0200 (CEST) Received: by pchp3.se.axis.com (Postfix, from userid 171) id D6FFD20410; Fri, 13 Oct 2023 06:02:31 +0200 (CEST) From: Hans-Peter Nilsson To: Jeff Law CC: In-Reply-To: (message from Jeff Law on Fri, 29 Sep 2023 16:37:21 -0600) Subject: Re: [committed] RISC-V: Fix INSN costing and more zicond tests MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT References: Message-ID: <20231013040231.D6FFD20410@pchp3.se.axis.com> Date: Fri, 13 Oct 2023 06:02:31 +0200 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001B6:EE_|PAWPR02MB9687:EE_ X-MS-Office365-Filtering-Correlation-Id: a9788d6c-8d08-42fa-fdc8-08dbcba13b24 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +uhdzKARRKi3EGyKBp2oREx43RaT/RlmTzfTD8PPHTincFlwhMJx7Slbl96yZz2gI5f3LI+Q6ySsRwYzOePcPKZuckymgxceK2xkJzM+E4HWyFfTIpOee87EUz+G6C/rrEqB7ZuUJAIl1aO+fpvMH9Rx6RUqzfDEfKB+JSyHjaqcbJQgbaG9wZHh1ik6INNu+HCbBjE3mLgfshvGuH8WAGoAJp5im7tq1l6HyX3g+Poui4HKZnNjlAq1k3t7qK1kPLV5F0wD/aXiq/BSI8Thb843E3B8zmpblPX/dM1FK0BGhKriMhsQGusIIWQEQ4MAFVG63h5eXkKpoDRLva4BN67PkKqA2rPJpbvlZbq4QYpuFXfY0LSNIjyRmHhcbnT+PUOJgaI/HnpO8rAnhPRKeVeXrxD9rR5vaO9JGIC4VYsFHQ6slWFIvByCgr+9G1eE0TpFLMzo7pYlpwfRZjapDn8djQ0bxu4JjHd0dpwZ1R7GNSI7+C4mowLbMLUWKvjRM/Tr8WhmMVKC3kiJCDQlr8dZcSNLHuYewyoHAUiTMYBxq/Ng4mwfvPTf5NJp2mTbO1Z4Ane0K07Ud30C+Pq/L59mzmH3JNAZVE/8zN/6EyZnW2lelpPAqrqoHbr/x/UYxUvRNEH7M+DwVHlfLyVKQq112AQ02rwNhjnuQrv8sFb6O3DYtEBy4y5HCSX5qbDV/OTQv6wGIsghfGWmVH58FFQTieNSprgRPlZpIXpHtSExOYNaIhSq1cflpxhSQ/QMu1fqMVWc5N27RA9NwjmtDgvoSpPU7g1WK3fuh/uQKKAhpzup751ivYfGfiMxRi/bONCHFd1alKSxhWhwVJRHfA== X-Forefront-Antispam-Report: CIP:195.60.68.100;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.axis.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(376002)(39860400002)(346002)(136003)(230922051799003)(64100799003)(1800799009)(82310400011)(451199024)(186009)(5400799018)(46966006)(36840700001)(40470700004)(33656002)(40460700003)(2906002)(426003)(336012)(26005)(6266002)(1076003)(4326008)(8676002)(47076005)(36860700001)(478600001)(8936002)(34020700004)(40480700001)(41300700001)(66899024)(316002)(82740400003)(356005)(5660300002)(81166007)(6916009)(70586007)(42186006)(70206006)(36900700001)(12100799048);DIR:OUT;SFP:1501; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 04:02:34.5197 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9788d6c-8d08-42fa-fdc8-08dbcba13b24 X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af;Ip=[195.60.68.100];Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001B6.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR02MB9687 X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > Date: Fri, 29 Sep 2023 16:37:21 -0600 > From: Jeff Law > So this ends up looking a lot like the bits that I had to revert several > weeks ago :-) > > The core issue we have is given an INSN the generic code will cost the > SET_SRC and SET_DEST and sum them. But that's far from ideal on a RISC > target. > > For a register destination, the cost can be determined be looking at > just the SET_SRC. Which is precisely what this patch does. When the > outer code is an INSN and we're presented with a SET we take one of two > paths. > > If the destination is a register, then we recurse just on the SET_SRC > and we're done. Otherwise we fall back to the existing code which sums > the cost of the SET_SRC and SET_DEST. Ackchyually... that "otherwise" happens for calls to set_rtx_cost (et al), but not calls to insn_cost. IOW, with that patch, it seems you're mimicking insn_cost behavior also for set_rtx_cost (et al). You're likely aware of this, but when seeing these target cost functions tweaked for reasons that appear somewhat empirical, I felt compelled to point out the related rabbit-hole. While I'm ranting, these slightly different cost api:s, somewhat arbitrarily, (or empirically) picked by callers, is a problem by itself. Not to mention that the default use of set_rtx_cost means you get hit by another problem; the default cost of 0 for registers is also a magic number to pattern_cost to set the cost to INSN_COSTS (1). The default insn_cost implementation, which RISC-V uses as opposed to implementing the TARGET_INSN_COST hook, only looks at the SET_SRC for calls to insn_cost for single-sets. See pattern_cost. I believe that's a bug. Fixing that was attempted in 2016 (by Bernd S.), a patch which was later reverted: cf. commits r7-4866-g334442f282a9d6 and r7-4930-g03612f25277590. Hence rabbit-hole. (And no, implementing TARGET_INSN_COST doesn't automatically fix things. Too much of the gcc middle-end appears tuned to the default behavior.) Sorry for the rant; have a nice day and a better week-end. > That fallback path isn't great > and probably could be further improved (just costing SET_DEST in that > case is probably quite reasonable). > > The difference between this version and the bits that slipped through by > accident several weeks ago is that old version mis-used the API due to a > thinko on my part. > > This tightens up various zicond tests to avoid undesirable matching. > > This has been tested on rv64gc -- the only difference it makes on the > testsuite is the new tests (included in this patch) flip from failing to > passing. > > Pushed to the trunk. > > Jeff brgds, H-P