1240aff80SAlex Richardson; Example input for update_llc_test_checks (taken from CodeGen/X86/iabs.ll) 2240aff80SAlex Richardson; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X86 --check-prefix=X86-NO-CMOV 3240aff80SAlex Richardson; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+cmov | FileCheck %s --check-prefix=X86 --check-prefix=X86-CMOV 4240aff80SAlex Richardson; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64 5240aff80SAlex Richardson 6240aff80SAlex Richardsondefine i8 @test_i8(i8 %a) nounwind { 7240aff80SAlex Richardson; X86-LABEL: test_i8: 8240aff80SAlex Richardson; X86: # %bb.0: 9*f0dd12ecSSanjay Patel; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax 10240aff80SAlex Richardson; X86-NEXT: movl %eax, %ecx 11240aff80SAlex Richardson; X86-NEXT: sarb $7, %cl 12240aff80SAlex Richardson; X86-NEXT: xorb %cl, %al 13440c4b70SCraig Topper; X86-NEXT: subb %cl, %al 14240aff80SAlex Richardson; X86-NEXT: retl 15240aff80SAlex Richardson; 16240aff80SAlex Richardson; X64-LABEL: test_i8: 17240aff80SAlex Richardson; X64: # %bb.0: 18440c4b70SCraig Topper; X64-NEXT: movl %edi, %eax 19440c4b70SCraig Topper; X64-NEXT: movl %eax, %ecx 20240aff80SAlex Richardson; X64-NEXT: sarb $7, %cl 21240aff80SAlex Richardson; X64-NEXT: xorb %cl, %al 22440c4b70SCraig Topper; X64-NEXT: subb %cl, %al 23240aff80SAlex Richardson; X64-NEXT: # kill: def $al killed $al killed $eax 24240aff80SAlex Richardson; X64-NEXT: retq 25240aff80SAlex Richardson %tmp1neg = sub i8 0, %a 26240aff80SAlex Richardson %b = icmp sgt i8 %a, -1 27240aff80SAlex Richardson %abs = select i1 %b, i8 %a, i8 %tmp1neg 28240aff80SAlex Richardson ret i8 %abs 29240aff80SAlex Richardson} 30240aff80SAlex Richardson 31240aff80SAlex Richardsondefine i16 @test_i16(i16 %a) nounwind { 32240aff80SAlex Richardson; X86-NO-CMOV-LABEL: test_i16: 33240aff80SAlex Richardson; X86-NO-CMOV: # %bb.0: 34c11051a4SCraig Topper; X86-NO-CMOV-NEXT: movzwl {{[0-9]+}}(%esp), %eax 35c11051a4SCraig Topper; X86-NO-CMOV-NEXT: movswl %ax, %ecx 36240aff80SAlex Richardson; X86-NO-CMOV-NEXT: sarl $15, %ecx 37240aff80SAlex Richardson; X86-NO-CMOV-NEXT: xorl %ecx, %eax 38440c4b70SCraig Topper; X86-NO-CMOV-NEXT: subl %ecx, %eax 39240aff80SAlex Richardson; X86-NO-CMOV-NEXT: # kill: def $ax killed $ax killed $eax 40240aff80SAlex Richardson; X86-NO-CMOV-NEXT: retl 41240aff80SAlex Richardson; 42240aff80SAlex Richardson; X86-CMOV-LABEL: test_i16: 43240aff80SAlex Richardson; X86-CMOV: # %bb.0: 44240aff80SAlex Richardson; X86-CMOV-NEXT: movzwl {{[0-9]+}}(%esp), %ecx 45240aff80SAlex Richardson; X86-CMOV-NEXT: movl %ecx, %eax 46240aff80SAlex Richardson; X86-CMOV-NEXT: negw %ax 473ff9cc01SCraig Topper; X86-CMOV-NEXT: cmovsw %cx, %ax 48240aff80SAlex Richardson; X86-CMOV-NEXT: retl 49240aff80SAlex Richardson; 50240aff80SAlex Richardson; X64-LABEL: test_i16: 51240aff80SAlex Richardson; X64: # %bb.0: 52240aff80SAlex Richardson; X64-NEXT: movl %edi, %eax 53240aff80SAlex Richardson; X64-NEXT: negw %ax 543ff9cc01SCraig Topper; X64-NEXT: cmovsw %di, %ax 55240aff80SAlex Richardson; X64-NEXT: retq 56240aff80SAlex Richardson %tmp1neg = sub i16 0, %a 57240aff80SAlex Richardson %b = icmp sgt i16 %a, -1 58240aff80SAlex Richardson %abs = select i1 %b, i16 %a, i16 %tmp1neg 59240aff80SAlex Richardson ret i16 %abs 60240aff80SAlex Richardson} 61240aff80SAlex Richardson 62240aff80SAlex Richardsondefine i32 @test_i32(i32 %a) nounwind { 63240aff80SAlex Richardson; X86-NO-CMOV-LABEL: test_i32: 64240aff80SAlex Richardson; X86-NO-CMOV: # %bb.0: 65240aff80SAlex Richardson; X86-NO-CMOV-NEXT: movl {{[0-9]+}}(%esp), %eax 66240aff80SAlex Richardson; X86-NO-CMOV-NEXT: movl %eax, %ecx 67240aff80SAlex Richardson; X86-NO-CMOV-NEXT: sarl $31, %ecx 68240aff80SAlex Richardson; X86-NO-CMOV-NEXT: xorl %ecx, %eax 69440c4b70SCraig Topper; X86-NO-CMOV-NEXT: subl %ecx, %eax 70240aff80SAlex Richardson; X86-NO-CMOV-NEXT: retl 71240aff80SAlex Richardson; 72240aff80SAlex Richardson; X86-CMOV-LABEL: test_i32: 73240aff80SAlex Richardson; X86-CMOV: # %bb.0: 74240aff80SAlex Richardson; X86-CMOV-NEXT: movl {{[0-9]+}}(%esp), %ecx 75240aff80SAlex Richardson; X86-CMOV-NEXT: movl %ecx, %eax 76240aff80SAlex Richardson; X86-CMOV-NEXT: negl %eax 773ff9cc01SCraig Topper; X86-CMOV-NEXT: cmovsl %ecx, %eax 78240aff80SAlex Richardson; X86-CMOV-NEXT: retl 79240aff80SAlex Richardson; 80240aff80SAlex Richardson; X64-LABEL: test_i32: 81240aff80SAlex Richardson; X64: # %bb.0: 82240aff80SAlex Richardson; X64-NEXT: movl %edi, %eax 83240aff80SAlex Richardson; X64-NEXT: negl %eax 843ff9cc01SCraig Topper; X64-NEXT: cmovsl %edi, %eax 85240aff80SAlex Richardson; X64-NEXT: retq 86240aff80SAlex Richardson %tmp1neg = sub i32 0, %a 87240aff80SAlex Richardson %b = icmp sgt i32 %a, -1 88240aff80SAlex Richardson %abs = select i1 %b, i32 %a, i32 %tmp1neg 89240aff80SAlex Richardson ret i32 %abs 90240aff80SAlex Richardson} 91240aff80SAlex Richardson 92240aff80SAlex Richardsondefine i64 @test_i64(i64 %a) nounwind { 93240aff80SAlex Richardson; X86-LABEL: test_i64: 94240aff80SAlex Richardson; X86: # %bb.0: 95240aff80SAlex Richardson; X86-NEXT: movl {{[0-9]+}}(%esp), %edx 96240aff80SAlex Richardson; X86-NEXT: movl %edx, %ecx 97240aff80SAlex Richardson; X86-NEXT: sarl $31, %ecx 98240aff80SAlex Richardson; X86-NEXT: xorl %ecx, %edx 998e132c5cSCraig Topper; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 100240aff80SAlex Richardson; X86-NEXT: xorl %ecx, %eax 1018e132c5cSCraig Topper; X86-NEXT: subl %ecx, %eax 1028e132c5cSCraig Topper; X86-NEXT: sbbl %ecx, %edx 103240aff80SAlex Richardson; X86-NEXT: retl 104240aff80SAlex Richardson; 105240aff80SAlex Richardson; X64-LABEL: test_i64: 106240aff80SAlex Richardson; X64: # %bb.0: 107240aff80SAlex Richardson; X64-NEXT: movq %rdi, %rax 108240aff80SAlex Richardson; X64-NEXT: negq %rax 1093ff9cc01SCraig Topper; X64-NEXT: cmovsq %rdi, %rax 110240aff80SAlex Richardson; X64-NEXT: retq 111240aff80SAlex Richardson %tmp1neg = sub i64 0, %a 112240aff80SAlex Richardson %b = icmp sgt i64 %a, -1 113240aff80SAlex Richardson %abs = select i1 %b, i64 %a, i64 %tmp1neg 114240aff80SAlex Richardson ret i64 %abs 115240aff80SAlex Richardson} 116