From patchwork Wed Apr 26 08:33:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1773936 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=8.43.85.97; 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=N/nFOfrL; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 4Q5sc06sm1z23vH for ; Wed, 26 Apr 2023 18:34:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 120023858428 for ; Wed, 26 Apr 2023 08:34:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 120023858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682498059; bh=357RXq3o07eH0KOIOBvCIrNiVM0hHhlEH4MnpLiNbKg=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=N/nFOfrLfh+1iiwO5y7e2wc05IiVn961WZF6o+75NDkSu5EOd3xSCDpxw4l/1tJlu dlZPgmqgNLSjZJqhl5+W+7LfjkAxEnMBWzwLYk/dQQexXV99SmegV7hFGO/4E+S+YL vGoGMAx48FOsF253BnDKgLqr6ljNjMWQ/my/7C00= 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 E94D33858CDA for ; Wed, 26 Apr 2023 08:33:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E94D33858CDA Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-413-9k-qnQbmOuuitXN4CnesGA-1; Wed, 26 Apr 2023 04:33:42 -0400 X-MC-Unique: 9k-qnQbmOuuitXN4CnesGA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F03E1884346 for ; Wed, 26 Apr 2023 08:33:41 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.195.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C75A2027043; Wed, 26 Apr 2023 08:33:41 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 33Q8XdS7313597 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 26 Apr 2023 10:33:39 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 33Q8Xdod313596; Wed, 26 Apr 2023 10:33:39 +0200 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Remove compare_names* from legacy cond folding. Date: Wed, 26 Apr 2023 10:33:20 +0200 Message-Id: <20230426083328.313566-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.4 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_H2, 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: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" In a test run I have asserted that the legacy conditional folding only gets overflows, so this removal is safe. gcc/ChangeLog: * vr-values.cc (get_vr_for_comparison): Remove. (compare_name_with_value): Same. (vrp_evaluate_conditional_warnv_with_ops): Remove calls to compare_name_with_value. * vr-values.h: Remove compare_name_with_value. Remove get_vr_for_comparison. --- gcc/vr-values.cc | 57 ------------------------------------------------ gcc/vr-values.h | 2 -- 2 files changed, 59 deletions(-) diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index 365f4976a39..1d757eeffc3 100644 --- a/gcc/vr-values.cc +++ b/gcc/vr-values.cc @@ -615,58 +615,6 @@ bounds_of_var_in_loop (tree *min, tree *max, range_query *query, return true; } -/* Helper that gets the value range of the SSA_NAME with version I - or a symbolic range containing the SSA_NAME only if the value range - is varying or undefined. Uses TEM as storage for the alternate range. */ - -const value_range * -simplify_using_ranges::get_vr_for_comparison (int i, value_range *tem, - gimple *s) -{ - /* Shallow-copy equiv bitmap. */ - const value_range *vr = query->get_value_range (ssa_name (i), s); - - /* If name N_i does not have a valid range, use N_i as its own - range. This allows us to compare against names that may - have N_i in their ranges. */ - if (vr->varying_p () || vr->undefined_p ()) - { - tree ssa = ssa_name (i); - tem->set (ssa, ssa); - return tem; - } - - return vr; -} - -/* Compare all the value ranges for names equivalent to VAR with VAL - using comparison code COMP. Return the same value returned by - compare_range_with_value, including the setting of - *STRICT_OVERFLOW_P. */ - -tree -simplify_using_ranges::compare_name_with_value - (enum tree_code comp, tree var, tree val, - bool *strict_overflow_p, gimple *s) -{ - /* Start at -1. Set it to 0 if we do a comparison without relying - on overflow, or 1 if all comparisons rely on overflow. */ - int used_strict_overflow = -1; - - /* Compare vars' value range with val. */ - value_range tem_vr; - const value_range *equiv_vr - = get_vr_for_comparison (SSA_NAME_VERSION (var), &tem_vr, s); - bool sop = false; - tree retval = compare_range_with_value (comp, equiv_vr, val, &sop); - if (retval) - used_strict_overflow = sop ? 1 : 0; - - if (retval && used_strict_overflow > 0) - *strict_overflow_p = true; - return retval; -} - /* Helper function for vrp_evaluate_conditional_warnv & other optimizers. */ @@ -780,11 +728,6 @@ simplify_using_ranges::vrp_evaluate_conditional_warnv_with_ops return ret; if (only_ranges) *only_ranges = false; - if (TREE_CODE (op0) == SSA_NAME) - return compare_name_with_value (code, op0, op1, strict_overflow_p, stmt); - else if (TREE_CODE (op1) == SSA_NAME) - return compare_name_with_value (swap_tree_comparison (code), op1, op0, - strict_overflow_p, stmt); return NULL_TREE; } diff --git a/gcc/vr-values.h b/gcc/vr-values.h index 00fcf7702aa..a89902c9c51 100644 --- a/gcc/vr-values.h +++ b/gcc/vr-values.h @@ -52,8 +52,6 @@ private: bool two_valued_val_range_p (tree, tree *, tree *, gimple *); bool op_with_boolean_value_range_p (tree, gimple *); - tree compare_name_with_value (enum tree_code, tree, tree, bool *, gimple *); - const value_range *get_vr_for_comparison (int, value_range *, gimple *s); tree vrp_evaluate_conditional_warnv_with_ops_using_ranges (enum tree_code, tree, tree, bool *, gimple *s);