From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id A6017384F6D7 for ; Wed, 23 Nov 2022 20:29:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A6017384F6D7 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x229.google.com with SMTP id s24so22628532ljs.11 for ; Wed, 23 Nov 2022 12:29:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=whWKR8pFM/6g/ddgOdNl5Gm0ty7rpQlA8hGf4W+6o1k=; b=ULy1+ND31X32QwPUpA8r++5jBA45K/Zm4CSniRkvtKYwaoEY80NhddEh+7A9svEQoH I/86f4CJ9lyCNp9V6fShGnKwVPJskTf8yNB7sElI246jMVhqcWPpjVaqV5Nwzxr4/Iu4 sSbzsKQ+Pi7cxt7zx5rw8dvH1sEshuUrxw8AS4w4QccUQP6wxYtmIX5oR4gwractxq86 nyjxLlvOQABrWdcL2c3Ae6TvwWIQ40VcIBQpJHb7Ie+0OzHDH1yVm4XQDhnGRY4K/3Is 4oRt1swhGvnAJW/7JFElwxiSelMMClsp5J+8EyQkd7LQ3AecYGRS0GJIbyvAFQznW1VP PHKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=whWKR8pFM/6g/ddgOdNl5Gm0ty7rpQlA8hGf4W+6o1k=; b=zD3ajm2TFKviNsvfKh5wldmIzyVpZ+vr8D1U6XDmkXNE3L5gA9W/31CoCTGowbREeb /7J7PrKgGqv6m7u5kImNx9Ub1lGsEU/4djoF+cMdXY1rWKe+Y+qkgvXU5mUX6bf2iKdL eKSHLuzt05YthXRAXva1lCpJeY0Q23O/7B5rzru6Y/fthMwJosWs0px7dD498jSgprzV 5RKaQGMe19oIrOkxHhnnkWBBc5lq80Q4hl0cWCxaTRjeDO49UM1ldPY3loRNpg6C6k9r oRhBWLVnLgEQbFxPao7shNYePIPoa3+qrZzx3qKpdubKli54i1zN+05kD8zgw1H35Wd8 erUw== X-Gm-Message-State: ANoB5pmAHXzMlbdLqJglltkWeWZIKi7VhMY9ry/OPgRa8MvUlia7Cp9C eo4/JufsjdWt6vyDQhsjETKU7ATAwzhv6QczEBM= X-Google-Smtp-Source: AA0mqf7JA7pWN1TtZxFM2e2QYcZECG/k+8gsUYWIpD90+rZX7xe02Af1kKJ2/g5Edx/ABRORJ+Lp3Tx7FOP9xUVHMVE= X-Received: by 2002:a2e:b11c:0:b0:261:d86f:3cde with SMTP id p28-20020a2eb11c000000b00261d86f3cdemr10301744ljl.86.1669235387240; Wed, 23 Nov 2022 12:29:47 -0800 (PST) MIME-Version: 1.0 References: <20221122135801.1945438-1-aldyh@redhat.com> <20221122135801.1945438-3-aldyh@redhat.com> In-Reply-To: <20221122135801.1945438-3-aldyh@redhat.com> From: Richard Biener Date: Wed, 23 Nov 2022 21:29:34 +0100 Message-ID: Subject: Re: [PATCH] Remove use_equiv_p in vr-values.cc To: Aldy Hernandez Cc: GCC patches , Andrew MacLeod Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On Tue, Nov 22, 2022 at 2:58 PM Aldy Hernandez wrote: > > With no equivalences, the use_equiv_p argument in various methods in > simplify_using_ranges is always false. This means we can remove all > calls to compare_names, along with the function. > > OK pending tests? OK > gcc/ChangeLog: > > * vr-values.cc (simplify_using_ranges::compare_names): Remove. > (vrp_evaluate_conditional_warnv_with_ops): Remove call to > compare_names. > (simplify_using_ranges::vrp_visit_cond_stmt): Remove use_equiv_p > argument to vrp_evaluate_conditional_warnv_with_ops. > * vr-values.h (class simplify_using_ranges): Remove > compare_names. > Remove use_equiv_p to vrp_evaluate_conditional_warnv_with_ops. > --- > gcc/vr-values.cc | 127 +---------------------------------------------- > gcc/vr-values.h | 4 +- > 2 files changed, 3 insertions(+), 128 deletions(-) > > diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc > index b0dd30260ae..1dbd9e47085 100644 > --- a/gcc/vr-values.cc > +++ b/gcc/vr-values.cc > @@ -667,124 +667,6 @@ simplify_using_ranges::compare_name_with_value > return retval; > } > > -/* Given a comparison code COMP and names N1 and N2, compare all the > - ranges equivalent to N1 against all the ranges equivalent to N2 > - to determine the value of N1 COMP N2. Return the same value > - returned by compare_ranges. Set *STRICT_OVERFLOW_P to indicate > - whether we relied on undefined signed overflow in the comparison. */ > - > - > -tree > -simplify_using_ranges::compare_names (enum tree_code comp, tree n1, tree n2, > - bool *strict_overflow_p, gimple *s) > -{ > - /* ?? These bitmaps are NULL as there are no longer any equivalences > - available in the value_range*. */ > - bitmap e1 = NULL; > - bitmap e2 = NULL; > - > - /* Use the fake bitmaps if e1 or e2 are not available. */ > - static bitmap s_e1 = NULL, s_e2 = NULL; > - static bitmap_obstack *s_obstack = NULL; > - if (s_obstack == NULL) > - { > - s_obstack = XNEW (bitmap_obstack); > - bitmap_obstack_initialize (s_obstack); > - s_e1 = BITMAP_ALLOC (s_obstack); > - s_e2 = BITMAP_ALLOC (s_obstack); > - } > - if (e1 == NULL) > - e1 = s_e1; > - if (e2 == NULL) > - e2 = s_e2; > - > - /* Add N1 and N2 to their own set of equivalences to avoid > - duplicating the body of the loop just to check N1 and N2 > - ranges. */ > - bitmap_set_bit (e1, SSA_NAME_VERSION (n1)); > - bitmap_set_bit (e2, SSA_NAME_VERSION (n2)); > - > - /* If the equivalence sets have a common intersection, then the two > - names can be compared without checking their ranges. */ > - if (bitmap_intersect_p (e1, e2)) > - { > - bitmap_clear_bit (e1, SSA_NAME_VERSION (n1)); > - bitmap_clear_bit (e2, SSA_NAME_VERSION (n2)); > - > - return (comp == EQ_EXPR || comp == GE_EXPR || comp == LE_EXPR) > - ? boolean_true_node > - : boolean_false_node; > - } > - > - /* 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; > - > - /* Otherwise, compare all the equivalent ranges. First, add N1 and > - N2 to their own set of equivalences to avoid duplicating the body > - of the loop just to check N1 and N2 ranges. */ > - bitmap_iterator bi1; > - unsigned i1; > - EXECUTE_IF_SET_IN_BITMAP (e1, 0, i1, bi1) > - { > - if (!ssa_name (i1)) > - continue; > - > - value_range tem_vr1; > - const value_range *vr1 = get_vr_for_comparison (i1, &tem_vr1, s); > - > - tree t = NULL_TREE, retval = NULL_TREE; > - bitmap_iterator bi2; > - unsigned i2; > - EXECUTE_IF_SET_IN_BITMAP (e2, 0, i2, bi2) > - { > - if (!ssa_name (i2)) > - continue; > - > - bool sop = false; > - > - value_range tem_vr2; > - const value_range *vr2 = get_vr_for_comparison (i2, &tem_vr2, s); > - > - t = compare_ranges (comp, vr1, vr2, &sop); > - if (t) > - { > - /* If we get different answers from different members > - of the equivalence set this check must be in a dead > - code region. Folding it to a trap representation > - would be correct here. For now just return don't-know. */ > - if (retval != NULL && t != retval) > - { > - bitmap_clear_bit (e1, SSA_NAME_VERSION (n1)); > - bitmap_clear_bit (e2, SSA_NAME_VERSION (n2)); > - return NULL_TREE; > - } > - retval = t; > - > - if (!sop) > - used_strict_overflow = 0; > - else if (used_strict_overflow < 0) > - used_strict_overflow = 1; > - } > - } > - > - if (retval) > - { > - bitmap_clear_bit (e1, SSA_NAME_VERSION (n1)); > - bitmap_clear_bit (e2, SSA_NAME_VERSION (n2)); > - if (used_strict_overflow > 0) > - *strict_overflow_p = true; > - return retval; > - } > - } > - > - /* None of the equivalent ranges are useful in computing this > - comparison. */ > - bitmap_clear_bit (e1, SSA_NAME_VERSION (n1)); > - bitmap_clear_bit (e2, SSA_NAME_VERSION (n2)); > - return NULL_TREE; > -} > - > /* Helper function for vrp_evaluate_conditional_warnv & other > optimizers. */ > > @@ -815,7 +697,6 @@ simplify_using_ranges::vrp_evaluate_conditional_warnv_with_ops > (gimple *stmt, > enum tree_code code, > tree op0, tree op1, > - bool use_equiv_p, > bool *strict_overflow_p, > bool *only_ranges) > { > @@ -899,11 +780,7 @@ simplify_using_ranges::vrp_evaluate_conditional_warnv_with_ops > return ret; > if (only_ranges) > *only_ranges = false; > - /* Do not use compare_names during propagation, it's quadratic. */ > - if (TREE_CODE (op0) == SSA_NAME && TREE_CODE (op1) == SSA_NAME > - && use_equiv_p) > - return compare_names (code, op0, op1, strict_overflow_p, stmt); > - else if (TREE_CODE (op0) == SSA_NAME) > + 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, > @@ -949,7 +826,7 @@ simplify_using_ranges::vrp_visit_cond_stmt (gcond *stmt, edge *taken_edge_p) > gimple_cond_code (stmt), > gimple_cond_lhs (stmt), > gimple_cond_rhs (stmt), > - false, &sop, NULL); > + &sop, NULL); > if (val) > *taken_edge_p = find_taken_edge (gimple_bb (stmt), val); > > diff --git a/gcc/vr-values.h b/gcc/vr-values.h > index 9804aaf83d1..6ad9fb2b81d 100644 > --- a/gcc/vr-values.h > +++ b/gcc/vr-values.h > @@ -37,8 +37,7 @@ public: > private: > void vrp_visit_cond_stmt (gcond *, edge *); > tree vrp_evaluate_conditional_warnv_with_ops (gimple *stmt, enum tree_code, > - tree, tree, bool, > - bool *, bool *); > + tree, tree, bool *, bool *); > bool simplify_casted_cond (gcond *); > bool simplify_truth_ops_using_ranges (gimple_stmt_iterator *, gimple *); > bool simplify_div_or_mod_using_ranges (gimple_stmt_iterator *, gimple *); > @@ -54,7 +53,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 *); > - tree compare_names (enum tree_code, tree, tree, bool *, gimple *s); > 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, > -- > 2.38.1 >