diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-03-10 20:47:44 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-03-10 20:47:44 +0100 |
commit | c7aee4a15c4b993b063a8a94d1b6e2825130ea72 (patch) | |
tree | 6c4021d9742adf491fdb3202d936b826a37cf289 /gcc/tree-vrp.c | |
parent | 80dd631fceac3b9b8da712fa9e1c1a2f61002cb9 (diff) | |
download | gcc-c7aee4a15c4b993b063a8a94d1b6e2825130ea72.zip gcc-c7aee4a15c4b993b063a8a94d1b6e2825130ea72.tar.gz gcc-c7aee4a15c4b993b063a8a94d1b6e2825130ea72.tar.bz2 |
re PR tree-optimization/79981 (Forwprop not working for __atomic_compare_exchange_n)
PR tree-optimization/79981
* tree-vrp.c (extract_range_basic): Handle IMAGPART_EXPR of
ATOMIC_COMPARE_EXCHANGE ifn result.
(stmt_interesting_for_vrp, vrp_visit_stmt): Handle
IFN_ATOMIC_COMPARE_EXCHANGE.
From-SVN: r246054
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 6420041..2a4c764 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4107,7 +4107,7 @@ extract_range_basic (value_range *vr, gimple *stmt) } /* Handle extraction of the two results (result of arithmetics and a flag whether arithmetics overflowed) from {ADD,SUB,MUL}_OVERFLOW - internal function. */ + internal function. Similarly from ATOMIC_COMPARE_EXCHANGE. */ else if (is_gimple_assign (stmt) && (gimple_assign_rhs_code (stmt) == REALPART_EXPR || gimple_assign_rhs_code (stmt) == IMAGPART_EXPR) @@ -4132,6 +4132,16 @@ extract_range_basic (value_range *vr, gimple *stmt) case IFN_MUL_OVERFLOW: subcode = MULT_EXPR; break; + case IFN_ATOMIC_COMPARE_EXCHANGE: + if (code == IMAGPART_EXPR) + { + /* This is the boolean return value whether compare and + exchange changed anything or not. */ + set_value_range (vr, VR_RANGE, build_int_cst (type, 0), + build_int_cst (type, 1), NULL); + return; + } + break; default: break; } @@ -7283,6 +7293,7 @@ stmt_interesting_for_vrp (gimple *stmt) case IFN_ADD_OVERFLOW: case IFN_SUB_OVERFLOW: case IFN_MUL_OVERFLOW: + case IFN_ATOMIC_COMPARE_EXCHANGE: /* These internal calls return _Complex integer type, but are interesting to VRP nevertheless. */ if (lhs && TREE_CODE (lhs) == SSA_NAME) @@ -8308,6 +8319,7 @@ vrp_visit_stmt (gimple *stmt, edge *taken_edge_p, tree *output_p) case IFN_ADD_OVERFLOW: case IFN_SUB_OVERFLOW: case IFN_MUL_OVERFLOW: + case IFN_ATOMIC_COMPARE_EXCHANGE: /* These internal calls return _Complex integer type, which VRP does not track, but the immediate uses thereof might be interesting. */ |