+2010-11-02 Nathan Froyd <froydnj@codesourcery.com>
+
+ * 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.
+
2010-11-02 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/i386-protos.h (ix86_split_call_pop_vzeroupper):
static tree
fold_builtin_signbit (location_t loc, tree arg, tree type)
{
- tree temp;
-
if (!validate_arg (arg, REAL_TYPE))
return NULL_TREE;
REAL_VALUE_TYPE c;
c = TREE_REAL_CST (arg);
- temp = REAL_VALUE_NEGATIVE (c) ? integer_one_node : integer_zero_node;
- return fold_convert_loc (loc, type, temp);
+ return (REAL_VALUE_NEGATIVE (c)
+ ? build_one_cst (type)
+ : build_zero_cst (type));
}
/* If ARG is non-negative, the result is always zero. */
build_constructor (return_type, 0),
false);
else
- rhs = fold_convert_loc (loc, return_type, integer_zero_node);
+ rhs = build_zero_cst (return_type);
return require_complete_type (build2 (COMPOUND_EXPR, return_type,
trap, rhs));
if (i < TYPE_VECTOR_SUBPARTS (TREE_TYPE (exp)))
{
op1 = expand_debug_expr
- (fold_convert (TREE_TYPE (TREE_TYPE (exp)), integer_zero_node));
+ (build_zero_cst (TREE_TYPE (TREE_TYPE (exp))));
if (!op1)
return NULL;
remove_edge (single_succ_edge (bb));
true_label = gimple_block_label (then_bb);
stmt = gimple_build_cond (NE_EXPR, restmp,
- fold_convert (TREE_TYPE (restmp),
- integer_zero_node),
+ build_zero_cst (TREE_TYPE (restmp)),
NULL_TREE, NULL_TREE);
gsi_insert_after (&bsi, stmt, GSI_NEW_STMT);
make_edge (bb, then_bb, EDGE_TRUE_VALUE);
{
gimple stmt;
bsi = gsi_last_bb (else_bb);
- stmt = gimple_build_assign (restmp, fold_convert (TREE_TYPE (restmp),
- integer_zero_node));
+ stmt = gimple_build_assign (restmp,
+ build_zero_cst (TREE_TYPE (restmp)));
gsi_insert_after (&bsi, stmt, GSI_NEW_STMT);
bsi = gsi_last_bb (return_bb);
}
if (ignore
&& icode != CODE_FOR_alignaddrsi_vis
&& icode != CODE_FOR_alignaddrdi_vis)
- return fold_convert (rtype, integer_zero_node);
+ return build_zero_cst (rtype);
switch (icode)
{
+2010-11-02 Nathan Froyd <froydnj@codesourcery.com>
+
+ * 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.
+
2010-11-02 Dodji Seketeli <dodji@redhat.com>
PR c++/46170
out:
if (null_test)
expr = fold_build3_loc (input_location, COND_EXPR, target_type, null_test, expr,
- fold_build1_loc (input_location, NOP_EXPR, target_type,
- integer_zero_node));
+ build_zero_cst (target_type));
return expr;
}
/* Find the overriding function. */
fn = find_final_overrider (vid->rtti_binfo, binfo, orig_fn);
if (fn == error_mark_node)
- vcall_offset = build1 (NOP_EXPR, vtable_entry_type,
- integer_zero_node);
+ vcall_offset = build_zero_cst (vtable_entry_type);
else
{
base = TREE_VALUE (fn);
init = build_constructor (type, v);
}
else if (TREE_CODE (type) == VECTOR_TYPE)
- init = fold_convert (type, integer_zero_node);
+ init = build_zero_cst (type);
else
gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);
tree e1 = cp_build_binary_op (location,
EQ_EXPR,
pfn0,
- fold_convert (TREE_TYPE (pfn0),
- integer_zero_node),
+ build_zero_cst (TREE_TYPE (pfn0)),
complain);
tree e2 = cp_build_binary_op (location,
BIT_AND_EXPR,
complain);
e2 = cp_build_binary_op (location, EQ_EXPR,
pfn0,
- fold_convert (TREE_TYPE (pfn0),
- integer_zero_node),
+ build_zero_cst (TREE_TYPE (pfn0)),
complain);
e2 = cp_build_binary_op (location,
TRUTH_ANDIF_EXPR, e2, e1, complain);
e2 = cp_build_binary_op (location,
EQ_EXPR,
pfn0,
- fold_convert (TREE_TYPE (pfn0),
- integer_zero_node),
+ build_zero_cst (TREE_TYPE (pfn0)),
complain);
e1 = cp_build_binary_op (location,
TRUTH_ORIF_EXPR, e1, e2, complain);
case IMAGPART_EXPR:
if (TREE_CODE (TREE_TYPE (arg0)) != COMPLEX_TYPE)
- return fold_convert_loc (loc, type, integer_zero_node);
+ return build_zero_cst (type);
if (TREE_CODE (arg0) == COMPLEX_EXPR)
return omit_one_operand_loc (loc, type, TREE_OPERAND (arg0, 1),
TREE_OPERAND (arg0, 0));
fold_build2_loc (loc, MULT_EXPR, itype, rpart, rpart),
fold_build2_loc (loc, MULT_EXPR, itype, ipart, ipart));
return fold_build2_loc (loc, COMPLEX_EXPR, type, tem,
- fold_convert_loc (loc, itype, integer_zero_node));
+ build_zero_cst (itype));
}
if ((!FLOAT_TYPE_P (type) || !HONOR_NANS (TYPE_MODE (type)))
&& operand_equal_p (arg0, arg1, 0))
- return fold_convert_loc (loc, type, integer_zero_node);
+ return build_zero_cst (type);
/* A - B -> A + (-B) if B is easily negatable. */
if (negate_expr_p (arg1)
if (TREE_CODE (arg0) == BIT_NOT_EXPR
&& operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0))
{
- t1 = fold_convert_loc (loc, type, integer_zero_node);
+ t1 = build_zero_cst (type);
t1 = fold_unary_loc (loc, BIT_NOT_EXPR, type, t1);
return omit_one_operand_loc (loc, type, t1, arg1);
}
if (TREE_CODE (arg1) == BIT_NOT_EXPR
&& operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0))
{
- t1 = fold_convert_loc (loc, type, integer_zero_node);
+ t1 = build_zero_cst (type);
t1 = fold_unary_loc (loc, BIT_NOT_EXPR, type, t1);
return omit_one_operand_loc (loc, type, t1, arg0);
}
if (TREE_CODE (arg0) == BIT_NOT_EXPR
&& operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0))
{
- t1 = fold_convert_loc (loc, type, integer_zero_node);
+ t1 = build_zero_cst (type);
t1 = fold_unary_loc (loc, BIT_NOT_EXPR, type, t1);
return omit_one_operand_loc (loc, type, t1, arg1);
}
if (TREE_CODE (arg1) == BIT_NOT_EXPR
&& operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0))
{
- t1 = fold_convert_loc (loc, type, integer_zero_node);
+ t1 = build_zero_cst (type);
t1 = fold_unary_loc (loc, BIT_NOT_EXPR, type, t1);
return omit_one_operand_loc (loc, type, t1, arg0);
}
if (elements)
return TREE_VALUE (elements);
else
- return fold_convert_loc (loc, type, integer_zero_node);
+ return build_zero_cst (type);
}
}
+2010-11-02 Nathan Froyd <froydnj@codesourcery.com>
+
+ * 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.
+
2010-11-02 Steven G. Kargl < kargl@gcc.gnu.org>
Tobias Burnus <burnus@net-b.de>
not_0length = fold_build2_loc (input_location, NE_EXPR,
boolean_type_node,
cl->passed_length,
- fold_convert (gfc_charlen_type_node,
- integer_zero_node));
+ build_zero_cst (gfc_charlen_type_node));
/* The symbol needs to be referenced for gfc_get_symbol_decl. */
fsym->attr.referenced = 1;
not_absent = gfc_conv_expr_present (fsym);
{
tmp = build3_loc (input_location, COND_EXPR, TREE_TYPE (se->expr),
present, se->expr,
- fold_convert (TREE_TYPE (se->expr), integer_zero_node));
+ build_zero_cst (TREE_TYPE (se->expr)));
tmp = gfc_evaluate_now (tmp, &se->pre);
se->expr = tmp;
}
/* Exit condition. */
cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, i,
- fold_convert (sizetype, integer_zero_node));
+ build_zero_cst (sizetype));
tmp = build1_v (GOTO_EXPR, exit_label);
tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, tmp,
build_empty_stmt (input_location));
if (gfc_option.rtcheck & GFC_RTCHECK_DO)
{
tmp = fold_build2_loc (input_location, EQ_EXPR, boolean_type_node, step,
- fold_convert (type, integer_zero_node));
+ build_zero_cst (type));
gfc_trans_runtime_check (true, false, tmp, &block, &code->loc,
"DO step value is zero");
}
return gfc_trans_simple_do (code, &block, dovar, from, to, step, exit_cond);
pos_step = fold_build2_loc (loc, GT_EXPR, boolean_type_node, step,
- fold_convert (type, integer_zero_node));
+ build_zero_cst (type));
if (TREE_CODE (type) == INTEGER_TYPE)
utype = unsigned_type_for (type);
if (!val
&& (INTEGRAL_TYPE_P (TREE_TYPE (sym))
|| SCALAR_FLOAT_TYPE_P (TREE_TYPE (sym))))
- return fold_convert (TREE_TYPE (sym), integer_zero_node);
+ return build_zero_cst (TREE_TYPE (sym));
}
return NULL_TREE;
/* Build 'DEST = 0' and insert. */
if (dest)
{
- g = gimple_build_assign (dest, fold_convert_loc (loc, TREE_TYPE (dest),
- integer_zero_node));
+ g = gimple_build_assign (dest, build_zero_cst (TREE_TYPE (dest)));
gimple_set_location (g, loc);
gimple_set_block (g, gimple_block (stmt));
gsi_insert_before (gsi, g, GSI_SAME_STMT);
gimple_cond_get_ops_from_tree (tree cond, enum tree_code *code_p,
tree *lhs_p, tree *rhs_p)
{
- location_t loc = EXPR_LOCATION (cond);
gcc_assert (TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison
|| TREE_CODE (cond) == TRUTH_NOT_EXPR
|| is_gimple_min_invariant (cond)
{
*code_p = EQ_EXPR;
gcc_assert (*lhs_p && *rhs_p == NULL_TREE);
- *rhs_p = fold_convert_loc (loc, TREE_TYPE (*lhs_p), integer_zero_node);
+ *rhs_p = build_zero_cst (TREE_TYPE (*lhs_p));
}
/* Canonicalize conditionals of the form 'if (VAL)' */
else if (TREE_CODE_CLASS (*code_p) != tcc_comparison)
{
*code_p = NE_EXPR;
gcc_assert (*lhs_p && *rhs_p == NULL_TREE);
- *rhs_p = fold_convert_loc (loc, TREE_TYPE (*lhs_p), integer_zero_node);
+ *rhs_p = build_zero_cst (TREE_TYPE (*lhs_p));
}
}
i = VEC_index (constructor_elt, elts, 1)->value;
if (r == NULL || i == NULL)
{
- tree zero = fold_convert (TREE_TYPE (type), integer_zero_node);
+ tree zero = build_zero_cst (TREE_TYPE (type));
if (r == NULL)
r = zero;
if (i == NULL)
{
unsigned i;
tree iv;
- tree expr = fold_convert (type, integer_zero_node);
+ tree expr = build_zero_cst (type);
for (i = 0; VEC_iterate (tree, ivs, i, iv); i++)
{
case TRUTH_ORIF_EXPR:
case TRUTH_XOR_EXPR:
case NE_EXPR:
- return fold_convert_loc (loc, type, integer_zero_node);
+ return build_zero_cst (type);
case MULT_EXPR:
case TRUTH_AND_EXPR:
{
gimple_stmt_iterator gsi = gsi_last_bb (id->entry_bb);
gimple init_stmt;
+ tree zero = build_zero_cst (TREE_TYPE (new_tree));
- init_stmt = gimple_build_assign (new_tree,
- fold_convert (TREE_TYPE (new_tree),
- integer_zero_node));
+ init_stmt = gimple_build_assign (new_tree, zero);
gsi_insert_after (&gsi, init_stmt, GSI_NEW_STMT);
SSA_NAME_IS_DEFAULT_DEF (new_tree) = 0;
}
result = fold_convert (size_type_node,
integer_minus_one_node);
else if (object_size_type < 4)
- result = fold_convert (size_type_node,
- integer_zero_node);
+ result = build_zero_cst (size_type_node);
}
}
gimple stmt;
stmt = gimple_build_assign (get_access_replacement (access),
- fold_convert (access->type,
- integer_zero_node));
+ build_zero_cst (access->type));
if (insert_after)
gsi_insert_after (gsi, stmt, GSI_NEW_STMT);
else
{
/* V_C_Es of constructors can cause trouble (PR 42714). */
if (is_gimple_reg_type (TREE_TYPE (*lhs_p)))
- *rhs_p = fold_convert (TREE_TYPE (*lhs_p), integer_zero_node);
+ *rhs_p = build_zero_cst (TREE_TYPE (*lhs_p));
else
*rhs_p = build_constructor (TREE_TYPE (*lhs_p), 0);
}
else if (gimple_code (stmt) == GIMPLE_COND)
{
tree lhs = NULL_TREE;
- tree rhs = fold_convert (TREE_TYPE (val), integer_zero_node);
+ tree rhs = build_zero_cst (TREE_TYPE (val));
propagate_tree_value (&lhs, val);
gimple_cond_set_code (stmt, NE_EXPR);
gimple_cond_set_lhs (stmt, lhs);
{
VEC_free (operand_entry_t, heap, *ops);
*ops = NULL;
- add_to_ops_vec (ops, fold_convert (TREE_TYPE (last->op),
- integer_zero_node));
+ add_to_ops_vec (ops, build_zero_cst (TREE_TYPE (last->op)));
*all_done = true;
}
else
}
VEC_ordered_remove (operand_entry_t, *ops, i);
- add_to_ops_vec (ops, fold_convert(TREE_TYPE (oe->op),
- integer_zero_node));
+ add_to_ops_vec (ops, build_zero_cst (TREE_TYPE (oe->op)));
VEC_ordered_remove (operand_entry_t, *ops, currindex);
reassociate_stats.ops_eliminated ++;
}
if (opcode == BIT_AND_EXPR)
- oe->op = fold_convert (TREE_TYPE (oe->op), integer_zero_node);
+ oe->op = build_zero_cst (TREE_TYPE (oe->op));
else if (opcode == BIT_IOR_EXPR)
oe->op = build_low_bits_mask (TREE_TYPE (oe->op),
TYPE_PRECISION (TREE_TYPE (oe->op)));
}
zero_one_operation (&oe2->op, c->oecode, c->op);
sum = build_and_add_sum (tmpvar, oe1->op, oe2->op, opcode);
- oe2->op = fold_convert (TREE_TYPE (oe2->op), integer_zero_node);
+ oe2->op = build_zero_cst (TREE_TYPE (oe2->op));
oe2->rank = 0;
oe1->op = gimple_get_lhs (sum);
}
&& offset2 <= offset
&& offset2 + size2 >= offset + maxsize)
{
- tree val = fold_convert (vr->type, integer_zero_node);
+ tree val = build_zero_cst (vr->type);
unsigned int value_id = get_or_alloc_constant_value_id (val);
return vn_reference_insert_pieces (vuse, vr->set, vr->type,
VEC_copy (vn_reference_op_s,
&& offset2 <= offset
&& offset2 + size2 >= offset + maxsize)
{
- tree val = fold_convert (vr->type, integer_zero_node);
+ tree val = build_zero_cst (vr->type);
unsigned int value_id = get_or_alloc_constant_value_id (val);
return vn_reference_insert_pieces (vuse, vr->set, vr->type,
VEC_copy (vn_reference_op_s,
type = TREE_TYPE (scalar_dest);
new_stmt = gimple_build_assign (gimple_call_lhs (stmt),
- fold_convert (type, integer_zero_node));
+ build_zero_cst (type));
set_vinfo_for_stmt (new_stmt, stmt_info);
set_vinfo_for_stmt (stmt, NULL);
STMT_VINFO_STMT (stmt_info) = new_stmt;
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));
}
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);
+ }
}