Commit b953ebd6 by Roger Sayle Committed by Roger Sayle

fold-const.c (fold, [...]): Use fold_convert instead of convert.


	* 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.

From-SVN: r82102
parent 17abdabc
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> 2004-05-21 Diego Novillo <dnovillo@redhat.com>
* tree-flow-inline.h (num_immediate_uses): Don't abort if DF * tree-flow-inline.h (num_immediate_uses): Don't abort if DF
......
...@@ -8020,7 +8020,7 @@ simplify_builtin (tree exp, int ignore) ...@@ -8020,7 +8020,7 @@ simplify_builtin (tree exp, int ignore)
} }
if (val) if (val)
val = convert (TREE_TYPE (exp), val); val = fold_convert (TREE_TYPE (exp), val);
return val; return val;
} }
...@@ -8061,13 +8061,13 @@ simplify_builtin_strstr (tree arglist) ...@@ -8061,13 +8061,13 @@ simplify_builtin_strstr (tree arglist)
{ {
const char *r = strstr (p1, p2); const char *r = strstr (p1, p2);
/* Return an offset into the constant string argument. */
if (r == NULL) if (r == NULL)
return integer_zero_node; return fold_convert (TREE_TYPE (s1), integer_zero_node);
else
return fold (build (PLUS_EXPR, TREE_TYPE (s1), /* Return an offset into the constant string argument. */
s1, convert (TREE_TYPE (s1), return fold (build2 (PLUS_EXPR, TREE_TYPE (s1),
ssize_int (r - p1)))); s1, fold_convert (TREE_TYPE (s1),
ssize_int (r - p1))));
} }
if (p2[0] == '\0') if (p2[0] == '\0')
...@@ -8130,12 +8130,12 @@ simplify_builtin_strchr (tree arglist) ...@@ -8130,12 +8130,12 @@ simplify_builtin_strchr (tree arglist)
r = strchr (p1, c); r = strchr (p1, c);
if (r == NULL) 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 an offset into the constant string argument. */
return fold (build (PLUS_EXPR, TREE_TYPE (s1), return fold (build (PLUS_EXPR, TREE_TYPE (s1),
s1, convert (TREE_TYPE (s1), s1, fold_convert (TREE_TYPE (s1),
ssize_int (r - p1)))); ssize_int (r - p1))));
} }
/* FIXME: Should use here strchrM optab so that ports can optimize /* FIXME: Should use here strchrM optab so that ports can optimize
...@@ -8187,12 +8187,12 @@ simplify_builtin_strrchr (tree arglist) ...@@ -8187,12 +8187,12 @@ simplify_builtin_strrchr (tree arglist)
r = strrchr (p1, c); r = strrchr (p1, c);
if (r == NULL) 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 an offset into the constant string argument. */
return fold (build (PLUS_EXPR, TREE_TYPE (s1), return fold (build (PLUS_EXPR, TREE_TYPE (s1),
s1, convert (TREE_TYPE (s1), s1, fold_convert (TREE_TYPE (s1),
ssize_int (r - p1)))); ssize_int (r - p1))));
} }
if (! integer_zerop (s2)) if (! integer_zerop (s2))
...@@ -8245,12 +8245,12 @@ simplify_builtin_strpbrk (tree arglist) ...@@ -8245,12 +8245,12 @@ simplify_builtin_strpbrk (tree arglist)
const char *r = strpbrk (p1, p2); const char *r = strpbrk (p1, p2);
if (r == NULL) 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 an offset into the constant string argument. */
return fold (build (PLUS_EXPR, TREE_TYPE (s1), return fold (build (PLUS_EXPR, TREE_TYPE (s1),
s1, convert (TREE_TYPE (s1), s1, fold_convert (TREE_TYPE (s1),
ssize_int (r - p1)))); ssize_int (r - p1))));
} }
if (p2[0] == '\0') if (p2[0] == '\0')
......
...@@ -5831,7 +5831,7 @@ fold (tree expr) ...@@ -5831,7 +5831,7 @@ fold (tree expr)
tree s1 = TYPE_SIZE (tt1); tree s1 = TYPE_SIZE (tt1);
if (s0 && s1 && operand_equal_p (s0, s1, OEP_ONLY_CONST)) 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)); TREE_OPERAND (arg0, 1));
} }
...@@ -9147,14 +9147,14 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p, ...@@ -9147,14 +9147,14 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p,
{ {
case GT_EXPR: case GT_EXPR:
return omit_one_operand (type, return omit_one_operand (type,
convert (type, integer_zero_node), fold_convert (type, integer_zero_node),
op0); op0);
case GE_EXPR: case GE_EXPR:
*code_p = EQ_EXPR; *code_p = EQ_EXPR;
break; break;
case LE_EXPR: case LE_EXPR:
return omit_one_operand (type, return omit_one_operand (type,
convert (type, integer_one_node), fold_convert (type, integer_one_node),
op0); op0);
case LT_EXPR: case LT_EXPR:
*code_p = NE_EXPR; *code_p = NE_EXPR;
...@@ -9187,7 +9187,7 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p, ...@@ -9187,7 +9187,7 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p,
{ {
case LT_EXPR: case LT_EXPR:
return omit_one_operand (type, return omit_one_operand (type,
convert (type, integer_zero_node), fold_convert (type, integer_zero_node),
op0); op0);
case LE_EXPR: case LE_EXPR:
*code_p = EQ_EXPR; *code_p = EQ_EXPR;
...@@ -9195,7 +9195,7 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p, ...@@ -9195,7 +9195,7 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p,
case GE_EXPR: case GE_EXPR:
return omit_one_operand (type, return omit_one_operand (type,
convert (type, integer_one_node), fold_convert (type, integer_one_node),
op0); op0);
case GT_EXPR: case GT_EXPR:
*code_p = NE_EXPR; *code_p = NE_EXPR;
...@@ -9236,8 +9236,8 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p, ...@@ -9236,8 +9236,8 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p,
exp = build2 (code == LE_EXPR ? GE_EXPR: LT_EXPR, exp = build2 (code == LE_EXPR ? GE_EXPR: LT_EXPR,
type, type,
convert (st0, op0), fold_convert (st0, op0),
convert (st1, integer_zero_node)); fold_convert (st1, integer_zero_node));
retval retval
= nondestructive_fold_binary_to_constant (TREE_CODE (exp), = nondestructive_fold_binary_to_constant (TREE_CODE (exp),
...@@ -9341,7 +9341,7 @@ nondestructive_fold_binary_to_constant (enum tree_code code, tree type, ...@@ -9341,7 +9341,7 @@ nondestructive_fold_binary_to_constant (enum tree_code code, tree type,
/* The return value should always have the same type as /* The return value should always have the same type as
the original expression. */ the original expression. */
if (TREE_TYPE (tem) != type) if (TREE_TYPE (tem) != type)
tem = convert (type, tem); tem = fold_convert (type, tem);
return tem; return tem;
} }
...@@ -9354,7 +9354,7 @@ nondestructive_fold_binary_to_constant (enum tree_code code, tree type, ...@@ -9354,7 +9354,7 @@ nondestructive_fold_binary_to_constant (enum tree_code code, tree type,
Also note that operand_equal_p is always false if an Also note that operand_equal_p is always false if an
operand is volatile. */ operand is volatile. */
if (! FLOAT_TYPE_P (type) && operand_equal_p (op0, op1, 0)) 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; goto binary;
...@@ -9670,7 +9670,7 @@ fold_read_from_constant_string (tree exp) ...@@ -9670,7 +9670,7 @@ fold_read_from_constant_string (tree exp)
{ {
tree domain = TYPE_DOMAIN (TREE_TYPE (exp1)); tree domain = TYPE_DOMAIN (TREE_TYPE (exp1));
tree low_bound = domain ? TYPE_MIN_VALUE (domain) : integer_zero_node; 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. /* Optimize the special-case of a zero lower bound.
...@@ -9680,7 +9680,7 @@ fold_read_from_constant_string (tree exp) ...@@ -9680,7 +9680,7 @@ fold_read_from_constant_string (tree exp)
+(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1)) +(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1))
+INDEX), which becomes (ARRAY+255+INDEX). Opps!) */ +INDEX), which becomes (ARRAY+255+INDEX). Opps!) */
if (! integer_zerop (low_bound)) if (! integer_zerop (low_bound))
index = size_diffop (index, convert (sizetype, low_bound)); index = size_diffop (index, fold_convert (sizetype, low_bound));
string = exp1; string = exp1;
} }
......
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