aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenth@gcc.gnu.org>2005-02-09 18:15:40 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2005-02-09 18:15:40 +0000
commit0c6c135bb38bbf0f03087aa29a7e517319b4c241 (patch)
tree5c71fda4c499bb7084c78f6b142edb8a17c5e2f5 /gcc
parent8f2bf9f18d96cfdda037ee14619ff866bc021e73 (diff)
downloadgcc-0c6c135bb38bbf0f03087aa29a7e517319b4c241.zip
gcc-0c6c135bb38bbf0f03087aa29a7e517319b4c241.tar.gz
gcc-0c6c135bb38bbf0f03087aa29a7e517319b4c241.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/fold-const.c24
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/tmmti.C7
4 files changed, 32 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b8675fb..3399695 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+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>
PR target/19597
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 1d2efbd..294f94c 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -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
- step of the array. TYPE is the type of the expression. ADDR is the address.
- MULT is the multiplicative expression. If the function succeeds, the new
- address expression is returned. Otherwise NULL_TREE is returned. */
+ step of the array. ADDR is the address. MULT is the multiplicative expression.
+ If the function succeeds, the new address expression is returned. Otherwise
+ NULL_TREE is returned. */
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 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)
/* If the type sizes do not match, we might run into problems
when one of them would overflow. */
- if (TYPE_PRECISION (itype) != TYPE_PRECISION (type))
+ if (TYPE_PRECISION (itype) != TYPE_PRECISION (TREE_TYPE (s)))
continue;
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)
TREE_OPERAND (pos, 1),
delta));
- return build1 (ADDR_EXPR, type, ret);
+ return build1 (ADDR_EXPR, TREE_TYPE (addr), ret);
}
@@ -6944,16 +6944,16 @@ fold (tree expr)
if (TREE_CODE (arg0) == ADDR_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)
- return fold (tem);
+ return fold_convert (type, fold (tem));
}
else if (TREE_CODE (arg1) == ADDR_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)
- return fold (tem);
+ return fold_convert (type, fold (tem));
}
}
else
@@ -7332,9 +7332,9 @@ fold (tree expr)
if (TREE_CODE (arg0) == ADDR_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)
- return fold (tem);
+ return fold_convert (type, fold (tem));
}
if (TREE_CODE (arg0) == MULT_EXPR
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5e9697f..135e31d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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>
* g++.dg/rtti/tinfo1.C: Allow newline after assembler label.
diff --git a/gcc/testsuite/g++.dg/tree-ssa/tmmti.C b/gcc/testsuite/g++.dg/tree-ssa/tmmti.C
new file mode 100644
index 0000000..111127b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/tmmti.C
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+
+void bar(unsigned int i)
+{
+ int a[4];
+ char *p = (char*)&a[1] + 4*i;
+}