aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2006-05-17 01:16:08 +0000
committerDaniel Berlin <dberlin@gcc.gnu.org>2006-05-17 01:16:08 +0000
commit2ed4b0ce33a6cecfb4f00c3be25f526f8438feee (patch)
treeec9df2ff2fe8bd0ca8b34836a411421352949f2e /gcc
parentada22a829973fbe063882e60863f7a28bfe76d1b (diff)
downloadgcc-2ed4b0ce33a6cecfb4f00c3be25f526f8438feee.zip
gcc-2ed4b0ce33a6cecfb4f00c3be25f526f8438feee.tar.gz
gcc-2ed4b0ce33a6cecfb4f00c3be25f526f8438feee.tar.bz2
re PR tree-optimization/27373 (ICE: add_virtual_operand with pointers to arrays)
2006-05-16 Daniel Berlin <dberlin@dberlin.org> Fix PR tree-optimization/27373 * tree-ssa-forwprop.c: (forward_propagate_addr_expr_1): Add argument. (forward_propagate_addr_expr): Update call. From-SVN: r113840
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr27373.c40
-rw-r--r--gcc/tree-ssa-forwprop.c39
3 files changed, 76 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d07c359..f72e1ee 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-05-16 Daniel Berlin <dberlin@dberlin.org>
+
+ Fix PR tree-optimization/27373
+ * tree-ssa-forwprop.c: (forward_propagate_addr_expr_1): Add argument.
+ (forward_propagate_addr_expr): Update call.
+
2006-05-16 H.J. Lu <hongjiu.lu@intel.com>
* doc/options.texi: Move the Negative option.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr27373.c b/gcc/testsuite/gcc.c-torture/compile/pr27373.c
new file mode 100644
index 0000000..bf62174
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr27373.c
@@ -0,0 +1,40 @@
+typedef struct atype
+{
+ float bg[1], cg[1];
+ _Bool ant;
+}atype;
+
+
+void cp_assert(_Bool*, float*, int*, _Bool*);
+
+void f(atype **rng_stream, int *error, float u)
+{
+ _Bool t = *rng_stream != 0;
+ float routinep;
+ _Bool failure;
+ cp_assert ( &t, &routinep, error, &failure);
+ if (failure == 0)
+ {
+ typedef float ty[1];
+ ty *tt = &((*rng_stream)->bg);
+ int i = 1;
+
+ do
+ {
+ (*tt)[i - 1] = u;
+ i ++;
+ }while (i > 1);
+ {
+ ty *tt = &(*rng_stream)->cg;
+ int i = 1;
+
+ do
+ {
+ (*tt)[i - 1] = u;
+ i ++;
+ }while (i > 1);
+ }
+ }
+}
+
+
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index d43fb85..e2c5ed4 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -663,10 +663,15 @@ forward_propagate_addr_into_variable_array_index (tree offset, tree lhs,
Try to forward propagate the ADDR_EXPR into the use USE_STMT.
Often this will allow for removal of an ADDR_EXPR and INDIRECT_REF
node or for recovery of array indexing from pointer arithmetic.
- Return true, if the propagation was successful. */
+
+ CHANGED is an optional pointer to a boolean variable set to true if
+ either the LHS or RHS was changed in the USE_STMT.
+
+ Return true if the propagation was successful (the propagation can
+ be not totally successful, yet things may have been changed). */
static bool
-forward_propagate_addr_expr_1 (tree stmt, tree use_stmt)
+forward_propagate_addr_expr_1 (tree stmt, tree use_stmt, bool *changed)
{
tree name = TREE_OPERAND (stmt, 0);
tree lhs, rhs, array_ref;
@@ -686,6 +691,8 @@ forward_propagate_addr_expr_1 (tree stmt, tree use_stmt)
TREE_OPERAND (lhs, 0) = unshare_expr (TREE_OPERAND (stmt, 1));
fold_stmt_inplace (use_stmt);
tidy_after_forward_propagate_addr (use_stmt);
+ if (changed)
+ *changed = true;
}
/* Trivial case. The use statement could be a trivial copy. We
@@ -699,6 +706,8 @@ forward_propagate_addr_expr_1 (tree stmt, tree use_stmt)
{
TREE_OPERAND (use_stmt, 1) = unshare_expr (TREE_OPERAND (stmt, 1));
tidy_after_forward_propagate_addr (use_stmt);
+ if (changed)
+ *changed = true;
return true;
}
@@ -719,6 +728,8 @@ forward_propagate_addr_expr_1 (tree stmt, tree use_stmt)
TREE_OPERAND (rhs, 0) = unshare_expr (TREE_OPERAND (stmt, 1));
fold_stmt_inplace (use_stmt);
tidy_after_forward_propagate_addr (use_stmt);
+ if (changed)
+ *changed = true;
return true;
}
@@ -751,6 +762,8 @@ forward_propagate_addr_expr_1 (tree stmt, tree use_stmt)
if (fold_stmt_inplace (use_stmt))
{
tidy_after_forward_propagate_addr (use_stmt);
+ if (changed)
+ *changed = true;
return true;
}
else
@@ -771,9 +784,14 @@ forward_propagate_addr_expr_1 (tree stmt, tree use_stmt)
different type than their operands. */
&& lang_hooks.types_compatible_p (TREE_TYPE (name), TREE_TYPE (rhs)))
{
+ bool res;
tree offset_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (rhs, 1));
- return forward_propagate_addr_into_variable_array_index (offset_stmt, lhs,
- stmt, use_stmt);
+
+ res = forward_propagate_addr_into_variable_array_index (offset_stmt, lhs,
+ stmt, use_stmt);
+ if (res && changed)
+ *changed = true;
+ return res;
}
/* Same as the previous case, except the operands of the PLUS_EXPR
@@ -784,9 +802,13 @@ forward_propagate_addr_expr_1 (tree stmt, tree use_stmt)
different type than their operands. */
&& lang_hooks.types_compatible_p (TREE_TYPE (name), TREE_TYPE (rhs)))
{
+ bool res;
tree offset_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (rhs, 0));
- return forward_propagate_addr_into_variable_array_index (offset_stmt, lhs,
- stmt, use_stmt);
+ res = forward_propagate_addr_into_variable_array_index (offset_stmt, lhs,
+ stmt, use_stmt);
+ if (res && changed)
+ *changed = true;
+ return res;
}
return false;
}
@@ -830,9 +852,8 @@ forward_propagate_addr_expr (tree stmt, bool *some)
continue;
}
- result = forward_propagate_addr_expr_1 (stmt, use_stmt);
- if (some)
- *some |= result;
+ result = forward_propagate_addr_expr_1 (stmt, use_stmt, some);
+ *some |= result;
all &= result;
}