+2004-05-21 Roger Sayle <roger@eyesopen.com>
+
+ * fold-const.c (fold, fold_relational_hi_lo,
+ nondestructive_fold_binary_to_constant,
+ fold_read_from_constant_string): Use fold_convert instead of convert.
+ * builtins.c (simplify_builtin, simplify_builtin_strstr,
+ simplify_builtin_strchr, simplify_builtin_strrchr,
+ simplify_builtin_strpbrk): Use fold_convert instead of convert.
+
2004-05-21 Diego Novillo <dnovillo@redhat.com>
* tree-flow-inline.h (num_immediate_uses): Don't abort if DF
}
if (val)
- val = convert (TREE_TYPE (exp), val);
+ val = fold_convert (TREE_TYPE (exp), val);
return val;
}
{
const char *r = strstr (p1, p2);
- /* Return an offset into the constant string argument. */
if (r == NULL)
- return integer_zero_node;
- else
- return fold (build (PLUS_EXPR, TREE_TYPE (s1),
- s1, convert (TREE_TYPE (s1),
- ssize_int (r - p1))));
+ return fold_convert (TREE_TYPE (s1), integer_zero_node);
+
+ /* Return an offset into the constant string argument. */
+ return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
+ s1, fold_convert (TREE_TYPE (s1),
+ ssize_int (r - p1))));
}
if (p2[0] == '\0')
r = strchr (p1, c);
if (r == NULL)
- return integer_zero_node;
+ return fold_convert (TREE_TYPE (s1), integer_zero_node);
/* Return an offset into the constant string argument. */
return fold (build (PLUS_EXPR, TREE_TYPE (s1),
- s1, convert (TREE_TYPE (s1),
- ssize_int (r - p1))));
+ s1, fold_convert (TREE_TYPE (s1),
+ ssize_int (r - p1))));
}
/* FIXME: Should use here strchrM optab so that ports can optimize
r = strrchr (p1, c);
if (r == NULL)
- return integer_zero_node;
+ return fold_convert (TREE_TYPE (s1), integer_zero_node);
/* Return an offset into the constant string argument. */
return fold (build (PLUS_EXPR, TREE_TYPE (s1),
- s1, convert (TREE_TYPE (s1),
- ssize_int (r - p1))));
+ s1, fold_convert (TREE_TYPE (s1),
+ ssize_int (r - p1))));
}
if (! integer_zerop (s2))
const char *r = strpbrk (p1, p2);
if (r == NULL)
- return integer_zero_node;
+ return fold_convert (TREE_TYPE (s1), integer_zero_node);
/* Return an offset into the constant string argument. */
return fold (build (PLUS_EXPR, TREE_TYPE (s1),
- s1, convert (TREE_TYPE (s1),
- ssize_int (r - p1))));
+ s1, fold_convert (TREE_TYPE (s1),
+ ssize_int (r - p1))));
}
if (p2[0] == '\0')
tree s1 = TYPE_SIZE (tt1);
if (s0 && s1 && operand_equal_p (s0, s1, OEP_ONLY_CONST))
- return build2 (TREE_CODE (arg0), t0, convert (t0, arg00),
+ return build2 (TREE_CODE (arg0), t0, fold_convert (t0, arg00),
TREE_OPERAND (arg0, 1));
}
{
case GT_EXPR:
return omit_one_operand (type,
- convert (type, integer_zero_node),
+ fold_convert (type, integer_zero_node),
op0);
case GE_EXPR:
*code_p = EQ_EXPR;
break;
case LE_EXPR:
return omit_one_operand (type,
- convert (type, integer_one_node),
+ fold_convert (type, integer_one_node),
op0);
case LT_EXPR:
*code_p = NE_EXPR;
{
case LT_EXPR:
return omit_one_operand (type,
- convert (type, integer_zero_node),
+ fold_convert (type, integer_zero_node),
op0);
case LE_EXPR:
*code_p = EQ_EXPR;
case GE_EXPR:
return omit_one_operand (type,
- convert (type, integer_one_node),
+ fold_convert (type, integer_one_node),
op0);
case GT_EXPR:
*code_p = NE_EXPR;
exp = build2 (code == LE_EXPR ? GE_EXPR: LT_EXPR,
type,
- convert (st0, op0),
- convert (st1, integer_zero_node));
+ fold_convert (st0, op0),
+ fold_convert (st1, integer_zero_node));
retval
= nondestructive_fold_binary_to_constant (TREE_CODE (exp),
/* The return value should always have the same type as
the original expression. */
if (TREE_TYPE (tem) != type)
- tem = convert (type, tem);
+ tem = fold_convert (type, tem);
return tem;
}
Also note that operand_equal_p is always false if an
operand is volatile. */
if (! FLOAT_TYPE_P (type) && operand_equal_p (op0, op1, 0))
- return convert (type, integer_zero_node);
+ return fold_convert (type, integer_zero_node);
goto binary;
{
tree domain = TYPE_DOMAIN (TREE_TYPE (exp1));
tree low_bound = domain ? TYPE_MIN_VALUE (domain) : integer_zero_node;
- index = convert (sizetype, TREE_OPERAND (exp, 1));
+ index = fold_convert (sizetype, TREE_OPERAND (exp, 1));
/* Optimize the special-case of a zero lower bound.
+(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1))
+INDEX), which becomes (ARRAY+255+INDEX). Opps!) */
if (! integer_zerop (low_bound))
- index = size_diffop (index, convert (sizetype, low_bound));
+ index = size_diffop (index, fold_convert (sizetype, low_bound));
string = exp1;
}