@@ -226,7 +226,7 @@ bool llvm::addStringMetadataToLoop(Loop *TheLoop, const char *StringMD,
226226 if (NumOps == 1 || NumOps == 2 ) {
227227 MDString *S = dyn_cast<MDString>(Node->getOperand (0 ));
228228 if (S && S->getString () == StringMD) {
229- // If it is already in place , do nothing.
229+ // If the metadata and any value are already as specified , do nothing.
230230 if (NumOps == 2 && V) {
231231 ConstantInt *IntMD =
232232 mdconst::extract_or_null<ConstantInt>(Node->getOperand (1 ));
@@ -879,7 +879,7 @@ std::optional<unsigned> llvm::getLoopEstimatedTripCount(
879879 // EstimatedLoopInvocationWeight parameter.
880880 if (EstimatedLoopInvocationWeight) {
881881 if (BranchInst *ExitingBranch = getExpectedExitLoopLatchBranch (L)) {
882- uint64_t LoopWeight, ExitWeight;
882+ uint64_t LoopWeight = 0 , ExitWeight = 0 ; // Inits expected to be unused.
883883 if (!extractBranchWeights (*ExitingBranch, LoopWeight, ExitWeight))
884884 return std::nullopt ;
885885 if (L->contains (ExitingBranch->getSuccessor (1 )))
@@ -951,7 +951,7 @@ bool llvm::setLoopEstimatedTripCount(
951951 unsigned LatchExitWeight = 0 ;
952952 unsigned BackedgeTakenWeight = 0 ;
953953
954- if (*EstimatedTripCount > 0 ) {
954+ if (*EstimatedTripCount != 0 ) {
955955 LatchExitWeight = *EstimatedloopInvocationWeight;
956956 BackedgeTakenWeight = (*EstimatedTripCount - 1 ) * LatchExitWeight;
957957 }
0 commit comments