@@ -47,7 +47,7 @@ cl::opt<bool>
47
47
HintsAllowReordering (" hints-allow-reordering" , cl::init(true ), cl::Hidden,
48
48
cl::desc (" Allow enabling loop hints to reorder "
49
49
" FP operations during vectorization." ));
50
- }
50
+ } // namespace llvm
51
51
52
52
// TODO: Move size-based thresholds out of legality checking, make cost based
53
53
// decisions instead of hard thresholds.
@@ -216,20 +216,19 @@ void LoopVectorizeHints::emitRemarkWithHints() const {
216
216
TheLoop->getStartLoc (),
217
217
TheLoop->getHeader ())
218
218
<< " 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 << " )" ;
232
230
}
231
+ return R;
233
232
});
234
233
}
235
234
@@ -271,8 +270,8 @@ void LoopVectorizeHints::getHintsFromMetadata() {
271
270
if (!MD || MD->getNumOperands () == 0 )
272
271
continue ;
273
272
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 ));
276
275
} else {
277
276
S = dyn_cast<MDString>(MDO);
278
277
assert (Args.size () == 0 && " too many arguments for MDString" );
@@ -444,10 +443,7 @@ static bool storeToSameAddress(ScalarEvolution *SE, StoreInst *A,
444
443
return true ;
445
444
446
445
// 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);
451
447
}
452
448
453
449
int LoopVectorizationLegality::isConsecutivePtr (Type *AccessTy,
@@ -734,26 +730,21 @@ bool LoopVectorizationLegality::setupOuterLoopInductions() {
734
730
BasicBlock *Header = TheLoop->getHeader ();
735
731
736
732
// Returns true if a given Phi is a supported induction.
737
- auto isSupportedPhi = [&](PHINode &Phi) -> bool {
733
+ auto IsSupportedPhi = [&](PHINode &Phi) -> bool {
738
734
InductionDescriptor ID;
739
735
if (InductionDescriptor::isInductionPHI (&Phi, TheLoop, PSE, ID) &&
740
736
ID.getKind () == InductionDescriptor::IK_IntInduction) {
741
737
addInductionPhi (&Phi, ID, AllowedExit);
742
738
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 ;
750
739
}
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 ;
751
745
};
752
746
753
- if (llvm::all_of (Header->phis (), isSupportedPhi))
754
- return true ;
755
- else
756
- return false ;
747
+ return llvm::all_of (Header->phis (), IsSupportedPhi);
757
748
}
758
749
759
750
// / Checks if a function is scalarizable according to the TLI, in
@@ -837,13 +828,13 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
837
828
// historical vectorizer behavior after a generalization of the
838
829
// IVDescriptor code. The intent is to remove this check, but we
839
830
// 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
+ };
847
838
848
839
// TODO: Instead of recording the AllowedExit, it would be good to
849
840
// record the complementary set: NotAllowedExit. These include (but may
@@ -861,7 +852,7 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
861
852
// of these NotAllowedExit.
862
853
InductionDescriptor ID;
863
854
if (InductionDescriptor::isInductionPHI (Phi, TheLoop, PSE, ID) &&
864
- !isDisallowedStridedPointerInduction (ID)) {
855
+ !IsDisallowedStridedPointerInduction (ID)) {
865
856
addInductionPhi (Phi, ID, AllowedExit);
866
857
Requirements->addExactFPMathInst (ID.getExactFPMathInst ());
867
858
continue ;
@@ -876,7 +867,7 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
876
867
// As a last resort, coerce the PHI to a AddRec expression
877
868
// and re-try classifying it a an induction PHI.
878
869
if (InductionDescriptor::isInductionPHI (Phi, TheLoop, PSE, ID, true ) &&
879
- !isDisallowedStridedPointerInduction (ID)) {
870
+ !IsDisallowedStridedPointerInduction (ID)) {
880
871
addInductionPhi (Phi, ID, AllowedExit);
881
872
continue ;
882
873
}
@@ -932,9 +923,10 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
932
923
if (CI) {
933
924
auto *SE = PSE.getSE ();
934
925
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)) {
938
930
reportVectorizationFailure (" Found unvectorizable intrinsic" ,
939
931
" intrinsic instruction cannot be vectorized" ,
940
932
" CantVectorizeIntrinsic" , ORE, TheLoop, CI);
@@ -1035,14 +1027,14 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
1035
1027
" loop induction variable could not be identified" ,
1036
1028
" NoInductionVariable" , ORE, TheLoop);
1037
1029
return false ;
1038
- } else if (!WidestIndTy) {
1030
+ }
1031
+ if (!WidestIndTy) {
1039
1032
reportVectorizationFailure (" Did not find one integer induction var" ,
1040
1033
" integer loop induction variable could not be identified" ,
1041
1034
" NoIntegerInductionVariable" , ORE, TheLoop);
1042
1035
return false ;
1043
- } else {
1044
- LLVM_DEBUG (dbgs () << " LV: Did not find one integer induction var.\n " );
1045
1036
}
1037
+ LLVM_DEBUG (dbgs () << " LV: Did not find one integer induction var.\n " );
1046
1038
}
1047
1039
1048
1040
// Now we know the widest induction type, check if our found induction
0 commit comments