Skip removed loops in `optBlockIsLoopEntry`
authorJoseph Tremoulet <jotrem@microsoft.com>
Fri, 14 Oct 2016 18:08:48 +0000 (14:08 -0400)
committerJoseph Tremoulet <jotrem@microsoft.com>
Mon, 31 Oct 2016 19:12:56 +0000 (15:12 -0400)
This allows running this utility downstream of loop unrolling.

Commit migrated from https://github.com/dotnet/coreclr/commit/77398bcc4f1a54222f7fb71a48bdc4ad32618e37

src/coreclr/src/jit/optimizer.cpp

index fdcd1d1..2273753 100644 (file)
@@ -6765,15 +6765,17 @@ void Compiler::fgCreateLoopPreHeader(unsigned lnum)
 
 bool Compiler::optBlockIsLoopEntry(BasicBlock* blk, unsigned* pLnum)
 {
-    unsigned lnum = blk->bbNatLoopNum;
-    while (lnum != BasicBlock::NOT_IN_LOOP)
+    for (unsigned lnum = blk->bbNatLoopNum; lnum != BasicBlock::NOT_IN_LOOP; lnum = optLoopTable[lnum].lpParent)
     {
+        if (optLoopTable[lnum].lpFlags & LPFLG_REMOVED)
+        {
+            continue;
+        }
         if (optLoopTable[lnum].lpEntry == blk)
         {
             *pLnum = lnum;
             return true;
         }
-        lnum = optLoopTable[lnum].lpParent;
     }
     return false;
 }