diff options
author | Jakub Jelinek <jakub@redhat.com> | 2010-02-19 10:50:30 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2010-02-19 10:50:30 +0100 |
commit | 554cf33034e4a4ba3960a0885f45fa7a919dbd0d (patch) | |
tree | c44db830c7f9a0e1b1c2a068434cbcd0e8876bc6 | |
parent | 40e053e3b823a02b3b77aebefbd037d0d9cb4707 (diff) | |
download | gcc-554cf33034e4a4ba3960a0885f45fa7a919dbd0d.zip gcc-554cf33034e4a4ba3960a0885f45fa7a919dbd0d.tar.gz gcc-554cf33034e4a4ba3960a0885f45fa7a919dbd0d.tar.bz2 |
re PR middle-end/42233 (c++ builtin_expect code generation regression)
PR middle-end/42233
* gimplify.c (gimple_boolify): For __builtin_expect call
gimple_boolify also on its first argument.
From-SVN: r156888
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/gimplify.c | 26 |
2 files changed, 32 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f7b78f9..bde0623 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-02-19 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/42233 + * gimplify.c (gimple_boolify): For __builtin_expect call + gimple_boolify also on its first argument. + 2010-02-18 Uros Bizjak <ubizjak@gmail.com> * configure.ac (gnu-unique-object): Wrap regexps using [] in diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 91dabd1..618e3a6 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2720,6 +2720,32 @@ gimple_boolify (tree expr) tree type = TREE_TYPE (expr); location_t loc = EXPR_LOCATION (expr); + if (TREE_CODE (expr) == NE_EXPR + && TREE_CODE (TREE_OPERAND (expr, 0)) == CALL_EXPR + && integer_zerop (TREE_OPERAND (expr, 1))) + { + tree call = TREE_OPERAND (expr, 0); + tree fn = get_callee_fndecl (call); + + /* For __builtin_expect ((long) (x), y) recurse into x as well. */ + if (fn + && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL + && DECL_FUNCTION_CODE (fn) == BUILT_IN_EXPECT + && call_expr_nargs (call) == 2) + { + tree arg = CALL_EXPR_ARG (call, 0); + if (arg) + { + if (TREE_CODE (arg) == NOP_EXPR + && TREE_TYPE (arg) == TREE_TYPE (call)) + arg = TREE_OPERAND (arg, 0); + arg = gimple_boolify (arg); + CALL_EXPR_ARG (call, 0) + = fold_convert_loc (loc, TREE_TYPE (call), arg); + } + } + } + if (TREE_CODE (type) == BOOLEAN_TYPE) return expr; |