From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 9AF9D384F6D9 for ; Wed, 23 Nov 2022 20:28:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9AF9D384F6D9 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-lf1-x12b.google.com with SMTP id j16so29798960lfe.12 for ; Wed, 23 Nov 2022 12:28:54 -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=eOqKDr8rt+tyr4OU7kDqPU5Cz599d9WTS5yOf9wGv3Q=; b=UKomAgc/sh3UGuRQxfEvBbFfo4buFF27IwUcRQKefk8Dh7JP7m36FIXNtkS8r7kBBG 3wT+dMSDWUk2II8j08Lk92hx7j3tY3LVD4MgHKjIEM30M7HMW5QG4nF6oEkWdmonHOvP GzfFs1IBb9dyn1VZ3FhWYQ9vfdpQ6nmjDghYs2TcUiqi0/sDt0uceFw9RcT5I1D8wbAX mUsWN6jJI3Hzgrwi8+ryk40YjetOsVgRRSFkBAhp754A6ZShOv28Zh89tXOKmXWDM7fe Y0sgHkJvvFaNsVr23FLu9jWszZEiu9Sekx71YZeuQZb2KFGD4zF0wW6JOp4qoSxYP9aZ ejNg== 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=eOqKDr8rt+tyr4OU7kDqPU5Cz599d9WTS5yOf9wGv3Q=; b=C7BX4TyyVSDLaF9CALsHb1KMY9/qr45lebbFzIMywuwb2hpLzbN29H64ZIYgEChwjy LtChmei7u/0HPcCY0JvzH2eG8kODqmuVtFg4YMPolbKYrn/K2hZS5aRURAyBPRA68NmZ 1ftKvPjaegJ5S4gtZ4DIqg2YqtPY8GxPtW6FrWBgD/rQJmzvAga4prsc50jJs+H4Nn9x 1gplLohkNltFBRnpWazdjwbyPalP4tOCOlrLeltkxqhyF/gpHzCrWgUV+tZ6LBD/V0Kq 1IZbGO5kyQ+73TtNHqxDKcjPxiRdfTqtDkrNhYHfaTzGuXeL1/SUOZKXEzPW2bbXSp8b DqAw== X-Gm-Message-State: ANoB5pnsD0MftWYsdILo7k88T2xAnC7vMDYIxwSo4qISKh/Fh8rhjgAf AAMeL5xQz7+ZNpESOP79CDzFxJfZuMzcwI2BweNaNTys X-Google-Smtp-Source: AA0mqf5DJH4mqtioij8d2FwukBaZnK20ZIcH5rv1oXD+Wzygs3zFCjPF1YleV/Z+rr9Ht4BbgV+tOaxNw/OlCkMU41g= X-Received: by 2002:ac2:5dd3:0:b0:4a2:6e1d:f996 with SMTP id x19-20020ac25dd3000000b004a26e1df996mr4958583lfq.114.1669235333251; Wed, 23 Nov 2022 12:28:53 -0800 (PST) MIME-Version: 1.0 References: <20221122135801.1945438-1-aldyh@redhat.com> <20221122135801.1945438-2-aldyh@redhat.com> In-Reply-To: <20221122135801.1945438-2-aldyh@redhat.com> From: Richard Biener Date: Wed, 23 Nov 2022 21:28:40 +0100 Message-ID: Subject: Re: [PATCH] Remove follow_assert_exprs from overflow_comparison. To: Aldy Hernandez Cc: GCC patches , Andrew MacLeod Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.2 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: > > OK pending tests? OK > gcc/ChangeLog: > > * tree-vrp.cc (overflow_comparison_p_1): Remove follow_assert_exprs. > (overflow_comparison_p): Remove use_equiv_p. > * tree-vrp.h (overflow_comparison_p): Same. > * vr-values.cc (vrp_evaluate_conditional_warnv_with_ops): Remove > use_equiv_p argument to overflow_comparison_p. > --- > gcc/tree-vrp.cc | 40 ++++------------------------------------ > gcc/tree-vrp.h | 2 +- > gcc/vr-values.cc | 2 +- > 3 files changed, 6 insertions(+), 38 deletions(-) > > diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc > index d29941d0f2d..3846dc1d849 100644 > --- a/gcc/tree-vrp.cc > +++ b/gcc/tree-vrp.cc > @@ -679,7 +679,7 @@ range_fold_unary_expr (value_range *vr, > > static bool > overflow_comparison_p_1 (enum tree_code code, tree op0, tree op1, > - bool follow_assert_exprs, bool reversed, tree *new_cst) > + bool reversed, tree *new_cst) > { > /* See if this is a relational operation between two SSA_NAMES with > unsigned, overflow wrapping values. If so, check it more deeply. */ > @@ -693,19 +693,6 @@ overflow_comparison_p_1 (enum tree_code code, tree op0, tree op1, > { > gimple *op1_def = SSA_NAME_DEF_STMT (op1); > > - /* If requested, follow any ASSERT_EXPRs backwards for OP1. */ > - if (follow_assert_exprs) > - { > - while (gimple_assign_single_p (op1_def) > - && TREE_CODE (gimple_assign_rhs1 (op1_def)) == ASSERT_EXPR) > - { > - op1 = TREE_OPERAND (gimple_assign_rhs1 (op1_def), 0); > - if (TREE_CODE (op1) != SSA_NAME) > - break; > - op1_def = SSA_NAME_DEF_STMT (op1); > - } > - } > - > /* Now look at the defining statement of OP1 to see if it adds > or subtracts a nonzero constant from another operand. */ > if (op1_def > @@ -716,24 +703,6 @@ overflow_comparison_p_1 (enum tree_code code, tree op0, tree op1, > { > tree target = gimple_assign_rhs1 (op1_def); > > - /* If requested, follow ASSERT_EXPRs backwards for op0 looking > - for one where TARGET appears on the RHS. */ > - if (follow_assert_exprs) > - { > - /* Now see if that "other operand" is op0, following the chain > - of ASSERT_EXPRs if necessary. */ > - gimple *op0_def = SSA_NAME_DEF_STMT (op0); > - while (op0 != target > - && gimple_assign_single_p (op0_def) > - && TREE_CODE (gimple_assign_rhs1 (op0_def)) == ASSERT_EXPR) > - { > - op0 = TREE_OPERAND (gimple_assign_rhs1 (op0_def), 0); > - if (TREE_CODE (op0) != SSA_NAME) > - break; > - op0_def = SSA_NAME_DEF_STMT (op0); > - } > - } > - > /* If we did not find our target SSA_NAME, then this is not > an overflow test. */ > if (op0 != target) > @@ -764,13 +733,12 @@ overflow_comparison_p_1 (enum tree_code code, tree op0, tree op1, > the alternate range representation is often useful within VRP. */ > > bool > -overflow_comparison_p (tree_code code, tree name, tree val, > - bool use_equiv_p, tree *new_cst) > +overflow_comparison_p (tree_code code, tree name, tree val, tree *new_cst) > { > - if (overflow_comparison_p_1 (code, name, val, use_equiv_p, false, new_cst)) > + if (overflow_comparison_p_1 (code, name, val, false, new_cst)) > return true; > return overflow_comparison_p_1 (swap_tree_comparison (code), val, name, > - use_equiv_p, true, new_cst); > + true, new_cst); > } > > /* Handle > diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h > index 07630b5b1ca..127909604f0 100644 > --- a/gcc/tree-vrp.h > +++ b/gcc/tree-vrp.h > @@ -39,7 +39,7 @@ extern enum value_range_kind intersect_range_with_nonzero_bits > extern bool find_case_label_range (gswitch *, tree, tree, size_t *, size_t *); > extern tree find_case_label_range (gswitch *, const irange *vr); > extern bool find_case_label_index (gswitch *, size_t, tree, size_t *); > -extern bool overflow_comparison_p (tree_code, tree, tree, bool, tree *); > +extern bool overflow_comparison_p (tree_code, tree, tree, tree *); > extern void maybe_set_nonzero_bits (edge, tree); > > #endif /* GCC_TREE_VRP_H */ > diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc > index 0347c29b216..b0dd30260ae 100644 > --- a/gcc/vr-values.cc > +++ b/gcc/vr-values.cc > @@ -837,7 +837,7 @@ simplify_using_ranges::vrp_evaluate_conditional_warnv_with_ops > occurs when the chosen argument is zero and does not occur if the > chosen argument is not zero. */ > tree x; > - if (overflow_comparison_p (code, op0, op1, use_equiv_p, &x)) > + if (overflow_comparison_p (code, op0, op1, &x)) > { > wide_int max = wi::max_value (TYPE_PRECISION (TREE_TYPE (op0)), UNSIGNED); > /* B = A - 1; if (A < B) -> B = A - 1; if (A == 0) > -- > 2.38.1 >