X86: Add patterns for MULHU/MULHS of v8i16 and v16i16.
[oota-llvm.git] / test / CodeGen / X86 / vector-idiv.ll
1 ; RUN: llc -march=x86-64 -mcpu=core2 < %s | FileCheck %s -check-prefix=SSE
2 ; RUN: llc -march=x86-64 -mcpu=core-avx2 < %s | FileCheck %s -check-prefix=AVX
3
4 define <4 x i32> @test1(<4 x i32> %a) {
5   %div = udiv <4 x i32> %a, <i32 7, i32 7, i32 7, i32 7>
6   ret <4 x i32> %div
7
8 ; SSE-LABEL: test1:
9 ; SSE: pmuludq
10 ; SSE: pshufd   $57
11 ; SSE: pmuludq
12 ; SSE: shufps   $-35
13 ; SSE: psubd
14 ; SSE: psrld $1
15 ; SSE: padd
16 ; SSE: psrld $2
17
18 ; AVX-LABEL: test1:
19 ; AVX: vpmuludq
20 ; AVX: vpshufd  $57
21 ; AVX: vpmuludq
22 ; AVX: vshufps  $-35
23 ; AVX: vpsubd
24 ; AVX: vpsrld $1
25 ; AVX: vpadd
26 ; AVX: vpsrld $2
27 }
28
29 define <8 x i32> @test2(<8 x i32> %a) {
30   %div = udiv <8 x i32> %a, <i32 7, i32 7, i32 7, i32 7,i32 7, i32 7, i32 7, i32 7>
31   ret <8 x i32> %div
32
33 ; AVX-LABEL: test2:
34 ; AVX: vpermd
35 ; AVX: vpmuludq
36 ; AVX: vshufps  $-35
37 ; AVX: vpmuludq
38 ; AVX: vshufps  $-35
39 ; AVX: vpsubd
40 ; AVX: vpsrld $1
41 ; AVX: vpadd
42 ; AVX: vpsrld $2
43 }
44
45 define <8 x i16> @test3(<8 x i16> %a) {
46   %div = udiv <8 x i16> %a, <i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7>
47   ret <8 x i16> %div
48
49 ; SSE-LABEL: test3:
50 ; SSE: pmulhuw
51 ; SSE: psubw
52 ; SSE: psrlw $1
53 ; SSE: paddw
54 ; SSE: psrlw $2
55
56 ; AVX-LABEL: test3:
57 ; AVX: vpmulhuw
58 ; AVX: vpsubw
59 ; AVX: vpsrlw $1
60 ; AVX: vpaddw
61 ; AVX: vpsrlw $2
62 }
63
64 define <16 x i16> @test4(<16 x i16> %a) {
65   %div = udiv <16 x i16> %a, <i16 7, i16 7, i16 7, i16 7,i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7,i16 7, i16 7, i16 7, i16 7>
66   ret <16 x i16> %div
67
68 ; AVX-LABEL: test4:
69 ; AVX: vpmulhuw
70 ; AVX: vpsubw
71 ; AVX: vpsrlw $1
72 ; AVX: vpaddw
73 ; AVX: vpsrlw $2
74 ; AVX-NOT: vpmulhuw
75 }
76
77 define <8 x i16> @test5(<8 x i16> %a) {
78   %div = sdiv <8 x i16> %a, <i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7>
79   ret <8 x i16> %div
80
81 ; SSE-LABEL: test5:
82 ; SSE: pmulhw
83 ; SSE: psrlw $15
84 ; SSE: psraw $1
85 ; SSE: paddw
86
87 ; AVX-LABEL: test5:
88 ; AVX: vpmulhw
89 ; AVX: vpsrlw $15
90 ; AVX: vpsraw $1
91 ; AVX: vpaddw
92 }
93
94 define <16 x i16> @test6(<16 x i16> %a) {
95   %div = sdiv <16 x i16> %a, <i16 7, i16 7, i16 7, i16 7,i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7,i16 7, i16 7, i16 7, i16 7>
96   ret <16 x i16> %div
97
98 ; AVX-LABEL: test6:
99 ; AVX: vpmulhw
100 ; AVX: vpsrlw $15
101 ; AVX: vpsraw $1
102 ; AVX: vpaddw
103 ; AVX-NOT: vpmulhw
104 }
105
106 ; TODO: sdiv -> pmuldq