summaryrefslogtreecommitdiffstats
path: root/gcc/expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 9b81988521b..4031cab1635 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -9913,6 +9913,39 @@ do_jump (exp, if_false_label, if_true_label)
}
break;
+ /* Special case:
+ __builtin_expect (<test>, 0) and
+ __builtin_expect (<test>, 1)
+
+ We need to do this here, so that <test> is not converted to a SCC
+ operation on machines that use condition code registers and COMPARE
+ like the PowerPC, and then the jump is done based on whether the SCC
+ operation produced a 1 or 0. */
+ case CALL_EXPR:
+ /* Check for a built-in function. */
+ if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR)
+ {
+ tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
+ tree arglist = TREE_OPERAND (exp, 1);
+
+ if (TREE_CODE (fndecl) == FUNCTION_DECL
+ && DECL_BUILT_IN (fndecl)
+ && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
+ && arglist != NULL_TREE
+ && TREE_CHAIN (arglist) != NULL_TREE)
+ {
+ rtx seq = expand_builtin_expect_jump (exp, if_false_label,
+ if_true_label);
+
+ if (seq != NULL_RTX)
+ {
+ emit_insn (seq);
+ return;
+ }
+ }
+ }
+ /* fall through and generate the normal code. */
+
default:
normal:
temp = expand_expr (exp, NULL_RTX, VOIDmode, 0);
OpenPOWER on IntegriCloud