From patchwork Wed Jul 5 23:08:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1804102 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=) 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=qh+ROonv; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QxFkp4Kmpz20ZC for ; Thu, 6 Jul 2023 09:10:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9712E3853D03 for ; Wed, 5 Jul 2023 23:10:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9712E3853D03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688598640; bh=esF9O8z4LPAAWNT0rezDuNTdTHcpuX/V8Lott8uid4U=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=qh+ROonvTmPJecZqXKkDpP102Ix2lALiQhHIeB7c1qWuQwSRYtR3mpXHcOuNXbOzN 4F41Wpqyw+KC4Ls/9xZYc5muIDMVZC1+XNoe2zyiXiaPaIOLQK2BBvW4PmsJxgVSzb FvGwBxne1ytwQlVlW89Ofu/dUsmvZ2+a7zqEMbPg= 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 CE277385C8B1 for ; Wed, 5 Jul 2023 23:08:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE277385C8B1 Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-372OkTFIORKOOPHCkyHNyg-1; Wed, 05 Jul 2023 19:08:38 -0400 X-MC-Unique: 372OkTFIORKOOPHCkyHNyg-1 Received: by mail-oo1-f72.google.com with SMTP id 006d021491bc7-5662c368572so17057eaf.2 for ; Wed, 05 Jul 2023 16:08:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688598516; x=1691190516; 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=k4Jh7CStJJSSZqegirhVH0DugDEpzuXDYP8qZjP5t+0=; b=MJ1Jen+i+m/O5ZDbeHf13P0rNEj9KUlyRAGtPh9gkdxtkqWsmS7PnzySqduIB6k3Sk m6uDgSZLjoDQWhgB+H8mQ0CzjTuv15zVNAnmzFjt/vpNvh38Bx2i+2Ewev9oDkrIvezd x8sdVrlMYQ9AhavEKnFJuCNGA6mBAG0wlsCDeXem8Zvhxsy0dmNJUOEg9eac5LfNnxjM oe9IQxUeNH7BYoiL6uE7qZM+L7q9rba1b/RhVdr855i6mtOc8F3Me8L3VwzJNw0qcbJf 4QeN59RfQyUaOnGSmMQRh2j1jV4OdIbANDCHo7Sdqp/EvVSYCpWKGk7VQ2Fsucght/+Y G9Sw== X-Gm-Message-State: ABy/qLb8gxB6HHmMDG8KKfLwzyUY3FX0JmJ2aIuFBvYwrM1PSqWZhuGP PN9r2rVUmVBXH/xeTKxpbxGWtIZY0gd8sItHtrht0vfLW0rUk5ZJrefbLwccE24TCtQSBSenCWW zTkdlh9x4Ikky0GAr7tdGVGCsfWzeLnGaKuiC3a36pIjIGXtDR7jni4ZrPuTSldz4+ltATzZSfq sP4Q== X-Received: by 2002:a05:6808:1490:b0:39e:c651:b2f1 with SMTP id e16-20020a056808149000b0039ec651b2f1mr40558oiw.2.1688598516815; Wed, 05 Jul 2023 16:08:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlEWiZj//1kjHL+Nyy0W2qgG7rvfimIh5TfvS92pgjGlqk8Zrs+jLEoRmO24K8lNpaxbq7qIDQ== X-Received: by 2002:a05:6808:1490:b0:39e:c651:b2f1 with SMTP id e16-20020a056808149000b0039ec651b2f1mr40540oiw.2.1688598516534; Wed, 05 Jul 2023 16:08:36 -0700 (PDT) Received: from [192.168.0.174] ([104.219.122.97]) by smtp.gmail.com with ESMTPSA id s9-20020a0ca609000000b0062de1ed9d15sm45374qva.102.2023.07.05.16.08.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jul 2023 16:08:36 -0700 (PDT) Message-ID: Date: Wed, 5 Jul 2023 19:08:35 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 5/5] Make compute_operand_range a tail call. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This simply tweaks cmpute_operand_range a little so the recursion is a tail call. With this, the patchset produces a modest speedup of 0.2% in VRP and 0.4% in threading.  It will also have a much smaller stack profile. Bootstraps on  x86_64-pc-linux-gnu  with no regressions.  Pushed. Andrew From 51ed3a6ce432e7e6226bb62125ef8a09b2ebf60c Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 5 Jul 2023 14:26:00 -0400 Subject: [PATCH 5/6] Make compute_operand_range a tail call. Tweak the routine so it is making a tail call. * gimple-range-gori.cc (compute_operand_range): Convert to a tail call. --- gcc/gimple-range-gori.cc | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index b036ed56f02..6dc15a0ce3f 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -725,36 +725,34 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, op1_trange, op1_frange, op2_trange, op2_frange); if (idx) tracer.trailer (idx, "compute_operand", res, name, r); + return res; } // Follow the appropriate operands now. - else if (op1_in_chain && op2_in_chain) - res = compute_operand1_and_operand2_range (r, handler, lhs, name, src, - vrel_ptr); - else if (op1_in_chain) + if (op1_in_chain && op2_in_chain) + return compute_operand1_and_operand2_range (r, handler, lhs, name, src, + vrel_ptr); + Value_Range vr; + gimple *src_stmt; + if (op1_in_chain) { - Value_Range vr (TREE_TYPE (op1)); + vr.set_type (TREE_TYPE (op1)); if (!compute_operand1_range (vr, handler, lhs, src, vrel_ptr)) return false; - gimple *src_stmt = SSA_NAME_DEF_STMT (op1); - gcc_checking_assert (src_stmt); - // Then feed this range back as the LHS of the defining statement. - return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr); + src_stmt = SSA_NAME_DEF_STMT (op1); } - else if (op2_in_chain) + else { - Value_Range vr (TREE_TYPE (op2)); + gcc_checking_assert (op2_in_chain); + vr.set_type (TREE_TYPE (op2)); if (!compute_operand2_range (vr, handler, lhs, src, vrel_ptr)) return false; - gimple *src_stmt = SSA_NAME_DEF_STMT (op2); - gcc_checking_assert (src_stmt); - // Then feed this range back as the LHS of the defining statement. - return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr); + src_stmt = SSA_NAME_DEF_STMT (op2); } - else - gcc_unreachable (); + gcc_checking_assert (src_stmt); + // Then feed this range back as the LHS of the defining statement. + return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr); // If neither operand is derived, this statement tells us nothing. - return res; } -- 2.40.1