1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=i686 -mattr=cmov | FileCheck %s --check-prefix=X86 3; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=X64 4 5declare i4 @llvm.usub.sat.i4(i4, i4) 6declare i8 @llvm.usub.sat.i8(i8, i8) 7declare i16 @llvm.usub.sat.i16(i16, i16) 8declare i32 @llvm.usub.sat.i32(i32, i32) 9declare i64 @llvm.usub.sat.i64(i64, i64) 10declare <4 x i32> @llvm.usub.sat.v4i32(<4 x i32>, <4 x i32>) 11 12define i32 @func(i32 %x, i32 %y) nounwind { 13; X86-LABEL: func: 14; X86: # %bb.0: 15; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 16; X86-NEXT: xorl %ecx, %ecx 17; X86-NEXT: subl {{[0-9]+}}(%esp), %eax 18; X86-NEXT: cmovbl %ecx, %eax 19; X86-NEXT: retl 20; 21; X64-LABEL: func: 22; X64: # %bb.0: 23; X64-NEXT: xorl %eax, %eax 24; X64-NEXT: subl %esi, %edi 25; X64-NEXT: cmovael %edi, %eax 26; X64-NEXT: retq 27 %tmp = call i32 @llvm.usub.sat.i32(i32 %x, i32 %y) 28 ret i32 %tmp 29} 30 31define i64 @func2(i64 %x, i64 %y) nounwind { 32; X86-LABEL: func2: 33; X86: # %bb.0: 34; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 35; X86-NEXT: movl {{[0-9]+}}(%esp), %edx 36; X86-NEXT: xorl %ecx, %ecx 37; X86-NEXT: subl {{[0-9]+}}(%esp), %eax 38; X86-NEXT: sbbl {{[0-9]+}}(%esp), %edx 39; X86-NEXT: cmovbl %ecx, %edx 40; X86-NEXT: cmovbl %ecx, %eax 41; X86-NEXT: retl 42; 43; X64-LABEL: func2: 44; X64: # %bb.0: 45; X64-NEXT: xorl %eax, %eax 46; X64-NEXT: subq %rsi, %rdi 47; X64-NEXT: cmovaeq %rdi, %rax 48; X64-NEXT: retq 49 %tmp = call i64 @llvm.usub.sat.i64(i64 %x, i64 %y) 50 ret i64 %tmp 51} 52 53define zeroext i16 @func16(i16 zeroext %x, i16 zeroext %y) nounwind { 54; X86-LABEL: func16: 55; X86: # %bb.0: 56; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax 57; X86-NEXT: xorl %ecx, %ecx 58; X86-NEXT: subw {{[0-9]+}}(%esp), %ax 59; X86-NEXT: cmovbl %ecx, %eax 60; X86-NEXT: # kill: def $ax killed $ax killed $eax 61; X86-NEXT: retl 62; 63; X64-LABEL: func16: 64; X64: # %bb.0: 65; X64-NEXT: xorl %eax, %eax 66; X64-NEXT: subw %si, %di 67; X64-NEXT: cmovael %edi, %eax 68; X64-NEXT: # kill: def $ax killed $ax killed $eax 69; X64-NEXT: retq 70 %tmp = call i16 @llvm.usub.sat.i16(i16 %x, i16 %y) 71 ret i16 %tmp 72} 73 74define zeroext i8 @func8(i8 zeroext %x, i8 zeroext %y) nounwind { 75; X86-LABEL: func8: 76; X86: # %bb.0: 77; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax 78; X86-NEXT: xorl %ecx, %ecx 79; X86-NEXT: subb {{[0-9]+}}(%esp), %al 80; X86-NEXT: movzbl %al, %eax 81; X86-NEXT: cmovbl %ecx, %eax 82; X86-NEXT: # kill: def $al killed $al killed $eax 83; X86-NEXT: retl 84; 85; X64-LABEL: func8: 86; X64: # %bb.0: 87; X64-NEXT: xorl %ecx, %ecx 88; X64-NEXT: subb %sil, %dil 89; X64-NEXT: movzbl %dil, %eax 90; X64-NEXT: cmovbl %ecx, %eax 91; X64-NEXT: # kill: def $al killed $al killed $eax 92; X64-NEXT: retq 93 %tmp = call i8 @llvm.usub.sat.i8(i8 %x, i8 %y) 94 ret i8 %tmp 95} 96 97define zeroext i4 @func3(i4 zeroext %x, i4 zeroext %y) nounwind { 98; X86-LABEL: func3: 99; X86: # %bb.0: 100; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax 101; X86-NEXT: xorl %ecx, %ecx 102; X86-NEXT: subb {{[0-9]+}}(%esp), %al 103; X86-NEXT: movzbl %al, %eax 104; X86-NEXT: cmovbl %ecx, %eax 105; X86-NEXT: movzbl %al, %eax 106; X86-NEXT: retl 107; 108; X64-LABEL: func3: 109; X64: # %bb.0: 110; X64-NEXT: xorl %eax, %eax 111; X64-NEXT: subb %sil, %dil 112; X64-NEXT: movzbl %dil, %ecx 113; X64-NEXT: cmovbl %eax, %ecx 114; X64-NEXT: movzbl %cl, %eax 115; X64-NEXT: retq 116 %tmp = call i4 @llvm.usub.sat.i4(i4 %x, i4 %y) 117 ret i4 %tmp 118} 119 120define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind { 121; X86-LABEL: vec: 122; X86: # %bb.0: 123; X86-NEXT: pushl %ebx 124; X86-NEXT: pushl %edi 125; X86-NEXT: pushl %esi 126; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 127; X86-NEXT: movl {{[0-9]+}}(%esp), %edi 128; X86-NEXT: movl {{[0-9]+}}(%esp), %esi 129; X86-NEXT: movl {{[0-9]+}}(%esp), %edx 130; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 131; X86-NEXT: xorl %ebx, %ebx 132; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx 133; X86-NEXT: cmovbl %ebx, %ecx 134; X86-NEXT: subl {{[0-9]+}}(%esp), %edx 135; X86-NEXT: cmovbl %ebx, %edx 136; X86-NEXT: subl {{[0-9]+}}(%esp), %esi 137; X86-NEXT: cmovbl %ebx, %esi 138; X86-NEXT: subl {{[0-9]+}}(%esp), %edi 139; X86-NEXT: cmovbl %ebx, %edi 140; X86-NEXT: movl %edi, 12(%eax) 141; X86-NEXT: movl %esi, 8(%eax) 142; X86-NEXT: movl %edx, 4(%eax) 143; X86-NEXT: movl %ecx, (%eax) 144; X86-NEXT: popl %esi 145; X86-NEXT: popl %edi 146; X86-NEXT: popl %ebx 147; X86-NEXT: retl $4 148; 149; X64-LABEL: vec: 150; X64: # %bb.0: 151; X64-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648] 152; X64-NEXT: movdqa %xmm1, %xmm3 153; X64-NEXT: pxor %xmm2, %xmm3 154; X64-NEXT: pxor %xmm0, %xmm2 155; X64-NEXT: pcmpgtd %xmm3, %xmm2 156; X64-NEXT: psubd %xmm1, %xmm0 157; X64-NEXT: pand %xmm2, %xmm0 158; X64-NEXT: retq 159 %tmp = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %x, <4 x i32> %y) 160 ret <4 x i32> %tmp 161} 162