From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27998 invoked by alias); 7 Nov 2015 12:48:22 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 27979 invoked by uid 89); 7 Nov 2015 12:48:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 07 Nov 2015 12:48:20 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-5-hYsHBSVFRySmAdvTWJpkAQ-1; Sat, 07 Nov 2015 12:48:15 +0000 Received: from localhost ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 7 Nov 2015 12:48:15 +0000 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Use combined_fn in tree-ssa-reassoc.c Date: Sat, 07 Nov 2015 12:48:00 -0000 Message-ID: <87egg2q8kw.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: hYsHBSVFRySmAdvTWJpkAQ-1 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2015-11/txt/msg00796.txt.bz2 Another patch to extend uses of built_in_function to combined_fn, this time in tree-ssa-reassoc.c. Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. OK to install? Thanks, Richard gcc/ * tree-ssa-reassoc.c: Include case-cfn-macros.h. (stmt_is_power_of_op): Use combined_fn instead of built-in codes. (decrement_power, acceptable_pow_call): Likewise. (attempt_builtin_copysign): Likewise. diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index a75290c..9394664 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "builtins.h" #include "gimplify.h" +#include "case-cfn-macros.h" =20 /* This is a simple global reassociation pass. It is, in part, based on the LLVM pass of the same name (They do some things more/less @@ -1035,21 +1036,13 @@ oecount_cmp (const void *p1, const void *p2) static bool stmt_is_power_of_op (gimple *stmt, tree op) { - tree fndecl; - if (!is_gimple_call (stmt)) return false; =20 - fndecl =3D gimple_call_fndecl (stmt); - - if (!fndecl - || DECL_BUILT_IN_CLASS (fndecl) !=3D BUILT_IN_NORMAL) - return false; - - switch (DECL_FUNCTION_CODE (gimple_call_fndecl (stmt))) + switch (gimple_call_combined_fn (stmt)) { - CASE_FLT_FN (BUILT_IN_POW): - CASE_FLT_FN (BUILT_IN_POWI): + CASE_CFN_POW: + CASE_CFN_POWI: return (operand_equal_p (gimple_call_arg (stmt, 0), op, 0)); =20=20=20=20=20=20=20 default: @@ -1068,9 +1061,9 @@ decrement_power (gimple *stmt) HOST_WIDE_INT power; tree arg1; =20 - switch (DECL_FUNCTION_CODE (gimple_call_fndecl (stmt))) + switch (gimple_call_combined_fn (stmt)) { - CASE_FLT_FN (BUILT_IN_POW): + CASE_CFN_POW: arg1 =3D gimple_call_arg (stmt, 1); c =3D TREE_REAL_CST (arg1); power =3D real_to_integer (&c) - 1; @@ -1078,7 +1071,7 @@ decrement_power (gimple *stmt) gimple_call_set_arg (stmt, 1, build_real (TREE_TYPE (arg1), cint)); return power; =20 - CASE_FLT_FN (BUILT_IN_POWI): + CASE_CFN_POWI: arg1 =3D gimple_call_arg (stmt, 1); power =3D TREE_INT_CST_LOW (arg1) - 1; gimple_call_set_arg (stmt, 1, build_int_cst (TREE_TYPE (arg1), power= )); @@ -3937,7 +3930,7 @@ break_up_subtract (gimple *stmt, gimple_stmt_iterator= *gsip) static bool acceptable_pow_call (gimple *stmt, tree *base, HOST_WIDE_INT *exponent) { - tree fndecl, arg1; + tree arg1; REAL_VALUE_TYPE c, cint; =20 if (!first_pass_instance @@ -3946,15 +3939,9 @@ acceptable_pow_call (gimple *stmt, tree *base, HOST_= WIDE_INT *exponent) || !has_single_use (gimple_call_lhs (stmt))) return false; =20 - fndecl =3D gimple_call_fndecl (stmt); - - if (!fndecl - || DECL_BUILT_IN_CLASS (fndecl) !=3D BUILT_IN_NORMAL) - return false; - - switch (DECL_FUNCTION_CODE (fndecl)) + switch (gimple_call_combined_fn (stmt)) { - CASE_FLT_FN (BUILT_IN_POW): + CASE_CFN_POW: if (flag_errno_math) return false; =20 @@ -3976,7 +3963,7 @@ acceptable_pow_call (gimple *stmt, tree *base, HOST_W= IDE_INT *exponent) =20 break; =20 - CASE_FLT_FN (BUILT_IN_POWI): + CASE_CFN_POWI: *base =3D gimple_call_arg (stmt, 0); arg1 =3D gimple_call_arg (stmt, 1); =20 @@ -4636,35 +4623,40 @@ attempt_builtin_copysign (vec *ops) && has_single_use (oe->op)) { gimple *def_stmt =3D SSA_NAME_DEF_STMT (oe->op); - if (gimple_call_builtin_p (def_stmt, BUILT_IN_NORMAL)) + if (gcall *old_call =3D dyn_cast (def_stmt)) { - tree fndecl =3D gimple_call_fndecl (def_stmt); tree arg0, arg1; - switch (DECL_FUNCTION_CODE (fndecl)) + switch (gimple_call_combined_fn (old_call)) { - CASE_FLT_FN (BUILT_IN_COPYSIGN): - arg0 =3D gimple_call_arg (def_stmt, 0); - arg1 =3D gimple_call_arg (def_stmt, 1); + CASE_CFN_COPYSIGN: + arg0 =3D gimple_call_arg (old_call, 0); + arg1 =3D gimple_call_arg (old_call, 1); /* The first argument of copysign must be a constant, otherwise there's nothing to do. */ if (TREE_CODE (arg0) =3D=3D REAL_CST) { - tree mul =3D const_binop (MULT_EXPR, TREE_TYPE (cst), - cst, arg0); + tree type =3D TREE_TYPE (arg0); + tree mul =3D const_binop (MULT_EXPR, type, cst, arg0); /* If we couldn't fold to a single constant, skip it. That happens e.g. for inexact multiplication when -frounding-math. */ if (mul =3D=3D NULL_TREE) break; - /* Instead of adjusting the old DEF_STMT, let's build - a new call to not leak the LHS and prevent keeping - bogus debug statements. DCE will clean up the old - call. */ - gcall *call =3D gimple_build_call (fndecl, 2, mul, arg1); - tree lhs =3D make_ssa_name (TREE_TYPE (arg0)); - gimple_call_set_lhs (call, lhs); - gimple_set_location (call, gimple_location (def_stmt)); - insert_stmt_after (call, def_stmt); + /* Instead of adjusting OLD_CALL, let's build a new + call to not leak the LHS and prevent keeping bogus + debug statements. DCE will clean up the old call. */ + gcall *new_call; + if (gimple_call_internal_p (old_call)) + new_call =3D gimple_build_call_internal + (IFN_COPYSIGN, 2, mul, arg1); + else + new_call =3D gimple_build_call + (gimple_call_fndecl (old_call), 2, mul, arg1); + tree lhs =3D make_ssa_name (type); + gimple_call_set_lhs (new_call, lhs); + gimple_set_location (new_call, + gimple_location (old_call)); + insert_stmt_after (new_call, old_call); /* We've used the constant, get rid of it. */ ops->pop (); bool cst1_neg =3D real_isneg (TREE_REAL_CST_PTR (cst)); @@ -4674,7 +4666,7 @@ attempt_builtin_copysign (vec *ops) tree negrhs =3D make_ssa_name (TREE_TYPE (lhs)); gimple *negate_stmt =3D gimple_build_assign (negrhs, NEGATE_EXPR, lhs); - insert_stmt_after (negate_stmt, call); + insert_stmt_after (negate_stmt, new_call); oe->op =3D negrhs; } else @@ -4683,18 +4675,12 @@ attempt_builtin_copysign (vec *ops) { fprintf (dump_file, "Optimizing copysign: "); print_generic_expr (dump_file, cst, 0); - fprintf (dump_file, " * "); - print_generic_expr (dump_file, - gimple_call_fn (def_stmt), 0); - fprintf (dump_file, " ("); + fprintf (dump_file, " * COPYSIGN ("); print_generic_expr (dump_file, arg0, 0); fprintf (dump_file, ", "); print_generic_expr (dump_file, arg1, 0); - fprintf (dump_file, ") into %s", + fprintf (dump_file, ") into %sCOPYSIGN (", cst1_neg ? "-" : ""); - print_generic_expr (dump_file, - gimple_call_fn (def_stmt), 0); - fprintf (dump_file, " ("); print_generic_expr (dump_file, mul, 0); fprintf (dump_file, ", "); print_generic_expr (dump_file, arg1, 0);