2016-07-09 08:19:07 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2017-10-30 01:15:09 +08:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s --check-prefix=CHECK --check-prefix=FASTINCDEC
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-- -mattr=slow-incdec | FileCheck %s --check-prefix=CHECK --check-prefix=SLOWINCDEC
|
2016-04-06 04:02:44 +08:00
|
|
|
|
2016-04-07 10:06:53 +08:00
|
|
|
define i32 @test_add_1_cmov_slt(i64* %p, i32 %a0, i32 %a1) #0 {
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-LABEL: test_add_1_cmov_slt:
|
2017-12-05 01:18:51 +08:00
|
|
|
; FASTINCDEC: # %bb.0: # %entry
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-NEXT: movl %esi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; FASTINCDEC-NEXT: lock incq (%rdi)
|
|
|
|
; FASTINCDEC-NEXT: cmovgl %edx, %eax
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-NEXT: retq
|
|
|
|
;
|
|
|
|
; SLOWINCDEC-LABEL: test_add_1_cmov_slt:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SLOWINCDEC: # %bb.0: # %entry
|
2017-10-30 01:15:09 +08:00
|
|
|
; SLOWINCDEC-NEXT: movl %esi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; SLOWINCDEC-NEXT: lock addq $1, (%rdi)
|
|
|
|
; SLOWINCDEC-NEXT: cmovgl %edx, %eax
|
2017-10-30 01:15:09 +08:00
|
|
|
; SLOWINCDEC-NEXT: retq
|
2016-04-06 04:02:44 +08:00
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw add i64* %p, i64 1 seq_cst
|
2016-04-07 10:06:53 +08:00
|
|
|
%tmp1 = icmp slt i64 %tmp0, 0
|
|
|
|
%tmp2 = select i1 %tmp1, i32 %a0, i32 %a1
|
|
|
|
ret i32 %tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test_add_1_cmov_sge(i64* %p, i32 %a0, i32 %a1) #0 {
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-LABEL: test_add_1_cmov_sge:
|
2017-12-05 01:18:51 +08:00
|
|
|
; FASTINCDEC: # %bb.0: # %entry
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-NEXT: movl %esi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; FASTINCDEC-NEXT: lock incq (%rdi)
|
|
|
|
; FASTINCDEC-NEXT: cmovlel %edx, %eax
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-NEXT: retq
|
|
|
|
;
|
|
|
|
; SLOWINCDEC-LABEL: test_add_1_cmov_sge:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SLOWINCDEC: # %bb.0: # %entry
|
2017-10-30 01:15:09 +08:00
|
|
|
; SLOWINCDEC-NEXT: movl %esi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; SLOWINCDEC-NEXT: lock addq $1, (%rdi)
|
|
|
|
; SLOWINCDEC-NEXT: cmovlel %edx, %eax
|
2017-10-30 01:15:09 +08:00
|
|
|
; SLOWINCDEC-NEXT: retq
|
2016-04-07 10:06:53 +08:00
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw add i64* %p, i64 1 seq_cst
|
|
|
|
%tmp1 = icmp sge i64 %tmp0, 0
|
|
|
|
%tmp2 = select i1 %tmp1, i32 %a0, i32 %a1
|
|
|
|
ret i32 %tmp2
|
2016-04-06 04:02:44 +08:00
|
|
|
}
|
|
|
|
|
2016-04-07 10:06:53 +08:00
|
|
|
define i32 @test_sub_1_cmov_sle(i64* %p, i32 %a0, i32 %a1) #0 {
|
2017-10-30 22:51:37 +08:00
|
|
|
; FASTINCDEC-LABEL: test_sub_1_cmov_sle:
|
2017-12-05 01:18:51 +08:00
|
|
|
; FASTINCDEC: # %bb.0: # %entry
|
2017-10-30 22:51:37 +08:00
|
|
|
; FASTINCDEC-NEXT: movl %esi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; FASTINCDEC-NEXT: lock decq (%rdi)
|
|
|
|
; FASTINCDEC-NEXT: cmovgel %edx, %eax
|
2017-10-30 22:51:37 +08:00
|
|
|
; FASTINCDEC-NEXT: retq
|
|
|
|
;
|
|
|
|
; SLOWINCDEC-LABEL: test_sub_1_cmov_sle:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SLOWINCDEC: # %bb.0: # %entry
|
2017-10-30 22:51:37 +08:00
|
|
|
; SLOWINCDEC-NEXT: movl %esi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; SLOWINCDEC-NEXT: lock addq $-1, (%rdi)
|
|
|
|
; SLOWINCDEC-NEXT: cmovgel %edx, %eax
|
2017-10-30 22:51:37 +08:00
|
|
|
; SLOWINCDEC-NEXT: retq
|
2016-04-06 04:02:44 +08:00
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw sub i64* %p, i64 1 seq_cst
|
2016-04-07 10:06:53 +08:00
|
|
|
%tmp1 = icmp sle i64 %tmp0, 0
|
|
|
|
%tmp2 = select i1 %tmp1, i32 %a0, i32 %a1
|
|
|
|
ret i32 %tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test_sub_1_cmov_sgt(i64* %p, i32 %a0, i32 %a1) #0 {
|
2017-10-30 22:51:37 +08:00
|
|
|
; FASTINCDEC-LABEL: test_sub_1_cmov_sgt:
|
2017-12-05 01:18:51 +08:00
|
|
|
; FASTINCDEC: # %bb.0: # %entry
|
2017-10-30 22:51:37 +08:00
|
|
|
; FASTINCDEC-NEXT: movl %esi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; FASTINCDEC-NEXT: lock decq (%rdi)
|
|
|
|
; FASTINCDEC-NEXT: cmovll %edx, %eax
|
2017-10-30 22:51:37 +08:00
|
|
|
; FASTINCDEC-NEXT: retq
|
|
|
|
;
|
|
|
|
; SLOWINCDEC-LABEL: test_sub_1_cmov_sgt:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SLOWINCDEC: # %bb.0: # %entry
|
2017-10-30 22:51:37 +08:00
|
|
|
; SLOWINCDEC-NEXT: movl %esi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; SLOWINCDEC-NEXT: lock addq $-1, (%rdi)
|
|
|
|
; SLOWINCDEC-NEXT: cmovll %edx, %eax
|
2017-10-30 22:51:37 +08:00
|
|
|
; SLOWINCDEC-NEXT: retq
|
2016-04-07 10:06:53 +08:00
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw sub i64* %p, i64 1 seq_cst
|
|
|
|
%tmp1 = icmp sgt i64 %tmp0, 0
|
|
|
|
%tmp2 = select i1 %tmp1, i32 %a0, i32 %a1
|
|
|
|
ret i32 %tmp2
|
2016-04-06 04:02:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; FIXME: (setcc slt x, 0) gets combined into shr early.
|
2016-04-07 10:06:53 +08:00
|
|
|
define i8 @test_add_1_setcc_slt(i64* %p) #0 {
|
|
|
|
; CHECK-LABEL: test_add_1_setcc_slt:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0: # %entry
|
2016-04-07 10:06:53 +08:00
|
|
|
; CHECK-NEXT: movl $1, %eax
|
2016-04-06 04:02:44 +08:00
|
|
|
; CHECK-NEXT: lock xaddq %rax, (%rdi)
|
|
|
|
; CHECK-NEXT: shrq $63, %rax
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK-NEXT: # kill: def $al killed $al killed $rax
|
2016-04-06 04:02:44 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
entry:
|
2016-04-07 10:06:53 +08:00
|
|
|
%tmp0 = atomicrmw add i64* %p, i64 1 seq_cst
|
2016-04-06 04:02:44 +08:00
|
|
|
%tmp1 = icmp slt i64 %tmp0, 0
|
|
|
|
%tmp2 = zext i1 %tmp1 to i8
|
|
|
|
ret i8 %tmp2
|
|
|
|
}
|
|
|
|
|
2016-04-07 10:06:53 +08:00
|
|
|
define i8 @test_sub_1_setcc_sgt(i64* %p) #0 {
|
2017-10-30 22:51:37 +08:00
|
|
|
; FASTINCDEC-LABEL: test_sub_1_setcc_sgt:
|
2017-12-05 01:18:51 +08:00
|
|
|
; FASTINCDEC: # %bb.0: # %entry
|
2017-10-30 22:51:37 +08:00
|
|
|
; FASTINCDEC-NEXT: lock decq (%rdi)
|
|
|
|
; FASTINCDEC-NEXT: setge %al
|
|
|
|
; FASTINCDEC-NEXT: retq
|
|
|
|
;
|
|
|
|
; SLOWINCDEC-LABEL: test_sub_1_setcc_sgt:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SLOWINCDEC: # %bb.0: # %entry
|
2017-10-30 22:51:37 +08:00
|
|
|
; SLOWINCDEC-NEXT: lock addq $-1, (%rdi)
|
|
|
|
; SLOWINCDEC-NEXT: setge %al
|
|
|
|
; SLOWINCDEC-NEXT: retq
|
2016-04-06 04:02:44 +08:00
|
|
|
entry:
|
2016-04-07 10:06:53 +08:00
|
|
|
%tmp0 = atomicrmw sub i64* %p, i64 1 seq_cst
|
|
|
|
%tmp1 = icmp sgt i64 %tmp0, 0
|
2016-04-06 04:02:44 +08:00
|
|
|
%tmp2 = zext i1 %tmp1 to i8
|
|
|
|
ret i8 %tmp2
|
|
|
|
}
|
|
|
|
|
2016-04-07 10:06:53 +08:00
|
|
|
define i32 @test_add_1_brcond_sge(i64* %p, i32 %a0, i32 %a1) #0 {
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-LABEL: test_add_1_brcond_sge:
|
2017-12-05 01:18:51 +08:00
|
|
|
; FASTINCDEC: # %bb.0: # %entry
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-NEXT: lock incq (%rdi)
|
|
|
|
; FASTINCDEC-NEXT: jle .LBB6_2
|
2017-12-05 01:18:51 +08:00
|
|
|
; FASTINCDEC-NEXT: # %bb.1: # %t
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-NEXT: movl %esi, %eax
|
|
|
|
; FASTINCDEC-NEXT: retq
|
|
|
|
; FASTINCDEC-NEXT: .LBB6_2: # %f
|
|
|
|
; FASTINCDEC-NEXT: movl %edx, %eax
|
|
|
|
; FASTINCDEC-NEXT: retq
|
|
|
|
;
|
|
|
|
; SLOWINCDEC-LABEL: test_add_1_brcond_sge:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SLOWINCDEC: # %bb.0: # %entry
|
2017-10-30 01:15:09 +08:00
|
|
|
; SLOWINCDEC-NEXT: lock addq $1, (%rdi)
|
|
|
|
; SLOWINCDEC-NEXT: jle .LBB6_2
|
2017-12-05 01:18:51 +08:00
|
|
|
; SLOWINCDEC-NEXT: # %bb.1: # %t
|
2017-10-30 01:15:09 +08:00
|
|
|
; SLOWINCDEC-NEXT: movl %esi, %eax
|
|
|
|
; SLOWINCDEC-NEXT: retq
|
|
|
|
; SLOWINCDEC-NEXT: .LBB6_2: # %f
|
|
|
|
; SLOWINCDEC-NEXT: movl %edx, %eax
|
|
|
|
; SLOWINCDEC-NEXT: retq
|
2016-04-06 04:02:44 +08:00
|
|
|
entry:
|
2016-04-07 10:06:53 +08:00
|
|
|
%tmp0 = atomicrmw add i64* %p, i64 1 seq_cst
|
2016-04-06 04:02:44 +08:00
|
|
|
%tmp1 = icmp sge i64 %tmp0, 0
|
|
|
|
br i1 %tmp1, label %t, label %f
|
|
|
|
t:
|
|
|
|
ret i32 %a0
|
|
|
|
f:
|
|
|
|
ret i32 %a1
|
|
|
|
}
|
|
|
|
|
|
|
|
; Also make sure we don't muck with condition codes that we should ignore.
|
|
|
|
; No need to test unsigned comparisons, as they should all be simplified.
|
|
|
|
|
|
|
|
define i32 @test_add_1_cmov_sle(i64* %p, i32 %a0, i32 %a1) #0 {
|
|
|
|
; CHECK-LABEL: test_add_1_cmov_sle:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0: # %entry
|
2016-04-06 04:02:44 +08:00
|
|
|
; CHECK-NEXT: movl %esi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; CHECK-NEXT: movl $1, %ecx
|
|
|
|
; CHECK-NEXT: lock xaddq %rcx, (%rdi)
|
|
|
|
; CHECK-NEXT: testq %rcx, %rcx
|
|
|
|
; CHECK-NEXT: cmovgl %edx, %eax
|
2016-04-06 04:02:44 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw add i64* %p, i64 1 seq_cst
|
|
|
|
%tmp1 = icmp sle i64 %tmp0, 0
|
|
|
|
%tmp2 = select i1 %tmp1, i32 %a0, i32 %a1
|
|
|
|
ret i32 %tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test_add_1_cmov_sgt(i64* %p, i32 %a0, i32 %a1) #0 {
|
|
|
|
; CHECK-LABEL: test_add_1_cmov_sgt:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0: # %entry
|
2016-04-06 04:02:44 +08:00
|
|
|
; CHECK-NEXT: movl %esi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; CHECK-NEXT: movl $1, %ecx
|
|
|
|
; CHECK-NEXT: lock xaddq %rcx, (%rdi)
|
|
|
|
; CHECK-NEXT: testq %rcx, %rcx
|
|
|
|
; CHECK-NEXT: cmovlel %edx, %eax
|
2016-04-06 04:02:44 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw add i64* %p, i64 1 seq_cst
|
|
|
|
%tmp1 = icmp sgt i64 %tmp0, 0
|
|
|
|
%tmp2 = select i1 %tmp1, i32 %a0, i32 %a1
|
|
|
|
ret i32 %tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test a result being used by more than just the comparison.
|
|
|
|
|
2016-04-07 10:06:53 +08:00
|
|
|
define i8 @test_add_1_setcc_sgt_reuse(i64* %p, i64* %p2) #0 {
|
|
|
|
; CHECK-LABEL: test_add_1_setcc_sgt_reuse:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0: # %entry
|
2016-04-06 04:02:44 +08:00
|
|
|
; CHECK-NEXT: movl $1, %ecx
|
|
|
|
; CHECK-NEXT: lock xaddq %rcx, (%rdi)
|
|
|
|
; CHECK-NEXT: testq %rcx, %rcx
|
2016-04-07 10:06:53 +08:00
|
|
|
; CHECK-NEXT: setg %al
|
2016-04-06 04:02:44 +08:00
|
|
|
; CHECK-NEXT: movq %rcx, (%rsi)
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw add i64* %p, i64 1 seq_cst
|
2016-04-07 10:06:53 +08:00
|
|
|
%tmp1 = icmp sgt i64 %tmp0, 0
|
2016-04-06 04:02:44 +08:00
|
|
|
%tmp2 = zext i1 %tmp1 to i8
|
|
|
|
store i64 %tmp0, i64* %p2
|
|
|
|
ret i8 %tmp2
|
|
|
|
}
|
|
|
|
|
2016-04-07 10:06:53 +08:00
|
|
|
define i8 @test_sub_2_setcc_sgt(i64* %p) #0 {
|
|
|
|
; CHECK-LABEL: test_sub_2_setcc_sgt:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0: # %entry
|
2016-04-07 10:06:53 +08:00
|
|
|
; CHECK-NEXT: movq $-2, %rax
|
|
|
|
; CHECK-NEXT: lock xaddq %rax, (%rdi)
|
|
|
|
; CHECK-NEXT: testq %rax, %rax
|
|
|
|
; CHECK-NEXT: setg %al
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw sub i64* %p, i64 2 seq_cst
|
|
|
|
%tmp1 = icmp sgt i64 %tmp0, 0
|
|
|
|
%tmp2 = zext i1 %tmp1 to i8
|
|
|
|
ret i8 %tmp2
|
|
|
|
}
|
|
|
|
|
[X86] Dont run combineSetCCAtomicArith() when the cmp has multiple uses
We would miscompile the following:
void g(int);
int f(volatile long long *p) {
bool b = __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST) < 0;
g(b ? 12 : 34);
return b ? 56 : 78;
}
into
pushq %rax
lock incq (%rdi)
movl $12, %eax
movl $34, %edi
cmovlel %eax, %edi
callq g(int)
testq %rax, %rax <---- Bad.
movl $56, %ecx
movl $78, %eax
cmovsl %ecx, %eax
popq %rcx
retq
because the code failed to take into account that the cmp has multiple
uses, replaced one of them, and left the other one comparing garbage.
llvm-svn: 291630
2017-01-11 08:49:54 +08:00
|
|
|
define i8 @test_add_1_cmov_cmov(i64* %p, i8* %q) #0 {
|
|
|
|
; TODO: It's possible to use "lock inc" here, but both cmovs need to be updated.
|
|
|
|
; CHECK-LABEL: test_add_1_cmov_cmov:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0: # %entry
|
[X86] Dont run combineSetCCAtomicArith() when the cmp has multiple uses
We would miscompile the following:
void g(int);
int f(volatile long long *p) {
bool b = __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST) < 0;
g(b ? 12 : 34);
return b ? 56 : 78;
}
into
pushq %rax
lock incq (%rdi)
movl $12, %eax
movl $34, %edi
cmovlel %eax, %edi
callq g(int)
testq %rax, %rax <---- Bad.
movl $56, %ecx
movl $78, %eax
cmovsl %ecx, %eax
popq %rcx
retq
because the code failed to take into account that the cmp has multiple
uses, replaced one of them, and left the other one comparing garbage.
llvm-svn: 291630
2017-01-11 08:49:54 +08:00
|
|
|
; CHECK-NEXT: movl $1, %eax
|
|
|
|
; CHECK-NEXT: lock xaddq %rax, (%rdi)
|
|
|
|
; CHECK-NEXT: testq %rax, %rax
|
|
|
|
entry:
|
|
|
|
%add = atomicrmw add i64* %p, i64 1 seq_cst
|
|
|
|
%cmp = icmp slt i64 %add, 0
|
|
|
|
%s1 = select i1 %cmp, i8 12, i8 34
|
|
|
|
store i8 %s1, i8* %q
|
|
|
|
%s2 = select i1 %cmp, i8 56, i8 78
|
|
|
|
ret i8 %s2
|
|
|
|
}
|
|
|
|
|
2017-08-21 16:45:19 +08:00
|
|
|
define i8 @test_sub_1_cmp_1_setcc_eq(i64* %p) #0 {
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-LABEL: test_sub_1_cmp_1_setcc_eq:
|
2017-12-05 01:18:51 +08:00
|
|
|
; FASTINCDEC: # %bb.0: # %entry
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-NEXT: lock decq (%rdi)
|
|
|
|
; FASTINCDEC-NEXT: sete %al
|
|
|
|
; FASTINCDEC-NEXT: retq
|
|
|
|
;
|
|
|
|
; SLOWINCDEC-LABEL: test_sub_1_cmp_1_setcc_eq:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SLOWINCDEC: # %bb.0: # %entry
|
2017-10-30 01:15:09 +08:00
|
|
|
; SLOWINCDEC-NEXT: lock subq $1, (%rdi)
|
|
|
|
; SLOWINCDEC-NEXT: sete %al
|
|
|
|
; SLOWINCDEC-NEXT: retq
|
2017-08-21 16:45:19 +08:00
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw sub i64* %p, i64 1 seq_cst
|
|
|
|
%tmp1 = icmp eq i64 %tmp0, 1
|
|
|
|
%tmp2 = zext i1 %tmp1 to i8
|
|
|
|
ret i8 %tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
define i8 @test_sub_1_cmp_1_setcc_ne(i64* %p) #0 {
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-LABEL: test_sub_1_cmp_1_setcc_ne:
|
2017-12-05 01:18:51 +08:00
|
|
|
; FASTINCDEC: # %bb.0: # %entry
|
2017-10-30 01:15:09 +08:00
|
|
|
; FASTINCDEC-NEXT: lock decq (%rdi)
|
|
|
|
; FASTINCDEC-NEXT: setne %al
|
|
|
|
; FASTINCDEC-NEXT: retq
|
|
|
|
;
|
|
|
|
; SLOWINCDEC-LABEL: test_sub_1_cmp_1_setcc_ne:
|
2017-12-05 01:18:51 +08:00
|
|
|
; SLOWINCDEC: # %bb.0: # %entry
|
2017-10-30 01:15:09 +08:00
|
|
|
; SLOWINCDEC-NEXT: lock subq $1, (%rdi)
|
|
|
|
; SLOWINCDEC-NEXT: setne %al
|
|
|
|
; SLOWINCDEC-NEXT: retq
|
2017-08-21 16:45:19 +08:00
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw sub i64* %p, i64 1 seq_cst
|
|
|
|
%tmp1 = icmp ne i64 %tmp0, 1
|
|
|
|
%tmp2 = zext i1 %tmp1 to i8
|
|
|
|
ret i8 %tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
define i8 @test_sub_1_cmp_1_setcc_ugt(i64* %p) #0 {
|
2017-10-30 22:51:37 +08:00
|
|
|
; CHECK-LABEL: test_sub_1_cmp_1_setcc_ugt:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0: # %entry
|
2017-10-30 22:51:37 +08:00
|
|
|
; CHECK-NEXT: lock subq $1, (%rdi)
|
|
|
|
; CHECK-NEXT: seta %al
|
|
|
|
; CHECK-NEXT: retq
|
2017-08-21 16:45:19 +08:00
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw sub i64* %p, i64 1 seq_cst
|
|
|
|
%tmp1 = icmp ugt i64 %tmp0, 1
|
|
|
|
%tmp2 = zext i1 %tmp1 to i8
|
|
|
|
ret i8 %tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
; FIXME: This test canonicalizes in a way that hides the fact that the
|
|
|
|
; comparison can be folded into the atomic subtract.
|
|
|
|
define i8 @test_sub_1_cmp_1_setcc_sle(i64* %p) #0 {
|
|
|
|
; CHECK-LABEL: test_sub_1_cmp_1_setcc_sle:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0: # %entry
|
2017-08-21 16:45:19 +08:00
|
|
|
; CHECK-NEXT: movq $-1, %rax
|
|
|
|
; CHECK-NEXT: lock xaddq %rax, (%rdi)
|
|
|
|
; CHECK-NEXT: cmpq $2, %rax
|
|
|
|
; CHECK-NEXT: setl %al
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw sub i64* %p, i64 1 seq_cst
|
|
|
|
%tmp1 = icmp sle i64 %tmp0, 1
|
|
|
|
%tmp2 = zext i1 %tmp1 to i8
|
|
|
|
ret i8 %tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
define i8 @test_sub_3_cmp_3_setcc_eq(i64* %p) #0 {
|
|
|
|
; CHECK-LABEL: test_sub_3_cmp_3_setcc_eq:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0: # %entry
|
2017-08-21 16:45:19 +08:00
|
|
|
; CHECK-NEXT: lock subq $3, (%rdi)
|
|
|
|
; CHECK-NEXT: sete %al
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw sub i64* %p, i64 3 seq_cst
|
|
|
|
%tmp1 = icmp eq i64 %tmp0, 3
|
|
|
|
%tmp2 = zext i1 %tmp1 to i8
|
|
|
|
ret i8 %tmp2
|
|
|
|
}
|
|
|
|
|
|
|
|
; FIXME: This test canonicalizes in a way that hides the fact that the
|
|
|
|
; comparison can be folded into the atomic subtract.
|
|
|
|
define i8 @test_sub_3_cmp_3_setcc_uge(i64* %p) #0 {
|
|
|
|
; CHECK-LABEL: test_sub_3_cmp_3_setcc_uge:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0: # %entry
|
2017-08-21 16:45:19 +08:00
|
|
|
; CHECK-NEXT: movq $-3, %rax
|
|
|
|
; CHECK-NEXT: lock xaddq %rax, (%rdi)
|
|
|
|
; CHECK-NEXT: cmpq $2, %rax
|
|
|
|
; CHECK-NEXT: seta %al
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
entry:
|
|
|
|
%tmp0 = atomicrmw sub i64* %p, i64 3 seq_cst
|
|
|
|
%tmp1 = icmp uge i64 %tmp0, 3
|
|
|
|
%tmp2 = zext i1 %tmp1 to i8
|
|
|
|
ret i8 %tmp2
|
|
|
|
}
|
|
|
|
|
2016-04-06 04:02:44 +08:00
|
|
|
attributes #0 = { nounwind }
|