From patchwork Thu Jun 13 07:31:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1947273 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=ia7vdsV/; 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 4W0DdH3km7z1ydW for ; Thu, 13 Jun 2024 17:32:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00D963883008 for ; Thu, 13 Jun 2024 07:32:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id C831D3882064 for ; Thu, 13 Jun 2024 07:31:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C831D3882064 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C831D3882064 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718263912; cv=none; b=Li2ndrCGrjScx10lTNNCAOhTocNg50MzSn9TSfvwEoz+nUElMVZlDeVdVB6Co9v6xHQV7O+Cn0yIILy+/qRZbF2EZbePwopojP0mVCsgnqN7lAsfyHdAED/yn17Nkv8QX0/te6ATRK46evDQOlAxaqsKOuOFdERhh74yfGREuA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718263912; c=relaxed/simple; bh=/dhL+rCbnGMO9RxIYwMBZ5gUd4KYP8UFL3lmileqKmE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=yCmEysOrsk4TtC0CVNl9bonf4oDN0xBM3Xf78wlUxW3hYYcAq+QihdIKJiSokmdRiBQTDD7bwlFpNU/+YO7wekm1uS5ykEntMINANn3aWKl3G5w/xx15OJzRuebRzEULOONRh+djsiisNdhUM+n6uSOhlVf+0mkhOqUHaUo6mL4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-705c1220a52so694441b3a.1 for ; Thu, 13 Jun 2024 00:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718263910; x=1718868710; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=1cd3C7SD5ZMQvYOtDWuRf308rvIwDfoV2Cu+3lIzaVA=; b=ia7vdsV/jWDda1Cw2XFghkoBrrzy5DJtCBiyJU5ZusktE+Yz04sRNk9fStcSburcvv iM+/6Mu4r1GxMtaUwx6s/cw7seS8E21S/lwSPnzZl0/qKq61aG5PzxBEecF2Vr5XpBZX +Q3dToAKqpjV/J/uBBY0k1MxkBODNWwxJs/8+Tg9SMWqclvyWCZPK75ax5QJaOuEXOuT YmNW9WuJc347HYxVM5rX1IKIcYVzy2hdr+ifXNAPCcn6Ym1kH6YxstmfeSx5OGPBaGTW GItnlXQVt4vQ4gqb5lJ0gKBT4Is8w/hYAqQK/FjYi+AqHo1XNAtVdMasMdD/pUmXJvbd Y4Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718263910; x=1718868710; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1cd3C7SD5ZMQvYOtDWuRf308rvIwDfoV2Cu+3lIzaVA=; b=GmzQrKGBUHVsX2so1j/6444rnaXwPdmm0/y5R1Z1bl0DAXnFNsEr3YwuG62u2mqwRZ uUSnj9HLwrZeyp3uT5GHZEizRclbSO4DMjWZ9UGnyJugWZCXH0e7KXm/zGpSNH1DDsIJ DzOkDKir5rwEBZf7rZ0ReiGfDvuZgMmuZUN6aKs//QVa+qHBc46ynZXJOp/hwZR28lpW VUijADRpGU4fJzBqjPv7i+mChMoDlJPQh5WgqwRdFKZ9VQ1eBAobsj0CF46qC3yji81X CK0Ly14jgi9VTKMqpSIu3Emo1jj9Wi6mQegnGF/OCnlLMAFo5duwkFAjEgDpX65y1XMd KIKA== X-Gm-Message-State: AOJu0Yw7hdOTWYXgamfe4UIiTryI7vKQREteFrvSOfzy0xV7+SFRRFxX HbWbEXkALkJQywQp7+z9dtT2pfcqC9k9EDefYuNh+2ctane2XShFCK9mB0+twWOdu+eRE0ylnCk MLg== X-Google-Smtp-Source: AGHT+IFrmhrIHCsnMGBd3Ko6TONlndw2SLjf4oKiJz/0Qb2aDPmlJ1f32AuCDe4x6OiZYT4EIz1DOA== X-Received: by 2002:a05:6a20:3d88:b0:1b2:a889:f7da with SMTP id adf61e73a8af0-1b8a9c887fdmr4699630637.55.1718263909504; Thu, 13 Jun 2024 00:31:49 -0700 (PDT) Received: from free.home ([2804:7f1:218b:1961:ef8:d680:5399:8b1a]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccb3d1ccsm710519b3a.125.2024.06.13.00.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 00:31:49 -0700 (PDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 45D7VZ3Q1173589 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 13 Jun 2024 04:31:35 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org, Hongyu Wang Cc: Jan Hubicka , Uros Bizjak Subject: [PATCH] [i386] restore recompute to override opts after change [PR113719] Organization: Free thinker, does not speak for AdaCore Date: Thu, 13 Jun 2024 04:31:35 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_QUOTING 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 The first patch for PR113719 regressed gcc.dg/ipa/iinline-attr.c on toolchains configured to --enable-frame-pointer, because the optimization node created within handle_optimize_attribute had flag_omit_frame_pointer incorrectly set, whereas default_optimization_node didn't. With this difference, can_inline_edge_by_limits_p flagged an optimization mismatch and we refused to inline the function that had a redundant optimization flag into one that didn't, which is exactly what is tested for there. This patch restores the calls to ix86_default_align and ix86_recompute_optlev_based_flags that used to be, and ought to be, issued during TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE, but preserves the intent of the original change, of having those functions called at different spots within ix86_option_override_internal. To that end, the remaining bits were refactored into a separate function, that was in turn adjusted to operate on explicitly-passed opts and opts_set, rather than going for their global counterparts. Regstrapped on x86_64-linux-gnu. Also tested with --enable-frame-pointer, and with gcc-13 x-x86-vx7r2, where the problem was detected. Ok to install? for gcc/ChangeLog PR target/113719 * config/i386/i386-options.cc (ix86_override_options_after_change_1): Add opts and opts_set parms, operate on them, after factoring out of... (ix86_override_options_after_change): ... this. Restore calls of ix86_default_align and ix86_recompute_optlev_based_flags. (ix86_option_override_internal): Call the factored-out bits. --- gcc/config/i386/i386-options.cc | 59 ++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc index f2cecc0e2545b..7fa7f6774e9cf 100644 --- a/gcc/config/i386/i386-options.cc +++ b/gcc/config/i386/i386-options.cc @@ -1911,37 +1911,58 @@ ix86_recompute_optlev_based_flags (struct gcc_options *opts, } } -/* Implement TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook. */ +/* Implement part of TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook. */ -void -ix86_override_options_after_change (void) +static void +ix86_override_options_after_change_1 (struct gcc_options *opts, + struct gcc_options *opts_set) { +#define OPTS_SET_P(OPTION) opts_set->x_ ## OPTION +#define OPTS(OPTION) opts->x_ ## OPTION + /* Disable unrolling small loops when there's explicit -f{,no}unroll-loop. */ - if ((OPTION_SET_P (flag_unroll_loops)) - || (OPTION_SET_P (flag_unroll_all_loops) - && flag_unroll_all_loops)) + if ((OPTS_SET_P (flag_unroll_loops)) + || (OPTS_SET_P (flag_unroll_all_loops) + && OPTS (flag_unroll_all_loops))) { - if (!OPTION_SET_P (ix86_unroll_only_small_loops)) - ix86_unroll_only_small_loops = 0; + if (!OPTS_SET_P (ix86_unroll_only_small_loops)) + OPTS (ix86_unroll_only_small_loops) = 0; /* Re-enable -frename-registers and -fweb if funroll-loops enabled. */ - if (!OPTION_SET_P (flag_web)) - flag_web = flag_unroll_loops; - if (!OPTION_SET_P (flag_rename_registers)) - flag_rename_registers = flag_unroll_loops; + if (!OPTS_SET_P (flag_web)) + OPTS (flag_web) = OPTS (flag_unroll_loops); + if (!OPTS_SET_P (flag_rename_registers)) + OPTS (flag_rename_registers) = OPTS (flag_unroll_loops); /* -fcunroll-grow-size default follws -f[no]-unroll-loops. */ - if (!OPTION_SET_P (flag_cunroll_grow_size)) - flag_cunroll_grow_size = flag_unroll_loops - || flag_peel_loops - || optimize >= 3; + if (!OPTS_SET_P (flag_cunroll_grow_size)) + OPTS (flag_cunroll_grow_size) + = (OPTS (flag_unroll_loops) + || OPTS (flag_peel_loops) + || OPTS (optimize) >= 3); } else { - if (!OPTION_SET_P (flag_cunroll_grow_size)) - flag_cunroll_grow_size = flag_peel_loops || optimize >= 3; + if (!OPTS_SET_P (flag_cunroll_grow_size)) + OPTS (flag_cunroll_grow_size) + = (OPTS (flag_peel_loops) + || OPTS (optimize) >= 3); } +#undef OPTS +#undef OPTS_SET_P +} + +/* Implement TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook. */ + +void +ix86_override_options_after_change (void) +{ + ix86_default_align (&global_options); + + ix86_recompute_optlev_based_flags (&global_options, &global_options_set); + + ix86_override_options_after_change_1 (&global_options, &global_options_set); } /* Clear stack slot assignments remembered from previous functions. @@ -2488,7 +2509,7 @@ ix86_option_override_internal (bool main_args_p, ix86_recompute_optlev_based_flags (opts, opts_set); - ix86_override_options_after_change (); + ix86_override_options_after_change_1 (opts, opts_set); ix86_tune_cost = processor_cost_table[ix86_tune]; /* TODO: ix86_cost should be chosen at instruction or function granuality