From patchwork Wed Oct 5 03:54:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 1710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp423532wrs; Tue, 4 Oct 2022 20:55:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7pM/Tw2FKRHrh0Zd+ujuzhXs3n1RoY/NbOA8geZBH3dEX+8UaNBQXdsj+B7Ig6dCinljtg X-Received: by 2002:a50:ff09:0:b0:456:fd61:83b3 with SMTP id a9-20020a50ff09000000b00456fd6183b3mr26163506edu.166.1664942152992; Tue, 04 Oct 2022 20:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664942152; cv=none; d=google.com; s=arc-20160816; b=PjXEl8oG6nYLxHctUPrmvczllhQnOBhZrqW0ZYn7BvG/XC1eUZQwzME9mg6BIWVOVU Gqu/WcDEwGp1g7lGhO8V/McvBHc5vhEu0sI77ZO/2PoIoAj6vV8aoKNv7vUOA2cuUsOH tHRn+9eJaPbH1QbLeLzXK88UnD9Ojkh9aECaEFxpTy3JE9HsWHf0j50/WDsQwdXj45AI Zek3Yhd6ZWqCflPURMcS8rQwheRqYfurac0las55gPV6eYqWla7td9QVWhSGGnRCqqbQ G6+b3xsXy7Z1Gec9tG+IxSAmgzPDlxr+V4FnJK/gBA4nsA6A62oW3GpWbnMpmUAvOhDs mbeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:to:from :content-transfer-encoding:mime-version:message-id:date:subject :dkim-signature:dmarc-filter:delivered-to; bh=Trtr/8zqBAlzD7Cb0UAAM2itUWyLZCWynsl4kc0ZCSY=; b=xZrmnn9uLjNJXtqX55sll6LyKEHUAAw25GxBGH+/RHuFvjR3Lq4my2pEqj6OoUb8yI vjzboDGwgxrhaOEm7P813/V2geppw5tPeW4i7pflDkJ15b7MpXzAcdLWoshucKOKttdv aejbYjkj7HUciMzEHHXQT5P3kF+iIBeX44lZ0NN+h9bQUZ0CFcjE4O2AtBd3IInNPn2c 1UOqJaTg2borpNaGHyA1lWG4Uz7wKO3S7kpJokBwQBVe67uiDYlSq3Z3/2g+GMSUj5Hb s8ffjHVjZ4dx8w96CAV8t50Vb8Q5TkXkcFX/eo7RXAIZO3rTLzm0/ODpdECOzJQCJvpj RwmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=6JrGItoM; 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" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id nc12-20020a1709071c0c00b00782c1d273cbsi12041181ejc.392.2022.10.04.20.55.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 20:55:52 -0700 (PDT) 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=fail header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=6JrGItoM; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E7CE7385800F for ; Wed, 5 Oct 2022 03:55:47 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id DAC733858D32 for ; Wed, 5 Oct 2022 03:55:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DAC733858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pg1-x529.google.com with SMTP id e129so14308882pgc.9 for ; Tue, 04 Oct 2022 20:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=to:from:cc:content-transfer-encoding:mime-version:message-id:date :subject:from:to:cc:subject:date:message-id:reply-to; bh=Trtr/8zqBAlzD7Cb0UAAM2itUWyLZCWynsl4kc0ZCSY=; b=6JrGItoMJHzV8qTlIghlL3bCuO8k9ws7C7nLTv+OaN7yuW9/rpKja75d6T5mU1zvP/ QrtVehAOw/HFIuQrjQ6yn6d5EoO+02vdb4jTuDIi2hr9+Z5jp28PMOfCcn3YJHrkSqSC Q9r9WiYfnFzX19tt6d6Qk98XtPZK8v88WqiUfxtSeF/CPSkRJMLMiEXlZuskzUJtpucy 28/KIaHdbynSMukNu4vdpBCxVvbmm9LpucWPV48MlvWKMGQ+qmgXrgeezco/1Tu64IXi o4zVNWY5NcPYHhB7SiRjZScs1V1sBBR7Lm5jTTz106srE8vb38xUOe95ktlaJzPEfVq9 lWwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:from:cc:content-transfer-encoding:mime-version:message-id:date :subject:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Trtr/8zqBAlzD7Cb0UAAM2itUWyLZCWynsl4kc0ZCSY=; b=fhendEi6WleexLlg7ZMd8hTSJefKApciBWuhiaikxw5NgcpthcaoT9SZI7rXQnQ6Ui 7s4G4jf5/SDegxT+CYIpn6H/vBnJpbk69YADK8tzdU07HiGrSE7Y/tggPE7axPYphUQv wiMd8Wv6EIpVdtWWscaPlr6W+/ZeIAEvFD4XYMI8JZ9UX7ZJYeJIGf/sY08aMen8Tcb+ Zz2Qh2oecZ7FkAguvLAB1/NL+xyr+rMTaimez7ckrO8QlBiTd++BXB93cDmJ4xQntq+2 s77r2/lYHraW/SIOAOwVsE6EX6bpu3VT+/JsM7/fSOdkYnEvyvD+gZ9WlugXAR5JpLxl oKng== X-Gm-Message-State: ACrzQf3mXqxMXakqX9nt9SSgBlZmwVmyprWiqONUxHnLnU8ex+Fq7cs2 DLgz8Fe4KyzDQWftDK8E3cJbVA== X-Received: by 2002:a63:5a41:0:b0:430:673e:1e13 with SMTP id k1-20020a635a41000000b00430673e1e13mr26792764pgm.435.1664942120632; Tue, 04 Oct 2022 20:55:20 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id t16-20020a17090a1c9000b0020abcecbf86sm329594pjt.17.2022.10.04.20.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 20:55:20 -0700 (PDT) Subject: [PATCH] RISC-V: Default to tuning for the thead-c906 Date: Tue, 4 Oct 2022 20:54:46 -0700 Message-Id: <20221005035446.30054-1-palmer@rivosinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 From: Palmer Dabbelt To: gcc-patches@gcc.gnu.org X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745818383220263279?= X-GMAIL-MSGID: =?utf-8?q?1745818383220263279?= The C906 is by far the most widely available RISC-V processor, so let's default to tuning for it. gcc/ChangeLog * config/riscv/riscv.h (RISCV_TUNE_STRING_DEFAULT): Change to thead-c906. * doc/invoke.texi (RISC-V -mtune): Change the default to thead-c906. --- This has come up a handful of times, most recently during the Cauldron. It seems like a grey area to me: we're changing the behavior of some command-line arguments (ie, everything that doesn't specify -mtune), but we sort of change that anyway as the tuning parameters change between releases. I'm not really seeing much of a precedent from the other ports. It looks like aarch64 sort of changed the default in 02fdbd5beb0 ("[AArch64] [-mtune cleanup 2/5] Tune for Cortex-A53 by default.") but I think at that point -mtune=generic and -mtune=cortex-a53 were equivalent so I'm not sure that counts. I can't quite sort out if the default x86 tuning has ever changed, but the tuning parameters have changed. I don't see any way around having the tuning parameters change as they're pretty tightly coupled to the GCC internals, but changing to a different tuning target is a bit bigger of a change. We also have a bit of a special case here: -mtune is in theory only a performance issue, but this change will emit a lot more misaligned accesses and we've seen those trigger bugs in the trap handlers before. Those bugs are elsewhere so it's sort of not a GCC problem, but I'm sure there's still users out there with broken firmware and this may cause visible fallout. We can just tell those users their systems were always broken, but that's never a fun way to do things. I figured the easiest way to talk about this would be to just send the patch, but I definitely don't plan on committing it without some discussion. --- gcc/config/riscv/riscv.h | 2 +- gcc/doc/invoke.texi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 363113c6511..1d9379fa5ee 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -40,7 +40,7 @@ along with GCC; see the file COPYING3. If not see #endif #ifndef RISCV_TUNE_STRING_DEFAULT -#define RISCV_TUNE_STRING_DEFAULT "rocket" +#define RISCV_TUNE_STRING_DEFAULT "thead-c906" #endif extern const char *riscv_expand_arch (int argc, const char **argv); diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e0c2c57c9b2..2a9ea3455f6 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -28529,7 +28529,7 @@ particular CPU name. Permissible values for this option are: @samp{rocket}, @samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}. When @option{-mtune=} is not specified, use the setting from @option{-mcpu}, -the default is @samp{rocket} if both are not specified. +the default is @samp{thead-c906} if both are not specified. The @samp{size} choice is not intended for use by end-users. This is used when @option{-Os} is specified. It overrides the instruction cost info