1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -O1 -mtriple=x86_64-unknown-unknown -o - | FileCheck %s
4 ; We used to assert on widening the SMULFIX/UMULFIX/SMULFIXSAT node result,
5 ; so primiary goal with the test is to see that we support legalization for
8 declare <4 x i16> @llvm.smul.fix.v4i16(<4 x i16>, <4 x i16>, i32 immarg)
9 declare <4 x i16> @llvm.umul.fix.v4i16(<4 x i16>, <4 x i16>, i32 immarg)
10 declare <4 x i16> @llvm.smul.fix.sat.v4i16(<4 x i16>, <4 x i16>, i32 immarg)
12 define <4 x i16> @smulfix(<4 x i16> %a) {
13 ; CHECK-LABEL: smulfix:
15 ; CHECK-NEXT: movdqa {{.*#+}} xmm1 = <1,2,3,4,u,u,u,u>
16 ; CHECK-NEXT: movdqa %xmm0, %xmm2
17 ; CHECK-NEXT: pmullw %xmm1, %xmm2
18 ; CHECK-NEXT: psrlw $15, %xmm2
19 ; CHECK-NEXT: pmulhw %xmm1, %xmm0
20 ; CHECK-NEXT: psllw $1, %xmm0
21 ; CHECK-NEXT: por %xmm2, %xmm0
23 %t = call <4 x i16> @llvm.smul.fix.v4i16(<4 x i16> <i16 1, i16 2, i16 3, i16 4>, <4 x i16> %a, i32 15)
27 define <4 x i16> @umulfix(<4 x i16> %a) {
28 ; CHECK-LABEL: umulfix:
30 ; CHECK-NEXT: movdqa {{.*#+}} xmm1 = <1,2,3,4,u,u,u,u>
31 ; CHECK-NEXT: movdqa %xmm0, %xmm2
32 ; CHECK-NEXT: pmullw %xmm1, %xmm2
33 ; CHECK-NEXT: psrlw $15, %xmm2
34 ; CHECK-NEXT: pmulhuw %xmm1, %xmm0
35 ; CHECK-NEXT: psllw $1, %xmm0
36 ; CHECK-NEXT: por %xmm2, %xmm0
38 %t = call <4 x i16> @llvm.umul.fix.v4i16(<4 x i16> <i16 1, i16 2, i16 3, i16 4>, <4 x i16> %a, i32 15)
42 define <4 x i16> @smulfixsat(<4 x i16> %a) {
43 ; CHECK-LABEL: smulfixsat:
45 ; CHECK-NEXT: pextrw $2, %xmm0, %eax
47 ; CHECK-NEXT: leal (%rax,%rax,2), %ecx
48 ; CHECK-NEXT: movl %ecx, %edx
49 ; CHECK-NEXT: shrl $16, %edx
50 ; CHECK-NEXT: shldw $1, %cx, %dx
51 ; CHECK-NEXT: sarl $16, %ecx
52 ; CHECK-NEXT: cmpl $16383, %ecx # imm = 0x3FFF
53 ; CHECK-NEXT: movl $32767, %r8d # imm = 0x7FFF
54 ; CHECK-NEXT: cmovgl %r8d, %edx
55 ; CHECK-NEXT: cmpl $-16384, %ecx # imm = 0xC000
56 ; CHECK-NEXT: movl $32768, %ecx # imm = 0x8000
57 ; CHECK-NEXT: cmovll %ecx, %edx
58 ; CHECK-NEXT: pextrw $1, %xmm0, %esi
59 ; CHECK-NEXT: movswl %si, %edi
60 ; CHECK-NEXT: movl %edi, %eax
61 ; CHECK-NEXT: shrl $15, %eax
62 ; CHECK-NEXT: leal (%rdi,%rdi), %esi
63 ; CHECK-NEXT: shrdw $15, %ax, %si
64 ; CHECK-NEXT: sarl $15, %edi
65 ; CHECK-NEXT: cmpl $16383, %edi # imm = 0x3FFF
66 ; CHECK-NEXT: cmovgl %r8d, %esi
67 ; CHECK-NEXT: cmpl $-16384, %edi # imm = 0xC000
68 ; CHECK-NEXT: cmovll %ecx, %esi
69 ; CHECK-NEXT: movd %xmm0, %eax
71 ; CHECK-NEXT: movl %eax, %edi
72 ; CHECK-NEXT: shrl $16, %edi
73 ; CHECK-NEXT: shldw $1, %ax, %di
74 ; CHECK-NEXT: sarl $16, %eax
75 ; CHECK-NEXT: cmpl $16383, %eax # imm = 0x3FFF
76 ; CHECK-NEXT: cmovgl %r8d, %edi
77 ; CHECK-NEXT: cmpl $-16384, %eax # imm = 0xC000
78 ; CHECK-NEXT: cmovll %ecx, %edi
79 ; CHECK-NEXT: pxor %xmm1, %xmm1
80 ; CHECK-NEXT: pinsrw $0, %edi, %xmm1
81 ; CHECK-NEXT: pinsrw $1, %esi, %xmm1
82 ; CHECK-NEXT: pinsrw $2, %edx, %xmm1
83 ; CHECK-NEXT: pextrw $3, %xmm0, %eax
85 ; CHECK-NEXT: movl %eax, %edx
86 ; CHECK-NEXT: shrl $14, %edx
87 ; CHECK-NEXT: leal (,%rax,4), %esi
88 ; CHECK-NEXT: shrdw $15, %dx, %si
89 ; CHECK-NEXT: sarl $14, %eax
90 ; CHECK-NEXT: cmpl $16383, %eax # imm = 0x3FFF
91 ; CHECK-NEXT: cmovgl %r8d, %esi
92 ; CHECK-NEXT: cmpl $-16384, %eax # imm = 0xC000
93 ; CHECK-NEXT: cmovll %ecx, %esi
94 ; CHECK-NEXT: pinsrw $3, %esi, %xmm1
95 ; CHECK-NEXT: movdqa %xmm1, %xmm0
97 %t = call <4 x i16> @llvm.smul.fix.sat.v4i16(<4 x i16> <i16 1, i16 2, i16 3, i16 4>, <4 x i16> %a, i32 15)