[llvm] [X86] Add (_BitInt(128) & (1 << BitNo)) != 0 test coverage from #147216 (PR #181880)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 17 10:51:49 PST 2026
https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/181880
None
>From b6cbe71953201d53c26eded2a691d1671f03499b Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Tue, 17 Feb 2026 18:50:12 +0000
Subject: [PATCH] [X86] Add (_BitInt(128) & (1 << BitNo)) != 0 test coverage
from #147216
---
...ist-and-by-const-from-shl-in-eqcmp-zero.ll | 152 +++++++++++++++++-
1 file changed, 150 insertions(+), 2 deletions(-)
diff --git a/llvm/test/CodeGen/X86/hoist-and-by-const-from-shl-in-eqcmp-zero.ll b/llvm/test/CodeGen/X86/hoist-and-by-const-from-shl-in-eqcmp-zero.ll
index b45d01e7b3653..19744a897f415 100644
--- a/llvm/test/CodeGen/X86/hoist-and-by-const-from-shl-in-eqcmp-zero.ll
+++ b/llvm/test/CodeGen/X86/hoist-and-by-const-from-shl-in-eqcmp-zero.ll
@@ -1,8 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2 < %s | FileCheck %s --check-prefixes=X86,X86-SSE2,X86-BMI1
; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2,+bmi < %s | FileCheck %s --check-prefixes=X86,X86-SSE2,X86-BMI1
-; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2 < %s | FileCheck %s --check-prefixes=X86,X86-SSE2,X86-BMI2
-; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2,+avx2 < %s | FileCheck %s --check-prefixes=X86,X86-BMI2,AVX2
+; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2 < %s | FileCheck %s --check-prefixes=X86,X86-SSE2,X86-BMI2,X86-BMI2-SSE2
+; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2,+avx2 < %s | FileCheck %s --check-prefixes=X86,X86-BMI2,AVX2,X86-BMI2-AVX2
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+sse,sse2 < %s | FileCheck %s --check-prefixes=X64,X64-SSE2,X64-BMI1
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+sse,sse2,+bmi < %s | FileCheck %s --check-prefixes=X64,X64-SSE2,X64-BMI1
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2 < %s | FileCheck %s --check-prefixes=X64,X64-SSE2,X64-BMI2
@@ -453,6 +453,154 @@ define i1 @scalar_i64_bitsinmiddle_eq(i64 %x, i64 %y) nounwind {
ret i1 %res
}
+define i1 @scalar_i128_lowestbit_eq(i128 %x, i128 %y) nounwind {
+; X86-BMI1-LABEL: scalar_i128_lowestbit_eq:
+; X86-BMI1: # %bb.0:
+; X86-BMI1-NEXT: pushl %edi
+; X86-BMI1-NEXT: pushl %esi
+; X86-BMI1-NEXT: subl $36, %esp
+; X86-BMI1-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-BMI1-NEXT: movss {{.*#+}} xmm0 = [1,0,0,0]
+; X86-BMI1-NEXT: movaps %xmm0, {{[0-9]+}}(%esp)
+; X86-BMI1-NEXT: xorps %xmm0, %xmm0
+; X86-BMI1-NEXT: movaps %xmm0, (%esp)
+; X86-BMI1-NEXT: movl %ecx, %eax
+; X86-BMI1-NEXT: shrb $3, %al
+; X86-BMI1-NEXT: andb $12, %al
+; X86-BMI1-NEXT: negb %al
+; X86-BMI1-NEXT: movsbl %al, %esi
+; X86-BMI1-NEXT: movl 24(%esp,%esi), %edi
+; X86-BMI1-NEXT: movl 28(%esp,%esi), %eax
+; X86-BMI1-NEXT: shldl %cl, %edi, %eax
+; X86-BMI1-NEXT: movl 16(%esp,%esi), %edx
+; X86-BMI1-NEXT: movl 20(%esp,%esi), %esi
+; X86-BMI1-NEXT: shldl %cl, %esi, %edi
+; X86-BMI1-NEXT: shldl %cl, %edx, %esi
+; X86-BMI1-NEXT: # kill: def $cl killed $cl killed $ecx
+; X86-BMI1-NEXT: shll %cl, %edx
+; X86-BMI1-NEXT: andl {{[0-9]+}}(%esp), %edi
+; X86-BMI1-NEXT: andl {{[0-9]+}}(%esp), %eax
+; X86-BMI1-NEXT: andl {{[0-9]+}}(%esp), %edx
+; X86-BMI1-NEXT: orl %edi, %edx
+; X86-BMI1-NEXT: andl {{[0-9]+}}(%esp), %esi
+; X86-BMI1-NEXT: orl %eax, %esi
+; X86-BMI1-NEXT: orl %edx, %esi
+; X86-BMI1-NEXT: sete %al
+; X86-BMI1-NEXT: addl $36, %esp
+; X86-BMI1-NEXT: popl %esi
+; X86-BMI1-NEXT: popl %edi
+; X86-BMI1-NEXT: retl
+;
+; X86-BMI2-SSE2-LABEL: scalar_i128_lowestbit_eq:
+; X86-BMI2-SSE2: # %bb.0:
+; X86-BMI2-SSE2-NEXT: pushl %edi
+; X86-BMI2-SSE2-NEXT: pushl %esi
+; X86-BMI2-SSE2-NEXT: subl $36, %esp
+; X86-BMI2-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-BMI2-SSE2-NEXT: movss {{.*#+}} xmm0 = [1,0,0,0]
+; X86-BMI2-SSE2-NEXT: movaps %xmm0, {{[0-9]+}}(%esp)
+; X86-BMI2-SSE2-NEXT: xorps %xmm0, %xmm0
+; X86-BMI2-SSE2-NEXT: movaps %xmm0, (%esp)
+; X86-BMI2-SSE2-NEXT: movl %ecx, %eax
+; X86-BMI2-SSE2-NEXT: shrb $3, %al
+; X86-BMI2-SSE2-NEXT: andb $12, %al
+; X86-BMI2-SSE2-NEXT: negb %al
+; X86-BMI2-SSE2-NEXT: movsbl %al, %edx
+; X86-BMI2-SSE2-NEXT: movl 24(%esp,%edx), %esi
+; X86-BMI2-SSE2-NEXT: movl 28(%esp,%edx), %eax
+; X86-BMI2-SSE2-NEXT: shldl %cl, %esi, %eax
+; X86-BMI2-SSE2-NEXT: movl 16(%esp,%edx), %edi
+; X86-BMI2-SSE2-NEXT: movl 20(%esp,%edx), %edx
+; X86-BMI2-SSE2-NEXT: shldl %cl, %edx, %esi
+; X86-BMI2-SSE2-NEXT: shldl %cl, %edi, %edx
+; X86-BMI2-SSE2-NEXT: shlxl %ecx, %edi, %ecx
+; X86-BMI2-SSE2-NEXT: andl {{[0-9]+}}(%esp), %esi
+; X86-BMI2-SSE2-NEXT: andl {{[0-9]+}}(%esp), %eax
+; X86-BMI2-SSE2-NEXT: andl {{[0-9]+}}(%esp), %ecx
+; X86-BMI2-SSE2-NEXT: orl %esi, %ecx
+; X86-BMI2-SSE2-NEXT: andl {{[0-9]+}}(%esp), %edx
+; X86-BMI2-SSE2-NEXT: orl %eax, %edx
+; X86-BMI2-SSE2-NEXT: orl %ecx, %edx
+; X86-BMI2-SSE2-NEXT: sete %al
+; X86-BMI2-SSE2-NEXT: addl $36, %esp
+; X86-BMI2-SSE2-NEXT: popl %esi
+; X86-BMI2-SSE2-NEXT: popl %edi
+; X86-BMI2-SSE2-NEXT: retl
+;
+; X86-BMI2-AVX2-LABEL: scalar_i128_lowestbit_eq:
+; X86-BMI2-AVX2: # %bb.0:
+; X86-BMI2-AVX2-NEXT: pushl %edi
+; X86-BMI2-AVX2-NEXT: pushl %esi
+; X86-BMI2-AVX2-NEXT: subl $36, %esp
+; X86-BMI2-AVX2-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-BMI2-AVX2-NEXT: vmovaps {{.*#+}} ymm0 = [0,0,0,0,1,0,0,0]
+; X86-BMI2-AVX2-NEXT: vmovups %ymm0, (%esp)
+; X86-BMI2-AVX2-NEXT: movl %ecx, %eax
+; X86-BMI2-AVX2-NEXT: shrb $3, %al
+; X86-BMI2-AVX2-NEXT: andb $12, %al
+; X86-BMI2-AVX2-NEXT: negb %al
+; X86-BMI2-AVX2-NEXT: movsbl %al, %edx
+; X86-BMI2-AVX2-NEXT: movl 24(%esp,%edx), %esi
+; X86-BMI2-AVX2-NEXT: movl 28(%esp,%edx), %eax
+; X86-BMI2-AVX2-NEXT: shldl %cl, %esi, %eax
+; X86-BMI2-AVX2-NEXT: movl 16(%esp,%edx), %edi
+; X86-BMI2-AVX2-NEXT: movl 20(%esp,%edx), %edx
+; X86-BMI2-AVX2-NEXT: shldl %cl, %edx, %esi
+; X86-BMI2-AVX2-NEXT: shldl %cl, %edi, %edx
+; X86-BMI2-AVX2-NEXT: shlxl %ecx, %edi, %ecx
+; X86-BMI2-AVX2-NEXT: andl {{[0-9]+}}(%esp), %esi
+; X86-BMI2-AVX2-NEXT: andl {{[0-9]+}}(%esp), %eax
+; X86-BMI2-AVX2-NEXT: andl {{[0-9]+}}(%esp), %ecx
+; X86-BMI2-AVX2-NEXT: orl %esi, %ecx
+; X86-BMI2-AVX2-NEXT: andl {{[0-9]+}}(%esp), %edx
+; X86-BMI2-AVX2-NEXT: orl %eax, %edx
+; X86-BMI2-AVX2-NEXT: orl %ecx, %edx
+; X86-BMI2-AVX2-NEXT: sete %al
+; X86-BMI2-AVX2-NEXT: addl $36, %esp
+; X86-BMI2-AVX2-NEXT: popl %esi
+; X86-BMI2-AVX2-NEXT: popl %edi
+; X86-BMI2-AVX2-NEXT: vzeroupper
+; X86-BMI2-AVX2-NEXT: retl
+;
+; X64-BMI1-LABEL: scalar_i128_lowestbit_eq:
+; X64-BMI1: # %bb.0:
+; X64-BMI1-NEXT: movq %rdx, %rcx
+; X64-BMI1-NEXT: xorl %eax, %eax
+; X64-BMI1-NEXT: movl $1, %edx
+; X64-BMI1-NEXT: xorl %r8d, %r8d
+; X64-BMI1-NEXT: shldq %cl, %rdx, %r8
+; X64-BMI1-NEXT: shlq %cl, %rdx
+; X64-BMI1-NEXT: testb $64, %cl
+; X64-BMI1-NEXT: cmovneq %rdx, %r8
+; X64-BMI1-NEXT: cmovneq %rax, %rdx
+; X64-BMI1-NEXT: andq %rsi, %r8
+; X64-BMI1-NEXT: andq %rdi, %rdx
+; X64-BMI1-NEXT: orq %r8, %rdx
+; X64-BMI1-NEXT: sete %al
+; X64-BMI1-NEXT: retq
+;
+; X64-BMI2-LABEL: scalar_i128_lowestbit_eq:
+; X64-BMI2: # %bb.0:
+; X64-BMI2-NEXT: movq %rdx, %rcx
+; X64-BMI2-NEXT: xorl %eax, %eax
+; X64-BMI2-NEXT: movl $1, %edx
+; X64-BMI2-NEXT: xorl %r8d, %r8d
+; X64-BMI2-NEXT: shldq %cl, %rdx, %r8
+; X64-BMI2-NEXT: shlxq %rcx, %rdx, %rdx
+; X64-BMI2-NEXT: testb $64, %cl
+; X64-BMI2-NEXT: cmovneq %rdx, %r8
+; X64-BMI2-NEXT: cmovneq %rax, %rdx
+; X64-BMI2-NEXT: andq %rsi, %r8
+; X64-BMI2-NEXT: andq %rdi, %rdx
+; X64-BMI2-NEXT: orq %r8, %rdx
+; X64-BMI2-NEXT: sete %al
+; X64-BMI2-NEXT: retq
+ %t0 = shl i128 1, %y
+ %t1 = and i128 %t0, %x
+ %res = icmp eq i128 %t1, 0
+ ret i1 %res
+}
+
;------------------------------------------------------------------------------;
; A few trivial vector tests
;------------------------------------------------------------------------------;
More information about the llvm-commits
mailing list