@@ -590,33 +590,35 @@ void ScopStmt::buildAccesses(TempScop &tempScop, const Region &CurRegion) {
590
590
}
591
591
}
592
592
593
- isl_set *ScopStmt::toConditionSet (const Comparison &Comp,
594
- isl_space *space) const {
593
+ __isl_give isl_set *ScopStmt::buildConditionSet (const Comparison &Comp,
594
+ __isl_take isl_space *Space)
595
+ const {
596
+
595
597
isl_pw_aff *LHS = SCEVAffinator::getPwAff (this , Comp.getLHS ()->OriginalSCEV ,
596
598
0 );
597
599
isl_pw_aff *RHS = SCEVAffinator::getPwAff (this , Comp.getRHS ()->OriginalSCEV ,
598
600
0 );
599
601
600
- isl_set *set ;
602
+ isl_set *Set ;
601
603
602
604
switch (Comp.getPred ()) {
603
605
case ICmpInst::ICMP_EQ:
604
- set = isl_pw_aff_eq_set (LHS, RHS);
606
+ Set = isl_pw_aff_eq_set (LHS, RHS);
605
607
break ;
606
608
case ICmpInst::ICMP_NE:
607
- set = isl_pw_aff_ne_set (LHS, RHS);
609
+ Set = isl_pw_aff_ne_set (LHS, RHS);
608
610
break ;
609
611
case ICmpInst::ICMP_SLT:
610
- set = isl_pw_aff_lt_set (LHS, RHS);
612
+ Set = isl_pw_aff_lt_set (LHS, RHS);
611
613
break ;
612
614
case ICmpInst::ICMP_SLE:
613
- set = isl_pw_aff_le_set (LHS, RHS);
615
+ Set = isl_pw_aff_le_set (LHS, RHS);
614
616
break ;
615
617
case ICmpInst::ICMP_SGT:
616
- set = isl_pw_aff_gt_set (LHS, RHS);
618
+ Set = isl_pw_aff_gt_set (LHS, RHS);
617
619
break ;
618
620
case ICmpInst::ICMP_SGE:
619
- set = isl_pw_aff_ge_set (LHS, RHS);
621
+ Set = isl_pw_aff_ge_set (LHS, RHS);
620
622
break ;
621
623
case ICmpInst::ICMP_ULT:
622
624
case ICmpInst::ICMP_UGT:
@@ -627,17 +629,16 @@ isl_set *ScopStmt::toConditionSet(const Comparison &Comp,
627
629
llvm_unreachable (" Non integer predicate not supported" );
628
630
}
629
631
630
- set = isl_set_set_tuple_name (set, isl_space_get_tuple_name (space, isl_dim_set));
631
-
632
- return set;
632
+ return Set;
633
633
}
634
634
635
- void ScopStmt::buildIterationDomainFromLoops (TempScop &tempScop) {
636
- isl_space *Space = isl_space_set_alloc (getIslCtx (), 0 , getNumIterators ());
635
+ __isl_give isl_set *ScopStmt::addLoopBoundsToDomain (__isl_take isl_set *Domain,
636
+ TempScop &tempScop) const {
637
+ isl_space *Space;
638
+ isl_local_space *LocalSpace;
637
639
638
- Domain = isl_set_universe (isl_space_copy (Space));
639
- Domain = isl_set_align_params (Domain, Parent.getParamSpace ());
640
- isl_local_space *LocalSpace = isl_local_space_from_space (Space);
640
+ Space = isl_set_get_space (Domain);
641
+ LocalSpace = isl_local_space_from_space (Space);
641
642
642
643
for (int i = 0 , e = getNumIterators (); i != e; ++i) {
643
644
isl_aff *Zero = isl_aff_zero_on_domain (isl_local_space_copy (LocalSpace));
@@ -656,40 +657,51 @@ void ScopStmt::buildIterationDomainFromLoops(TempScop &tempScop) {
656
657
Domain = isl_set_intersect (Domain, UpperBoundSet);
657
658
}
658
659
659
- Domain = isl_set_set_tuple_name (Domain, getBaseName ());
660
660
isl_local_space_free (LocalSpace);
661
+ return Domain;
661
662
}
662
663
663
- void ScopStmt::addConditionsToDomain (TempScop &tempScop,
664
- const Region &CurRegion) {
664
+ __isl_give isl_set *ScopStmt::addConditionsToDomain (__isl_take isl_set *Domain,
665
+ TempScop &tempScop,
666
+ const Region &CurRegion)
667
+ const {
665
668
isl_space *Space = isl_set_get_space (Domain);
666
- const Region *TopR = tempScop.getMaxRegion ().getParent (),
667
- *CurR = &CurRegion;
668
- const BasicBlock *CurEntry = BB;
669
+ const Region *TopRegion = tempScop.getMaxRegion ().getParent (),
670
+ *CurrentRegion = &CurRegion;
671
+ const BasicBlock *BranchingBB = BB;
669
672
670
- // Build BB condition constrains, by traveling up the region tree.
671
673
do {
672
- assert (CurR && " We exceed the top region?" );
673
- // Skip when multiple regions share the same entry.
674
- if (CurEntry != CurR->getEntry ()) {
675
- if (const BBCond *Cnd = tempScop.getBBCond (CurEntry))
676
- for (BBCond::const_iterator I = Cnd->begin (), E = Cnd->end ();
677
- I != E; ++I) {
678
- isl_set *c = toConditionSet (*I, Space);
679
- Domain = isl_set_intersect (Domain, c);
674
+ if (BranchingBB != CurrentRegion->getEntry ()) {
675
+ if (const BBCond *Condition = tempScop.getBBCond (BranchingBB))
676
+ for (BBCond::const_iterator CI = Condition->begin (),
677
+ CE = Condition->end (); CI != CE; ++CI) {
678
+ isl_set *ConditionSet = buildConditionSet (*CI, Space);
679
+ Domain = isl_set_intersect (Domain, ConditionSet);
680
680
}
681
681
}
682
- CurEntry = CurR ->getEntry ();
683
- CurR = CurR ->getParent ();
684
- } while (TopR != CurR );
682
+ BranchingBB = CurrentRegion ->getEntry ();
683
+ CurrentRegion = CurrentRegion ->getParent ();
684
+ } while (TopRegion != CurrentRegion );
685
685
686
686
isl_space_free (Space);
687
+
688
+ return Domain;
687
689
}
688
690
689
- void ScopStmt::buildIterationDomain (TempScop &tempScop, const Region &CurRegion)
690
- {
691
- buildIterationDomainFromLoops (tempScop);
692
- addConditionsToDomain (tempScop, CurRegion);
691
+ __isl_give isl_set *ScopStmt::buildDomain (TempScop &tempScop,
692
+ const Region &CurRegion) const {
693
+ isl_space *Space;
694
+ isl_set *Domain;
695
+
696
+ Space = isl_space_set_alloc (getIslCtx (), 0 , getNumIterators ());
697
+
698
+ Domain = isl_set_universe (Space);
699
+ Domain = isl_set_align_params (Domain, Parent.getParamSpace ());
700
+ Domain = addLoopBoundsToDomain (Domain, tempScop);
701
+ Domain = addConditionsToDomain (Domain, tempScop, CurRegion);
702
+ Domain = isl_set_set_tuple_name (Domain, getBaseName ());
703
+
704
+ return Domain;
693
705
}
694
706
695
707
ScopStmt::ScopStmt (Scop &parent, TempScop &tempScop,
@@ -711,7 +723,7 @@ ScopStmt::ScopStmt(Scop &parent, TempScop &tempScop,
711
723
makeIslCompatible (BaseName);
712
724
BaseName = " Stmt_" + BaseName;
713
725
714
- buildIterationDomain (tempScop, CurRegion);
726
+ Domain = buildDomain (tempScop, CurRegion);
715
727
buildScattering (Scatter);
716
728
buildAccesses (tempScop, CurRegion);
717
729
}
0 commit comments