1; Example input for update_llc_test_checks (taken from CodeGen/X86/iabs.ll) 2; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X86 --check-prefix=X86-NO-CMOV 3; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+cmov | FileCheck %s --check-prefix=X86 --check-prefix=X86-CMOV 4; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64 5 6define i8 @test_i8(i8 %a) nounwind { 7; X86-LABEL: test_i8: 8; X86: # %bb.0: 9; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax 10; X86-NEXT: movl %eax, %ecx 11; X86-NEXT: sarb $7, %cl 12; X86-NEXT: xorb %cl, %al 13; X86-NEXT: subb %cl, %al 14; X86-NEXT: retl 15; 16; X64-LABEL: test_i8: 17; X64: # %bb.0: 18; X64-NEXT: movl %edi, %eax 19; X64-NEXT: movl %eax, %ecx 20; X64-NEXT: sarb $7, %cl 21; X64-NEXT: xorb %cl, %al 22; X64-NEXT: subb %cl, %al 23; X64-NEXT: # kill: def $al killed $al killed $eax 24; X64-NEXT: retq 25 %tmp1neg = sub i8 0, %a 26 %b = icmp sgt i8 %a, -1 27 %abs = select i1 %b, i8 %a, i8 %tmp1neg 28 ret i8 %abs 29} 30 31define i16 @test_i16(i16 %a) nounwind { 32; X86-NO-CMOV-LABEL: test_i16: 33; X86-NO-CMOV: # %bb.0: 34; X86-NO-CMOV-NEXT: movzwl {{[0-9]+}}(%esp), %eax 35; X86-NO-CMOV-NEXT: movswl %ax, %ecx 36; X86-NO-CMOV-NEXT: sarl $15, %ecx 37; X86-NO-CMOV-NEXT: xorl %ecx, %eax 38; X86-NO-CMOV-NEXT: subl %ecx, %eax 39; X86-NO-CMOV-NEXT: # kill: def $ax killed $ax killed $eax 40; X86-NO-CMOV-NEXT: retl 41; 42; X86-CMOV-LABEL: test_i16: 43; X86-CMOV: # %bb.0: 44; X86-CMOV-NEXT: movzwl {{[0-9]+}}(%esp), %ecx 45; X86-CMOV-NEXT: movl %ecx, %eax 46; X86-CMOV-NEXT: negw %ax 47; X86-CMOV-NEXT: cmovsw %cx, %ax 48; X86-CMOV-NEXT: retl 49; 50; X64-LABEL: test_i16: 51; X64: # %bb.0: 52; X64-NEXT: movl %edi, %eax 53; X64-NEXT: negw %ax 54; X64-NEXT: cmovsw %di, %ax 55; X64-NEXT: retq 56 %tmp1neg = sub i16 0, %a 57 %b = icmp sgt i16 %a, -1 58 %abs = select i1 %b, i16 %a, i16 %tmp1neg 59 ret i16 %abs 60} 61 62define i32 @test_i32(i32 %a) nounwind { 63; X86-NO-CMOV-LABEL: test_i32: 64; X86-NO-CMOV: # %bb.0: 65; X86-NO-CMOV-NEXT: movl {{[0-9]+}}(%esp), %eax 66; X86-NO-CMOV-NEXT: movl %eax, %ecx 67; X86-NO-CMOV-NEXT: sarl $31, %ecx 68; X86-NO-CMOV-NEXT: xorl %ecx, %eax 69; X86-NO-CMOV-NEXT: subl %ecx, %eax 70; X86-NO-CMOV-NEXT: retl 71; 72; X86-CMOV-LABEL: test_i32: 73; X86-CMOV: # %bb.0: 74; X86-CMOV-NEXT: movl {{[0-9]+}}(%esp), %ecx 75; X86-CMOV-NEXT: movl %ecx, %eax 76; X86-CMOV-NEXT: negl %eax 77; X86-CMOV-NEXT: cmovsl %ecx, %eax 78; X86-CMOV-NEXT: retl 79; 80; X64-LABEL: test_i32: 81; X64: # %bb.0: 82; X64-NEXT: movl %edi, %eax 83; X64-NEXT: negl %eax 84; X64-NEXT: cmovsl %edi, %eax 85; X64-NEXT: retq 86 %tmp1neg = sub i32 0, %a 87 %b = icmp sgt i32 %a, -1 88 %abs = select i1 %b, i32 %a, i32 %tmp1neg 89 ret i32 %abs 90} 91 92define i64 @test_i64(i64 %a) nounwind { 93; X86-LABEL: test_i64: 94; X86: # %bb.0: 95; X86-NEXT: movl {{[0-9]+}}(%esp), %edx 96; X86-NEXT: movl %edx, %ecx 97; X86-NEXT: sarl $31, %ecx 98; X86-NEXT: xorl %ecx, %edx 99; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 100; X86-NEXT: xorl %ecx, %eax 101; X86-NEXT: subl %ecx, %eax 102; X86-NEXT: sbbl %ecx, %edx 103; X86-NEXT: retl 104; 105; X64-LABEL: test_i64: 106; X64: # %bb.0: 107; X64-NEXT: movq %rdi, %rax 108; X64-NEXT: negq %rax 109; X64-NEXT: cmovsq %rdi, %rax 110; X64-NEXT: retq 111 %tmp1neg = sub i64 0, %a 112 %b = icmp sgt i64 %a, -1 113 %abs = select i1 %b, i64 %a, i64 %tmp1neg 114 ret i64 %abs 115} 116