From 461f8762a0b00404770bbbcc288c741f931140e4 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Sun, 16 Mar 2008 15:45:09 +0000 Subject: [PATCH] re PR tree-optimization/35607 (IVOPTs produces invalid gimple) 2008-03-16 Richard Guenther PR middle-end/35607 * tree-ssa-loop-niter.c (expand_simple_operations): Do not expand TREE_INVARIANT operations that are not gimple invariant. * gcc.c-torture/compile/pr35607.c: New testcase. * gcc.dg/tree-ssa/loop-19.c: Use -O2 to avoid vectorization. From-SVN: r133273 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.c-torture/compile/pr35607.c | 9 +++++++++ gcc/testsuite/gcc.dg/tree-ssa/loop-19.c | 2 +- gcc/tree-ssa-loop-niter.c | 4 ++++ 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr35607.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 246acc9d1f9..58d47850c18 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-03-16 Richard Guenther + + PR middle-end/35607 + * tree-ssa-loop-niter.c (expand_simple_operations): Do not + expand TREE_INVARIANT operations that are not gimple invariant. + 2008-03-16 Hans-Peter Nilsson * doc/extend.texi (Alignment): Say that the ABI controls diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7bb0108ef25..d6c830a3e18 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-03-16 Richard Guenther + + PR middle-end/35607 + * gcc.c-torture/compile/pr35607.c: New testcase. + * gcc.dg/tree-ssa/loop-19.c: Use -O2 to avoid vectorization. + 2008-03-16 Daniel Franke PR fortran/35582 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr35607.c b/gcc/testsuite/gcc.c-torture/compile/pr35607.c new file mode 100644 index 00000000000..7f5aa7a2b7c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr35607.c @@ -0,0 +1,9 @@ +extern void (*__fini_array_start []) (void); +extern void (*__fini_array_end []) (void); +void +__libc_csu_fini (void) +{ + __SIZE_TYPE__ i = __fini_array_end - __fini_array_start; + while (i-- > 0) + (*__fini_array_start [i]) (); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-19.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-19.c index 748c6e81434..1614f7e4de1 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/loop-19.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-19.c @@ -6,7 +6,7 @@ /* { dg-do compile { target i?86-*-* x86_64-*-* powerpc*-*-*} } */ /* { dg-require-effective-target nonpic } */ -/* { dg-options "-O3 -fdump-tree-final_cleanup" } */ +/* { dg-options "-O2 -fdump-tree-final_cleanup" } */ # define N 2000000 static double a[N],c[N]; diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 40e7051c265..0696342bd1b 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -1436,6 +1436,10 @@ expand_simple_operations (tree expr) return expr; e = GIMPLE_STMT_OPERAND (stmt, 1); + /* Do not expand random invariants. */ + if (TREE_INVARIANT (e) + && !is_gimple_min_invariant (e)) + return expr; if (/* Casts are simple. */ TREE_CODE (e) != NOP_EXPR && TREE_CODE (e) != CONVERT_EXPR -- 2.30.2