1# RUN: llvm-mc -triple hexagon -filetype=obj -o - %s | llvm-objdump -d - | FileCheck %s
2# Hexagon Programmer's Reference Manual 11.1.3 ALU32/PRED
3
4# Conditional add
5# CHECK: f1 c3 75 74
6if (p3) r17 = add(r21, #31)
7# CHECK: 03 40 45 85
8# CHECK-NEXT: f1 e3 75 74
9{ p3 = r5
10  if (p3.new) r17 = add(r21, #31) }
11# CHECK: f1 c3 f5 74
12if (!p3) r17 = add(r21, #31)
13# CHECK: 03 40 45 85
14# CHECK-NEXT: f1 e3 f5 74
15{ p3 = r5
16  if (!p3.new) r17 = add(r21, #31) }
17# CHECK: 71 df 15 fb
18if (p3) r17 = add(r21, r31)
19# CHECK: 03 40 45 85
20# CHECK-NEXT: 71 ff 15 fb
21{ p3 = r5
22  if (p3.new) r17 = add(r21, r31) }
23# CHECK: f1 df 15 fb
24if (!p3) r17 = add(r21, r31)
25# CHECK: 03 40 45 85
26# CHECK-NEXT: f1 ff 15 fb
27{ p3 = r5
28  if (!p3.new) r17 = add(r21, r31) }
29
30# Conditional shift halfword
31# CHECK: 11 e3 15 70
32if (p3) r17 = aslh(r21)
33# CHECK: 03 40 45 85
34# CHECK-NEXT: 11 e7 15 70
35{ p3 = r5
36  if (p3.new) r17 = aslh(r21) }
37# CHECK: 11 eb 15 70
38if (!p3) r17 = aslh(r21)
39# CHECK: 03 40 45 85
40# CHECK-NEXT: 11 ef 15 70
41{ p3 = r5
42  if (!p3.new) r17 = aslh(r21) }
43# CHECK: 11 e3 35 70
44if (p3) r17 = asrh(r21)
45# CHECK: 03 40 45 85
46# CHECK-NEXT: 11 e7 35 70
47{ p3 = r5
48  if (p3.new) r17 = asrh(r21) }
49# CHECK: 11 eb 35 70
50if (!p3) r17 = asrh(r21)
51# CHECK: 03 40 45 85
52# CHECK-NEXT: 11 ef 35 70
53{ p3 = r5
54  if (!p3.new) r17 = asrh(r21) }
55
56# Conditional combine
57# CHECK: 70 df 15 fd
58if (p3) r17:16 = combine(r21, r31)
59# CHECK: f0 df 15 fd
60if (!p3) r17:16 = combine(r21, r31)
61# CHECK: 03 40 45 85
62# CHECK-NEXT: 70 ff 15 fd
63{ p3 = r5
64  if (p3.new) r17:16 = combine(r21, r31) }
65# CHECK: 03 40 45 85
66# CHECK-NEXT: f0 ff 15 fd
67{ p3 = r5
68  if (!p3.new) r17:16 = combine(r21, r31) }
69
70# Conditional logical operations
71# CHECK: 71 df 15 f9
72if (p3) r17 = and(r21, r31)
73# CHECK: f1 df 15 f9
74if (!p3) r17 = and(r21, r31)
75# CHECK: 03 40 45 85
76# CHECK-NEXT: 71 ff 15 f9
77{ p3 = r5
78  if (p3.new) r17 = and(r21, r31) }
79# CHECK: 03 40 45 85
80# CHECK-NEXT: f1 ff 15 f9
81{ p3 = r5
82  if (!p3.new) r17 = and(r21, r31) }
83# CHECK: 71 df 35 f9
84if (p3) r17 = or(r21, r31)
85# CHECK: f1 df 35 f9
86if (!p3) r17 = or(r21, r31)
87# CHECK: 03 40 45 85
88# CHECK-NEXT: 71 ff 35 f9
89{ p3 = r5
90  if (p3.new) r17 = or(r21, r31) }
91# CHECK: 03 40 45 85
92# CHECK-NEXT: f1 ff 35 f9
93{ p3 = r5
94  if (!p3.new) r17 = or(r21, r31) }
95# CHECK: 71 df 75 f9
96if (p3) r17 = xor(r21, r31)
97# CHECK: f1 df 75 f9
98if (!p3) r17 = xor(r21, r31)
99# CHECK: 03 40 45 85
100# CHECK-NEXT: 71 ff 75 f9
101{ p3 = r5
102  if (p3.new) r17 = xor(r21, r31) }
103# CHECK: 03 40 45 85
104# CHECK-NEXT: f1 ff 75 f9
105{ p3 = r5
106  if (!p3.new) r17 = xor(r21, r31) }
107
108# Conditional subtract
109# CHECK: 71 df 35 fb
110if (p3) r17 = sub(r31, r21)
111# CHECK: f1 df 35 fb
112if (!p3) r17 = sub(r31, r21)
113# CHECK: 03 40 45 85
114# CHECK-NEXT: 71 ff 35 fb
115{ p3 = r5
116  if (p3.new) r17 = sub(r31, r21) }
117# CHECK: 03 40 45 85
118# CHECK-NEXT: f1 ff 35 fb
119{ p3 = r5
120  if (!p3.new) r17 = sub(r31, r21) }
121
122# Conditional sign extend
123# CHECK: 11 e3 b5 70
124if (p3) r17 = sxtb(r21)
125# CHECK: 11 eb b5 70
126if (!p3) r17 = sxtb(r21)
127# CHECK: 03 40 45 85
128# CHECK-NEXT: 11 e7 b5 70
129{ p3 = r5
130  if (p3.new) r17 = sxtb(r21) }
131# CHECK: 03 40 45 85
132# CHECK-NEXT: 11 ef b5 70
133{ p3 = r5
134  if (!p3.new) r17 = sxtb(r21) }
135# CHECK: 11 e3 f5 70
136if (p3) r17 = sxth(r21)
137# CHECK: 11 eb f5 70
138if (!p3) r17 = sxth(r21)
139# CHECK: 03 40 45 85
140# CHECK-NEXT: 11 e7 f5 70
141{ p3 = r5
142  if (p3.new) r17 = sxth(r21) }
143# CHECK: 03 40 45 85
144# CHECK-NEXT: 11 ef f5 70
145{ p3 = r5
146  if (!p3.new) r17 = sxth(r21) }
147
148# Conditional transfer
149# CHECK: b1 c2 60 7e
150if (p3) r17 = #21
151# CHECK: b1 c2 e0 7e
152if (!p3) r17 = #21
153# CHECK: 03 40 45 85
154# CHECK-NEXT: b1 e2 60 7e
155{ p3 = r5
156  if (p3.new) r17 = #21 }
157# CHECK: 03 40 45 85
158# CHECK-NEXT: b1 e2 e0 7e
159{ p3 = r5
160  if (!p3.new) r17 = #21 }
161
162# Conditional zero extend
163# CHECK: 11 e3 95 70
164if (p3) r17 = zxtb(r21)
165# CHECK: 11 eb 95 70
166if (!p3) r17 = zxtb(r21)
167# CHECK: 03 40 45 85
168# CHECK-NEXT: 11 e7 95 70
169{ p3 = r5
170  if (p3.new) r17 = zxtb(r21) }
171# CHECK: 03 40 45 85
172# CHECK-NEXT: 11 ef 95 70
173{ p3 = r5
174  if (!p3.new) r17 = zxtb(r21) }
175# CHECK: 11 e3 d5 70
176if (p3) r17 = zxth(r21)
177# CHECK: 11 eb d5 70
178if (!p3) r17 = zxth(r21)
179# CHECK: 03 40 45 85
180# CHECK-NEXT: 11 e7 d5 70
181{ p3 = r5
182  if (p3.new) r17 = zxth(r21) }
183# CHECK: 03 40 45 85
184# CHECK-NEXT: 11 ef d5 70
185{ p3 = r5
186  if (!p3.new) r17 = zxth(r21) }
187
188# Compare
189# CHECK: e3 c3 15 75
190p3 = cmp.eq(r21, #31)
191# CHECK: f3 c3 15 75
192p3 = !cmp.eq(r21, #31)
193# CHECK: e3 c3 55 75
194p3 = cmp.gt(r21, #31)
195# CHECK: f3 c3 55 75
196p3 = !cmp.gt(r21, #31)
197# CHECK: e3 c3 95 75
198p3 = cmp.gtu(r21, #31)
199# CHECK: f3 c3 95 75
200p3 = !cmp.gtu(r21, #31)
201# CHECK: 03 df 15 f2
202p3 = cmp.eq(r21, r31)
203# CHECK: 13 df 15 f2
204p3 = !cmp.eq(r21, r31)
205# CHECK: 03 df 55 f2
206p3 = cmp.gt(r21, r31)
207# CHECK: 13 df 55 f2
208p3 = !cmp.gt(r21, r31)
209# CHECK: 03 df 75 f2
210p3 = cmp.gtu(r21, r31)
211# CHECK: 13 df 75 f2
212p3 = !cmp.gtu(r21, r31)
213
214# Compare to general register
215# CHECK: f1 e3 55 73
216r17 = cmp.eq(r21, #31)
217# CHECK: f1 e3 75 73
218r17 = !cmp.eq(r21, #31)
219# CHECK: 11 df 55 f3
220r17 = cmp.eq(r21, r31)
221# CHECK: 11 df 75 f3
222r17 = !cmp.eq(r21, r31)
223