@@ -42,6 +42,24 @@ bool GenIntrinsicsTTIImpl::isLoweredToCall(const Function *F) {
42
42
// instructions. Set this to false unless IGC legalization can fix them.
43
43
bool GenIntrinsicsTTIImpl::shouldBuildLookupTables () { return false ; }
44
44
45
+ bool GenIntrinsicsTTIImpl::enablePromoteLoopUnrollwithAlloca () {
46
+ const IGC::TriboolFlag RK_PromoteLoopUnrollwithAlloca =
47
+ static_cast <TriboolFlag>(IGC_GET_FLAG_VALUE (ForcePromoteLoopUnrollwithAlloca));
48
+ switch (RK_PromoteLoopUnrollwithAlloca) {
49
+ case TriboolFlag::Enabled:
50
+ return true ;
51
+ case TriboolFlag::Disabled:
52
+ return false ;
53
+ default :
54
+ if (ctx->type == ShaderType::OPENCL_SHADER)
55
+ return false ;
56
+ if (!ctx->platform .isCoreChildOf (IGFX_XE2_HPG_CORE))
57
+ return false ;
58
+
59
+ return true ;
60
+ }
61
+ }
62
+
45
63
void *GenIntrinsicsTTIImpl::getAdjustedAnalysisPointer (const void *ID) {
46
64
if (ID == &TargetTransformInfoWrapperPass::ID)
47
65
return (TargetTransformInfo *)this ;
@@ -318,7 +336,7 @@ void GenIntrinsicsTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
318
336
// It can potentially do some global cost estimations.
319
337
const unsigned UnrollMaxCountForAlloca = IGC_GET_FLAG_VALUE (PromoteLoopUnrollwithAllocaCountThreshold);
320
338
bool AllocaFound = false ;
321
- if (MaxTripCount && MaxTripCount <= UnrollMaxCountForAlloca ) {
339
+ if (MaxTripCount && MaxTripCount <= UnrollMaxCountForAlloca) {
322
340
unsigned int ThresholdBoost = 0 ;
323
341
for (auto BB : L->blocks ()) {
324
342
for (auto &I : *BB) {
@@ -357,13 +375,12 @@ void GenIntrinsicsTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
357
375
}
358
376
}
359
377
if (AllocaFound) {
360
- // LLVM default only to 10, boost to UnrollMaxCountForAlloca
361
- UP.MaxIterationsCountToAnalyze = UnrollMaxCountForAlloca;
362
378
UP.UpperBound = true ;
363
379
UP.Force = UnrollLoopForCodeSizeOnly ? false : true ;
364
380
365
- if (IGC_IS_FLAG_ENABLED (EnablePromoteLoopUnrollwithAlloca) &&
366
- ctx->type != ShaderType::OPENCL_SHADER) {
381
+ if (enablePromoteLoopUnrollwithAlloca ()){
382
+ // LLVM default only to 10, boost to UnrollMaxCountForAlloca
383
+ UP.MaxIterationsCountToAnalyze = UnrollMaxCountForAlloca;
367
384
UP.Threshold += ThresholdBoost;
368
385
LLVM_DEBUG (dbgs () << " Increasing L:" << L->getName () << " threshold to " << UP.Threshold
369
386
<< " due to Alloca accessed by:" );
@@ -648,7 +665,7 @@ llvm::InstructionCost GenIntrinsicsTTIImpl::internalCalculateCost(const User *U,
648
665
}
649
666
}
650
667
651
- if (IGC_IS_FLAG_ENABLED (EnablePromoteLoopUnrollwithAlloca )) {
668
+ if (enablePromoteLoopUnrollwithAlloca ( )) {
652
669
const GetElementPtrInst *GEP = nullptr ;
653
670
if (Operator::getOpcode (U) == Instruction::Load)
654
671
GEP = dyn_cast<GetElementPtrInst>(cast<LoadInst>(U)->getPointerOperand ());
0 commit comments