Skip to content

Commit 43c78c9

Browse files
jaladreipsigcbot
authored andcommitted
Minor improvements to SetDebugReg
Minor improvements to SetDebugReg
1 parent e02a966 commit 43c78c9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

IGC/common/IGCIRBuilder.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,20 @@ class IGCIRBuilder : public IGCLLVM::IRBuilder<T, InserterTy> {
175175

176176
if (V->getType()->isPointerTy()) {
177177
V = this->CreatePtrToInt(V, this->getInt64Ty());
178-
this->CreateCall(fn, this->CreateTrunc(V, this->getInt32Ty()), Name);
179-
this->CreateCall(fn, this->CreateTrunc(this->CreateLShr(V, 32), this->getInt32Ty()), Name);
178+
}
179+
180+
auto &DL = M->getDataLayout();
181+
uint64_t size = DL.getTypeAllocSize(V->getType());
182+
if (size == 4) {
183+
this->CreateCall(fn, this->CreateBitOrPointerCast(V, this->getInt32Ty()), Name);
180184
return;
181185
}
182186

183-
if (V->getType()->getPrimitiveSizeInBits() == 32) {
184-
this->CreateCall(fn, this->CreateBitCast(V, this->getInt32Ty()), Name);
187+
if (size % 4 == 0) {
188+
auto numElements = size / 4;
189+
V = this->CreateBitCast(V, VectorType::get(this->getInt32Ty(), static_cast<uint32_t>(numElements), false));
190+
for (uint32_t i = 0; i < numElements; i++)
191+
this->CreateCall(fn, this->CreateExtractElement(V, numElements - i - 1u), Name);
185192
return;
186193
}
187194

0 commit comments

Comments
 (0)