@@ -321,6 +321,22 @@ namespace {
321
321
return true ;
322
322
}
323
323
324
+ bool EnableCanonicalizeGEP () const {
325
+ switch (IGC_GET_FLAG_VALUE (MemOptGEPCanon)) {
326
+ case 1 :
327
+ return false ;
328
+ case 2 :
329
+ {
330
+ if (CGC && CGC->type == ShaderType::OPENCL_SHADER)
331
+ return false ;
332
+ break ;
333
+ }
334
+ default :
335
+ break ;
336
+ }
337
+ return true ;
338
+ }
339
+
324
340
// / Canonicalize the calculation of 64-bit pointer by performing the
325
341
// / following transformations to help SCEV to identify the constant offset
326
342
// / between pointers.
@@ -526,7 +542,7 @@ bool MemOpt::runOnFunction(Function& F) {
526
542
if (MemRefs.size () < 2 )
527
543
continue ;
528
544
529
- if (IGC_IS_FLAG_ENABLED (EnableMemOptGEPCanon )) {
545
+ if (EnableCanonicalizeGEP ( )) {
530
546
// Canonicalize 64-bit GEP to help SCEV find constant offset by
531
547
// distributing `zext`/`sext` over safe expressions.
532
548
for (auto & M : MemRefs)
@@ -553,7 +569,7 @@ bool MemOpt::runOnFunction(Function& F) {
553
569
}
554
570
}
555
571
556
- if (IGC_IS_FLAG_ENABLED (EnableMemOptGEPCanon )) {
572
+ if (EnableCanonicalizeGEP ( )) {
557
573
// Optimize 64-bit GEP to reduce strength by factoring out `zext`/`sext`
558
574
// over safe expressions.
559
575
for (auto I : MemRefsToOptimize)
@@ -1137,7 +1153,7 @@ bool MemOpt::mergeLoad(LoadInst* LeadingLoad,
1137
1153
return false ;
1138
1154
const SCEV* LeadingLastIdx = nullptr ; // set on-demand
1139
1155
bool DoCmpOnLastIdx = false ;
1140
- if (IGC_IS_FLAG_DISABLED (EnableMemOptGEPCanon )) {
1156
+ if (! EnableCanonicalizeGEP ( )) {
1141
1157
auto aGEP = dyn_cast<GetElementPtrInst>(LeadingLoad->getPointerOperand ());
1142
1158
if (aGEP && aGEP->hasIndices ()) {
1143
1159
// index starts from 1
@@ -1305,8 +1321,8 @@ bool MemOpt::mergeLoad(LoadInst* LeadingLoad,
1305
1321
MaxElts = profitVec[k++];
1306
1322
}
1307
1323
1308
- if (IGC_IS_FLAG_ENABLED (EnableMemOptGEPCanon )) {
1309
- // Guard under the key to distinguish new code (EnableMemOptGEPCanon=0 ) from the old.
1324
+ if (EnableCanonicalizeGEP ( )) {
1325
+ // Guard under the key to distinguish new code (GEPCanon is off ) from the old.
1310
1326
// Note: not sure about the reason for the following check.
1311
1327
if (NumElts == 3 && (LeadingLoadScalarType->isIntegerTy (16 ) || LeadingLoadScalarType->isHalfTy ())) {
1312
1328
return false ;
0 commit comments