1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV64I
4 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbp -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s -check-prefix=RV64ZBP-ZBKB
6 ; RUN: llc -mtriple=riscv64 -mattr=+zbkb -verify-machineinstrs < %s \
7 ; RUN: | FileCheck %s -check-prefix=RV64ZBP-ZBKB
9 define signext i32 @pack_i32(i32 signext %a, i32 signext %b) nounwind {
10 ; RV64I-LABEL: pack_i32:
12 ; RV64I-NEXT: slli a0, a0, 48
13 ; RV64I-NEXT: srli a0, a0, 48
14 ; RV64I-NEXT: slliw a1, a1, 16
15 ; RV64I-NEXT: or a0, a1, a0
18 ; RV64ZBP-ZBKB-LABEL: pack_i32:
19 ; RV64ZBP-ZBKB: # %bb.0:
20 ; RV64ZBP-ZBKB-NEXT: packw a0, a0, a1
21 ; RV64ZBP-ZBKB-NEXT: ret
22 %shl = and i32 %a, 65535
23 %shl1 = shl i32 %b, 16
24 %or = or i32 %shl1, %shl
28 define i64 @pack_i64(i64 %a, i64 %b) nounwind {
29 ; RV64I-LABEL: pack_i64:
31 ; RV64I-NEXT: slli a0, a0, 32
32 ; RV64I-NEXT: srli a0, a0, 32
33 ; RV64I-NEXT: slli a1, a1, 32
34 ; RV64I-NEXT: or a0, a1, a0
37 ; RV64ZBP-ZBKB-LABEL: pack_i64:
38 ; RV64ZBP-ZBKB: # %bb.0:
39 ; RV64ZBP-ZBKB-NEXT: pack a0, a0, a1
40 ; RV64ZBP-ZBKB-NEXT: ret
41 %shl = and i64 %a, 4294967295
42 %shl1 = shl i64 %b, 32
43 %or = or i64 %shl1, %shl
47 define signext i32 @packh_i32(i32 signext %a, i32 signext %b) nounwind {
48 ; RV64I-LABEL: packh_i32:
50 ; RV64I-NEXT: andi a0, a0, 255
51 ; RV64I-NEXT: slli a1, a1, 56
52 ; RV64I-NEXT: srli a1, a1, 48
53 ; RV64I-NEXT: or a0, a1, a0
56 ; RV64ZBP-ZBKB-LABEL: packh_i32:
57 ; RV64ZBP-ZBKB: # %bb.0:
58 ; RV64ZBP-ZBKB-NEXT: packh a0, a0, a1
59 ; RV64ZBP-ZBKB-NEXT: ret
60 %and = and i32 %a, 255
62 %shl = and i32 %and1, 65280
63 %or = or i32 %shl, %and
67 define i32 @packh_i32_2(i32 %a, i32 %b) nounwind {
68 ; RV64I-LABEL: packh_i32_2:
70 ; RV64I-NEXT: andi a0, a0, 255
71 ; RV64I-NEXT: andi a1, a1, 255
72 ; RV64I-NEXT: slli a1, a1, 8
73 ; RV64I-NEXT: or a0, a1, a0
76 ; RV64ZBP-ZBKB-LABEL: packh_i32_2:
77 ; RV64ZBP-ZBKB: # %bb.0:
78 ; RV64ZBP-ZBKB-NEXT: packh a0, a0, a1
79 ; RV64ZBP-ZBKB-NEXT: ret
80 %and = and i32 %a, 255
81 %and1 = and i32 %b, 255
82 %shl = shl i32 %and1, 8
83 %or = or i32 %shl, %and
87 define i64 @packh_i64(i64 %a, i64 %b) nounwind {
88 ; RV64I-LABEL: packh_i64:
90 ; RV64I-NEXT: andi a0, a0, 255
91 ; RV64I-NEXT: slli a1, a1, 56
92 ; RV64I-NEXT: srli a1, a1, 48
93 ; RV64I-NEXT: or a0, a1, a0
96 ; RV64ZBP-ZBKB-LABEL: packh_i64:
97 ; RV64ZBP-ZBKB: # %bb.0:
98 ; RV64ZBP-ZBKB-NEXT: packh a0, a0, a1
99 ; RV64ZBP-ZBKB-NEXT: ret
100 %and = and i64 %a, 255
101 %and1 = shl i64 %b, 8
102 %shl = and i64 %and1, 65280
103 %or = or i64 %shl, %and
107 define i64 @packh_i64_2(i64 %a, i64 %b) nounwind {
108 ; RV64I-LABEL: packh_i64_2:
110 ; RV64I-NEXT: andi a0, a0, 255
111 ; RV64I-NEXT: andi a1, a1, 255
112 ; RV64I-NEXT: slli a1, a1, 8
113 ; RV64I-NEXT: or a0, a1, a0
116 ; RV64ZBP-ZBKB-LABEL: packh_i64_2:
117 ; RV64ZBP-ZBKB: # %bb.0:
118 ; RV64ZBP-ZBKB-NEXT: packh a0, a0, a1
119 ; RV64ZBP-ZBKB-NEXT: ret
120 %and = and i64 %a, 255
121 %and1 = and i64 %b, 255
122 %shl = shl i64 %and1, 8
123 %or = or i64 %shl, %and