2929#include " llvm/Support/MemoryBuffer.h"
3030#include " llvm/Support/Path.h"
3131#include " llvm/Support/Program.h"
32+ #include " llvm/Support/TypeSize.h"
3233#include " llvm/Support/WithColor.h"
3334#include " llvm/Support/raw_ostream.h"
3435#include < cstdlib>
@@ -100,7 +101,7 @@ struct OptReportLocationInfo {
100101 OptReportLocationItemInfo Unrolled;
101102 OptReportLocationItemInfo Vectorized;
102103
103- int VectorizationFactor = 1 ;
104+ ElementCount VectorizationFactor = ElementCount::getFixed( 1 ) ;
104105 int InterleaveCount = 1 ;
105106 int UnrollCount = 1 ;
106107
@@ -109,8 +110,9 @@ struct OptReportLocationInfo {
109110 Unrolled |= RHS.Unrolled ;
110111 Vectorized |= RHS.Vectorized ;
111112
112- VectorizationFactor =
113- std::max (VectorizationFactor, RHS.VectorizationFactor );
113+ if (ElementCount::isKnownLT (VectorizationFactor, RHS.VectorizationFactor ))
114+ VectorizationFactor = RHS.VectorizationFactor ;
115+
114116 InterleaveCount = std::max (InterleaveCount, RHS.InterleaveCount );
115117 UnrollCount = std::max (UnrollCount, RHS.UnrollCount );
116118
@@ -130,9 +132,11 @@ struct OptReportLocationInfo {
130132 return true ;
131133 else if (RHS.Vectorized < Vectorized || Succinct)
132134 return false ;
133- else if (VectorizationFactor < RHS.VectorizationFactor )
135+ else if (ElementCount::isKnownLT (VectorizationFactor,
136+ RHS.VectorizationFactor ))
134137 return true ;
135- else if (VectorizationFactor > RHS.VectorizationFactor )
138+ else if (ElementCount::isKnownGT (VectorizationFactor,
139+ RHS.VectorizationFactor ))
136140 return false ;
137141 else if (InterleaveCount < RHS.InterleaveCount )
138142 return true ;
@@ -197,17 +201,26 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) {
197201
198202 bool Transformed = Remark.RemarkType == remarks::Type::Passed;
199203
200- int VectorizationFactor = 1 ;
204+ ElementCount VectorizationFactor = ElementCount::getFixed ( 1 ) ;
201205 int InterleaveCount = 1 ;
202206 int UnrollCount = 1 ;
203207
204208 for (const remarks::Argument &Arg : Remark.Args ) {
205- if (Arg.Key == " VectorizationFactor" )
206- Arg.Val .getAsInteger (10 , VectorizationFactor);
207- else if (Arg.Key == " InterleaveCount" )
209+ if (Arg.Key == " VectorizationFactor" ) {
210+ int MinValue = 1 ;
211+ bool IsScalable = false ;
212+ if (Arg.Val .starts_with (" vscale x " )) {
213+ Arg.Val .drop_front (9 ).getAsInteger (10 , MinValue);
214+ IsScalable = true ;
215+ } else {
216+ Arg.Val .getAsInteger (10 , MinValue);
217+ }
218+ VectorizationFactor = ElementCount::get (MinValue, IsScalable);
219+ } else if (Arg.Key == " InterleaveCount" ) {
208220 Arg.Val .getAsInteger (10 , InterleaveCount);
209- else if (Arg.Key == " UnrollCount" )
221+ } else if (Arg.Key == " UnrollCount" ) {
210222 Arg.Val .getAsInteger (10 , UnrollCount);
223+ }
211224 }
212225
213226 const std::optional<remarks::RemarkLocation> &Loc = Remark.Loc ;
@@ -292,7 +305,11 @@ static bool writeReport(LocationInfoTy &LocationInfo) {
292305 bool NothingUnrolled = !MaxLI.Unrolled .Transformed ;
293306 bool NothingVectorized = !MaxLI.Vectorized .Transformed ;
294307
295- unsigned VFDigits = llvm::utostr (MaxLI.VectorizationFactor ).size ();
308+ unsigned VFDigits =
309+ llvm::utostr (MaxLI.VectorizationFactor .getKnownMinValue ()).size ();
310+ if (MaxLI.VectorizationFactor .isScalable ())
311+ VFDigits += 2 ; // For "Nx..."
312+
296313 unsigned ICDigits = llvm::utostr (MaxLI.InterleaveCount ).size ();
297314 unsigned UCDigits = llvm::utostr (MaxLI.UnrollCount ).size ();
298315
@@ -382,7 +399,10 @@ static bool writeReport(LocationInfoTy &LocationInfo) {
382399 raw_string_ostream RS (R);
383400
384401 if (!Succinct) {
385- RS << LLI.VectorizationFactor << " ," << LLI.InterleaveCount ;
402+ if (LLI.VectorizationFactor .isScalable ())
403+ RS << " Nx" ;
404+ RS << LLI.VectorizationFactor .getKnownMinValue () << " ,"
405+ << LLI.InterleaveCount ;
386406 RS << std::string (VFDigits + ICDigits + 1 - R.size (), ' ' );
387407 }
388408
0 commit comments