diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2019-06-25 14:46:52 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2019-06-25 14:46:52 +0000 |
| commit | 685c5cbc654fe6edca15811d1fc2c6b5832027de (patch) | |
| tree | 7da9aca9805145b078fbf5eb1a0b3a5acaa3431c /llvm/test/CodeGen/X86/ctpop-combine.ll | |
| parent | f0a665afca70c924e7d582242c01f1835d601a65 (diff) | |
| download | bcm5719-llvm-685c5cbc654fe6edca15811d1fc2c6b5832027de.tar.gz bcm5719-llvm-685c5cbc654fe6edca15811d1fc2c6b5832027de.zip | |
[SDAG] expand ctpop != 1
Change the generic ctpop expansion to more efficiently handle a
check for not-a-power-of-two value:
(ctpop x) != 1 --> (x == 0) || ((x & x-1) != 0)
This is the inverted predicate sibling pattern that was added with:
D63004
This should have been done before I changed IR canonicalization to
favor this form with:
rL364246
...so if this requires revert/changing, the earlier commit may also
need to modified.
llvm-svn: 364319
Diffstat (limited to 'llvm/test/CodeGen/X86/ctpop-combine.ll')
| -rw-r--r-- | llvm/test/CodeGen/X86/ctpop-combine.ll | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/llvm/test/CodeGen/X86/ctpop-combine.ll b/llvm/test/CodeGen/X86/ctpop-combine.ll index f351637c113..cdef5771f2c 100644 --- a/llvm/test/CodeGen/X86/ctpop-combine.ll +++ b/llvm/test/CodeGen/X86/ctpop-combine.ll @@ -147,28 +147,13 @@ define i32 @ctpop_ne_one(i64 %x) nounwind readnone { ; ; 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: leaq -1(%rdi), %rax +; NO-POPCOUNT-NEXT: testq %rax, %rdi ; NO-POPCOUNT-NEXT: setne %al +; NO-POPCOUNT-NEXT: testq %rdi, %rdi +; NO-POPCOUNT-NEXT: sete %cl +; NO-POPCOUNT-NEXT: orb %al, %cl +; NO-POPCOUNT-NEXT: movzbl %cl, %eax ; NO-POPCOUNT-NEXT: retq %count = tail call i64 @llvm.ctpop.i64(i64 %x) %cmp = icmp ne i64 %count, 1 |

