2013-03-06 08:17:04 +08:00
|
|
|
; RUN: llc < %s -O0 -mtriple=x86_64-unknown-unknown -mcpu=corei7 -verify-machineinstrs -show-mc-encoding | FileCheck %s --check-prefix X64
|
|
|
|
; RUN: llc < %s -O0 -mtriple=i386-unknown-unknown -mcpu=corei7 -verify-machineinstrs | FileCheck %s --check-prefix X32
|
2012-09-20 11:06:15 +08:00
|
|
|
|
|
|
|
@sc16 = external global i16
|
|
|
|
|
|
|
|
define void @atomic_fetch_add16() nounwind {
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64-LABEL: atomic_fetch_add16
|
|
|
|
; X32-LABEL: atomic_fetch_add16
|
2012-09-20 11:06:15 +08:00
|
|
|
entry:
|
|
|
|
; 32-bit
|
|
|
|
%t1 = atomicrmw add i16* @sc16, i16 1 acquire
|
|
|
|
; X64: lock
|
|
|
|
; X64: incw
|
|
|
|
; X32: lock
|
|
|
|
; X32: incw
|
|
|
|
%t2 = atomicrmw add i16* @sc16, i16 3 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: addw $3, {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: addw $3
|
|
|
|
%t3 = atomicrmw add i16* @sc16, i16 5 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: xaddw {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: xaddw
|
|
|
|
%t4 = atomicrmw add i16* @sc16, i16 %t3 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: addw {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: addw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_sub16() nounwind {
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64-LABEL: atomic_fetch_sub16
|
|
|
|
; X32-LABEL: atomic_fetch_sub16
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw sub i16* @sc16, i16 1 acquire
|
|
|
|
; X64: lock
|
|
|
|
; X64: decw
|
|
|
|
; X32: lock
|
|
|
|
; X32: decw
|
|
|
|
%t2 = atomicrmw sub i16* @sc16, i16 3 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: subw $3, {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: subw $3
|
|
|
|
%t3 = atomicrmw sub i16* @sc16, i16 5 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: xaddw {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: xaddw
|
|
|
|
%t4 = atomicrmw sub i16* @sc16, i16 %t3 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: subw {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: subw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_and16() nounwind {
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64-LABEL: atomic_fetch_and16
|
|
|
|
; X32-LABEL: atomic_fetch_and16
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw and i16* @sc16, i16 3 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: andw $3, {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: andw $3
|
|
|
|
%t2 = atomicrmw and i16* @sc16, i16 5 acquire
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64: andl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X64: lock
|
|
|
|
; X64: cmpxchgw
|
2014-07-02 02:53:31 +08:00
|
|
|
; X32: andl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: cmpxchgw
|
|
|
|
%t3 = atomicrmw and i16* @sc16, i16 %t2 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: andw {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: andw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_or16() nounwind {
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64-LABEL: atomic_fetch_or16
|
|
|
|
; X32-LABEL: atomic_fetch_or16
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw or i16* @sc16, i16 3 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: orw $3, {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: orw $3
|
|
|
|
%t2 = atomicrmw or i16* @sc16, i16 5 acquire
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64: orl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X64: lock
|
|
|
|
; X64: cmpxchgw
|
2014-07-02 02:53:31 +08:00
|
|
|
; X32: orl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: cmpxchgw
|
|
|
|
%t3 = atomicrmw or i16* @sc16, i16 %t2 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: orw {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: orw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_xor16() nounwind {
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64-LABEL: atomic_fetch_xor16
|
|
|
|
; X32-LABEL: atomic_fetch_xor16
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw xor i16* @sc16, i16 3 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: xorw $3, {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: xorw $3
|
|
|
|
%t2 = atomicrmw xor i16* @sc16, i16 5 acquire
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64: xorl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X64: lock
|
|
|
|
; X64: cmpxchgw
|
2014-07-02 02:53:31 +08:00
|
|
|
; X32: xorl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: cmpxchgw
|
|
|
|
%t3 = atomicrmw xor i16* @sc16, i16 %t2 acquire
|
|
|
|
; X64: lock
|
2014-12-16 06:34:58 +08:00
|
|
|
; X64: xorw {{.*}} # encoding: [0x66,0xf0
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: xorw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_nand16(i16 %x) nounwind {
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64-LABEL: atomic_fetch_nand16
|
|
|
|
; X32-LABEL: atomic_fetch_nand16
|
2012-09-20 11:06:15 +08:00
|
|
|
%t1 = atomicrmw nand i16* @sc16, i16 %x acquire
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64: andl
|
|
|
|
; X64: notl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X64: lock
|
|
|
|
; X64: cmpxchgw
|
2014-07-02 02:53:31 +08:00
|
|
|
; X32: andl
|
|
|
|
; X32: notl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: lock
|
|
|
|
; X32: cmpxchgw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_max16(i16 %x) nounwind {
|
|
|
|
%t1 = atomicrmw max i16* @sc16, i16 %x acquire
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64: movswl
|
|
|
|
; X64: movswl
|
|
|
|
; X64: subl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X64: cmov
|
|
|
|
; X64: lock
|
|
|
|
; X64: cmpxchgw
|
|
|
|
|
2014-07-02 02:53:31 +08:00
|
|
|
; X32: movswl
|
|
|
|
; X32: movswl
|
|
|
|
; X32: subl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: cmov
|
|
|
|
; X32: lock
|
|
|
|
; X32: cmpxchgw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_min16(i16 %x) nounwind {
|
|
|
|
%t1 = atomicrmw min i16* @sc16, i16 %x acquire
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64: movswl
|
|
|
|
; X64: movswl
|
|
|
|
; X64: subl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X64: cmov
|
|
|
|
; X64: lock
|
|
|
|
; X64: cmpxchgw
|
|
|
|
|
2014-07-02 02:53:31 +08:00
|
|
|
; X32: movswl
|
|
|
|
; X32: movswl
|
|
|
|
; X32: subl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: cmov
|
|
|
|
; X32: lock
|
|
|
|
; X32: cmpxchgw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_umax16(i16 %x) nounwind {
|
|
|
|
%t1 = atomicrmw umax i16* @sc16, i16 %x acquire
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64: movzwl
|
|
|
|
; X64: movzwl
|
|
|
|
; X64: subl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X64: cmov
|
|
|
|
; X64: lock
|
|
|
|
; X64: cmpxchgw
|
|
|
|
|
2014-07-02 02:53:31 +08:00
|
|
|
; X32: movzwl
|
|
|
|
; X32: movzwl
|
|
|
|
; X32: subl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: cmov
|
|
|
|
; X32: lock
|
|
|
|
; X32: cmpxchgw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_umin16(i16 %x) nounwind {
|
|
|
|
%t1 = atomicrmw umin i16* @sc16, i16 %x acquire
|
2014-07-02 02:53:31 +08:00
|
|
|
; X64: movzwl
|
|
|
|
; X64: movzwl
|
|
|
|
; X64: subl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X64: cmov
|
|
|
|
; X64: lock
|
|
|
|
; X64: cmpxchgw
|
2014-07-02 02:53:31 +08:00
|
|
|
|
|
|
|
; X32: movzwl
|
|
|
|
; X32: movzwl
|
|
|
|
; X32: subl
|
2012-09-20 11:06:15 +08:00
|
|
|
; X32: cmov
|
|
|
|
; X32: lock
|
|
|
|
; X32: cmpxchgw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_cmpxchg16() nounwind {
|
2014-03-11 18:48:52 +08:00
|
|
|
%t1 = cmpxchg i16* @sc16, i16 0, i16 1 acquire acquire
|
2012-09-20 11:06:15 +08:00
|
|
|
; X64: lock
|
|
|
|
; X64: cmpxchgw
|
|
|
|
; X32: lock
|
|
|
|
; X32: cmpxchgw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_store16(i16 %x) nounwind {
|
|
|
|
store atomic i16 %x, i16* @sc16 release, align 4
|
|
|
|
; X64-NOT: lock
|
|
|
|
; X64: movw
|
|
|
|
; X32-NOT: lock
|
|
|
|
; X32: movw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @atomic_fetch_swap16(i16 %x) nounwind {
|
|
|
|
%t1 = atomicrmw xchg i16* @sc16, i16 %x acquire
|
|
|
|
; X64-NOT: lock
|
|
|
|
; X64: xchgw
|
|
|
|
; X32-NOT: lock
|
|
|
|
; X32: xchgw
|
|
|
|
ret void
|
|
|
|
; X64: ret
|
|
|
|
; X32: ret
|
|
|
|
}
|