[cfe-commits] r154659 - in /cfe/trunk: include/clang/Basic/Builtins.def lib/AST/Expr.cpp lib/CodeGen/CGExpr.cpp lib/Sema/SemaChecking.cpp test/CodeGen/atomic-ops.c
Chris Lattner
clattner at apple.com
Fri Apr 13 13:41:50 PDT 2012
On Apr 13, 2012, at 1:20 PM, Richard Smith wrote:
> * clang implements __atomic_fetch_nand but does not impement __sync_fetch_and_nand.
>
> That all seems fine to me. However...
>
> Clang lowers __atomic_fetch_nand(&p, 123, 5) to:
>
> %0 = atomicrmw nand i32* @p, i32 123 seq_cst
>
> ... which is documented as performing *x = ~(*x & y) operation, but actually performs *x = ~*x & y (at least on x86):
Sounds like a (bad!) codegen bug. It probably dates back to when we did support __sync_fetch_and_nand. I think that GCC 4.4 is old enough that we could add support for __sync_fetch_and_nand in, with the proper semantics (and fix the codegen bug!)
-Chris
>
> movl $123, %ecx
> .LBB0_1: # %entry
> movl p, %eax
> movl %eax, %edx
> notl %edx
> andl %ecx, %edx
> lock
> cmpxchgl %edx, p
> jne .LBB0_1
>
> So, is this an LLVM documentation bug (in which case I'll remove these builtins again, since LLVM doesn't provide support for them) or is it an LLVM codegen bug?
>
> Thanks!
> Richard
More information about the cfe-commits
mailing list