On Wed, Sep 5, 2018 at 2:01 PM Ilya Leoshkevich <i...@linux.ibm.com> wrote:
>
> gcc/ChangeLog:
>
> 2018-09-05  Ilya Leoshkevich  <i...@linux.ibm.com>
>
>         PR target/80080
>         * combine.c (rest_of_handle_combine): Perform jump threading.
>
> gcc/testsuite/ChangeLog:
>
> 2018-09-05  Ilya Leoshkevich  <i...@linux.ibm.com>
>
>         PR target/80080
>         * gcc.target/s390/pr80080-4.c: New test.
> ---
>  gcc/combine.c                             | 10 ++++++++--
>  gcc/testsuite/gcc.target/s390/pr80080-4.c | 16 ++++++++++++++++
>  2 files changed, 24 insertions(+), 2 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/s390/pr80080-4.c
>
> diff --git a/gcc/combine.c b/gcc/combine.c
> index a2649b6d5a1..818b4c5b77d 100644
> --- a/gcc/combine.c
> +++ b/gcc/combine.c
> @@ -14960,10 +14960,16 @@ rest_of_handle_combine (void)
>         free_dominance_info (CDI_DOMINATORS);
>        timevar_push (TV_JUMP);
>        rebuild_jump_labels (get_insns ());
> -      cleanup_cfg (0);
> -      timevar_pop (TV_JUMP);
>      }
>
> +  /* Combining insns can change basic blocks in a way that they end up
> +     containing a single jump_insn. This creates an opportunity to improve 
> code
> +     with jump threading.  */
> +  cleanup_cfg (CLEANUP_THREADING);
> +
> +  if (rebuild_jump_labels_after_combine)
> +    timevar_pop (TV_JUMP);

cleanup_cfg pushes its own timevar so it doesn't make sense to try covering it
with TV_JUMP.  And rebuild_jump_labels immediately pushes TV_REBUILD_JUMP.

So I suggest to remove the timevar_push/pop of TV_JUMP here.

No comment in general about the change, maybe we can detect transforms that
make jump-threading viable and conditionalize that properly?  Note the only
setter of CLEANUP_THREADING guards it with flag_thread_jumps so maybe better
do it above as well (avoids cost at -O0 for example).

Richard.

> +
>    regstat_free_n_sets_and_refs ();
>    return 0;
>  }
> diff --git a/gcc/testsuite/gcc.target/s390/pr80080-4.c 
> b/gcc/testsuite/gcc.target/s390/pr80080-4.c
> new file mode 100644
> index 00000000000..91d31ec7845
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/s390/pr80080-4.c
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +/* { dg-options "-march=z196 -O2" } */
> +
> +extern void bar(int *mem);
> +
> +void foo4(int *mem)
> +{
> +  int oldval = 0;
> +  if (!__atomic_compare_exchange_n (mem, (void *) &oldval, 1,
> +                                   1, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
> +    {
> +      bar (mem);
> +    }
> +}
> +
> +/* { dg-final { scan-assembler 
> "\n\tlt\t.*\n\tjne\t(\\.L\\d+)\n(.*\n)*\tcs\t.*\n\tber\t%r14\n\\1:\n\tjg\tbar\n"
>  } } */
> --
> 2.18.0
>

Reply via email to