[llvm] r349450 - [X86] Add test cases to show isel failing to match BMI blsmsk/blsi/blsr when the flag result is used.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 18 00:26:01 PST 2018
Author: ctopper
Date: Tue Dec 18 00:26:01 2018
New Revision: 349450
URL: http://llvm.org/viewvc/llvm-project?rev=349450&view=rev
Log:
[X86] Add test cases to show isel failing to match BMI blsmsk/blsi/blsr when the flag result is used.
A similar things happen to TBM instructions which we already have tests for.
Modified:
llvm/trunk/test/CodeGen/X86/bmi.ll
Modified: llvm/trunk/test/CodeGen/X86/bmi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/bmi.ll?rev=349450&r1=349449&r2=349450&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/bmi.ll (original)
+++ llvm/trunk/test/CodeGen/X86/bmi.ll Tue Dec 18 00:26:01 2018
@@ -1,9 +1,9 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+bmi | FileCheck %s --check-prefixes=CHECK,X86,X86-SLOW-BEXTR
-; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+bmi,+bmi2 | FileCheck %s --check-prefixes=CHECK,X86,X86-SLOW-BEXTR
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+cmov,+bmi | FileCheck %s --check-prefixes=CHECK,X86,X86-SLOW-BEXTR
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+cmov,+bmi,+bmi2 | FileCheck %s --check-prefixes=CHECK,X86,X86-SLOW-BEXTR
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi | FileCheck %s --check-prefixes=CHECK,X64,X64-SLOW-BEXTR
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi,+bmi2 | FileCheck %s --check-prefixes=CHECK,X64,X64-SLOW-BEXTR
-; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+bmi,+fast-bextr | FileCheck %s --check-prefixes=CHECK,X86,X86-FAST-BEXTR
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+cmov,+bmi,+fast-bextr | FileCheck %s --check-prefixes=CHECK,X86,X86-FAST-BEXTR
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi,+fast-bextr | FileCheck %s --check-prefixes=CHECK,X64,X64-FAST-BEXTR
define i32 @andn32(i32 %x, i32 %y) {
@@ -494,6 +494,56 @@ define i32 @blsi32_load(i32* %x) {
ret i32 %tmp2
}
+define i32 @blsi32_z(i32 %a, i32 %b) nounwind {
+; X86-LABEL: blsi32_z:
+; X86: # %bb.0:
+; X86-NEXT: blsil {{[0-9]+}}(%esp), %eax
+; X86-NEXT: jne .LBB24_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: .LBB24_2:
+; X86-NEXT: retl
+;
+; X64-LABEL: blsi32_z:
+; X64: # %bb.0:
+; X64-NEXT: blsil %edi, %eax
+; X64-NEXT: cmovel %esi, %eax
+; X64-NEXT: retq
+ %t0 = sub i32 0, %a
+ %t1 = and i32 %t0, %a
+ %t2 = icmp eq i32 %t1, 0
+ %t3 = select i1 %t2, i32 %b, i32 %t1
+ ret i32 %t3
+}
+
+define i32 @blsi32_z2(i32 %a, i32 %b, i32 %c) nounwind {
+; X86-LABEL: blsi32_z2:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl %eax, %ecx
+; X86-NEXT: negl %ecx
+; X86-NEXT: testl %eax, %ecx
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: cmovel %eax, %ecx
+; X86-NEXT: movl (%ecx), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: blsi32_z2:
+; X64: # %bb.0:
+; X64-NEXT: movl %esi, %eax
+; X64-NEXT: movl %edi, %ecx
+; X64-NEXT: negl %ecx
+; X64-NEXT: testl %edi, %ecx
+; X64-NEXT: cmovnel %edx, %eax
+; X64-NEXT: retq
+ %t0 = sub i32 0, %a
+ %t1 = and i32 %t0, %a
+ %t2 = icmp eq i32 %t1, 0
+ %t3 = select i1 %t2, i32 %b, i32 %c
+ ret i32 %t3
+}
+
define i64 @blsi64(i64 %x) {
; X86-LABEL: blsi64:
; X86: # %bb.0:
@@ -521,6 +571,76 @@ define i64 @blsi64(i64 %x) {
ret i64 %tmp2
}
+define i64 @blsi64_z(i64 %a, i64 %b) nounwind {
+; X86-LABEL: blsi64_z:
+; X86: # %bb.0:
+; X86-NEXT: pushl %esi
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: xorl %edx, %edx
+; X86-NEXT: movl %ecx, %eax
+; X86-NEXT: negl %eax
+; X86-NEXT: sbbl %esi, %edx
+; X86-NEXT: andl %esi, %edx
+; X86-NEXT: andl %ecx, %eax
+; X86-NEXT: movl %eax, %ecx
+; X86-NEXT: orl %edx, %ecx
+; X86-NEXT: jne .LBB27_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: .LBB27_2:
+; X86-NEXT: popl %esi
+; X86-NEXT: retl
+;
+; X64-LABEL: blsi64_z:
+; X64: # %bb.0:
+; X64-NEXT: blsiq %rdi, %rax
+; X64-NEXT: cmoveq %rsi, %rax
+; X64-NEXT: retq
+ %t0 = sub i64 0, %a
+ %t1 = and i64 %t0, %a
+ %t2 = icmp eq i64 %t1, 0
+ %t3 = select i1 %t2, i64 %b, i64 %t1
+ ret i64 %t3
+}
+
+define i64 @blsi64_z2(i64 %a, i64 %b, i64 %c) nounwind {
+; X86-LABEL: blsi64_z2:
+; X86: # %bb.0:
+; X86-NEXT: pushl %esi
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: xorl %edx, %edx
+; X86-NEXT: movl %eax, %esi
+; X86-NEXT: negl %esi
+; X86-NEXT: sbbl %ecx, %edx
+; X86-NEXT: andl %ecx, %edx
+; X86-NEXT: andl %eax, %esi
+; X86-NEXT: orl %edx, %esi
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: cmovel %eax, %ecx
+; X86-NEXT: movl (%ecx), %eax
+; X86-NEXT: movl 4(%ecx), %edx
+; X86-NEXT: popl %esi
+; X86-NEXT: retl
+;
+; X64-LABEL: blsi64_z2:
+; X64: # %bb.0:
+; X64-NEXT: movq %rsi, %rax
+; X64-NEXT: movq %rdi, %rcx
+; X64-NEXT: negq %rcx
+; X64-NEXT: testq %rdi, %rcx
+; X64-NEXT: cmovneq %rdx, %rax
+; X64-NEXT: retq
+ %t0 = sub i64 0, %a
+ %t1 = and i64 %t0, %a
+ %t2 = icmp eq i64 %t1, 0
+ %t3 = select i1 %t2, i64 %b, i64 %c
+ ret i64 %t3
+}
+
define i32 @blsmsk32(i32 %x) {
; X86-LABEL: blsmsk32:
; X86: # %bb.0:
@@ -553,6 +673,55 @@ define i32 @blsmsk32_load(i32* %x) {
ret i32 %tmp2
}
+define i32 @blsmsk32_z(i32 %a, i32 %b) nounwind {
+; X86-LABEL: blsmsk32_z:
+; X86: # %bb.0:
+; X86-NEXT: blsmskl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: jne .LBB31_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: .LBB31_2:
+; X86-NEXT: retl
+;
+; X64-LABEL: blsmsk32_z:
+; X64: # %bb.0:
+; X64-NEXT: blsmskl %edi, %eax
+; X64-NEXT: cmovel %esi, %eax
+; X64-NEXT: retq
+ %t0 = sub i32 %a, 1
+ %t1 = xor i32 %t0, %a
+ %t2 = icmp eq i32 %t1, 0
+ %t3 = select i1 %t2, i32 %b, i32 %t1
+ ret i32 %t3
+}
+
+define i32 @blsmsk32_z2(i32 %a, i32 %b, i32 %c) nounwind {
+; X86-LABEL: blsmsk32_z2:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: leal -1(%eax), %ecx
+; X86-NEXT: xorl %eax, %ecx
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: cmovel %eax, %ecx
+; X86-NEXT: movl (%ecx), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: blsmsk32_z2:
+; X64: # %bb.0:
+; X64-NEXT: movl %esi, %eax
+; X64-NEXT: # kill: def $edi killed $edi def $rdi
+; X64-NEXT: leal -1(%rdi), %ecx
+; X64-NEXT: xorl %edi, %ecx
+; X64-NEXT: cmovnel %edx, %eax
+; X64-NEXT: retq
+ %t0 = sub i32 %a, 1
+ %t1 = xor i32 %t0, %a
+ %t2 = icmp eq i32 %t1, 0
+ %t3 = select i1 %t2, i32 %b, i32 %c
+ ret i32 %t3
+}
+
define i64 @blsmsk64(i64 %x) {
; X86-LABEL: blsmsk64:
; X86: # %bb.0:
@@ -580,6 +749,75 @@ define i64 @blsmsk64(i64 %x) {
ret i64 %tmp2
}
+define i64 @blsmsk64_z(i64 %a, i64 %b) nounwind {
+; X86-LABEL: blsmsk64_z:
+; X86: # %bb.0:
+; X86-NEXT: pushl %esi
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: movl %ecx, %eax
+; X86-NEXT: addl $-1, %eax
+; X86-NEXT: movl %esi, %edx
+; X86-NEXT: adcl $-1, %edx
+; X86-NEXT: xorl %ecx, %eax
+; X86-NEXT: xorl %esi, %edx
+; X86-NEXT: movl %eax, %ecx
+; X86-NEXT: orl %edx, %ecx
+; X86-NEXT: jne .LBB34_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: .LBB34_2:
+; X86-NEXT: popl %esi
+; X86-NEXT: retl
+;
+; X64-LABEL: blsmsk64_z:
+; X64: # %bb.0:
+; X64-NEXT: blsmskq %rdi, %rax
+; X64-NEXT: cmoveq %rsi, %rax
+; X64-NEXT: retq
+ %t0 = sub i64 %a, 1
+ %t1 = xor i64 %t0, %a
+ %t2 = icmp eq i64 %t1, 0
+ %t3 = select i1 %t2, i64 %b, i64 %t1
+ ret i64 %t3
+}
+
+define i64 @blsmsk64_z2(i64 %a, i64 %b, i64 %c) nounwind {
+; X86-LABEL: blsmsk64_z2:
+; X86: # %bb.0:
+; X86-NEXT: pushl %esi
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %eax, %edx
+; X86-NEXT: addl $-1, %edx
+; X86-NEXT: movl %ecx, %esi
+; X86-NEXT: adcl $-1, %esi
+; X86-NEXT: xorl %eax, %edx
+; X86-NEXT: xorl %ecx, %esi
+; X86-NEXT: orl %edx, %esi
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: cmovel %eax, %ecx
+; X86-NEXT: movl (%ecx), %eax
+; X86-NEXT: movl 4(%ecx), %edx
+; X86-NEXT: popl %esi
+; X86-NEXT: retl
+;
+; X64-LABEL: blsmsk64_z2:
+; X64: # %bb.0:
+; X64-NEXT: movq %rsi, %rax
+; X64-NEXT: leaq -1(%rdi), %rcx
+; X64-NEXT: xorq %rdi, %rcx
+; X64-NEXT: cmovneq %rdx, %rax
+; X64-NEXT: retq
+ %t0 = sub i64 %a, 1
+ %t1 = xor i64 %t0, %a
+ %t2 = icmp eq i64 %t1, 0
+ %t3 = select i1 %t2, i64 %b, i64 %c
+ ret i64 %t3
+}
+
define i32 @blsr32(i32 %x) {
; X86-LABEL: blsr32:
; X86: # %bb.0:
@@ -612,6 +850,55 @@ define i32 @blsr32_load(i32* %x) {
ret i32 %tmp2
}
+define i32 @blsr32_z(i32 %a, i32 %b) nounwind {
+; X86-LABEL: blsr32_z:
+; X86: # %bb.0:
+; X86-NEXT: blsrl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: jne .LBB38_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: .LBB38_2:
+; X86-NEXT: retl
+;
+; X64-LABEL: blsr32_z:
+; X64: # %bb.0:
+; X64-NEXT: blsrl %edi, %eax
+; X64-NEXT: cmovel %esi, %eax
+; X64-NEXT: retq
+ %t0 = sub i32 %a, 1
+ %t1 = and i32 %t0, %a
+ %t2 = icmp eq i32 %t1, 0
+ %t3 = select i1 %t2, i32 %b, i32 %t1
+ ret i32 %t3
+}
+
+define i32 @blsr32_z2(i32 %a, i32 %b, i32 %c) nounwind {
+; X86-LABEL: blsr32_z2:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: leal -1(%eax), %ecx
+; X86-NEXT: testl %eax, %ecx
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: cmovel %eax, %ecx
+; X86-NEXT: movl (%ecx), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: blsr32_z2:
+; X64: # %bb.0:
+; X64-NEXT: movl %esi, %eax
+; X64-NEXT: # kill: def $edi killed $edi def $rdi
+; X64-NEXT: leal -1(%rdi), %ecx
+; X64-NEXT: testl %edi, %ecx
+; X64-NEXT: cmovnel %edx, %eax
+; X64-NEXT: retq
+ %t0 = sub i32 %a, 1
+ %t1 = and i32 %t0, %a
+ %t2 = icmp eq i32 %t1, 0
+ %t3 = select i1 %t2, i32 %b, i32 %c
+ ret i32 %t3
+}
+
define i64 @blsr64(i64 %x) {
; X86-LABEL: blsr64:
; X86: # %bb.0:
@@ -639,6 +926,75 @@ define i64 @blsr64(i64 %x) {
ret i64 %tmp2
}
+define i64 @blsr64_z(i64 %a, i64 %b) nounwind {
+; X86-LABEL: blsr64_z:
+; X86: # %bb.0:
+; X86-NEXT: pushl %esi
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
+; X86-NEXT: movl %ecx, %eax
+; X86-NEXT: addl $-1, %eax
+; X86-NEXT: movl %esi, %edx
+; X86-NEXT: adcl $-1, %edx
+; X86-NEXT: andl %ecx, %eax
+; X86-NEXT: andl %esi, %edx
+; X86-NEXT: movl %eax, %ecx
+; X86-NEXT: orl %edx, %ecx
+; X86-NEXT: jne .LBB41_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: .LBB41_2:
+; X86-NEXT: popl %esi
+; X86-NEXT: retl
+;
+; X64-LABEL: blsr64_z:
+; X64: # %bb.0:
+; X64-NEXT: blsrq %rdi, %rax
+; X64-NEXT: cmoveq %rsi, %rax
+; X64-NEXT: retq
+ %t0 = sub i64 %a, 1
+ %t1 = and i64 %t0, %a
+ %t2 = icmp eq i64 %t1, 0
+ %t3 = select i1 %t2, i64 %b, i64 %t1
+ ret i64 %t3
+}
+
+define i64 @blsr64_z2(i64 %a, i64 %b, i64 %c) nounwind {
+; X86-LABEL: blsr64_z2:
+; X86: # %bb.0:
+; X86-NEXT: pushl %esi
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %eax, %edx
+; X86-NEXT: addl $-1, %edx
+; X86-NEXT: movl %ecx, %esi
+; X86-NEXT: adcl $-1, %esi
+; X86-NEXT: andl %eax, %edx
+; X86-NEXT: andl %ecx, %esi
+; X86-NEXT: orl %edx, %esi
+; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
+; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: cmovel %eax, %ecx
+; X86-NEXT: movl (%ecx), %eax
+; X86-NEXT: movl 4(%ecx), %edx
+; X86-NEXT: popl %esi
+; X86-NEXT: retl
+;
+; X64-LABEL: blsr64_z2:
+; X64: # %bb.0:
+; X64-NEXT: movq %rsi, %rax
+; X64-NEXT: leaq -1(%rdi), %rcx
+; X64-NEXT: testq %rdi, %rcx
+; X64-NEXT: cmovneq %rdx, %rax
+; X64-NEXT: retq
+ %t0 = sub i64 %a, 1
+ %t1 = and i64 %t0, %a
+ %t2 = icmp eq i64 %t1, 0
+ %t3 = select i1 %t2, i64 %b, i64 %c
+ ret i64 %t3
+}
+
; PR35792 - https://bugs.llvm.org/show_bug.cgi?id=35792
define i64 @blsr_disguised_constant(i64 %x) {
@@ -688,19 +1044,19 @@ define void @pr40060(i32, i32) {
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: bextrl %eax, {{[0-9]+}}(%esp), %eax
-; X86-NEXT: js .LBB33_1
+; X86-NEXT: js .LBB45_1
; X86-NEXT: # %bb.2:
; X86-NEXT: jmp bar # TAILCALL
-; X86-NEXT: .LBB33_1:
+; X86-NEXT: .LBB45_1:
; X86-NEXT: retl
;
; X64-LABEL: pr40060:
; X64: # %bb.0:
; X64-NEXT: bextrl %esi, %edi, %eax
-; X64-NEXT: js .LBB33_1
+; X64-NEXT: js .LBB45_1
; X64-NEXT: # %bb.2:
; X64-NEXT: jmp bar # TAILCALL
-; X64-NEXT: .LBB33_1:
+; X64-NEXT: .LBB45_1:
; X64-NEXT: retq
%3 = tail call i32 @llvm.x86.bmi.bextr.32(i32 %0, i32 %1)
%4 = icmp sgt i32 %3, -1
More information about the llvm-commits
mailing list