From 2f5030259ccb5944c83dfd4c10306ae1844bec38 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 20 Aug 2003 15:27:49 -0400 Subject: [PATCH] builtins.c (expand_builtin_mathfn): Use get_callee_fndecl. * builtins.c (expand_builtin_mathfn): Use get_callee_fndecl. (expand_builtin_mathfn2, expand_builtin, builtin_mathfn_code, fold_trunc_transparent_mathfn, fold_builtin): Likewise. * dojump.c (do_jump): Likewise. * fold-const.c (operand_equal_p, fold): Likewise. (tree_expr_nonnegative_p): Likewise. From-SVN: r70611 --- gcc/ChangeLog | 7 +++ gcc/builtins.c | 14 +++--- gcc/dojump.c | 41 ++++++++-------- gcc/fold-const.c | 122 +++++++++++++++++++++++------------------------ 4 files changed, 93 insertions(+), 91 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ff2a9f70f9c..9e026a1489c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2003-08-20 Jason Merrill + * builtins.c (expand_builtin_mathfn): Use get_callee_fndecl. + (expand_builtin_mathfn2, expand_builtin, builtin_mathfn_code, + fold_trunc_transparent_mathfn, fold_builtin): Likewise. + * dojump.c (do_jump): Likewise. + * fold-const.c (operand_equal_p, fold): Likewise. + (tree_expr_nonnegative_p): Likewise. + * stor-layout.c (do_type_align): Only copy DECL_USER_ALIGN from TYPE_USER_ALIGN for FIELD_DECLs. diff --git a/gcc/builtins.c b/gcc/builtins.c index 934e6fa923d..10e9a2cb5eb 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -1566,7 +1566,7 @@ expand_builtin_mathfn (tree exp, rtx target, rtx subtarget) { optab builtin_optab; rtx op0, insns; - tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); + tree fndecl = get_callee_fndecl (exp); tree arglist = TREE_OPERAND (exp, 1); enum machine_mode mode; bool errno_set = false; @@ -1695,7 +1695,7 @@ expand_builtin_mathfn_2 (tree exp, rtx target, rtx subtarget) { optab builtin_optab; rtx op0, op1, insns; - tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); + tree fndecl = get_callee_fndecl (exp); tree arglist = TREE_OPERAND (exp, 1); tree arg0, arg1, temp, narg; enum machine_mode mode; @@ -4756,7 +4756,7 @@ rtx expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, int ignore) { - tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); + tree fndecl = get_callee_fndecl (exp); tree arglist = TREE_OPERAND (exp, 1); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); enum machine_mode target_mode = TYPE_MODE (TREE_TYPE (exp)); @@ -5301,8 +5301,8 @@ builtin_mathfn_code (tree t) || TREE_CODE (TREE_OPERAND (t, 0)) != ADDR_EXPR) return END_BUILTINS; - fndecl = TREE_OPERAND (TREE_OPERAND (t, 0), 0); - if (TREE_CODE (fndecl) != FUNCTION_DECL + fndecl = get_callee_fndecl (t); + if (fndecl == NULL_TREE || ! DECL_BUILT_IN (fndecl) || DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) return END_BUILTINS; @@ -5513,7 +5513,7 @@ integer_valued_real_p (tree t) static tree fold_trunc_transparent_mathfn (tree exp) { - tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); + tree fndecl = get_callee_fndecl (exp); tree arglist = TREE_OPERAND (exp, 1); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); tree arg; @@ -5732,7 +5732,7 @@ fold_builtin_ceil (tree exp) tree fold_builtin (tree exp) { - tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); + tree fndecl = get_callee_fndecl (exp); tree arglist = TREE_OPERAND (exp, 1); tree type = TREE_TYPE (TREE_TYPE (fndecl)); diff --git a/gcc/dojump.c b/gcc/dojump.c index c213cd0e967..2ed014bacf9 100644 --- a/gcc/dojump.c +++ b/gcc/dojump.c @@ -530,27 +530,26 @@ do_jump (tree exp, rtx if_false_label, rtx if_true_label) operation produced a 1 or 0. */ case CALL_EXPR: /* Check for a built-in function. */ - if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR) - { - tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); - tree arglist = TREE_OPERAND (exp, 1); - - if (TREE_CODE (fndecl) == FUNCTION_DECL - && DECL_BUILT_IN (fndecl) - && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT - && arglist != NULL_TREE - && TREE_CHAIN (arglist) != NULL_TREE) - { - rtx seq = expand_builtin_expect_jump (exp, if_false_label, - if_true_label); - - if (seq != NULL_RTX) - { - emit_insn (seq); - return; - } - } - } + { + tree fndecl = get_callee_fndecl (exp); + tree arglist = TREE_OPERAND (exp, 1); + + if (fndecl + && DECL_BUILT_IN (fndecl) + && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT + && arglist != NULL_TREE + && TREE_CHAIN (arglist) != NULL_TREE) + { + rtx seq = expand_builtin_expect_jump (exp, if_false_label, + if_true_label); + + if (seq != NULL_RTX) + { + emit_insn (seq); + return; + } + } + } /* Fall through and generate the normal code. */ default: diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 18fd4e7fa2a..488239d75cb 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1837,6 +1837,8 @@ truth_value_p (enum tree_code code) int operand_equal_p (tree arg0, tree arg1, int only_const) { + tree fndecl; + /* If both types don't have the same signedness, then we can't consider them equal. We must check this before the STRIP_NOPS calls because they may change the signedness of the arguments. */ @@ -2007,13 +2009,9 @@ operand_equal_p (tree arg0, tree arg1, int only_const) return 0; /* Only consider const functions equivalent. */ - if (TREE_CODE (TREE_OPERAND (arg0, 0)) == ADDR_EXPR) - { - tree fndecl = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0); - if (! (flags_from_decl_or_type (fndecl) & ECF_CONST)) - return 0; - } - else + fndecl = get_callee_fndecl (arg0); + if (fndecl == NULL_TREE + || ! (flags_from_decl_or_type (fndecl) & ECF_CONST)) return 0; /* Now see if all the arguments are the same. operand_equal_p @@ -5481,7 +5479,7 @@ fold (tree expr) { tree fndecl, arg, arglist; - fndecl = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0); + fndecl = get_callee_fndecl (arg0); arg = TREE_VALUE (TREE_OPERAND (arg0, 1)); arg = fold (build1 (NEGATE_EXPR, type, arg)); arglist = build_tree_list (NULL_TREE, arg); @@ -7622,13 +7620,12 @@ fold (tree expr) due to the return value of strlen being unsigned. */ if ((code == EQ_EXPR || code == NE_EXPR) && integer_zerop (arg1) - && TREE_CODE (arg0) == CALL_EXPR - && TREE_CODE (TREE_OPERAND (arg0, 0)) == ADDR_EXPR) + && TREE_CODE (arg0) == CALL_EXPR) { - tree fndecl = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0); + tree fndecl = get_callee_fndecl (arg0); tree arglist; - if (TREE_CODE (fndecl) == FUNCTION_DECL + if (fndecl && DECL_BUILT_IN (fndecl) && DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRLEN @@ -8637,58 +8634,57 @@ tree_expr_nonnegative_p (tree t) return rtl_expr_nonnegative_p (RTL_EXPR_RTL (t)); case CALL_EXPR: - if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR) - { - tree fndecl = TREE_OPERAND (TREE_OPERAND (t, 0), 0); - tree arglist = TREE_OPERAND (t, 1); - if (TREE_CODE (fndecl) == FUNCTION_DECL - && DECL_BUILT_IN (fndecl) - && DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD) - switch (DECL_FUNCTION_CODE (fndecl)) - { - case BUILT_IN_CABS: - case BUILT_IN_CABSL: - case BUILT_IN_CABSF: - case BUILT_IN_EXP: - case BUILT_IN_EXPF: - case BUILT_IN_EXPL: - case BUILT_IN_FABS: - case BUILT_IN_FABSF: - case BUILT_IN_FABSL: - case BUILT_IN_SQRT: - case BUILT_IN_SQRTF: - case BUILT_IN_SQRTL: - return 1; - - case BUILT_IN_ATAN: - case BUILT_IN_ATANF: - case BUILT_IN_ATANL: - case BUILT_IN_CEIL: - case BUILT_IN_CEILF: - case BUILT_IN_CEILL: - case BUILT_IN_FLOOR: - case BUILT_IN_FLOORF: - case BUILT_IN_FLOORL: - case BUILT_IN_NEARBYINT: - case BUILT_IN_NEARBYINTF: - case BUILT_IN_NEARBYINTL: - case BUILT_IN_ROUND: - case BUILT_IN_ROUNDF: - case BUILT_IN_ROUNDL: - case BUILT_IN_TRUNC: - case BUILT_IN_TRUNCF: - case BUILT_IN_TRUNCL: - return tree_expr_nonnegative_p (TREE_VALUE (arglist)); - - case BUILT_IN_POW: - case BUILT_IN_POWF: - case BUILT_IN_POWL: - return tree_expr_nonnegative_p (TREE_VALUE (arglist)); + { + tree fndecl = get_callee_fndecl (t); + tree arglist = TREE_OPERAND (t, 1); + if (fndecl + && DECL_BUILT_IN (fndecl) + && DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD) + switch (DECL_FUNCTION_CODE (fndecl)) + { + case BUILT_IN_CABS: + case BUILT_IN_CABSL: + case BUILT_IN_CABSF: + case BUILT_IN_EXP: + case BUILT_IN_EXPF: + case BUILT_IN_EXPL: + case BUILT_IN_FABS: + case BUILT_IN_FABSF: + case BUILT_IN_FABSL: + case BUILT_IN_SQRT: + case BUILT_IN_SQRTF: + case BUILT_IN_SQRTL: + return 1; + + case BUILT_IN_ATAN: + case BUILT_IN_ATANF: + case BUILT_IN_ATANL: + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + case BUILT_IN_NEARBYINT: + case BUILT_IN_NEARBYINTF: + case BUILT_IN_NEARBYINTL: + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + return tree_expr_nonnegative_p (TREE_VALUE (arglist)); + + case BUILT_IN_POW: + case BUILT_IN_POWF: + case BUILT_IN_POWL: + return tree_expr_nonnegative_p (TREE_VALUE (arglist)); - default: - break; - } - } + default: + break; + } + } /* ... fall through ... */ -- 2.30.2