@@ -82,7 +82,7 @@ SPDX-License-Identifier: MIT
82
82
char IGCVectorizer::ID = 0 ;
83
83
84
84
#define PASS_FLAG2 " igc-vectorizer"
85
- #define PASS_DESCRIPTION2 " Vectorizes scalar path around igc vector intrinsics like dpas "
85
+ #define PASS_DESCRIPTION2 " prints register pressure estimation "
86
86
#define PASS_CFG_ONLY2 false
87
87
#define PASS_ANALYSIS2 false
88
88
IGC_INITIALIZE_PASS_BEGIN (IGCVectorizer, PASS_FLAG2, PASS_DESCRIPTION2,
@@ -91,12 +91,11 @@ IGC_INITIALIZE_PASS_DEPENDENCY(CodeGenContextWrapper)
91
91
IGC_INITIALIZE_PASS_END(IGCVectorizer, PASS_FLAG2, PASS_DESCRIPTION2,
92
92
PASS_CFG_ONLY2, PASS_ANALYSIS2)
93
93
94
- #define OutputLogStreamM OutputLogStream
95
94
#define DEBUG IGC_IS_FLAG_ENABLED (VectorizerLog)
96
- #define PRINT_LOG (Str ) if (DEBUG) OutputLogStreamM << Str;
97
- #define PRINT_LOG_NL (Str ) if (DEBUG) OutputLogStreamM << Str << " \n " ;
98
- #define PRINT_INST (I ) if (DEBUG) { I->print (OutputLogStreamM , false ); }
99
- #define PRINT_INST_NL (I ) if (DEBUG) { I->print (OutputLogStreamM , false ); OutputLogStreamM << " \n " ; }
95
+ #define PRINT_LOG (Str ) if (DEBUG) OutputLogStream << Str;
96
+ #define PRINT_LOG_NL (Str ) if (DEBUG) OutputLogStream << Str << " \n " ;
97
+ #define PRINT_INST (I ) if (DEBUG) { I->print (OutputLogStream , false ); }
98
+ #define PRINT_INST_NL (I ) if (DEBUG) { I->print (OutputLogStream , false ); OutputLogStream << " \n " ; }
100
99
#define PRINT_DS (Str, DS ) if (DEBUG) { for (auto DS_EL : DS) { { PRINT_LOG (Str); } { PRINT_INST_NL (DS_EL); } } }
101
100
102
101
IGCVectorizer::IGCVectorizer () : FunctionPass(ID) {
@@ -181,41 +180,29 @@ unsigned int getVectorSize(Instruction *I) {
181
180
bool isSafeToVectorize (Instruction *I) {
182
181
// this is a very limited approach for vectorizing
183
182
// but it's safe
184
- bool Result =
185
- llvm::isa<PHINode>(I) ||
186
- llvm::isa<ExtractElementInst>(I) ||
187
- llvm::isa<InsertElementInst>(I) ||
188
- llvm::isa<CastInst>(I);
183
+ bool Result = llvm::isa<PHINode>(I) || llvm::isa<ExtractElementInst>(I) ||
184
+ llvm::isa<InsertElementInst>(I);
189
185
190
186
return Result;
191
187
}
192
188
193
189
bool IGCVectorizer::compareOperands (Value *A, Value *B) {
194
-
195
- PRINT_INST (A); PRINT_LOG (" & " ); PRINT_INST (B);
196
190
Constant *ConstA = llvm::dyn_cast<Constant>(A);
197
191
Constant *ConstB = llvm::dyn_cast<Constant>(B);
198
192
199
193
Instruction *InstA = llvm::dyn_cast<Instruction>(A);
200
194
Instruction *InstB = llvm::dyn_cast<Instruction>(B);
201
195
202
196
if (ConstA && ConstB) {
203
-
204
- PRINT_LOG (" --> Const " );
205
197
bool BothZero = ConstA->isZeroValue () && ConstB->isZeroValue ();
206
- PRINT_LOG (" --> " << BothZero << " " );
207
- // negative zero value returns true for 0 int
208
- BothZero &= llvm::isa<ConstantInt>(ConstA) || !(ConstA->isNegativeZeroValue () || ConstB->isNegativeZeroValue ());
209
- PRINT_LOG_NL (" Negative Zero --> " << BothZero << " " );
198
+ BothZero &= !(ConstA->isNegativeZeroValue () || ConstB->isNegativeZeroValue ());
210
199
return BothZero;
211
200
} else if (InstA && InstB) {
212
201
if (!ScalarToVector.count (InstA)) {
213
202
PRINT_LOG_NL (" some elements weren't even vectorized" );
214
203
return false ;
215
204
}
216
205
bool Same = ScalarToVector[InstA] == ScalarToVector[InstB];
217
- PRINT_LOG (" A: " ); PRINT_INST_NL (ScalarToVector[InstA]);
218
- PRINT_LOG (" B: " ); PRINT_INST_NL (ScalarToVector[InstB]);
219
206
return Same;
220
207
}
221
208
return false ;
@@ -275,48 +262,6 @@ bool IGCVectorizer::handleInsertElement(VecArr &Slice, Instruction* Final) {
275
262
return true ;
276
263
}
277
264
278
-
279
- bool IGCVectorizer::handleCastInstruction (VecArr &Slice) {
280
-
281
- Instruction *First = Slice.front ();
282
-
283
- if (!ScalarToVector.count (First->getOperand (0 ))) {
284
- PRINT_LOG_NL (" some elements weren't even vectorized" );
285
- return false ;
286
- }
287
-
288
- Value *Compare = ScalarToVector[First->getOperand (0 )];
289
- for (auto &El : Slice) {
290
- Value *Val = El->getOperand (0 );
291
- Value *ValCompare = ScalarToVector[Val];
292
- if (ValCompare != Compare) {
293
- PRINT_LOG (" UnaryCompare: " ); PRINT_INST_NL (Compare);
294
- PRINT_LOG (" UnaryVal: " ); PRINT_INST_NL (ValCompare);
295
- PRINT_LOG_NL (" Insert Element, operands do not converge" );
296
- return false ;
297
- }
298
- }
299
-
300
- auto VectorSize = getVectorSize ((Instruction* )Compare);
301
- auto Type = IGCLLVM::FixedVectorType::get (First->getType (), VectorSize);
302
- auto CastOpcode = llvm::cast<CastInst>(First)->getOpcode ();
303
-
304
- CastInst* CreatedCast = CastInst::Create (CastOpcode, Compare, Type);
305
- CreatedCast->setName (" vectorized_cast" );
306
-
307
- CreatedCast->setDebugLoc (First->getDebugLoc ());
308
- CreatedCast->insertBefore (First);
309
- CreatedVectorInstructions.push_back (CreatedCast);
310
-
311
- PRINT_LOG (" Cast instruction created: " );
312
- PRINT_INST_NL (CreatedCast);
313
-
314
- for (auto &el : Slice)
315
- ScalarToVector[el] = CreatedCast;
316
-
317
- return true ;
318
- }
319
-
320
265
// this basicaly seeds the chain
321
266
bool IGCVectorizer::handleExtractElement (VecArr &Slice) {
322
267
Instruction *First = Slice.front ();
@@ -343,8 +288,6 @@ bool IGCVectorizer::processChain(InsertStruct &InSt) {
343
288
Instruction *First = Slice[0 ];
344
289
if (llvm::isa<PHINode>(First)) {
345
290
if (!handlePHI (Slice, InSt.Final ->getType ())) return false ;
346
- } else if (llvm::isa<CastInst>(First)) {
347
- if (!handleCastInstruction (Slice)) return false ;
348
291
} else if (llvm::isa<ExtractElementInst>(First)) {
349
292
if (!handleExtractElement (Slice)) return false ;
350
293
} else if (llvm::isa<InsertElementInst>(First)) {
@@ -645,10 +588,8 @@ bool IGCVectorizer::runOnFunction(llvm::Function &F) {
645
588
646
589
CreatedVectorInstructions.clear ();
647
590
if (!processChain (InSt)) {
648
- writeLog ();
649
- std::reverse (CreatedVectorInstructions.begin (), CreatedVectorInstructions.end ());
650
591
for (auto & el : CreatedVectorInstructions) {
651
- PRINT_LOG (" Cleaned: " ); PRINT_INST_NL (el); writeLog ();
592
+ PRINT_LOG (" Cleaned: " ); PRINT_INST_NL (el);
652
593
el->eraseFromParent ();
653
594
}
654
595
}
0 commit comments