Skip to content

Commit 6bf9bd7

Browse files
vmustyaigcbot
authored andcommitted
Minor refactoring for VC pattern matching pass
.
1 parent 52dab22 commit 6bf9bd7

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXPatternMatch.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ using namespace llvm::PatternMatch;
9494
using namespace genx;
9595
using namespace vc;
9696

97-
#define DEBUG_TYPE "GENX_PATTERN_MATCH"
97+
#define DEBUG_TYPE "genx-pattern-match"
9898

9999
STATISTIC(NumOfMadMatched, "Number of mad instructions matched");
100100
STATISTIC(NumOfMinMaxMatched, "Number of min/max instructions matched");
@@ -114,13 +114,14 @@ static cl::opt<bool> EnableBfnMatcher("enable-bfn", cl::init(true), cl::Hidden,
114114
cl::desc("Enable bfn matching."));
115115

116116
namespace {
117-
118117
class GenXPatternMatch : public FunctionPass,
119118
public InstVisitor<GenXPatternMatch> {
120-
DominatorTree *DT = nullptr;
121-
LoopInfo *LI = nullptr;
122119
const DataLayout *DL = nullptr;
123120
const TargetOptions *Options = nullptr;
121+
const GenXSubtarget *ST = nullptr;
122+
DominatorTree *DT = nullptr;
123+
LoopInfo *LI = nullptr;
124+
124125
// Indicates whether there is any change.
125126
bool Changed = false;
126127

@@ -223,35 +224,31 @@ bool GenXPatternMatch::runOnFunction(Function &F) {
223224

224225
// Before we get the simd-control-flow representation right,
225226
// we avoid dealing with predicate constants
226-
const GenXSubtarget *ST = &getAnalysis<TargetPassConfig>()
227-
.getTM<GenXTargetMachine>()
228-
.getGenXSubtarget();
227+
ST = &getAnalysis<TargetPassConfig>()
228+
.getTM<GenXTargetMachine>()
229+
.getGenXSubtarget();
229230
if (Kind == PatternMatchKind::PreLegalization) {
230231
loadPhiConstants(F, DT, *ST, *DL, true);
231232
Changed |= distributeIntegerMul(&F);
232233
Changed |= propagateFoldableRegion(&F);
233234
Changed |= reassociateIntegerMad(&F);
234235
Changed |= placeConstants(&F);
235236
Changed |= vectorizeConstants(&F);
237+
}
236238

237-
visit(F);
239+
visit(F);
238240

241+
if (Kind == PatternMatchKind::PreLegalization) {
239242
Changed |= simplifyVolatileGlobals(&F);
240-
241243
Changed |= simplifySelect(&F);
242244
// Break big predicate variables and run after min/max pattern match.
243245
Changed |= decomposeSelect(&F);
244-
245246
Changed |= mergeLscLoad(&F);
246247

247248
// Simplify instructions after select decomposition and clear dead ones.
248-
for (auto& BB : F)
249+
for (auto &BB : F)
249250
Changed |= SimplifyInstructionsInBlock(&BB);
250251
}
251-
else {
252-
visit(F);
253-
}
254-
255252
return Changed;
256253
}
257254

@@ -530,9 +527,6 @@ void GenXPatternMatch::visitCallInst(CallInst &I) {
530527
return;
531528
}
532529

533-
const GenXSubtarget *ST = &getAnalysis<TargetPassConfig>()
534-
.getTM<GenXTargetMachine>()
535-
.getGenXSubtarget();
536530
auto IID = vc::getAnyIntrinsicID(&I);
537531
switch (IID) {
538532
default:

0 commit comments

Comments
 (0)