[llvm] 005066f - [X86] Add PR35202 test case for commuted cmp merging
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 7 10:39:29 PDT 2022
Author: Simon Pilgrim
Date: 2022-04-07T18:39:18+01:00
New Revision: 005066fd456ad497d1c2d3384e0a99b6d0aca99b
URL: https://github.com/llvm/llvm-project/commit/005066fd456ad497d1c2d3384e0a99b6d0aca99b
DIFF: https://github.com/llvm/llvm-project/commit/005066fd456ad497d1c2d3384e0a99b6d0aca99b.diff
LOG: [X86] Add PR35202 test case for commuted cmp merging
Test coverage for Issue #34550
Added:
llvm/test/CodeGen/X86/cmp-merge.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/X86/cmp-merge.ll b/llvm/test/CodeGen/X86/cmp-merge.ll
new file mode 100644
index 0000000000000..2a503bf902765
--- /dev/null
+++ b/llvm/test/CodeGen/X86/cmp-merge.ll
@@ -0,0 +1,102 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686--| FileCheck %s --check-prefixes=X86
+; RUN: llc < %s -mtriple=x86_64--| FileCheck %s --check-prefixes=X64
+
+;
+; PR35202
+;
+
+declare void @on_less()
+declare void @on_equal()
+declare void @on_greater()
+
+define void @eq_first(i32 %0, i32 %1) {
+; X86-LABEL: eq_first:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: cmpl %eax, {{[0-9]+}}(%esp)
+; X86-NEXT: jge .LBB0_1
+; X86-NEXT: # %bb.3:
+; X86-NEXT: jmp on_less at PLT # TAILCALL
+; X86-NEXT: .LBB0_1:
+; X86-NEXT: jne .LBB0_2
+; X86-NEXT: # %bb.4:
+; X86-NEXT: jmp on_equal at PLT # TAILCALL
+; X86-NEXT: .LBB0_2:
+; X86-NEXT: jmp on_greater at PLT # TAILCALL
+;
+; X64-LABEL: eq_first:
+; X64: # %bb.0:
+; X64-NEXT: cmpl %esi, %edi
+; X64-NEXT: jge .LBB0_1
+; X64-NEXT: # %bb.3:
+; X64-NEXT: jmp on_less at PLT # TAILCALL
+; X64-NEXT: .LBB0_1:
+; X64-NEXT: jne .LBB0_2
+; X64-NEXT: # %bb.4:
+; X64-NEXT: jmp on_equal at PLT # TAILCALL
+; X64-NEXT: .LBB0_2:
+; X64-NEXT: jmp on_greater at PLT # TAILCALL
+ %3 = icmp slt i32 %0, %1
+ br i1 %3, label %4, label %5
+4:
+ tail call void @on_less()
+ br label %9
+5:
+ %6 = icmp eq i32 %0, %1
+ br i1 %6, label %7, label %8
+7:
+ tail call void @on_equal()
+ br label %9
+8:
+ tail call void @on_greater()
+ br label %9
+9:
+ ret void
+}
+
+define void @gt_first(i32 %0, i32 %1) {
+; X86-LABEL: gt_first:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: cmpl %eax, %ecx
+; X86-NEXT: jge .LBB1_1
+; X86-NEXT: # %bb.3:
+; X86-NEXT: jmp on_less at PLT # TAILCALL
+; X86-NEXT: .LBB1_1:
+; X86-NEXT: jle .LBB1_2
+; X86-NEXT: # %bb.4:
+; X86-NEXT: jmp on_greater at PLT # TAILCALL
+; X86-NEXT: .LBB1_2:
+; X86-NEXT: jmp on_equal at PLT # TAILCALL
+;
+; X64-LABEL: gt_first:
+; X64: # %bb.0:
+; X64-NEXT: cmpl %esi, %edi
+; X64-NEXT: jge .LBB1_1
+; X64-NEXT: # %bb.3:
+; X64-NEXT: jmp on_less at PLT # TAILCALL
+; X64-NEXT: .LBB1_1:
+; X64-NEXT: jle .LBB1_2
+; X64-NEXT: # %bb.4:
+; X64-NEXT: jmp on_greater at PLT # TAILCALL
+; X64-NEXT: .LBB1_2:
+; X64-NEXT: jmp on_equal at PLT # TAILCALL
+ %3 = icmp slt i32 %0, %1
+ br i1 %3, label %4, label %5
+4:
+ tail call void @on_less()
+ br label %9
+5:
+ %6 = icmp slt i32 %1, %0
+ br i1 %6, label %7, label %8
+7:
+ tail call void @on_greater()
+ br label %9
+8:
+ tail call void @on_equal()
+ br label %9
+9:
+ ret void
+}
More information about the llvm-commits
mailing list