From 5f4d82c2ea1d086294ed3b2863760bcd171a9127 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Fri, 30 Jan 2009 22:09:15 +0000 Subject: [PATCH] re PR tree-optimization/39041 (ICE on valid during vrp2) 2009-01-30 Richard Guenther PR tree-optimization/39041 * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Propagate variable indices only if the types match for this stmt. * gcc.c-torture/compile/pr39041.c: New testcase. From-SVN: r143808 --- gcc/ChangeLog | 6 ++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.c-torture/compile/pr39041.c | 28 +++++++++++++++++++ gcc/tree-ssa-forwprop.c | 1 + 4 files changed, 40 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr39041.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b3ae08395c6..e871bd645cd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-01-30 Richard Guenther + + PR tree-optimization/39041 + * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): + Propagate variable indices only if the types match for this stmt. + 2009-01-30 Jakub Jelinek PR target/39013 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 67522c6d4cb..02244e51b5d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-01-30 Richard Guenther + + PR tree-optimization/39041 + * gcc.c-torture/compile/pr39041.c: New testcase. + 2009-01-30 Jakub Jelinek PR target/39013 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39041.c b/gcc/testsuite/gcc.c-torture/compile/pr39041.c new file mode 100644 index 00000000000..cc58a8a37e0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr39041.c @@ -0,0 +1,28 @@ +int test_bit(int nr, void *addr) +{ + int *a = (int *)addr; + int mask; + a += nr; + mask = 1 << nr; + return mask & *a; +} +struct { + struct { + int disabled; + } *data[1]; +} trace; +struct { + unsigned bits[1]; +} cpumask; +void inc(int *); +void dec(int *); +int foo(void) +{ + int cpu; + for (cpu = 0; cpu < 1; cpu++) { + if (test_bit(cpu, cpumask.bits)) + inc(&trace.data[cpu]->disabled); + if (!test_bit(cpu, cpumask.bits)) + dec(&trace.data[cpu]->disabled); + } +} diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 3826f1af598..3a8126262c2 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -845,6 +845,7 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs, array elements, then the result is converted into the proper type for the arithmetic. */ if (TREE_CODE (rhs2) == SSA_NAME + && useless_type_conversion_p (TREE_TYPE (name), TREE_TYPE (def_rhs)) /* Avoid problems with IVopts creating PLUS_EXPRs with a different type than their operands. */ && useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (def_rhs))) -- 2.30.2