xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/arm64_vecCmpBr.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -O3 -triple arm64-apple-ios7 -target-feature +neon -S -ffreestanding %s -o - -target-cpu cyclone | FileCheck %s
2*0a6a1f1dSLionel Sambuc // REQUIRES: aarch64-registered-target
3*0a6a1f1dSLionel Sambuc // test code generation for <rdar://problem/11487757>
4*0a6a1f1dSLionel Sambuc #include <arm_neon.h>
5*0a6a1f1dSLionel Sambuc 
6*0a6a1f1dSLionel Sambuc unsigned bar();
7*0a6a1f1dSLionel Sambuc 
8*0a6a1f1dSLionel Sambuc // Branch if any lane of V0 is zero; 64 bit => !min
anyZero64(uint16x4_t a)9*0a6a1f1dSLionel Sambuc unsigned anyZero64(uint16x4_t a) {
10*0a6a1f1dSLionel Sambuc // CHECK: anyZero64:
11*0a6a1f1dSLionel Sambuc // CHECK: uminv.8b b[[REGNO1:[0-9]+]], v0
12*0a6a1f1dSLionel Sambuc // CHECK-NEXT: fmov w[[REGNO2:[0-9]+]], s[[REGNO1]]
13*0a6a1f1dSLionel Sambuc // CHECK-NEXT: cbz w[[REGNO2]], [[LABEL:[.A-Z_0-9]+]]
14*0a6a1f1dSLionel Sambuc // CHECK: [[LABEL]]:
15*0a6a1f1dSLionel Sambuc // CHECK-NEXT: b {{_bar|bar}}
16*0a6a1f1dSLionel Sambuc   if (!vminv_u8(a))
17*0a6a1f1dSLionel Sambuc     return bar();
18*0a6a1f1dSLionel Sambuc   return 0;
19*0a6a1f1dSLionel Sambuc }
20*0a6a1f1dSLionel Sambuc 
21*0a6a1f1dSLionel Sambuc // Branch if any lane of V0 is zero; 128 bit => !min
anyZero128(uint16x8_t a)22*0a6a1f1dSLionel Sambuc unsigned anyZero128(uint16x8_t a) {
23*0a6a1f1dSLionel Sambuc // CHECK: anyZero128:
24*0a6a1f1dSLionel Sambuc // CHECK: uminv.16b b[[REGNO1:[0-9]+]], v0
25*0a6a1f1dSLionel Sambuc // CHECK-NEXT: fmov w[[REGNO2:[0-9]+]], s[[REGNO1]]
26*0a6a1f1dSLionel Sambuc // CHECK-NEXT: cbz w[[REGNO2]], [[LABEL:[.A-Z_0-9]+]]
27*0a6a1f1dSLionel Sambuc // CHECK: [[LABEL]]:
28*0a6a1f1dSLionel Sambuc // CHECK-NEXT: b {{_bar|bar}}
29*0a6a1f1dSLionel Sambuc   if (!vminvq_u8(a))
30*0a6a1f1dSLionel Sambuc     return bar();
31*0a6a1f1dSLionel Sambuc   return 0;
32*0a6a1f1dSLionel Sambuc }
33*0a6a1f1dSLionel Sambuc 
34*0a6a1f1dSLionel Sambuc // Branch if any lane of V0 is non-zero; 64 bit => max
anyNonZero64(uint16x4_t a)35*0a6a1f1dSLionel Sambuc unsigned anyNonZero64(uint16x4_t a) {
36*0a6a1f1dSLionel Sambuc // CHECK: anyNonZero64:
37*0a6a1f1dSLionel Sambuc // CHECK: umaxv.8b b[[REGNO1:[0-9]+]], v0
38*0a6a1f1dSLionel Sambuc // CHECK-NEXT: fmov w[[REGNO2:[0-9]+]], s[[REGNO1]]
39*0a6a1f1dSLionel Sambuc // CHECK-NEXT: cbz w[[REGNO2]], [[LABEL:[.A-Z_0-9]+]]
40*0a6a1f1dSLionel Sambuc // CHECK: [[LABEL]]:
41*0a6a1f1dSLionel Sambuc // CHECK-NEXT: movz w0, #0
42*0a6a1f1dSLionel Sambuc   if (vmaxv_u8(a))
43*0a6a1f1dSLionel Sambuc     return bar();
44*0a6a1f1dSLionel Sambuc   return 0;
45*0a6a1f1dSLionel Sambuc }
46*0a6a1f1dSLionel Sambuc 
47*0a6a1f1dSLionel Sambuc // Branch if any lane of V0 is non-zero; 128 bit => max
anyNonZero128(uint16x8_t a)48*0a6a1f1dSLionel Sambuc unsigned anyNonZero128(uint16x8_t a) {
49*0a6a1f1dSLionel Sambuc // CHECK: anyNonZero128:
50*0a6a1f1dSLionel Sambuc // CHECK: umaxv.16b b[[REGNO1:[0-9]+]], v0
51*0a6a1f1dSLionel Sambuc // CHECK-NEXT: fmov w[[REGNO2:[0-9]+]], s[[REGNO1]]
52*0a6a1f1dSLionel Sambuc // CHECK-NEXT: cbz w[[REGNO2]], [[LABEL:[.A-Z_0-9]+]]
53*0a6a1f1dSLionel Sambuc // CHECK: [[LABEL]]:
54*0a6a1f1dSLionel Sambuc // CHECK-NEXT: movz w0, #0
55*0a6a1f1dSLionel Sambuc   if (vmaxvq_u8(a))
56*0a6a1f1dSLionel Sambuc     return bar();
57*0a6a1f1dSLionel Sambuc   return 0;
58*0a6a1f1dSLionel Sambuc }
59*0a6a1f1dSLionel Sambuc 
60*0a6a1f1dSLionel Sambuc // Branch if all lanes of V0 are zero; 64 bit => !max
allZero64(uint16x4_t a)61*0a6a1f1dSLionel Sambuc unsigned allZero64(uint16x4_t a) {
62*0a6a1f1dSLionel Sambuc // CHECK: allZero64:
63*0a6a1f1dSLionel Sambuc // CHECK: umaxv.8b b[[REGNO1:[0-9]+]], v0
64*0a6a1f1dSLionel Sambuc // CHECK-NEXT: fmov w[[REGNO2:[0-9]+]], s[[REGNO1]]
65*0a6a1f1dSLionel Sambuc // CHECK-NEXT: cbz w[[REGNO2]], [[LABEL:[.A-Z_0-9]+]]
66*0a6a1f1dSLionel Sambuc // CHECK: [[LABEL]]:
67*0a6a1f1dSLionel Sambuc // CHECK-NEXT: b {{_bar|bar}}
68*0a6a1f1dSLionel Sambuc   if (!vmaxv_u8(a))
69*0a6a1f1dSLionel Sambuc     return bar();
70*0a6a1f1dSLionel Sambuc   return 0;
71*0a6a1f1dSLionel Sambuc }
72*0a6a1f1dSLionel Sambuc 
73*0a6a1f1dSLionel Sambuc // Branch if all lanes of V0 are zero; 128 bit => !max
allZero128(uint16x8_t a)74*0a6a1f1dSLionel Sambuc unsigned allZero128(uint16x8_t a) {
75*0a6a1f1dSLionel Sambuc // CHECK: allZero128:
76*0a6a1f1dSLionel Sambuc // CHECK: umaxv.16b b[[REGNO1:[0-9]+]], v0
77*0a6a1f1dSLionel Sambuc // CHECK-NEXT: fmov w[[REGNO2:[0-9]+]], s[[REGNO1]]
78*0a6a1f1dSLionel Sambuc // CHECK-NEXT: cbz w[[REGNO2]], [[LABEL:[.A-Z_0-9]+]]
79*0a6a1f1dSLionel Sambuc // CHECK: [[LABEL]]:
80*0a6a1f1dSLionel Sambuc // CHECK-NEXT: b {{_bar|bar}}
81*0a6a1f1dSLionel Sambuc   if (!vmaxvq_u8(a))
82*0a6a1f1dSLionel Sambuc     return bar();
83*0a6a1f1dSLionel Sambuc   return 0;
84*0a6a1f1dSLionel Sambuc }
85*0a6a1f1dSLionel Sambuc 
86*0a6a1f1dSLionel Sambuc // Branch if all lanes of V0 are non-zero; 64 bit => min
allNonZero64(uint16x4_t a)87*0a6a1f1dSLionel Sambuc unsigned allNonZero64(uint16x4_t a) {
88*0a6a1f1dSLionel Sambuc // CHECK: allNonZero64:
89*0a6a1f1dSLionel Sambuc // CHECK: uminv.8b b[[REGNO1:[0-9]+]], v0
90*0a6a1f1dSLionel Sambuc // CHECK-NEXT: fmov w[[REGNO2:[0-9]+]], s[[REGNO1]]
91*0a6a1f1dSLionel Sambuc // CHECK-NEXT: cbz w[[REGNO2]], [[LABEL:[.A-Z_0-9]+]]
92*0a6a1f1dSLionel Sambuc // CHECK: [[LABEL]]:
93*0a6a1f1dSLionel Sambuc // CHECK-NEXT: movz w0, #0
94*0a6a1f1dSLionel Sambuc   if (vminv_u8(a))
95*0a6a1f1dSLionel Sambuc     return bar();
96*0a6a1f1dSLionel Sambuc   return 0;
97*0a6a1f1dSLionel Sambuc }
98*0a6a1f1dSLionel Sambuc 
99*0a6a1f1dSLionel Sambuc // Branch if all lanes of V0 are non-zero; 128 bit => min
allNonZero128(uint16x8_t a)100*0a6a1f1dSLionel Sambuc unsigned allNonZero128(uint16x8_t a) {
101*0a6a1f1dSLionel Sambuc // CHECK: allNonZero128:
102*0a6a1f1dSLionel Sambuc // CHECK: uminv.16b b[[REGNO1:[0-9]+]], v0
103*0a6a1f1dSLionel Sambuc // CHECK-NEXT: fmov w[[REGNO2:[0-9]+]], s[[REGNO1]]
104*0a6a1f1dSLionel Sambuc // CHECK-NEXT: cbz w[[REGNO2]], [[LABEL:[.A-Z_0-9]+]]
105*0a6a1f1dSLionel Sambuc // CHECK: [[LABEL]]:
106*0a6a1f1dSLionel Sambuc // CHECK-NEXT: movz w0, #0
107*0a6a1f1dSLionel Sambuc   if (vminvq_u8(a))
108*0a6a1f1dSLionel Sambuc     return bar();
109*0a6a1f1dSLionel Sambuc   return 0;
110*0a6a1f1dSLionel Sambuc }
111*0a6a1f1dSLionel Sambuc 
112