@@ -166,26 +166,86 @@ bool PushAnalysis::IsStatelessCBLoad(
166
166
pAddress = cast<Instruction>(pAddress)->getOperand (0 );
167
167
}
168
168
169
- offset = 0 ;
170
- // % 13 = add i64 % 12, 16
171
- // This add might or might not be present necessarily.
172
- if (BinaryOperator* pAdd = dyn_cast<BinaryOperator>(pAddress))
169
+ if (GenIntrinsicInst* genIntr = dyn_cast<GenIntrinsicInst>(pAddress))
173
170
{
174
- if (pAdd->getOpcode () == llvm::Instruction::Add)
171
+ /*
172
+ find 64 bit case
173
+ %33 = call { i32, i32 } @llvm.genx.GenISA.ptr.to.pair.p2v4f32(<4 x float> addrspace(2)* %runtime_value_4)
174
+ %34 = extractvalue { i32, i32 } %33, 0
175
+ %35 = extractvalue { i32, i32 } %33, 1
176
+ %36 = call { i32, i32 } @llvm.genx.GenISA.add.pair(i32 %34, i32 %35, i32 368, i32 0)
177
+ %37 = extractvalue { i32, i32 } %36, 0
178
+ %38 = extractvalue { i32, i32 } %36, 1
179
+ %39 = call <2 x i32> addrspace(2)* @llvm.genx.GenISA.pair.to.ptr.p2v2i32(i32 %37, i32 %38)
180
+ */
181
+ if (genIntr->getIntrinsicID () == GenISAIntrinsic::GenISA_pair_to_ptr)
175
182
{
176
- ConstantInt* pConst = dyn_cast<llvm::ConstantInt>(pAdd->getOperand (1 ));
177
- if (!pConst)
178
- return false ;
179
-
180
- pAddress = pAdd->getOperand (0 );
181
- offset = (uint)pConst->getZExtValue ();
183
+ ExtractValueInst *Lo = dyn_cast<ExtractValueInst>(genIntr->getOperand (0 ));
184
+ ExtractValueInst *Hi = dyn_cast<ExtractValueInst>(genIntr->getOperand (1 ));
185
+ if (Lo && Hi && Lo->getOperand (0 ) == Hi->getOperand (0 ))
186
+ {
187
+ if (GenIntrinsicInst* AddPair = dyn_cast<GenIntrinsicInst>(Lo->getOperand (0 )))
188
+ {
189
+ if (AddPair->getIntrinsicID () == GenISAIntrinsic::GenISA_add_pair)
190
+ {
191
+ ExtractValueInst *Lo2 = dyn_cast<ExtractValueInst>(AddPair->getOperand (0 ));
192
+ ExtractValueInst *Hi2 = dyn_cast<ExtractValueInst>(AddPair->getOperand (1 ));
193
+ if (Lo2 && Hi2 && Lo2->getOperand (0 ) == Hi2->getOperand (0 ))
194
+ {
195
+ if (GenIntrinsicInst* ptrToPair = dyn_cast<GenIntrinsicInst>(Lo2->getOperand (0 )))
196
+ {
197
+ if (ptrToPair->getIntrinsicID () == GenISAIntrinsic::GenISA_ptr_to_pair)
198
+ {
199
+ ConstantInt* pConst = dyn_cast<llvm::ConstantInt>(AddPair->getOperand (2 ));
200
+ if (!pConst)
201
+ return false ;
202
+ offset = (uint)pConst->getZExtValue ();
203
+ pAddress = ptrToPair->getOperand (0 );
204
+ }
205
+ }
206
+ }
207
+ }
208
+ }
209
+ }
182
210
}
183
211
}
212
+ else
213
+ {
214
+ /*
215
+ find 32 bit case
216
+ % 33 = ptrtoint <4 x float> addrspace(2)* %runtime_value_4 to i64
217
+ % 34 = add i64 % 33, 368
218
+ % chunkPtr = inttoptr i64 % 34 to <2 x i32> addrspace(2)*
219
+ */
220
+
221
+ offset = 0 ;
222
+ // % 13 = add i64 % 12, 16
223
+ // This add might or might not be present necessarily.
224
+ if (BinaryOperator* pAdd = dyn_cast<BinaryOperator>(pAddress))
225
+ {
226
+ if (pAdd->getOpcode () == llvm::Instruction::Add)
227
+ {
228
+ ConstantInt* pConst = dyn_cast<llvm::ConstantInt>(pAdd->getOperand (1 ));
229
+ if (!pConst)
230
+ return false ;
231
+
232
+ pAddress = pAdd->getOperand (0 );
233
+ offset = (uint)pConst->getZExtValue ();
234
+ }
235
+ }
184
236
237
+ }
185
238
// skip casts
186
- if (isa<IntToPtrInst>(pAddress) || isa<PtrToIntInst>(pAddress) || isa<BitCastInst>(pAddress) )
239
+ while ( 1 )
187
240
{
188
- pAddress = cast<Instruction>(pAddress)->getOperand (0 );
241
+ if (isa<IntToPtrInst>(pAddress) || isa<PtrToIntInst>(pAddress) || isa<BitCastInst>(pAddress))
242
+ {
243
+ pAddress = cast<Instruction>(pAddress)->getOperand (0 );
244
+ }
245
+ else
246
+ {
247
+ break ;
248
+ }
189
249
}
190
250
191
251
llvm::GenIntrinsicInst *pRuntimeVal = llvm::dyn_cast<llvm::GenIntrinsicInst>(pAddress);
0 commit comments