annotate lib/Target/X86/X86InstrVecCompiler.td @ 121:803732b1fca8

LLVM 5.0
author kono
date Fri, 27 Oct 2017 17:07:41 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
1 //===- X86InstrVecCompiler.td - Vector Compiler Patterns ---*- tablegen -*-===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
2 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
3 // The LLVM Compiler Infrastructure
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
4 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
5 // This file is distributed under the University of Illinois Open Source
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
6 // License. See LICENSE.TXT for details.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
7 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
9 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
10 // This file describes the various vector pseudo instructions used by the
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
11 // compiler, as well as Pat patterns used during instruction selection.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
12 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
13 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
14
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
15 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
16 // No op bitconverts
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
17 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
18
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
19 // Bitcasts between 128-bit vector types. Return the original type since
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
20 // no instruction is needed for the conversion
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
21 def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
22 def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
23 def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
24 def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
25 def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
26 def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
27 def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
28 def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
29 def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
30 def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
31 def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
32 def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
33 def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
34 def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
35 def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
36 def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
37 def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
38 def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
39 def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
40 def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
41 def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
42 def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
43 def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
44 def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
45 def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
46 def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
47 def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
48 def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
49 def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
50 def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
51 def : Pat<(f128 (bitconvert (i128 FR128:$src))), (f128 FR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
52 def : Pat<(i128 (bitconvert (f128 FR128:$src))), (i128 FR128:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
53
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
54 // Bitcasts between 256-bit vector types. Return the original type since
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
55 // no instruction is needed for the conversion
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
56 def : Pat<(v4i64 (bitconvert (v8i32 VR256:$src))), (v4i64 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
57 def : Pat<(v4i64 (bitconvert (v16i16 VR256:$src))), (v4i64 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
58 def : Pat<(v4i64 (bitconvert (v32i8 VR256:$src))), (v4i64 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
59 def : Pat<(v4i64 (bitconvert (v8f32 VR256:$src))), (v4i64 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
60 def : Pat<(v4i64 (bitconvert (v4f64 VR256:$src))), (v4i64 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
61 def : Pat<(v8i32 (bitconvert (v4i64 VR256:$src))), (v8i32 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
62 def : Pat<(v8i32 (bitconvert (v16i16 VR256:$src))), (v8i32 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
63 def : Pat<(v8i32 (bitconvert (v32i8 VR256:$src))), (v8i32 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
64 def : Pat<(v8i32 (bitconvert (v4f64 VR256:$src))), (v8i32 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
65 def : Pat<(v8i32 (bitconvert (v8f32 VR256:$src))), (v8i32 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
66 def : Pat<(v16i16 (bitconvert (v4i64 VR256:$src))), (v16i16 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
67 def : Pat<(v16i16 (bitconvert (v8i32 VR256:$src))), (v16i16 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
68 def : Pat<(v16i16 (bitconvert (v32i8 VR256:$src))), (v16i16 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
69 def : Pat<(v16i16 (bitconvert (v4f64 VR256:$src))), (v16i16 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
70 def : Pat<(v16i16 (bitconvert (v8f32 VR256:$src))), (v16i16 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
71 def : Pat<(v32i8 (bitconvert (v4i64 VR256:$src))), (v32i8 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
72 def : Pat<(v32i8 (bitconvert (v8i32 VR256:$src))), (v32i8 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
73 def : Pat<(v32i8 (bitconvert (v16i16 VR256:$src))), (v32i8 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
74 def : Pat<(v32i8 (bitconvert (v4f64 VR256:$src))), (v32i8 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
75 def : Pat<(v32i8 (bitconvert (v8f32 VR256:$src))), (v32i8 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
76 def : Pat<(v8f32 (bitconvert (v4i64 VR256:$src))), (v8f32 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
77 def : Pat<(v8f32 (bitconvert (v8i32 VR256:$src))), (v8f32 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
78 def : Pat<(v8f32 (bitconvert (v16i16 VR256:$src))), (v8f32 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
79 def : Pat<(v8f32 (bitconvert (v32i8 VR256:$src))), (v8f32 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
80 def : Pat<(v8f32 (bitconvert (v4f64 VR256:$src))), (v8f32 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
81 def : Pat<(v4f64 (bitconvert (v4i64 VR256:$src))), (v4f64 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
82 def : Pat<(v4f64 (bitconvert (v8i32 VR256:$src))), (v4f64 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
83 def : Pat<(v4f64 (bitconvert (v16i16 VR256:$src))), (v4f64 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
84 def : Pat<(v4f64 (bitconvert (v32i8 VR256:$src))), (v4f64 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
85 def : Pat<(v4f64 (bitconvert (v8f32 VR256:$src))), (v4f64 VR256:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
86
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
87 // Bitcasts between 512-bit vector types. Return the original type since
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
88 // no instruction is needed for the conversion.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
89 def : Pat<(v8f64 (bitconvert (v8i64 VR512:$src))), (v8f64 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
90 def : Pat<(v8f64 (bitconvert (v16i32 VR512:$src))), (v8f64 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
91 def : Pat<(v8f64 (bitconvert (v32i16 VR512:$src))), (v8f64 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
92 def : Pat<(v8f64 (bitconvert (v64i8 VR512:$src))), (v8f64 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
93 def : Pat<(v8f64 (bitconvert (v16f32 VR512:$src))), (v8f64 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
94 def : Pat<(v16f32 (bitconvert (v8i64 VR512:$src))), (v16f32 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
95 def : Pat<(v16f32 (bitconvert (v16i32 VR512:$src))), (v16f32 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
96 def : Pat<(v16f32 (bitconvert (v32i16 VR512:$src))), (v16f32 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
97 def : Pat<(v16f32 (bitconvert (v64i8 VR512:$src))), (v16f32 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
98 def : Pat<(v16f32 (bitconvert (v8f64 VR512:$src))), (v16f32 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
99 def : Pat<(v8i64 (bitconvert (v16i32 VR512:$src))), (v8i64 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
100 def : Pat<(v8i64 (bitconvert (v32i16 VR512:$src))), (v8i64 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
101 def : Pat<(v8i64 (bitconvert (v64i8 VR512:$src))), (v8i64 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
102 def : Pat<(v8i64 (bitconvert (v8f64 VR512:$src))), (v8i64 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
103 def : Pat<(v8i64 (bitconvert (v16f32 VR512:$src))), (v8i64 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
104 def : Pat<(v16i32 (bitconvert (v8i64 VR512:$src))), (v16i32 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
105 def : Pat<(v16i32 (bitconvert (v16f32 VR512:$src))), (v16i32 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
106 def : Pat<(v16i32 (bitconvert (v32i16 VR512:$src))), (v16i32 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
107 def : Pat<(v16i32 (bitconvert (v64i8 VR512:$src))), (v16i32 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
108 def : Pat<(v16i32 (bitconvert (v8f64 VR512:$src))), (v16i32 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
109 def : Pat<(v32i16 (bitconvert (v8i64 VR512:$src))), (v32i16 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
110 def : Pat<(v32i16 (bitconvert (v16i32 VR512:$src))), (v32i16 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
111 def : Pat<(v32i16 (bitconvert (v64i8 VR512:$src))), (v32i16 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
112 def : Pat<(v32i16 (bitconvert (v8f64 VR512:$src))), (v32i16 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
113 def : Pat<(v32i16 (bitconvert (v16f32 VR512:$src))), (v32i16 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
114 def : Pat<(v32i16 (bitconvert (v16f32 VR512:$src))), (v32i16 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
115 def : Pat<(v64i8 (bitconvert (v8i64 VR512:$src))), (v64i8 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
116 def : Pat<(v64i8 (bitconvert (v16i32 VR512:$src))), (v64i8 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
117 def : Pat<(v64i8 (bitconvert (v32i16 VR512:$src))), (v64i8 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
118 def : Pat<(v64i8 (bitconvert (v8f64 VR512:$src))), (v64i8 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
119 def : Pat<(v64i8 (bitconvert (v16f32 VR512:$src))), (v64i8 VR512:$src)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
120
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
122 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
123 // Non-instruction patterns
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
124 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
125
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
126 // A vector extract of the first f32/f64 position is a subregister copy
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
127 def : Pat<(f32 (extractelt (v4f32 VR128:$src), (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
128 (COPY_TO_REGCLASS (v4f32 VR128:$src), FR32)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
129 def : Pat<(f64 (extractelt (v2f64 VR128:$src), (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
130 (COPY_TO_REGCLASS (v2f64 VR128:$src), FR64)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
131
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
132 // Implicitly promote a 32-bit scalar to a vector.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
133 def : Pat<(v4f32 (scalar_to_vector FR32:$src)),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
134 (COPY_TO_REGCLASS FR32:$src, VR128)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
135 // Implicitly promote a 64-bit scalar to a vector.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
136 def : Pat<(v2f64 (scalar_to_vector FR64:$src)),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
137 (COPY_TO_REGCLASS FR64:$src, VR128)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
138
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
139
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
140 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
141 // Subvector tricks
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
142 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
143
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
144 // Patterns for insert_subvector/extract_subvector to/from index=0
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
145 multiclass subvector_subreg_lowering<RegisterClass subRC, ValueType subVT,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
146 RegisterClass RC, ValueType VT,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
147 SubRegIndex subIdx> {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
148 def : Pat<(subVT (extract_subvector (VT RC:$src), (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
149 (subVT (EXTRACT_SUBREG RC:$src, subIdx))>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
150
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
151 let AddedComplexity = 25 in // to give priority over vinsertf128rm
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
152 def : Pat<(VT (insert_subvector undef, subRC:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
153 (VT (INSERT_SUBREG (IMPLICIT_DEF), subRC:$src, subIdx))>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
154 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
155
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
156 // A 128-bit subvector extract from the first 256-bit vector position is a
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
157 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
158 // insert to the first 256-bit vector position is a subregister copy that needs
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
159 // no instruction.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
160 defm : subvector_subreg_lowering<VR128, v4i32, VR256, v8i32, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
161 defm : subvector_subreg_lowering<VR128, v4f32, VR256, v8f32, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
162 defm : subvector_subreg_lowering<VR128, v2i64, VR256, v4i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
163 defm : subvector_subreg_lowering<VR128, v2f64, VR256, v4f64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
164 defm : subvector_subreg_lowering<VR128, v8i16, VR256, v16i16, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
165 defm : subvector_subreg_lowering<VR128, v16i8, VR256, v32i8, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
166
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
167 // A 128-bit subvector extract from the first 512-bit vector position is a
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
168 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
169 // insert to the first 512-bit vector position is a subregister copy that needs
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
170 // no instruction.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
171 defm : subvector_subreg_lowering<VR128, v4i32, VR512, v16i32, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
172 defm : subvector_subreg_lowering<VR128, v4f32, VR512, v16f32, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
173 defm : subvector_subreg_lowering<VR128, v2i64, VR512, v8i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
174 defm : subvector_subreg_lowering<VR128, v2f64, VR512, v8f64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
175 defm : subvector_subreg_lowering<VR128, v8i16, VR512, v32i16, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
176 defm : subvector_subreg_lowering<VR128, v16i8, VR512, v64i8, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
177
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
178 // A 128-bit subvector extract from the first 512-bit vector position is a
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
179 // subregister copy that needs no instruction. Likewise, a 128-bit subvector
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
180 // insert to the first 512-bit vector position is a subregister copy that needs
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
181 // no instruction.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
182 defm : subvector_subreg_lowering<VR256, v8i32, VR512, v16i32, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
183 defm : subvector_subreg_lowering<VR256, v8f32, VR512, v16f32, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
184 defm : subvector_subreg_lowering<VR256, v4i64, VR512, v8i64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
185 defm : subvector_subreg_lowering<VR256, v4f64, VR512, v8f64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
186 defm : subvector_subreg_lowering<VR256, v16i16, VR512, v32i16, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
187 defm : subvector_subreg_lowering<VR256, v32i8, VR512, v64i8, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
188
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
189
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
190 multiclass subvector_store_lowering<string AlignedStr, string UnalignedStr,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
191 RegisterClass RC, ValueType DstTy,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
192 ValueType SrcTy, SubRegIndex SubIdx> {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
193 def : Pat<(alignedstore (DstTy (extract_subvector
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
194 (SrcTy RC:$src), (iPTR 0))), addr:$dst),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
195 (!cast<Instruction>("VMOV"#AlignedStr#"mr") addr:$dst,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
196 (DstTy (EXTRACT_SUBREG RC:$src, SubIdx)))>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
197
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
198 def : Pat<(store (DstTy (extract_subvector
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
199 (SrcTy RC:$src), (iPTR 0))), addr:$dst),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
200 (!cast<Instruction>("VMOV"#UnalignedStr#"mr") addr:$dst,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
201 (DstTy (EXTRACT_SUBREG RC:$src, SubIdx)))>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
202 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
203
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
204 let Predicates = [HasAVX, NoVLX] in {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
205 defm : subvector_store_lowering<"APD", "UPD", VR256X, v2f64, v4f64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
206 defm : subvector_store_lowering<"APS", "UPS", VR256X, v4f32, v8f32, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
207 defm : subvector_store_lowering<"DQA", "DQU", VR256X, v2i64, v4i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
208 defm : subvector_store_lowering<"DQA", "DQU", VR256X, v4i32, v8i32, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
209 defm : subvector_store_lowering<"DQA", "DQU", VR256X, v8i16, v16i16, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
210 defm : subvector_store_lowering<"DQA", "DQU", VR256X, v16i8, v32i8, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
211 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
212
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
213 let Predicates = [HasVLX] in {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
214 // Special patterns for storing subvector extracts of lower 128-bits
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
215 // Its cheaper to just use VMOVAPS/VMOVUPS instead of VEXTRACTF128mr
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
216 defm : subvector_store_lowering<"APDZ128", "UPDZ128", VR256X, v2f64, v4f64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
217 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
218 defm : subvector_store_lowering<"APSZ128", "UPSZ128", VR256X, v4f32, v8f32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
219 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
220 defm : subvector_store_lowering<"DQA32Z128", "DQU32Z128", VR256X, v2i64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
221 v4i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
222 defm : subvector_store_lowering<"DQA32Z128", "DQU32Z128", VR256X, v4i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
223 v8i32, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
224 defm : subvector_store_lowering<"DQA32Z128", "DQU32Z128", VR256X, v8i16,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
225 v16i16, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
226 defm : subvector_store_lowering<"DQA32Z128", "DQU32Z128", VR256X, v16i8,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
227 v32i8, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
228
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
229 // Special patterns for storing subvector extracts of lower 128-bits of 512.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
230 // Its cheaper to just use VMOVAPS/VMOVUPS instead of VEXTRACTF128mr
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
231 defm : subvector_store_lowering<"APDZ128", "UPDZ128", VR512, v2f64, v8f64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
232 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
233 defm : subvector_store_lowering<"APSZ128", "UPSZ128", VR512, v4f32, v16f32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
234 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
235 defm : subvector_store_lowering<"DQA32Z128", "DQU32Z128", VR512, v2i64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
236 v8i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
237 defm : subvector_store_lowering<"DQA32Z128", "DQU32Z128", VR512, v4i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
238 v16i32, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
239 defm : subvector_store_lowering<"DQA32Z128", "DQU32Z128", VR512, v8i16,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
240 v32i16, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
241 defm : subvector_store_lowering<"DQA32Z128", "DQU32Z128", VR512, v16i8,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
242 v64i8, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
243
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
244 // Special patterns for storing subvector extracts of lower 256-bits of 512.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
245 // Its cheaper to just use VMOVAPS/VMOVUPS instead of VEXTRACTF128mr
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
246 defm : subvector_store_lowering<"APDZ256", "UPDZ256", VR512, v4f64, v8f64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
247 sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
248 defm : subvector_store_lowering<"APSZ256", "UPSZ256", VR512, v8f32, v16f32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
249 sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
250 defm : subvector_store_lowering<"DQA32Z256", "DQU32Z256", VR512, v4i64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
251 v8i64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
252 defm : subvector_store_lowering<"DQA32Z256", "DQU32Z256", VR512, v8i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
253 v16i32, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
254 defm : subvector_store_lowering<"DQA32Z256", "DQU32Z256", VR512, v16i16,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
255 v32i16, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
256 defm : subvector_store_lowering<"DQA32Z256", "DQU32Z256", VR512, v32i8,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
257 v64i8, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
258 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
259
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
260 // If we're inserting into an all zeros vector, just use a plain move which
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
261 // will zero the upper bits.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
262 // TODO: Is there a safe way to detect whether the producing instruction
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
263 // already zeroed the upper bits?
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
264 multiclass subvector_zero_lowering<string MoveStr, RegisterClass RC,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
265 ValueType DstTy, ValueType SrcTy,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
266 ValueType ZeroTy, PatFrag memop,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
267 SubRegIndex SubIdx> {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
268 def : Pat<(DstTy (insert_subvector (bitconvert (ZeroTy immAllZerosV)),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
269 (SrcTy RC:$src), (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
270 (SUBREG_TO_REG (i64 0),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
271 (!cast<Instruction>("VMOV"#MoveStr#"rr") RC:$src), SubIdx)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
272
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
273 def : Pat<(DstTy (insert_subvector (bitconvert (ZeroTy immAllZerosV)),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
274 (SrcTy (bitconvert (memop addr:$src))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
275 (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
276 (SUBREG_TO_REG (i64 0),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
277 (!cast<Instruction>("VMOV"#MoveStr#"rm") addr:$src), SubIdx)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
278 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
279
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
280 let Predicates = [HasAVX, NoVLX] in {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
281 defm : subvector_zero_lowering<"APD", VR128, v4f64, v2f64, v8i32, loadv2f64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
282 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
283 defm : subvector_zero_lowering<"APS", VR128, v8f32, v4f32, v8i32, loadv4f32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
284 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
285 defm : subvector_zero_lowering<"DQA", VR128, v4i64, v2i64, v8i32, loadv2i64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
286 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
287 defm : subvector_zero_lowering<"DQA", VR128, v8i32, v4i32, v8i32, loadv2i64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
288 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
289 defm : subvector_zero_lowering<"DQA", VR128, v16i16, v8i16, v8i32, loadv2i64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
290 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
291 defm : subvector_zero_lowering<"DQA", VR128, v32i8, v16i8, v8i32, loadv2i64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
292 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
293 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
294
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
295 let Predicates = [HasVLX] in {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
296 defm : subvector_zero_lowering<"APDZ128", VR128X, v4f64, v2f64, v8i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
297 loadv2f64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
298 defm : subvector_zero_lowering<"APSZ128", VR128X, v8f32, v4f32, v8i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
299 loadv4f32, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
300 defm : subvector_zero_lowering<"DQA64Z128", VR128X, v4i64, v2i64, v8i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
301 loadv2i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
302 defm : subvector_zero_lowering<"DQA64Z128", VR128X, v8i32, v4i32, v8i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
303 loadv2i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
304 defm : subvector_zero_lowering<"DQA64Z128", VR128X, v16i16, v8i16, v8i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
305 loadv2i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
306 defm : subvector_zero_lowering<"DQA64Z128", VR128X, v32i8, v16i8, v8i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
307 loadv2i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
308
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
309 defm : subvector_zero_lowering<"APDZ128", VR128X, v8f64, v2f64, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
310 loadv2f64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
311 defm : subvector_zero_lowering<"APSZ128", VR128X, v16f32, v4f32, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
312 loadv4f32, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
313 defm : subvector_zero_lowering<"DQA64Z128", VR128X, v8i64, v2i64, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
314 loadv2i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
315 defm : subvector_zero_lowering<"DQA64Z128", VR128X, v16i32, v4i32, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
316 loadv2i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
317 defm : subvector_zero_lowering<"DQA64Z128", VR128X, v32i16, v8i16, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
318 loadv2i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
319 defm : subvector_zero_lowering<"DQA64Z128", VR128X, v64i8, v16i8, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
320 loadv2i64, sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
321
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
322 defm : subvector_zero_lowering<"APDZ256", VR256X, v8f64, v4f64, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
323 loadv4f64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
324 defm : subvector_zero_lowering<"APSZ256", VR256X, v16f32, v8f32, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
325 loadv8f32, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
326 defm : subvector_zero_lowering<"DQA64Z256", VR256X, v8i64, v4i64, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
327 loadv4i64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
328 defm : subvector_zero_lowering<"DQA64Z256", VR256X, v16i32, v8i32, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
329 loadv4i64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
330 defm : subvector_zero_lowering<"DQA64Z256", VR256X, v32i16, v16i16, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
331 loadv4i64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
332 defm : subvector_zero_lowering<"DQA64Z256", VR256X, v64i8, v32i8, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
333 loadv4i64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
334 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
335
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
336 let Predicates = [HasAVX512, NoVLX] in {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
337 defm : subvector_zero_lowering<"APD", VR128, v8f64, v2f64, v16i32, loadv2f64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
338 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
339 defm : subvector_zero_lowering<"APS", VR128, v16f32, v4f32, v16i32, loadv4f32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
340 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
341 defm : subvector_zero_lowering<"DQA", VR128, v8i64, v2i64, v16i32, loadv2i64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
342 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
343 defm : subvector_zero_lowering<"DQA", VR128, v16i32, v4i32, v16i32, loadv2i64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
344 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
345 defm : subvector_zero_lowering<"DQA", VR128, v32i16, v8i16, v16i32, loadv2i64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
346 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
347 defm : subvector_zero_lowering<"DQA", VR128, v64i8, v16i8, v16i32, loadv2i64,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
348 sub_xmm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
349
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
350 defm : subvector_zero_lowering<"APDY", VR256, v8f64, v4f64, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
351 loadv4f64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
352 defm : subvector_zero_lowering<"APSY", VR256, v16f32, v8f32, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
353 loadv8f32, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
354 defm : subvector_zero_lowering<"DQAY", VR256, v8i64, v4i64, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
355 loadv4i64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
356 defm : subvector_zero_lowering<"DQAY", VR256, v16i32, v8i32, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
357 loadv4i64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
358 defm : subvector_zero_lowering<"DQAY", VR256, v32i16, v16i16, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
359 loadv4i64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
360 defm : subvector_zero_lowering<"DQAY", VR256, v64i8, v32i8, v16i32,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
361 loadv4i64, sub_ymm>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
362 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
363
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
364 // List of opcodes that guaranteed to zero the upper elements of vector regs.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
365 // TODO: Ideally this would be a blacklist instead of a whitelist. But SHA
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
366 // intrinsics and some MMX->XMM move instructions that aren't VEX encoded make
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
367 // this difficult. So starting with a couple opcodes used by reduction loops
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
368 // where we explicitly insert zeros.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
369 class veczeroupper<ValueType vt, RegisterClass RC> :
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
370 PatLeaf<(vt RC:$src), [{
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
371 return N->getOpcode() == X86ISD::VPMADDWD ||
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
372 N->getOpcode() == X86ISD::PSADBW;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
373 }]>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
374
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
375 def zeroupperv2f64 : veczeroupper<v2f64, VR128>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
376 def zeroupperv4f32 : veczeroupper<v4f32, VR128>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
377 def zeroupperv2i64 : veczeroupper<v2i64, VR128>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
378 def zeroupperv4i32 : veczeroupper<v4i32, VR128>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
379 def zeroupperv8i16 : veczeroupper<v8i16, VR128>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
380 def zeroupperv16i8 : veczeroupper<v16i8, VR128>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
381
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
382 def zeroupperv4f64 : veczeroupper<v4f64, VR256>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
383 def zeroupperv8f32 : veczeroupper<v8f32, VR256>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
384 def zeroupperv4i64 : veczeroupper<v4i64, VR256>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
385 def zeroupperv8i32 : veczeroupper<v8i32, VR256>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
386 def zeroupperv16i16 : veczeroupper<v16i16, VR256>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
387 def zeroupperv32i8 : veczeroupper<v32i8, VR256>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
388
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
389
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
390 // If we can guarantee the upper elements have already been zeroed we can elide
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
391 // an explicit zeroing.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
392 multiclass subvector_zero_ellision<RegisterClass RC, ValueType DstTy,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
393 ValueType SrcTy, ValueType ZeroTy,
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
394 SubRegIndex SubIdx, PatLeaf Zeroupper> {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
395 def : Pat<(DstTy (insert_subvector (bitconvert (ZeroTy immAllZerosV)),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
396 Zeroupper:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
397 (SUBREG_TO_REG (i64 0), RC:$src, SubIdx)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
398 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
399
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
400 // 128->256
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
401 defm: subvector_zero_ellision<VR128, v4f64, v2f64, v8i32, sub_xmm, zeroupperv2f64>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
402 defm: subvector_zero_ellision<VR128, v8f32, v4f32, v8i32, sub_xmm, zeroupperv4f32>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
403 defm: subvector_zero_ellision<VR128, v4i64, v2i64, v8i32, sub_xmm, zeroupperv2i64>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
404 defm: subvector_zero_ellision<VR128, v8i32, v4i32, v8i32, sub_xmm, zeroupperv4i32>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
405 defm: subvector_zero_ellision<VR128, v16i16, v8i16, v8i32, sub_xmm, zeroupperv8i16>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
406 defm: subvector_zero_ellision<VR128, v32i8, v16i8, v8i32, sub_xmm, zeroupperv16i8>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
407
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
408 // 128->512
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
409 defm: subvector_zero_ellision<VR128, v8f64, v2f64, v16i32, sub_xmm, zeroupperv2f64>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
410 defm: subvector_zero_ellision<VR128, v16f32, v4f32, v16i32, sub_xmm, zeroupperv4f32>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
411 defm: subvector_zero_ellision<VR128, v8i64, v2i64, v16i32, sub_xmm, zeroupperv2i64>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
412 defm: subvector_zero_ellision<VR128, v16i32, v4i32, v16i32, sub_xmm, zeroupperv4i32>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
413 defm: subvector_zero_ellision<VR128, v32i16, v8i16, v16i32, sub_xmm, zeroupperv8i16>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
414 defm: subvector_zero_ellision<VR128, v64i8, v16i8, v16i32, sub_xmm, zeroupperv16i8>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
415
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
416 // 256->512
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
417 defm: subvector_zero_ellision<VR256, v8f64, v4f64, v16i32, sub_ymm, zeroupperv4f64>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
418 defm: subvector_zero_ellision<VR256, v16f32, v8f32, v16i32, sub_ymm, zeroupperv8f32>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
419 defm: subvector_zero_ellision<VR256, v8i64, v4i64, v16i32, sub_ymm, zeroupperv4i64>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
420 defm: subvector_zero_ellision<VR256, v16i32, v8i32, v16i32, sub_ymm, zeroupperv8i32>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
421 defm: subvector_zero_ellision<VR256, v32i16, v16i16, v16i32, sub_ymm, zeroupperv16i16>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
422 defm: subvector_zero_ellision<VR256, v64i8, v32i8, v16i32, sub_ymm, zeroupperv32i8>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
423
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
424
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
425 class maskzeroupper<ValueType vt, RegisterClass RC> :
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
426 PatLeaf<(vt RC:$src), [{
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
427 return isMaskZeroExtended(N);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
428 }]>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
429
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
430 def maskzeroupperv2i1 : maskzeroupper<v2i1, VK2>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
431 def maskzeroupperv4i1 : maskzeroupper<v4i1, VK4>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
432 def maskzeroupperv8i1 : maskzeroupper<v8i1, VK8>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
433 def maskzeroupperv16i1 : maskzeroupper<v16i1, VK16>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
434 def maskzeroupperv32i1 : maskzeroupper<v32i1, VK32>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
435
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
436 // The patterns determine if we can depend on the upper bits of a mask register
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
437 // being zeroed by the previous operation so that we can skip explicit
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
438 // zeroing.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
439 let Predicates = [HasBWI] in {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
440 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
441 maskzeroupperv8i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
442 (COPY_TO_REGCLASS VK8:$src, VK32)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
443 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
444 maskzeroupperv16i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
445 (COPY_TO_REGCLASS VK16:$src, VK32)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
446 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
447 maskzeroupperv8i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
448 (COPY_TO_REGCLASS VK8:$src, VK64)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
449 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
450 maskzeroupperv16i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
451 (COPY_TO_REGCLASS VK16:$src, VK64)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
452 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
453 maskzeroupperv32i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
454 (COPY_TO_REGCLASS VK32:$src, VK64)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
455 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
456
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
457 let Predicates = [HasAVX512] in {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
458 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
459 maskzeroupperv8i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
460 (COPY_TO_REGCLASS VK8:$src, VK16)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
461 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
462
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
463 let Predicates = [HasVLX] in {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
464 def : Pat<(v4i1 (insert_subvector (v4i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
465 maskzeroupperv2i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
466 (COPY_TO_REGCLASS VK2:$src, VK4)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
467 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
468 maskzeroupperv2i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
469 (COPY_TO_REGCLASS VK2:$src, VK8)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
470 def : Pat<(v8i1 (insert_subvector (v8i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
471 maskzeroupperv4i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
472 (COPY_TO_REGCLASS VK4:$src, VK8)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
473 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
474 maskzeroupperv2i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
475 (COPY_TO_REGCLASS VK2:$src, VK16)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
476 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
477 maskzeroupperv4i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
478 (COPY_TO_REGCLASS VK4:$src, VK16)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
479 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
480
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
481 let Predicates = [HasBWI, HasVLX] in {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
482 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
483 maskzeroupperv2i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
484 (COPY_TO_REGCLASS VK2:$src, VK32)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
485 def : Pat<(v32i1 (insert_subvector (v32i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
486 maskzeroupperv4i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
487 (COPY_TO_REGCLASS VK4:$src, VK32)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
488 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
489 maskzeroupperv2i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
490 (COPY_TO_REGCLASS VK2:$src, VK64)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
491 def : Pat<(v64i1 (insert_subvector (v64i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
492 maskzeroupperv4i1:$src, (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
493 (COPY_TO_REGCLASS VK4:$src, VK64)>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
494 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
495
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
496 // If the bits are not zero we have to fall back to explicitly zeroing by
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
497 // using shifts.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
498 let Predicates = [HasAVX512, NoVLX] in {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
499 def : Pat<(v16i1 (insert_subvector (v16i1 immAllZerosV),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
500 (v8i1 VK8:$mask), (iPTR 0))),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
501 (KSHIFTRWri (KSHIFTLWri (COPY_TO_REGCLASS VK8:$mask, VK16),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
502 (i8 8)), (i8 8))>;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
503 }