1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple riscv64 -mattr=+v -enable-subreg-liveness < %s | FileCheck %s
4 define <vscale x 2 x float> @vrgather_all_undef(ptr %p) {
5 ; CHECK-LABEL: vrgather_all_undef:
6 ; CHECK: # %bb.0: # %entry
7 ; CHECK-NEXT: vsetivli zero, 0, e32, m1, ta, ma
8 ; CHECK-NEXT: vrgather.vi v8, v9, 0
11 %0 = tail call <vscale x 2 x float> @llvm.riscv.vrgather.vx.nxv2f32.i64(<vscale x 2 x float> undef, <vscale x 2 x float> undef, i64 0, i64 0)
12 ret <vscale x 2 x float> %0
15 define dso_local signext i32 @undef_early_clobber_chain() {
16 ; CHECK-LABEL: undef_early_clobber_chain:
17 ; CHECK: # %bb.0: # %entry
18 ; CHECK-NEXT: addi sp, sp, -400
19 ; CHECK-NEXT: .cfi_def_cfa_offset 400
20 ; CHECK-NEXT: vsetivli zero, 0, e32, m1, ta, ma
21 ; CHECK-NEXT: vrgather.vi v9, v8, 0
22 ; CHECK-NEXT: mv a0, sp
23 ; CHECK-NEXT: vse32.v v9, (a0)
24 ; CHECK-NEXT: li a0, 0
25 ; CHECK-NEXT: addi sp, sp, 400
28 %dst = alloca [100 x float], align 8
29 call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %dst) #4
30 %0 = tail call <vscale x 2 x float> @llvm.riscv.vrgather.vx.nxv2f32.i64(<vscale x 2 x float> undef, <vscale x 2 x float> undef, i64 0, i64 0)
31 call void @llvm.riscv.vse.nxv2f32.i64(<vscale x 2 x float> %0, ptr nonnull %dst, i64 0)
32 call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %dst) #4
36 define internal void @SubRegLivenessUndefInPhi(i64 %cond) {
37 ; CHECK-LABEL: SubRegLivenessUndefInPhi:
38 ; CHECK: # %bb.0: # %start
39 ; CHECK-NEXT: blez a0, .LBB2_2
40 ; CHECK-NEXT: # %bb.1: # %Cond1
41 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
42 ; CHECK-NEXT: vid.v v8
43 ; CHECK-NEXT: vadd.vi v10, v8, 1
44 ; CHECK-NEXT: vadd.vi v12, v8, 3
45 ; CHECK-NEXT: j .LBB2_3
46 ; CHECK-NEXT: .LBB2_2: # %Cond2
47 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
48 ; CHECK-NEXT: vid.v v9
49 ; CHECK-NEXT: csrr a0, vlenb
50 ; CHECK-NEXT: srli a0, a0, 3
51 ; CHECK-NEXT: add a1, a0, a0
52 ; CHECK-NEXT: vsetvli zero, a1, e16, m1, ta, ma
53 ; CHECK-NEXT: vslideup.vx v8, v9, a0
54 ; CHECK-NEXT: vsetvli a2, zero, e16, mf4, ta, ma
55 ; CHECK-NEXT: vadd.vi v11, v9, 1
56 ; CHECK-NEXT: vsetvli zero, a1, e16, m1, ta, ma
57 ; CHECK-NEXT: vslideup.vx v10, v11, a0
58 ; CHECK-NEXT: vsetvli a2, zero, e16, mf4, ta, ma
59 ; CHECK-NEXT: vadd.vi v9, v9, 3
60 ; CHECK-NEXT: vsetvli zero, a1, e16, m1, ta, ma
61 ; CHECK-NEXT: vslideup.vx v12, v9, a0
62 ; CHECK-NEXT: .LBB2_3: # %UseSR
63 ; CHECK-NEXT: vl1r.v v14, (zero)
64 ; CHECK-NEXT: vsetivli zero, 4, e8, m1, ta, ma
65 ; CHECK-NEXT: vrgatherei16.vv v13, v14, v8
66 ; CHECK-NEXT: vrgatherei16.vv v8, v14, v10
67 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
68 ; CHECK-NEXT: vand.vv v8, v13, v8
69 ; CHECK-NEXT: vsetivli zero, 4, e8, m1, ta, ma
70 ; CHECK-NEXT: vrgatherei16.vv v9, v14, v12
71 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
72 ; CHECK-NEXT: vand.vv v8, v8, v9
73 ; CHECK-NEXT: vs1r.v v8, (zero)
76 %0 = icmp sgt i64 %cond, 0
77 br i1 %0, label %Cond1, label %Cond2
79 Cond1: ; preds = %start
80 %v15 = tail call <vscale x 1 x i16> @llvm.experimental.stepvector.nxv1i16()
81 %v17 = tail call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.nxv1i16(<vscale x 8 x i16> poison, <vscale x 1 x i16> %v15, i64 0)
82 %vs12.i.i.i = add <vscale x 1 x i16> %v15, splat (i16 1)
83 %v18 = tail call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.nxv1i16(<vscale x 8 x i16> poison, <vscale x 1 x i16> %vs12.i.i.i, i64 0)
84 %vs16.i.i.i = add <vscale x 1 x i16> %v15, splat (i16 3)
85 %v20 = tail call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.nxv1i16(<vscale x 8 x i16> poison, <vscale x 1 x i16> %vs16.i.i.i, i64 0)
88 Cond2: ; preds = %start
89 %v15.2 = tail call <vscale x 1 x i16> @llvm.experimental.stepvector.nxv1i16()
90 %v17.2 = tail call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.nxv1i16(<vscale x 8 x i16> poison, <vscale x 1 x i16> %v15.2, i64 1)
91 %vs12.i.i.i.2 = add <vscale x 1 x i16> %v15.2, splat (i16 1)
92 %v18.2 = tail call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.nxv1i16(<vscale x 8 x i16> poison, <vscale x 1 x i16> %vs12.i.i.i.2, i64 1)
93 %vs16.i.i.i.2 = add <vscale x 1 x i16> %v15.2, splat (i16 3)
94 %v20.2 = tail call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.nxv1i16(<vscale x 8 x i16> poison, <vscale x 1 x i16> %vs16.i.i.i.2, i64 1)
97 UseSR: ; preds = %Cond1, Cond2
98 %v17.3 = phi <vscale x 8 x i16> [ %v17, %Cond1 ], [ %v17.2, %Cond2 ]
99 %v18.3 = phi <vscale x 8 x i16> [ %v18, %Cond1 ], [ %v18.2, %Cond2 ]
100 %v20.3 = phi <vscale x 8 x i16> [ %v20, %Cond1 ], [ %v20.2, %Cond2 ]
101 %v37 = load <vscale x 8 x i8>, ptr addrspace(1) null, align 8
102 %v38 = tail call <vscale x 8 x i8> @llvm.riscv.vrgatherei16.vv.nxv8i8.i64(<vscale x 8 x i8> undef, <vscale x 8 x i8> %v37, <vscale x 8 x i16> %v17.3, i64 4)
103 %v40 = tail call <vscale x 8 x i8> @llvm.riscv.vrgatherei16.vv.nxv8i8.i64(<vscale x 8 x i8> undef, <vscale x 8 x i8> %v37, <vscale x 8 x i16> %v18.3, i64 4)
104 %v42 = and <vscale x 8 x i8> %v38, %v40
105 %v46 = tail call <vscale x 8 x i8> @llvm.riscv.vrgatherei16.vv.nxv8i8.i64(<vscale x 8 x i8> undef, <vscale x 8 x i8> %v37, <vscale x 8 x i16> %v20.3, i64 4)
106 %v60 = and <vscale x 8 x i8> %v42, %v46
107 store <vscale x 8 x i8> %v60, ptr addrspace(1) null, align 4
111 define internal void @SubRegLivenessUndef() {
112 ; CHECK-LABEL: SubRegLivenessUndef:
113 ; CHECK: # %bb.0: # %loopIR.preheader.i.i
114 ; CHECK-NEXT: vsetvli a0, zero, e16, mf4, ta, ma
115 ; CHECK-NEXT: vid.v v8
116 ; CHECK-NEXT: vadd.vi v10, v8, 1
117 ; CHECK-NEXT: vadd.vi v12, v8, 3
118 ; CHECK-NEXT: .LBB3_1: # %loopIR3.i.i
119 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
120 ; CHECK-NEXT: vl1r.v v14, (zero)
121 ; CHECK-NEXT: vsetivli zero, 4, e8, m1, ta, ma
122 ; CHECK-NEXT: vrgatherei16.vv v13, v14, v8
123 ; CHECK-NEXT: vrgatherei16.vv v9, v14, v10
124 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
125 ; CHECK-NEXT: vand.vv v9, v13, v9
126 ; CHECK-NEXT: vsetivli zero, 4, e8, m1, ta, ma
127 ; CHECK-NEXT: vrgatherei16.vv v11, v14, v12
128 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
129 ; CHECK-NEXT: vand.vv v9, v9, v11
130 ; CHECK-NEXT: vs1r.v v9, (zero)
131 ; CHECK-NEXT: j .LBB3_1
132 loopIR.preheader.i.i:
133 %v15 = tail call <vscale x 1 x i16> @llvm.experimental.stepvector.nxv1i16()
134 %v17 = tail call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.nxv1i16(<vscale x 8 x i16> poison, <vscale x 1 x i16> %v15, i64 0)
135 %vs12.i.i.i = add <vscale x 1 x i16> %v15, splat (i16 1)
136 %v18 = tail call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.nxv1i16(<vscale x 8 x i16> poison, <vscale x 1 x i16> %vs12.i.i.i, i64 0)
137 %vs16.i.i.i = add <vscale x 1 x i16> %v15, splat (i16 3)
138 %v20 = tail call <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.nxv1i16(<vscale x 8 x i16> poison, <vscale x 1 x i16> %vs16.i.i.i, i64 0)
139 br label %loopIR3.i.i
141 loopIR3.i.i: ; preds = %loopIR3.i.i, %loopIR.preheader.i.i
142 %v37 = load <vscale x 8 x i8>, ptr addrspace(1) null, align 8
143 %v38 = tail call <vscale x 8 x i8> @llvm.riscv.vrgatherei16.vv.nxv8i8.i64(<vscale x 8 x i8> undef, <vscale x 8 x i8> %v37, <vscale x 8 x i16> %v17, i64 4)
144 %v40 = tail call <vscale x 8 x i8> @llvm.riscv.vrgatherei16.vv.nxv8i8.i64(<vscale x 8 x i8> undef, <vscale x 8 x i8> %v37, <vscale x 8 x i16> %v18, i64 4)
145 %v42 = and <vscale x 8 x i8> %v38, %v40
146 %v46 = tail call <vscale x 8 x i8> @llvm.riscv.vrgatherei16.vv.nxv8i8.i64(<vscale x 8 x i8> undef, <vscale x 8 x i8> %v37, <vscale x 8 x i16> %v20, i64 4)
147 %v60 = and <vscale x 8 x i8> %v42, %v46
148 store <vscale x 8 x i8> %v60, ptr addrspace(1) null, align 4
149 br label %loopIR3.i.i
152 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
153 declare <vscale x 2 x float> @llvm.riscv.vrgather.vx.nxv2f32.i64(<vscale x 2 x float>, <vscale x 2 x float>, i64, i64) #2
154 declare void @llvm.riscv.vse.nxv2f32.i64(<vscale x 2 x float>, ptr nocapture, i64)
155 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
156 declare <vscale x 1 x i16> @llvm.experimental.stepvector.nxv1i16()
157 declare <vscale x 8 x i16> @llvm.vector.insert.nxv8i16.nxv1i16(<vscale x 8 x i16>, <vscale x 1 x i16>, i64 immarg)
158 declare <vscale x 8 x i8> @llvm.riscv.vrgatherei16.vv.nxv8i8.i64(<vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i16>, i64)
161 define void @repeat_shuffle(<2 x double> %v, ptr noalias %q) {
162 ; CHECK-LABEL: repeat_shuffle:
164 ; CHECK-NEXT: vmv2r.v v10, v8
165 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, ma
166 ; CHECK-NEXT: vslideup.vi v10, v8, 2
167 ; CHECK-NEXT: vse64.v v10, (a0)
169 %w = shufflevector <2 x double> %v, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
170 store <4 x double> %w, ptr %q