[polly] r246433 - ScopDetection: Correctly count the loops in a region

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 14:06:20 PDT 2015


On 08/31/2015 10:10 PM, Johannes Doerfert wrote:
> On 08/31, Tobias Grosser via llvm-commits wrote:
>> Author: grosser
>> Date: Mon Aug 31 07:08:11 2015
>> New Revision: 246433
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=246433&view=rev
>> Log:
>> ScopDetection: Correctly count the loops in a region
>>
>> There is no reason the loops in a region need to touch either entry or exit
>> block. Hence, we need to look through all loops that may touch the region as
>> well as their children to understand if our region has at least two loops.
>>
>> Added:
>>      polly/trunk/test/ScopDetect/more-than-one-loop.ll
>> Modified:
>>      polly/trunk/lib/Analysis/ScopDetection.cpp
>>
>> Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
>> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=246433&r1=246432&r2=246433&view=diff
>> ==============================================================================
>> --- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
>> +++ polly/trunk/lib/Analysis/ScopDetection.cpp Mon Aug 31 07:08:11 2015
>> @@ -779,19 +779,24 @@ bool ScopDetection::isValidLoop(Loop *L,
>>   }
>>
>>   bool ScopDetection::hasMoreThanOneLoop(Region *R) const {
>> -  Loop *EntryLoop = LI->getLoopFor(R->getEntry());
>> -  if (!EntryLoop)
>> -    return false;
>> -
>> -  if (!EntryLoop->getSubLoops().empty())
>> -    return true;
>> -
>> -  for (pred_iterator PI = pred_begin(R->getExit()), PE = pred_end(R->getExit());
>> -       PI != PE; ++PI)
>> -    if (R->contains(*PI))
>> -      if (EntryLoop != LI->getLoopFor(*PI))
>> -        return true;
>> +  auto LoopNum = 0;
>> +
>> +  auto L = LI->getLoopFor(R->getEntry());
>> +  L = L ? R->outermostLoopInRegion(L) : nullptr;
>> +  L = L ? L->getParentLoop() : nullptr;
>> +
>> +  auto SubLoops =
>> +      L ? L->getSubLoopsVector() : std::vector<Loop *>(LI->begin(), LI->end());
>>
>> +  for (auto &SubLoop : SubLoops)
>> +    if (R->contains(SubLoop)) {
>> +      LoopNum++;
>> +      if (SubLoop > 0)
> SubLoop : Loop *
>
> -      if (SubLoop > 0)
> +      if (SubLoop->getSubLoops().size())
>
> See also:
>    llvm/tools/polly/lib/Analysis/ScopDetection.cpp:794:21: warning:
>    ordered comparison of pointer with integer zero [-Wextra]
>      if (SubLoop > 0)

Fixed in r246483. Thank you!

Tobias


More information about the llvm-commits mailing list