From patchwork Fri Jun 21 13:02:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1950789 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TaQHyW0U; 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 4W5HcP1Pg9z20X4 for ; Fri, 21 Jun 2024 23:04:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F8503898C43 for ; Fri, 21 Jun 2024 13:04:03 +0000 (GMT) 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 5F8EA3898510 for ; Fri, 21 Jun 2024 13:02:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F8EA3898510 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5F8EA3898510 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718974958; cv=none; b=BcklkAKJm2U0M1bk6k+eB6edB9i//JPFz847ICNy47gD3ZMMaZQRRKJ/VnsCis2pvXwveQhdwoYkpYw5HmkJF6DAItpuTONy7TKWcUes8o0PkMw491GiPPGqbZsgiJF4JVyh1HjzeTA0zRFano09tl4f12yOl9bRdkJ9caDavyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718974958; c=relaxed/simple; bh=9t2JyRKb0hb6zUEB/Viu/7BL7NQNTJlQzTR9i/+aSnk=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=L9EY5BDAz4m0j1L0AFtI2GoB1eV5NyWaSvPWiYDYnYXVHCnfC3/l0aUTuhFvY/H9A7sKdiUublQe61qPkUKCJ3tFWcBNSgde/4VlYxPt10O8A3a5Vy5EAngGKEW1gWRn6KdNh4s8fAcjnPLecTJw+geW/S5sPoADTfl+LnG7YyE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718974956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=APsHHQnNp/2OAfUsGjhuPe7Bey87yUljGVjF9gZRQMU=; b=TaQHyW0U1b26g9zEYWScDcCZqgmJNStnoOzS0dwx/VQAs/tQzPBzJieFuAnnrVeL2sZZ6G Elrx2JmmXDNBKJLHz/CL7Bin95+wTm1AJMY0uAOE7GbFKCG+RBM+vYP+qU7J6pdHcF9OGa Wwz8rzDoMfQsA/+3MnrlL3gI8X3C/7o= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-385-dUqQYJa8MGWet9O6ascZ6g-1; Fri, 21 Jun 2024 09:02:32 -0400 X-MC-Unique: dUqQYJa8MGWet9O6ascZ6g-1 Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-5ba6394f7c6so2196179eaf.0 for ; Fri, 21 Jun 2024 06:02:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718974951; x=1719579751; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yd6N3R2Y9USc2cs4gFvauVJTmOjxW9x5nPYBKnRF0EQ=; b=mlHJV9699EcAadjXXl9mBkA8FFqoMAN0FWsYqBLL8o+uPRwUG/CFcqHIZU6ZI5Pu+U kDbzR3ULn6P6sjd1UHon/f0KI1HVyuy+Jb43v9Zy2kyFSTc59bAArca9n/LeUl7YZoC4 QqIyvzC4/j4RN3jJaFr2KB2vdbX4/7e/MZDZWQH3b39ovVvSyXHgJiDYaYQ5QkurwzKt a1ZrjUOMElbY6UW02+0K028oXVLv25eeOB56HmsPTowZEkSrleNxxxtRtbvRMcRMP5N4 rG5WICXk+VFIkMw5Nk+JiRhSkfJ11HXQYi24XY/dpNAPmAX0UWGAJn1Osf31ftq+plkJ o7/Q== X-Gm-Message-State: AOJu0Yy9QDZTnwe0GLO9lBP4i/XX1+ICGYOT7JIK0/89NCUv1loOfoN+ 1MNUV1NQvvHDJPEuOcSXnRHoOkH7O2Gi59ClG+amFL6Lib6pfejxiV+aIYsWx452uVdfW480++w M7nClvZ0G14t79pt4R9cWA6VYflX4A6IbKnjf5mAfVvHWNufP04ux1HZ5Bnhfh4lNeQZGpLtYJQ CGD2YM2ucBkR/YkzsH/QauFcJzSfAaHKcaQ3UUYVI= X-Received: by 2002:a05:6358:78a:b0:199:28ad:1447 with SMTP id e5c5f4694b2df-1a1fd3c7b16mr1032031955d.10.1718974951031; Fri, 21 Jun 2024 06:02:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBdzyYwl03wzdmFV35jio7hLQ1xsRBXIqVUfDxaiQ7TEyu61THEUwLvA5r0cX5blYHUHCKdQ== X-Received: by 2002:a05:6358:78a:b0:199:28ad:1447 with SMTP id e5c5f4694b2df-1a1fd3c7b16mr1032026955d.10.1718974950447; Fri, 21 Jun 2024 06:02:30 -0700 (PDT) Received: from ?IPV6:2607:fea8:51de:a700::7158? ([2607:fea8:51de:a700::7158]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b51ef30bf2sm8411246d6.101.2024.06.21.06.02.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Jun 2024 06:02:29 -0700 (PDT) Message-ID: <1bb04945-d13b-4805-b9ed-0be4a5c773fc@redhat.com> Date: Fri, 21 Jun 2024 09:02:27 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: gcc-patches Cc: "hernandez, aldy" , Richard Biener From: Andrew MacLeod Subject: [PATCH] Add param for bb limit to invoke fast_vrp. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, BODY_8BITS, 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_H4, RCVD_IN_MSPIKE_WL, 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.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 This patch adds     --param=vrp-block-limit=N When the basic block counter for a function exceeded 'N' , VRP is invoked with the new fast_vrp algorithm instead.   This algorithm uses a lot less memory and processing power, although it does get a few less things. Primary motivation is cases like https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114855 in which the 3  VRP passes consume about 600 seconds of the compile time, and a lot of memory.      With fast_vrp, it spends less than 10 seconds total in the 3 passes of VRP.     This test case has about 400,000 basic blocks. The default for N in this patch is 150,000,  arbitrarily chosen. This bootstraps, (and I bootstrapped it with --param=vrp-block-limit=0 as well) on x86_64-pc-linux-gnu, with no regressions. What do you think, OK for trunk? Andrew PS sorry,. it doesn't help the threader in that PR :-( From 3bb9bd3ca8038676e45b0bddcda91cbed7e51662 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Mon, 17 Jun 2024 11:38:46 -0400 Subject: [PATCH 4/5] Add param for bb limit to invoke fast_vrp. If the basic block count is too high, simply use fast_vrp for all VRP passes. gcc/doc/ * invoke.texi (vrp-block-limit): Document. gcc/ * params.opt (-param=vrp-block-limit): New. * tree-vrp.cc (fvrp_folder::execute): Invoke fast_vrp if block count exceeds limit. --- gcc/doc/invoke.texi | 3 +++ gcc/params.opt | 4 ++++ gcc/tree-vrp.cc | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 5d7a87fde86..f2f8f6334dc 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -16840,6 +16840,9 @@ this parameter. The default value of this parameter is 50. @item vect-induction-float Enable loop vectorization of floating point inductions. +@item vrp-block-limit +Maximum number of basic blocks before VRP switches to a lower memory algorithm. + @item vrp-sparse-threshold Maximum number of basic blocks before VRP uses a sparse bitmap cache. diff --git a/gcc/params.opt b/gcc/params.opt index d34ef545bf0..c17ba17b91b 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -1198,6 +1198,10 @@ The maximum factor which the loop vectorizer applies to the cost of statements i Common Joined UInteger Var(param_vect_induction_float) Init(1) IntegerRange(0, 1) Param Optimization Enable loop vectorization of floating point inductions. +-param=vrp-block-limit= +Common Joined UInteger Var(param_vrp_block_limit) Init(150000) Optimization Param +Maximum number of basic blocks before VRP switches to a fast model with less memory requirements. + -param=vrp-sparse-threshold= Common Joined UInteger Var(param_vrp_sparse_threshold) Init(3000) Optimization Param Maximum number of basic blocks before VRP uses a sparse bitmap cache. diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc index 4fc33e63e7d..eef02146ec6 100644 --- a/gcc/tree-vrp.cc +++ b/gcc/tree-vrp.cc @@ -1330,9 +1330,9 @@ public: unsigned int execute (function *fun) final override { // Check for fast vrp. - if (&data == &pass_data_fast_vrp) + if (last_basic_block_for_fn (fun) > param_vrp_block_limit || + &data == &pass_data_fast_vrp) return execute_fast_vrp (fun, final_p); - return execute_ranger_vrp (fun, final_p); } -- 2.45.0