Commit 0c6c135b by Richard Guenther Committed by Richard Biener

fold-const.c (try_move_mult_to_index): Remove redundant type argument.

2005-02-09  Richard Guenther  <rguenth@gcc.gnu.org>

	* fold-const.c (try_move_mult_to_index): Remove redundant
	type argument.  Create ADDR_EXPR with correct type.
	(fold): Update callers of try_move_mult_to_index.  Convert
	result to the appropriate type.

	* g++.dg/tree-ssa/tmmti.C: New testcase.

From-SVN: r94767
parent 8f2bf9f1
2005-02-09 Richard Guenther <rguenth@gcc.gnu.org>
PR middle-end/19854
* fold-const.c (try_move_mult_to_index): Remove redundant
type argument. Create ADDR_EXPR with correct type.
(fold): Update callers of try_move_mult_to_index. Convert
result to the appropriate type.
2005-02-09 Roger Sayle <roger@eyesopen.com> 2005-02-09 Roger Sayle <roger@eyesopen.com>
PR target/19597 PR target/19597
......
...@@ -6172,12 +6172,12 @@ fold_sign_changed_comparison (enum tree_code code, tree type, ...@@ -6172,12 +6172,12 @@ fold_sign_changed_comparison (enum tree_code code, tree type,
} }
/* Tries to replace &a[idx] CODE s * delta with &a[idx CODE delta], if s is /* Tries to replace &a[idx] CODE s * delta with &a[idx CODE delta], if s is
step of the array. TYPE is the type of the expression. ADDR is the address. step of the array. ADDR is the address. MULT is the multiplicative expression.
MULT is the multiplicative expression. If the function succeeds, the new If the function succeeds, the new address expression is returned. Otherwise
address expression is returned. Otherwise NULL_TREE is returned. */ NULL_TREE is returned. */
static tree static tree
try_move_mult_to_index (tree type, enum tree_code code, tree addr, tree mult) try_move_mult_to_index (enum tree_code code, tree addr, tree mult)
{ {
tree s, delta, step; tree s, delta, step;
tree arg0 = TREE_OPERAND (mult, 0), arg1 = TREE_OPERAND (mult, 1); tree arg0 = TREE_OPERAND (mult, 0), arg1 = TREE_OPERAND (mult, 1);
...@@ -6214,7 +6214,7 @@ try_move_mult_to_index (tree type, enum tree_code code, tree addr, tree mult) ...@@ -6214,7 +6214,7 @@ try_move_mult_to_index (tree type, enum tree_code code, tree addr, tree mult)
/* If the type sizes do not match, we might run into problems /* If the type sizes do not match, we might run into problems
when one of them would overflow. */ when one of them would overflow. */
if (TYPE_PRECISION (itype) != TYPE_PRECISION (type)) if (TYPE_PRECISION (itype) != TYPE_PRECISION (TREE_TYPE (s)))
continue; continue;
if (!operand_equal_p (step, fold_convert (itype, s), 0)) if (!operand_equal_p (step, fold_convert (itype, s), 0))
...@@ -6246,7 +6246,7 @@ try_move_mult_to_index (tree type, enum tree_code code, tree addr, tree mult) ...@@ -6246,7 +6246,7 @@ try_move_mult_to_index (tree type, enum tree_code code, tree addr, tree mult)
TREE_OPERAND (pos, 1), TREE_OPERAND (pos, 1),
delta)); delta));
return build1 (ADDR_EXPR, type, ret); return build1 (ADDR_EXPR, TREE_TYPE (addr), ret);
} }
...@@ -6944,16 +6944,16 @@ fold (tree expr) ...@@ -6944,16 +6944,16 @@ fold (tree expr)
if (TREE_CODE (arg0) == ADDR_EXPR if (TREE_CODE (arg0) == ADDR_EXPR
&& TREE_CODE (arg1) == MULT_EXPR) && TREE_CODE (arg1) == MULT_EXPR)
{ {
tem = try_move_mult_to_index (type, PLUS_EXPR, arg0, arg1); tem = try_move_mult_to_index (PLUS_EXPR, arg0, arg1);
if (tem) if (tem)
return fold (tem); return fold_convert (type, fold (tem));
} }
else if (TREE_CODE (arg1) == ADDR_EXPR else if (TREE_CODE (arg1) == ADDR_EXPR
&& TREE_CODE (arg0) == MULT_EXPR) && TREE_CODE (arg0) == MULT_EXPR)
{ {
tem = try_move_mult_to_index (type, PLUS_EXPR, arg1, arg0); tem = try_move_mult_to_index (PLUS_EXPR, arg1, arg0);
if (tem) if (tem)
return fold (tem); return fold_convert (type, fold (tem));
} }
} }
else else
...@@ -7332,9 +7332,9 @@ fold (tree expr) ...@@ -7332,9 +7332,9 @@ fold (tree expr)
if (TREE_CODE (arg0) == ADDR_EXPR if (TREE_CODE (arg0) == ADDR_EXPR
&& TREE_CODE (arg1) == MULT_EXPR) && TREE_CODE (arg1) == MULT_EXPR)
{ {
tem = try_move_mult_to_index (type, MINUS_EXPR, arg0, arg1); tem = try_move_mult_to_index (MINUS_EXPR, arg0, arg1);
if (tem) if (tem)
return fold (tem); return fold_convert (type, fold (tem));
} }
if (TREE_CODE (arg0) == MULT_EXPR if (TREE_CODE (arg0) == MULT_EXPR
......
2005-02-09 Richard Guenther <rguenth@gcc.gnu.org>
PR middle-end/19854
* g++.dg/tree-ssa/tmmti.C: New testcase.
2005-02-09 Joseph S. Myers <joseph@codesourcery.com> 2005-02-09 Joseph S. Myers <joseph@codesourcery.com>
* g++.dg/rtti/tinfo1.C: Allow newline after assembler label. * g++.dg/rtti/tinfo1.C: Allow newline after assembler label.
......
/* { dg-do compile } */
void bar(unsigned int i)
{
int a[4];
char *p = (char*)&a[1] + 4*i;
}
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