From patchwork Fri Feb 10 16:47:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 1740571 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=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=J5OdSraf; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PD05h5vcDz23fc for ; Sat, 11 Feb 2023 03:47:35 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AA74E385B501 for ; Fri, 10 Feb 2023 16:47:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA74E385B501 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676047652; bh=EFKLwnickqF61qW+3e10qkqaJH9SM8DkSfYoFrzIpOM=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=J5OdSraf1SEnyhdBz61fOm8Bg2+A7C8BF38HTO03NYmPOSf0mdq9IQF4Qkf58kh4y w54LZGv8U2nL0CQRNJ2XJ4QAXdRfrEpOMxGdOitRUgmql1v4OHYWHGulYNS2t0020Q ahtfQcO0sFDboOVSJpvthasXan5xEZWI+q+5GW3w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7F322385840D for ; Fri, 10 Feb 2023 16:47:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F322385840D Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-664-1KPywA6mO1CvniAvqKt8wA-1; Fri, 10 Feb 2023 11:47:11 -0500 X-MC-Unique: 1KPywA6mO1CvniAvqKt8wA-1 Received: by mail-il1-f199.google.com with SMTP id g1-20020a92cda1000000b0030c45d93884so4451018ild.16 for ; Fri, 10 Feb 2023 08:47:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:from:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uFnEhHS/1fbEI+5LoGYfcidnD25fk/tup1b0fBfy6Fs=; b=o426RCv72BVcdym4CmUIzFb+U1XKnAzywjfRV1oo2KjrNxVc82gZvyD7nmzFjg1kHV dHjvTwPZrWO8ws1/HJCnjN1/EZ2+cgYJOz03jAbqo28vM5LhdBQu4C6A4QMnV/50+BRO jO2g0pF3MOqe7Q8LaEeeOKd6ZG7vvd7NDC539H8K7Tx8KSuiQ2uFQOfpympitRASwP+6 5mi45uMVEVHwy54SYNHC/GHb0+Nd86d0w8W4PUEzGtXqntOROYalgFZVat/B7y4Q26jK +v3po/xThObAOotg1JJ4DxRTXAi9A/V1W43CSlv5njkwskO3zXlaUdwf7DpBDdYvuPHs VzPA== X-Gm-Message-State: AO0yUKVLVdSYouEVk+fcE0f0XHDFrWehaieRMTM3q0h43q6/XMBm50vn ZySrv0X77m7O6v4Vbe4sA9RsT540De3DWEP0/iS6m+q9KH4oTS+Li1m+rfBmsH0ZJddYV16dTcy iWmkBQG5nA9sd+sg35TQLcERZQ0oeSOKfWwDu/RgmAPn0Fog9jhbMdERDt7PF6XZMSySCTt9yfc s= X-Received: by 2002:a05:6e02:1d88:b0:313:c491:52dd with SMTP id h8-20020a056e021d8800b00313c49152ddmr1945582ila.8.1676047630146; Fri, 10 Feb 2023 08:47:10 -0800 (PST) X-Google-Smtp-Source: AK7set9Nh+ACkeeFfqY8Zk46y0nuH8P0JcCwchY3ZHiE1MICQOHVKnb6zE8PMZH0WlWFHpu4lyWmfA== X-Received: by 2002:a05:6e02:1d88:b0:313:c491:52dd with SMTP id h8-20020a056e021d8800b00313c49152ddmr1945557ila.8.1676047629741; Fri, 10 Feb 2023 08:47:09 -0800 (PST) Received: from [192.168.1.104] (23-233-12-120.cpe.pppoe.ca. [23.233.12.120]) by smtp.gmail.com with ESMTPSA id u27-20020a02cbdb000000b003afe5e747d6sm1516221jaq.126.2023.02.10.08.47.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Feb 2023 08:47:08 -0800 (PST) Message-ID: <08b7c01c-00f1-8428-e8eb-61508843b714@redhat.com> Date: Fri, 10 Feb 2023 11:47:08 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: [pushed] [PR108500] RA: Use simple LRA for huge functions To: "gcc-patches@gcc.gnu.org" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: , X-Patchwork-Original-From: Vladimir Makarov via Gcc-patches From: Vladimir Makarov Reply-To: Vladimir Makarov Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The following patch is for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108500 The patch improves compilation speed.  Compilation time of the biggest test in the PR decreases from 1235s to 709s. The patch was successfully bootstrapped on x86-64. commit 02371cdd755d2b53fb580d3e8209c44e0c45c337 Author: Vladimir N. Makarov Date: Fri Feb 10 11:12:37 2023 -0500 RA: Use simple LRA for huge functions The PR108500 test contains a huge function and RA spends a lot of time to compile the test with -O0. The patch decreases compilation time considerably for huge functions. Compilation time for the PR test decreases from 1235s to 709s on Intel i7-13600K. PR tree-optimization/108500 gcc/ChangeLog: * params.opt (ira-simple-lra-insn-threshold): Add new param. * ira.cc (ira): Use the param to switch on simple LRA. diff --git a/gcc/ira.cc b/gcc/ira.cc index 6143db06c52..d0b6ea062e8 100644 --- a/gcc/ira.cc +++ b/gcc/ira.cc @@ -5624,12 +5624,16 @@ ira (FILE *f) if (DF_REG_DEF_COUNT (i) || DF_REG_USE_COUNT (i)) num_used_regs++; - /* If there are too many pseudos and/or basic blocks (e.g. 10K - pseudos and 10K blocks or 100K pseudos and 1K blocks), we will - use simplified and faster algorithms in LRA. */ + /* If there are too many pseudos and/or basic blocks (e.g. 10K pseudos and + 10K blocks or 100K pseudos and 1K blocks) or we have too many function + insns, we will use simplified and faster algorithms in LRA. */ lra_simple_p - = ira_use_lra_p - && num_used_regs >= (1U << 26) / last_basic_block_for_fn (cfun); + = (ira_use_lra_p + && (num_used_regs >= (1U << 26) / last_basic_block_for_fn (cfun) + /* max uid is a good evaluation of the number of insns as most + optimizations are done on tree-SSA level. */ + || ((uint64_t) get_max_uid () + > (uint64_t) param_ira_simple_lra_insn_threshold * 1000))); if (lra_simple_p) { diff --git a/gcc/params.opt b/gcc/params.opt index 8a128c321c9..c7913d9063a 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -302,6 +302,10 @@ The number of registers in each class kept unused by loop invariant motion. Common Joined UInteger Var(param_ira_max_conflict_table_size) Init(1000) Param Optimization Max size of conflict table in MB. +-param=ira-simple-lra-insn-threshold= +Common Joined UInteger Var(param_ira_simple_lra_insn_threshold) Init(1000) Param Optimization +Approximate function insn number in 1K units triggering simple local RA. + -param=ira-max-loops-num= Common Joined UInteger Var(param_ira_max_loops_num) Init(100) Param Optimization Max loops number for regional RA.