This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, middle end]: Fix PR 37908, thinko with atomic NAND operation


Jakub Jelinek wrote:
> On Fri, Oct 24, 2008 at 12:18:41PM +0200, Uros Bizjak wrote:
>> Currently, we are expanding atomic NAND operation as "target =
>> (~target & val)", whic is simply not NAND operation. Correct operation
>> would be "target = ~(target & val)".
> 
> 1) you have attached a different test.
> 2) I think the __sync*nand* builtins do what is documented:
> 
> ...
> `TYPE __sync_fetch_and_nand (TYPE *ptr, TYPE value, ...)'
>      These builtins perform the operation suggested by the name, and
>      returns the value that had previously been in memory.  That is,
> 
>           { tmp = *ptr; *ptr OP= value; return tmp; }
>           { tmp = *ptr; *ptr = ~tmp & value; return tmp; }   // nand
> 
> ...
> `TYPE __sync_nand_and_fetch (TYPE *ptr, TYPE value, ...)'
>      These builtins perform the operation suggested by the name, and
>      return the new value.  That is,
> 
>           { *ptr OP= value; return *ptr; }
>           { *ptr = ~*ptr & value; return *ptr; }   // nand
> 
> So I'd say the submitter just haven't read the documentation.

I don't think it's that exactly, but that what the builtins do is
wrong, or at best very misleading.  NAND is a well-defined term of
the art; it isn't defined by the gcc documentation.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]