diff options
author | Hal Finkel <hfinkel@anl.gov> | 2014-10-02 20:53:50 +0000 |
---|---|---|
committer | Hal Finkel <hfinkel@anl.gov> | 2014-10-02 20:53:50 +0000 |
commit | d2208b59cfaa092dddb533587e7670247df9de30 (patch) | |
tree | 909b4477a8389e24271097c99d00a4e7f43b2d69 /clang/test/CodeGen/Atomics.c | |
parent | e9914abe3b132622aa7f85707f5da23c179d5edd (diff) | |
download | bcm5719-llvm-d2208b59cfaa092dddb533587e7670247df9de30.tar.gz bcm5719-llvm-d2208b59cfaa092dddb533587e7670247df9de30.zip |
Add __sync_fetch_and_nand (again)
Prior to GCC 4.4, __sync_fetch_and_nand was implemented as:
{ tmp = *ptr; *ptr = ~tmp & value; return tmp; }
but this was changed in GCC 4.4 to be:
{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; }
in response to this change, support for sync_fetch_and_nand (and
sync_nand_and_fetch) was removed in r99522 in order to avoid miscompiling code
depending on the old semantics. However, at this point:
1. Many years have passed, and the amount of code relying on the old
semantics is likely smaller.
2. Through the work of many contributors, all LLVM backends have been updated
such that "atomicrmw nand" provides the newer GCC 4.4+ semantics (this process
was complete July of 2014 (added to the release notes in r212635).
3. The lack of this intrinsic is now a needless impediment to porting codes
from GCC to Clang (I've now seen several examples of this).
It is true, however, that we still set GNUC_MINOR to 2 (corresponding to GCC
4.2). To compensate for this, and to address the original concern regarding
code relying on the old semantics, I've added a warning that specifically
details the fact that the semantics have changed and that we provide the newer
semantics.
Fixes PR8842.
llvm-svn: 218905
Diffstat (limited to 'clang/test/CodeGen/Atomics.c')
-rw-r--r-- | clang/test/CodeGen/Atomics.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/test/CodeGen/Atomics.c b/clang/test/CodeGen/Atomics.c index 684f36d4044..f957883575d 100644 --- a/clang/test/CodeGen/Atomics.c +++ b/clang/test/CodeGen/Atomics.c @@ -49,6 +49,15 @@ void test_op_ignore (void) // CHECK-LABEL: define void @test_op_ignore (void) __sync_fetch_and_xor (&sll, 1); // CHECK: atomicrmw xor i64 (void) __sync_fetch_and_xor (&ull, 1); // CHECK: atomicrmw xor i64 + (void) __sync_fetch_and_nand (&sc, 1); // CHECK: atomicrmw nand i8 + (void) __sync_fetch_and_nand (&uc, 1); // CHECK: atomicrmw nand i8 + (void) __sync_fetch_and_nand (&ss, 1); // CHECK: atomicrmw nand i16 + (void) __sync_fetch_and_nand (&us, 1); // CHECK: atomicrmw nand i16 + (void) __sync_fetch_and_nand (&si, 1); // CHECK: atomicrmw nand i32 + (void) __sync_fetch_and_nand (&ui, 1); // CHECK: atomicrmw nand i32 + (void) __sync_fetch_and_nand (&sll, 1); // CHECK: atomicrmw nand i64 + (void) __sync_fetch_and_nand (&ull, 1); // CHECK: atomicrmw nand i64 + (void) __sync_fetch_and_and (&sc, 1); // CHECK: atomicrmw and i8 (void) __sync_fetch_and_and (&uc, 1); // CHECK: atomicrmw and i8 (void) __sync_fetch_and_and (&ss, 1); // CHECK: atomicrmw and i16 @@ -98,6 +107,15 @@ void test_fetch_and_op (void) // CHECK-LABEL: define void @test_fetch_and_op sll = __sync_fetch_and_xor (&sll, 11); // CHECK: atomicrmw xor ull = __sync_fetch_and_xor (&ull, 11); // CHECK: atomicrmw xor + sc = __sync_fetch_and_nand (&sc, 11); // CHECK: atomicrmw nand + uc = __sync_fetch_and_nand (&uc, 11); // CHECK: atomicrmw nand + ss = __sync_fetch_and_nand (&ss, 11); // CHECK: atomicrmw nand + us = __sync_fetch_and_nand (&us, 11); // CHECK: atomicrmw nand + si = __sync_fetch_and_nand (&si, 11); // CHECK: atomicrmw nand + ui = __sync_fetch_and_nand (&ui, 11); // CHECK: atomicrmw nand + sll = __sync_fetch_and_nand (&sll, 11); // CHECK: atomicrmw nand + ull = __sync_fetch_and_nand (&ull, 11); // CHECK: atomicrmw nand + sc = __sync_fetch_and_and (&sc, 11); // CHECK: atomicrmw and uc = __sync_fetch_and_and (&uc, 11); // CHECK: atomicrmw and ss = __sync_fetch_and_and (&ss, 11); // CHECK: atomicrmw and @@ -147,6 +165,31 @@ void test_op_and_fetch (void) sll = __sync_xor_and_fetch (&sll, uc); // CHECK: atomicrmw xor ull = __sync_xor_and_fetch (&ull, uc); // CHECK: atomicrmw xor + sc = __sync_nand_and_fetch (&sc, uc); // CHECK: atomicrmw nand + // CHECK: and + // CHECK: xor + uc = __sync_nand_and_fetch (&uc, uc); // CHECK: atomicrmw nand + // CHECK: and + // CHECK: xor + ss = __sync_nand_and_fetch (&ss, uc); // CHECK: atomicrmw nand + // CHECK: and + // CHECK: xor + us = __sync_nand_and_fetch (&us, uc); // CHECK: atomicrmw nand + // CHECK: and + // CHECK: xor + si = __sync_nand_and_fetch (&si, uc); // CHECK: atomicrmw nand + // CHECK: and + // CHECK: xor + ui = __sync_nand_and_fetch (&ui, uc); // CHECK: atomicrmw nand + // CHECK: and + // CHECK: xor + sll = __sync_nand_and_fetch (&sll, uc); // CHECK: atomicrmw nand + // CHECK: and + // CHECK: xor + ull = __sync_nand_and_fetch (&ull, uc); // CHECK: atomicrmw nand + // CHECK: and + // CHECK: xor + sc = __sync_and_and_fetch (&sc, uc); // CHECK: atomicrmw and uc = __sync_and_and_fetch (&uc, uc); // CHECK: atomicrmw and ss = __sync_and_and_fetch (&ss, uc); // CHECK: atomicrmw and |