@@ -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 )
@@ -223,7 +227,7 @@ bool isSafeToVectorize(Instruction *I) {
223
227
return Result;
224
228
}
225
229
226
- bool IGCVectorizer::handlePHI (VecArr &Slice, Type *VectorType ) {
230
+ bool IGCVectorizer::handlePHI (VecArr &Slice) {
227
231
PHINode *ScalarPhi = static_cast <PHINode *>(Slice[0 ]);
228
232
229
233
if (!checkPHI (ScalarPhi, Slice))
@@ -315,11 +319,6 @@ bool IGCVectorizer::handleInsertElement(VecArr &Slice, Instruction* Final) {
315
319
if (!checkInsertElement (First, Slice))
316
320
return false ;
317
321
318
- // we can handle case with more than 1 value
319
- // but it wasn't tested
320
- if (!Final->hasOneUse ())
321
- return false ;
322
-
323
322
PRINT_LOG_NL (" InsertElement substituted with vectorized instruction" );
324
323
PRINT_LOG_NL (" " );
325
324
Value *Compare = ScalarToVector[First->getOperand (1 )];
@@ -473,7 +472,7 @@ bool IGCVectorizer::processChain(InsertStruct &InSt) {
473
472
474
473
Instruction *First = Slice[0 ];
475
474
if (llvm::isa<PHINode>(First)) {
476
- if (!handlePHI (Slice, InSt. Final -> getType () )) return false ;
475
+ if (!handlePHI (Slice)) return false ;
477
476
} else if (llvm::isa<CastInst>(First)) {
478
477
if (!handleCastInstruction (Slice)) return false ;
479
478
} else if (llvm::isa<BinaryOperator>(First)) {
@@ -489,10 +488,8 @@ bool IGCVectorizer::processChain(InsertStruct &InSt) {
489
488
return true ;
490
489
}
491
490
492
- void IGCVectorizer::clusterInsertElement (
493
- InsertElementInst* HeadInsertEl, InsertStruct &InSt) {
494
- InSt.Final = HeadInsertEl;
495
- Instruction *Head = HeadInsertEl;
491
+ void IGCVectorizer::clusterInsertElement (InsertStruct &InSt) {
492
+ Instruction *Head = InSt.Final ;
496
493
497
494
while (true ) {
498
495
InSt.Vec .push_back (Head);
@@ -803,9 +800,20 @@ bool IGCVectorizer::runOnFunction(llvm::Function &F) {
803
800
804
801
// we process collected insert elements into a specific data structure
805
802
// for convenience
806
- for (auto el : VecOfInsert) {
807
- InsertStruct InSt;
808
- clusterInsertElement (static_cast <InsertElementInst*>(el), InSt);
803
+ InsertStruct InSt;
804
+ InSt.SlChain .reserve (128 );
805
+ for (auto elFinal : VecOfInsert) {
806
+
807
+ InSt.SlChain .clear ();
808
+ InSt.Vec .clear ();
809
+
810
+ if (!elFinal->hasOneUse ()) {
811
+ PRINT_LOG_NL (" Final insert has more than one use -> rejected" );
812
+ continue ;
813
+ }
814
+ InSt.Final = elFinal;
815
+ clusterInsertElement (InSt);
816
+
809
817
if (InSt.Vec .size () != getVectorSize (InSt.Final )) {
810
818
PRINT_LOG_NL (" partial insert -> rejected" );
811
819
continue ;
0 commit comments