1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -march=hexagon < %s | FileCheck %s
4 ; Check that selection (based on i1) between vector predicates works.
5 define <128 x i8> @f0(<128 x i8> %a0, <128 x i8> %a1, <128 x i8> %a2, <128 x i8> %a3, i32 %a4) #0 {
9 ; CHECK-NEXT: q0 = vcmp.gt(v0.b,v1.b)
12 ; CHECK-NEXT: q1 = vcmp.gt(v1.b,v2.b)
15 ; CHECK-NEXT: r2 = #-1
18 ; CHECK-NEXT: p0 = cmp.gt(r0,#0)
21 ; CHECK-NEXT: v0 = vand(q1,r2)
24 ; CHECK-NEXT: v2 = vand(q0,r2)
27 ; CHECK-NEXT: if (p0) v0 = v2
30 ; CHECK-NEXT: q3 = vand(v0,r2)
33 ; CHECK-NEXT: v0 = vmux(q3,v1,v3)
36 ; CHECK-NEXT: jumpr r31
38 %v0 = icmp sgt <128 x i8> %a0, %a1
39 %v1 = icmp sgt <128 x i8> %a1, %a2
40 %v2 = icmp sgt i32 %a4, 0
41 %v3 = select i1 %v2, <128 x i1> %v0, <128 x i1> %v1
42 %v4 = select <128 x i1> %v3, <128 x i8> %a1, <128 x i8> %a3
46 define <64 x i16> @f1(<64 x i16> %a0, <64 x i16> %a1, <64 x i16> %a2, <64 x i16> %a3, i32 %a4) #0 {
50 ; CHECK-NEXT: q0 = vcmp.gt(v0.h,v1.h)
53 ; CHECK-NEXT: q1 = vcmp.gt(v1.h,v2.h)
56 ; CHECK-NEXT: r2 = #-1
59 ; CHECK-NEXT: p0 = cmp.gt(r0,#0)
62 ; CHECK-NEXT: v0 = vand(q1,r2)
65 ; CHECK-NEXT: v2 = vand(q0,r2)
68 ; CHECK-NEXT: if (p0) v0 = v2
71 ; CHECK-NEXT: q3 = vand(v0,r2)
74 ; CHECK-NEXT: v0 = vmux(q3,v1,v3)
77 ; CHECK-NEXT: jumpr r31
79 %v0 = icmp sgt <64 x i16> %a0, %a1
80 %v1 = icmp sgt <64 x i16> %a1, %a2
81 %v2 = icmp sgt i32 %a4, 0
82 %v3 = select i1 %v2, <64 x i1> %v0, <64 x i1> %v1
83 %v4 = select <64 x i1> %v3, <64 x i16> %a1, <64 x i16> %a3
87 define <32 x i32> @f2(<32 x i32> %a0, <32 x i32> %a1, <32 x i32> %a2, <32 x i32> %a3, i32 %a4) #0 {
91 ; CHECK-NEXT: q0 = vcmp.gt(v0.w,v1.w)
94 ; CHECK-NEXT: q1 = vcmp.gt(v1.w,v2.w)
97 ; CHECK-NEXT: r2 = #-1
100 ; CHECK-NEXT: p0 = cmp.gt(r0,#0)
103 ; CHECK-NEXT: v0 = vand(q1,r2)
106 ; CHECK-NEXT: v2 = vand(q0,r2)
109 ; CHECK-NEXT: if (p0) v0 = v2
112 ; CHECK-NEXT: q3 = vand(v0,r2)
115 ; CHECK-NEXT: v0 = vmux(q3,v1,v3)
118 ; CHECK-NEXT: jumpr r31
120 %v0 = icmp sgt <32 x i32> %a0, %a1
121 %v1 = icmp sgt <32 x i32> %a1, %a2
122 %v2 = icmp sgt i32 %a4, 0
123 %v3 = select i1 %v2, <32 x i1> %v0, <32 x i1> %v1
124 %v4 = select <32 x i1> %v3, <32 x i32> %a1, <32 x i32> %a3
128 ; Selection of vector predicates first converts them into regular vectors.
129 ; Check that all-true and all-false bool vectors are optimized into splat(-1)
131 define <128 x i8> @f3(<128 x i8> %a0, <128 x i8> %a1, i32 %a2) #0 {
135 ; CHECK-NEXT: r2 = #-1
138 ; CHECK-NEXT: p0 = cmp.gt(r0,#0)
141 ; CHECK-NEXT: v2 = vxor(v2,v2)
144 ; CHECK-NEXT: v3 = vsplat(r2)
147 ; CHECK-NEXT: if (p0) v2 = v3
150 ; CHECK-NEXT: q0 = vand(v2,r2)
153 ; CHECK-NEXT: v0 = vmux(q0,v0,v1)
156 ; CHECK-NEXT: jumpr r31
158 %v0 = insertelement <128 x i1> undef, i1 true, i32 0
159 %v1 = shufflevector <128 x i1> %v0, <128 x i1> undef, <128 x i32> zeroinitializer
160 %v2 = icmp sgt i32 %a2, 0
161 %v3 = select i1 %v2, <128 x i1> %v1, <128 x i1> zeroinitializer
162 %v4 = select <128 x i1> %v3, <128 x i8> %a0, <128 x i8> %a1
166 define <64 x i16> @f4(<64 x i16> %a0, <64 x i16> %a1, i32 %a2) #0 {
170 ; CHECK-NEXT: r2 = #-1
173 ; CHECK-NEXT: p0 = cmp.gt(r0,#0)
176 ; CHECK-NEXT: v2 = vxor(v2,v2)
179 ; CHECK-NEXT: v3 = vsplat(r2)
182 ; CHECK-NEXT: if (p0) v2 = v3
185 ; CHECK-NEXT: q0 = vand(v2,r2)
188 ; CHECK-NEXT: v0 = vmux(q0,v0,v1)
191 ; CHECK-NEXT: jumpr r31
193 %v0 = insertelement <64 x i1> undef, i1 true, i32 0
194 %v1 = shufflevector <64 x i1> %v0, <64 x i1> undef, <64 x i32> zeroinitializer
195 %v2 = icmp sgt i32 %a2, 0
196 %v3 = select i1 %v2, <64 x i1> %v1, <64 x i1> zeroinitializer
197 %v4 = select <64 x i1> %v3, <64 x i16> %a0, <64 x i16> %a1
201 define <32 x i32> @f5(<32 x i32> %a0, <32 x i32> %a1, i32 %a2) #0 {
205 ; CHECK-NEXT: r2 = #-1
208 ; CHECK-NEXT: p0 = cmp.gt(r0,#0)
211 ; CHECK-NEXT: v2 = vxor(v2,v2)
214 ; CHECK-NEXT: v3 = vsplat(r2)
217 ; CHECK-NEXT: if (p0) v2 = v3
220 ; CHECK-NEXT: q0 = vand(v2,r2)
223 ; CHECK-NEXT: v0 = vmux(q0,v0,v1)
226 ; CHECK-NEXT: jumpr r31
228 %v0 = insertelement <32 x i1> undef, i1 true, i32 0
229 %v1 = shufflevector <32 x i1> %v0, <32 x i1> undef, <32 x i32> zeroinitializer
230 %v2 = icmp sgt i32 %a2, 0
231 %v3 = select i1 %v2, <32 x i1> %v1, <32 x i1> zeroinitializer
232 %v4 = select <32 x i1> %v3, <32 x i32> %a0, <32 x i32> %a1
236 attributes #0 = { nounwind "target-cpu"="hexagonv66" "target-features"="+hvx,+hvx-length128b,-packets" }