aboutsummaryrefslogtreecommitdiff
path: root/gcc/predict.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2011-11-30 14:19:02 -0800
committerRichard Henderson <rth@gcc.gnu.org>2011-11-30 14:19:02 -0800
commitc08472eaf611a76fa2545b5a45f32d274ac0d25d (patch)
tree12dcee32e763cdc77a0ac7766025f3973125533d /gcc/predict.c
parented079c4be707a95d7b935f1bf0f66bf47df93d30 (diff)
downloadgcc-c08472eaf611a76fa2545b5a45f32d274ac0d25d.zip
gcc-c08472eaf611a76fa2545b5a45f32d274ac0d25d.tar.gz
gcc-c08472eaf611a76fa2545b5a45f32d274ac0d25d.tar.bz2
predict.c (expr_expected_value_1): Assume compare-and-swap builtin boolean return is true.
* predict.c (expr_expected_value_1): Assume compare-and-swap builtin boolean return is true. From-SVN: r181862
Diffstat (limited to 'gcc/predict.c')
-rw-r--r--gcc/predict.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/gcc/predict.c b/gcc/predict.c
index eeca172..9236531 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -1190,7 +1190,8 @@ static tree expr_expected_value (tree, bitmap);
/* Helper function for expr_expected_value. */
static tree
-expr_expected_value_1 (tree type, tree op0, enum tree_code code, tree op1, bitmap visited)
+expr_expected_value_1 (tree type, tree op0, enum tree_code code,
+ tree op1, bitmap visited)
{
gimple def;
@@ -1255,17 +1256,36 @@ expr_expected_value_1 (tree type, tree op0, enum tree_code code, tree op1, bitma
tree decl = gimple_call_fndecl (def);
if (!decl)
return NULL;
- if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
- && DECL_FUNCTION_CODE (decl) == BUILT_IN_EXPECT)
- {
- tree val;
+ if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
+ switch (DECL_FUNCTION_CODE (decl))
+ {
+ case BUILT_IN_EXPECT:
+ {
+ tree val;
+ if (gimple_call_num_args (def) != 2)
+ return NULL;
+ val = gimple_call_arg (def, 0);
+ if (TREE_CONSTANT (val))
+ return val;
+ return gimple_call_arg (def, 1);
+ }
- if (gimple_call_num_args (def) != 2)
- return NULL;
- val = gimple_call_arg (def, 0);
- if (TREE_CONSTANT (val))
- return val;
- return gimple_call_arg (def, 1);
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_N:
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_1:
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_2:
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_4:
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8:
+ case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_16:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_N:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_1:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_2:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_4:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_8:
+ case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_16:
+ /* Assume that any given atomic operation has low contention,
+ and thus the compare-and-swap operation succeeds. */
+ return boolean_true_node;
}
}