|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 |
| 2 | +; RUN: llc --mtriple=loongarch32 --mattr=+32s,+lasx < %s | FileCheck %s --check-prefixes=CHECK,LA32 |
| 3 | +; RUN: llc --mtriple=loongarch64 --mattr=+lasx < %s | FileCheck %s --check-prefixes=CHECK,LA64 |
| 4 | + |
| 5 | +define void @rotl_v32i8(ptr %dst, ptr %src, i8 signext %a0) nounwind { |
| 6 | +; CHECK-LABEL: rotl_v32i8: |
| 7 | +; CHECK: # %bb.0: |
| 8 | +; CHECK-NEXT: xvld $xr0, $a1, 0 |
| 9 | +; CHECK-NEXT: xvreplgr2vr.b $xr1, $a2 |
| 10 | +; CHECK-NEXT: xvrepli.b $xr2, 8 |
| 11 | +; CHECK-NEXT: xvsub.b $xr2, $xr2, $xr1 |
| 12 | +; CHECK-NEXT: xvsll.b $xr1, $xr0, $xr1 |
| 13 | +; CHECK-NEXT: xvsrl.b $xr0, $xr0, $xr2 |
| 14 | +; CHECK-NEXT: xvor.v $xr0, $xr1, $xr0 |
| 15 | +; CHECK-NEXT: xvst $xr0, $a0, 0 |
| 16 | +; CHECK-NEXT: ret |
| 17 | + %v0 = load <32 x i8>, ptr %src |
| 18 | + %v1.ele = insertelement <32 x i8> poison, i8 %a0, i8 0 |
| 19 | + %v1 = shufflevector <32 x i8> %v1.ele, <32 x i8> poison, <32 x i32> zeroinitializer |
| 20 | + %v1.sub = sub <32 x i8> splat (i8 8), %v1 |
| 21 | + %b = shl <32 x i8> %v0, %v1 |
| 22 | + %c = lshr <32 x i8> %v0, %v1.sub |
| 23 | + %d = or <32 x i8> %b, %c |
| 24 | + store <32 x i8> %d, ptr %dst |
| 25 | + ret void |
| 26 | +} |
| 27 | + |
| 28 | +define void @rotr_v32i8(ptr %dst, ptr %src, i8 signext %a0) nounwind { |
| 29 | +; CHECK-LABEL: rotr_v32i8: |
| 30 | +; CHECK: # %bb.0: |
| 31 | +; CHECK-NEXT: xvld $xr0, $a1, 0 |
| 32 | +; CHECK-NEXT: xvreplgr2vr.b $xr1, $a2 |
| 33 | +; CHECK-NEXT: xvrepli.b $xr2, 8 |
| 34 | +; CHECK-NEXT: xvsub.b $xr2, $xr2, $xr1 |
| 35 | +; CHECK-NEXT: xvsrl.b $xr1, $xr0, $xr1 |
| 36 | +; CHECK-NEXT: xvsll.b $xr0, $xr0, $xr2 |
| 37 | +; CHECK-NEXT: xvor.v $xr0, $xr1, $xr0 |
| 38 | +; CHECK-NEXT: xvst $xr0, $a0, 0 |
| 39 | +; CHECK-NEXT: ret |
| 40 | + %v0 = load <32 x i8>, ptr %src |
| 41 | + %v1.ele = insertelement <32 x i8> poison, i8 %a0, i8 0 |
| 42 | + %v1 = shufflevector <32 x i8> %v1.ele, <32 x i8> poison, <32 x i32> zeroinitializer |
| 43 | + %v1.sub = sub <32 x i8> splat (i8 8), %v1 |
| 44 | + %b = lshr <32 x i8> %v0, %v1 |
| 45 | + %c = shl <32 x i8> %v0, %v1.sub |
| 46 | + %d = or <32 x i8> %b, %c |
| 47 | + store <32 x i8> %d, ptr %dst |
| 48 | + ret void |
| 49 | +} |
| 50 | + |
| 51 | +define void @rotr_v32i8_imm(ptr %dst, ptr %src) nounwind { |
| 52 | +; CHECK-LABEL: rotr_v32i8_imm: |
| 53 | +; CHECK: # %bb.0: |
| 54 | +; CHECK-NEXT: xvld $xr0, $a1, 0 |
| 55 | +; CHECK-NEXT: xvsrli.b $xr1, $xr0, 2 |
| 56 | +; CHECK-NEXT: xvslli.b $xr0, $xr0, 6 |
| 57 | +; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1 |
| 58 | +; CHECK-NEXT: xvst $xr0, $a0, 0 |
| 59 | +; CHECK-NEXT: ret |
| 60 | + %v0 = load <32 x i8>, ptr %src |
| 61 | + %b = lshr <32 x i8> %v0, splat (i8 2) |
| 62 | + %c = shl <32 x i8> %v0, splat (i8 6) |
| 63 | + %d = or <32 x i8> %b, %c |
| 64 | + store <32 x i8> %d, ptr %dst |
| 65 | + ret void |
| 66 | +} |
| 67 | + |
| 68 | +define void @rotl_v16i16(ptr %dst, ptr %src, i16 signext %a0) nounwind { |
| 69 | +; CHECK-LABEL: rotl_v16i16: |
| 70 | +; CHECK: # %bb.0: |
| 71 | +; CHECK-NEXT: xvld $xr0, $a1, 0 |
| 72 | +; CHECK-NEXT: xvreplgr2vr.h $xr1, $a2 |
| 73 | +; CHECK-NEXT: xvrepli.h $xr2, 16 |
| 74 | +; CHECK-NEXT: xvsub.h $xr2, $xr2, $xr1 |
| 75 | +; CHECK-NEXT: xvsll.h $xr1, $xr0, $xr1 |
| 76 | +; CHECK-NEXT: xvsrl.h $xr0, $xr0, $xr2 |
| 77 | +; CHECK-NEXT: xvor.v $xr0, $xr1, $xr0 |
| 78 | +; CHECK-NEXT: xvst $xr0, $a0, 0 |
| 79 | +; CHECK-NEXT: ret |
| 80 | + %v0 = load <16 x i16>, ptr %src |
| 81 | + %v1.ele = insertelement <16 x i16> poison, i16 %a0, i16 0 |
| 82 | + %v1 = shufflevector <16 x i16> %v1.ele, <16 x i16> poison, <16 x i32> zeroinitializer |
| 83 | + %v1.sub = sub <16 x i16> splat (i16 16), %v1 |
| 84 | + %b = shl <16 x i16> %v0, %v1 |
| 85 | + %c = lshr <16 x i16> %v0, %v1.sub |
| 86 | + %d = or <16 x i16> %b, %c |
| 87 | + store <16 x i16> %d, ptr %dst |
| 88 | + ret void |
| 89 | +} |
| 90 | + |
| 91 | +define void @rotr_v16i16(ptr %dst, ptr %src, i16 signext %a0) nounwind { |
| 92 | +; CHECK-LABEL: rotr_v16i16: |
| 93 | +; CHECK: # %bb.0: |
| 94 | +; CHECK-NEXT: xvld $xr0, $a1, 0 |
| 95 | +; CHECK-NEXT: xvreplgr2vr.h $xr1, $a2 |
| 96 | +; CHECK-NEXT: xvrepli.h $xr2, 16 |
| 97 | +; CHECK-NEXT: xvsub.h $xr2, $xr2, $xr1 |
| 98 | +; CHECK-NEXT: xvsrl.h $xr1, $xr0, $xr1 |
| 99 | +; CHECK-NEXT: xvsll.h $xr0, $xr0, $xr2 |
| 100 | +; CHECK-NEXT: xvor.v $xr0, $xr1, $xr0 |
| 101 | +; CHECK-NEXT: xvst $xr0, $a0, 0 |
| 102 | +; CHECK-NEXT: ret |
| 103 | + %v0 = load <16 x i16>, ptr %src |
| 104 | + %v1.ele = insertelement <16 x i16> poison, i16 %a0, i16 0 |
| 105 | + %v1 = shufflevector <16 x i16> %v1.ele, <16 x i16> poison, <16 x i32> zeroinitializer |
| 106 | + %v1.sub = sub <16 x i16> splat (i16 16), %v1 |
| 107 | + %b = lshr <16 x i16> %v0, %v1 |
| 108 | + %c = shl <16 x i16> %v0, %v1.sub |
| 109 | + %d = or <16 x i16> %b, %c |
| 110 | + store <16 x i16> %d, ptr %dst |
| 111 | + ret void |
| 112 | +} |
| 113 | + |
| 114 | +define void @rotr_v16i16_imm(ptr %dst, ptr %src) nounwind { |
| 115 | +; CHECK-LABEL: rotr_v16i16_imm: |
| 116 | +; CHECK: # %bb.0: |
| 117 | +; CHECK-NEXT: xvld $xr0, $a1, 0 |
| 118 | +; CHECK-NEXT: xvsrli.h $xr1, $xr0, 2 |
| 119 | +; CHECK-NEXT: xvslli.h $xr0, $xr0, 14 |
| 120 | +; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1 |
| 121 | +; CHECK-NEXT: xvst $xr0, $a0, 0 |
| 122 | +; CHECK-NEXT: ret |
| 123 | + %v0 = load <16 x i16>, ptr %src |
| 124 | + %b = lshr <16 x i16> %v0, splat (i16 2) |
| 125 | + %c = shl <16 x i16> %v0, splat (i16 14) |
| 126 | + %d = or <16 x i16> %b, %c |
| 127 | + store <16 x i16> %d, ptr %dst |
| 128 | + ret void |
| 129 | +} |
| 130 | + |
| 131 | +define void @rotl_v8i32(ptr %dst, ptr %src, i32 signext %a0) nounwind { |
| 132 | +; CHECK-LABEL: rotl_v8i32: |
| 133 | +; CHECK: # %bb.0: |
| 134 | +; CHECK-NEXT: xvld $xr0, $a1, 0 |
| 135 | +; CHECK-NEXT: xvreplgr2vr.w $xr1, $a2 |
| 136 | +; CHECK-NEXT: xvrepli.w $xr2, 32 |
| 137 | +; CHECK-NEXT: xvsub.w $xr2, $xr2, $xr1 |
| 138 | +; CHECK-NEXT: xvsll.w $xr1, $xr0, $xr1 |
| 139 | +; CHECK-NEXT: xvsrl.w $xr0, $xr0, $xr2 |
| 140 | +; CHECK-NEXT: xvor.v $xr0, $xr1, $xr0 |
| 141 | +; CHECK-NEXT: xvst $xr0, $a0, 0 |
| 142 | +; CHECK-NEXT: ret |
| 143 | + %v0 = load <8 x i32>, ptr %src |
| 144 | + %v1.ele = insertelement <8 x i32> poison, i32 %a0, i32 0 |
| 145 | + %v1 = shufflevector <8 x i32> %v1.ele, <8 x i32> poison, <8 x i32> zeroinitializer |
| 146 | + %v1.sub = sub <8 x i32> splat (i32 32), %v1 |
| 147 | + %b = shl <8 x i32> %v0, %v1 |
| 148 | + %c = lshr <8 x i32> %v0, %v1.sub |
| 149 | + %d = or <8 x i32> %b, %c |
| 150 | + store <8 x i32> %d, ptr %dst |
| 151 | + ret void |
| 152 | +} |
| 153 | + |
| 154 | +define void @rotr_v8i32(ptr %dst, ptr %src, i32 signext %a0) nounwind { |
| 155 | +; CHECK-LABEL: rotr_v8i32: |
| 156 | +; CHECK: # %bb.0: |
| 157 | +; CHECK-NEXT: xvld $xr0, $a1, 0 |
| 158 | +; CHECK-NEXT: xvreplgr2vr.w $xr1, $a2 |
| 159 | +; CHECK-NEXT: xvrepli.w $xr2, 32 |
| 160 | +; CHECK-NEXT: xvsub.w $xr2, $xr2, $xr1 |
| 161 | +; CHECK-NEXT: xvsrl.w $xr1, $xr0, $xr1 |
| 162 | +; CHECK-NEXT: xvsll.w $xr0, $xr0, $xr2 |
| 163 | +; CHECK-NEXT: xvor.v $xr0, $xr1, $xr0 |
| 164 | +; CHECK-NEXT: xvst $xr0, $a0, 0 |
| 165 | +; CHECK-NEXT: ret |
| 166 | + %v0 = load <8 x i32>, ptr %src |
| 167 | + %v1.ele = insertelement <8 x i32> poison, i32 %a0, i32 0 |
| 168 | + %v1 = shufflevector <8 x i32> %v1.ele, <8 x i32> poison, <8 x i32> zeroinitializer |
| 169 | + %v1.sub = sub <8 x i32> splat (i32 32), %v1 |
| 170 | + %b = lshr <8 x i32> %v0, %v1 |
| 171 | + %c = shl <8 x i32> %v0, %v1.sub |
| 172 | + %d = or <8 x i32> %b, %c |
| 173 | + store <8 x i32> %d, ptr %dst |
| 174 | + ret void |
| 175 | +} |
| 176 | + |
| 177 | +define void @rotr_v8i32_imm(ptr %dst, ptr %src) nounwind { |
| 178 | +; CHECK-LABEL: rotr_v8i32_imm: |
| 179 | +; CHECK: # %bb.0: |
| 180 | +; CHECK-NEXT: xvld $xr0, $a1, 0 |
| 181 | +; CHECK-NEXT: xvsrli.w $xr1, $xr0, 2 |
| 182 | +; CHECK-NEXT: xvslli.w $xr0, $xr0, 30 |
| 183 | +; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1 |
| 184 | +; CHECK-NEXT: xvst $xr0, $a0, 0 |
| 185 | +; CHECK-NEXT: ret |
| 186 | + %v0 = load <8 x i32>, ptr %src |
| 187 | + %b = lshr <8 x i32> %v0, splat (i32 2) |
| 188 | + %c = shl <8 x i32> %v0, splat (i32 30) |
| 189 | + %d = or <8 x i32> %b, %c |
| 190 | + store <8 x i32> %d, ptr %dst |
| 191 | + ret void |
| 192 | +} |
| 193 | + |
| 194 | +define void @rotl_v4i64(ptr %dst, ptr %src, i64 %a0) nounwind { |
| 195 | +; LA32-LABEL: rotl_v4i64: |
| 196 | +; LA32: # %bb.0: |
| 197 | +; LA32-NEXT: xvld $xr0, $a1, 0 |
| 198 | +; LA32-NEXT: vinsgr2vr.w $vr1, $a2, 0 |
| 199 | +; LA32-NEXT: vinsgr2vr.w $vr1, $a3, 1 |
| 200 | +; LA32-NEXT: xvreplve0.d $xr1, $xr1 |
| 201 | +; LA32-NEXT: xvrepli.d $xr2, 64 |
| 202 | +; LA32-NEXT: xvsub.d $xr2, $xr2, $xr1 |
| 203 | +; LA32-NEXT: xvsll.d $xr1, $xr0, $xr1 |
| 204 | +; LA32-NEXT: xvsrl.d $xr0, $xr0, $xr2 |
| 205 | +; LA32-NEXT: xvor.v $xr0, $xr1, $xr0 |
| 206 | +; LA32-NEXT: xvst $xr0, $a0, 0 |
| 207 | +; LA32-NEXT: ret |
| 208 | +; |
| 209 | +; LA64-LABEL: rotl_v4i64: |
| 210 | +; LA64: # %bb.0: |
| 211 | +; LA64-NEXT: xvld $xr0, $a1, 0 |
| 212 | +; LA64-NEXT: xvreplgr2vr.d $xr1, $a2 |
| 213 | +; LA64-NEXT: xvrepli.d $xr2, 64 |
| 214 | +; LA64-NEXT: xvsub.d $xr2, $xr2, $xr1 |
| 215 | +; LA64-NEXT: xvsll.d $xr1, $xr0, $xr1 |
| 216 | +; LA64-NEXT: xvsrl.d $xr0, $xr0, $xr2 |
| 217 | +; LA64-NEXT: xvor.v $xr0, $xr1, $xr0 |
| 218 | +; LA64-NEXT: xvst $xr0, $a0, 0 |
| 219 | +; LA64-NEXT: ret |
| 220 | + %v0 = load <4 x i64>, ptr %src |
| 221 | + %v1.ele = insertelement <4 x i64> poison, i64 %a0, i64 0 |
| 222 | + %v1 = shufflevector <4 x i64> %v1.ele, <4 x i64> poison, <4 x i32> zeroinitializer |
| 223 | + %v1.sub = sub <4 x i64> splat (i64 64), %v1 |
| 224 | + %b = shl <4 x i64> %v0, %v1 |
| 225 | + %c = lshr <4 x i64> %v0, %v1.sub |
| 226 | + %d = or <4 x i64> %b, %c |
| 227 | + store <4 x i64> %d, ptr %dst |
| 228 | + ret void |
| 229 | +} |
| 230 | + |
| 231 | +define void @rotr_v4i64(ptr %dst, ptr %src, i64 %a0) nounwind { |
| 232 | +; LA32-LABEL: rotr_v4i64: |
| 233 | +; LA32: # %bb.0: |
| 234 | +; LA32-NEXT: xvld $xr0, $a1, 0 |
| 235 | +; LA32-NEXT: vinsgr2vr.w $vr1, $a2, 0 |
| 236 | +; LA32-NEXT: vinsgr2vr.w $vr1, $a3, 1 |
| 237 | +; LA32-NEXT: xvreplve0.d $xr1, $xr1 |
| 238 | +; LA32-NEXT: xvrepli.d $xr2, 64 |
| 239 | +; LA32-NEXT: xvsub.d $xr2, $xr2, $xr1 |
| 240 | +; LA32-NEXT: xvsrl.d $xr1, $xr0, $xr1 |
| 241 | +; LA32-NEXT: xvsll.d $xr0, $xr0, $xr2 |
| 242 | +; LA32-NEXT: xvor.v $xr0, $xr1, $xr0 |
| 243 | +; LA32-NEXT: xvst $xr0, $a0, 0 |
| 244 | +; LA32-NEXT: ret |
| 245 | +; |
| 246 | +; LA64-LABEL: rotr_v4i64: |
| 247 | +; LA64: # %bb.0: |
| 248 | +; LA64-NEXT: xvld $xr0, $a1, 0 |
| 249 | +; LA64-NEXT: xvreplgr2vr.d $xr1, $a2 |
| 250 | +; LA64-NEXT: xvrepli.d $xr2, 64 |
| 251 | +; LA64-NEXT: xvsub.d $xr2, $xr2, $xr1 |
| 252 | +; LA64-NEXT: xvsrl.d $xr1, $xr0, $xr1 |
| 253 | +; LA64-NEXT: xvsll.d $xr0, $xr0, $xr2 |
| 254 | +; LA64-NEXT: xvor.v $xr0, $xr1, $xr0 |
| 255 | +; LA64-NEXT: xvst $xr0, $a0, 0 |
| 256 | +; LA64-NEXT: ret |
| 257 | + %v0 = load <4 x i64>, ptr %src |
| 258 | + %v1.ele = insertelement <4 x i64> poison, i64 %a0, i64 0 |
| 259 | + %v1 = shufflevector <4 x i64> %v1.ele, <4 x i64> poison, <4 x i32> zeroinitializer |
| 260 | + %v1.sub = sub <4 x i64> splat (i64 64), %v1 |
| 261 | + %b = lshr <4 x i64> %v0, %v1 |
| 262 | + %c = shl <4 x i64> %v0, %v1.sub |
| 263 | + %d = or <4 x i64> %b, %c |
| 264 | + store <4 x i64> %d, ptr %dst |
| 265 | + ret void |
| 266 | +} |
| 267 | + |
| 268 | +define void @rotr_v4i64_imm(ptr %dst, ptr %src) nounwind { |
| 269 | +; CHECK-LABEL: rotr_v4i64_imm: |
| 270 | +; CHECK: # %bb.0: |
| 271 | +; CHECK-NEXT: xvld $xr0, $a1, 0 |
| 272 | +; CHECK-NEXT: xvsrli.d $xr1, $xr0, 2 |
| 273 | +; CHECK-NEXT: xvslli.d $xr0, $xr0, 62 |
| 274 | +; CHECK-NEXT: xvor.v $xr0, $xr0, $xr1 |
| 275 | +; CHECK-NEXT: xvst $xr0, $a0, 0 |
| 276 | +; CHECK-NEXT: ret |
| 277 | + %v0 = load <4 x i64>, ptr %src |
| 278 | + %b = lshr <4 x i64> %v0, splat (i64 2) |
| 279 | + %c = shl <4 x i64> %v0, splat (i64 62) |
| 280 | + %d = or <4 x i64> %b, %c |
| 281 | + store <4 x i64> %d, ptr %dst |
| 282 | + ret void |
| 283 | +} |
0 commit comments