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 3 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 7 8; CODE-LABEL: v8i8_select_eq 9; CODE: bb.0 10; CODE-NEXT: cmeq v{{.+}}.8b, v{{.+}}.8b, v{{.+}}.8b 11; CODE-NEXT: bif v{{.+}}.8b, v{{.+}}.8b, v{{.+}}.8b 12; CODE-NEXT: ret 13 14define <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 17 ret <8 x i8> %s.1 18} 19 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 23 24; CODE-LABEL: v16i8_select_sgt 25; CODE: bb.0 26; CODE-NEXT: cmgt v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b 27; CODE-NEXT: bif v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b 28; CODE-NEXT: ret 29 30define <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 33 ret <16 x i8> %s.1 34} 35 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 39 40; CODE-LABEL: v4i16_select_ne 41; CODE: bb.0 42; CODE-NEXT: cmeq v{{.+}}.4h, v{{.+}}.4h, v{{.+}}.4h 43; CODE-NEXT: bit v{{.+}}.8b, v{{.+}}.8b, v{{.+}}.8b 44; CODE-NEXT: ret 45 46define <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 49 ret <4 x i16> %s.1 50} 51 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 55 56; CODE-LABEL: v8i16_select_ugt 57; CODE: bb.0 58; CODE-NEXT: cmhi v{{.+}}.8h, v{{.+}}.8h, v{{.+}}.8h 59; CODE-NEXT: bif v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b 60; CODE-NEXT: ret 61 62define <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 65 ret <8 x i16> %s.1 66} 67 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 71 72; CODE-LABEL: v2i32_select_ule 73; CODE: bb.0 74; CODE-NEXT: cmhs v{{.+}}.2s, v{{.+}}.2s, v{{.+}}.2s 75; CODE-NEXT: bif v{{.+}}.8b, v{{.+}}.8b, v{{.+}}.8b 76; CODE-NEXT: ret 77 78define <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 81 ret <2 x i32> %s.1 82} 83 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 87 88; CODE-LABEL: v4i32_select_ult 89; CODE: bb.0 90; CODE-NEXT: cmhi v{{.+}}.4s, v{{.+}}.4s, v{{.+}}.4s 91; CODE-NEXT: bif v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b 92; CODE-NEXT: ret 93 94define <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 97 ret <4 x i32> %s.1 98} 99 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 103 104; CODE-LABEL: v2i64_select_sle 105; CODE: bb.0 106; CODE-NEXT: cmge v{{.+}}.2d, v{{.+}}.2d, v{{.+}}.2d 107; CODE-NEXT: bif v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b 108; CODE-NEXT: ret 109 110define <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 113 ret <2 x i64> %s.1 114} 115 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 119 120; CODE-LABEL: v3i64_select_sle 121; CODE: bb.0 122; CODE: ldr 123; CODE: mov 124; CODE: mov 125; CODE: mov 126; CODE: cmge 127; CODE: cmge 128; CODE: bif 129; CODE: ext 130; CODE: bif 131; CODE: ret 132 133define <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 136 ret <3 x i64> %s.1 137} 138 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 141 142; CODE-LABEL: v2i64_select_no_cmp 143; CODE: bb.0 144; CODE-NEXT: ushll v{{.+}}.2d, v{{.+}}.2s, #0 145; CODE-NEXT: shl v{{.+}}.2d, v{{.+}}.2d, #63 146; CODE-NEXT: sshr v{{.+}}.2d, v{{.+}}.2d, #63 147; CODE-NEXT: bif v{{.+}}.16b, v{{.+}}.16b, v{{.+}}.16b 148; CODE-NEXT: ret 149 150define <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 152 ret <2 x i64> %s.1 153} 154