Skip to content

Commit 0c8bc85

Browse files
esukhovfda0
authored andcommitted
Revert: New vectorization pattern for IGCVectorizer
. (cherry picked from commit 26c11d9)
1 parent 5a72fca commit 0c8bc85

File tree

4 files changed

+9
-275
lines changed

4 files changed

+9
-275
lines changed

IGC/Compiler/CISACodeGen/IGCVectorizer.cpp

Lines changed: 9 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ SPDX-License-Identifier: MIT
8282
char IGCVectorizer::ID = 0;
8383

8484
#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"
8686
#define PASS_CFG_ONLY2 false
8787
#define PASS_ANALYSIS2 false
8888
IGC_INITIALIZE_PASS_BEGIN(IGCVectorizer, PASS_FLAG2, PASS_DESCRIPTION2,
@@ -91,12 +91,11 @@ IGC_INITIALIZE_PASS_DEPENDENCY(CodeGenContextWrapper)
9191
IGC_INITIALIZE_PASS_END(IGCVectorizer, PASS_FLAG2, PASS_DESCRIPTION2,
9292
PASS_CFG_ONLY2, PASS_ANALYSIS2)
9393

94-
#define OutputLogStreamM OutputLogStream
9594
#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"; }
10099
#define PRINT_DS(Str, DS) if (DEBUG) { for (auto DS_EL : DS) { { PRINT_LOG(Str); } { PRINT_INST_NL(DS_EL); } } }
101100

102101
IGCVectorizer::IGCVectorizer() : FunctionPass(ID) {
@@ -181,41 +180,29 @@ unsigned int getVectorSize(Instruction *I) {
181180
bool isSafeToVectorize(Instruction *I) {
182181
// this is a very limited approach for vectorizing
183182
// 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);
189185

190186
return Result;
191187
}
192188

193189
bool IGCVectorizer::compareOperands(Value *A, Value *B) {
194-
195-
PRINT_INST(A); PRINT_LOG(" & "); PRINT_INST(B);
196190
Constant *ConstA = llvm::dyn_cast<Constant>(A);
197191
Constant *ConstB = llvm::dyn_cast<Constant>(B);
198192

199193
Instruction *InstA = llvm::dyn_cast<Instruction>(A);
200194
Instruction *InstB = llvm::dyn_cast<Instruction>(B);
201195

202196
if (ConstA && ConstB) {
203-
204-
PRINT_LOG(" --> Const ");
205197
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());
210199
return BothZero;
211200
} else if (InstA && InstB) {
212201
if (!ScalarToVector.count(InstA)) {
213202
PRINT_LOG_NL("some elements weren't even vectorized");
214203
return false;
215204
}
216205
bool Same = ScalarToVector[InstA] == ScalarToVector[InstB];
217-
PRINT_LOG("A: "); PRINT_INST_NL(ScalarToVector[InstA]);
218-
PRINT_LOG("B: "); PRINT_INST_NL(ScalarToVector[InstB]);
219206
return Same;
220207
}
221208
return false;
@@ -275,48 +262,6 @@ bool IGCVectorizer::handleInsertElement(VecArr &Slice, Instruction* Final) {
275262
return true;
276263
}
277264

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-
320265
// this basicaly seeds the chain
321266
bool IGCVectorizer::handleExtractElement(VecArr &Slice) {
322267
Instruction *First = Slice.front();
@@ -343,8 +288,6 @@ bool IGCVectorizer::processChain(InsertStruct &InSt) {
343288
Instruction *First = Slice[0];
344289
if (llvm::isa<PHINode>(First)) {
345290
if (!handlePHI(Slice, InSt.Final->getType())) return false;
346-
} else if (llvm::isa<CastInst>(First)) {
347-
if (!handleCastInstruction(Slice)) return false;
348291
} else if (llvm::isa<ExtractElementInst>(First)) {
349292
if (!handleExtractElement(Slice)) return false;
350293
} else if (llvm::isa<InsertElementInst>(First)) {
@@ -645,10 +588,8 @@ bool IGCVectorizer::runOnFunction(llvm::Function &F) {
645588

646589
CreatedVectorInstructions.clear();
647590
if (!processChain(InSt)) {
648-
writeLog();
649-
std::reverse(CreatedVectorInstructions.begin(), CreatedVectorInstructions.end());
650591
for (auto& el : CreatedVectorInstructions) {
651-
PRINT_LOG("Cleaned: "); PRINT_INST_NL(el); writeLog();
592+
PRINT_LOG("Cleaned: "); PRINT_INST_NL(el);
652593
el->eraseFromParent();
653594
}
654595
}

IGC/Compiler/CISACodeGen/IGCVectorizer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class IGCVectorizer : public llvm::FunctionPass {
7070
bool handleInsertElement(VecArr& Slice, Instruction* Final);
7171
bool checkExtractElement(Instruction* Compare, VecArr& Slice);
7272
bool handleExtractElement(VecArr& Slice);
73-
bool handleCastInstruction(VecArr& Slice);
7473

7574
bool compareOperands(Value* A, Value* B);
7675

IGC/Compiler/tests/IGCVectorizer/cast_test_vectorization.ll

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)