diff options
author | Kai Tietz <ktietz@redhat.com> | 2011-07-20 19:10:24 +0200 |
---|---|---|
committer | Kai Tietz <ktietz@gcc.gnu.org> | 2011-07-20 19:10:24 +0200 |
commit | be31603aad66140822c345a93f5e1ae3d4fa9300 (patch) | |
tree | 47f33616929f687720831f27ad08d967a25ec19d /gcc | |
parent | c36193c690369c4180ab460b3a7c9a797f87e160 (diff) | |
download | gcc-be31603aad66140822c345a93f5e1ae3d4fa9300.zip gcc-be31603aad66140822c345a93f5e1ae3d4fa9300.tar.gz gcc-be31603aad66140822c345a93f5e1ae3d4fa9300.tar.bz2 |
builtins.c (fold_builtin_expect): See through the cast from truthvalue_type_node to long.
2011-07-20 Kai Tietz <ktietz@redhat.com>
* builtins.c (fold_builtin_expect): See through the cast
from truthvalue_type_node to long.
From-SVN: r176526
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/builtins.c | 26 |
2 files changed, 19 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eb02423..5a832e2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-07-20 Kai Tietz <ktietz@redhat.com> + + * builtins.c (fold_builtin_expect): See through the cast + from truthvalue_type_node to long. + 2011-07-20 Michael Meissner <meissner@linux.vnet.ibm.com> * config/rs6000/vsx.md (vsx_fma*): Use 4 argument fma instructions diff --git a/gcc/builtins.c b/gcc/builtins.c index afe1ed0..79a6b09 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -6263,13 +6263,22 @@ build_builtin_expect_predicate (location_t loc, tree pred, tree expected) static tree fold_builtin_expect (location_t loc, tree arg0, tree arg1) { - tree inner, fndecl; + tree inner, fndecl, inner_arg0; enum tree_code code; + /* Distribute the expected value over short-circuiting operators. + See through the cast from truthvalue_type_node to long. */ + inner_arg0 = arg0; + while (TREE_CODE (inner_arg0) == NOP_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (inner_arg0)) + && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (inner_arg0, 0)))) + inner_arg0 = TREE_OPERAND (inner_arg0, 0); + /* If this is a builtin_expect within a builtin_expect keep the inner one. See through a comparison against a constant. It might have been added to create a thruthvalue. */ - inner = arg0; + inner = inner_arg0; + if (COMPARISON_CLASS_P (inner) && TREE_CODE (TREE_OPERAND (inner, 1)) == INTEGER_CST) inner = TREE_OPERAND (inner, 0); @@ -6280,14 +6289,7 @@ fold_builtin_expect (location_t loc, tree arg0, tree arg1) && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT) return arg0; - /* Distribute the expected value over short-circuiting operators. - See through the cast from truthvalue_type_node to long. */ - inner = arg0; - while (TREE_CODE (inner) == NOP_EXPR - && INTEGRAL_TYPE_P (TREE_TYPE (inner)) - && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (inner, 0)))) - inner = TREE_OPERAND (inner, 0); - + inner = inner_arg0; code = TREE_CODE (inner); if (code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR) { @@ -6302,13 +6304,13 @@ fold_builtin_expect (location_t loc, tree arg0, tree arg1) } /* If the argument isn't invariant then there's nothing else we can do. */ - if (!TREE_CONSTANT (arg0)) + if (!TREE_CONSTANT (inner_arg0)) return NULL_TREE; /* If we expect that a comparison against the argument will fold to a constant return the constant. In practice, this means a true constant or the address of a non-weak symbol. */ - inner = arg0; + inner = inner_arg0; STRIP_NOPS (inner); if (TREE_CODE (inner) == ADDR_EXPR) { |