@@ -179,42 +179,40 @@ void LoopVectorizeHints::setAlreadyVectorized() {
179179 IsVectorized.Value = 1 ;
180180}
181181
182+ void LoopVectorizeHints::reportDisallowedVectorization (
183+ const StringRef DebugMsg, const StringRef RemarkName,
184+ const StringRef RemarkMsg, const Loop *L) const {
185+ LLVM_DEBUG (dbgs () << " LV: Not vectorizing: " << DebugMsg << " .\n " );
186+ ORE.emit (OptimizationRemarkMissed (LV_NAME, RemarkName, L->getStartLoc (),
187+ L->getHeader ())
188+ << " loop not vectorized: " << RemarkMsg);
189+ }
190+
182191bool LoopVectorizeHints::allowVectorization (
183192 Function *F, Loop *L, bool VectorizeOnlyWhenForced) const {
184193 if (getForce () == LoopVectorizeHints::FK_Disabled) {
185194 if (Force.Value == LoopVectorizeHints::FK_Disabled) {
186- LLVM_DEBUG (dbgs () << " LV: Not vectorizing: #pragma vectorize disable.\n " );
187- ORE.emit (OptimizationRemarkMissed (LV_NAME, " MissedExplicitlyDisabled" ,
188- TheLoop->getStartLoc (),
189- TheLoop->getHeader ())
190- << " loop not vectorized: vectorization is explicitly disabled" );
191- } else if (hasDisableAllTransformsHint (TheLoop)) {
192- LLVM_DEBUG (
193- dbgs () << " LV: Not vectorizing: loop hasDisableAllTransformsHint.\n " );
194- ORE.emit (OptimizationRemarkMissed (LV_NAME, " MissedTransformsDisabled" ,
195- TheLoop->getStartLoc (),
196- TheLoop->getHeader ())
197- << " loop not vectorized: loop transformations are disabled" );
195+ reportDisallowedVectorization (" #pragma vectorize disable" ,
196+ " MissedExplicitlyDisabled" ,
197+ " vectorization is explicitly disabled" );
198+ } else if (hasDisableAllTransformsHint (L)) {
199+ reportDisallowedVectorization (" loop hasDisableAllTransformsHint" ,
200+ " MissedTransformsDisabled" ,
201+ " loop transformations are disabled" );
198202 } else {
199203 // This should be unreachable unless there is a bug.
200- ORE.emit (OptimizationRemarkMissed (LV_NAME, " MissedUnknown" ,
201- TheLoop->getStartLoc (),
202- TheLoop->getHeader ())
203- << " loop not vectorized: unknown reason, please file a bug "
204- " report on the LLVM issue tracker" );
204+ reportDisallowedVectorization (
205+ " disabled for an unknown reason" , " MissedUnknown" ,
206+ " unknown reason, please file a bug report on the LLVM issue tracker" );
205207 llvm_unreachable (" loop vect disabled for an unknown reason" );
206208 }
207209 return false ;
208210 }
209211
210212 if (VectorizeOnlyWhenForced && getForce () != LoopVectorizeHints::FK_Enabled) {
211- LLVM_DEBUG (dbgs () << " LV: Not vectorizing: VectorizeOnlyWhenForced is set, "
212- " and no #pragma vectorize enable.\n " );
213- ORE.emit (OptimizationRemarkMissed (LV_NAME, " MissedForceOnly" ,
214- TheLoop->getStartLoc (),
215- TheLoop->getHeader ())
216- << " loop not vectorized: only vectorizing loops that "
217- " explicitly request it" );
213+ reportDisallowedVectorization (
214+ " VectorizeOnlyWhenForced is set, and no #pragma vectorize enable" ,
215+ " MissedForceOnly" , " only vectorizing loops that explicitly request it" );
218216 return false ;
219217 }
220218
0 commit comments