Skip to content

Commit c32d307

Browse files
committed
android: enable double-word CAS on x64
The android target assumes that for the x86_64 target, the CPU supports SSE4.2 and popcnt. This implies that the CPU is Nehalem or newer. This should be sufficiently new to provide the double word compare and exchange instruction. This allows us to directly lower `__sync_val_compare_and_swap_16` to a `cmpxchg16b`. It appears that the libatomic in android's NDK does not provide the implementation for lowering calls to the library function. llvm-svn: 364352
1 parent c8e450a commit c32d307

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

clang/lib/Driver/ToolChains/Arch/X86.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
135135
if (ArchType == llvm::Triple::x86_64) {
136136
Features.push_back("+sse4.2");
137137
Features.push_back("+popcnt");
138+
Features.push_back("+mcx16");
138139
} else
139140
Features.push_back("+ssse3");
140141
}

clang/test/Driver/clang-translation.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@
318318
// ANDROID-X86_64: "-target-cpu" "x86-64"
319319
// ANDROID-X86_64: "-target-feature" "+sse4.2"
320320
// ANDROID-X86_64: "-target-feature" "+popcnt"
321+
// ANDROID-X86_64: "-target-feature" "+mcx16"
321322

322323
// RUN: %clang -target mips-linux-gnu -### -S %s 2>&1 | \
323324
// RUN: FileCheck -check-prefix=MIPS %s

0 commit comments

Comments
 (0)