[InstCombine] Signed saturation patterns
[llvm-core.git] / test / CodeGen / AMDGPU / preserve-hi16.ll
bloba0b03363945698b36730e319a06c92d317644ac7
1 ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,GFX9 %s
2 ; RUN: llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,GFX10 %s
4 ; GCN-LABEL: {{^}}shl_i16:
5 ; GCN: v_lshlrev_b16_e{{32|64}} [[OP:v[0-9]+]],
6 ; GFX10-NEXT: ; implicit-def: $vcc_hi
7 ; GCN-NEXT: s_setpc_b64
8 define i16 @shl_i16(i16 %x, i16 %y) {
9   %res = shl i16 %x, %y
10   ret i16 %res
13 ; GCN-LABEL: {{^}}lshr_i16:
14 ; GCN: v_lshrrev_b16_e{{32|64}} [[OP:v[0-9]+]],
15 ; GFX10-NEXT: ; implicit-def: $vcc_hi
16 ; GCN-NEXT: s_setpc_b64
17 define i16 @lshr_i16(i16 %x, i16 %y) {
18   %res = lshr i16 %x, %y
19   ret i16 %res
22 ; GCN-LABEL: {{^}}ashr_i16:
23 ; GCN: v_ashrrev_i16_e{{32|64}} [[OP:v[0-9]+]],
24 ; GFX10-NEXT: ; implicit-def: $vcc_hi
25 ; GCN-NEXT: s_setpc_b64
26 define i16 @ashr_i16(i16 %x, i16 %y) {
27   %res = ashr i16 %x, %y
28   ret i16 %res
31 ; GCN-LABEL: {{^}}add_u16:
32 ; GCN: v_add_{{(nc_)*}}u16_e{{32|64}} [[OP:v[0-9]+]],
33 ; GFX10-NEXT: ; implicit-def: $vcc_hi
34 ; GCN-NEXT: s_setpc_b64
35 define i16 @add_u16(i16 %x, i16 %y) {
36   %res = add i16 %x, %y
37   ret i16 %res
40 ; GCN-LABEL: {{^}}sub_u16:
41 ; GCN: v_sub_{{(nc_)*}}u16_e{{32|64}} [[OP:v[0-9]+]],
42 ; GFX10-NEXT: ; implicit-def: $vcc_hi
43 ; GCN-NEXT: s_setpc_b64
44 define i16 @sub_u16(i16 %x, i16 %y) {
45   %res = sub i16 %x, %y
46   ret i16 %res
49 ; GCN-LABEL: {{^}}mul_lo_u16:
50 ; GCN: v_mul_lo_u16_e{{32|64}} [[OP:v[0-9]+]],
51 ; GFX10-NEXT: ; implicit-def: $vcc_hi
52 ; GCN-NEXT: s_setpc_b64
53 define i16 @mul_lo_u16(i16 %x, i16 %y) {
54   %res = mul i16 %x, %y
55   ret i16 %res
58 ; GCN-LABEL: {{^}}min_u16:
59 ; GCN: v_min_u16_e{{32|64}} [[OP:v[0-9]+]],
60 ; GFX10-NEXT: ; implicit-def: $vcc_hi
61 ; GCN-NEXT: s_setpc_b64
62 define i16 @min_u16(i16 %x, i16 %y) {
63   %cmp = icmp ule i16 %x, %y
64   %res = select i1 %cmp, i16 %x, i16 %y
65   ret i16 %res
68 ; GCN-LABEL: {{^}}min_i16:
69 ; GCN: v_min_i16_e{{32|64}} [[OP:v[0-9]+]],
70 ; GFX10-NEXT: ; implicit-def: $vcc_hi
71 ; GCN-NEXT: s_setpc_b64
72 define i16 @min_i16(i16 %x, i16 %y) {
73   %cmp = icmp sle i16 %x, %y
74   %res = select i1 %cmp, i16 %x, i16 %y
75   ret i16 %res
78 ; GCN-LABEL: {{^}}max_u16:
79 ; GCN: v_max_u16_e{{32|64}} [[OP:v[0-9]+]],
80 ; GFX10-NEXT: ; implicit-def: $vcc_hi
81 ; GCN-NEXT: s_setpc_b64
82 define i16 @max_u16(i16 %x, i16 %y) {
83   %cmp = icmp uge i16 %x, %y
84   %res = select i1 %cmp, i16 %x, i16 %y
85   ret i16 %res
88 ; GCN-LABEL: {{^}}max_i16:
89 ; GCN: v_max_i16_e{{32|64}} [[OP:v[0-9]+]],
90 ; GFX10-NEXT: ; implicit-def: $vcc_hi
91 ; GCN-NEXT: s_setpc_b64
92 define i16 @max_i16(i16 %x, i16 %y) {
93   %cmp = icmp sge i16 %x, %y
94   %res = select i1 %cmp, i16 %x, i16 %y
95   ret i16 %res
98 ; GCN-LABEL: {{^}}shl_i16_zext_i32:
99 ; GCN: v_lshlrev_b16_e{{32|64}} [[OP:v[0-9]+]],
100 ; GFX10-NEXT: ; implicit-def: $vcc_hi
101 ; GFX10-NEXT: v_and_b32_e32 v{{[0-9]+}}, 0xffff, [[OP]]
102 ; GCN-NEXT: s_setpc_b64
103 define i32 @shl_i16_zext_i32(i16 %x, i16 %y) {
104   %res = shl i16 %x, %y
105   %zext = zext i16 %res to i32
106   ret i32 %zext
109 ; GCN-LABEL: {{^}}lshr_i16_zext_i32:
110 ; GCN: v_lshrrev_b16_e{{32|64}} [[OP:v[0-9]+]],
111 ; GFX10-NEXT: ; implicit-def: $vcc_hi
112 ; GFX10-NEXT: v_and_b32_e32 v{{[0-9]+}}, 0xffff, [[OP]]
113 ; GCN-NEXT: s_setpc_b64
114 define i32 @lshr_i16_zext_i32(i16 %x, i16 %y) {
115   %res = lshr i16 %x, %y
116   %zext = zext i16 %res to i32
117   ret i32 %zext
120 ; GCN-LABEL: {{^}}ashr_i16_zext_i32:
121 ; GCN: v_ashrrev_i16_e{{32|64}} [[OP:v[0-9]+]],
122 ; GFX10-NEXT: ; implicit-def: $vcc_hi
123 ; GFX10-NEXT: v_and_b32_e32 v{{[0-9]+}}, 0xffff, [[OP]]
124 ; GCN-NEXT: s_setpc_b64
125 define i32 @ashr_i16_zext_i32(i16 %x, i16 %y) {
126   %res = ashr i16 %x, %y
127   %zext = zext i16 %res to i32
128   ret i32 %zext
131 ; GCN-LABEL: {{^}}add_u16_zext_i32:
132 ; GCN: v_add_{{(nc_)*}}u16_e{{32|64}} [[OP:v[0-9]+]],
133 ; GFX10-NEXT: ; implicit-def: $vcc_hi
134 ; GFX10-NEXT: v_and_b32_e32 v{{[0-9]+}}, 0xffff, [[OP]]
135 ; GCN-NEXT: s_setpc_b64
136 define i32 @add_u16_zext_i32(i16 %x, i16 %y) {
137   %res = add i16 %x, %y
138   %zext = zext i16 %res to i32
139   ret i32 %zext
142 ; GCN-LABEL: {{^}}sub_u16_zext_i32:
143 ; GCN: v_sub_{{(nc_)*}}u16_e{{32|64}} [[OP:v[0-9]+]],
144 ; GFX10-NEXT: ; implicit-def: $vcc_hi
145 ; GFX10-NEXT: v_and_b32_e32 v{{[0-9]+}}, 0xffff, [[OP]]
146 ; GCN-NEXT: s_setpc_b64
147 define i32 @sub_u16_zext_i32(i16 %x, i16 %y) {
148   %res = sub i16 %x, %y
149   %zext = zext i16 %res to i32
150   ret i32 %zext
153 ; GCN-LABEL: {{^}}mul_lo_u16_zext_i32:
154 ; GCN: v_mul_lo_u16_e{{32|64}} [[OP:v[0-9]+]],
155 ; GFX10-NEXT: ; implicit-def: $vcc_hi
156 ; GFX10-NEXT: v_and_b32_e32 v{{[0-9]+}}, 0xffff, [[OP]]
157 ; GCN-NEXT: s_setpc_b64
158 define i32 @mul_lo_u16_zext_i32(i16 %x, i16 %y) {
159   %res = mul i16 %x, %y
160   %zext = zext i16 %res to i32
161   ret i32 %zext
164 ; GCN-LABEL: {{^}}min_u16_zext_i32:
165 ; GCN: v_min_u16_e{{32|64}} [[OP:v[0-9]+]],
166 ; GFX10-NEXT: ; implicit-def: $vcc_hi
167 ; GFX10-NEXT: v_and_b32_e32 v{{[0-9]+}}, 0xffff, [[OP]]
168 ; GCN-NEXT: s_setpc_b64
169 define i32 @min_u16_zext_i32(i16 %x, i16 %y) {
170   %cmp = icmp ule i16 %x, %y
171   %res = select i1 %cmp, i16 %x, i16 %y
172   %zext = zext i16 %res to i32
173   ret i32 %zext
176 ; GCN-LABEL: {{^}}min_i16_zext_i32:
177 ; GCN: v_min_i16_e{{32|64}} [[OP:v[0-9]+]],
178 ; GFX10-NEXT: ; implicit-def: $vcc_hi
179 ; GFX10-NEXT: v_and_b32_e32 v{{[0-9]+}}, 0xffff, [[OP]]
180 ; GCN-NEXT: s_setpc_b64
181 define i32 @min_i16_zext_i32(i16 %x, i16 %y) {
182   %cmp = icmp sle i16 %x, %y
183   %res = select i1 %cmp, i16 %x, i16 %y
184   %zext = zext i16 %res to i32
185   ret i32 %zext
188 ; GCN-LABEL: {{^}}max_u16_zext_i32:
189 ; GCN: v_max_u16_e{{32|64}} [[OP:v[0-9]+]],
190 ; GFX10-NEXT: ; implicit-def: $vcc_hi
191 ; GFX10-NEXT: v_and_b32_e32 v{{[0-9]+}}, 0xffff, [[OP]]
192 ; GCN-NEXT: s_setpc_b64
193 define i32 @max_u16_zext_i32(i16 %x, i16 %y) {
194   %cmp = icmp uge i16 %x, %y
195   %res = select i1 %cmp, i16 %x, i16 %y
196   %zext = zext i16 %res to i32
197   ret i32 %zext
200 ; GCN-LABEL: {{^}}max_i16_zext_i32:
201 ; GCN: v_max_i16_e{{32|64}} [[OP:v[0-9]+]],
202 ; GFX10-NEXT: ; implicit-def: $vcc_hi
203 ; GFX10-NEXT: v_and_b32_e32 v{{[0-9]+}}, 0xffff, [[OP]]
204 ; GCN-NEXT: s_setpc_b64
205 define i32 @max_i16_zext_i32(i16 %x, i16 %y) {
206   %cmp = icmp sge i16 %x, %y
207   %res = select i1 %cmp, i16 %x, i16 %y
208   %zext = zext i16 %res to i32
209   ret i32 %zext