Skip to content

Commit a89aaf9

Browse files
committed
address Nick's feedback
1 parent 1eacea6 commit a89aaf9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

llvm/lib/SYCLLowerIR/SYCLJointMatrixTransform.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Type *replaceInnermostType(Type *Ty, Type *NewInnermostTy) {
3636
return NewInnermostTy;
3737
}
3838

39-
// This function is a copy of llvm::stripPointerCastsAndOffsets,
39+
// This function is a copy of stripPointerCastsAndOffsets from Value.cpp,
4040
// simplified and modified to strip non-zero GEP indices as well and also
4141
// find nearest GEP instruction.
4242
Value *stripPointerCastsAndOffsets(Value *V, bool StopOnGEP = false) {
@@ -53,17 +53,19 @@ Value *stripPointerCastsAndOffsets(Value *V, bool StopOnGEP = false) {
5353
if (StopOnGEP && isa<GetElementPtrInst>(GEP))
5454
return V;
5555
V = GEP->getPointerOperand();
56-
} else if (Operator::getOpcode(V) == Instruction::BitCast) {
57-
Value *NewV = cast<Operator>(V)->getOperand(0);
56+
} else if (auto *BC = dyn_cast<BitCastOperator>(V)) {
57+
Value *NewV = BC->getOperand(0);
5858
if (!NewV->getType()->isPointerTy())
5959
return V;
6060
V = NewV;
61-
} else if (Operator::getOpcode(V) == Instruction::AddrSpaceCast) {
62-
V = cast<Operator>(V)->getOperand(0);
61+
} else if (auto *ASC = dyn_cast<AddrSpaceCastOperator>(V)) {
62+
V = ASC->getOperand(0);
6363
} else {
6464
if (auto *Call = dyn_cast<CallBase>(V)) {
6565
if (Value *RV = Call->getReturnedArgOperand()) {
6666
V = RV;
67+
// Strip the call instruction, since callee returns its RV
68+
// argument as return value. So, we need to continue stripping.
6769
continue;
6870
}
6971
}
@@ -83,8 +85,7 @@ TargetExtType *extractMatrixType(StructType *WrapperMatrixTy) {
8385

8486
if (!MatrixTy)
8587
return nullptr;
86-
StringRef Name = MatrixTy->getName();
87-
if (Name != MATRIX_TYPE)
88+
if (MatrixTy->getName() != MATRIX_TYPE)
8889
return nullptr;
8990
return MatrixTy;
9091
}
@@ -161,7 +162,7 @@ bool transformAccessChain(Function *F) {
161162
// __spirv_AccessChain
162163
// First we check if the argument came from a GEP instruction
163164
GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(
164-
stripPointerCastsAndOffsets(CI->getArgOperand(0), true));
165+
stripPointerCastsAndOffsets(CI->getArgOperand(0), /*StopOnGEP=*/true));
165166
if (!GEP)
166167
continue;
167168

@@ -181,7 +182,6 @@ bool transformAccessChain(Function *F) {
181182
ModuleChanged = true;
182183
}
183184
}
184-
185185
return ModuleChanged;
186186
}
187187
} // namespace

0 commit comments

Comments
 (0)