public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ramana Radhakrishnan <ramana.radhakrishnan@foss.arm.com>
To: Jason Merrill <jason@redhat.com>, David Edelsohn <dje.gcc@gmail.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	 Jim Wilson <wilson@tuliptree.org>,
	Steve Ellcey <sellcey@mips.com>,
	Richard Henderson <rth@redhat.com>,
	 Steve Munroe <munroesj@linux.vnet.ibm.com>
Subject: Re: [RFC / CFT] PR c++/66192 - Remove TARGET_RELAXED_ORDERING and use load acquires.
Date: Fri, 22 May 2015 15:42:00 -0000	[thread overview]
Message-ID: <555F49FF.1070402@foss.arm.com> (raw)
In-Reply-To: <555F3D09.2070700@redhat.com>



On 22/05/15 15:28, Jason Merrill wrote:
> On 05/22/2015 09:55 AM, David Edelsohn wrote:
>> On Fri, May 22, 2015 at 9:40 AM, Jason Merrill <jason@redhat.com> wrote:
>>> On 05/22/2015 07:23 AM, Ramana Radhakrishnan wrote:
>>>>
>>>> +  /* Load the guard value only through an atomic acquire load.  */
>>>> +  guard = build_atomic_load (guard, MEMMODEL_ACQUIRE);
>>>> +
>>>>      /* Check to see if the GUARD is zero.  */
>>>>      guard = get_guard_bits (guard);
>>>
>>>
>>> I wonder if these calls should be reversed, to express that we're only
>>> trying to atomically load a byte (on non-ARM targets)?
>>
>> That expresses the semantics more directly, but will that lead to less
>> efficient code on some RISC architectures?
>
> I'm not sure.  I would expect that the target would use a larger load
> and mask it if that is better for performance, but I don't know.
>
> I do notice that get_guard_bits after build_atomic_load just won't work
> on non-ARM targets, as it ends up trying to take the address of a value.
>
> Jason
>



So on powerpc where targetm.guard_mask_bit is false - this is what I see.


{
   static int * p;

     static int * p;
   if (<<cleanup_point (unsigned char) *(char *) &(long long int) 
__atomic_load_8 (&_ZGVZ1fvE1p, 2) == 0>>)
     {
       if (<<cleanup_point __cxa_guard_acquire (&_ZGVZ1fvE1p) != 0>>)
         {
           <<cleanup_point <<< Unknown tree: expr_stmt
   TARGET_EXPR <D.2846, 0>;, p = (int *) operator new (4);;, D.2846 = 
1;;, __cxa_guard_release (&_ZGVZ1fvE1p); >>>>>;
         }
     }
   return <retval> = p;
}

with the following output - David - is this what you would expect ?


0:      addis 2,12,.TOC.-0b@ha
         addi 2,2,.TOC.-0b@l
         .localentry     _Z1fv,.-_Z1fv
         mflr %r0
         std %r30,-16(%r1)
         std %r31,-8(%r1)
         .cfi_register 65, 0
         .cfi_offset 30, -16
         .cfi_offset 31, -8
         addis %r30,%r2,_ZGVZ1fvE1p@toc@ha
         addi %r30,%r30,_ZGVZ1fvE1p@toc@l
         std %r0,16(%r1)
         stdu %r1,-64(%r1)
         .cfi_def_cfa_offset 64
         .cfi_offset 65, 16
         addis %r10,%r2,_ZGVZ1fvE1p@toc@ha               # gpr load 
fusion, type long
         ld %r10,_ZGVZ1fvE1p@toc@l(%r10)
         cmpw %cr7,%r10,%r10
         bne- %cr7,$+4
         isync
         rlwinm %r9,%r10,0,0xff
         std %r10,32(%r1)
         cmpwi %cr7,%r9,0
         beq %cr7,.L11
.L9:
         addi %r1,%r1,64
         .cfi_remember_state
         .cfi_def_cfa_offset 0
         addis %r3,%r2,_ZZ1fvE1p@toc@ha          # gpr load fusion, type 
long
         ld %r3,_ZZ1fvE1p@toc@l(%r3)
         ld %r0,16(%r1)
         ld %r30,-16(%r1)
         ld %r31,-8(%r1)
         mtlr %r0
         .cfi_restore 65
         .cfi_restore 31
         .cfi_restore 30
         blr
         .p2align 4,,15
.L11:
         .cfi_restore_state
         mr %r3,%r30




And on AArch64 which is where guard_mask_bit is true.


  static int * p;

     static int * p;
   if (<<cleanup_point ((long long int) __atomic_load_8 (&_ZGVZ1fvE1p, 
2) & 1) == 0>>)
     {
       if (<<cleanup_point __cxa_guard_acquire (&_ZGVZ1fvE1p) != 0>>)
         {
           <<cleanup_point <<< Unknown tree: expr_stmt
   TARGET_EXPR <D.3168, 0>;, p = (int *) operator new (4);;, D.3168 = 
1;;, __cxa_guard_release (&_ZGVZ1fvE1p); >>>>>;
         }
     }
   return <retval> = p;
}

Alternatively I can change this to an atomic_load of just the byte 
required but I'm not sure if that's supported on all targets.

I'm going to be running away shortly for the long weekend here, so will 
resume discussions/experiments on Tuesday.


regards
Ramana

  reply	other threads:[~2015-05-22 15:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 11:26 Ramana Radhakrishnan
2015-05-22 11:37 ` Ramana Radhakrishnan
2015-05-22 13:49   ` Jason Merrill
2015-05-22 14:15     ` David Edelsohn
2015-05-22 14:42       ` Jason Merrill
2015-05-22 15:42         ` Ramana Radhakrishnan [this message]
2015-05-22 17:48           ` David Edelsohn
2015-05-22 18:19           ` Jason Merrill
2015-05-22 19:49             ` Richard Henderson
2015-05-29 13:32             ` Ramana Radhakrishnan
2015-05-29 16:34               ` Richard Henderson
2015-05-29 16:36               ` Richard Henderson
2015-05-29 20:53               ` Jason Merrill
2015-06-04  9:46                 ` Ramana Radhakrishnan
2015-06-02 14:42               ` David Edelsohn
2015-05-22 14:28     ` Ramana Radhakrishnan
2015-05-24 18:55 Uros Bizjak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=555F49FF.1070402@foss.arm.com \
    --to=ramana.radhakrishnan@foss.arm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=munroesj@linux.vnet.ibm.com \
    --cc=rth@redhat.com \
    --cc=sellcey@mips.com \
    --cc=wilson@tuliptree.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).