summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPat Gavlin <pgavlin@gmail.com>2016-07-13 15:11:13 -0700
committerGitHub <noreply@github.com>2016-07-13 15:11:13 -0700
commitec23a84b3cf065ad35a8f3bcf44554674241b799 (patch)
tree7cd42afde29870f444f11d4f203ea90f28894d21
parent8aa21531be9676335d53a79bb4baed0c5de04316 (diff)
parentc30ee385bc69e677c29a3907daa4a460a20c6b5a (diff)
downloadcoreclr-ec23a84b3cf065ad35a8f3bcf44554674241b799.tar.gz
coreclr-ec23a84b3cf065ad35a8f3bcf44554674241b799.tar.bz2
coreclr-ec23a84b3cf065ad35a8f3bcf44554674241b799.zip
Merge pull request #6254 from pgavlin/RemoveRenameUpdatedVars
Remove RenameUpdatedVars.
-rw-r--r--src/jit/rationalize.cpp145
-rw-r--r--src/jit/rationalize.h12
2 files changed, 0 insertions, 157 deletions
diff --git a/src/jit/rationalize.cpp b/src/jit/rationalize.cpp
index ba81b87633..6c322fb88d 100644
--- a/src/jit/rationalize.cpp
+++ b/src/jit/rationalize.cpp
@@ -328,138 +328,6 @@ Compiler::fgInsertEmbeddedFormTemp(GenTree** ppTree, unsigned lclNum)
return stmt;
}
-//------------------------------------------------------------------------------
-// RenameUpdatedVars - detect trees that have internal assignments with preceding reads
-// of the variables being written.
-// Replace the preceding reads with references to copies made in advance
-// in order to make breaking out the assignments legal
-//------------------------------------------------------------------------------
-
-void Rationalizer::RenameUpdatedVars(Location loc)
-{
- // A variable which is assigned within the tree will have different
- // values at different points in the tree. The rationalizer tries to
- // break internal assignments out into their own tree and place those trees before
- // the original tree. This could result in changed meaning unless
- // we have a way of differentiating between original and modified values
-
- GenTree *statement = loc.tree;
- assert(statement->IsStatement());
-
- GenTree *tree = loc.tree->gtStmt.gtStmtExpr;
-
- use->ZeroAll();
- usedef->ZeroAll();
- rename->ZeroAll();
- unexp->ZeroAll();
-
- int *renameMap = (int *) alloca(sizeof(int) * comp->lvaCount);
- var_types *renameTypeMap = (var_types *) alloca(sizeof(var_types) * comp->lvaCount);
-
- // find locals that are redefined within the tree
- foreach_treenode_execution_order(tree, statement)
- {
- if (tree->IsLocal())
- {
- int varIdx = tree->gtLclVarCommon.gtLclNum;
- if (tree->gtFlags & GTF_VAR_DEF // definition
- || tree->gtFlags & GTF_VAR_USEDEF // this is a use/def as in x=x+y (only the lhs x is tagged)
- || tree->gtFlags & GTF_VAR_USEASG)// this is a use/def for a x<op>=y
- {
- if (use->testBit(varIdx))
- {
- usedef->setBit(varIdx);
- }
- else
- {
- unexp->setBit(varIdx);
- }
- }
- else
- {
- if (usedef->testBit(varIdx))
- {
- rename->setBit(varIdx);
- renameTypeMap[varIdx] = tree->TypeGet();
- }
- else
- {
- use->setBit(varIdx); // it's a plain use
- }
- }
- }
- }
-
- if (!rename->anySet())
- return;
-
- indexType index;
-
- // create the new variables and establish the mapping
- // also insert copies before the statement
- FOREACH_HBV_BIT_SET(index, rename)
- {
- JITDUMP("had to rename idx:%d in tree!\n", index);
- DISPTREE(statement);
-
- unsigned tmpIndex =
- renameMap[index] =
- comp->lvaGrabTemp(true DEBUGARG("rationalize renaming"));
-
- LclVarDsc *newVar = &comp->lvaTable[tmpIndex];
-
- newVar->lvType = renameTypeMap[index];
-
- // Increment its lvRefCnt and lvRefCntWtd
- comp->lvaTable[tmpIndex].incRefCnts(loc.block->getBBWeight(comp), comp);
-
- // only need a copy for exposed uses, otherwise a def is the first occurence
- if (!unexp->testBit(index))
- {
- GenTree *write = comp->gtNewAssignNode(comp->gtNewLclvNode(renameMap[index], newVar->TypeGet()),
- comp->gtNewLclvNode((int)index, newVar->TypeGet()));
-
- write = comp->fgNewStmtFromTree(write, statement->gtStmt.gtStmtILoffsx);
- comp->fgInsertStmtBefore(loc.block, statement, write);
-
- JITDUMP("New write tree:\n");
- DISPTREE(write);
- }
- }
- NEXT_HBV_BIT_SET;
-
- hashBv *seenUse = hashBv::Create(this->comp);
- hashBv *seenRedef = hashBv::Create(this->comp);
-
- // we are looking for a def after use
- // don't just start renaming if it kicks off with a def
- foreach_treenode_execution_order(tree, statement)
- {
- if (tree->IsLocal())
- {
- int varIdx = tree->gtLclVarCommon.gtLclNum;
- if (rename->testBit(varIdx))
- {
- if (tree->gtFlags & GTF_VAR_DEF
- //|| tree->gtFlags & GTF_VAR_USEDEF
- || tree->gtFlags & GTF_VAR_USEASG)
- {
- if (seenUse->testBit(varIdx))
- seenRedef->setBit(varIdx);
- }
- else
- {
- seenUse->setBit(varIdx);
- }
- if (!seenRedef->testBit(varIdx))
- {
- tree->gtLclVarCommon.SetLclNum(renameMap[varIdx]);
- }
- }
- }
- }
-}
-
// return op that is the store equivalent of the given load opcode
genTreeOps storeForm(genTreeOps loadForm)
{
@@ -1933,23 +1801,10 @@ void Rationalizer::DoPhase()
comp->compCurBB = NULL;
comp->fgOrder = Compiler::FGOrderLinear;
- use = hashBv::Create(this->comp); // is used
- usedef = hashBv::Create(this->comp); // is used and then defined
- rename = hashBv::Create(this->comp); // is used, defined and used again
- unexp = hashBv::Create(this->comp); // is unexposed - there is a def in this tree before any uses
-
// break up the trees at side effects, etc
Location loc(comp->fgFirstBB);
while (loc.block)
{
- RenameUpdatedVars(loc);
- loc = loc.Next();
- }
-
- loc.Reset(comp);
-
- while (loc.block)
- {
loc = TreeTransformRationalization(loc);
loc = loc.Next();
}
diff --git a/src/jit/rationalize.h b/src/jit/rationalize.h
index b6f6ee752a..7d3b00b051 100644
--- a/src/jit/rationalize.h
+++ b/src/jit/rationalize.h
@@ -89,23 +89,11 @@ private:
class Rationalizer : public Phase
{
//===============================================================================
- // Data members
-
- // used for renaming updated variables
- hashBv *use;
- hashBv *usedef;
- hashBv *rename;
- hashBv *unexp;
-
-
- //===============================================================================
// Methods
public:
Rationalizer(Compiler* comp);
Location TreeTransformRationalization (Location loc);
- void RenameUpdatedVars(Location loc);
-
#ifdef DEBUG
static void ValidateStatement(Location loc);