[llvm] 5a997c1 - [X86] Add count leading ones test coverage based on #96455
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 24 03:40:30 PDT 2024
Author: Simon Pilgrim
Date: 2024-06-24T11:40:17+01:00
New Revision: 5a997c1d83845cd891c1e4662cb7ddb02c1eaecc
URL: https://github.com/llvm/llvm-project/commit/5a997c1d83845cd891c1e4662cb7ddb02c1eaecc
DIFF: https://github.com/llvm/llvm-project/commit/5a997c1d83845cd891c1e4662cb7ddb02c1eaecc.diff
LOG: [X86] Add count leading ones test coverage based on #96455
Added:
llvm/test/CodeGen/X86/ctlo.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/X86/ctlo.ll b/llvm/test/CodeGen/X86/ctlo.ll
new file mode 100644
index 0000000000000..d735ca5d446cd
--- /dev/null
+++ b/llvm/test/CodeGen/X86/ctlo.ll
@@ -0,0 +1,425 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefixes=X86,X86-NOCMOV
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+cmov | FileCheck %s --check-prefixes=X86,X86-CMOV
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+bmi,+lzcnt | FileCheck %s --check-prefix=X86-CLZ
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi,+lzcnt | FileCheck %s --check-prefix=X64-CLZ
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+bmi,+lzcnt,+fast-lzcnt | FileCheck %s --check-prefix=X86-CLZ
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi,+lzcnt,+fast-lzcnt | FileCheck %s --check-prefix=X64-CLZ
+
+declare i8 @llvm.ctlz.i8(i8, i1)
+declare i16 @llvm.ctlz.i16(i16, i1)
+declare i32 @llvm.ctlz.i32(i32, i1)
+declare i64 @llvm.ctlz.i64(i64, i1)
+
+define i8 @ctlo_i8(i8 %x) {
+; X86-LABEL: ctlo_i8:
+; X86: # %bb.0:
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: xorb $-1, %al
+; X86-NEXT: je .LBB0_1
+; X86-NEXT: # %bb.2: # %cond.false
+; X86-NEXT: movzbl %al, %eax
+; X86-NEXT: bsrl %eax, %eax
+; X86-NEXT: xorl $7, %eax
+; X86-NEXT: # kill: def $al killed $al killed $eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB0_1:
+; X86-NEXT: movb $8, %al
+; X86-NEXT: # kill: def $al killed $al killed $eax
+; X86-NEXT: retl
+;
+; X64-LABEL: ctlo_i8:
+; X64: # %bb.0:
+; X64-NEXT: xorb $-1, %dil
+; X64-NEXT: je .LBB0_1
+; X64-NEXT: # %bb.2: # %cond.false
+; X64-NEXT: movzbl %dil, %eax
+; X64-NEXT: bsrl %eax, %eax
+; X64-NEXT: xorl $7, %eax
+; X64-NEXT: # kill: def $al killed $al killed $eax
+; X64-NEXT: retq
+; X64-NEXT: .LBB0_1:
+; X64-NEXT: movb $8, %al
+; X64-NEXT: # kill: def $al killed $al killed $eax
+; X64-NEXT: retq
+;
+; X86-CLZ-LABEL: ctlo_i8:
+; X86-CLZ: # %bb.0:
+; X86-CLZ-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-CLZ-NEXT: notb %al
+; X86-CLZ-NEXT: movzbl %al, %eax
+; X86-CLZ-NEXT: lzcntl %eax, %eax
+; X86-CLZ-NEXT: addl $-24, %eax
+; X86-CLZ-NEXT: # kill: def $al killed $al killed $eax
+; X86-CLZ-NEXT: retl
+;
+; X64-CLZ-LABEL: ctlo_i8:
+; X64-CLZ: # %bb.0:
+; X64-CLZ-NEXT: notb %dil
+; X64-CLZ-NEXT: movzbl %dil, %eax
+; X64-CLZ-NEXT: lzcntl %eax, %eax
+; X64-CLZ-NEXT: addl $-24, %eax
+; X64-CLZ-NEXT: # kill: def $al killed $al killed $eax
+; X64-CLZ-NEXT: retq
+ %tmp1 = xor i8 %x, -1
+ %tmp2 = call i8 @llvm.ctlz.i8( i8 %tmp1, i1 false )
+ ret i8 %tmp2
+}
+
+define i8 @ctlo_i8_undef(i8 %x) {
+; X86-LABEL: ctlo_i8_undef:
+; X86: # %bb.0:
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: notb %al
+; X86-NEXT: movzbl %al, %eax
+; X86-NEXT: bsrl %eax, %eax
+; X86-NEXT: xorl $7, %eax
+; X86-NEXT: # kill: def $al killed $al killed $eax
+; X86-NEXT: retl
+;
+; X64-LABEL: ctlo_i8_undef:
+; X64: # %bb.0:
+; X64-NEXT: notb %dil
+; X64-NEXT: movzbl %dil, %eax
+; X64-NEXT: bsrl %eax, %eax
+; X64-NEXT: xorl $7, %eax
+; X64-NEXT: # kill: def $al killed $al killed $eax
+; X64-NEXT: retq
+;
+; X86-CLZ-LABEL: ctlo_i8_undef:
+; X86-CLZ: # %bb.0:
+; X86-CLZ-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-CLZ-NEXT: notb %al
+; X86-CLZ-NEXT: movzbl %al, %eax
+; X86-CLZ-NEXT: lzcntl %eax, %eax
+; X86-CLZ-NEXT: addl $-24, %eax
+; X86-CLZ-NEXT: # kill: def $al killed $al killed $eax
+; X86-CLZ-NEXT: retl
+;
+; X64-CLZ-LABEL: ctlo_i8_undef:
+; X64-CLZ: # %bb.0:
+; X64-CLZ-NEXT: notb %dil
+; X64-CLZ-NEXT: movzbl %dil, %eax
+; X64-CLZ-NEXT: lzcntl %eax, %eax
+; X64-CLZ-NEXT: addl $-24, %eax
+; X64-CLZ-NEXT: # kill: def $al killed $al killed $eax
+; X64-CLZ-NEXT: retq
+ %tmp1 = xor i8 %x, -1
+ %tmp2 = call i8 @llvm.ctlz.i8( i8 %tmp1, i1 true )
+ ret i8 %tmp2
+}
+
+define i16 @ctlo_i16(i16 %x) {
+; X86-LABEL: ctlo_i16:
+; X86: # %bb.0:
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: xorw $-1, %ax
+; X86-NEXT: je .LBB2_1
+; X86-NEXT: # %bb.2: # %cond.false
+; X86-NEXT: bsrw %ax, %ax
+; X86-NEXT: xorl $15, %eax
+; X86-NEXT: # kill: def $ax killed $ax killed $eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB2_1:
+; X86-NEXT: movw $16, %ax
+; X86-NEXT: # kill: def $ax killed $ax killed $eax
+; X86-NEXT: retl
+;
+; X64-LABEL: ctlo_i16:
+; X64: # %bb.0:
+; X64-NEXT: xorw $-1, %di
+; X64-NEXT: je .LBB2_1
+; X64-NEXT: # %bb.2: # %cond.false
+; X64-NEXT: bsrw %di, %ax
+; X64-NEXT: xorl $15, %eax
+; X64-NEXT: # kill: def $ax killed $ax killed $eax
+; X64-NEXT: retq
+; X64-NEXT: .LBB2_1:
+; X64-NEXT: movw $16, %ax
+; X64-NEXT: # kill: def $ax killed $ax killed $eax
+; X64-NEXT: retq
+;
+; X86-CLZ-LABEL: ctlo_i16:
+; X86-CLZ: # %bb.0:
+; X86-CLZ-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-CLZ-NEXT: notl %eax
+; X86-CLZ-NEXT: lzcntw %ax, %ax
+; X86-CLZ-NEXT: retl
+;
+; X64-CLZ-LABEL: ctlo_i16:
+; X64-CLZ: # %bb.0:
+; X64-CLZ-NEXT: notl %edi
+; X64-CLZ-NEXT: lzcntw %di, %ax
+; X64-CLZ-NEXT: retq
+ %tmp1 = xor i16 %x, -1
+ %tmp2 = call i16 @llvm.ctlz.i16( i16 %tmp1, i1 false )
+ ret i16 %tmp2
+}
+
+define i16 @ctlo_i16_undef(i16 %x) {
+; X86-LABEL: ctlo_i16_undef:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: notl %eax
+; X86-NEXT: bsrw %ax, %ax
+; X86-NEXT: xorl $15, %eax
+; X86-NEXT: # kill: def $ax killed $ax killed $eax
+; X86-NEXT: retl
+;
+; X64-LABEL: ctlo_i16_undef:
+; X64: # %bb.0:
+; X64-NEXT: notl %edi
+; X64-NEXT: bsrw %di, %ax
+; X64-NEXT: xorl $15, %eax
+; X64-NEXT: # kill: def $ax killed $ax killed $eax
+; X64-NEXT: retq
+;
+; X86-CLZ-LABEL: ctlo_i16_undef:
+; X86-CLZ: # %bb.0:
+; X86-CLZ-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-CLZ-NEXT: notl %eax
+; X86-CLZ-NEXT: lzcntw %ax, %ax
+; X86-CLZ-NEXT: retl
+;
+; X64-CLZ-LABEL: ctlo_i16_undef:
+; X64-CLZ: # %bb.0:
+; X64-CLZ-NEXT: notl %edi
+; X64-CLZ-NEXT: lzcntw %di, %ax
+; X64-CLZ-NEXT: retq
+ %tmp1 = xor i16 %x, -1
+ %tmp2 = call i16 @llvm.ctlz.i16( i16 %tmp1, i1 true )
+ ret i16 %tmp2
+}
+
+define i32 @ctlo_i32(i32 %x) {
+; X86-LABEL: ctlo_i32:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: xorl $-1, %eax
+; X86-NEXT: je .LBB4_1
+; X86-NEXT: # %bb.2: # %cond.false
+; X86-NEXT: bsrl %eax, %eax
+; X86-NEXT: xorl $31, %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB4_1:
+; X86-NEXT: movl $32, %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: ctlo_i32:
+; X64: # %bb.0:
+; X64-NEXT: xorl $-1, %edi
+; X64-NEXT: je .LBB4_1
+; X64-NEXT: # %bb.2: # %cond.false
+; X64-NEXT: bsrl %edi, %eax
+; X64-NEXT: xorl $31, %eax
+; X64-NEXT: retq
+; X64-NEXT: .LBB4_1:
+; X64-NEXT: movl $32, %eax
+; X64-NEXT: retq
+;
+; X86-CLZ-LABEL: ctlo_i32:
+; X86-CLZ: # %bb.0:
+; X86-CLZ-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-CLZ-NEXT: notl %eax
+; X86-CLZ-NEXT: lzcntl %eax, %eax
+; X86-CLZ-NEXT: retl
+;
+; X64-CLZ-LABEL: ctlo_i32:
+; X64-CLZ: # %bb.0:
+; X64-CLZ-NEXT: notl %edi
+; X64-CLZ-NEXT: lzcntl %edi, %eax
+; X64-CLZ-NEXT: retq
+ %tmp1 = xor i32 %x, -1
+ %tmp2 = call i32 @llvm.ctlz.i32( i32 %tmp1, i1 false )
+ ret i32 %tmp2
+}
+
+define i32 @ctlo_i32_undef(i32 %x) {
+; X86-LABEL: ctlo_i32_undef:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: notl %eax
+; X86-NEXT: bsrl %eax, %eax
+; X86-NEXT: xorl $31, %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: ctlo_i32_undef:
+; X64: # %bb.0:
+; X64-NEXT: notl %edi
+; X64-NEXT: bsrl %edi, %eax
+; X64-NEXT: xorl $31, %eax
+; X64-NEXT: retq
+;
+; X86-CLZ-LABEL: ctlo_i32_undef:
+; X86-CLZ: # %bb.0:
+; X86-CLZ-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-CLZ-NEXT: notl %eax
+; X86-CLZ-NEXT: lzcntl %eax, %eax
+; X86-CLZ-NEXT: retl
+;
+; X64-CLZ-LABEL: ctlo_i32_undef:
+; X64-CLZ: # %bb.0:
+; X64-CLZ-NEXT: notl %edi
+; X64-CLZ-NEXT: lzcntl %edi, %eax
+; X64-CLZ-NEXT: retq
+ %tmp1 = xor i32 %x, -1
+ %tmp2 = call i32 @llvm.ctlz.i32( i32 %tmp1, i1 true )
+ ret i32 %tmp2
+}
+
+define i64 @ctlo_i64(i64 %x) {
+; X86-NOCMOV-LABEL: ctlo_i64:
+; X86-NOCMOV: # %bb.0:
+; X86-NOCMOV-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NOCMOV-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NOCMOV-NEXT: notl %ecx
+; X86-NOCMOV-NEXT: notl %eax
+; X86-NOCMOV-NEXT: bsrl %eax, %edx
+; X86-NOCMOV-NEXT: movl $63, %eax
+; X86-NOCMOV-NEXT: je .LBB6_2
+; X86-NOCMOV-NEXT: # %bb.1:
+; X86-NOCMOV-NEXT: movl %edx, %eax
+; X86-NOCMOV-NEXT: .LBB6_2:
+; X86-NOCMOV-NEXT: testl %ecx, %ecx
+; X86-NOCMOV-NEXT: jne .LBB6_3
+; X86-NOCMOV-NEXT: # %bb.4:
+; X86-NOCMOV-NEXT: xorl $31, %eax
+; X86-NOCMOV-NEXT: addl $32, %eax
+; X86-NOCMOV-NEXT: xorl %edx, %edx
+; X86-NOCMOV-NEXT: retl
+; X86-NOCMOV-NEXT: .LBB6_3:
+; X86-NOCMOV-NEXT: bsrl %ecx, %eax
+; X86-NOCMOV-NEXT: xorl $31, %eax
+; X86-NOCMOV-NEXT: xorl %edx, %edx
+; X86-NOCMOV-NEXT: retl
+;
+; X86-CMOV-LABEL: ctlo_i64:
+; X86-CMOV: # %bb.0:
+; X86-CMOV-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-CMOV-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-CMOV-NEXT: notl %ecx
+; X86-CMOV-NEXT: notl %eax
+; X86-CMOV-NEXT: bsrl %eax, %eax
+; X86-CMOV-NEXT: movl $63, %edx
+; X86-CMOV-NEXT: cmovnel %eax, %edx
+; X86-CMOV-NEXT: xorl $31, %edx
+; X86-CMOV-NEXT: addl $32, %edx
+; X86-CMOV-NEXT: bsrl %ecx, %eax
+; X86-CMOV-NEXT: xorl $31, %eax
+; X86-CMOV-NEXT: testl %ecx, %ecx
+; X86-CMOV-NEXT: cmovel %edx, %eax
+; X86-CMOV-NEXT: xorl %edx, %edx
+; X86-CMOV-NEXT: retl
+;
+; X64-LABEL: ctlo_i64:
+; X64: # %bb.0:
+; X64-NEXT: xorq $-1, %rdi
+; X64-NEXT: je .LBB6_1
+; X64-NEXT: # %bb.2: # %cond.false
+; X64-NEXT: bsrq %rdi, %rax
+; X64-NEXT: xorq $63, %rax
+; X64-NEXT: retq
+; X64-NEXT: .LBB6_1:
+; X64-NEXT: movl $64, %eax
+; X64-NEXT: retq
+;
+; X86-CLZ-LABEL: ctlo_i64:
+; X86-CLZ: # %bb.0:
+; X86-CLZ-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-CLZ-NEXT: notl %eax
+; X86-CLZ-NEXT: testl %eax, %eax
+; X86-CLZ-NEXT: jne .LBB6_1
+; X86-CLZ-NEXT: # %bb.2:
+; X86-CLZ-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-CLZ-NEXT: notl %eax
+; X86-CLZ-NEXT: lzcntl %eax, %eax
+; X86-CLZ-NEXT: addl $32, %eax
+; X86-CLZ-NEXT: xorl %edx, %edx
+; X86-CLZ-NEXT: retl
+; X86-CLZ-NEXT: .LBB6_1:
+; X86-CLZ-NEXT: lzcntl %eax, %eax
+; X86-CLZ-NEXT: xorl %edx, %edx
+; X86-CLZ-NEXT: retl
+;
+; X64-CLZ-LABEL: ctlo_i64:
+; X64-CLZ: # %bb.0:
+; X64-CLZ-NEXT: notq %rdi
+; X64-CLZ-NEXT: lzcntq %rdi, %rax
+; X64-CLZ-NEXT: retq
+ %tmp1 = xor i64 %x, -1
+ %tmp2 = call i64 @llvm.ctlz.i64( i64 %tmp1, i1 false )
+ ret i64 %tmp2
+}
+
+define i64 @ctlo_i64_undef(i64 %x) {
+; X86-NOCMOV-LABEL: ctlo_i64_undef:
+; X86-NOCMOV: # %bb.0:
+; X86-NOCMOV-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NOCMOV-NEXT: notl %eax
+; X86-NOCMOV-NEXT: testl %eax, %eax
+; X86-NOCMOV-NEXT: jne .LBB7_1
+; X86-NOCMOV-NEXT: # %bb.2:
+; X86-NOCMOV-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NOCMOV-NEXT: notl %eax
+; X86-NOCMOV-NEXT: bsrl %eax, %eax
+; X86-NOCMOV-NEXT: xorl $31, %eax
+; X86-NOCMOV-NEXT: addl $32, %eax
+; X86-NOCMOV-NEXT: xorl %edx, %edx
+; X86-NOCMOV-NEXT: retl
+; X86-NOCMOV-NEXT: .LBB7_1:
+; X86-NOCMOV-NEXT: bsrl %eax, %eax
+; X86-NOCMOV-NEXT: xorl $31, %eax
+; X86-NOCMOV-NEXT: xorl %edx, %edx
+; X86-NOCMOV-NEXT: retl
+;
+; X86-CMOV-LABEL: ctlo_i64_undef:
+; X86-CMOV: # %bb.0:
+; X86-CMOV-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-CMOV-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-CMOV-NEXT: notl %eax
+; X86-CMOV-NEXT: notl %ecx
+; X86-CMOV-NEXT: bsrl %ecx, %edx
+; X86-CMOV-NEXT: xorl $31, %edx
+; X86-CMOV-NEXT: bsrl %eax, %eax
+; X86-CMOV-NEXT: xorl $31, %eax
+; X86-CMOV-NEXT: addl $32, %eax
+; X86-CMOV-NEXT: testl %ecx, %ecx
+; X86-CMOV-NEXT: cmovnel %edx, %eax
+; X86-CMOV-NEXT: xorl %edx, %edx
+; X86-CMOV-NEXT: retl
+;
+; X64-LABEL: ctlo_i64_undef:
+; X64: # %bb.0:
+; X64-NEXT: notq %rdi
+; X64-NEXT: bsrq %rdi, %rax
+; X64-NEXT: xorq $63, %rax
+; X64-NEXT: retq
+;
+; X86-CLZ-LABEL: ctlo_i64_undef:
+; X86-CLZ: # %bb.0:
+; X86-CLZ-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-CLZ-NEXT: notl %eax
+; X86-CLZ-NEXT: testl %eax, %eax
+; X86-CLZ-NEXT: jne .LBB7_1
+; X86-CLZ-NEXT: # %bb.2:
+; X86-CLZ-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-CLZ-NEXT: notl %eax
+; X86-CLZ-NEXT: lzcntl %eax, %eax
+; X86-CLZ-NEXT: addl $32, %eax
+; X86-CLZ-NEXT: xorl %edx, %edx
+; X86-CLZ-NEXT: retl
+; X86-CLZ-NEXT: .LBB7_1:
+; X86-CLZ-NEXT: lzcntl %eax, %eax
+; X86-CLZ-NEXT: xorl %edx, %edx
+; X86-CLZ-NEXT: retl
+;
+; X64-CLZ-LABEL: ctlo_i64_undef:
+; X64-CLZ: # %bb.0:
+; X64-CLZ-NEXT: notq %rdi
+; X64-CLZ-NEXT: lzcntq %rdi, %rax
+; X64-CLZ-NEXT: retq
+ %tmp1 = xor i64 %x, -1
+ %tmp2 = call i64 @llvm.ctlz.i64( i64 %tmp1, i1 true )
+ ret i64 %tmp2
+}
More information about the llvm-commits
mailing list