1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse4.1 | FileCheck %s --check-prefixes=CHECK,SSE
3 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx2 | FileCheck %s --check-prefixes=CHECK,AVX
5 define i16 @mulhs(i16 %a0, i16 %a1) {
8 ; CHECK-NEXT: movswl %si, %ecx
9 ; CHECK-NEXT: movswl %di, %eax
10 ; CHECK-NEXT: imull %ecx, %eax
11 ; CHECK-NEXT: shrl $16, %eax
12 ; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
14 %x0 = sext i16 %a0 to i32
15 %x1 = sext i16 %a1 to i32
16 %v0 = insertelement <1 x i32> <i32 undef>, i32 %x0, i32 0
17 %v1 = insertelement <1 x i32> <i32 undef>, i32 %x1, i32 0
18 %mul = mul nsw <1 x i32> %v0, %v1
19 %lshr = lshr <1 x i32> %mul, <i32 16>
20 %trunc = trunc <1 x i32> %lshr to <1 x i16>
21 %res = extractelement <1 x i16> %trunc, i32 0
25 define i16 @mulhu(i16 %a0, i16 %a1) {
28 ; SSE-NEXT: movzwl %si, %ecx
29 ; SSE-NEXT: movzwl %di, %eax
30 ; SSE-NEXT: imull %ecx, %eax
31 ; SSE-NEXT: shrl $16, %eax
32 ; SSE-NEXT: # kill: def $ax killed $ax killed $eax
37 ; AVX-NEXT: vmovd %edi, %xmm0
38 ; AVX-NEXT: vmovd %esi, %xmm1
39 ; AVX-NEXT: vpmulhuw %xmm1, %xmm0, %xmm0
40 ; AVX-NEXT: vmovd %xmm0, %eax
41 ; AVX-NEXT: # kill: def $ax killed $ax killed $eax
43 %x0 = zext i16 %a0 to i32
44 %x1 = zext i16 %a1 to i32
45 %v0 = insertelement <1 x i32> <i32 undef>, i32 %x0, i32 0
46 %v1 = insertelement <1 x i32> <i32 undef>, i32 %x1, i32 0
47 %mul = mul nsw <1 x i32> %v0, %v1
48 %lshr = lshr <1 x i32> %mul, <i32 16>
49 %trunc = trunc <1 x i32> %lshr to <1 x i16>
50 %res = extractelement <1 x i16> %trunc, i32 0