@@ -552,11 +552,11 @@ MDNode *LoopInfo::createMetadata(
552552 }
553553
554554 // Setting max_concurrency attribute with number of threads
555- if (Attrs.SYCLMaxConcurrencyEnable ) {
556- Metadata *Vals[] = {MDString::get (Ctx, " llvm.loop.max_concurrency.count " ),
557- ConstantAsMetadata ::get (ConstantInt::get (
558- llvm::Type::getInt32Ty (Ctx),
559- Attrs.SYCLMaxConcurrencyNThreads ))};
555+ if (Attrs.SYCLMaxConcurrencyNThreads ) {
556+ Metadata *Vals[] = {
557+ MDString ::get (Ctx, " llvm.loop.max_concurrency.count " ),
558+ ConstantAsMetadata::get ( ConstantInt::get (
559+ llvm::Type::getInt32Ty (Ctx), * Attrs.SYCLMaxConcurrencyNThreads ))};
560560 LoopProperties.push_back (MDNode::get (Ctx, Vals));
561561 }
562562
@@ -582,11 +582,11 @@ MDNode *LoopInfo::createMetadata(
582582 LoopProperties.push_back (MDNode::get (Ctx, Vals));
583583 }
584584
585- if (Attrs.SYCLMaxInterleavingEnable ) {
585+ if (Attrs.SYCLMaxInterleavingNInvocations ) {
586586 Metadata *Vals[] = {MDString::get (Ctx, " llvm.loop.max_interleaving.count" ),
587587 ConstantAsMetadata::get (ConstantInt::get (
588588 llvm::Type::getInt32Ty (Ctx),
589- Attrs.SYCLMaxInterleavingNInvocations ))};
589+ * Attrs.SYCLMaxInterleavingNInvocations ))};
590590 LoopProperties.push_back (MDNode::get (Ctx, Vals));
591591 }
592592
@@ -596,16 +596,16 @@ MDNode *LoopInfo::createMetadata(
596596 LoopProperties.push_back (MDNode::get (Ctx, Vals));
597597 }
598598
599- if (Attrs.SYCLSpeculatedIterationsEnable ) {
599+ if (Attrs.SYCLSpeculatedIterationsNIterations ) {
600600 Metadata *Vals[] = {
601601 MDString::get (Ctx, " llvm.loop.intel.speculated.iterations.count" ),
602602 ConstantAsMetadata::get (
603603 ConstantInt::get (llvm::Type::getInt32Ty (Ctx),
604- Attrs.SYCLSpeculatedIterationsNIterations ))};
604+ * Attrs.SYCLSpeculatedIterationsNIterations ))};
605605 LoopProperties.push_back (MDNode::get (Ctx, Vals));
606606 }
607607
608- for (auto &VC : Attrs.SYCLIntelFPGAVariantCount ) {
608+ for (const auto &VC : Attrs.SYCLIntelFPGAVariantCount ) {
609609 Metadata *Vals[] = {MDString::get (Ctx, VC.first ),
610610 ConstantAsMetadata::get (ConstantInt::get (
611611 llvm::Type::getInt32Ty (Ctx), VC.second ))};
@@ -622,15 +622,12 @@ LoopAttributes::LoopAttributes(bool IsParallel)
622622 UnrollAndJamEnable(LoopAttributes::Unspecified),
623623 VectorizePredicateEnable(LoopAttributes::Unspecified), VectorizeWidth(0 ),
624624 VectorizeScalable(LoopAttributes::Unspecified), InterleaveCount(0 ),
625- SYCLIInterval(0 ), SYCLMaxConcurrencyEnable(false ),
626- SYCLMaxConcurrencyNThreads(0 ), SYCLLoopCoalesceEnable(false ),
625+ SYCLIInterval(0 ), SYCLLoopCoalesceEnable(false ),
627626 SYCLLoopCoalesceNLevels(0 ), SYCLLoopPipeliningDisable(false ),
628- SYCLMaxInterleavingEnable(false ), SYCLMaxInterleavingNInvocations(0 ),
629- SYCLSpeculatedIterationsEnable(false ),
630- SYCLSpeculatedIterationsNIterations(0 ), UnrollCount(0 ),
631- UnrollAndJamCount(0 ), DistributeEnable(LoopAttributes::Unspecified),
632- PipelineDisabled(false ), PipelineInitiationInterval(0 ),
633- SYCLNofusionEnable(false ), MustProgress(false ) {}
627+ UnrollCount(0 ), UnrollAndJamCount(0 ),
628+ DistributeEnable(LoopAttributes::Unspecified), PipelineDisabled(false ),
629+ PipelineInitiationInterval(0 ), SYCLNofusionEnable(false ),
630+ MustProgress(false ) {}
634631
635632void LoopAttributes::clear () {
636633 IsParallel = false ;
@@ -640,15 +637,12 @@ void LoopAttributes::clear() {
640637 GlobalSYCLIVDepInfo.reset ();
641638 ArraySYCLIVDepInfo.clear ();
642639 SYCLIInterval = 0 ;
643- SYCLMaxConcurrencyEnable = false ;
644- SYCLMaxConcurrencyNThreads = 0 ;
640+ SYCLMaxConcurrencyNThreads.reset ();
645641 SYCLLoopCoalesceEnable = false ;
646642 SYCLLoopCoalesceNLevels = 0 ;
647643 SYCLLoopPipeliningDisable = false ;
648- SYCLMaxInterleavingEnable = false ;
649- SYCLMaxInterleavingNInvocations = 0 ;
650- SYCLSpeculatedIterationsEnable = false ;
651- SYCLSpeculatedIterationsNIterations = 0 ;
644+ SYCLMaxInterleavingNInvocations.reset ();
645+ SYCLSpeculatedIterationsNIterations.reset ();
652646 SYCLIntelFPGAVariantCount.clear ();
653647 UnrollCount = 0 ;
654648 UnrollAndJamCount = 0 ;
@@ -679,14 +673,12 @@ LoopInfo::LoopInfo(BasicBlock *Header, const LoopAttributes &Attrs,
679673 Attrs.VectorizeScalable == LoopAttributes::Unspecified &&
680674 Attrs.InterleaveCount == 0 && !Attrs.GlobalSYCLIVDepInfo .hasValue () &&
681675 Attrs.ArraySYCLIVDepInfo .empty () && Attrs.SYCLIInterval == 0 &&
682- Attrs.SYCLMaxConcurrencyEnable == false &&
676+ ! Attrs.SYCLMaxConcurrencyNThreads &&
683677 Attrs.SYCLLoopCoalesceEnable == false &&
684678 Attrs.SYCLLoopCoalesceNLevels == 0 &&
685679 Attrs.SYCLLoopPipeliningDisable == false &&
686- Attrs.SYCLMaxInterleavingEnable == false &&
687- Attrs.SYCLMaxInterleavingNInvocations == 0 &&
688- Attrs.SYCLSpeculatedIterationsEnable == false &&
689- Attrs.SYCLSpeculatedIterationsNIterations == 0 &&
680+ !Attrs.SYCLMaxInterleavingNInvocations &&
681+ !Attrs.SYCLSpeculatedIterationsNIterations &&
690682 Attrs.SYCLIntelFPGAVariantCount .empty () && Attrs.UnrollCount == 0 &&
691683 Attrs.UnrollAndJamCount == 0 && !Attrs.PipelineDisabled &&
692684 Attrs.PipelineInitiationInterval == 0 &&
@@ -1025,59 +1017,60 @@ void LoopInfoStack::push(BasicBlock *Header, clang::ASTContext &Ctx,
10251017 IntelFPGAIVDep->getArrayDecl ());
10261018
10271019 if (const auto *IntelFPGAII =
1028- dyn_cast<SYCLIntelFPGAInitiationIntervalAttr>(A))
1029- setSYCLIInterval (IntelFPGAII->getIntervalExpr ()
1030- ->getIntegerConstantExpr (Ctx)
1031- ->getSExtValue ());
1020+ dyn_cast<SYCLIntelFPGAInitiationIntervalAttr>(A)) {
1021+ const auto *CE = cast<ConstantExpr>(IntelFPGAII->getIntervalExpr ());
1022+ llvm::APSInt ArgVal = CE->getResultAsAPSInt ();
1023+ setSYCLIInterval (ArgVal.getSExtValue ());
1024+ }
10321025
10331026 if (const auto *IntelFPGAMaxConcurrency =
10341027 dyn_cast<SYCLIntelFPGAMaxConcurrencyAttr>(A)) {
1035- setSYCLMaxConcurrencyEnable ();
1036- setSYCLMaxConcurrencyNThreads (IntelFPGAMaxConcurrency->getNThreadsExpr ()
1037- -> getIntegerConstantExpr (Ctx)
1038- -> getSExtValue ());
1028+ const auto *CE =
1029+ cast<ConstantExpr> (IntelFPGAMaxConcurrency->getNThreadsExpr ());
1030+ llvm::APSInt ArgVal = CE-> getResultAsAPSInt ();
1031+ setSYCLMaxConcurrencyNThreads (ArgVal. getSExtValue ());
10391032 }
10401033
10411034 if (const auto *IntelFPGALoopCountAvg =
10421035 dyn_cast<SYCLIntelFPGALoopCountAttr>(A)) {
1043- unsigned int Count = IntelFPGALoopCountAvg-> getNTripCount ()
1044- -> getIntegerConstantExpr (Ctx)
1045- -> getSExtValue ();
1036+ const auto *CE =
1037+ cast<ConstantExpr>(IntelFPGALoopCountAvg-> getNTripCount ());
1038+ llvm::APSInt ArgVal = CE-> getResultAsAPSInt ();
10461039 const char *Var = IntelFPGALoopCountAvg->isMax ()
10471040 ? " llvm.loop.intel.loopcount_max"
10481041 : IntelFPGALoopCountAvg->isMin ()
10491042 ? " llvm.loop.intel.loopcount_min"
10501043 : " llvm.loop.intel.loopcount_avg" ;
1051- setSYCLIntelFPGAVariantCount (Var, Count );
1044+ setSYCLIntelFPGAVariantCount (Var, ArgVal. getSExtValue () );
10521045 }
10531046
10541047 if (const auto *IntelFPGALoopCoalesce =
10551048 dyn_cast<SYCLIntelFPGALoopCoalesceAttr>(A)) {
1056- if (auto *LCE = IntelFPGALoopCoalesce->getNExpr ())
1057- setSYCLLoopCoalesceNLevels (
1058- LCE->getIntegerConstantExpr (Ctx)->getSExtValue ());
1059- else
1049+ if (const auto *LCE = IntelFPGALoopCoalesce->getNExpr ()) {
1050+ const auto *CE = cast<ConstantExpr>(LCE);
1051+ llvm::APSInt ArgVal = CE->getResultAsAPSInt ();
1052+ setSYCLLoopCoalesceNLevels (ArgVal.getSExtValue ());
1053+ } else {
10601054 setSYCLLoopCoalesceEnable ();
1055+ }
10611056 }
10621057
10631058 if (isa<SYCLIntelFPGADisableLoopPipeliningAttr>(A))
10641059 setSYCLLoopPipeliningDisable ();
10651060
10661061 if (const auto *IntelFPGAMaxInterleaving =
10671062 dyn_cast<SYCLIntelFPGAMaxInterleavingAttr>(A)) {
1068- setSYCLMaxInterleavingEnable ();
1069- setSYCLMaxInterleavingNInvocations (IntelFPGAMaxInterleaving->getNExpr ()
1070- ->getIntegerConstantExpr (Ctx)
1071- ->getSExtValue ());
1063+ const auto *CE = cast<ConstantExpr>(IntelFPGAMaxInterleaving->getNExpr ());
1064+ llvm::APSInt ArgVal = CE->getResultAsAPSInt ();
1065+ setSYCLMaxInterleavingNInvocations (ArgVal.getSExtValue ());
10721066 }
10731067
10741068 if (const auto *IntelFPGASpeculatedIterations =
10751069 dyn_cast<SYCLIntelFPGASpeculatedIterationsAttr>(A)) {
1076- setSYCLSpeculatedIterationsEnable ();
1077- setSYCLSpeculatedIterationsNIterations (
1078- IntelFPGASpeculatedIterations->getNExpr ()
1079- ->getIntegerConstantExpr (Ctx)
1080- ->getSExtValue ());
1070+ const auto *CE =
1071+ cast<ConstantExpr>(IntelFPGASpeculatedIterations->getNExpr ());
1072+ llvm::APSInt ArgVal = CE->getResultAsAPSInt ();
1073+ setSYCLSpeculatedIterationsNIterations (ArgVal.getSExtValue ());
10811074 }
10821075
10831076 if (isa<SYCLIntelFPGANofusionAttr>(A))
0 commit comments