[PATCH] D15068: ScopInfo: Replace while/iterator construct with std::remove_if

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 30 13:17:33 PST 2015


On 11/30/2015 09:57 PM, Michael Kruse wrote:
> 2015-11-30 18:23 GMT+01:00 Tobias Grosser <tobias at grosser.es>:
>> This revision was automatically updated to reflect the committed changes.
>> Closed by commit rL254305: ScopInfo: Replace while/iterator construct with std::remove_if (authored by grosser).
>>
>> Changed prior to commit:
>>    http://reviews.llvm.org/D15068?vs=41367&id=41407#toc
>>
>> Repository:
>>    rL LLVM
>>
>> http://reviews.llvm.org/D15068
>>
>> Files:
>>    polly/trunk/lib/Analysis/ScopInfo.cpp
>>
>> Index: polly/trunk/lib/Analysis/ScopInfo.cpp
>> ===================================================================
>> --- polly/trunk/lib/Analysis/ScopInfo.cpp
>> +++ polly/trunk/lib/Analysis/ScopInfo.cpp
>> @@ -1464,29 +1464,17 @@
>>   void ScopStmt::dump() const { print(dbgs()); }
>>
>>   void ScopStmt::removeMemoryAccesses(MemoryAccessList &InvMAs) {
>> -
>> -  // Remove all memory accesses in @p InvMAs from this statement together
>> -  // with all scalar accesses that were caused by them. The tricky iteration
>> -  // order uses is needed because the MemAccs is a vector and the order in
>> -  // which the accesses of each memory access list (MAL) are stored in this
>> -  // vector is reversed.
>> +  // Remove all memory accesses in @p InvMAs from this statement
>> +  // together with all scalar accesses that were caused by them.
>>     for (MemoryAccess *MA : InvMAs) {
>> -    auto &MAL = *lookupAccessesFor(MA->getAccessInstruction());
>> -    MAL.reverse();
>> -
>> -    auto MALIt = MAL.begin();
>> -    auto MALEnd = MAL.end();
>> -    auto MemAccsIt = MemAccs.begin();
>> -    while (MALIt != MALEnd) {
>> -      while (*MemAccsIt != *MALIt)
>> -        MemAccsIt++;
>> -
>> -      MALIt++;
>> -      MemAccs.erase(MemAccsIt);
>> -    }
>> -
>> +    auto Predicate = [&](MemoryAccess *Acc) {
>> +      return Acc == MA ||
>> +             Acc->getAccessInstruction() == MA->getAccessInstruction();
>
> Because Acc==MA implies Acc->getAccessInstruction() ==
> MA->getAccessInstruction(), this could be simplified to just
>
> return Acc->getAccessInstruction() == MA->getAccessInstruction();

r254327.

Thank you,
Tobias


More information about the llvm-commits mailing list