[PATCH, middle end]: Fix PR 37908, thinko with atomic NAND operation
Jakub Jelinek
jakub@redhat.com
Fri Oct 24 11:28:00 GMT 2008
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.
Jakub
More information about the Gcc-patches
mailing list