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.ssub.sat.i4(i4, i4) 6declare i8 @llvm.ssub.sat.i8(i8, i8) 7declare i16 @llvm.ssub.sat.i16(i16, i16) 8declare i32 @llvm.ssub.sat.i32(i32, i32) 9declare i64 @llvm.ssub.sat.i64(i64, i64) 10declare <4 x i32> @llvm.ssub.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: movl {{[0-9]+}}(%esp), %edx 17; X86-NEXT: xorl %ecx, %ecx 18; X86-NEXT: cmpl %edx, %eax 19; X86-NEXT: setns %cl 20; X86-NEXT: addl $2147483647, %ecx # imm = 0x7FFFFFFF 21; X86-NEXT: subl %edx, %eax 22; X86-NEXT: cmovol %ecx, %eax 23; X86-NEXT: retl 24; 25; X64-LABEL: func: 26; X64: # %bb.0: 27; X64-NEXT: xorl %eax, %eax 28; X64-NEXT: cmpl %esi, %edi 29; X64-NEXT: setns %al 30; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF 31; X64-NEXT: subl %esi, %edi 32; X64-NEXT: cmovnol %edi, %eax 33; X64-NEXT: retq 34 %tmp = call i32 @llvm.ssub.sat.i32(i32 %x, i32 %y) 35 ret i32 %tmp 36} 37 38define i64 @func2(i64 %x, i64 %y) nounwind { 39; X86-LABEL: func2: 40; X86: # %bb.0: 41; X86-NEXT: pushl %ebx 42; X86-NEXT: pushl %esi 43; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 44; X86-NEXT: movl {{[0-9]+}}(%esp), %esi 45; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx 46; X86-NEXT: sbbl {{[0-9]+}}(%esp), %esi 47; X86-NEXT: seto %bl 48; X86-NEXT: movl %esi, %eax 49; X86-NEXT: sarl $31, %eax 50; X86-NEXT: testb %bl, %bl 51; X86-NEXT: cmovel %ecx, %eax 52; X86-NEXT: xorl %edx, %edx 53; X86-NEXT: testl %esi, %esi 54; X86-NEXT: setns %dl 55; X86-NEXT: addl $2147483647, %edx # imm = 0x7FFFFFFF 56; X86-NEXT: testb %bl, %bl 57; X86-NEXT: cmovel %esi, %edx 58; X86-NEXT: popl %esi 59; X86-NEXT: popl %ebx 60; X86-NEXT: retl 61; 62; X64-LABEL: func2: 63; X64: # %bb.0: 64; X64-NEXT: xorl %ecx, %ecx 65; X64-NEXT: cmpq %rsi, %rdi 66; X64-NEXT: setns %cl 67; X64-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF 68; X64-NEXT: addq %rcx, %rax 69; X64-NEXT: subq %rsi, %rdi 70; X64-NEXT: cmovnoq %rdi, %rax 71; X64-NEXT: retq 72 %tmp = call i64 @llvm.ssub.sat.i64(i64 %x, i64 %y) 73 ret i64 %tmp 74} 75 76define signext i16 @func16(i16 signext %x, i16 signext %y) nounwind { 77; X86-LABEL: func16: 78; X86: # %bb.0: 79; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax 80; X86-NEXT: movzwl {{[0-9]+}}(%esp), %edx 81; X86-NEXT: xorl %ecx, %ecx 82; X86-NEXT: cmpw %dx, %ax 83; X86-NEXT: setns %cl 84; X86-NEXT: addl $32767, %ecx # imm = 0x7FFF 85; X86-NEXT: subw %dx, %ax 86; X86-NEXT: cmovol %ecx, %eax 87; X86-NEXT: # kill: def $ax killed $ax killed $eax 88; X86-NEXT: retl 89; 90; X64-LABEL: func16: 91; X64: # %bb.0: 92; X64-NEXT: xorl %eax, %eax 93; X64-NEXT: cmpw %si, %di 94; X64-NEXT: setns %al 95; X64-NEXT: addl $32767, %eax # imm = 0x7FFF 96; X64-NEXT: subw %si, %di 97; X64-NEXT: cmovnol %edi, %eax 98; X64-NEXT: # kill: def $ax killed $ax killed $eax 99; X64-NEXT: retq 100 %tmp = call i16 @llvm.ssub.sat.i16(i16 %x, i16 %y) 101 ret i16 %tmp 102} 103 104define signext i8 @func8(i8 signext %x, i8 signext %y) nounwind { 105; X86-LABEL: func8: 106; X86: # %bb.0: 107; X86-NEXT: movb {{[0-9]+}}(%esp), %al 108; X86-NEXT: movb {{[0-9]+}}(%esp), %dl 109; X86-NEXT: xorl %ecx, %ecx 110; X86-NEXT: cmpb %dl, %al 111; X86-NEXT: setns %cl 112; X86-NEXT: addl $127, %ecx 113; X86-NEXT: subb %dl, %al 114; X86-NEXT: movzbl %al, %eax 115; X86-NEXT: cmovol %ecx, %eax 116; X86-NEXT: # kill: def $al killed $al killed $eax 117; X86-NEXT: retl 118; 119; X64-LABEL: func8: 120; X64: # %bb.0: 121; X64-NEXT: xorl %ecx, %ecx 122; X64-NEXT: cmpb %sil, %dil 123; X64-NEXT: setns %cl 124; X64-NEXT: addl $127, %ecx 125; X64-NEXT: subb %sil, %dil 126; X64-NEXT: movzbl %dil, %eax 127; X64-NEXT: cmovol %ecx, %eax 128; X64-NEXT: # kill: def $al killed $al killed $eax 129; X64-NEXT: retq 130 %tmp = call i8 @llvm.ssub.sat.i8(i8 %x, i8 %y) 131 ret i8 %tmp 132} 133 134define signext i4 @func3(i4 signext %x, i4 signext %y) nounwind { 135; X86-LABEL: func3: 136; X86: # %bb.0: 137; X86-NEXT: movb {{[0-9]+}}(%esp), %al 138; X86-NEXT: subb {{[0-9]+}}(%esp), %al 139; X86-NEXT: movzbl %al, %ecx 140; X86-NEXT: cmpb $7, %al 141; X86-NEXT: movl $7, %eax 142; X86-NEXT: cmovll %ecx, %eax 143; X86-NEXT: cmpb $-8, %al 144; X86-NEXT: movl $248, %ecx 145; X86-NEXT: cmovgl %eax, %ecx 146; X86-NEXT: movsbl %cl, %eax 147; X86-NEXT: retl 148; 149; X64-LABEL: func3: 150; X64: # %bb.0: 151; X64-NEXT: subb %sil, %dil 152; X64-NEXT: movzbl %dil, %eax 153; X64-NEXT: cmpb $7, %al 154; X64-NEXT: movl $7, %ecx 155; X64-NEXT: cmovll %eax, %ecx 156; X64-NEXT: cmpb $-8, %cl 157; X64-NEXT: movl $248, %eax 158; X64-NEXT: cmovgl %ecx, %eax 159; X64-NEXT: movsbl %al, %eax 160; X64-NEXT: retq 161 %tmp = call i4 @llvm.ssub.sat.i4(i4 %x, i4 %y) 162 ret i4 %tmp 163} 164 165define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind { 166; X86-LABEL: vec: 167; X86: # %bb.0: 168; X86-NEXT: pushl %ebx 169; X86-NEXT: pushl %edi 170; X86-NEXT: pushl %esi 171; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 172; X86-NEXT: movl {{[0-9]+}}(%esp), %edx 173; X86-NEXT: xorl %eax, %eax 174; X86-NEXT: cmpl %edx, %ecx 175; X86-NEXT: setns %al 176; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF 177; X86-NEXT: subl %edx, %ecx 178; X86-NEXT: movl {{[0-9]+}}(%esp), %edx 179; X86-NEXT: cmovol %eax, %ecx 180; X86-NEXT: movl {{[0-9]+}}(%esp), %esi 181; X86-NEXT: xorl %eax, %eax 182; X86-NEXT: cmpl %esi, %edx 183; X86-NEXT: setns %al 184; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF 185; X86-NEXT: subl %esi, %edx 186; X86-NEXT: movl {{[0-9]+}}(%esp), %esi 187; X86-NEXT: cmovol %eax, %edx 188; X86-NEXT: movl {{[0-9]+}}(%esp), %edi 189; X86-NEXT: xorl %eax, %eax 190; X86-NEXT: cmpl %edi, %esi 191; X86-NEXT: setns %al 192; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF 193; X86-NEXT: subl %edi, %esi 194; X86-NEXT: movl {{[0-9]+}}(%esp), %edi 195; X86-NEXT: cmovol %eax, %esi 196; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 197; X86-NEXT: xorl %ebx, %ebx 198; X86-NEXT: cmpl %eax, %edi 199; X86-NEXT: setns %bl 200; X86-NEXT: addl $2147483647, %ebx # imm = 0x7FFFFFFF 201; X86-NEXT: subl %eax, %edi 202; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 203; X86-NEXT: cmovol %ebx, %edi 204; X86-NEXT: movl %ecx, 12(%eax) 205; X86-NEXT: movl %edx, 8(%eax) 206; X86-NEXT: movl %esi, 4(%eax) 207; X86-NEXT: movl %edi, (%eax) 208; X86-NEXT: popl %esi 209; X86-NEXT: popl %edi 210; X86-NEXT: popl %ebx 211; X86-NEXT: retl $4 212; 213; X64-LABEL: vec: 214; X64: # %bb.0: 215; X64-NEXT: pxor %xmm2, %xmm2 216; X64-NEXT: movdqa %xmm0, %xmm3 217; X64-NEXT: psubd %xmm1, %xmm3 218; X64-NEXT: pcmpgtd %xmm2, %xmm1 219; X64-NEXT: pcmpgtd %xmm3, %xmm0 220; X64-NEXT: pxor %xmm1, %xmm0 221; X64-NEXT: movdqa %xmm3, %xmm1 222; X64-NEXT: pandn {{.*}}(%rip), %xmm1 223; X64-NEXT: pcmpgtd %xmm3, %xmm2 224; X64-NEXT: psrld $1, %xmm2 225; X64-NEXT: por %xmm2, %xmm1 226; X64-NEXT: pand %xmm0, %xmm1 227; X64-NEXT: pandn %xmm3, %xmm0 228; X64-NEXT: por %xmm1, %xmm0 229; X64-NEXT: retq 230 %tmp = call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %x, <4 x i32> %y) 231 ret <4 x i32> %tmp 232} 233