From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 4A97B384640E for ; Mon, 5 Jul 2021 11:18:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4A97B384640E Received: by mail-ej1-x62c.google.com with SMTP id i20so28255019ejw.4 for ; Mon, 05 Jul 2021 04:18:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=N6n2rl2cBU2j9l4i9BPHyE01LLM6Ln4theqc0XCIIzs=; b=YzYQFWj/jLrDNmr8FkZk6/HIcRfPJT8TUO1KfC0eKfYkEyavQc6f+fiIfvqM105+1g 2RwyZBjTunPK+rHs/iTlch95iOVVcMGinIxd1U1uLj7me4CuxF0PAz4PPvdEbmtG+Ud7 kVPydc05DHfLLfW3tHu5Up+Sm4nleCOg/unK0bzD3MPhE4/SJv1bxyCs6qqggjA6L1uA YrKNZceY+Y/6ipy/lVCuXx68XEbseaC11uOqDVMYyVW2mvI0cWRGAqlX4vQiqKbZNJHk BguFK3RXrXTWy3X+3MJyPeNsMH/1LuiCRqbWrG74V9rfRI8bvFGWotdbP7CyKSQ7BljY SiTA== X-Gm-Message-State: AOAM530oaTwMrUkaCiS2XaxDHPu8cMVCEkcBhF2C3Zs5PcjNwWB94VKg naQndI+uDmtQuDm7ZRr9d+eE3iwp7b3fpsYP1GM= X-Google-Smtp-Source: ABdhPJxWEngl2y1Uh4InzwTUW3EC713VGU9JQnqXkPi3/ReMd5daxvNoEP+0y/T2n/EVEvoWDy9VKZkFLNXtWMZJOVM= X-Received: by 2002:a17:906:99c2:: with SMTP id s2mr7444444ejn.482.1625483914296; Mon, 05 Jul 2021 04:18:34 -0700 (PDT) MIME-Version: 1.0 References: <1625423864-20417-1-git-send-email-apinski@marvell.com> <1625423864-20417-2-git-send-email-apinski@marvell.com> In-Reply-To: <1625423864-20417-2-git-send-email-apinski@marvell.com> From: Richard Biener Date: Mon, 5 Jul 2021 13:18:23 +0200 Message-ID: Subject: Re: [PATCH 2/5] Fix PR 101237: Remove element_type call when used with the functions from real To: Andrew Pinski Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.9 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Mon, 05 Jul 2021 11:18:39 -0000 On Sun, Jul 4, 2021 at 8:39 PM apinski--- via Gcc-patches wrote: > > From: Andrew Pinski > > HONOR_SIGNED_ZEROS, HONOR_SIGN_DEPENDENT_ROUNDING, and HONOR_SNANS all > have an overload for taking a tree type now, so we should do that instead. > > OK? Bootstrapped and tested on x86_64-linux-gnu. OK. Thanks, Richard. > gcc/ChangeLog: > > PR middle-end/101237 > * fold-const.c (negate_expr_p): Remove call to element_mode > and TREE_MODE/TREE_TYPE when calling HONOR_SIGNED_ZEROS, > HONOR_SIGN_DEPENDENT_ROUNDING, and HONOR_SNANS. > (fold_negate_expr_1): Likewise. > (const_unop): Likewise. > (fold_cond_expr_with_comparison): Likewise. > (fold_binary_loc): Likewise. > (fold_ternary_loc): Likewise. > (tree_call_nonnegative_warnv_p): Likewise. > * match.pd (-(A + B) -> (-B) - A): Likewise. > --- > gcc/fold-const.c | 46 +++++++++++++++++++++++----------------------- > gcc/match.pd | 4 ++-- > 2 files changed, 25 insertions(+), 25 deletions(-) > > diff --git a/gcc/fold-const.c b/gcc/fold-const.c > index dfccbaec683..e0cdb75fb26 100644 > --- a/gcc/fold-const.c > +++ b/gcc/fold-const.c > @@ -432,8 +432,8 @@ negate_expr_p (tree t) > return negate_expr_p (TREE_OPERAND (t, 0)); > > case PLUS_EXPR: > - if (HONOR_SIGN_DEPENDENT_ROUNDING (element_mode (type)) > - || HONOR_SIGNED_ZEROS (element_mode (type)) > + if (HONOR_SIGN_DEPENDENT_ROUNDING (type) > + || HONOR_SIGNED_ZEROS (type) > || (ANY_INTEGRAL_TYPE_P (type) > && ! TYPE_OVERFLOW_WRAPS (type))) > return false; > @@ -445,8 +445,8 @@ negate_expr_p (tree t) > > case MINUS_EXPR: > /* We can't turn -(A-B) into B-A when we honor signed zeros. */ > - return !HONOR_SIGN_DEPENDENT_ROUNDING (element_mode (type)) > - && !HONOR_SIGNED_ZEROS (element_mode (type)) > + return !HONOR_SIGN_DEPENDENT_ROUNDING (type) > + && !HONOR_SIGNED_ZEROS (type) > && (! ANY_INTEGRAL_TYPE_P (type) > || TYPE_OVERFLOW_WRAPS (type)); > > @@ -468,7 +468,7 @@ negate_expr_p (tree t) > /* Fall through. */ > > case RDIV_EXPR: > - if (! HONOR_SIGN_DEPENDENT_ROUNDING (element_mode (TREE_TYPE (t)))) > + if (! HONOR_SIGN_DEPENDENT_ROUNDING (t)) > return negate_expr_p (TREE_OPERAND (t, 1)) > || negate_expr_p (TREE_OPERAND (t, 0)); > break; > @@ -605,8 +605,8 @@ fold_negate_expr_1 (location_t loc, tree t) > break; > > case PLUS_EXPR: > - if (!HONOR_SIGN_DEPENDENT_ROUNDING (element_mode (type)) > - && !HONOR_SIGNED_ZEROS (element_mode (type))) > + if (!HONOR_SIGN_DEPENDENT_ROUNDING (type) > + && !HONOR_SIGNED_ZEROS (type)) > { > /* -(A + B) -> (-B) - A. */ > if (negate_expr_p (TREE_OPERAND (t, 1))) > @@ -628,8 +628,8 @@ fold_negate_expr_1 (location_t loc, tree t) > > case MINUS_EXPR: > /* - (A - B) -> B - A */ > - if (!HONOR_SIGN_DEPENDENT_ROUNDING (element_mode (type)) > - && !HONOR_SIGNED_ZEROS (element_mode (type))) > + if (!HONOR_SIGN_DEPENDENT_ROUNDING (type) > + && !HONOR_SIGNED_ZEROS (type)) > return fold_build2_loc (loc, MINUS_EXPR, type, > TREE_OPERAND (t, 1), TREE_OPERAND (t, 0)); > break; > @@ -641,7 +641,7 @@ fold_negate_expr_1 (location_t loc, tree t) > /* Fall through. */ > > case RDIV_EXPR: > - if (! HONOR_SIGN_DEPENDENT_ROUNDING (element_mode (type))) > + if (! HONOR_SIGN_DEPENDENT_ROUNDING (type)) > { > tem = TREE_OPERAND (t, 1); > if (negate_expr_p (tem)) > @@ -1725,7 +1725,7 @@ const_unop (enum tree_code code, tree type, tree arg0) > /* Don't perform the operation, other than NEGATE and ABS, if > flag_signaling_nans is on and the operand is a signaling NaN. */ > if (TREE_CODE (arg0) == REAL_CST > - && HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0))) > + && HONOR_SNANS (arg0) > && REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (arg0)) > && code != NEGATE_EXPR > && code != ABS_EXPR > @@ -2135,7 +2135,7 @@ fold_convert_const_real_from_real (tree type, const_tree arg1) > > /* Don't perform the operation if flag_signaling_nans is on > and the operand is a signaling NaN. */ > - if (HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg1))) > + if (HONOR_SNANS (arg1) > && REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (arg1))) > return NULL_TREE; > > @@ -5773,7 +5773,7 @@ fold_cond_expr_with_comparison (location_t loc, tree type, > > Note that all these transformations are correct if A is > NaN, since the two alternatives (A and -A) are also NaNs. */ > - if (!HONOR_SIGNED_ZEROS (element_mode (type)) > + if (!HONOR_SIGNED_ZEROS (type) > && (FLOAT_TYPE_P (TREE_TYPE (arg01)) > ? real_zerop (arg01) > : integer_zerop (arg01)) > @@ -5842,7 +5842,7 @@ fold_cond_expr_with_comparison (location_t loc, tree type, > both transformations are correct when A is NaN: A != 0 > is then true, and A == 0 is false. */ > > - if (!HONOR_SIGNED_ZEROS (element_mode (type)) > + if (!HONOR_SIGNED_ZEROS (type) > && integer_zerop (arg01) && integer_zerop (arg2)) > { > if (comp_code == NE_EXPR) > @@ -5877,7 +5877,7 @@ fold_cond_expr_with_comparison (location_t loc, tree type, > a number and A is not. The conditions in the original > expressions will be false, so all four give B. The min() > and max() versions would give a NaN instead. */ > - if (!HONOR_SIGNED_ZEROS (element_mode (type)) > + if (!HONOR_SIGNED_ZEROS (type) > && operand_equal_for_comparison_p (arg01, arg2) > /* Avoid these transformations if the COND_EXPR may be used > as an lvalue in the C++ front-end. PR c++/19199. */ > @@ -11005,8 +11005,8 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type, > /* Fold __complex__ ( x, 0 ) + __complex__ ( 0, y ) > to __complex__ ( x, y ). This is not the same for SNaNs or > if signed zeros are involved. */ > - if (!HONOR_SNANS (element_mode (arg0)) > - && !HONOR_SIGNED_ZEROS (element_mode (arg0)) > + if (!HONOR_SNANS (arg0) > + && !HONOR_SIGNED_ZEROS (arg0) > && COMPLEX_FLOAT_TYPE_P (TREE_TYPE (arg0))) > { > tree rtype = TREE_TYPE (TREE_TYPE (arg0)); > @@ -11404,8 +11404,8 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type, > /* Fold __complex__ ( x, 0 ) - __complex__ ( 0, y ) to > __complex__ ( x, -y ). This is not the same for SNaNs or if > signed zeros are involved. */ > - if (!HONOR_SNANS (element_mode (arg0)) > - && !HONOR_SIGNED_ZEROS (element_mode (arg0)) > + if (!HONOR_SNANS (arg0) > + && !HONOR_SIGNED_ZEROS (arg0) > && COMPLEX_FLOAT_TYPE_P (TREE_TYPE (arg0))) > { > tree rtype = TREE_TYPE (TREE_TYPE (arg0)); > @@ -11509,7 +11509,7 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type, > This is not the same for NaNs or if signed zeros are > involved. */ > if (!HONOR_NANS (arg0) > - && !HONOR_SIGNED_ZEROS (element_mode (arg0)) > + && !HONOR_SIGNED_ZEROS (arg0) > && COMPLEX_FLOAT_TYPE_P (TREE_TYPE (arg0)) > && TREE_CODE (arg1) == COMPLEX_CST > && real_zerop (TREE_REALPART (arg1))) > @@ -12819,7 +12819,7 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type, > Also try swapping the arguments and inverting the conditional. */ > if (COMPARISON_CLASS_P (arg0) > && operand_equal_for_comparison_p (TREE_OPERAND (arg0, 0), op1) > - && !HONOR_SIGNED_ZEROS (element_mode (op1))) > + && !HONOR_SIGNED_ZEROS (op1)) > { > tem = fold_cond_expr_with_comparison (loc, type, TREE_CODE (arg0), > TREE_OPERAND (arg0, 0), > @@ -12831,7 +12831,7 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type, > > if (COMPARISON_CLASS_P (arg0) > && operand_equal_for_comparison_p (TREE_OPERAND (arg0, 0), op2) > - && !HONOR_SIGNED_ZEROS (element_mode (op2))) > + && !HONOR_SIGNED_ZEROS (op2)) > { > enum tree_code comp_code = TREE_CODE (arg0); > tree arg00 = TREE_OPERAND (arg0, 0); > @@ -14713,7 +14713,7 @@ tree_call_nonnegative_warnv_p (tree type, combined_fn fn, tree arg0, tree arg1, > CASE_CFN_SQRT: > CASE_CFN_SQRT_FN: > /* sqrt(-0.0) is -0.0. */ > - if (!HONOR_SIGNED_ZEROS (element_mode (type))) > + if (!HONOR_SIGNED_ZEROS (type)) > return true; > return RECURSE (arg0); > > diff --git a/gcc/match.pd b/gcc/match.pd > index 82052714e1c..4e10d54383c 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -1458,8 +1458,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > /* -(A + B) -> (-B) - A. */ > (simplify > (negate (plus:c @0 negate_expr_p@1)) > - (if (!HONOR_SIGN_DEPENDENT_ROUNDING (element_mode (type)) > - && !HONOR_SIGNED_ZEROS (element_mode (type))) > + (if (!HONOR_SIGN_DEPENDENT_ROUNDING (type) > + && !HONOR_SIGNED_ZEROS (type)) > (minus (negate @1) @0))) > > /* -(A - B) -> B - A. */ > -- > 2.27.0 >