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) 10 11define i32 @func32(i32 %x, i32 %y, i32 %z) nounwind { 12; X86-LABEL: func32: 13; X86: # %bb.0: 14; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 15; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 16; X86-NEXT: imull {{[0-9]+}}(%esp), %ecx 17; X86-NEXT: xorl %edx, %edx 18; X86-NEXT: subl %ecx, %eax 19; X86-NEXT: cmovbl %edx, %eax 20; X86-NEXT: retl 21; 22; X64-LABEL: func32: 23; X64: # %bb.0: 24; X64-NEXT: imull %edx, %esi 25; X64-NEXT: xorl %eax, %eax 26; X64-NEXT: subl %esi, %edi 27; X64-NEXT: cmovael %edi, %eax 28; X64-NEXT: retq 29 %a = mul i32 %y, %z 30 %tmp = call i32 @llvm.usub.sat.i32(i32 %x, i32 %a) 31 ret i32 %tmp 32} 33 34define i64 @func64(i64 %x, i64 %y, i64 %z) nounwind { 35; X86-LABEL: func64: 36; X86: # %bb.0: 37; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 38; X86-NEXT: movl {{[0-9]+}}(%esp), %edx 39; X86-NEXT: xorl %ecx, %ecx 40; X86-NEXT: subl {{[0-9]+}}(%esp), %eax 41; X86-NEXT: sbbl {{[0-9]+}}(%esp), %edx 42; X86-NEXT: cmovbl %ecx, %edx 43; X86-NEXT: cmovbl %ecx, %eax 44; X86-NEXT: retl 45; 46; X64-LABEL: func64: 47; X64: # %bb.0: 48; X64-NEXT: xorl %eax, %eax 49; X64-NEXT: subq %rdx, %rdi 50; X64-NEXT: cmovaeq %rdi, %rax 51; X64-NEXT: retq 52 %a = mul i64 %y, %z 53 %tmp = call i64 @llvm.usub.sat.i64(i64 %x, i64 %z) 54 ret i64 %tmp 55} 56 57define zeroext i16 @func16(i16 zeroext %x, i16 zeroext %y, i16 zeroext %z) nounwind { 58; X86-LABEL: func16: 59; X86: # %bb.0: 60; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax 61; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx 62; X86-NEXT: imulw {{[0-9]+}}(%esp), %cx 63; X86-NEXT: xorl %edx, %edx 64; X86-NEXT: subw %cx, %ax 65; X86-NEXT: cmovbl %edx, %eax 66; X86-NEXT: # kill: def $ax killed $ax killed $eax 67; X86-NEXT: retl 68; 69; X64-LABEL: func16: 70; X64: # %bb.0: 71; X64-NEXT: imull %edx, %esi 72; X64-NEXT: xorl %eax, %eax 73; X64-NEXT: subw %si, %di 74; X64-NEXT: cmovael %edi, %eax 75; X64-NEXT: # kill: def $ax killed $ax killed $eax 76; X64-NEXT: retq 77 %a = mul i16 %y, %z 78 %tmp = call i16 @llvm.usub.sat.i16(i16 %x, i16 %a) 79 ret i16 %tmp 80} 81 82define zeroext i8 @func8(i8 zeroext %x, i8 zeroext %y, i8 zeroext %z) nounwind { 83; X86-LABEL: func8: 84; X86: # %bb.0: 85; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx 86; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax 87; X86-NEXT: mulb {{[0-9]+}}(%esp) 88; X86-NEXT: xorl %edx, %edx 89; X86-NEXT: subb %al, %cl 90; X86-NEXT: movzbl %cl, %eax 91; X86-NEXT: cmovbl %edx, %eax 92; X86-NEXT: # kill: def $al killed $al killed $eax 93; X86-NEXT: retl 94; 95; X64-LABEL: func8: 96; X64: # %bb.0: 97; X64-NEXT: movl %esi, %eax 98; X64-NEXT: # kill: def $al killed $al killed $eax 99; X64-NEXT: mulb %dl 100; X64-NEXT: xorl %ecx, %ecx 101; X64-NEXT: subb %al, %dil 102; X64-NEXT: movzbl %dil, %eax 103; X64-NEXT: cmovbl %ecx, %eax 104; X64-NEXT: # kill: def $al killed $al killed $eax 105; X64-NEXT: retq 106 %a = mul i8 %y, %z 107 %tmp = call i8 @llvm.usub.sat.i8(i8 %x, i8 %a) 108 ret i8 %tmp 109} 110 111define zeroext i4 @func4(i4 zeroext %x, i4 zeroext %y, i4 zeroext %z) nounwind { 112; X86-LABEL: func4: 113; X86: # %bb.0: 114; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx 115; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax 116; X86-NEXT: mulb {{[0-9]+}}(%esp) 117; X86-NEXT: andb $15, %al 118; X86-NEXT: xorl %edx, %edx 119; X86-NEXT: subb %al, %cl 120; X86-NEXT: movzbl %cl, %eax 121; X86-NEXT: cmovbl %edx, %eax 122; X86-NEXT: movzbl %al, %eax 123; X86-NEXT: retl 124; 125; X64-LABEL: func4: 126; X64: # %bb.0: 127; X64-NEXT: movl %esi, %eax 128; X64-NEXT: # kill: def $al killed $al killed $eax 129; X64-NEXT: mulb %dl 130; X64-NEXT: andb $15, %al 131; X64-NEXT: xorl %ecx, %ecx 132; X64-NEXT: subb %al, %dil 133; X64-NEXT: movzbl %dil, %eax 134; X64-NEXT: cmovbl %ecx, %eax 135; X64-NEXT: movzbl %al, %eax 136; X64-NEXT: retq 137 %a = mul i4 %y, %z 138 %tmp = call i4 @llvm.usub.sat.i4(i4 %x, i4 %a) 139 ret i4 %tmp 140} 141