Fix flag check when morphing into rotate
authorMichelle McDaniel <adiaaida@gmail.com>
Tue, 25 Oct 2016 17:09:06 +0000 (10:09 -0700)
committerMichelle McDaniel <adiaaida@gmail.com>
Tue, 25 Oct 2016 17:12:36 +0000 (10:12 -0700)
When we morphed a tree into a rotate, we assumed that the parent's flags
would be the same as its operands' flags, when in actuality, the parent's
flags should be a superset of its operands' flags. This change fixes the
flag check.

Fixes VSO 278374.

Commit migrated from https://github.com/dotnet/coreclr/commit/650358779c1d0f3cca92bf599aaf249773a9b554

src/coreclr/src/jit/morph.cpp

index b55c24a..ef7bd7d 100644 (file)
@@ -14339,7 +14339,15 @@ GenTreePtr Compiler::fgRecognizeAndMorphBitwiseRotation(GenTreePtr tree)
                 tree->gtOp.gtOp1 = rotatedValue;
                 tree->gtOp.gtOp2 = rotateIndex;
                 tree->ChangeOper(rotateOp);
-                noway_assert(inputTreeEffects == ((rotatedValue->gtFlags | rotateIndex->gtFlags) & GTF_ALL_EFFECT));
+
+                unsigned childFlags = 0;
+                for (GenTree* op : tree->Operands())
+                {
+                    childFlags |= (op->gtFlags & GTF_ALL_EFFECT);
+                }
+
+                // The parent's flags should be a superset of its operands' flags
+                noway_assert((inputTreeEffects & childFlags) == childFlags);
             }
             else
             {