29
29
#include " llvm/Support/MemoryBuffer.h"
30
30
#include " llvm/Support/Path.h"
31
31
#include " llvm/Support/Program.h"
32
+ #include " llvm/Support/TypeSize.h"
32
33
#include " llvm/Support/WithColor.h"
33
34
#include " llvm/Support/raw_ostream.h"
34
35
#include < cstdlib>
@@ -100,7 +101,7 @@ struct OptReportLocationInfo {
100
101
OptReportLocationItemInfo Unrolled;
101
102
OptReportLocationItemInfo Vectorized;
102
103
103
- int VectorizationFactor = 1 ;
104
+ ElementCount VectorizationFactor = ElementCount::getFixed( 1 ) ;
104
105
int InterleaveCount = 1 ;
105
106
int UnrollCount = 1 ;
106
107
@@ -109,8 +110,9 @@ struct OptReportLocationInfo {
109
110
Unrolled |= RHS.Unrolled ;
110
111
Vectorized |= RHS.Vectorized ;
111
112
112
- VectorizationFactor =
113
- std::max (VectorizationFactor, RHS.VectorizationFactor );
113
+ if (ElementCount::isKnownLT (VectorizationFactor, RHS.VectorizationFactor ))
114
+ VectorizationFactor = RHS.VectorizationFactor ;
115
+
114
116
InterleaveCount = std::max (InterleaveCount, RHS.InterleaveCount );
115
117
UnrollCount = std::max (UnrollCount, RHS.UnrollCount );
116
118
@@ -130,9 +132,11 @@ struct OptReportLocationInfo {
130
132
return true ;
131
133
else if (RHS.Vectorized < Vectorized || Succinct)
132
134
return false ;
133
- else if (VectorizationFactor < RHS.VectorizationFactor )
135
+ else if (ElementCount::isKnownLT (VectorizationFactor,
136
+ RHS.VectorizationFactor ))
134
137
return true ;
135
- else if (VectorizationFactor > RHS.VectorizationFactor )
138
+ else if (ElementCount::isKnownGT (VectorizationFactor,
139
+ RHS.VectorizationFactor ))
136
140
return false ;
137
141
else if (InterleaveCount < RHS.InterleaveCount )
138
142
return true ;
@@ -197,17 +201,26 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) {
197
201
198
202
bool Transformed = Remark.RemarkType == remarks::Type::Passed;
199
203
200
- int VectorizationFactor = 1 ;
204
+ ElementCount VectorizationFactor = ElementCount::getFixed ( 1 ) ;
201
205
int InterleaveCount = 1 ;
202
206
int UnrollCount = 1 ;
203
207
204
208
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" ) {
208
220
Arg.Val .getAsInteger (10 , InterleaveCount);
209
- else if (Arg.Key == " UnrollCount" )
221
+ } else if (Arg.Key == " UnrollCount" ) {
210
222
Arg.Val .getAsInteger (10 , UnrollCount);
223
+ }
211
224
}
212
225
213
226
const std::optional<remarks::RemarkLocation> &Loc = Remark.Loc ;
@@ -292,7 +305,11 @@ static bool writeReport(LocationInfoTy &LocationInfo) {
292
305
bool NothingUnrolled = !MaxLI.Unrolled .Transformed ;
293
306
bool NothingVectorized = !MaxLI.Vectorized .Transformed ;
294
307
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
+
296
313
unsigned ICDigits = llvm::utostr (MaxLI.InterleaveCount ).size ();
297
314
unsigned UCDigits = llvm::utostr (MaxLI.UnrollCount ).size ();
298
315
@@ -382,7 +399,10 @@ static bool writeReport(LocationInfoTy &LocationInfo) {
382
399
raw_string_ostream RS (R);
383
400
384
401
if (!Succinct) {
385
- RS << LLI.VectorizationFactor << " ," << LLI.InterleaveCount ;
402
+ if (LLI.VectorizationFactor .isScalable ())
403
+ RS << " Nx" ;
404
+ RS << LLI.VectorizationFactor .getKnownMinValue () << " ,"
405
+ << LLI.InterleaveCount ;
386
406
RS << std::string (VFDigits + ICDigits + 1 - R.size (), ' ' );
387
407
}
388
408
0 commit comments