Commit 2f503025 by Jason Merrill Committed by Jason Merrill

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
parent 47d4c811
2003-08-20 Jason Merrill <jason@redhat.com> 2003-08-20 Jason Merrill <jason@redhat.com>
* 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 * stor-layout.c (do_type_align): Only copy DECL_USER_ALIGN from
TYPE_USER_ALIGN for FIELD_DECLs. TYPE_USER_ALIGN for FIELD_DECLs.
......
...@@ -1566,7 +1566,7 @@ expand_builtin_mathfn (tree exp, rtx target, rtx subtarget) ...@@ -1566,7 +1566,7 @@ expand_builtin_mathfn (tree exp, rtx target, rtx subtarget)
{ {
optab builtin_optab; optab builtin_optab;
rtx op0, insns; rtx op0, insns;
tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); tree fndecl = get_callee_fndecl (exp);
tree arglist = TREE_OPERAND (exp, 1); tree arglist = TREE_OPERAND (exp, 1);
enum machine_mode mode; enum machine_mode mode;
bool errno_set = false; bool errno_set = false;
...@@ -1695,7 +1695,7 @@ expand_builtin_mathfn_2 (tree exp, rtx target, rtx subtarget) ...@@ -1695,7 +1695,7 @@ expand_builtin_mathfn_2 (tree exp, rtx target, rtx subtarget)
{ {
optab builtin_optab; optab builtin_optab;
rtx op0, op1, insns; 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 arglist = TREE_OPERAND (exp, 1);
tree arg0, arg1, temp, narg; tree arg0, arg1, temp, narg;
enum machine_mode mode; enum machine_mode mode;
...@@ -4756,7 +4756,7 @@ rtx ...@@ -4756,7 +4756,7 @@ rtx
expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
int ignore) int ignore)
{ {
tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); tree fndecl = get_callee_fndecl (exp);
tree arglist = TREE_OPERAND (exp, 1); tree arglist = TREE_OPERAND (exp, 1);
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
enum machine_mode target_mode = TYPE_MODE (TREE_TYPE (exp)); enum machine_mode target_mode = TYPE_MODE (TREE_TYPE (exp));
...@@ -5301,8 +5301,8 @@ builtin_mathfn_code (tree t) ...@@ -5301,8 +5301,8 @@ builtin_mathfn_code (tree t)
|| TREE_CODE (TREE_OPERAND (t, 0)) != ADDR_EXPR) || TREE_CODE (TREE_OPERAND (t, 0)) != ADDR_EXPR)
return END_BUILTINS; return END_BUILTINS;
fndecl = TREE_OPERAND (TREE_OPERAND (t, 0), 0); fndecl = get_callee_fndecl (t);
if (TREE_CODE (fndecl) != FUNCTION_DECL if (fndecl == NULL_TREE
|| ! DECL_BUILT_IN (fndecl) || ! DECL_BUILT_IN (fndecl)
|| DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) || DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
return END_BUILTINS; return END_BUILTINS;
...@@ -5513,7 +5513,7 @@ integer_valued_real_p (tree t) ...@@ -5513,7 +5513,7 @@ integer_valued_real_p (tree t)
static tree static tree
fold_trunc_transparent_mathfn (tree exp) 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); tree arglist = TREE_OPERAND (exp, 1);
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
tree arg; tree arg;
...@@ -5732,7 +5732,7 @@ fold_builtin_ceil (tree exp) ...@@ -5732,7 +5732,7 @@ fold_builtin_ceil (tree exp)
tree tree
fold_builtin (tree exp) 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 arglist = TREE_OPERAND (exp, 1);
tree type = TREE_TYPE (TREE_TYPE (fndecl)); tree type = TREE_TYPE (TREE_TYPE (fndecl));
......
...@@ -530,27 +530,26 @@ do_jump (tree exp, rtx if_false_label, rtx if_true_label) ...@@ -530,27 +530,26 @@ do_jump (tree exp, rtx if_false_label, rtx if_true_label)
operation produced a 1 or 0. */ operation produced a 1 or 0. */
case CALL_EXPR: case CALL_EXPR:
/* Check for a built-in function. */ /* Check for a built-in function. */
if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR) {
{ tree fndecl = get_callee_fndecl (exp);
tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); tree arglist = TREE_OPERAND (exp, 1);
tree arglist = TREE_OPERAND (exp, 1);
if (fndecl
if (TREE_CODE (fndecl) == FUNCTION_DECL && DECL_BUILT_IN (fndecl)
&& DECL_BUILT_IN (fndecl) && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
&& DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT && arglist != NULL_TREE
&& arglist != NULL_TREE && TREE_CHAIN (arglist) != NULL_TREE)
&& TREE_CHAIN (arglist) != NULL_TREE) {
{ rtx seq = expand_builtin_expect_jump (exp, if_false_label,
rtx seq = expand_builtin_expect_jump (exp, if_false_label, if_true_label);
if_true_label);
if (seq != NULL_RTX)
if (seq != NULL_RTX) {
{ emit_insn (seq);
emit_insn (seq); return;
return; }
} }
} }
}
/* Fall through and generate the normal code. */ /* Fall through and generate the normal code. */
default: default:
......
...@@ -1837,6 +1837,8 @@ truth_value_p (enum tree_code code) ...@@ -1837,6 +1837,8 @@ truth_value_p (enum tree_code code)
int int
operand_equal_p (tree arg0, tree arg1, int only_const) 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 /* 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 them equal. We must check this before the STRIP_NOPS calls
because they may change the signedness of the arguments. */ because they may change the signedness of the arguments. */
...@@ -2007,13 +2009,9 @@ operand_equal_p (tree arg0, tree arg1, int only_const) ...@@ -2007,13 +2009,9 @@ operand_equal_p (tree arg0, tree arg1, int only_const)
return 0; return 0;
/* Only consider const functions equivalent. */ /* Only consider const functions equivalent. */
if (TREE_CODE (TREE_OPERAND (arg0, 0)) == ADDR_EXPR) fndecl = get_callee_fndecl (arg0);
{ if (fndecl == NULL_TREE
tree fndecl = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0); || ! (flags_from_decl_or_type (fndecl) & ECF_CONST))
if (! (flags_from_decl_or_type (fndecl) & ECF_CONST))
return 0;
}
else
return 0; return 0;
/* Now see if all the arguments are the same. operand_equal_p /* Now see if all the arguments are the same. operand_equal_p
...@@ -5481,7 +5479,7 @@ fold (tree expr) ...@@ -5481,7 +5479,7 @@ fold (tree expr)
{ {
tree fndecl, arg, arglist; 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 = TREE_VALUE (TREE_OPERAND (arg0, 1));
arg = fold (build1 (NEGATE_EXPR, type, arg)); arg = fold (build1 (NEGATE_EXPR, type, arg));
arglist = build_tree_list (NULL_TREE, arg); arglist = build_tree_list (NULL_TREE, arg);
...@@ -7622,13 +7620,12 @@ fold (tree expr) ...@@ -7622,13 +7620,12 @@ fold (tree expr)
due to the return value of strlen being unsigned. */ due to the return value of strlen being unsigned. */
if ((code == EQ_EXPR || code == NE_EXPR) if ((code == EQ_EXPR || code == NE_EXPR)
&& integer_zerop (arg1) && integer_zerop (arg1)
&& TREE_CODE (arg0) == CALL_EXPR && TREE_CODE (arg0) == CALL_EXPR)
&& TREE_CODE (TREE_OPERAND (arg0, 0)) == ADDR_EXPR)
{ {
tree fndecl = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0); tree fndecl = get_callee_fndecl (arg0);
tree arglist; tree arglist;
if (TREE_CODE (fndecl) == FUNCTION_DECL if (fndecl
&& DECL_BUILT_IN (fndecl) && DECL_BUILT_IN (fndecl)
&& DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD && DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD
&& DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRLEN && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRLEN
...@@ -8637,58 +8634,57 @@ tree_expr_nonnegative_p (tree t) ...@@ -8637,58 +8634,57 @@ tree_expr_nonnegative_p (tree t)
return rtl_expr_nonnegative_p (RTL_EXPR_RTL (t)); return rtl_expr_nonnegative_p (RTL_EXPR_RTL (t));
case CALL_EXPR: case CALL_EXPR:
if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR) {
{ tree fndecl = get_callee_fndecl (t);
tree fndecl = TREE_OPERAND (TREE_OPERAND (t, 0), 0); tree arglist = TREE_OPERAND (t, 1);
tree arglist = TREE_OPERAND (t, 1); if (fndecl
if (TREE_CODE (fndecl) == FUNCTION_DECL && DECL_BUILT_IN (fndecl)
&& DECL_BUILT_IN (fndecl) && DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD)
&& DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD) switch (DECL_FUNCTION_CODE (fndecl))
switch (DECL_FUNCTION_CODE (fndecl)) {
{ case BUILT_IN_CABS:
case BUILT_IN_CABS: case BUILT_IN_CABSL:
case BUILT_IN_CABSL: case BUILT_IN_CABSF:
case BUILT_IN_CABSF: case BUILT_IN_EXP:
case BUILT_IN_EXP: case BUILT_IN_EXPF:
case BUILT_IN_EXPF: case BUILT_IN_EXPL:
case BUILT_IN_EXPL: case BUILT_IN_FABS:
case BUILT_IN_FABS: case BUILT_IN_FABSF:
case BUILT_IN_FABSF: case BUILT_IN_FABSL:
case BUILT_IN_FABSL: case BUILT_IN_SQRT:
case BUILT_IN_SQRT: case BUILT_IN_SQRTF:
case BUILT_IN_SQRTF: case BUILT_IN_SQRTL:
case BUILT_IN_SQRTL: return 1;
return 1;
case BUILT_IN_ATAN:
case BUILT_IN_ATAN: case BUILT_IN_ATANF:
case BUILT_IN_ATANF: case BUILT_IN_ATANL:
case BUILT_IN_ATANL: case BUILT_IN_CEIL:
case BUILT_IN_CEIL: case BUILT_IN_CEILF:
case BUILT_IN_CEILF: case BUILT_IN_CEILL:
case BUILT_IN_CEILL: case BUILT_IN_FLOOR:
case BUILT_IN_FLOOR: case BUILT_IN_FLOORF:
case BUILT_IN_FLOORF: case BUILT_IN_FLOORL:
case BUILT_IN_FLOORL: case BUILT_IN_NEARBYINT:
case BUILT_IN_NEARBYINT: case BUILT_IN_NEARBYINTF:
case BUILT_IN_NEARBYINTF: case BUILT_IN_NEARBYINTL:
case BUILT_IN_NEARBYINTL: case BUILT_IN_ROUND:
case BUILT_IN_ROUND: case BUILT_IN_ROUNDF:
case BUILT_IN_ROUNDF: case BUILT_IN_ROUNDL:
case BUILT_IN_ROUNDL: case BUILT_IN_TRUNC:
case BUILT_IN_TRUNC: case BUILT_IN_TRUNCF:
case BUILT_IN_TRUNCF: case BUILT_IN_TRUNCL:
case BUILT_IN_TRUNCL: return tree_expr_nonnegative_p (TREE_VALUE (arglist));
return tree_expr_nonnegative_p (TREE_VALUE (arglist));
case BUILT_IN_POW:
case BUILT_IN_POW: case BUILT_IN_POWF:
case BUILT_IN_POWF: case BUILT_IN_POWL:
case BUILT_IN_POWL: return tree_expr_nonnegative_p (TREE_VALUE (arglist));
return tree_expr_nonnegative_p (TREE_VALUE (arglist));
default: default:
break; break;
} }
} }
/* ... fall through ... */ /* ... fall through ... */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment