Skip to content

Commit 548fc2d

Browse files
authored
[NFC] Fix misuse of dyn_cast (#1959)
Signed-off-by: Lu, John <[email protected]>
1 parent 0ed2286 commit 548fc2d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/SPIRV/SPIRVReader.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,8 +2183,8 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
21832183
GEP->setIsInBounds(IsInbound);
21842184
V = GEP;
21852185
} else {
2186-
V = ConstantExpr::getGetElementPtr(BaseTy, dyn_cast<Constant>(Base),
2187-
Index, IsInbound);
2186+
auto *CT = cast<Constant>(Base);
2187+
V = ConstantExpr::getGetElementPtr(BaseTy, CT, Index, IsInbound);
21882188
}
21892189
return mapValue(BV, V);
21902190
}
@@ -2199,14 +2199,14 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
21992199
switch (static_cast<size_t>(BV->getType()->getOpCode())) {
22002200
case OpTypeVector:
22012201
return mapValue(BV, ConstantVector::get(CV));
2202-
case OpTypeArray:
2203-
return mapValue(
2204-
BV, ConstantArray::get(dyn_cast<ArrayType>(transType(CC->getType())),
2205-
CV));
2206-
case OpTypeStruct:
2207-
return mapValue(BV,
2208-
ConstantStruct::get(
2209-
dyn_cast<StructType>(transType(CC->getType())), CV));
2202+
case OpTypeArray: {
2203+
auto *AT = cast<ArrayType>(transType(CC->getType()));
2204+
return mapValue(BV, ConstantArray::get(AT, CV));
2205+
}
2206+
case OpTypeStruct: {
2207+
auto *ST = cast<StructType>(transType(CC->getType()));
2208+
return mapValue(BV, ConstantStruct::get(ST, CV));
2209+
}
22102210
case internal::OpTypeJointMatrixINTEL:
22112211
return mapValue(BV, transSPIRVBuiltinFromInst(CC, BB));
22122212
default:

0 commit comments

Comments
 (0)