]> granicus.if.org Git - llvm/commitdiff
[x86] add cmov promotion tests for D36711; NFC
authorSanjay Patel <spatel@rotateright.com>
Wed, 16 Aug 2017 22:50:11 +0000 (22:50 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 16 Aug 2017 22:50:11 +0000 (22:50 +0000)
This way we can see what the current codegen looks like.
I've also explicitly added/removed the cmov attribute from the RUN lines,
so we know exactly what we're checking in the runs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311052 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGen/X86/cmov-promotion.ll [new file with mode: 0644]

diff --git a/test/CodeGen/X86/cmov-promotion.ll b/test/CodeGen/X86/cmov-promotion.ll
new file mode 100644 (file)
index 0000000..531bb6a
--- /dev/null
@@ -0,0 +1,107 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+cmov | FileCheck %s --check-prefix=CMOV
+; RUN: llc < %s -mtriple=i686-unknown-unknown   -mattr=-cmov | FileCheck %s --check-prefix=NO_CMOV
+
+define i32 @cmov_zpromotion_16_to_32(i1 %c) {
+; CMOV-LABEL: cmov_zpromotion_16_to_32:
+; CMOV:       # BB#0:
+; CMOV-NEXT:    testb $1, %dil
+; CMOV-NEXT:    movw $12414, %ax # imm = 0x307E
+; CMOV-NEXT:    movw $-1, %cx
+; CMOV-NEXT:    cmovnew %ax, %cx
+; CMOV-NEXT:    movzwl %cx, %eax
+; CMOV-NEXT:    retq
+;
+; NO_CMOV-LABEL: cmov_zpromotion_16_to_32:
+; NO_CMOV:       # BB#0:
+; NO_CMOV-NEXT:    testb $1, {{[0-9]+}}(%esp)
+; NO_CMOV-NEXT:    movw $12414, %ax # imm = 0x307E
+; NO_CMOV-NEXT:    jne .LBB0_2
+; NO_CMOV-NEXT:  # BB#1:
+; NO_CMOV-NEXT:    movw $-1, %ax
+; NO_CMOV-NEXT:  .LBB0_2:
+; NO_CMOV-NEXT:    movzwl %ax, %eax
+; NO_CMOV-NEXT:    retl
+  %t0 = select i1 %c, i16 12414, i16 -1
+  %ret = zext i16 %t0 to i32
+  ret i32 %ret
+}
+
+define i64 @cmov_zpromotion_16_to_64(i1 %c) {
+; CMOV-LABEL: cmov_zpromotion_16_to_64:
+; CMOV:       # BB#0:
+; CMOV-NEXT:    testb $1, %dil
+; CMOV-NEXT:    movw $12414, %ax # imm = 0x307E
+; CMOV-NEXT:    movw $-1, %cx
+; CMOV-NEXT:    cmovnew %ax, %cx
+; CMOV-NEXT:    movzwl %cx, %eax
+; CMOV-NEXT:    retq
+;
+; NO_CMOV-LABEL: cmov_zpromotion_16_to_64:
+; NO_CMOV:       # BB#0:
+; NO_CMOV-NEXT:    testb $1, {{[0-9]+}}(%esp)
+; NO_CMOV-NEXT:    movw $12414, %ax # imm = 0x307E
+; NO_CMOV-NEXT:    jne .LBB1_2
+; NO_CMOV-NEXT:  # BB#1:
+; NO_CMOV-NEXT:    movw $-1, %ax
+; NO_CMOV-NEXT:  .LBB1_2:
+; NO_CMOV-NEXT:    movzwl %ax, %eax
+; NO_CMOV-NEXT:    xorl %edx, %edx
+; NO_CMOV-NEXT:    retl
+  %t0 = select i1 %c, i16 12414, i16 -1
+  %ret = zext i16 %t0 to i64
+  ret i64 %ret
+}
+
+define i32 @cmov_spromotion_16_to_32(i1 %c) {
+; CMOV-LABEL: cmov_spromotion_16_to_32:
+; CMOV:       # BB#0:
+; CMOV-NEXT:    testb $1, %dil
+; CMOV-NEXT:    movw $12414, %ax # imm = 0x307E
+; CMOV-NEXT:    movw $-1, %cx
+; CMOV-NEXT:    cmovnew %ax, %cx
+; CMOV-NEXT:    movswl %cx, %eax
+; CMOV-NEXT:    retq
+;
+; NO_CMOV-LABEL: cmov_spromotion_16_to_32:
+; NO_CMOV:       # BB#0:
+; NO_CMOV-NEXT:    testb $1, {{[0-9]+}}(%esp)
+; NO_CMOV-NEXT:    movw $12414, %ax # imm = 0x307E
+; NO_CMOV-NEXT:    jne .LBB2_2
+; NO_CMOV-NEXT:  # BB#1:
+; NO_CMOV-NEXT:    movw $-1, %ax
+; NO_CMOV-NEXT:  .LBB2_2:
+; NO_CMOV-NEXT:    cwtl
+; NO_CMOV-NEXT:    retl
+  %t0 = select i1 %c, i16 12414, i16 -1
+  %ret = sext i16 %t0 to i32
+  ret i32 %ret
+}
+
+define i64 @cmov_spromotion_16_to_64(i1 %c) {
+; CMOV-LABEL: cmov_spromotion_16_to_64:
+; CMOV:       # BB#0:
+; CMOV-NEXT:    testb $1, %dil
+; CMOV-NEXT:    movw $12414, %ax # imm = 0x307E
+; CMOV-NEXT:    movw $-1, %cx
+; CMOV-NEXT:    cmovnew %ax, %cx
+; CMOV-NEXT:    movswq %cx, %rax
+; CMOV-NEXT:    retq
+;
+; NO_CMOV-LABEL: cmov_spromotion_16_to_64:
+; NO_CMOV:       # BB#0:
+; NO_CMOV-NEXT:    testb $1, {{[0-9]+}}(%esp)
+; NO_CMOV-NEXT:    movw $12414, %ax # imm = 0x307E
+; NO_CMOV-NEXT:    jne .LBB3_2
+; NO_CMOV-NEXT:  # BB#1:
+; NO_CMOV-NEXT:    movw $-1, %ax
+; NO_CMOV-NEXT:  .LBB3_2:
+; NO_CMOV-NEXT:    cwtl
+; NO_CMOV-NEXT:    movl %eax, %edx
+; NO_CMOV-NEXT:    sarl $31, %edx
+; NO_CMOV-NEXT:    retl
+  %t0 = select i1 %c, i16 12414, i16 -1
+  %ret = sext i16 %t0 to i64
+  ret i64 %ret
+}
+