1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 2# 3# Check that we can recognize a shuffle mask for a zip instruction, and produce 4# G_ZIP1 or G_ZIP2 where appropriate. 5# 6# RUN: llc -mtriple aarch64 -run-pass=aarch64-postlegalizer-lowering -verify-machineinstrs %s -o - | FileCheck %s 7 8... 9--- 10name: zip1_v2s32 11alignment: 4 12legalized: true 13tracksRegLiveness: true 14body: | 15 bb.1.entry: 16 liveins: $d0, $d1 17 18 ; CHECK-LABEL: name: zip1_v2s32 19 ; CHECK: liveins: $d0, $d1 20 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0 21 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1 22 ; CHECK: [[ZIP1_:%[0-9]+]]:_(<2 x s32>) = G_ZIP1 [[COPY]], [[COPY1]] 23 ; CHECK: $d0 = COPY [[ZIP1_]](<2 x s32>) 24 ; CHECK: RET_ReallyLR implicit $d0 25 %0:_(<2 x s32>) = COPY $d0 26 %1:_(<2 x s32>) = COPY $d1 27 %2:_(<2 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1, shufflemask(0, 2) 28 $d0 = COPY %2(<2 x s32>) 29 RET_ReallyLR implicit $d0 30 31... 32--- 33name: zip1_v2s64 34alignment: 4 35legalized: true 36tracksRegLiveness: true 37body: | 38 bb.1.entry: 39 liveins: $q0, $q1 40 41 ; CHECK-LABEL: name: zip1_v2s64 42 ; CHECK: liveins: $q0, $q1 43 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0 44 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1 45 ; CHECK: [[ZIP1_:%[0-9]+]]:_(<2 x s64>) = G_ZIP1 [[COPY]], [[COPY1]] 46 ; CHECK: $q0 = COPY [[ZIP1_]](<2 x s64>) 47 ; CHECK: RET_ReallyLR implicit $q0 48 %0:_(<2 x s64>) = COPY $q0 49 %1:_(<2 x s64>) = COPY $q1 50 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(0, 2) 51 $q0 = COPY %2(<2 x s64>) 52 RET_ReallyLR implicit $q0 53 54... 55--- 56name: zip1_v4s32 57alignment: 4 58legalized: true 59tracksRegLiveness: true 60body: | 61 bb.1.entry: 62 liveins: $q0, $q1 63 64 ; CHECK-LABEL: name: zip1_v4s32 65 ; CHECK: liveins: $q0, $q1 66 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0 67 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1 68 ; CHECK: [[ZIP1_:%[0-9]+]]:_(<4 x s32>) = G_ZIP1 [[COPY]], [[COPY1]] 69 ; CHECK: $q0 = COPY [[ZIP1_]](<4 x s32>) 70 ; CHECK: RET_ReallyLR implicit $q0 71 %0:_(<4 x s32>) = COPY $q0 72 %1:_(<4 x s32>) = COPY $q1 73 %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1, shufflemask(0, 4, 1, 5) 74 $q0 = COPY %2(<4 x s32>) 75 RET_ReallyLR implicit $q0 76 77... 78--- 79name: zip2_v2s32 80alignment: 4 81legalized: true 82tracksRegLiveness: true 83body: | 84 bb.1.entry: 85 liveins: $d0, $d1 86 87 ; CHECK-LABEL: name: zip2_v2s32 88 ; CHECK: liveins: $d0, $d1 89 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0 90 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1 91 ; CHECK: [[ZIP2_:%[0-9]+]]:_(<2 x s32>) = G_ZIP2 [[COPY]], [[COPY1]] 92 ; CHECK: $d0 = COPY [[ZIP2_]](<2 x s32>) 93 ; CHECK: RET_ReallyLR implicit $d0 94 %0:_(<2 x s32>) = COPY $d0 95 %1:_(<2 x s32>) = COPY $d1 96 %2:_(<2 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1, shufflemask(1, 3) 97 $d0 = COPY %2(<2 x s32>) 98 RET_ReallyLR implicit $d0 99 100... 101--- 102name: zip2_v2s64 103alignment: 4 104legalized: true 105tracksRegLiveness: true 106body: | 107 bb.1.entry: 108 liveins: $q0, $q1 109 110 ; CHECK-LABEL: name: zip2_v2s64 111 ; CHECK: liveins: $q0, $q1 112 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0 113 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1 114 ; CHECK: [[ZIP2_:%[0-9]+]]:_(<2 x s64>) = G_ZIP2 [[COPY]], [[COPY1]] 115 ; CHECK: $q0 = COPY [[ZIP2_]](<2 x s64>) 116 ; CHECK: RET_ReallyLR implicit $q0 117 %0:_(<2 x s64>) = COPY $q0 118 %1:_(<2 x s64>) = COPY $q1 119 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(1, 3) 120 $q0 = COPY %2(<2 x s64>) 121 RET_ReallyLR implicit $q0 122 123... 124--- 125name: zip2_v4s32 126alignment: 4 127legalized: true 128tracksRegLiveness: true 129body: | 130 bb.1.entry: 131 liveins: $q0, $q1 132 133 ; CHECK-LABEL: name: zip2_v4s32 134 ; CHECK: liveins: $q0, $q1 135 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0 136 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1 137 ; CHECK: [[ZIP2_:%[0-9]+]]:_(<4 x s32>) = G_ZIP2 [[COPY]], [[COPY1]] 138 ; CHECK: $q0 = COPY [[ZIP2_]](<4 x s32>) 139 ; CHECK: RET_ReallyLR implicit $q0 140 %0:_(<4 x s32>) = COPY $q0 141 %1:_(<4 x s32>) = COPY $q1 142 %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1, shufflemask(2, 6, 3, 7) 143 $q0 = COPY %2(<4 x s32>) 144 RET_ReallyLR implicit $q0 145 146... 147--- 148name: zip2_no_combine_idx_mismatch 149alignment: 4 150legalized: true 151tracksRegLiveness: true 152body: | 153 bb.1.entry: 154 liveins: $q0, $q1 155 156 ; This will fail because it expects 3 to be the second element of the 157 ; shuffle vector mask. 158 ; 159 ; CHECK-LABEL: name: zip2_no_combine_idx_mismatch 160 ; CHECK: liveins: $q0, $q1 161 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0 162 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1 163 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 8 164 ; CHECK: [[EXT:%[0-9]+]]:_(<2 x s64>) = G_EXT [[COPY]], [[COPY1]], [[C]](s32) 165 ; CHECK: $q0 = COPY [[EXT]](<2 x s64>) 166 ; CHECK: RET_ReallyLR implicit $q0 167 %0:_(<2 x s64>) = COPY $q0 168 %1:_(<2 x s64>) = COPY $q1 169 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(1, 2) 170 $q0 = COPY %2(<2 x s64>) 171 RET_ReallyLR implicit $q0 172 173... 174--- 175name: zip1_no_combine_idx_mismatch 176alignment: 4 177legalized: true 178tracksRegLiveness: true 179body: | 180 bb.1.entry: 181 liveins: $q0, $q1 182 183 ; This will fail because it expects 2 to be the second element of the 184 ; shuffle vector mask. 185 ; 186 ; CHECK-LABEL: name: zip1_no_combine_idx_mismatch 187 ; CHECK: liveins: $q0, $q1 188 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0 189 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s64>) = COPY $q1 190 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0 191 ; CHECK: [[EXT:%[0-9]+]]:_(<2 x s64>) = G_EXT [[COPY]], [[COPY1]], [[C]](s32) 192 ; CHECK: $q0 = COPY [[EXT]](<2 x s64>) 193 ; CHECK: RET_ReallyLR implicit $q0 194 %0:_(<2 x s64>) = COPY $q0 195 %1:_(<2 x s64>) = COPY $q1 196 %2:_(<2 x s64>) = G_SHUFFLE_VECTOR %0(<2 x s64>), %1, shufflemask(0, 1) 197 $q0 = COPY %2(<2 x s64>) 198 RET_ReallyLR implicit $q0 199 200... 201--- 202name: no_combine_first_elt_of_mask_must_be_zero_or_one 203alignment: 4 204legalized: true 205tracksRegLiveness: true 206body: | 207 bb.1.entry: 208 liveins: $q0, $q1 209 210 ; zip1/zip2 must have 0 or 1 as the first element in the shuffle mask. 211 ; 212 ; CHECK-LABEL: name: no_combine_first_elt_of_mask_must_be_zero_or_one 213 ; CHECK: liveins: $q0, $q1 214 ; CHECK: [[COPY:%[0-9]+]]:_(<4 x s32>) = COPY $q0 215 ; CHECK: [[COPY1:%[0-9]+]]:_(<4 x s32>) = COPY $q1 216 ; CHECK: [[SHUF:%[0-9]+]]:_(<4 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<4 x s32>), [[COPY1]], shufflemask(3, 4, 1, 5) 217 ; CHECK: $q0 = COPY [[SHUF]](<4 x s32>) 218 ; CHECK: RET_ReallyLR implicit $q0 219 %0:_(<4 x s32>) = COPY $q0 220 %1:_(<4 x s32>) = COPY $q1 221 %2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<4 x s32>), %1, shufflemask(3, 4, 1, 5) 222 $q0 = COPY %2(<4 x s32>) 223 RET_ReallyLR implicit $q0 224