On Fri, Jun 24, 2016 at 6:35 AM, Jakub Jelinek <ja...@redhat.com> wrote:
> On Thu, Jun 23, 2016 at 05:23:21PM +0200, Jakub Jelinek wrote:
>> Thinking about this again, there could be another option - keep
>> __atomic_compare_exchange_N in the IL, but under certain conditions (similar
>> to what the patch uses in fold_builtin_atomic_compare_exchange) for these
>> builtins ignore &var on the second argument, and if we actually turn var
>> into non-addressable, convert the builtin call similarly to what
>> fold_builtin_atomic_compare_exchange does in the patch (except the store
>> would be non-conditional then; the gimple-fold.c part wouldn't be needed
>> then).
>
> Here is this second approach implemented.  Generally it gives slight code
> size savings over the other patch on the testcases I've posted (and even the
> other patch used to produce generally smaller code than vanilla).
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2016-06-24  Jakub Jelinek  <ja...@redhat.com>
>
>         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.
>

This caused:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71716

H.J.

Reply via email to