@@ -30,8 +30,9 @@ target triple = "spir64-unknown-unknown"
3030; CHECK-LABEL: define spir_kernel void @test(
3131; CHECK-SAME: i64 [[OFFSET:%.*]], i8 addrspace(1)* [[PTR:%.*]], i8* [[PTR1:%.*]]) {
3232define spir_kernel void @test (i64 %offset , i8 addrspace (1 )* %ptr , i8* %ptr1 ) {
33+ entry:
3334
34- ; CHECK-NEXT: [[TC_I1:%.*]] = alloca [4 x [4 x %"struct::joint_matrix::C.resolved"]], align 8
35+ ; CHECK: [[TC_I1:%.*]] = alloca [4 x [4 x %"struct::joint_matrix::C.resolved"]], align 8
3536; CHECK-NEXT: [[TA_I3:%.*]] = alloca [4 x [2 x %"struct::joint_matrix::A.resolved"]], align 8
3637; CHECK-NEXT: [[TB_I5:%.*]] = alloca [4 x [2 x %"struct::joint_matrix::B.resolved"]], align 8
3738; CHECK-NEXT: [[TI_I:%.*]] = alloca [4 x [4 x %"struct::almost_joint_matrix"]], align 8
@@ -49,74 +50,89 @@ define spir_kernel void @test(i64 %offset, i8 addrspace(1)* %ptr, i8* %ptr1) {
4950; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 128, i8* [[TMP2]])
5051; CHECK-NEXT: [[TMP3:%.*]] = bitcast [4 x [2 x %"struct::joint_matrix::B.resolved"]]* [[TB_I5]] to i8*
5152; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 256, i8* [[TMP3]])
52- %1 = bitcast [4 x [4 x %"struct::joint_matrix::C" ]]* %tC.i to i8*
53- call void @llvm.lifetime.start.p0i8 (i64 128 , i8* %1 )
54- %2 = bitcast [4 x [2 x %"struct::joint_matrix::A" ]]* %tA.i to i8*
55- call void @llvm.lifetime.start.p0i8 (i64 64 , i8* %2 )
56- %3 = bitcast [4 x [2 x %"struct::joint_matrix::B" ]]* %tB.i to i8*
57- call void @llvm.lifetime.start.p0i8 (i64 64 , i8* %3 )
58-
59- ; Update GEP offsets
53+ %b1 = bitcast [4 x [4 x %"struct::joint_matrix::C" ]]* %tC.i to i8*
54+ call void @llvm.lifetime.start.p0i8 (i64 128 , i8* %b1 )
55+ %b2 = bitcast [4 x [2 x %"struct::joint_matrix::A" ]]* %tA.i to i8*
56+ call void @llvm.lifetime.start.p0i8 (i64 64 , i8* %b2 )
57+ %b3 = bitcast [4 x [2 x %"struct::joint_matrix::B" ]]* %tB.i to i8*
58+ call void @llvm.lifetime.start.p0i8 (i64 64 , i8* %b3 )
59+
60+ ; Update GEP offsets coming from alloca directly
6061; CHECK-NEXT: [[TMP4:%.*]] = bitcast [4 x [4 x %"struct::joint_matrix::C.resolved"]]* [[TC_I1]] to i8*
6162; CHECK-NEXT: [[I1:%.*]] = getelementptr inbounds i8, i8* [[TMP4]], i64 512
6263; CHECK-NEXT: [[TMP5:%.*]] = bitcast [4 x [2 x %"struct::joint_matrix::A.resolved"]]* [[TA_I3]] to i8*
6364; CHECK-NEXT: [[I2:%.*]] = getelementptr inbounds i8, i8* [[TMP5]], i64 128
6465; CHECK-NEXT: [[TMP6:%.*]] = bitcast [4 x [2 x %"struct::joint_matrix::B.resolved"]]* [[TB_I5]] to i8*
6566; CHECK-NEXT: [[I3:%.*]] = getelementptr inbounds i8, i8* [[TMP6]], i64 256
66- %4 = bitcast [4 x [4 x %"struct::joint_matrix::C" ]]* %tC.i to i8*
67- %i1 = getelementptr inbounds i8 , i8* %4 , i64 128
68- %5 = bitcast [4 x [2 x %"struct::joint_matrix::A" ]]* %tA.i to i8*
69- %i2 = getelementptr inbounds i8 , i8* %5 , i64 64
70- %6 = bitcast [4 x [2 x %"struct::joint_matrix::B" ]]* %tB.i to i8*
71- %i3 = getelementptr inbounds i8 , i8* %6 , i64 64
67+ %b4 = bitcast [4 x [4 x %"struct::joint_matrix::C" ]]* %tC.i to i8*
68+ %i1 = getelementptr inbounds i8 , i8* %b4 , i64 128
69+ %b5 = bitcast [4 x [2 x %"struct::joint_matrix::A" ]]* %tA.i to i8*
70+ %i2 = getelementptr inbounds i8 , i8* %b5 , i64 64
71+ %b6 = bitcast [4 x [2 x %"struct::joint_matrix::B" ]]* %tB.i to i8*
72+ %i3 = getelementptr inbounds i8 , i8* %b6 , i64 64
7273
7374; Do not touch if offest is not a constant
7475; CHECK-NEXT: [[TMP7:%.*]] = bitcast [4 x [4 x %"struct::joint_matrix::C.resolved"]]* [[TC_I1]] to i8*
7576; CHECK-NEXT: [[I4:%.*]] = getelementptr inbounds i8, i8* [[TMP7]], i64 [[OFFSET]]
76- %7 = bitcast [4 x [4 x %"struct::joint_matrix::C" ]]* %tC.i to i8*
77- %i4 = getelementptr inbounds i8 , i8* %7 , i64 %offset
77+ %b7 = bitcast [4 x [4 x %"struct::joint_matrix::C" ]]* %tC.i to i8*
78+ %i4 = getelementptr inbounds i8 , i8* %b7 , i64 %offset
7879
79- ; no change: GEP operand is not a result of bitcast
80+ ; no change: GEP operand is comming from kernel argument - not from matrix type
8081; CHECK-NEXT: [[I5:%.*]] = getelementptr inbounds i8, i8* [[PTR1]], i64 128
8182 %i5 = getelementptr inbounds i8 , i8* %ptr1 , i64 128
8283
83- ; Do not touch if bitcast is not for matrix type
84+ ; no change: GEP comes from bitcast that doesn't come from matrix type
8485; CHECK-NEXT: [[TMP8:%.*]] = bitcast [4 x [4 x %"struct::almost_joint_matrix"]]* [[TI_I]] to i8*
8586; CHECK-NEXT: [[I6:%.*]] = getelementptr inbounds i8, i8* [[TMP8]], i64 128
86- %8 = bitcast [4 x [4 x %"struct::almost_joint_matrix" ]]* %tI.i to i8*
87- %i6 = getelementptr inbounds i8 , i8* %8 , i64 128
87+ %b8 = bitcast [4 x [4 x %"struct::almost_joint_matrix" ]]* %tI.i to i8*
88+ %i6 = getelementptr inbounds i8 , i8* %b8 , i64 128
8889
8990; no change - GEP is not based on i8
9091; CHECK-NEXT: [[TMP9:%.*]] = bitcast [4 x [4 x %"struct::joint_matrix::C.resolved"]]* [[TC_I1]] to i16*
9192; CHECK-NEXT: [[ARRAYCTOR_END_I:%.*]] = getelementptr inbounds i16, i16* [[TMP9]], i64 128
92- %9 = bitcast [4 x [4 x %"struct::joint_matrix::C" ]]* %tC.i to i16*
93- %arrayctor.end.i = getelementptr inbounds i16 , i16* %9 , i64 128
93+ %b9 = bitcast [4 x [4 x %"struct::joint_matrix::C" ]]* %tC.i to i16*
94+ %arrayctor.end.i = getelementptr inbounds i16 , i16* %b9 , i64 128
95+ br label %loop_header
9496
97+ ; Test going through phi value + check that we aren't doing ininite recursion
98+ loop_header:
99+ %loop_cond = phi i1 [1 , %entry ], [0 , %loop_header ]
100+ %loop_matrix = phi [4 x [4 x %"struct::joint_matrix::C" ]]* [%tC.i , %entry ], [%loop_matrix , %loop_header ]
101+
102+ ; Update GEP offsets coming from phi value
103+ ; CHECK: [[TMP10:%.*]] = bitcast [4 x [4 x %"struct::joint_matrix::C.resolved"]]* {{.*}} to i8*
104+ ; CHECK-NEXT: {{.*}} = getelementptr inbounds i8, i8* [[TMP10]], i64 128
105+ %b10 = bitcast [4 x [4 x %"struct::joint_matrix::C" ]]* %tC.i to i8*
106+ %i7 = getelementptr inbounds i8 , i8* %b10 , i64 32
107+
108+ br i1 %loop_cond , label %loop_header , label %after_loop
109+
110+ after_loop:
95111; Life time end size update
96- ; CHECK-NEXT : [[TMP10 :%.*]] = bitcast [4 x [2 x %"struct::joint_matrix::B.resolved"]]* [[TB_I5]] to i8*
97- ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 256, i8* [[TMP10 ]])
98- ; CHECK-NEXT: [[TMP11 :%.*]] = bitcast [4 x [2 x %"struct::joint_matrix::A.resolved"]]* [[TA_I3]] to i8*
99- ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 128, i8* [[TMP11 ]])
100- ; CHECK-NEXT: [[TMP12 :%.*]] = bitcast [4 x [4 x %"struct::joint_matrix::C.resolved"]]* [[TC_I1]] to i8*
101- ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 512, i8* [[TMP12 ]])
102- %10 = bitcast [4 x [2 x %"struct::joint_matrix::B" ]]* %tB.i to i8*
103- call void @llvm.lifetime.end.p0i8 (i64 64 , i8* %10 )
104- %11 = bitcast [4 x [2 x %"struct::joint_matrix::A" ]]* %tA.i to i8*
105- call void @llvm.lifetime.end.p0i8 (i64 64 , i8* %11 )
106- %12 = bitcast [4 x [4 x %"struct::joint_matrix::C" ]]* %tC.i to i8*
107- call void @llvm.lifetime.end.p0i8 (i64 128 , i8* %12 )
112+ ; CHECK: [[TMP11 :%.*]] = bitcast [4 x [2 x %"struct::joint_matrix::B.resolved"]]* [[TB_I5]] to i8*
113+ ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 256, i8* [[TMP11 ]])
114+ ; CHECK-NEXT: [[TMP12 :%.*]] = bitcast [4 x [2 x %"struct::joint_matrix::A.resolved"]]* [[TA_I3]] to i8*
115+ ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 128, i8* [[TMP12 ]])
116+ ; CHECK-NEXT: [[TMP13 :%.*]] = bitcast [4 x [4 x %"struct::joint_matrix::C.resolved"]]* [[TC_I1]] to i8*
117+ ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 512, i8* [[TMP13 ]])
118+ %b11 = bitcast [4 x [2 x %"struct::joint_matrix::B" ]]* %tB.i to i8*
119+ call void @llvm.lifetime.end.p0i8 (i64 64 , i8* %b11 )
120+ %b12 = bitcast [4 x [2 x %"struct::joint_matrix::A" ]]* %tA.i to i8*
121+ call void @llvm.lifetime.end.p0i8 (i64 64 , i8* %b12 )
122+ %b13 = bitcast [4 x [4 x %"struct::joint_matrix::C" ]]* %tC.i to i8*
123+ call void @llvm.lifetime.end.p0i8 (i64 128 , i8* %b13 )
108124
109125; do not touch life time intrinsics if not for Joint Matrix types
110126; CHECK-NEXT: [[GROUPID_ASCAST:%.*]] = addrspacecast [3 x i64]* [[GROUPID]] to [3 x i64] addrspace(4)*
111- ; CHECK-NEXT: [[TMP13:%.*]] = bitcast [3 x i64]* [[GROUPID]] to i8*
112- ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 24, i8* [[TMP13]])
113127; CHECK-NEXT: [[TMP14:%.*]] = bitcast [3 x i64]* [[GROUPID]] to i8*
114- ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 24, i8* [[TMP14]])
128+ ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 24, i8* [[TMP14]])
129+ ; CHECK-NEXT: [[TMP15:%.*]] = bitcast [3 x i64]* [[GROUPID]] to i8*
130+ ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 24, i8* [[TMP15]])
115131 %GroupID.ascast = addrspacecast [3 x i64 ]* %GroupID to [3 x i64 ] addrspace (4 )*
116- %13 = bitcast [3 x i64 ]* %GroupID to i8*
117- call void @llvm.lifetime.start.p0i8 (i64 24 , i8* %13 )
118- %14 = bitcast [3 x i64 ]* %GroupID to i8*
119- call void @llvm.lifetime.end.p0i8 (i64 24 , i8* %14 )
132+ %b14 = bitcast [3 x i64 ]* %GroupID to i8*
133+ call void @llvm.lifetime.start.p0i8 (i64 24 , i8* %b14 )
134+ %b15 = bitcast [3 x i64 ]* %GroupID to i8*
135+ call void @llvm.lifetime.end.p0i8 (i64 24 , i8* %b15 )
120136
121137; CHECK-NEXT: ret void
122138 ret void
0 commit comments