diff options
Diffstat (limited to 'gcc/gimplify.cc')
-rw-r--r-- | gcc/gimplify.cc | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index 9e0e342..d4209ea 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -3554,6 +3554,25 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value) enum internal_fn ifn = CALL_EXPR_IFN (*expr_p); auto_vec<tree> vargs (nargs); + if (ifn == IFN_ASSUME) + { + if (simple_condition_p (CALL_EXPR_ARG (*expr_p, 0))) + { + /* If the [[assume (cond)]]; condition is simple + enough and can be evaluated unconditionally + without side-effects, expand it as + if (!cond) __builtin_unreachable (); */ + tree fndecl = builtin_decl_explicit (BUILT_IN_UNREACHABLE); + *expr_p = build3 (COND_EXPR, void_type_node, + CALL_EXPR_ARG (*expr_p, 0), void_node, + build_call_expr_loc (EXPR_LOCATION (*expr_p), + fndecl, 0)); + return GS_OK; + } + /* FIXME: Otherwise expand it specially. */ + return GS_ALL_DONE; + } + for (i = 0; i < nargs; i++) { gimplify_arg (&CALL_EXPR_ARG (*expr_p, i), pre_p, @@ -5601,7 +5620,7 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, } break; case INDIRECT_REF: - { + if (!TREE_ADDRESSABLE (TREE_TYPE (*from_p))) /* If we have code like *(const A*)(A*)&x @@ -5610,11 +5629,13 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, of "A"), treat the entire expression as identical to "x". This kind of code arises in C++ when an object is bound to a const reference, and if "x" is a TARGET_EXPR we want - to take advantage of the optimization below. */ - bool volatile_p = TREE_THIS_VOLATILE (*from_p); - tree t = gimple_fold_indirect_ref_rhs (TREE_OPERAND (*from_p, 0)); - if (t) + to take advantage of the optimization below. But not if + the type is TREE_ADDRESSABLE; then C++17 says that the + TARGET_EXPR needs to be a temporary. */ + if (tree t + = gimple_fold_indirect_ref_rhs (TREE_OPERAND (*from_p, 0))) { + bool volatile_p = TREE_THIS_VOLATILE (*from_p); if (TREE_THIS_VOLATILE (t) != volatile_p) { if (DECL_P (t)) @@ -5627,8 +5648,7 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, ret = GS_OK; changed = true; } - break; - } + break; case TARGET_EXPR: { |