116 lines · plain
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-CMOV3; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+cmov | FileCheck %s --check-prefix=X86 --check-prefix=X86-CMOV4; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X645 6define i8 @test_i8(i8 %a) nounwind {7; X86-LABEL: test_i8:8; X86: # %bb.0:9; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax10; X86-NEXT: movl %eax, %ecx11; X86-NEXT: sarb $7, %cl12; X86-NEXT: xorb %cl, %al13; X86-NEXT: subb %cl, %al14; X86-NEXT: retl15;16; X64-LABEL: test_i8:17; X64: # %bb.0:18; X64-NEXT: movl %edi, %eax19; X64-NEXT: movl %eax, %ecx20; X64-NEXT: sarb $7, %cl21; X64-NEXT: xorb %cl, %al22; X64-NEXT: subb %cl, %al23; X64-NEXT: # kill: def $al killed $al killed $eax24; X64-NEXT: retq25 %tmp1neg = sub i8 0, %a26 %b = icmp sgt i8 %a, -127 %abs = select i1 %b, i8 %a, i8 %tmp1neg28 ret i8 %abs29}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), %eax35; X86-NO-CMOV-NEXT: movswl %ax, %ecx36; X86-NO-CMOV-NEXT: sarl $15, %ecx37; X86-NO-CMOV-NEXT: xorl %ecx, %eax38; X86-NO-CMOV-NEXT: subl %ecx, %eax39; X86-NO-CMOV-NEXT: # kill: def $ax killed $ax killed $eax40; X86-NO-CMOV-NEXT: retl41;42; X86-CMOV-LABEL: test_i16:43; X86-CMOV: # %bb.0:44; X86-CMOV-NEXT: movzwl {{[0-9]+}}(%esp), %ecx45; X86-CMOV-NEXT: movl %ecx, %eax46; X86-CMOV-NEXT: negw %ax47; X86-CMOV-NEXT: cmovsw %cx, %ax48; X86-CMOV-NEXT: retl49;50; X64-LABEL: test_i16:51; X64: # %bb.0:52; X64-NEXT: movl %edi, %eax53; X64-NEXT: negw %ax54; X64-NEXT: cmovsw %di, %ax55; X64-NEXT: retq56 %tmp1neg = sub i16 0, %a57 %b = icmp sgt i16 %a, -158 %abs = select i1 %b, i16 %a, i16 %tmp1neg59 ret i16 %abs60}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), %eax66; X86-NO-CMOV-NEXT: movl %eax, %ecx67; X86-NO-CMOV-NEXT: sarl $31, %ecx68; X86-NO-CMOV-NEXT: xorl %ecx, %eax69; X86-NO-CMOV-NEXT: subl %ecx, %eax70; X86-NO-CMOV-NEXT: retl71;72; X86-CMOV-LABEL: test_i32:73; X86-CMOV: # %bb.0:74; X86-CMOV-NEXT: movl {{[0-9]+}}(%esp), %ecx75; X86-CMOV-NEXT: movl %ecx, %eax76; X86-CMOV-NEXT: negl %eax77; X86-CMOV-NEXT: cmovsl %ecx, %eax78; X86-CMOV-NEXT: retl79;80; X64-LABEL: test_i32:81; X64: # %bb.0:82; X64-NEXT: movl %edi, %eax83; X64-NEXT: negl %eax84; X64-NEXT: cmovsl %edi, %eax85; X64-NEXT: retq86 %tmp1neg = sub i32 0, %a87 %b = icmp sgt i32 %a, -188 %abs = select i1 %b, i32 %a, i32 %tmp1neg89 ret i32 %abs90}91 92define i64 @test_i64(i64 %a) nounwind {93; X86-LABEL: test_i64:94; X86: # %bb.0:95; X86-NEXT: movl {{[0-9]+}}(%esp), %edx96; X86-NEXT: movl %edx, %ecx97; X86-NEXT: sarl $31, %ecx98; X86-NEXT: xorl %ecx, %edx99; X86-NEXT: movl {{[0-9]+}}(%esp), %eax100; X86-NEXT: xorl %ecx, %eax101; X86-NEXT: subl %ecx, %eax102; X86-NEXT: sbbl %ecx, %edx103; X86-NEXT: retl104;105; X64-LABEL: test_i64:106; X64: # %bb.0:107; X64-NEXT: movq %rdi, %rax108; X64-NEXT: negq %rax109; X64-NEXT: cmovsq %rdi, %rax110; X64-NEXT: retq111 %tmp1neg = sub i64 0, %a112 %b = icmp sgt i64 %a, -1113 %abs = select i1 %b, i64 %a, i64 %tmp1neg114 ret i64 %abs115}116