[llvm] 8b05b6d - [X86] Add test cases for PR46203. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 14:28:09 PDT 2020
Author: Craig Topper
Date: 2020-06-05T14:27:13-07:00
New Revision: 8b05b6d53342b4532b046f85cbbe3278ed4d59cb
URL: https://github.com/llvm/llvm-project/commit/8b05b6d53342b4532b046f85cbbe3278ed4d59cb
DIFF: https://github.com/llvm/llvm-project/commit/8b05b6d53342b4532b046f85cbbe3278ed4d59cb.diff
LOG: [X86] Add test cases for PR46203. NFC
Added:
Modified:
llvm/test/CodeGen/X86/dagcombine-select.ll
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/X86/dagcombine-select.ll b/llvm/test/CodeGen/X86/dagcombine-select.ll
index 506234b25f27..a6a81b975705 100644
--- a/llvm/test/CodeGen/X86/dagcombine-select.ll
+++ b/llvm/test/CodeGen/X86/dagcombine-select.ll
@@ -430,3 +430,54 @@ define i32 @cttz_32_ne_select_ffs(i32 %v) nounwind {
%add = select i1 %tobool, i32 %.op, i32 0
ret i32 %add
}
+
+; This matches the pattern emitted for __builtin_ffs - 1
+define i32 @cttz_32_eq_select_ffs_m1(i32 %v) nounwind {
+; NOBMI-LABEL: cttz_32_eq_select_ffs_m1:
+; NOBMI: # %bb.0:
+; NOBMI-NEXT: bsfl %edi, %ecx
+; NOBMI-NEXT: xorl %eax, %eax
+; NOBMI-NEXT: cmpl $1, %edi
+; NOBMI-NEXT: sbbl %eax, %eax
+; NOBMI-NEXT: orl %ecx, %eax
+; NOBMI-NEXT: retq
+;
+; BMI-LABEL: cttz_32_eq_select_ffs_m1:
+; BMI: # %bb.0:
+; BMI-NEXT: tzcntl %edi, %ecx
+; BMI-NEXT: xorl %eax, %eax
+; BMI-NEXT: cmpl $1, %edi
+; BMI-NEXT: sbbl %eax, %eax
+; BMI-NEXT: orl %ecx, %eax
+; BMI-NEXT: retq
+
+ %cnt = tail call i32 @llvm.cttz.i32(i32 %v, i1 true)
+ %tobool = icmp eq i32 %v, 0
+ %sel = select i1 %tobool, i32 -1, i32 %cnt
+ ret i32 %sel
+}
+
+define i32 @cttz_32_ne_select_ffs_m1(i32 %v) nounwind {
+; NOBMI-LABEL: cttz_32_ne_select_ffs_m1:
+; NOBMI: # %bb.0:
+; NOBMI-NEXT: bsfl %edi, %ecx
+; NOBMI-NEXT: xorl %eax, %eax
+; NOBMI-NEXT: cmpl $1, %edi
+; NOBMI-NEXT: sbbl %eax, %eax
+; NOBMI-NEXT: orl %ecx, %eax
+; NOBMI-NEXT: retq
+;
+; BMI-LABEL: cttz_32_ne_select_ffs_m1:
+; BMI: # %bb.0:
+; BMI-NEXT: tzcntl %edi, %ecx
+; BMI-NEXT: xorl %eax, %eax
+; BMI-NEXT: cmpl $1, %edi
+; BMI-NEXT: sbbl %eax, %eax
+; BMI-NEXT: orl %ecx, %eax
+; BMI-NEXT: retq
+
+ %cnt = tail call i32 @llvm.cttz.i32(i32 %v, i1 true)
+ %tobool = icmp ne i32 %v, 0
+ %sel = select i1 %tobool, i32 %cnt, i32 -1
+ ret i32 %sel
+}
More information about the llvm-commits
mailing list