1 ; RUN: opt < %s -mtriple=aarch64--linux-gnu -cost-model -analyze | FileCheck %s --check-prefix=COST
2 ; RUN: llc < %s -mtriple=aarch64--linux-gnu | FileCheck %s --check-prefix=CODE
4 ; COST-LABEL: v8i8_select_eq
5 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp.1 = icmp eq <8 x i8> %a, %b
6 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s.1 = select <8 x i1> %cmp.1, <8 x i8> %a, <8 x i8> %c
8 ; CODE-LABEL: v8i8_select_eq
10 ; CODE-NEXT: cmeq v{{.+}}.8b, v{{.+}}.8b, v{{.+}}.8b
11 ; CODE-NEXT: bif v{{.+}}.8b, v{{.+}}.8b, v{{.+}}.8b
14 define <8 x i8> @v8i8_select_eq(<8 x i8> %a, <8 x i8> %b, <8 x i8> %c) {
15 %cmp.1 = icmp eq <8 x i8> %a, %b
16 %s.1 = select <8 x i1> %cmp.1, <8 x i8> %a, <8 x i8> %c
20 ; COST-LABEL: v16i8_select_sgt
21 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp.1 = icmp sgt <16 x i8> %a, %b
22 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s.1 = select <16 x i1> %cmp.1, <16 x i8> %a, <16 x i8> %c
24 ; CODE-LABEL: v16i8_select_sgt
26 ; CODE-NEXT: cmgt v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b
27 ; CODE-NEXT: bif v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b
30 define <16 x i8> @v16i8_select_sgt(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c) {
31 %cmp.1 = icmp sgt <16 x i8> %a, %b
32 %s.1 = select <16 x i1> %cmp.1, <16 x i8> %a, <16 x i8> %c
36 ; COST-LABEL: v4i16_select_ne
37 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp.1 = icmp ne <4 x i16> %a, %b
38 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s.1 = select <4 x i1> %cmp.1, <4 x i16> %a, <4 x i16> %c
40 ; CODE-LABEL: v4i16_select_ne
42 ; CODE-NEXT: cmeq v{{.+}}.4h, v{{.+}}.4h, v{{.+}}.4h
43 ; CODE-NEXT: bit v{{.+}}.8b, v{{.+}}.8b, v{{.+}}.8b
46 define <4 x i16> @v4i16_select_ne(<4 x i16> %a, <4 x i16> %b, <4 x i16> %c) {
47 %cmp.1 = icmp ne <4 x i16> %a, %b
48 %s.1 = select <4 x i1> %cmp.1, <4 x i16> %a, <4 x i16> %c
52 ; COST-LABEL: v8i16_select_ugt
53 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp.1 = icmp ugt <8 x i16> %a, %b
54 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s.1 = select <8 x i1> %cmp.1, <8 x i16> %a, <8 x i16> %c
56 ; CODE-LABEL: v8i16_select_ugt
58 ; CODE-NEXT: cmhi v{{.+}}.8h, v{{.+}}.8h, v{{.+}}.8h
59 ; CODE-NEXT: bif v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b
62 define <8 x i16> @v8i16_select_ugt(<8 x i16> %a, <8 x i16> %b, <8 x i16> %c) {
63 %cmp.1 = icmp ugt <8 x i16> %a, %b
64 %s.1 = select <8 x i1> %cmp.1, <8 x i16> %a, <8 x i16> %c
68 ; COST-LABEL: v2i32_select_ule
69 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp.1 = icmp ule <2 x i32> %a, %b
70 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s.1 = select <2 x i1> %cmp.1, <2 x i32> %a, <2 x i32> %c
72 ; CODE-LABEL: v2i32_select_ule
74 ; CODE-NEXT: cmhs v{{.+}}.2s, v{{.+}}.2s, v{{.+}}.2s
75 ; CODE-NEXT: bif v{{.+}}.8b, v{{.+}}.8b, v{{.+}}.8b
78 define <2 x i32> @v2i32_select_ule(<2 x i32> %a, <2 x i32> %b, <2 x i32> %c) {
79 %cmp.1 = icmp ule <2 x i32> %a, %b
80 %s.1 = select <2 x i1> %cmp.1, <2 x i32> %a, <2 x i32> %c
84 ; COST-LABEL: v4i32_select_ult
85 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp.1 = icmp ult <4 x i32> %a, %b
86 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s.1 = select <4 x i1> %cmp.1, <4 x i32> %a, <4 x i32> %c
88 ; CODE-LABEL: v4i32_select_ult
90 ; CODE-NEXT: cmhi v{{.+}}.4s, v{{.+}}.4s, v{{.+}}.4s
91 ; CODE-NEXT: bif v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b
94 define <4 x i32> @v4i32_select_ult(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
95 %cmp.1 = icmp ult <4 x i32> %a, %b
96 %s.1 = select <4 x i1> %cmp.1, <4 x i32> %a, <4 x i32> %c
100 ; COST-LABEL: v2i64_select_sle
101 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %cmp.1 = icmp sle <2 x i64> %a, %b
102 ; COST-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %s.1 = select <2 x i1> %cmp.1, <2 x i64> %a, <2 x i64> %c
104 ; CODE-LABEL: v2i64_select_sle
106 ; CODE-NEXT: cmge v{{.+}}.2d, v{{.+}}.2d, v{{.+}}.2d
107 ; CODE-NEXT: bif v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b
110 define <2 x i64> @v2i64_select_sle(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c) {
111 %cmp.1 = icmp sle <2 x i64> %a, %b
112 %s.1 = select <2 x i1> %cmp.1, <2 x i64> %a, <2 x i64> %c
116 ; COST-LABEL: v3i64_select_sle
117 ; COST-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %cmp.1 = icmp sle <3 x i64> %a, %b
118 ; COST-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %s.1 = select <3 x i1> %cmp.1, <3 x i64> %a, <3 x i64> %c
120 ; CODE-LABEL: v3i64_select_sle
133 define <3 x i64> @v3i64_select_sle(<3 x i64> %a, <3 x i64> %b, <3 x i64> %c) {
134 %cmp.1 = icmp sle <3 x i64> %a, %b
135 %s.1 = select <3 x i1> %cmp.1, <3 x i64> %a, <3 x i64> %c
139 ; COST-LABEL: v2i64_select_no_cmp
140 ; COST-NEXT: Cost Model: Found an estimated cost of 5 for instruction: %s.1 = select <2 x i1> %cond, <2 x i64> %a, <2 x i64> %b
142 ; CODE-LABEL: v2i64_select_no_cmp
144 ; CODE-NEXT: ushll v{{.+}}.2d, v{{.+}}.2s, #0
145 ; CODE-NEXT: shl v{{.+}}.2d, v{{.+}}.2d, #63
146 ; CODE-NEXT: cmlt v{{.+}}.2d, v{{.+}}.2d, #0
147 ; CODE-NEXT: bif v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b
150 define <2 x i64> @v2i64_select_no_cmp(<2 x i64> %a, <2 x i64> %b, <2 x i1> %cond) {
151 %s.1 = select <2 x i1> %cond, <2 x i64> %a, <2 x i64> %b