@@ -47,7 +47,7 @@ cl::opt<bool>
4747 HintsAllowReordering (" hints-allow-reordering" , cl::init(true ), cl::Hidden,
4848 cl::desc (" Allow enabling loop hints to reorder "
4949 " FP operations during vectorization." ));
50- }
50+ } // namespace llvm
5151
5252// TODO: Move size-based thresholds out of legality checking, make cost based
5353// decisions instead of hard thresholds.
@@ -216,20 +216,19 @@ void LoopVectorizeHints::emitRemarkWithHints() const {
216216 TheLoop->getStartLoc (),
217217 TheLoop->getHeader ())
218218 << " loop not vectorized: vectorization is explicitly disabled" ;
219- else {
220- OptimizationRemarkMissed R (LV_NAME, " MissedDetails" ,
221- TheLoop->getStartLoc (), TheLoop->getHeader ());
222- R << " loop not vectorized" ;
223- if (Force.Value == LoopVectorizeHints::FK_Enabled) {
224- R << " (Force=" << NV (" Force" , true );
225- if (Width.Value != 0 )
226- R << " , Vector Width=" << NV (" VectorWidth" , getWidth ());
227- if (getInterleave () != 0 )
228- R << " , Interleave Count=" << NV (" InterleaveCount" , getInterleave ());
229- R << " )" ;
230- }
231- return R;
219+
220+ OptimizationRemarkMissed R (LV_NAME, " MissedDetails" , TheLoop->getStartLoc (),
221+ TheLoop->getHeader ());
222+ R << " loop not vectorized" ;
223+ if (Force.Value == LoopVectorizeHints::FK_Enabled) {
224+ R << " (Force=" << NV (" Force" , true );
225+ if (Width.Value != 0 )
226+ R << " , Vector Width=" << NV (" VectorWidth" , getWidth ());
227+ if (getInterleave () != 0 )
228+ R << " , Interleave Count=" << NV (" InterleaveCount" , getInterleave ());
229+ R << " )" ;
232230 }
231+ return R;
233232 });
234233}
235234
@@ -271,8 +270,8 @@ void LoopVectorizeHints::getHintsFromMetadata() {
271270 if (!MD || MD->getNumOperands () == 0 )
272271 continue ;
273272 S = dyn_cast<MDString>(MD->getOperand (0 ));
274- for (unsigned i = 1 , ie = MD->getNumOperands (); i < ie; ++i )
275- Args.push_back (MD->getOperand (i ));
273+ for (unsigned Idx = 1 ; Idx < MD->getNumOperands (); ++Idx )
274+ Args.push_back (MD->getOperand (Idx ));
276275 } else {
277276 S = dyn_cast<MDString>(MDO);
278277 assert (Args.size () == 0 && " too many arguments for MDString" );
@@ -444,10 +443,7 @@ static bool storeToSameAddress(ScalarEvolution *SE, StoreInst *A,
444443 return true ;
445444
446445 // Otherwise compare address SCEVs
447- if (SE->getSCEV (APtr) == SE->getSCEV (BPtr))
448- return true ;
449-
450- return false ;
446+ return SE->getSCEV (APtr) == SE->getSCEV (BPtr);
451447}
452448
453449int LoopVectorizationLegality::isConsecutivePtr (Type *AccessTy,
@@ -734,26 +730,21 @@ bool LoopVectorizationLegality::setupOuterLoopInductions() {
734730 BasicBlock *Header = TheLoop->getHeader ();
735731
736732 // Returns true if a given Phi is a supported induction.
737- auto isSupportedPhi = [&](PHINode &Phi) -> bool {
733+ auto IsSupportedPhi = [&](PHINode &Phi) -> bool {
738734 InductionDescriptor ID;
739735 if (InductionDescriptor::isInductionPHI (&Phi, TheLoop, PSE, ID) &&
740736 ID.getKind () == InductionDescriptor::IK_IntInduction) {
741737 addInductionPhi (&Phi, ID, AllowedExit);
742738 return true ;
743- } else {
744- // Bail out for any Phi in the outer loop header that is not a supported
745- // induction.
746- LLVM_DEBUG (
747- dbgs ()
748- << " LV: Found unsupported PHI for outer loop vectorization.\n " );
749- return false ;
750739 }
740+ // Bail out for any Phi in the outer loop header that is not a supported
741+ // induction.
742+ LLVM_DEBUG (
743+ dbgs () << " LV: Found unsupported PHI for outer loop vectorization.\n " );
744+ return false ;
751745 };
752746
753- if (llvm::all_of (Header->phis (), isSupportedPhi))
754- return true ;
755- else
756- return false ;
747+ return llvm::all_of (Header->phis (), IsSupportedPhi);
757748}
758749
759750// / Checks if a function is scalarizable according to the TLI, in
@@ -837,13 +828,13 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
837828 // historical vectorizer behavior after a generalization of the
838829 // IVDescriptor code. The intent is to remove this check, but we
839830 // have to fix issues around code quality for such loops first.
840- auto isDisallowedStridedPointerInduction =
841- [](const InductionDescriptor &ID) {
842- if (AllowStridedPointerIVs)
843- return false ;
844- return ID.getKind () == InductionDescriptor::IK_PtrInduction &&
845- ID.getConstIntStepValue () == nullptr ;
846- };
831+ auto IsDisallowedStridedPointerInduction =
832+ [](const InductionDescriptor &ID) {
833+ if (AllowStridedPointerIVs)
834+ return false ;
835+ return ID.getKind () == InductionDescriptor::IK_PtrInduction &&
836+ ID.getConstIntStepValue () == nullptr ;
837+ };
847838
848839 // TODO: Instead of recording the AllowedExit, it would be good to
849840 // record the complementary set: NotAllowedExit. These include (but may
@@ -861,7 +852,7 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
861852 // of these NotAllowedExit.
862853 InductionDescriptor ID;
863854 if (InductionDescriptor::isInductionPHI (Phi, TheLoop, PSE, ID) &&
864- !isDisallowedStridedPointerInduction (ID)) {
855+ !IsDisallowedStridedPointerInduction (ID)) {
865856 addInductionPhi (Phi, ID, AllowedExit);
866857 Requirements->addExactFPMathInst (ID.getExactFPMathInst ());
867858 continue ;
@@ -876,7 +867,7 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
876867 // As a last resort, coerce the PHI to a AddRec expression
877868 // and re-try classifying it a an induction PHI.
878869 if (InductionDescriptor::isInductionPHI (Phi, TheLoop, PSE, ID, true ) &&
879- !isDisallowedStridedPointerInduction (ID)) {
870+ !IsDisallowedStridedPointerInduction (ID)) {
880871 addInductionPhi (Phi, ID, AllowedExit);
881872 continue ;
882873 }
@@ -932,9 +923,10 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
932923 if (CI) {
933924 auto *SE = PSE.getSE ();
934925 Intrinsic::ID IntrinID = getVectorIntrinsicIDForCall (CI, TLI);
935- for (unsigned i = 0 , e = CI->arg_size (); i != e; ++i)
936- if (isVectorIntrinsicWithScalarOpAtArg (IntrinID, i)) {
937- if (!SE->isLoopInvariant (PSE.getSCEV (CI->getOperand (i)), TheLoop)) {
926+ for (unsigned Idx = 0 ; Idx < CI->arg_size (); ++Idx)
927+ if (isVectorIntrinsicWithScalarOpAtArg (IntrinID, Idx)) {
928+ if (!SE->isLoopInvariant (PSE.getSCEV (CI->getOperand (Idx)),
929+ TheLoop)) {
938930 reportVectorizationFailure (" Found unvectorizable intrinsic" ,
939931 " intrinsic instruction cannot be vectorized" ,
940932 " CantVectorizeIntrinsic" , ORE, TheLoop, CI);
@@ -1035,14 +1027,14 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
10351027 " loop induction variable could not be identified" ,
10361028 " NoInductionVariable" , ORE, TheLoop);
10371029 return false ;
1038- } else if (!WidestIndTy) {
1030+ }
1031+ if (!WidestIndTy) {
10391032 reportVectorizationFailure (" Did not find one integer induction var" ,
10401033 " integer loop induction variable could not be identified" ,
10411034 " NoIntegerInductionVariable" , ORE, TheLoop);
10421035 return false ;
1043- } else {
1044- LLVM_DEBUG (dbgs () << " LV: Did not find one integer induction var.\n " );
10451036 }
1037+ LLVM_DEBUG (dbgs () << " LV: Did not find one integer induction var.\n " );
10461038 }
10471039
10481040 // Now we know the widest induction type, check if our found induction
0 commit comments