diff options
author | Joseph Tremoulet <jotrem@microsoft.com> | 2016-10-19 18:14:24 -0400 |
---|---|---|
committer | Joseph Tremoulet <jotrem@microsoft.com> | 2016-11-04 10:42:44 -0400 |
commit | 4748bb354f00b6d48aae4a85ac3b1c955e6fe0ca (patch) | |
tree | 2979b7cf1eb144242b0101962a3e5fec7391a652 | |
parent | 85559d607577c88d17d45d53f270f78e09b39f7d (diff) | |
download | coreclr-4748bb354f00b6d48aae4a85ac3b1c955e6fe0ca.tar.gz coreclr-4748bb354f00b6d48aae4a85ac3b1c955e6fe0ca.tar.bz2 coreclr-4748bb354f00b6d48aae4a85ac3b1c955e6fe0ca.zip |
Avoid clobbering FldSeq annotations in cloneExpr
The overload of cloneExpr that takes a variable number and value to
perform replacements is intended to be used by the loop unroller, which
runs between Morph (where FldSeq annotations are generated) and value
numbering (where FldSeq annotations are consumed). Update that codepath
to call `LabelIndex` when replacing a `GTF_VAR_ARR_INDEX` node, and to
avoid calling `gtFoldExpr` (which does not preserve these annotations).
Downstream constant folding should be capable of doing that optimization.
-rw-r--r-- | src/jit/gentree.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index 777ce7d2de..1ad72f02d9 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -7777,6 +7777,10 @@ GenTreePtr Compiler::gtCloneExpr( if (tree->gtLclVarCommon.gtLclNum == varNum) { copy = gtNewIconNode(varVal, tree->gtType); + if (tree->gtFlags & GTF_VAR_ARR_INDEX) + { + copy->LabelIndex(this); + } } else { @@ -8119,18 +8123,6 @@ GenTreePtr Compiler::gtCloneExpr( copy->CopyReg(tree); } - // We can call gtCloneExpr() before we have called fgMorph when we expand a GT_INDEX node in fgMorphArrayIndex() - // The method gtFoldExpr() expects to be run after fgMorph so it will set the GTF_DEBUG_NODE_MORPHED - // flag on nodes that it adds/modifies. Then when we call fgMorph we will assert. - // We really only will need to fold when this method is used to replace references to - // local variable with an integer. - // - if (varNum != (unsigned)-1) - { - /* Try to do some folding */ - copy = gtFoldExpr(copy); - } - goto DONE; } |