2015-03-25 19:44:19 +08:00
|
|
|
; RUN: llc < %s -O0 -march=x86-64 -mcpu=corei7 -verify-machineinstrs | FileCheck %s -check-prefix=WITH-CMOV
|
|
|
|
; RUN: llc < %s -O0 -march=x86 -mcpu=corei7 -verify-machineinstrs | FileCheck %s -check-prefix=WITH-CMOV
|
2013-03-07 09:01:29 +08:00
|
|
|
; RUN: llc < %s -O0 -march=x86 -mcpu=corei7 -mattr=-cmov -verify-machineinstrs | FileCheck %s --check-prefix NOCMOV
|
2012-09-20 11:06:15 +08:00
|
|
|
|
|
|
|
@sc32 = external global i32
|
|
|
|
|
|
|
|
define void @atomic_fetch_add32() nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_add32:
|
2012-09-20 11:06:15 +08:00
|
|
|
entry:
|
|
|
|
; 32-bit
|
|
|
|
%t1 = atomicrmw add i32* @sc32, i32 1 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: incl
|
2012-09-20 11:06:15 +08:00
|
|
|
%t2 = atomicrmw add i32* @sc32, i32 3 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: addl $3
|
2012-09-20 11:06:15 +08:00
|
|
|
%t3 = atomicrmw add i32* @sc32, i32 5 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: xaddl
|
2012-09-20 11:06:15 +08:00
|
|
|
%t4 = atomicrmw add i32* @sc32, i32 %t3 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: addl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_sub32() nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_sub32:
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw sub i32* @sc32, i32 1 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: decl
|
2012-09-20 11:06:15 +08:00
|
|
|
%t2 = atomicrmw sub i32* @sc32, i32 3 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: subl $3
|
2012-09-20 11:06:15 +08:00
|
|
|
%t3 = atomicrmw sub i32* @sc32, i32 5 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: xaddl
|
2012-09-20 11:06:15 +08:00
|
|
|
%t4 = atomicrmw sub i32* @sc32, i32 %t3 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: subl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_and32() nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_and32:
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw and i32* @sc32, i32 3 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: andl $3
|
2012-09-20 11:06:15 +08:00
|
|
|
%t2 = atomicrmw and i32* @sc32, i32 5 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: andl
|
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: cmpxchgl
|
2012-09-20 11:06:15 +08:00
|
|
|
%t3 = atomicrmw and i32* @sc32, i32 %t2 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: andl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_or32() nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_or32:
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw or i32* @sc32, i32 3 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: orl $3
|
2012-09-20 11:06:15 +08:00
|
|
|
%t2 = atomicrmw or i32* @sc32, i32 5 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: orl
|
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: cmpxchgl
|
2012-09-20 11:06:15 +08:00
|
|
|
%t3 = atomicrmw or i32* @sc32, i32 %t2 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: orl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_xor32() nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_xor32:
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw xor i32* @sc32, i32 3 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: xorl $3
|
2012-09-20 11:06:15 +08:00
|
|
|
%t2 = atomicrmw xor i32* @sc32, i32 5 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: xorl
|
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: cmpxchgl
|
2012-09-20 11:06:15 +08:00
|
|
|
%t3 = atomicrmw xor i32* @sc32, i32 %t2 acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: xorl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_nand32(i32 %x) nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_nand32:
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw nand i32* @sc32, i32 %x acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: andl
|
|
|
|
; WITH-CMOV: notl
|
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: cmpxchgl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_max32(i32 %x) nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_max32:
|
2014-07-02 02:53:31 +08:00
|
|
|
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw max i32* @sc32, i32 %x acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: subl
|
|
|
|
; WITH-CMOV: cmov
|
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: cmpxchgl
|
2013-03-07 09:01:29 +08:00
|
|
|
|
2014-07-02 02:53:31 +08:00
|
|
|
; NOCMOV: subl
|
|
|
|
; NOCMOV: jge
|
2013-03-07 09:01:29 +08:00
|
|
|
; NOCMOV: lock
|
|
|
|
; NOCMOV: cmpxchgl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2013-03-07 09:01:29 +08:00
|
|
|
; NOCMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_min32(i32 %x) nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_min32:
|
2014-07-02 02:53:31 +08:00
|
|
|
; NOCMOV-LABEL: atomic_fetch_min32:
|
|
|
|
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw min i32* @sc32, i32 %x acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: subl
|
|
|
|
; WITH-CMOV: cmov
|
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: cmpxchgl
|
2013-03-07 09:01:29 +08:00
|
|
|
|
2014-07-02 02:53:31 +08:00
|
|
|
; NOCMOV: subl
|
|
|
|
; NOCMOV: jle
|
2013-03-07 09:01:29 +08:00
|
|
|
; NOCMOV: lock
|
|
|
|
; NOCMOV: cmpxchgl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2013-03-07 09:01:29 +08:00
|
|
|
; NOCMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_umax32(i32 %x) nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_umax32:
|
2014-07-02 02:53:31 +08:00
|
|
|
; NOCMOV-LABEL: atomic_fetch_umax32:
|
|
|
|
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw umax i32* @sc32, i32 %x acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: subl
|
|
|
|
; WITH-CMOV: cmov
|
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: cmpxchgl
|
2013-03-07 09:01:29 +08:00
|
|
|
|
2014-07-02 02:53:31 +08:00
|
|
|
; NOCMOV: subl
|
|
|
|
; NOCMOV: ja
|
2013-03-07 09:01:29 +08:00
|
|
|
; NOCMOV: lock
|
|
|
|
; NOCMOV: cmpxchgl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2013-03-07 09:01:29 +08:00
|
|
|
; NOCMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_umin32(i32 %x) nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_umin32:
|
2014-07-02 02:53:31 +08:00
|
|
|
; NOCMOV-LABEL: atomic_fetch_umin32:
|
|
|
|
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw umin i32* @sc32, i32 %x acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: subl
|
|
|
|
; WITH-CMOV: cmov
|
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: cmpxchgl
|
2013-03-07 09:01:29 +08:00
|
|
|
|
2014-07-02 02:53:31 +08:00
|
|
|
; NOCMOV: subl
|
|
|
|
; NOCMOV: jb
|
2013-03-07 09:01:29 +08:00
|
|
|
; NOCMOV: lock
|
|
|
|
; NOCMOV: cmpxchgl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2013-03-07 09:01:29 +08:00
|
|
|
; NOCMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_cmpxchg32() nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_cmpxchg32:
|
2014-07-02 02:53:31 +08:00
|
|
|
|
2014-03-11 18:48:52 +08:00
|
|
|
%t1 = cmpxchg i32* @sc32, i32 0, i32 1 acquire acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: lock
|
|
|
|
; WITH-CMOV: cmpxchgl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_store32(i32 %x) nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_store32:
|
2014-07-02 02:53:31 +08:00
|
|
|
|
2012-09-20 11:06:15 +08:00
|
|
|
store atomic i32 %x, i32* @sc32 release, align 4
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-NOT: lock
|
|
|
|
; WITH-CMOV: movl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_swap32(i32 %x) nounwind {
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-LABEL: atomic_fetch_swap32:
|
2014-07-02 02:53:31 +08:00
|
|
|
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw xchg i32* @sc32, i32 %x acquire
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV-NOT: lock
|
|
|
|
; WITH-CMOV: xchgl
|
2012-09-20 11:06:15 +08:00
|
|
|
ret void
|
2015-03-25 19:44:19 +08:00
|
|
|
; WITH-CMOV: ret
|
2012-09-20 11:06:15 +08:00
|
|
|
}
|