From patchwork Tue Jul 23 14:06:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam James X-Patchwork-Id: 1963918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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 4WSzVx0j3Rz1ybY for ; Wed, 24 Jul 2024 00:07:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 43AFF386180E for ; Tue, 23 Jul 2024 14:07:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id DD2273858414 for ; Tue, 23 Jul 2024 14:07:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DD2273858414 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DD2273858414 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:ea4a:1:5054:ff:fec7:86e4 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721743632; cv=none; b=YHpGFvlYJt1jlQfdtafUMh/PsVOAo33zAqTscZr2CabNDfLRWIcq5h0ISwiIDPty6z5e6T2x4GAkAMynVFlurgG1bDG+RV6ESmhtECX69yhsgbd7yqpJWAWojMSmOEMa9b+yXFCMw1wumJDjJeLVjFaxY6enVOyOw4aezQqiZXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721743632; c=relaxed/simple; bh=QcE0bK63XcsN9fFljSIrUORmDycBrVLn6OwGysxbqSk=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=ciwxjxDghBuJ423e1D8cVjjug+nGjLDAwK2U8JOv8/blrVaIy3QqTG84tU97NloWr+YkPkuvpZKrzBacm+9XGRfNUsStXPlLmZyYDuwyoDSyW8JIAx5brH5EWSSEGv+mhdUo4Bhh0Jzft4GQfBb0Lqz5cuewa4I6SQeIRtoTEsM= ARC-Authentication-Results: i=1; server2.sourceware.org From: Sam James To: gcc-patches@gcc.gnu.org Cc: Richard Biener , Sam James Subject: [PATCH] doc: Document -O1 as the preferred level for large machine-generated code Date: Tue, 23 Jul 2024 15:06:10 +0100 Message-ID: <5eef1b19afac0f6608f5a44e9560ca703752d689.1721743570.git.sam@gentoo.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, 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 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 At -O1, the intention is that we compile things in a "reasonable" amount of time (ditto memory use). In particular, we try to especially avoid optimizations which scale poorly on pathological cases, as is the case for large machine-generated code. Recommend -O1 for large machine-generated code, as has been informally done on bugs for a while now. This applies (broadly speaking) for both large machine-generated functions but also to a lesser extent repetitive small-but-still-not-tiny functions from a generator program. gcc/ChangeLog: PR middle-end/114855 * doc/invoke.texi (Optimize options): Mention machine-generated code for -O1. --- richi, does this accurately reflect the discussion we had on IRC a little while ago? Please push if OK, thanks. gcc/doc/invoke.texi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e0a641213ae4..9fb0925ed292 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -12560,6 +12560,11 @@ With @option{-O}, the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compilation time. +@option{-O} is the recommended optimization level for large machine-generated +code as a sensible balance between time taken to compile and memory use: +higher optimization levels perform optimizations with greater algorithmic +complexity than at @option{-O}. + @c Note that in addition to the default_options_table list in opts.cc, @c several optimization flags default to true but control optimization @c passes that are explicitly disabled at -O0.