diff options
author | Jeff Law <law@redhat.com> | 2004-03-01 12:18:01 -0700 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2004-03-01 12:18:01 -0700 |
commit | 9bf793f93534b672f460149e704869ac1d0f854d (patch) | |
tree | be50a4b46ffe2e6609446e59e988c1df925aa7d5 /gcc/fold-const.c | |
parent | c9e0ce371610049698e7af2a065ddea2ede63709 (diff) | |
download | gcc-9bf793f93534b672f460149e704869ac1d0f854d.zip gcc-9bf793f93534b672f460149e704869ac1d0f854d.tar.gz gcc-9bf793f93534b672f460149e704869ac1d0f854d.tar.bz2 |
fold-const.c (fold): An equality comparison of a non-weak object against zero has a known result.
* fold-const.c (fold): An equality comparison of a non-weak object
against zero has a known result. Similarly an equality comparison
of the address of two non-weak, unaliased symbols has a known result.
* ggc-page.c (struct page_entry): New field PREV.
(ggc_alloc): Update PREV field appropriately.
(sweep_pages): Likewise.
(ggc_free): Likewise. Use PREV field rather than loop to
improve ggc_free performance.
cp/
* init.c (build_vec_delete_1): Convert 2nd argument to NE_EXPR to
the proper type.
From-SVN: r78713
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 04452de..cffa2ec 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7183,6 +7183,45 @@ fold (tree expr) if (tree_swap_operands_p (arg0, arg1, true)) return fold (build (swap_tree_comparison (code), type, arg1, arg0)); + /* If this is an equality comparison of the address of a non-weak + object against zero, then we know the result. */ + if ((code == EQ_EXPR || code == NE_EXPR) + && TREE_CODE (arg0) == ADDR_EXPR + && DECL_P (TREE_OPERAND (arg0, 0)) + && ! DECL_WEAK (TREE_OPERAND (arg0, 0)) + && integer_zerop (arg1)) + { + if (code == EQ_EXPR) + return integer_zero_node; + else + return integer_one_node; + } + + /* If this is an equality comparison of the address of two non-weak, + unaliased symbols neither of which are extern (since we do not + have access to attributes for externs), then we know the result. */ + if ((code == EQ_EXPR || code == NE_EXPR) + && TREE_CODE (arg0) == ADDR_EXPR + && DECL_P (TREE_OPERAND (arg0, 0)) + && ! DECL_WEAK (TREE_OPERAND (arg0, 0)) + && ! lookup_attribute ("alias", + DECL_ATTRIBUTES (TREE_OPERAND (arg0, 0))) + && ! DECL_EXTERNAL (TREE_OPERAND (arg0, 0)) + && TREE_CODE (arg1) == ADDR_EXPR + && DECL_P (TREE_OPERAND (arg1, 0)) + && ! DECL_WEAK (TREE_OPERAND (arg1, 0)) + && ! lookup_attribute ("alias", + DECL_ATTRIBUTES (TREE_OPERAND (arg1, 0))) + && ! DECL_EXTERNAL (TREE_OPERAND (arg1, 0))) + { + if (code == EQ_EXPR) + return (operand_equal_p (arg0, arg1, 0) + ? integer_one_node : integer_zero_node); + else + return (operand_equal_p (arg0, arg1, 0) + ? integer_zero_node : integer_one_node); + } + if (FLOAT_TYPE_P (TREE_TYPE (arg0))) { tree targ0 = strip_float_extensions (arg0); |