@@ -319,3 +319,83 @@ define i64 @zext_i16_to_i64(i16 %a) nounwind {
319
319
%1 = zext i16 %a to i64
320
320
ret i64 %1
321
321
}
322
+
323
+ define i32 @pack_lo_packh_hi_packh (i8 zeroext %0 , i8 zeroext %1 , i8 zeroext %2 , i8 zeroext %3 ) nounwind {
324
+ ; RV32I-LABEL: pack_lo_packh_hi_packh:
325
+ ; RV32I: # %bb.0:
326
+ ; RV32I-NEXT: slli a1, a1, 8
327
+ ; RV32I-NEXT: slli a2, a2, 16
328
+ ; RV32I-NEXT: slli a3, a3, 24
329
+ ; RV32I-NEXT: or a0, a0, a1
330
+ ; RV32I-NEXT: or a2, a2, a3
331
+ ; RV32I-NEXT: or a0, a0, a2
332
+ ; RV32I-NEXT: ret
333
+ ;
334
+ ; RV32ZBKB-LABEL: pack_lo_packh_hi_packh:
335
+ ; RV32ZBKB: # %bb.0:
336
+ ; RV32ZBKB-NEXT: packh a0, a0, a1
337
+ ; RV32ZBKB-NEXT: packh a1, a2, a3
338
+ ; RV32ZBKB-NEXT: pack a0, a0, a1
339
+ ; RV32ZBKB-NEXT: ret
340
+ %a = zext i8 %0 to i32
341
+ %b = zext i8 %1 to i32
342
+ %c = zext i8 %2 to i32
343
+ %d = zext i8 %3 to i32
344
+ %e = shl i32 %b , 8
345
+ %f = shl i32 %c , 16
346
+ %g = shl i32 %d , 24
347
+ %h = or i32 %a , %e
348
+ %i = or i32 %h , %f
349
+ %j = or i32 %i , %g
350
+ ret i32 %j
351
+ }
352
+
353
+ define i32 @pack_lo_zext_hi_packh (i16 zeroext %0 , i8 zeroext %1 , i8 zeroext %2 ) nounwind {
354
+ ; RV32I-LABEL: pack_lo_zext_hi_packh:
355
+ ; RV32I: # %bb.0:
356
+ ; RV32I-NEXT: slli a1, a2, 16
357
+ ; RV32I-NEXT: slli a2, a2, 24
358
+ ; RV32I-NEXT: or a1, a2, a1
359
+ ; RV32I-NEXT: or a0, a1, a0
360
+ ; RV32I-NEXT: ret
361
+ ;
362
+ ; RV32ZBKB-LABEL: pack_lo_zext_hi_packh:
363
+ ; RV32ZBKB: # %bb.0:
364
+ ; RV32ZBKB-NEXT: packh a1, a2, a2
365
+ ; RV32ZBKB-NEXT: pack a0, a0, a1
366
+ ; RV32ZBKB-NEXT: ret
367
+ %a = zext i16 %0 to i32
368
+ %b = zext i8 %1 to i32
369
+ %c = zext i8 %2 to i32
370
+ %d = shl i32 %c , 8
371
+ %e = or i32 %c , %d
372
+ %f = shl i32 %e , 16
373
+ %g = or i32 %f , %a
374
+ ret i32 %g
375
+ }
376
+
377
+ ; Negative test, %a isn't extended so we can't use pack for the outer or, but
378
+ ; we can use packh for the high half.
379
+ define i32 @pack_lo_noext_hi_packh (i32 %a , i8 zeroext %1 , i8 zeroext %2 ) nounwind {
380
+ ; RV32I-LABEL: pack_lo_noext_hi_packh:
381
+ ; RV32I: # %bb.0:
382
+ ; RV32I-NEXT: slli a1, a2, 16
383
+ ; RV32I-NEXT: slli a2, a2, 24
384
+ ; RV32I-NEXT: or a1, a2, a1
385
+ ; RV32I-NEXT: or a0, a1, a0
386
+ ; RV32I-NEXT: ret
387
+ ;
388
+ ; RV32ZBKB-LABEL: pack_lo_noext_hi_packh:
389
+ ; RV32ZBKB: # %bb.0:
390
+ ; RV32ZBKB-NEXT: packh a1, a2, a2
391
+ ; RV32ZBKB-NEXT: slli a1, a1, 16
392
+ ; RV32ZBKB-NEXT: or a0, a1, a0
393
+ ; RV32ZBKB-NEXT: ret
394
+ %b = zext i8 %1 to i32
395
+ %c = zext i8 %2 to i32
396
+ %d = shl i32 %c , 8
397
+ %e = or i32 %c , %d
398
+ %f = shl i32 %e , 16
399
+ %g = or i32 %f , %a
400
+ ret i32 %g
401
+ }
0 commit comments