|
| 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. |
| 3 | + |
| 4 | +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64le-unknown-unknown \ |
| 5 | +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s |
| 6 | + |
| 7 | +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc-ibm-aix-xcoff \ |
| 8 | +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s |
| 9 | + |
| 10 | +; RUN: llc -verify-machineinstrs -mcpu=pwr10 -mtriple=powerpc64-ibm-aix-xcoff \ |
| 11 | +; RUN: -ppc-asm-full-reg-names --ppc-vsr-nums-as-vr < %s | FileCheck %s |
| 12 | + |
| 13 | +; Function to test ternary(A, xor(B, C), and(B, C)) for <4 x i32> |
| 14 | +define <4 x i32> @ternary_A_xor_BC_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { |
| 15 | +; CHECK-LABEL: ternary_A_xor_BC_and_BC_4x32: |
| 16 | +; CHECK: # %bb.0: # %entry |
| 17 | +; CHECK-NEXT: xxleqv v5, v5, v5 |
| 18 | +; CHECK-NEXT: xxlxor vs0, v3, v4 |
| 19 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 20 | +; CHECK-NEXT: vslw v2, v2, v5 |
| 21 | +; CHECK-NEXT: vsraw v2, v2, v5 |
| 22 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 23 | +; CHECK-NEXT: blr |
| 24 | +entry: |
| 25 | + %xor = xor <4 x i32> %B, %C |
| 26 | + %and = and <4 x i32> %B, %C |
| 27 | + %res = select <4 x i1> %A, <4 x i32> %xor, <4 x i32> %and |
| 28 | + ret <4 x i32> %res |
| 29 | +} |
| 30 | + |
| 31 | +; Function to test ternary(A, xor(B, C), and(B, C)) for <2 x i64> |
| 32 | +define <2 x i64> @ternary_A_xor_BC_and_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { |
| 33 | +; CHECK-LABEL: ternary_A_xor_BC_and_BC_2x64: |
| 34 | +; CHECK: # %bb.0: # %entry |
| 35 | +; CHECK-NEXT: xxlxor v5, v5, v5 |
| 36 | +; CHECK-NEXT: xxlxor vs0, v3, v4 |
| 37 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 38 | +; CHECK-NEXT: xxsplti32dx v5, 1, 63 |
| 39 | +; CHECK-NEXT: vsld v2, v2, v5 |
| 40 | +; CHECK-NEXT: vsrad v2, v2, v5 |
| 41 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 42 | +; CHECK-NEXT: blr |
| 43 | +entry: |
| 44 | + %xor = xor <2 x i64> %B, %C |
| 45 | + %and = and <2 x i64> %B, %C |
| 46 | + %res = select <2 x i1> %A, <2 x i64> %xor, <2 x i64> %and |
| 47 | + ret <2 x i64> %res |
| 48 | +} |
| 49 | + |
| 50 | +; Function to test ternary(A, nor(B, C), and(B, C)) for <4 x i32> |
| 51 | +define <4 x i32> @ternary_A_nor_BC_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { |
| 52 | +; CHECK-LABEL: ternary_A_nor_BC_and_BC_4x32: |
| 53 | +; CHECK: # %bb.0: # %entry |
| 54 | +; CHECK-NEXT: xxleqv v5, v5, v5 |
| 55 | +; CHECK-NEXT: xxlnor vs0, v3, v4 |
| 56 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 57 | +; CHECK-NEXT: vslw v2, v2, v5 |
| 58 | +; CHECK-NEXT: vsraw v2, v2, v5 |
| 59 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 60 | +; CHECK-NEXT: blr |
| 61 | +entry: |
| 62 | + %or = or <4 x i32> %B, %C |
| 63 | + %nor = xor <4 x i32> %or, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector NOR operation |
| 64 | + %and = and <4 x i32> %B, %C |
| 65 | + %res = select <4 x i1> %A, <4 x i32> %nor, <4 x i32> %and |
| 66 | + ret <4 x i32> %res |
| 67 | +} |
| 68 | + |
| 69 | +; Function to test ternary(A, nor(B, C), and(B, C)) for <2 x i64> |
| 70 | +define <2 x i64> @ternary_A_nor_BC_and_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { |
| 71 | +; CHECK-LABEL: ternary_A_nor_BC_and_BC_2x64: |
| 72 | +; CHECK: # %bb.0: # %entry |
| 73 | +; CHECK-NEXT: xxlxor v5, v5, v5 |
| 74 | +; CHECK-NEXT: xxlnor vs0, v3, v4 |
| 75 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 76 | +; CHECK-NEXT: xxsplti32dx v5, 1, 63 |
| 77 | +; CHECK-NEXT: vsld v2, v2, v5 |
| 78 | +; CHECK-NEXT: vsrad v2, v2, v5 |
| 79 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 80 | +; CHECK-NEXT: blr |
| 81 | +entry: |
| 82 | + %or = or <2 x i64> %B, %C |
| 83 | + %nor = xor <2 x i64> %or, <i64 -1, i64 -1> ; Vector NOR operation |
| 84 | + %and = and <2 x i64> %B, %C |
| 85 | + %res = select <2 x i1> %A, <2 x i64> %nor, <2 x i64> %and |
| 86 | + ret <2 x i64> %res |
| 87 | +} |
| 88 | + |
| 89 | +; Function to test ternary(A, eqv(B, C), and(B, C)) for <4 x i32> |
| 90 | +define <4 x i32> @ternary_A_eqv_BC_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { |
| 91 | +; CHECK-LABEL: ternary_A_eqv_BC_and_BC_4x32: |
| 92 | +; CHECK: # %bb.0: # %entry |
| 93 | +; CHECK-NEXT: xxleqv v5, v5, v5 |
| 94 | +; CHECK-NEXT: xxleqv vs0, v3, v4 |
| 95 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 96 | +; CHECK-NEXT: vslw v2, v2, v5 |
| 97 | +; CHECK-NEXT: vsraw v2, v2, v5 |
| 98 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 99 | +; CHECK-NEXT: blr |
| 100 | +entry: |
| 101 | + %xor = xor <4 x i32> %B, %C |
| 102 | + %eqv = xor <4 x i32> %xor, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector eqv operation |
| 103 | + %and = and <4 x i32> %B, %C |
| 104 | + %res = select <4 x i1> %A, <4 x i32> %eqv, <4 x i32> %and |
| 105 | + ret <4 x i32> %res |
| 106 | +} |
| 107 | + |
| 108 | +; Function to test ternary(A, eqv(B, C), and(B, C)) for <2 x i64> |
| 109 | +define <2 x i64> @ternary_A_eqv_BC_and_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { |
| 110 | +; CHECK-LABEL: ternary_A_eqv_BC_and_BC_2x64: |
| 111 | +; CHECK: # %bb.0: # %entry |
| 112 | +; CHECK-NEXT: xxlxor v5, v5, v5 |
| 113 | +; CHECK-NEXT: xxleqv vs0, v3, v4 |
| 114 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 115 | +; CHECK-NEXT: xxsplti32dx v5, 1, 63 |
| 116 | +; CHECK-NEXT: vsld v2, v2, v5 |
| 117 | +; CHECK-NEXT: vsrad v2, v2, v5 |
| 118 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 119 | +; CHECK-NEXT: blr |
| 120 | +entry: |
| 121 | + %xor = xor <2 x i64> %B, %C |
| 122 | + %eqv = xor <2 x i64> %xor, <i64 -1, i64 -1> ; Vector eqv operation |
| 123 | + %and = and <2 x i64> %B, %C |
| 124 | + %res = select <2 x i1> %A, <2 x i64> %eqv, <2 x i64> %and |
| 125 | + ret <2 x i64> %res |
| 126 | +} |
| 127 | + |
| 128 | +; Function to test ternary(A, not(C), and(B, C)) for <4 x i32> |
| 129 | +define <4 x i32> @ternary_A_not_C_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { |
| 130 | +; CHECK-LABEL: ternary_A_not_C_and_BC_4x32: |
| 131 | +; CHECK: # %bb.0: # %entry |
| 132 | +; CHECK-NEXT: xxleqv v5, v5, v5 |
| 133 | +; CHECK-NEXT: xxlnor vs0, v4, v4 |
| 134 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 135 | +; CHECK-NEXT: vslw v2, v2, v5 |
| 136 | +; CHECK-NEXT: vsraw v2, v2, v5 |
| 137 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 138 | +; CHECK-NEXT: blr |
| 139 | +entry: |
| 140 | + %not = xor <4 x i32> %C, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector not operation |
| 141 | + %and = and <4 x i32> %B, %C |
| 142 | + %res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %and |
| 143 | + ret <4 x i32> %res |
| 144 | +} |
| 145 | + |
| 146 | +; Function to test ternary(A, not(C), and(B, C)) for <2 x i64> |
| 147 | +define <2 x i64> @ternary_A_not_C_and_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { |
| 148 | +; CHECK-LABEL: ternary_A_not_C_and_BC_2x64: |
| 149 | +; CHECK: # %bb.0: # %entry |
| 150 | +; CHECK-NEXT: xxlxor v5, v5, v5 |
| 151 | +; CHECK-NEXT: xxlnor vs0, v4, v4 |
| 152 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 153 | +; CHECK-NEXT: xxsplti32dx v5, 1, 63 |
| 154 | +; CHECK-NEXT: vsld v2, v2, v5 |
| 155 | +; CHECK-NEXT: vsrad v2, v2, v5 |
| 156 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 157 | +; CHECK-NEXT: blr |
| 158 | +entry: |
| 159 | + %not = xor <2 x i64> %C, <i64 -1, i64 -1> ; Vector not operation |
| 160 | + %and = and <2 x i64> %B, %C |
| 161 | + %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %and |
| 162 | + ret <2 x i64> %res |
| 163 | +} |
| 164 | + |
| 165 | +; Function to test ternary(A, not(B), and(B, C)) for <4 x i32> |
| 166 | +define <4 x i32> @ternary_A_not_B_and_BC_4x32(<4 x i1> %A, <4 x i32> %B, <4 x i32> %C) { |
| 167 | +; CHECK-LABEL: ternary_A_not_B_and_BC_4x32: |
| 168 | +; CHECK: # %bb.0: # %entry |
| 169 | +; CHECK-NEXT: xxleqv v5, v5, v5 |
| 170 | +; CHECK-NEXT: xxlnor vs0, v3, v3 |
| 171 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 172 | +; CHECK-NEXT: vslw v2, v2, v5 |
| 173 | +; CHECK-NEXT: vsraw v2, v2, v5 |
| 174 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 175 | +; CHECK-NEXT: blr |
| 176 | +entry: |
| 177 | + %not = xor <4 x i32> %B, <i32 -1, i32 -1, i32 -1, i32 -1> ; Vector not operation |
| 178 | + %and = and <4 x i32> %B, %C |
| 179 | + %res = select <4 x i1> %A, <4 x i32> %not, <4 x i32> %and |
| 180 | + ret <4 x i32> %res |
| 181 | +} |
| 182 | + |
| 183 | +; Function to test ternary(A, not(B), and(B, C)) for <2 x i64> |
| 184 | +define <2 x i64> @ternary_A_not_B_and_BC_2x64(<2 x i1> %A, <2 x i64> %B, <2 x i64> %C) { |
| 185 | +; CHECK-LABEL: ternary_A_not_B_and_BC_2x64: |
| 186 | +; CHECK: # %bb.0: # %entry |
| 187 | +; CHECK-NEXT: xxlxor v5, v5, v5 |
| 188 | +; CHECK-NEXT: xxlnor vs0, v3, v3 |
| 189 | +; CHECK-NEXT: xxland vs1, v3, v4 |
| 190 | +; CHECK-NEXT: xxsplti32dx v5, 1, 63 |
| 191 | +; CHECK-NEXT: vsld v2, v2, v5 |
| 192 | +; CHECK-NEXT: vsrad v2, v2, v5 |
| 193 | +; CHECK-NEXT: xxsel v2, vs1, vs0, v2 |
| 194 | +; CHECK-NEXT: blr |
| 195 | +entry: |
| 196 | + %not = xor <2 x i64> %B, <i64 -1, i64 -1> ; Vector not operation |
| 197 | + %and = and <2 x i64> %B, %C |
| 198 | + %res = select <2 x i1> %A, <2 x i64> %not, <2 x i64> %and |
| 199 | + ret <2 x i64> %res |
| 200 | +} |
0 commit comments