forked from OSchip/llvm-project
[AArch64][x86] add tests for ctpop != 1; NFC
This is the inverted predicate pattern for D63004. llvm-svn: 364314
This commit is contained in:
parent
aae4b68703
commit
0baacea2c7
|
@ -199,6 +199,40 @@ define i32 @ctpop_eq_one(i64 %x) nounwind readnone {
|
|||
ret i32 %conv
|
||||
}
|
||||
|
||||
define i32 @ctpop_ne_one(i64 %x) nounwind readnone {
|
||||
; CHECK-LABEL: ctpop_ne_one:
|
||||
; CHECK: // %bb.0:
|
||||
; CHECK-NEXT: fmov d0, x0
|
||||
; CHECK-NEXT: cnt.8b v0, v0
|
||||
; CHECK-NEXT: uaddlv.8b h0, v0
|
||||
; CHECK-NEXT: fmov w8, s0
|
||||
; CHECK-NEXT: cmp x8, #1 // =1
|
||||
; CHECK-NEXT: cset w0, ne
|
||||
; CHECK-NEXT: ret
|
||||
;
|
||||
; CHECK-NONEON-LABEL: ctpop_ne_one:
|
||||
; CHECK-NONEON: // %bb.0:
|
||||
; CHECK-NONEON-NEXT: lsr x8, x0, #1
|
||||
; CHECK-NONEON-NEXT: and x8, x8, #0x5555555555555555
|
||||
; CHECK-NONEON-NEXT: sub x8, x0, x8
|
||||
; CHECK-NONEON-NEXT: and x9, x8, #0x3333333333333333
|
||||
; CHECK-NONEON-NEXT: lsr x8, x8, #2
|
||||
; CHECK-NONEON-NEXT: and x8, x8, #0x3333333333333333
|
||||
; CHECK-NONEON-NEXT: add x8, x9, x8
|
||||
; CHECK-NONEON-NEXT: add x8, x8, x8, lsr #4
|
||||
; CHECK-NONEON-NEXT: and x8, x8, #0xf0f0f0f0f0f0f0f
|
||||
; CHECK-NONEON-NEXT: mov x9, #72340172838076673
|
||||
; CHECK-NONEON-NEXT: mul x8, x8, x9
|
||||
; CHECK-NONEON-NEXT: lsr x8, x8, #56
|
||||
; CHECK-NONEON-NEXT: cmp x8, #1 // =1
|
||||
; CHECK-NONEON-NEXT: cset w0, ne
|
||||
; CHECK-NONEON-NEXT: ret
|
||||
%count = tail call i64 @llvm.ctpop.i64(i64 %x)
|
||||
%cmp = icmp ne i64 %count, 1
|
||||
%conv = zext i1 %cmp to i32
|
||||
ret i32 %conv
|
||||
}
|
||||
|
||||
|
||||
declare i32 @llvm.ctpop.i32(i32) nounwind readnone
|
||||
declare i64 @llvm.ctpop.i64(i64) nounwind readnone
|
||||
|
|
|
@ -135,3 +135,43 @@ define i32 @ctpop_eq_one(i64 %x) nounwind readnone {
|
|||
%conv = zext i1 %cmp to i32
|
||||
ret i32 %conv
|
||||
}
|
||||
|
||||
define i32 @ctpop_ne_one(i64 %x) nounwind readnone {
|
||||
; POPCOUNT-LABEL: ctpop_ne_one:
|
||||
; POPCOUNT: # %bb.0:
|
||||
; POPCOUNT-NEXT: popcntq %rdi, %rcx
|
||||
; POPCOUNT-NEXT: xorl %eax, %eax
|
||||
; POPCOUNT-NEXT: cmpq $1, %rcx
|
||||
; POPCOUNT-NEXT: setne %al
|
||||
; POPCOUNT-NEXT: retq
|
||||
;
|
||||
; NO-POPCOUNT-LABEL: ctpop_ne_one:
|
||||
; NO-POPCOUNT: # %bb.0:
|
||||
; NO-POPCOUNT-NEXT: movq %rdi, %rax
|
||||
; NO-POPCOUNT-NEXT: shrq %rax
|
||||
; NO-POPCOUNT-NEXT: movabsq $6148914691236517205, %rcx # imm = 0x5555555555555555
|
||||
; NO-POPCOUNT-NEXT: andq %rax, %rcx
|
||||
; NO-POPCOUNT-NEXT: subq %rcx, %rdi
|
||||
; NO-POPCOUNT-NEXT: movabsq $3689348814741910323, %rax # imm = 0x3333333333333333
|
||||
; NO-POPCOUNT-NEXT: movq %rdi, %rcx
|
||||
; NO-POPCOUNT-NEXT: andq %rax, %rcx
|
||||
; NO-POPCOUNT-NEXT: shrq $2, %rdi
|
||||
; NO-POPCOUNT-NEXT: andq %rax, %rdi
|
||||
; NO-POPCOUNT-NEXT: addq %rcx, %rdi
|
||||
; NO-POPCOUNT-NEXT: movq %rdi, %rax
|
||||
; NO-POPCOUNT-NEXT: shrq $4, %rax
|
||||
; NO-POPCOUNT-NEXT: addq %rdi, %rax
|
||||
; NO-POPCOUNT-NEXT: movabsq $1085102592571150095, %rcx # imm = 0xF0F0F0F0F0F0F0F
|
||||
; NO-POPCOUNT-NEXT: andq %rax, %rcx
|
||||
; NO-POPCOUNT-NEXT: movabsq $72340172838076673, %rdx # imm = 0x101010101010101
|
||||
; NO-POPCOUNT-NEXT: imulq %rcx, %rdx
|
||||
; NO-POPCOUNT-NEXT: shrq $56, %rdx
|
||||
; NO-POPCOUNT-NEXT: xorl %eax, %eax
|
||||
; NO-POPCOUNT-NEXT: cmpq $1, %rdx
|
||||
; NO-POPCOUNT-NEXT: setne %al
|
||||
; NO-POPCOUNT-NEXT: retq
|
||||
%count = tail call i64 @llvm.ctpop.i64(i64 %x)
|
||||
%cmp = icmp ne i64 %count, 1
|
||||
%conv = zext i1 %cmp to i32
|
||||
ret i32 %conv
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue