|
1 | 1 | ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
|
2 |
| -; Test file to verify the emission of Vector selection instructions when ternary operators are used. |
| 2 | +; Test file to verify the emission of Vector Selection instructions when ternary operators are used. |
3 | 3 |
|
4 | 4 | ; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64le-unknown-unknown \
|
5 | 5 | ; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s
|
@@ -47,6 +47,42 @@ entry:
|
47 | 47 | ret <2 x i64> %res
|
48 | 48 | }
|
49 | 49 |
|
| 50 | +; Function to test ternary(A, xor(B, C), and(B, C)) for <16 x i8> |
| 51 | +define <16 x i8> @ternary_A_xor_BC_and_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { |
| 52 | +; CHECK-LABEL: ternary_A_xor_BC_and_BC_16x8: |
| 53 | +; CHECK: # %bb.0: # %entry |
| 54 | +; CHECK-NEXT: xxspltib v5, 7 |
| 55 | +; CHECK-NEXT: xxlxor vs0, v3, v4 |
| 56 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 57 | +; CHECK-NEXT: vslb v2, v2, v5 |
| 58 | +; CHECK-NEXT: vsrab v2, v2, v5 |
| 59 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 60 | +; CHECK-NEXT: blr |
| 61 | +entry: |
| 62 | + %xor = xor <16 x i8> %B, %C |
| 63 | + %and = and <16 x i8> %B, %C |
| 64 | + %res = select <16 x i1> %A, <16 x i8> %xor, <16 x i8> %and |
| 65 | + ret <16 x i8> %res |
| 66 | +} |
| 67 | + |
| 68 | +; Function to test ternary(A, xor(B, C), and(B, C)) for <8 x i16> |
| 69 | +define <8 x i16> @ternary_A_xor_BC_and_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { |
| 70 | +; CHECK-LABEL: ternary_A_xor_BC_and_BC_8x16: |
| 71 | +; CHECK: # %bb.0: # %entry |
| 72 | +; CHECK-NEXT: xxspltiw v5, 983055 |
| 73 | +; CHECK-NEXT: xxlxor vs0, v3, v4 |
| 74 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 75 | +; CHECK-NEXT: vslh v2, v2, v5 |
| 76 | +; CHECK-NEXT: vsrah v2, v2, v5 |
| 77 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 78 | +; CHECK-NEXT: blr |
| 79 | +entry: |
| 80 | + %xor = xor <8 x i16> %B, %C |
| 81 | + %and = and <8 x i16> %B, %C |
| 82 | + %res = select <8 x i1> %A, <8 x i16> %xor, <8 x i16> %and |
| 83 | + ret <8 x i16> %res |
| 84 | +} |
| 85 | + |
50 | 86 | ; Function to test ternary(A, nor(B, C), and(B, C)) for <4 x i32>
|
51 | 87 | define <4 x i32> @ternary_A_nor_BC_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
|
52 | 88 | ; CHECK-LABEL: ternary_A_nor_BC_and_BC_4x32:
|
@@ -86,6 +122,44 @@ entry:
|
86 | 122 | ret <2 x i64> %res
|
87 | 123 | }
|
88 | 124 |
|
| 125 | +; Function to test ternary(A, nor(B, C), and(B, C)) for <16 x i8> |
| 126 | +define <16 x i8> @ternary_A_nor_BC_and_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { |
| 127 | +; CHECK-LABEL: ternary_A_nor_BC_and_BC_16x8: |
| 128 | +; CHECK: # %bb.0: # %entry |
| 129 | +; CHECK-NEXT: xxspltib v5, 7 |
| 130 | +; CHECK-NEXT: xxlnor vs0, v3, v4 |
| 131 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 132 | +; CHECK-NEXT: vslb v2, v2, v5 |
| 133 | +; CHECK-NEXT: vsrab v2, v2, v5 |
| 134 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 135 | +; CHECK-NEXT: blr |
| 136 | +entry: |
| 137 | + %or = or <16 x i8> %B, %C |
| 138 | + %nor = xor <16 x i8> %or, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1> ; Vector NOR operation |
| 139 | + %and = and <16 x i8> %B, %C |
| 140 | + %res = select <16 x i1> %A, <16 x i8> %nor, <16 x i8> %and |
| 141 | + ret <16 x i8> %res |
| 142 | +} |
| 143 | + |
| 144 | +; Function to test ternary(A, nor(B, C), and(B, C)) for <8 x i16> |
| 145 | +define <8 x i16> @ternary_A_nor_BC_and_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { |
| 146 | +; CHECK-LABEL: ternary_A_nor_BC_and_BC_8x16: |
| 147 | +; CHECK: # %bb.0: # %entry |
| 148 | +; CHECK-NEXT: xxspltiw v5, 983055 |
| 149 | +; CHECK-NEXT: xxlnor vs0, v3, v4 |
| 150 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 151 | +; CHECK-NEXT: vslh v2, v2, v5 |
| 152 | +; CHECK-NEXT: vsrah v2, v2, v5 |
| 153 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 154 | +; CHECK-NEXT: blr |
| 155 | +entry: |
| 156 | + %or = or <8 x i16> %B, %C |
| 157 | + %nor = xor <8 x i16> %or, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector NOR operation |
| 158 | + %and = and <8 x i16> %B, %C |
| 159 | + %res = select <8 x i1> %A, <8 x i16> %nor, <8 x i16> %and |
| 160 | + ret <8 x i16> %res |
| 161 | +} |
| 162 | + |
89 | 163 | ; Function to test ternary(A, eqv(B, C), and(B, C)) for <4 x i32>
|
90 | 164 | define <4 x i32> @ternary_A_eqv_BC_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
|
91 | 165 | ; CHECK-LABEL: ternary_A_eqv_BC_and_BC_4x32:
|
@@ -125,6 +199,44 @@ entry:
|
125 | 199 | ret <2 x i64> %res
|
126 | 200 | }
|
127 | 201 |
|
| 202 | +; Function to test ternary(A, eqv(B, C), and(B, C)) for <16 x i8> |
| 203 | +define <16 x i8> @ternary_A_eqv_BC_and_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { |
| 204 | +; CHECK-LABEL: ternary_A_eqv_BC_and_BC_16x8: |
| 205 | +; CHECK: # %bb.0: # %entry |
| 206 | +; CHECK-NEXT: xxspltib v5, 7 |
| 207 | +; CHECK-NEXT: xxleqv vs0, v3, v4 |
| 208 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 209 | +; CHECK-NEXT: vslb v2, v2, v5 |
| 210 | +; CHECK-NEXT: vsrab v2, v2, v5 |
| 211 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 212 | +; CHECK-NEXT: blr |
| 213 | +entry: |
| 214 | + %xor = xor <16 x i8> %B, %C |
| 215 | + %eqv = xor <16 x i8> %xor, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1> ; Vector eqv operation |
| 216 | + %and = and <16 x i8> %B, %C |
| 217 | + %res = select <16 x i1> %A, <16 x i8> %eqv, <16 x i8> %and |
| 218 | + ret <16 x i8> %res |
| 219 | +} |
| 220 | + |
| 221 | +; Function to test ternary(A, eqv(B, C), and(B, C)) for <8 x i16> |
| 222 | +define <8 x i16> @ternary_A_eqv_BC_and_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { |
| 223 | +; CHECK-LABEL: ternary_A_eqv_BC_and_BC_8x16: |
| 224 | +; CHECK: # %bb.0: # %entry |
| 225 | +; CHECK-NEXT: xxspltiw v5, 983055 |
| 226 | +; CHECK-NEXT: xxleqv vs0, v3, v4 |
| 227 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 228 | +; CHECK-NEXT: vslh v2, v2, v5 |
| 229 | +; CHECK-NEXT: vsrah v2, v2, v5 |
| 230 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 231 | +; CHECK-NEXT: blr |
| 232 | +entry: |
| 233 | + %xor = xor <8 x i16> %B, %C |
| 234 | + %eqv = xor <8 x i16> %xor, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector eqv operation |
| 235 | + %and = and <8 x i16> %B, %C |
| 236 | + %res = select <8 x i1> %A, <8 x i16> %eqv, <8 x i16> %and |
| 237 | + ret <8 x i16> %res |
| 238 | +} |
| 239 | + |
128 | 240 | ; Function to test ternary(A, not(C), and(B, C)) for <4 x i32>
|
129 | 241 | define <4 x i32> @ternary_A_not_C_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
|
130 | 242 | ; CHECK-LABEL: ternary_A_not_C_and_BC_4x32:
|
@@ -162,6 +274,42 @@ entry:
|
162 | 274 | ret <2 x i64> %res
|
163 | 275 | }
|
164 | 276 |
|
| 277 | +; Function to test ternary(A, not(C), and(B, C)) for <16 x i8> |
| 278 | +define <16 x i8> @ternary_A_not_C_and_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { |
| 279 | +; CHECK-LABEL: ternary_A_not_C_and_BC_16x8: |
| 280 | +; CHECK: # %bb.0: # %entry |
| 281 | +; CHECK-NEXT: xxspltib v5, 7 |
| 282 | +; CHECK-NEXT: xxlnor vs0, v4, v4 |
| 283 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 284 | +; CHECK-NEXT: vslb v2, v2, v5 |
| 285 | +; CHECK-NEXT: vsrab v2, v2, v5 |
| 286 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 287 | +; CHECK-NEXT: blr |
| 288 | +entry: |
| 289 | + %not = xor <16 x i8> %C, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1> ; Vector not operation |
| 290 | + %and = and <16 x i8> %B, %C |
| 291 | + %res = select <16 x i1> %A, <16 x i8> %not, <16 x i8> %and |
| 292 | + ret <16 x i8> %res |
| 293 | +} |
| 294 | + |
| 295 | +; Function to test ternary(A, not(C), and(B, C)) for <8 x i16> |
| 296 | +define <8 x i16> @ternary_A_not_C_and_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { |
| 297 | +; CHECK-LABEL: ternary_A_not_C_and_BC_8x16: |
| 298 | +; CHECK: # %bb.0: # %entry |
| 299 | +; CHECK-NEXT: xxspltiw v5, 983055 |
| 300 | +; CHECK-NEXT: xxlnor vs0, v4, v4 |
| 301 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 302 | +; CHECK-NEXT: vslh v2, v2, v5 |
| 303 | +; CHECK-NEXT: vsrah v2, v2, v5 |
| 304 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 305 | +; CHECK-NEXT: blr |
| 306 | +entry: |
| 307 | + %not = xor <8 x i16> %C, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector not operation |
| 308 | + %and = and <8 x i16> %B, %C |
| 309 | + %res = select <8 x i1> %A, <8 x i16> %not, <8 x i16> %and |
| 310 | + ret <8 x i16> %res |
| 311 | +} |
| 312 | + |
165 | 313 | ; Function to test ternary(A, not(B), and(B, C)) for <4 x i32>
|
166 | 314 | define <4 x i32> @ternary_A_not_B_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) {
|
167 | 315 | ; CHECK-LABEL: ternary_A_not_B_and_BC_4x32:
|
@@ -198,3 +346,39 @@ entry:
|
198 | 346 | %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %and
|
199 | 347 | ret <2 x i64> %res
|
200 | 348 | }
|
| 349 | + |
| 350 | +; Function to test ternary(A, not(B), and(B, C)) for <16 x i8> |
| 351 | +define <16 x i8> @ternary_A_not_B_and_BC_16x8(<16 x i1> %A, <16 x i8> %B, <16 x i8> %C) { |
| 352 | +; CHECK-LABEL: ternary_A_not_B_and_BC_16x8: |
| 353 | +; CHECK: # %bb.0: # %entry |
| 354 | +; CHECK-NEXT: xxspltib v5, 7 |
| 355 | +; CHECK-NEXT: xxlnor vs0, v3, v3 |
| 356 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 357 | +; CHECK-NEXT: vslb v2, v2, v5 |
| 358 | +; CHECK-NEXT: vsrab v2, v2, v5 |
| 359 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 360 | +; CHECK-NEXT: blr |
| 361 | +entry: |
| 362 | + %not = xor <16 x i8> %B, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1> ; Vector not operation |
| 363 | + %and = and <16 x i8> %B, %C |
| 364 | + %res = select <16 x i1> %A, <16 x i8> %not, <16 x i8> %and |
| 365 | + ret <16 x i8> %res |
| 366 | +} |
| 367 | + |
| 368 | +; Function to test ternary(A, not(B), and(B, C)) for <8 x i16> |
| 369 | +define <8 x i16> @ternary_A_not_B_and_BC_8x16(<8 x i1> %A, <8 x i16> %B, <8 x i16> %C) { |
| 370 | +; CHECK-LABEL: ternary_A_not_B_and_BC_8x16: |
| 371 | +; CHECK: # %bb.0: # %entry |
| 372 | +; CHECK-NEXT: xxspltiw v5, 983055 |
| 373 | +; CHECK-NEXT: xxlnor vs0, v3, v3 |
| 374 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 375 | +; CHECK-NEXT: vslh v2, v2, v5 |
| 376 | +; CHECK-NEXT: vsrah v2, v2, v5 |
| 377 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 378 | +; CHECK-NEXT: blr |
| 379 | +entry: |
| 380 | + %not = xor <8 x i16> %B, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1> ; Vector not operation |
| 381 | + %and = and <8 x i16> %B, %C |
| 382 | + %res = select <8 x i1> %A, <8 x i16> %not, <8 x i16> %and |
| 383 | + ret <8 x i16> %res |
| 384 | +} |
0 commit comments