summaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/2008-08-19-SubAndFetch.ll
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2009-07-30 08:33:02 +0000
committerEvan Cheng <evan.cheng@apple.com>2009-07-30 08:33:02 +0000
commit37b7387da90ffd42d28ad0f08fca00b684294b2c (patch)
tree04a5091e8f343355eabbad04f432011bc9211a83 /test/CodeGen/X86/2008-08-19-SubAndFetch.ll
parent7f93dc8345fb33652973e35cae4c3b58addf4f87 (diff)
downloadllvm-37b7387da90ffd42d28ad0f08fca00b684294b2c.tar.gz
llvm-37b7387da90ffd42d28ad0f08fca00b684294b2c.tar.bz2
llvm-37b7387da90ffd42d28ad0f08fca00b684294b2c.tar.xz
Optimize some common usage patterns of atomic built-ins __sync_add_and_fetch() and __sync_sub_and_fetch.
When the return value is not used (i.e. only care about the value in the memory), x86 does not have to use add to implement these. Instead, it can use add, sub, inc, dec instructions with the "lock" prefix. This is currently implemented using a bit of instruction selection trick. The issue is the target independent pattern produces one output and a chain and we want to map it into one that just output a chain. The current trick is to select it into a merge_values with the first definition being an implicit_def. The proper solution is to add new ISD opcodes for the no-output variant. DAG combiner can then transform the node before it gets to target node selection. Problem #2 is we are adding a whole bunch of x86 atomic instructions when in fact these instructions are identical to the non-lock versions. We need a way to add target specific information to target nodes and have this information carried over to machine instructions. Asm printer (or JIT) can use this information to add the "lock" prefix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77582 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/2008-08-19-SubAndFetch.ll')
-rw-r--r--test/CodeGen/X86/2008-08-19-SubAndFetch.ll5
1 files changed, 4 insertions, 1 deletions
diff --git a/test/CodeGen/X86/2008-08-19-SubAndFetch.ll b/test/CodeGen/X86/2008-08-19-SubAndFetch.ll
index 00bcdf82e8..72efa16866 100644
--- a/test/CodeGen/X86/2008-08-19-SubAndFetch.ll
+++ b/test/CodeGen/X86/2008-08-19-SubAndFetch.ll
@@ -1,9 +1,12 @@
-; RUN: llvm-as < %s | llc -march=x86-64 | grep xadd
+; RUN: llvm-as < %s | llc -march=x86-64 | FileCheck %s
@var = external global i64 ; <i64*> [#uses=1]
define i32 @main() nounwind {
entry:
+; CHECK: main:
+; CHECK: lock
+; CHECK: decq
tail call i64 @llvm.atomic.load.sub.i64.p0i64( i64* @var, i64 1 ) ; <i64>:0 [#uses=0]
unreachable
}