aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSteven Bosscher <stevenb@suse.de>2005-10-04 05:57:38 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2005-10-04 05:57:38 +0000
commit46fbb29c2ee1a905f9cad8b5004ff79fcf82bfeb (patch)
tree7151af0afa8919a5d3d55f199b5534c2e0dbb2eb /gcc
parent36dd6d31e4cfb026258d1885e788d7934521f694 (diff)
downloadgcc-46fbb29c2ee1a905f9cad8b5004ff79fcf82bfeb.zip
gcc-46fbb29c2ee1a905f9cad8b5004ff79fcf82bfeb.tar.gz
gcc-46fbb29c2ee1a905f9cad8b5004ff79fcf82bfeb.tar.bz2
re PR tree-optimization/23049 (ICE with -O3 -ftree-vectorize on 4.1.x)
2005-10-05 Steven Bosscher <stevenb@suse.de> gcc/ PR tree-optimization/23049 * tree-ssa-dom.c (thread_across_edge): Make sure that the condition of a COND_EXPR is folded before calling fold on the whole rhs of a conditional assignment. * doc/tree-ssa.texi: Update the GIMPLE grammar for a valid rhs to document that a COND_EXPR may appear there. testsuite/ * gcc.dg/pr23049.c: New test. * gcc.dg/ucnid-4.c: Fix test. From-SVN: r104938
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/doc/tree-ssa.texi4
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/pr23049.c26
-rw-r--r--gcc/testsuite/gcc.dg/ucnid-4.c2
-rw-r--r--gcc/tree-ssa-dom.c33
6 files changed, 72 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 229ef27..9003d0d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2005-10-05 Steven Bosscher <stevenb@suse.de>
+
+ PR tree-optimization/23049
+ * tree-ssa-dom.c (thread_across_edge): Make sure that the condition
+ of a COND_EXPR is folded before calling fold on the whole rhs of a
+ conditional assignment.
+ * doc/tree-ssa.texi: Update the GIMPLE grammar for a valid rhs to
+ document that a COND_EXPR may appear there.
+
2005-10-03 Diego Novillo <dnovillo@redhat.com>
PR 23445
diff --git a/gcc/doc/tree-ssa.texi b/gcc/doc/tree-ssa.texi
index cbc08a1..77a2f0a 100644
--- a/gcc/doc/tree-ssa.texi
+++ b/gcc/doc/tree-ssa.texi
@@ -728,6 +728,10 @@ void f()
| RELOP
op0 -> val
op1 -> val
+ | COND_EXPR
+ op0 -> condition
+ op1 -> val
+ op2 -> val
@end smallexample
@node Annotations
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6aa6e81..34826bf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2005-10-05 Steven Bosscher <stevenb@suse.de>
+
+ * gcc.dg/pr23049.c: New test.
+
+ * gcc.dg/ucnid-4.c: Fix test.
+
2005-10-03 Diego Novillo <dnovillo@redhat.com>
PR 23445
diff --git a/gcc/testsuite/gcc.dg/pr23049.c b/gcc/testsuite/gcc.dg/pr23049.c
new file mode 100644
index 0000000..0a71cec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr23049.c
@@ -0,0 +1,26 @@
+/* This was an ICE in fold where we tried to fold something like,
+
+ a = 0 == 0 ? 0 : 3988292384
+
+ after doing if-conversion for the vectorizer. Folding "0 == 0"
+ should have been done before calling fold on the whole rhs of
+ the above expression. */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -ftree-vectorize" } */
+
+static unsigned short int crc_table[256];
+void AC3_encode_init(void)
+{
+ unsigned int c, n, k;
+ for(n=0; n<256; n++)
+ {
+ c = n << 8;
+ for (k = 0; k < 8; k++)
+ {
+ if (c & (1 << 15))
+ c = ((c << 1) & 0xffff) ^ (((1 << 0) | (1 << 2) | (1 << 15) | (1 << 16)) & 0xffff);
+ }
+ crc_table[n] = c;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/ucnid-4.c b/gcc/testsuite/gcc.dg/ucnid-4.c
index f9bf68e..1fd4925 100644
--- a/gcc/testsuite/gcc.dg/ucnid-4.c
+++ b/gcc/testsuite/gcc.dg/ucnid-4.c
@@ -1,4 +1,4 @@
-/* { dg-do run */
+/* { dg-do run } */
/* { dg-xfail-if "" { "powerpc-ibm-aix*" } { "*" } { "" } } */
/* { dg-options "-std=c99 -fextended-identifiers" } */
void abort (void);
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 1b78b6d5..71dcd4f 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -666,7 +666,7 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
statements. This does not prevent threading through E->dest. */
for (bsi = bsi_start (e->dest); ! bsi_end_p (bsi); bsi_next (&bsi))
{
- tree cached_lhs;
+ tree cached_lhs = NULL;
stmt = bsi_stmt (bsi);
@@ -705,7 +705,7 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
else
{
/* Copy the operands. */
- tree *copy;
+ tree *copy, pre_fold_expr;
ssa_op_iter iter;
use_operand_p use_p;
unsigned int num, i = 0;
@@ -729,12 +729,31 @@ thread_across_edge (struct dom_walk_data *walk_data, edge e)
/* Try to fold/lookup the new expression. Inserting the
expression into the hash table is unlikely to help
- simplify anything later, so just query the hashtable. */
- cached_lhs = fold (TREE_OPERAND (stmt, 1));
- if (TREE_CODE (cached_lhs) != SSA_NAME
- && !is_gimple_min_invariant (cached_lhs))
- cached_lhs = lookup_avail_expr (stmt, false);
+ Sadly, we have to handle conditional assignments specially
+ here, because fold expects all the operands of an expression
+ to be folded before the expression itself is folded, but we
+ can't just substitute the folded condition here. */
+ if (TREE_CODE (TREE_OPERAND (stmt, 1)) == COND_EXPR)
+ {
+ tree cond = COND_EXPR_COND (TREE_OPERAND (stmt, 1));
+ cond = fold (cond);
+ if (cond == boolean_true_node)
+ pre_fold_expr = COND_EXPR_THEN (TREE_OPERAND (stmt, 1));
+ else if (cond == boolean_false_node)
+ pre_fold_expr = COND_EXPR_ELSE (TREE_OPERAND (stmt, 1));
+ else
+ pre_fold_expr = TREE_OPERAND (stmt, 1);
+ }
+ else
+ pre_fold_expr = TREE_OPERAND (stmt, 1);
+ if (pre_fold_expr)
+ {
+ cached_lhs = fold (pre_fold_expr);
+ if (TREE_CODE (cached_lhs) != SSA_NAME
+ && !is_gimple_min_invariant (cached_lhs))
+ cached_lhs = lookup_avail_expr (stmt, false);
+ }
/* Restore the statement's original uses/defs. */
i = 0;