@@ -114,8 +114,12 @@ void IGCVectorizer::initializeLogFile(Function &F) {
114
114
if (!IGC_IS_FLAG_ENABLED (VectorizerLog))
115
115
return ;
116
116
117
+ string FName = F.getName ().str ();
118
+
119
+ if (FName.size () > 128 ) FName.resize (128 );
120
+
117
121
std::stringstream ss;
118
- ss << F. getName (). str () << " _"
122
+ ss << FName << " _"
119
123
<< " Vectorizer" ;
120
124
auto Name = Debug::DumpName (IGC::Debug::GetShaderOutputName ())
121
125
.Hash (CGCtx->hash )
@@ -221,7 +225,7 @@ bool isSafeToVectorize(Instruction *I) {
221
225
return Result;
222
226
}
223
227
224
- bool IGCVectorizer::handlePHI (VecArr &Slice, Type *VectorType ) {
228
+ bool IGCVectorizer::handlePHI (VecArr &Slice) {
225
229
PHINode *ScalarPhi = static_cast <PHINode *>(Slice[0 ]);
226
230
227
231
if (!checkPHI (ScalarPhi, Slice))
@@ -313,11 +317,6 @@ bool IGCVectorizer::handleInsertElement(VecArr &Slice, Instruction* Final) {
313
317
if (!checkInsertElement (First, Slice))
314
318
return false ;
315
319
316
- // we can handle case with more than 1 value
317
- // but it wasn't tested
318
- if (!Final->hasOneUse ())
319
- return false ;
320
-
321
320
PRINT_LOG_NL (" InsertElement substituted with vectorized instruction" );
322
321
PRINT_LOG_NL (" " );
323
322
Value *Compare = ScalarToVector[First->getOperand (1 )];
@@ -471,7 +470,7 @@ bool IGCVectorizer::processChain(InsertStruct &InSt) {
471
470
472
471
Instruction *First = Slice[0 ];
473
472
if (llvm::isa<PHINode>(First)) {
474
- if (!handlePHI (Slice, InSt. Final -> getType () )) return false ;
473
+ if (!handlePHI (Slice)) return false ;
475
474
} else if (llvm::isa<CastInst>(First)) {
476
475
if (!handleCastInstruction (Slice)) return false ;
477
476
} else if (llvm::isa<BinaryOperator>(First)) {
@@ -487,10 +486,8 @@ bool IGCVectorizer::processChain(InsertStruct &InSt) {
487
486
return true ;
488
487
}
489
488
490
- void IGCVectorizer::clusterInsertElement (
491
- InsertElementInst* HeadInsertEl, InsertStruct &InSt) {
492
- InSt.Final = HeadInsertEl;
493
- Instruction *Head = HeadInsertEl;
489
+ void IGCVectorizer::clusterInsertElement (InsertStruct &InSt) {
490
+ Instruction *Head = InSt.Final ;
494
491
495
492
while (true ) {
496
493
InSt.Vec .push_back (Head);
@@ -801,9 +798,20 @@ bool IGCVectorizer::runOnFunction(llvm::Function &F) {
801
798
802
799
// we process collected insert elements into a specific data structure
803
800
// for convenience
804
- for (auto el : VecOfInsert) {
805
- InsertStruct InSt;
806
- clusterInsertElement (static_cast <InsertElementInst*>(el), InSt);
801
+ InsertStruct InSt;
802
+ InSt.SlChain .reserve (128 );
803
+ for (auto elFinal : VecOfInsert) {
804
+
805
+ InSt.SlChain .clear ();
806
+ InSt.Vec .clear ();
807
+
808
+ if (!elFinal->hasOneUse ()) {
809
+ PRINT_LOG_NL (" Final insert has more than one use -> rejected" );
810
+ continue ;
811
+ }
812
+ InSt.Final = elFinal;
813
+ clusterInsertElement (InSt);
814
+
807
815
if (InSt.Vec .size () != getVectorSize (InSt.Final )) {
808
816
PRINT_LOG_NL (" partial insert -> rejected" );
809
817
continue ;
0 commit comments