aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@codesourcery.com>2010-11-03 00:49:00 +0000
committerNathan Froyd <froydnj@gcc.gnu.org>2010-11-03 00:49:00 +0000
commite8160c9a604ed01f38060655561a8fdf8ef854c8 (patch)
treeaa2d2827a0f82adc2311c64a062ea2a424f865c4 /gcc/tree.c
parent7d1c5d3530bcea4099af22a346315c70e62a9b25 (diff)
downloadgcc-e8160c9a604ed01f38060655561a8fdf8ef854c8.zip
gcc-e8160c9a604ed01f38060655561a8fdf8ef854c8.tar.gz
gcc-e8160c9a604ed01f38060655561a8fdf8ef854c8.tar.bz2
builtins.c (fold_builtin_signbit): Use build_zero_cst instead of fold_convert.
gcc/ * builtins.c (fold_builtin_signbit): Use build_zero_cst instead of fold_convert. * c-typeck.c (build_function_call_vec): Likewise. * cfgexpand.c (expand_debug_expr): Likewise. * cgraphunit.c (assemble_thunk): Likewise. * config/sparc/sparc.c (sparc_fold_builtin): Likewise. * fold-const.c (fold_unary_loc, fold_mult_zconjz): Likewise. (fold_binary_loc, fold_ternary_loc): Likewise. * gimple-fold.c (get_symbol_constant_value): Likewise. * gimple-low.c (lower_builtin_setjmp): Likewise. * gimple.c (gimple_cond_get_ops_from_tree): Likewise. * gimplify.c (gimplify_init_constructor): Likewise. * lambda.h (build_linear_expr): Likewise. * omp-low.c (omp_reduction_init): Likewise. * tree-inline.c (remap_ssa_name): Likewise. * tree-object-size.c (compute_object_sizes): Likewise. * tree-sra.c (init_subtree_with_zero): Likewise. (sra_ipa_modify_assign): Likewise. * tree-ssa-copy.c (propagate_tree_value_into_stmt): Likewise. * tree-ssa-reassoc.c (eliminate_duplicate_pair): Likewise. (eliminate_plus_minus_pair, eliminate_not_pairs): Likewise. (undistribute_ops_list): Likewise. * tree-ssa-sccvn.c (vn_reference_lookup_3): Likewise. * tree-vect-stmts.c (vectorizable_call): Likewise. * tree.c (build_vector_from_ctor, build_one_cst): Likewise. (build_zero_cst): Handle more cases directly. Update comment. gcc/cp/ * class.c (build_base_path, add_vcall_offset): Use build_zero_cst instead of fold_convert. * init.c (build_zero_init): Likewise. * typeck.c (cp_build_binary_op): Likewise. gcc/fortran/ * trans-decl.c (add_argument_checking): Use build_zero_cst instead of fold_convert. * trans-expr.c (gfc_conv_missing_dummy, fill_with_spaces): Likewise. * trans-stmt.c (gfc_trans_do): Likewise. From-SVN: r166227
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 1cc99f0..4a27fd2 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1362,7 +1362,7 @@ build_vector_from_ctor (tree type, VEC(constructor_elt,gc) *v)
list = tree_cons (NULL_TREE, value, list);
for (; idx < TYPE_VECTOR_SUBPARTS (type); ++idx)
list = tree_cons (NULL_TREE,
- fold_convert (TREE_TYPE (type), integer_zero_node), list);
+ build_zero_cst (TREE_TYPE (type)), list);
return build_vector (type, nreverse (list));
}
@@ -1599,22 +1599,52 @@ build_one_cst (tree type)
case COMPLEX_TYPE:
return build_complex (type,
build_one_cst (TREE_TYPE (type)),
- fold_convert (TREE_TYPE (type), integer_zero_node));
+ build_zero_cst (TREE_TYPE (type)));
default:
gcc_unreachable ();
}
}
-/* Build 0 constant of type TYPE. This is used by constructor folding and thus
- the constant should correspond zero in memory representation. */
+/* Build 0 constant of type TYPE. This is used by constructor folding
+ and thus the constant should be represented in memory by
+ zero(es). */
tree
build_zero_cst (tree type)
{
- if (!AGGREGATE_TYPE_P (type))
- return fold_convert (type, integer_zero_node);
- return build_constructor (type, NULL);
+ switch (TREE_CODE (type))
+ {
+ case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
+ case POINTER_TYPE: case REFERENCE_TYPE:
+ case OFFSET_TYPE:
+ return build_int_cst (type, 0);
+
+ case REAL_TYPE:
+ return build_real (type, dconst0);
+
+ case FIXED_POINT_TYPE:
+ return build_fixed (type, FCONST0 (TYPE_MODE (type)));
+
+ case VECTOR_TYPE:
+ {
+ tree scalar = build_zero_cst (TREE_TYPE (type));
+
+ return build_vector_from_val (type, scalar);
+ }
+
+ case COMPLEX_TYPE:
+ {
+ tree zero = build_zero_cst (TREE_TYPE (type));
+
+ return build_complex (type, zero, zero);
+ }
+
+ default:
+ if (!AGGREGATE_TYPE_P (type))
+ return fold_convert (type, integer_zero_node);
+ return build_constructor (type, NULL);
+ }
}