diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-06-28 10:27:18 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-06-28 10:27:18 +0200 |
commit | 849a76a5a20db3830b3a627aae1b8c7eb0f1623d (patch) | |
tree | 532f4d56f6e6da5f9c6f2a7cf4ae65a7b9a8342d /gcc/predict.c | |
parent | a826405801ce4e28d534e3f693f236405d886caf (diff) | |
download | gcc-849a76a5a20db3830b3a627aae1b8c7eb0f1623d.zip gcc-849a76a5a20db3830b3a627aae1b8c7eb0f1623d.tar.gz gcc-849a76a5a20db3830b3a627aae1b8c7eb0f1623d.tar.bz2 |
re PR middle-end/66867 (Suboptimal code generation for atomic_compare_exchange)
PR middle-end/66867
* builtins.c (expand_ifn_atomic_compare_exchange_into_call,
expand_ifn_atomic_compare_exchange): New functions.
* internal-fn.c (expand_ATOMIC_COMPARE_EXCHANGE): New function.
* tree.h (build_call_expr_internal_loc): Rename to ...
(build_call_expr_internal_loc_array): ... this. Fix up type of
last argument.
* internal-fn.def (ATOMIC_COMPARE_EXCHANGE): New internal fn.
* predict.c (expr_expected_value_1): Handle IMAGPART_EXPR of
ATOMIC_COMPARE_EXCHANGE result.
* builtins.h (expand_ifn_atomic_compare_exchange): New prototype.
* gimple-fold.h (optimize_atomic_compare_exchange_p,
fold_builtin_atomic_compare_exchange): New prototypes.
* gimple-fold.c (optimize_atomic_compare_exchange_p,
fold_builtin_atomic_compare_exchange): New functions..
* tree-ssa.c (execute_update_addresses_taken): If
optimize_atomic_compare_exchange_p, ignore &var in 2nd argument
of call when finding addressable vars, and if such var becomes
non-addressable, call fold_builtin_atomic_compare_exchange.
From-SVN: r237814
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index 01f5cfc..66a88ab 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -2134,6 +2134,25 @@ expr_expected_value_1 (tree type, tree op0, enum tree_code code, if (TREE_CONSTANT (op0)) return op0; + if (code == IMAGPART_EXPR) + { + if (TREE_CODE (TREE_OPERAND (op0, 0)) == SSA_NAME) + { + def = SSA_NAME_DEF_STMT (TREE_OPERAND (op0, 0)); + if (is_gimple_call (def) + && gimple_call_internal_p (def) + && (gimple_call_internal_fn (def) + == IFN_ATOMIC_COMPARE_EXCHANGE)) + { + /* Assume that any given atomic operation has low contention, + and thus the compare-and-swap operation succeeds. */ + if (predictor) + *predictor = PRED_COMPARE_AND_SWAP; + return build_one_cst (TREE_TYPE (op0)); + } + } + } + if (code != SSA_NAME) return NULL_TREE; |