This is an archive of the discontinued LLVM Phabricator instance.

[Polly] Pass around Domain of BB to getPwAff(). NFC.
Needs ReviewPublic

Authored by nandini12396 on Jul 30 2017, 1:07 AM.

Details

Diff Detail

Event Timeline

nandini12396 created this revision.Jul 30 2017, 1:07 AM
Meinersbur added inline comments.Jul 30 2017, 2:20 PM
lib/Analysis/ScopInfo.cpp
2266–2267

Some tests fail here:

********************

Testing Time: 31.63s
********************
Failing Tests (8):
    Polly :: Isl/CodeGen/intrinsics_misc.ll
    Polly :: ScopInfo/user_provided_assumptions-in-bb-signed-conditional.ll
    Polly :: ScopInfo/user_provided_assumptions-in-bb-signed.ll
    Polly :: ScopInfo/user_provided_assumptions-in-bb-unsigned.ll
    Polly :: ScopInfo/user_provided_assumptions.ll
    Polly :: ScopInfo/user_provided_assumptions_2.ll
    Polly :: ScopInfo/user_provided_assumptions_3.ll
    Polly :: ScopInfo/user_provided_non_dominating_assumptions.ll

Before your change, buildConditionSets would ignore the Dom argument on getPwAff and instead look it up in DomainMap instead (regardless of what InScop is).

We should never pass a Context (which is a parameter set, therefore incompatible to a domain) to buildConditionSets. Instead, get the Domain of the SCoP's entry block (Which is BB here).

Hello,

Thank you for your comments and sorry for being late on this.
I addressed your remark but some tests still fail. I have no idea why? Could you please have a look.

lib/Support/SCEVAffinator.cpp
115–116

I dont think we can eliminate use of BB here.

Meinersbur edited edge metadata.Aug 2 2017, 8:57 AM

The problem is, with InScop==true, buildConditionSets expects a domain, but with InScop==false it expects a context (a parameter set). With the change below we can make it always expect a domain.

diff --git a/lib/Analysis/ScopInfo.cpp b/lib/Analysis/ScopInfo.cpp
index 76c82fce..4db232d9 100644
--- a/lib/Analysis/ScopInfo.cpp
+++ b/lib/Analysis/ScopInfo.cpp
@@ -1633,8 +1633,10 @@ buildConditionSets(Scop &S, BasicBlock *BB, Value *Condition,

   // If no terminator was given we are only looking for parameter constraints
   // under which @p Condition is true/false.
-  if (!TI)
+  if (!TI) {
     ConsequenceCondSet = isl_set_params(ConsequenceCondSet);
+    Domain = Domain.params();
+  }
   assert(ConsequenceCondSet);
   ConsequenceCondSet =
       isl_set_coalesce(isl_set_intersect(ConsequenceCondSet, Domain.copy()));
@@ -2261,7 +2263,7 @@ void Scop::addUserAssumptions(
     SmallVector<isl_set *, 2> ConditionSets;
     auto *TI = InScop ? CI->getParent()->getTerminator() : nullptr;
     BasicBlock *BB = InScop ? CI->getParent() : getRegion().getEntry();
-    isl::set Dom = DomainMap[BB];
+    isl::set Dom = DomainMap[BB].intersect_params(give(isl_set_copy(Context)));
     assert(Dom && "Cannot propagate a nullptr.");
     bool Valid = buildConditionSets(*this, BB, Val, TI, L, Dom,
                                     InvalidDomainMap[BB], ConditionSets);
diff --git a/test/ScopInfo/user_provided_assumptions_2.ll b/test/ScopInfo/user_provided_assumptions_2.ll
index 4636ef41..fefcb6a1 100644
--- a/test/ScopInfo/user_provided_assumptions_2.ll
+++ b/test/ScopInfo/user_provided_assumptions_2.ll
@@ -2,7 +2,7 @@
 ; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s --check-prefix=SCOP
 ;
 ; CHECK:      remark: <unknown>:0:0: SCoP begins here.
-; CHECK-NEXT: remark: <unknown>:0:0: Use user assumption: { : }
+; CHECK-NEXT: remark: <unknown>:0:0: Use user assumption: [N] -> { : }
 ; CHECK-NEXT: remark: <unknown>:0:0: SCoP ends here.

 ; SCOP:      Context:

However, I am not 100% sure whether this is a correct solution. @grosser may have an opinion.

Alternatively, we can make buildConditionSets take accept two parameters: One is the domain of BB (as Dom in the current state of the patch), and another which is either the domain of BB or the context, depending on InScop (as Dom in the original code).

lib/Support/SCEVAffinator.cpp
115–116

You could set this->BB by other means (e.g. In the constructor of SCEVAffinator), but I think that's not important for this patch.

@Meinersbur : I dont know what to do with the Context in buildConditionSets(). Could you please suggest?

@Meinersbur : I dont know what to do with the Context in buildConditionSets(). Could you please suggest?

Why do you need to do something with Context in buildConditionSets()?

lib/Analysis/ScopInfo.cpp
1431

[Nit] indention