Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 29 additions & 27 deletions compiler/optimizer/OMRCFGSimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ bool OMR::CFGSimplifier::simplify()

bool OMR::CFGSimplifier::simplifyIfStructure()
{
logprintf(trace(), comp()->log(), "Attempting if simpliciaton on block_%d\n", _block->getNumber());
logprintf(trace(), comp()->log(), "Attempting if simplification on block_%d\n", _block->getNumber());
// There must be exactly two successors, and they must be real blocks
//
if (_next1 == NULL || _next2 == NULL)
Expand Down Expand Up @@ -198,8 +198,9 @@ bool OMR::CFGSimplifier::hasExceptionPoint(TR::Block *block, TR::TreeTop *end)

bool OMR::CFGSimplifier::simplifyInstanceOfTestToCheckcast(bool needToDuplicateTree)
{
static char *disableSimplifyInstanceOfTestToCheckcast = feGetEnv("TR_disableSimplifyInstanceOfTestToCheckcast");
if (disableSimplifyInstanceOfTestToCheckcast != NULL)
static const char *enableSimplifyInstanceOfTestToCheckcast = feGetEnv("TR_enableSimplifyInstanceOfTestToCheckcast");

if (enableSimplifyInstanceOfTestToCheckcast == NULL)
return false;

if (comp()->getOSRMode() == TR::involuntaryOSR)
Expand Down Expand Up @@ -359,7 +360,7 @@ bool OMR::CFGSimplifier::simplifyInstanceOfTestToCheckcast(bool needToDuplicateT
//
//
// Simplification:
// BNDCHK (i, length) ----(exp edge) ------
// BNDCHK (length, i) ----(exp edge) ------
// | |
// return |
// |
Expand All @@ -369,7 +370,7 @@ bool OMR::CFGSimplifier::simplifyInstanceOfTestToCheckcast(bool needToDuplicateT
// Or,
//
// Simplification:
// BNDCHK (i, length) ----(exp edge) ------
// BNDCHK (length, i) ----(exp edge) ------
// | |
// goto ================= |
// | |
Expand All @@ -383,9 +384,10 @@ bool OMR::CFGSimplifier::simplifyInstanceOfTestToCheckcast(bool needToDuplicateT
//
bool OMR::CFGSimplifier::simplifyBoundCheckWithThrowException(bool needToDuplicateTree)
{
static char *disableSimplifyBoundCheckWithThrowException
= feGetEnv("TR_disableSimplifyBoundCheckWithThrowException");
if (disableSimplifyBoundCheckWithThrowException != NULL)
static const char *enableSimplifyBoundCheckWithThrowException
= feGetEnv("TR_enableSimplifyBoundCheckWithThrowException");

if (enableSimplifyBoundCheckWithThrowException == NULL)
return false;

OMR::Logger *log = comp()->log();
Expand Down Expand Up @@ -642,7 +644,7 @@ static bool containsIndirectOperation(TR::Compilation *comp, TR::TreeTop *treeto

bool OMR::CFGSimplifier::simplifyCondStoreSequence(bool needToDuplicateTree)
{
static char *enableSimplifyCondStoreSequence = feGetEnv("TR_enableSimplifyCondStoreSequence");
static const char *enableSimplifyCondStoreSequence = feGetEnv("TR_enableSimplifyCondStoreSequence");
if (enableSimplifyCondStoreSequence == NULL)
return false;

Expand Down Expand Up @@ -750,7 +752,7 @@ bool OMR::CFGSimplifier::simplifyCondStoreSequence(bool needToDuplicateTree)

bool OMR::CFGSimplifier::simplifySimpleStore(bool needToDuplicateTree)
{
static char *enableSimplifySimpleStore = feGetEnv("TR_enableSimplifySimpleStore");
static const char *enableSimplifySimpleStore = feGetEnv("TR_enableSimplifySimpleStore");
if (enableSimplifySimpleStore == NULL)
return false;

Expand All @@ -774,11 +776,11 @@ bool OMR::CFGSimplifier::simplifySimpleStore(bool needToDuplicateTree)
logprintf(trace(), log, " block%d triangle1: %d triangle2: %d diamond: %d\n", _block->getNumber(), triangle1,
triangle2, diamond);

static char *disableSimplifySimpleStoreTriangle = feGetEnv("TR_disableSimplifySimpleStoreTriangle");
static const char *disableSimplifySimpleStoreTriangle = feGetEnv("TR_disableSimplifySimpleStoreTriangle");
if ((triangle1 || triangle2) && disableSimplifySimpleStoreTriangle != NULL)
return false;

static char *disableSimplifySimpleStoreDiamond = feGetEnv("TR_disableSimplifySimpleStoreDiamond");
static const char *disableSimplifySimpleStoreDiamond = feGetEnv("TR_disableSimplifySimpleStoreDiamond");
if ((diamond) && disableSimplifySimpleStoreDiamond != NULL)
return false;

Expand Down Expand Up @@ -917,9 +919,9 @@ bool OMR::CFGSimplifier::simplifySimpleStore(bool needToDuplicateTree)

bool OMR::CFGSimplifier::simplifyNullToException(bool needToDuplicateTree)
{
static char *disableSimplifyExplicitNULLTest = feGetEnv("TR_disableSimplifyExplicitNULLTest");
static char *disableSimplifyNullToException = feGetEnv("TR_disableSimplifyNullToException");
if (disableSimplifyExplicitNULLTest != NULL || disableSimplifyNullToException != NULL)
static const char *enableSimplifyExplicitNULLTest = feGetEnv("TR_enableSimplifyExplicitNULLTest");
static const char *enableSimplifyNullToException = feGetEnv("TR_enableSimplifyNullToException");
if (enableSimplifyExplicitNULLTest == NULL && enableSimplifyNullToException == NULL)
return false;

if (comp()->getOSRMode() == TR::involuntaryOSR)
Expand Down Expand Up @@ -951,7 +953,7 @@ bool OMR::CFGSimplifier::simplifyNullToException(bool needToDuplicateTree)
return false;

if (!performTransformation(comp(),
"%sReplace ifacmpeq/ifacmpne of NULL node n%dn [%p] to a blcok ending in throw with a NULLCHK to a catch "
"%sReplace ifacmpeq/ifacmpne of NULL node n%dn [%p] to a block ending in throw with a NULLCHK to a catch "
"which goes to block_%d\n",
OPT_DETAILS, compareNode->getGlobalIndex(), compareNode, nullBlock->getNumber()))
return false;
Expand Down Expand Up @@ -1052,8 +1054,8 @@ static bool checkEquivalentIndirectLoadChain(TR::Node *lhs, TR::Node *rhs)
//
bool OMR::CFGSimplifier::simplifyBooleanStore(bool needToDuplicateTree)
{
static char *enableSimplifyBooleanStore = feGetEnv("TR_enableSimplifyBooleanStore");
if (enableSimplifyBooleanStore == NULL)
static const char *disableSimplifyBooleanStore = feGetEnv("TR_disableSimplifyBooleanStore");
if (disableSimplifyBooleanStore != NULL)
return false;

if (!(comp()->cg()->getSupportsSelect()))
Expand Down Expand Up @@ -1105,15 +1107,6 @@ bool OMR::CFGSimplifier::simplifyBooleanStore(bool needToDuplicateTree)
return false;
logprintf(trace(), log, " Successor block_%d is single store\n", _next2->getNumber());

// Store values cannot be internal pointers
//
int32_t valueIndex = store1->getOpCode().isIndirect() ? 1 : 0;
TR::Node *value1 = store1->getChild(valueIndex);
TR::Node *value2 = store2->getChild(valueIndex);
if (value1->isInternalPointer() || value2->isInternalPointer())
return false;
logprints(trace(), log, " Store values are not internal pointers\n");

// The stores must be integer stores to the same variable
//
if (store1->getOpCodeValue() != store2->getOpCodeValue())
Expand All @@ -1124,6 +1117,15 @@ bool OMR::CFGSimplifier::simplifyBooleanStore(bool needToDuplicateTree)
return false;
logprints(trace(), log, " Store nodes opcode and symref checks out\n");

// Store values cannot be internal pointers
//
int32_t valueIndex = store1->getOpCode().isIndirect() ? 1 : 0;
TR::Node *value1 = store1->getChild(valueIndex);
TR::Node *value2 = store2->getChild(valueIndex);
if (value1->isInternalPointer() || value2->isInternalPointer())
return false;
logprints(trace(), log, " Store values are not internal pointers\n");

// Indirect stores must have the same base
//
if (valueIndex == 1) // indirect store, check base objects
Expand Down