[llvm] r212443 - CodeGen: it turns out that NAND is not the same thing as BIC. At all.

Duncan Sands duncan.sands at gmail.com
Mon Jul 7 07:03:40 PDT 2014


Hi Hal,

>>> We've been performing the wrong operation on ARM for "atomicrmw
>>> nand" for
>>> years, since "a NAND b" is "~(a & b)" rather than ARM's very
>>> tempting "a & ~b".
>>> This bled over into the generic expansion pass.
>>>
>>> So I assume no-one has ever actually tried to do an atomic nand in
>>> the real
>>> world. Oh well.
>>
>> this may have been a feature, not a mistake: it might simply have
>> been trying to
>> be compatible with GCC which also did a & ~b for atomic nand for
>> years (it was
>> even documented to be this way).  The semantics were changed to ~(a &
>> b) in GCC
>> 4.4.  See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37908
>
> Is this a problem, then, because we claim compatibility with gcc 4.2.1? I wonder if this breaks anything in the wild.

in my opinion this was a gcc misfeature that is better off dead, so I suggest 
updating the docs to note that we deviate from gcc 4.2.1 (and follow gcc-4.4+) 
in defining atomic nand to be ~(a & b).

Ciao, Duncan.




More information about the llvm-commits mailing list