diff --git a/llvm/tools/sycl-post-link/SPIRKernelParamOptInfo.cpp b/llvm/tools/sycl-post-link/SPIRKernelParamOptInfo.cpp index bb404c6211239..9532ee0e0f836 100644 --- a/llvm/tools/sycl-post-link/SPIRKernelParamOptInfo.cpp +++ b/llvm/tools/sycl-post-link/SPIRKernelParamOptInfo.cpp @@ -36,10 +36,10 @@ SPIRKernelParamOptInfoAnalysis::run(Module &M, ModuleAnalysisManager &AM) { assert(Ins.second && "duplicate kernel?"); BitVector &ParamDropped = Ins.first->second; - for (unsigned int I = 0; I < MD->getNumOperands(); ++I) { - const auto *MDInt1 = cast(MD->getOperand(I)); + for (const MDOperand &MDOp : MD->operands()) { + const auto *MDConst = cast(MDOp); unsigned ID = static_cast( - cast(MDInt1->getValue())->getValue().getZExtValue()); + cast(MDConst->getValue())->getValue().getZExtValue()); ParamDropped.push_back(ID != 0); } }