2014-07-01 18:53:31 +00:00
|
|
|
; RUN: llc < %s -mcpu=generic -march=x86 -mattr=+cmov,cx16 -verify-machineinstrs | FileCheck %s
|
2008-05-05 19:05:59 +00:00
|
|
|
|
|
|
|
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
|
|
|
|
|
2010-10-05 11:16:24 +00:00
|
|
|
define void @func(i32 %argc, i8** %argv) nounwind {
|
2008-05-05 19:05:59 +00:00
|
|
|
entry:
|
|
|
|
%argc.addr = alloca i32 ; <i32*> [#uses=1]
|
|
|
|
%argv.addr = alloca i8** ; <i8***> [#uses=1]
|
|
|
|
%val1 = alloca i32 ; <i32*> [#uses=2]
|
|
|
|
%val2 = alloca i32 ; <i32*> [#uses=15]
|
|
|
|
%andt = alloca i32 ; <i32*> [#uses=2]
|
|
|
|
%ort = alloca i32 ; <i32*> [#uses=2]
|
|
|
|
%xort = alloca i32 ; <i32*> [#uses=2]
|
|
|
|
%old = alloca i32 ; <i32*> [#uses=18]
|
|
|
|
%temp = alloca i32 ; <i32*> [#uses=2]
|
2012-04-13 22:47:00 +00:00
|
|
|
%temp64 = alloca i64
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %argc, i32* %argc.addr
|
|
|
|
store i8** %argv, i8*** %argv.addr
|
|
|
|
store i32 0, i32* %val1
|
|
|
|
store i32 31, i32* %val2
|
|
|
|
store i32 3855, i32* %andt
|
|
|
|
store i32 3855, i32* %ort
|
|
|
|
store i32 3855, i32* %xort
|
|
|
|
store i32 4, i32* %temp
|
2010-09-21 23:57:27 +00:00
|
|
|
%tmp = load i32* %temp
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: xaddl
|
2011-09-27 00:17:29 +00:00
|
|
|
%0 = atomicrmw add i32* %val1, i32 %tmp monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %0, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: xaddl
|
2011-09-27 00:17:29 +00:00
|
|
|
%1 = atomicrmw sub i32* %val2, i32 30 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %1, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: xaddl
|
2011-09-27 00:17:29 +00:00
|
|
|
%2 = atomicrmw add i32* %val2, i32 1 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %2, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: xaddl
|
2011-09-27 00:17:29 +00:00
|
|
|
%3 = atomicrmw sub i32* %val2, i32 1 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %3, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: andl
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
2011-09-27 00:17:29 +00:00
|
|
|
%4 = atomicrmw and i32* %andt, i32 4080 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %4, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: orl
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
2011-09-27 00:17:29 +00:00
|
|
|
%5 = atomicrmw or i32* %ort, i32 4080 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %5, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: xorl
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
2011-09-27 00:17:29 +00:00
|
|
|
%6 = atomicrmw xor i32* %xort, i32 4080 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %6, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: cmov
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
2011-09-27 00:17:29 +00:00
|
|
|
%7 = atomicrmw min i32* %val2, i32 16 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %7, i32* %old
|
|
|
|
%neg = sub i32 0, 1 ; <i32> [#uses=1]
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: cmov
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
2011-09-27 00:17:29 +00:00
|
|
|
%8 = atomicrmw min i32* %val2, i32 %neg monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %8, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: cmov
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
2011-09-27 00:17:29 +00:00
|
|
|
%9 = atomicrmw max i32* %val2, i32 1 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %9, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: cmov
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
2011-09-27 00:17:29 +00:00
|
|
|
%10 = atomicrmw max i32* %val2, i32 0 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %10, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: cmov
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
2011-09-27 00:17:29 +00:00
|
|
|
%11 = atomicrmw umax i32* %val2, i32 65535 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %11, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: cmov
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
2011-09-27 00:17:29 +00:00
|
|
|
%12 = atomicrmw umax i32* %val2, i32 10 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %12, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: cmov
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
2011-09-27 00:17:29 +00:00
|
|
|
%13 = atomicrmw umin i32* %val2, i32 1 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %13, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: cmov
|
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
2011-09-27 00:17:29 +00:00
|
|
|
%14 = atomicrmw umin i32* %val2, i32 10 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %14, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: xchgl %{{.*}}, {{.*}}(%esp)
|
2011-09-27 00:17:29 +00:00
|
|
|
%15 = atomicrmw xchg i32* %val2, i32 1976 monotonic
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %15, i32* %old
|
|
|
|
%neg1 = sub i32 0, 10 ; <i32> [#uses=1]
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
IR: add "cmpxchg weak" variant to support permitted failure.
This commit adds a weak variant of the cmpxchg operation, as described
in C++11. A cmpxchg instruction with this modifier is permitted to
fail to store, even if the comparison indicated it should.
As a result, cmpxchg instructions must return a flag indicating
success in addition to their original iN value loaded. Thus, for
uniformity *all* cmpxchg instructions now return "{ iN, i1 }". The
second flag is 1 when the store succeeded.
At the DAG level, a new ATOMIC_CMP_SWAP_WITH_SUCCESS node has been
added as the natural representation for the new cmpxchg instructions.
It is a strong cmpxchg.
By default this gets Expanded to the existing ATOMIC_CMP_SWAP during
Legalization, so existing backends should see no change in behaviour.
If they wish to deal with the enhanced node instead, they can call
setOperationAction on it. Beware: as a node with 2 results, it cannot
be selected from TableGen.
Currently, no use is made of the extra information provided in this
patch. Test updates are almost entirely adapting the input IR to the
new scheme.
Summary for out of tree users:
------------------------------
+ Legacy Bitcode files are upgraded during read.
+ Legacy assembly IR files will be invalid.
+ Front-ends must adapt to different type for "cmpxchg".
+ Backends should be unaffected by default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210903 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-13 14:24:07 +00:00
|
|
|
%pair16 = cmpxchg i32* %val2, i32 %neg1, i32 1 monotonic monotonic
|
|
|
|
%16 = extractvalue { i32, i1 } %pair16, 0
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %16, i32* %old
|
2010-09-21 23:57:27 +00:00
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchgl
|
IR: add "cmpxchg weak" variant to support permitted failure.
This commit adds a weak variant of the cmpxchg operation, as described
in C++11. A cmpxchg instruction with this modifier is permitted to
fail to store, even if the comparison indicated it should.
As a result, cmpxchg instructions must return a flag indicating
success in addition to their original iN value loaded. Thus, for
uniformity *all* cmpxchg instructions now return "{ iN, i1 }". The
second flag is 1 when the store succeeded.
At the DAG level, a new ATOMIC_CMP_SWAP_WITH_SUCCESS node has been
added as the natural representation for the new cmpxchg instructions.
It is a strong cmpxchg.
By default this gets Expanded to the existing ATOMIC_CMP_SWAP during
Legalization, so existing backends should see no change in behaviour.
If they wish to deal with the enhanced node instead, they can call
setOperationAction on it. Beware: as a node with 2 results, it cannot
be selected from TableGen.
Currently, no use is made of the extra information provided in this
patch. Test updates are almost entirely adapting the input IR to the
new scheme.
Summary for out of tree users:
------------------------------
+ Legacy Bitcode files are upgraded during read.
+ Legacy assembly IR files will be invalid.
+ Front-ends must adapt to different type for "cmpxchg".
+ Backends should be unaffected by default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210903 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-13 14:24:07 +00:00
|
|
|
%pair17 = cmpxchg i32* %val2, i32 1976, i32 1 monotonic monotonic
|
|
|
|
%17 = extractvalue { i32, i1 } %pair17, 0
|
2008-05-05 19:05:59 +00:00
|
|
|
store i32 %17, i32* %old
|
2012-09-20 03:06:15 +00:00
|
|
|
; CHECK: movl [[R17atomic:.*]], %eax
|
2014-07-01 18:53:31 +00:00
|
|
|
; CHECK: movl %eax, %[[R17mask:[a-z]*]]
|
|
|
|
; CHECK: notl %[[R17mask]]
|
|
|
|
; CHECK: orl $-1402, %[[R17mask]]
|
2012-04-16 18:43:53 +00:00
|
|
|
; CHECK: lock
|
2012-09-20 03:06:15 +00:00
|
|
|
; CHECK: cmpxchgl %[[R17mask]], [[R17atomic]]
|
2012-04-16 18:43:53 +00:00
|
|
|
; CHECK: jne
|
|
|
|
; CHECK: movl %eax,
|
2012-04-13 22:47:00 +00:00
|
|
|
%18 = atomicrmw nand i32* %val2, i32 1401 monotonic
|
|
|
|
store i32 %18, i32* %old
|
|
|
|
; CHECK: notl
|
|
|
|
; CHECK: notl
|
2014-07-01 18:53:31 +00:00
|
|
|
; CHECK: orl $252645135
|
|
|
|
; CHECK: orl $252645135
|
2012-04-13 22:47:00 +00:00
|
|
|
; CHECK: lock
|
|
|
|
; CHECK: cmpxchg8b
|
|
|
|
%19 = atomicrmw nand i64* %temp64, i64 17361641481138401520 monotonic
|
|
|
|
store i64 %19, i64* %temp64
|
2008-05-05 19:05:59 +00:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2010-09-21 23:59:42 +00:00
|
|
|
define void @test2(i32 addrspace(256)* nocapture %P) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: lock
|
2010-11-29 22:34:55 +00:00
|
|
|
; CHECK: cmpxchgl %{{.*}}, %gs:(%{{.*}})
|
2010-09-21 23:59:42 +00:00
|
|
|
|
IR: add "cmpxchg weak" variant to support permitted failure.
This commit adds a weak variant of the cmpxchg operation, as described
in C++11. A cmpxchg instruction with this modifier is permitted to
fail to store, even if the comparison indicated it should.
As a result, cmpxchg instructions must return a flag indicating
success in addition to their original iN value loaded. Thus, for
uniformity *all* cmpxchg instructions now return "{ iN, i1 }". The
second flag is 1 when the store succeeded.
At the DAG level, a new ATOMIC_CMP_SWAP_WITH_SUCCESS node has been
added as the natural representation for the new cmpxchg instructions.
It is a strong cmpxchg.
By default this gets Expanded to the existing ATOMIC_CMP_SWAP during
Legalization, so existing backends should see no change in behaviour.
If they wish to deal with the enhanced node instead, they can call
setOperationAction on it. Beware: as a node with 2 results, it cannot
be selected from TableGen.
Currently, no use is made of the extra information provided in this
patch. Test updates are almost entirely adapting the input IR to the
new scheme.
Summary for out of tree users:
------------------------------
+ Legacy Bitcode files are upgraded during read.
+ Legacy assembly IR files will be invalid.
+ Front-ends must adapt to different type for "cmpxchg".
+ Backends should be unaffected by default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210903 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-13 14:24:07 +00:00
|
|
|
%pair0 = cmpxchg i32 addrspace(256)* %P, i32 0, i32 1 monotonic monotonic
|
|
|
|
%0 = extractvalue { i32, i1 } %pair0, 0
|
2010-09-21 23:59:42 +00:00
|
|
|
ret void
|
|
|
|
}
|