Skip to content

Commit 08de650

Browse files
committed
[LV] Return debug loc directly from getDebugLocFromInstrOrOps (NFCI)
The return value of the function is only used to get the debug location. Directly return the debug location, as this avoids an extra null check in the caller.
1 parent e5fe3d2 commit 08de650

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -932,21 +932,21 @@ class EpilogueVectorizerEpilogueLoop : public InnerLoopAndEpilogueVectorizer {
932932

933933
/// Look for a meaningful debug location on the instruction or it's
934934
/// operands.
935-
static Instruction *getDebugLocFromInstOrOperands(Instruction *I) {
935+
static DebugLoc getDebugLocFromInstOrOperands(Instruction *I) {
936936
if (!I)
937-
return I;
937+
return DebugLoc();
938938

939939
DebugLoc Empty;
940940
if (I->getDebugLoc() != Empty)
941-
return I;
941+
return I->getDebugLoc();
942942

943943
for (Use &Op : I->operands()) {
944944
if (Instruction *OpInst = dyn_cast<Instruction>(Op))
945945
if (OpInst->getDebugLoc() != Empty)
946-
return OpInst;
946+
return OpInst->getDebugLoc();
947947
}
948948

949-
return I;
949+
return I->getDebugLoc();
950950
}
951951

952952
/// Write a \p DebugMsg about vectorization to the debug output stream. If \p I
@@ -8814,10 +8814,8 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
88148814
for (ElementCount VF : Range)
88158815
IVUpdateMayOverflow |= !isIndvarOverflowCheckKnownFalse(&CM, VF);
88168816

8817-
Instruction *DLInst =
8818-
getDebugLocFromInstOrOperands(Legal->getPrimaryInduction());
8819-
addCanonicalIVRecipes(*Plan, Legal->getWidestInductionType(),
8820-
DLInst ? DLInst->getDebugLoc() : DebugLoc(),
8817+
DebugLoc DL = getDebugLocFromInstOrOperands(Legal->getPrimaryInduction());
8818+
addCanonicalIVRecipes(*Plan, Legal->getWidestInductionType(), DL,
88218819
CM.getTailFoldingStyle(IVUpdateMayOverflow));
88228820

88238821
// Proactively create header mask. Masks for other blocks are created on

0 commit comments

Comments
 (0)