]> granicus.if.org Git - llvm/commitdiff
[AArch64][x86] add tests for ctpop != 1; NFC
authorSanjay Patel <spatel@rotateright.com>
Tue, 25 Jun 2019 13:37:16 +0000 (13:37 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 25 Jun 2019 13:37:16 +0000 (13:37 +0000)
This is the inverted predicate pattern for D63004.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364314 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGen/AArch64/arm64-popcnt.ll
test/CodeGen/X86/ctpop-combine.ll

index 2bc3a6d50ea8106f9329811bd4f3788d7de75195..1b465eb60adde909ae6c20b31daeab59da1e96a2 100644 (file)
@@ -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
index 41a7d93025dd1f9e295338b9f65bf6137ccc40a7..f351637c11308bf4e923898b21e12077bb1a5370 100644 (file)
@@ -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
+}