@@ -94,7 +94,7 @@ using namespace llvm::PatternMatch;
94
94
using namespace genx ;
95
95
using namespace vc ;
96
96
97
- #define DEBUG_TYPE " GENX_PATTERN_MATCH "
97
+ #define DEBUG_TYPE " genx-pattern-match "
98
98
99
99
STATISTIC (NumOfMadMatched, " Number of mad instructions matched" );
100
100
STATISTIC (NumOfMinMaxMatched, " Number of min/max instructions matched" );
@@ -114,13 +114,14 @@ static cl::opt<bool> EnableBfnMatcher("enable-bfn", cl::init(true), cl::Hidden,
114
114
cl::desc(" Enable bfn matching." ));
115
115
116
116
namespace {
117
-
118
117
class GenXPatternMatch : public FunctionPass ,
119
118
public InstVisitor<GenXPatternMatch> {
120
- DominatorTree *DT = nullptr ;
121
- LoopInfo *LI = nullptr ;
122
119
const DataLayout *DL = nullptr ;
123
120
const TargetOptions *Options = nullptr ;
121
+ const GenXSubtarget *ST = nullptr ;
122
+ DominatorTree *DT = nullptr ;
123
+ LoopInfo *LI = nullptr ;
124
+
124
125
// Indicates whether there is any change.
125
126
bool Changed = false ;
126
127
@@ -223,35 +224,31 @@ bool GenXPatternMatch::runOnFunction(Function &F) {
223
224
224
225
// Before we get the simd-control-flow representation right,
225
226
// 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 ();
229
230
if (Kind == PatternMatchKind::PreLegalization) {
230
231
loadPhiConstants (F, DT, *ST, *DL, true );
231
232
Changed |= distributeIntegerMul (&F);
232
233
Changed |= propagateFoldableRegion (&F);
233
234
Changed |= reassociateIntegerMad (&F);
234
235
Changed |= placeConstants (&F);
235
236
Changed |= vectorizeConstants (&F);
237
+ }
236
238
237
- visit (F);
239
+ visit (F);
238
240
241
+ if (Kind == PatternMatchKind::PreLegalization) {
239
242
Changed |= simplifyVolatileGlobals (&F);
240
-
241
243
Changed |= simplifySelect (&F);
242
244
// Break big predicate variables and run after min/max pattern match.
243
245
Changed |= decomposeSelect (&F);
244
-
245
246
Changed |= mergeLscLoad (&F);
246
247
247
248
// Simplify instructions after select decomposition and clear dead ones.
248
- for (auto & BB : F)
249
+ for (auto & BB : F)
249
250
Changed |= SimplifyInstructionsInBlock (&BB);
250
251
}
251
- else {
252
- visit (F);
253
- }
254
-
255
252
return Changed;
256
253
}
257
254
@@ -530,9 +527,6 @@ void GenXPatternMatch::visitCallInst(CallInst &I) {
530
527
return ;
531
528
}
532
529
533
- const GenXSubtarget *ST = &getAnalysis<TargetPassConfig>()
534
- .getTM <GenXTargetMachine>()
535
- .getGenXSubtarget ();
536
530
auto IID = vc::getAnyIntrinsicID (&I);
537
531
switch (IID) {
538
532
default :
0 commit comments