Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove implicit sign extension assumptions from iRegStore evaluator (0.15.0) #30

Merged
merged 1 commit into from
Jul 10, 2019
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
96 changes: 32 additions & 64 deletions compiler/z/codegen/OMRTreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11995,15 +11995,27 @@ OMR::Z::TreeEvaluator::lRegLoadEvaluator(TR::Node * node, TR::CodeGenerator * cg
TR::Register *
OMR::Z::TreeEvaluator::iRegStoreEvaluator(TR::Node * node, TR::CodeGenerator * cg)
{
TR::Node * child = node->getFirstChild();
TR::Node* value = node->getFirstChild();

TR::Register* globalReg = NULL;

// If the child is an add/sub that could be used in a branch on count op, don't evaluate it here
if (isBranchOnCountAddSub(cg, value))
{
if (value->getFirstChild()->getGlobalRegisterNumber() == node->getGlobalRegisterNumber())
{
cg->decReferenceCount(value);

return globalReg;
}
}

bool needsLGFR = node->needsSignExtension();
bool useLGHI = false;
bool globalRegLive = false;
TR::Compilation *comp = cg->comp();

if (needsLGFR && child->getOpCode().isLoadConst() &&
(getIntegralValue(child)<MAX_IMMEDIATE_VAL) &&
(getIntegralValue(child)>MIN_IMMEDIATE_VAL) &&
if (needsLGFR && value->getOpCode().isLoadConst() &&
getIntegralValue(value) < MAX_IMMEDIATE_VAL &&
getIntegralValue(value) > MIN_IMMEDIATE_VAL &&
!cg->comp()->compileRelocatableCode())
{
needsLGFR = false;
Expand All @@ -12013,103 +12025,59 @@ OMR::Z::TreeEvaluator::iRegStoreEvaluator(TR::Node * node, TR::CodeGenerator * c
}
}

bool noLGFgenerated =true;
bool childEvaluatedPreviously = child->getRegister() != NULL;
bool noLGFgenerated = true;

if (needsLGFR && child->getOpCode().isLoadVar() && (child->getRegister()==NULL) && child->getType().isInt32())
if (needsLGFR && value->getOpCode().isLoadVar() && value->getRegister() == NULL && value->getType().isInt32())
{
child->setSignExtendTo64BitAtSource(true);
child->setUseSignExtensionMode(true);
value->setSignExtendTo64BitAtSource(true);
value->setUseSignExtensionMode(true);
noLGFgenerated =false;
}

TR::Register * globalReg;
TR_GlobalRegisterNumber globalRegNum = node->getGlobalRegisterNumber();

// If the child is an add/sub that could be used in a branch on count op, don't evaluate it here
if (isBranchOnCountAddSub(cg, child))
{
TR::Node *regLoad = child->getFirstChild();
if (regLoad->getGlobalRegisterNumber() == globalRegNum)
{
cg->decReferenceCount(child);
return NULL;
}
}

if (!useLGHI)
{
globalReg = cg->evaluate(child);
globalReg = cg->evaluate(value);
}
else
{
globalReg = child->getRegister();
globalReg = value->getRegister();
if (globalReg == NULL)
{
globalReg = child->setRegister(cg->allocateRegister());
globalReg = value->setRegister(cg->allocateRegister());
}
globalReg->setIs64BitReg(true);
genLoadLongConstant(cg, child, getIntegralValue(child), globalReg);
genLoadLongConstant(cg, value, getIntegralValue(value), globalReg);
}

// Without extensive evaluation of children & context, assume that we might have swapped signs
globalReg->resetAlreadySignExtended();

// LGB generated for TR::bloadi or LLGH generated for TR::cloadi sign extend implicitly
bool child_sign_extended = ((child->getOpCodeValue() == TR::b2i) && (child->getFirstChild()->getOpCodeValue() == TR::bloadi)) ||
((child->getOpCodeValue() == TR::su2i) && (child->getFirstChild()->getOpCodeValue() == TR::cloadi)) ||
((child->getOpCodeValue() == TR::l2i) && (child->getFirstChild()->getOpCodeValue() == TR::i2l));

if (needsLGFR)
{
if ((noLGFgenerated) && (!child_sign_extended))
if (noLGFgenerated)
{
generateRRInstruction(cg, TR::InstOpCode::LGFR, node, globalReg, globalReg);
}
static char * noMarkRegister = feGetEnv("TR_NRECORDLGFR");
if (noMarkRegister == NULL)
{
globalReg->setAlreadySignExtended();
} // any i2l using this reg will now be a nop
}

TR::Node * symNode = node->getFirstChild();
while (symNode->isUnneededConversion())
{
symNode = symNode->getFirstChild();
globalReg->setAlreadySignExtended();
}

cg->decReferenceCount(child);
cg->decReferenceCount(value);

return globalReg;
}

TR::Register *
OMR::Z::TreeEvaluator::lRegStoreEvaluator(TR::Node * node, TR::CodeGenerator * cg)
{
TR::Node * child = node->getFirstChild();
TR::Register * globalReg;
TR::Compilation *comp = cg->comp();
bool childEvaluatedPreviously = child->getRegister() != NULL;
TR::RegisterPair *globalPair=NULL;
TR::Register *globalRegLow;
TR::Register *globalRegHigh;

TR_GlobalRegisterNumber globalRegNum = node->getGlobalRegisterNumber();

globalReg = cg->evaluate(child);
TR::Node* value = node->getFirstChild();

globalPair = globalReg->getRegisterPair();
if(globalPair)
{
globalRegLow=globalPair->getLowOrder();
globalRegHigh=globalPair->getHighOrder();
}
TR::Register* globalReg = cg->evaluate(value);

// GRA needs to tell LRA about the register type
globalReg->setIs64BitReg(true);

cg->decReferenceCount(child);
cg->decReferenceCount(value);

return globalReg;
}
Expand Down