Clear side-effect flags on local reads in rationalize.
authorPat Gavlin <pagavlin@microsoft.com>
Tue, 25 Oct 2016 21:56:56 +0000 (14:56 -0700)
committerPat Gavlin <pagavlin@microsoft.com>
Tue, 25 Oct 2016 21:56:56 +0000 (14:56 -0700)
These operations are always side-effect free.

Commit migrated from https://github.com/dotnet/coreclr/commit/7e002fd3c5d2b01a28f6af1679d17554d88098e9

src/coreclr/src/jit/rationalize.cpp

index 42c2cf6..70d9e7a 100644 (file)
@@ -865,12 +865,18 @@ Compiler::fgWalkResult Rationalizer::RewriteNode(GenTree** useEdge, ArrayStack<G
     }
 
     // Do some extra processing on top-level nodes to remove unused local reads.
-    if (use.IsDummyUse() && node->OperIsLocalRead())
+    if (node->OperIsLocalRead())
     {
-        assert((node->gtFlags & GTF_ALL_EFFECT) == 0);
-
-        comp->lvaDecRefCnts(node);
-        BlockRange().Remove(node);
+        if (use.IsDummyUse())
+        {
+            comp->lvaDecRefCnts(node);
+            BlockRange().Remove(node);
+        }
+        else
+        {
+            // Local reads are side-effect-free; clear any flags leftover from frontend transformations.
+            node->gtFlags &= ~GTF_ALL_EFFECT;
+        }
     }
 
     assert(isLateArg == ((use.Def()->gtFlags & GTF_LATE_ARG) != 0));