{
if (integer_zerop (expr))
{
- expr = build_int_2 (0, 0);
- TREE_TYPE (expr) = type;
+ expr = build_int_cst (type, 0, 0);
return expr;
}
return build_real (type, real_value_truncate (TYPE_MODE (type), orig));
}
- if (TREE_CODE (exp) != NOP_EXPR)
+ if (TREE_CODE (exp) != NOP_EXPR
+ && TREE_CODE (exp) != CONVERT_EXPR)
return exp;
sub = TREE_OPERAND (exp, 0);
newtype = TREE_TYPE (arg1);
if (TYPE_PRECISION (newtype) < TYPE_PRECISION (itype))
{
- expr = build (TREE_CODE (expr), newtype,
- fold (convert_to_real (newtype, arg0)),
- fold (convert_to_real (newtype, arg1)));
+ expr = build2 (TREE_CODE (expr), newtype,
+ fold (convert_to_real (newtype, arg0)),
+ fold (convert_to_real (newtype, arg1)));
if (newtype == type)
return expr;
}
/* If the original expression had side-effects, we must
preserve it. */
if (TREE_SIDE_EFFECTS (expr))
- return build (COMPOUND_EXPR, type, expr, t);
+ return build2 (COMPOUND_EXPR, type, expr, t);
else
return t;
}
else
typex = lang_hooks.types.signed_type (typex);
return convert (type,
- fold (build (ex_form, typex,
- convert (typex, arg0),
- convert (typex, arg1))));
+ fold (build2 (ex_form, typex,
+ convert (typex, arg0),
+ convert (typex, arg1))));
}
}
}
case COND_EXPR:
/* It is sometimes worthwhile to push the narrowing down through
the conditional and never loses. */
- return fold (build (COND_EXPR, type, TREE_OPERAND (expr, 0),
- convert (type, TREE_OPERAND (expr, 1)),
- convert (type, TREE_OPERAND (expr, 2))));
+ return fold (build3 (COND_EXPR, type, TREE_OPERAND (expr, 0),
+ convert (type, TREE_OPERAND (expr, 1)),
+ convert (type, TREE_OPERAND (expr, 2))));
default:
break;
TREE_TYPE (TREE_TYPE (expr)), expr)));
case VECTOR_TYPE:
- if (GET_MODE_SIZE (TYPE_MODE (type))
- != GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr))))
+ if (!tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (expr))))
{
error ("can't convert between vector values of different size");
return error_mark_node;
case ENUMERAL_TYPE:
case BOOLEAN_TYPE:
case CHAR_TYPE:
- return build (COMPLEX_EXPR, type, convert (subtype, expr),
- convert (subtype, integer_zero_node));
+ return build2 (COMPLEX_EXPR, type, convert (subtype, expr),
+ convert (subtype, integer_zero_node));
case COMPLEX_TYPE:
{
if (TYPE_MAIN_VARIANT (elt_type) == TYPE_MAIN_VARIANT (subtype))
return expr;
else if (TREE_CODE (expr) == COMPLEX_EXPR)
- return fold (build (COMPLEX_EXPR,
- type,
- convert (subtype, TREE_OPERAND (expr, 0)),
- convert (subtype, TREE_OPERAND (expr, 1))));
+ return fold (build2 (COMPLEX_EXPR, type,
+ convert (subtype, TREE_OPERAND (expr, 0)),
+ convert (subtype, TREE_OPERAND (expr, 1))));
else
{
expr = save_expr (expr);
return
- fold (build (COMPLEX_EXPR,
- type, convert (subtype,
- fold (build1 (REALPART_EXPR,
- TREE_TYPE (TREE_TYPE (expr)),
- expr))),
- convert (subtype,
- fold (build1 (IMAGPART_EXPR,
- TREE_TYPE (TREE_TYPE (expr)),
- expr)))));
+ fold (build2 (COMPLEX_EXPR, type,
+ convert (subtype,
+ fold (build1 (REALPART_EXPR,
+ TREE_TYPE (TREE_TYPE (expr)),
+ expr))),
+ convert (subtype,
+ fold (build1 (IMAGPART_EXPR,
+ TREE_TYPE (TREE_TYPE (expr)),
+ expr)))));
}
}
{
case INTEGER_TYPE:
case VECTOR_TYPE:
- if (GET_MODE_SIZE (TYPE_MODE (type))
- != GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr))))
+ if (!tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (expr))))
{
error ("can't convert between vector values of different size");
return error_mark_node;