; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=X64
; RUN: llc < %s -mtriple=i686 -mattr=cmov | FileCheck %s --check-prefix=X86

declare  <4 x i32> @llvm.ushl.sat.v4i32(<4 x i32>, <4 x i32>)

define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
; X64-LABEL: vec:
; X64:       # %bb.0:
; X64-NEXT:    pshufd {{.*#+}} xmm2 = xmm0[3,3,3,3]
; X64-NEXT:    movd %xmm2, %eax
; X64-NEXT:    pshufd {{.*#+}} xmm2 = xmm1[3,3,3,3]
; X64-NEXT:    movd %xmm2, %ecx
; X64-NEXT:    movl %eax, %edx
; X64-NEXT:    shll %cl, %edx
; X64-NEXT:    movl %edx, %esi
; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
; X64-NEXT:    shrl %cl, %esi
; X64-NEXT:    cmpl %esi, %eax
; X64-NEXT:    movl $-1, %eax
; X64-NEXT:    cmovnel %eax, %edx
; X64-NEXT:    movd %edx, %xmm2
; X64-NEXT:    pshufd {{.*#+}} xmm3 = xmm0[2,3,2,3]
; X64-NEXT:    movd %xmm3, %edx
; X64-NEXT:    pshufd {{.*#+}} xmm3 = xmm1[2,3,2,3]
; X64-NEXT:    movd %xmm3, %ecx
; X64-NEXT:    movl %edx, %esi
; X64-NEXT:    shll %cl, %esi
; X64-NEXT:    movl %esi, %edi
; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
; X64-NEXT:    shrl %cl, %edi
; X64-NEXT:    cmpl %edi, %edx
; X64-NEXT:    cmovnel %eax, %esi
; X64-NEXT:    movd %esi, %xmm3
; X64-NEXT:    punpckldq {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
; X64-NEXT:    movd %xmm0, %edx
; X64-NEXT:    movd %xmm1, %ecx
; X64-NEXT:    movl %edx, %esi
; X64-NEXT:    shll %cl, %esi
; X64-NEXT:    movl %esi, %edi
; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
; X64-NEXT:    shrl %cl, %edi
; X64-NEXT:    cmpl %edi, %edx
; X64-NEXT:    cmovnel %eax, %esi
; X64-NEXT:    movd %esi, %xmm2
; X64-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[1,1,1,1]
; X64-NEXT:    movd %xmm0, %edx
; X64-NEXT:    pshufd {{.*#+}} xmm0 = xmm1[1,1,1,1]
; X64-NEXT:    movd %xmm0, %ecx
; X64-NEXT:    movl %edx, %esi
; X64-NEXT:    shll %cl, %esi
; X64-NEXT:    movl %esi, %edi
; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
; X64-NEXT:    shrl %cl, %edi
; X64-NEXT:    cmpl %edi, %edx
; X64-NEXT:    cmovnel %eax, %esi
; X64-NEXT:    movd %esi, %xmm0
; X64-NEXT:    punpckldq {{.*#+}} xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
; X64-NEXT:    punpcklqdq {{.*#+}} xmm2 = xmm2[0],xmm3[0]
; X64-NEXT:    movdqa %xmm2, %xmm0
; X64-NEXT:    retq
;
; X86-LABEL: vec:
; X86:       # %bb.0:
; X86-NEXT:    pushl %ebp
; X86-NEXT:    pushl %ebx
; X86-NEXT:    pushl %edi
; X86-NEXT:    pushl %esi
; X86-NEXT:    movb {{[0-9]+}}(%esp), %ch
; X86-NEXT:    movb {{[0-9]+}}(%esp), %dl
; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ebx
; X86-NEXT:    movl %ebx, %esi
; X86-NEXT:    shll %cl, %esi
; X86-NEXT:    movl %esi, %ebp
; X86-NEXT:    shrl %cl, %ebp
; X86-NEXT:    cmpl %ebp, %ebx
; X86-NEXT:    movl $-1, %ebx
; X86-NEXT:    cmovnel %ebx, %esi
; X86-NEXT:    movl %edi, %eax
; X86-NEXT:    movb %dl, %cl
; X86-NEXT:    shll %cl, %eax
; X86-NEXT:    movl %eax, %ebp
; X86-NEXT:    shrl %cl, %ebp
; X86-NEXT:    cmpl %ebp, %edi
; X86-NEXT:    cmovnel %ebx, %eax
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ebp
; X86-NEXT:    movl %ebp, %edx
; X86-NEXT:    movb %ch, %cl
; X86-NEXT:    shll %cl, %edx
; X86-NEXT:    movl %edx, %edi
; X86-NEXT:    shrl %cl, %edi
; X86-NEXT:    cmpl %edi, %ebp
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ebp
; X86-NEXT:    cmovnel %ebx, %edx
; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
; X86-NEXT:    shll %cl, %ebp
; X86-NEXT:    movl %ebp, %edi
; X86-NEXT:    shrl %cl, %edi
; X86-NEXT:    cmpl %edi, {{[0-9]+}}(%esp)
; X86-NEXT:    cmovnel %ebx, %ebp
; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT:    movl %ebp, 12(%ecx)
; X86-NEXT:    movl %edx, 8(%ecx)
; X86-NEXT:    movl %eax, 4(%ecx)
; X86-NEXT:    movl %esi, (%ecx)
; X86-NEXT:    movl %ecx, %eax
; X86-NEXT:    popl %esi
; X86-NEXT:    popl %edi
; X86-NEXT:    popl %ebx
; X86-NEXT:    popl %ebp
; X86-NEXT:    retl $4
  %tmp = call <4 x i32> @llvm.ushl.sat.v4i32(<4 x i32> %x, <4 x i32> %y)
  ret <4 x i32> %tmp
}
