diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-16 13:41:03 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-16 13:41:03 +0000 |
commit | d1d2495d53f8f05317f62241f1064f7d076f8f74 (patch) | |
tree | aca0763151e885e1cc02f3593e3df8c155834feb | |
parent | 13bb2154622c7c79ede7e2156d96888c41aa4220 (diff) | |
download | ppe42-gcc-d1d2495d53f8f05317f62241f1064f7d076f8f74.tar.gz ppe42-gcc-d1d2495d53f8f05317f62241f1064f7d076f8f74.zip |
2007-02-16 Richard Guenther <rguenther@suse.de>
Christian Bruel <christian.bruel@st.com>
* fold-const.c (tree_swap_operands_p): Treat SSA_NAMEs like
DECLs but prefer SSA_NAMEs over DECLs.
* gcc.dg/strict-overflow-5.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122040 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/strict-overflow-5.c | 19 |
4 files changed, 42 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1af0a93776d..5d49c8807ab 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,10 @@ 2007-02-16 Richard Guenther <rguenther@suse.de> + Christian Bruel <christian.bruel@st.com> + + * fold-const.c (tree_swap_operands_p): Treat SSA_NAMEs like + DECLs but prefer SSA_NAMEs over DECLs. + +2007-02-16 Richard Guenther <rguenther@suse.de> * tree-flow-inline.h (single_imm_use_p): Remove. (zero_imm_uses_p): Likewise. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3c8636e8fc3..946146c2579 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -6673,11 +6673,6 @@ tree_swap_operands_p (tree arg0, tree arg1, bool reorder) && (TREE_SIDE_EFFECTS (arg0) || TREE_SIDE_EFFECTS (arg1))) return 0; - if (DECL_P (arg1)) - return 0; - if (DECL_P (arg0)) - return 1; - /* It is preferable to swap two SSA_NAME to ensure a canonical form for commutative and comparison operators. Ensuring a canonical form allows the optimizers to find additional redundancies without @@ -6687,6 +6682,18 @@ tree_swap_operands_p (tree arg0, tree arg1, bool reorder) && SSA_NAME_VERSION (arg0) > SSA_NAME_VERSION (arg1)) return 1; + /* Put SSA_NAMEs last. */ + if (TREE_CODE (arg1) == SSA_NAME) + return 0; + if (TREE_CODE (arg0) == SSA_NAME) + return 1; + + /* Put variables last. */ + if (DECL_P (arg1)) + return 0; + if (DECL_P (arg0)) + return 1; + return 0; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7db30065a9e..dd038d15c46 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-02-16 Richard Guenther <rguenther@suse.de> + Christian Bruel <christian.bruel@st.com> + + * gcc.dg/strict-overflow-5.c: New testcase. + 2007-02-16 Tobias Burnus <burnus@net-b.de> PR fortran/30793 diff --git a/gcc/testsuite/gcc.dg/strict-overflow-5.c b/gcc/testsuite/gcc.dg/strict-overflow-5.c new file mode 100644 index 00000000000..26e0174ba6a --- /dev/null +++ b/gcc/testsuite/gcc.dg/strict-overflow-5.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -fdump-tree-final_cleanup" } */ + +/* We can only unroll when using strict overflow semantics. */ + +int foo (int i) +{ + int index; + int r=0; + + for (index = i; index <= i+4; index+=2) + r++; + + return r; +} + +/* { dg-final { scan-tree-dump-times "r = 3" 1 "final_cleanup" } } */ +/* { dg-final { cleanup-tree-dump "final_cleanup" } } */ + |