Skip to content

Commit

Permalink
Fold code assuming MemToMemVarLenMacroOp::needsLoop is always true
Browse files Browse the repository at this point in the history
* Remove the function MemToMemVarLenMacroOp::needsLoop()
* Fold code that references it assuming it is always true

Signed-off-by: Daryl Maier <maier@ca.ibm.com>
  • Loading branch information
0xdaryl committed Jun 14, 2019
1 parent 073acff commit 7103275
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
13 changes: 10 additions & 3 deletions compiler/z/codegen/OMRTreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9995,6 +9995,13 @@ OMR::Z::TreeEvaluator::BBEndEvaluator(TR::Node * node, TR::CodeGenerator * cg)
} \
}

#define AlwaysClobberRegisterForLoops(evaluateChildren,baseAddr,baseReg) \
{ if (evaluateChildren) \
{ \
baseReg = cg->gprClobberEvaluate(baseAddr); \
} \
}

///////////////////////////////////////////////////////////////////////////////////////

TR::Register *
Expand Down Expand Up @@ -11121,7 +11128,7 @@ OMR::Z::TreeEvaluator::arraysetEvaluator(TR::Node * node, TR::CodeGenerator * cg
if (isZero)
{
MemClearVarLenMacroOp op(node, baseAddr, cg, elemsRegister, elemsExpr, lenMinusOne);
ClobberRegisterForLoops(evaluateChildren, op, baseAddr, baseReg);
AlwaysClobberRegisterForLoops(evaluateChildren, baseAddr, baseReg);
op.setUseEXForRemainder(true);
op.generate(baseReg);
}
Expand All @@ -11130,14 +11137,14 @@ OMR::Z::TreeEvaluator::arraysetEvaluator(TR::Node * node, TR::CodeGenerator * cg
if (useMVI)
{
MemInitVarLenMacroOp op(node, baseAddr, cg, elemsRegister, constExpr->getByte(), elemsExpr, lenMinusOne);
ClobberRegisterForLoops(evaluateChildren, op, baseAddr, baseReg);
AlwaysClobberRegisterForLoops(evaluateChildren, baseAddr, baseReg);
op.setUseEXForRemainder(true);
op.generate(baseReg);
}
else
{
MemInitVarLenMacroOp op(node, baseAddr, cg, elemsRegister, constExprRegister, elemsExpr, lenMinusOne);
ClobberRegisterForLoops(evaluateChildren, op, baseAddr, baseReg);
AlwaysClobberRegisterForLoops(evaluateChildren, baseAddr, baseReg);
op.setUseEXForRemainder(true);
op.generate(baseReg);
}
Expand Down
14 changes: 2 additions & 12 deletions compiler/z/codegen/OpMemToMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ MemToMemVarLenMacroOp::generateLoop()
if (getKind() == MemToMemMacroOp::IsMemInit)
generateInstruction(0, 1);

if (!needsLoop()) return NULL;

TR::LabelSymbol * topOfLoop = generateLabelSymbol(_cg);
TR::LabelSymbol * bottomOfLoop = generateLabelSymbol(_cg);

Expand Down Expand Up @@ -195,11 +193,6 @@ MemToMemVarLenMacroOp::generateLoop()

return cursor;
}
bool
MemToMemVarLenMacroOp::needsLoop()
{
return true;
}

TR::Instruction *
MemToMemMacroOp::genSrcLoadAddress(int32_t offset, TR::Instruction *cursor)
Expand Down Expand Up @@ -978,7 +971,7 @@ MemToMemVarLenMacroOp::generateRemainder()

TR::Instruction* cursor = NULL;

if (!TR::Compiler->target.cpu.getSupportsArch(TR::CPU::z10) || comp->getOption(TR_DisableInlineEXTarget) || !needsLoop())
if (!TR::Compiler->target.cpu.getSupportsArch(TR::CPU::z10) || comp->getOption(TR_DisableInlineEXTarget))
{
cursor = generateInstruction(0, 1);
}
Expand All @@ -998,7 +991,7 @@ MemToMemVarLenMacroOp::generateRemainder()
}


if (TR::Compiler->target.cpu.getSupportsArch(TR::CPU::z10) && !comp->getOption(TR_DisableInlineEXTarget) && needsLoop())
if (TR::Compiler->target.cpu.getSupportsArch(TR::CPU::z10) && !comp->getOption(TR_DisableInlineEXTarget))
{
TR_ASSERT(_EXTargetLabel != NULL, "Assert: EXTarget label must not be NULL");

Expand Down Expand Up @@ -1035,9 +1028,6 @@ MemToMemVarLenMacroOp::generateRemainder()
_cursor = generateS390LabelInstruction(_cg, TR::InstOpCode::LABEL, _rootNode, remainderDoneLabel);
}

if(!needsLoop() && _doneLabel==NULL)
_startControlFlow = _cursor; // If loop was not generated there is no need for control flow

return _cursor;
}

Expand Down
2 changes: 0 additions & 2 deletions compiler/z/codegen/OpMemToMem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,6 @@ class MemToMemConstLenMacroOp : public MemToMemMacroOp

class MemToMemVarLenMacroOp : public MemToMemMacroOp
{
public:
bool needsLoop();
protected:
MemToMemVarLenMacroOp(TR::Node* rootNode, TR::Node* dstNode, TR::Node* srcNode, TR::CodeGenerator * cg, TR::Register* regLen, TR::Node * lenNode, bool lengthMinusOne=false, TR::InstOpCode::Mnemonic opcode = TR::InstOpCode::MVC, TR::Register * itersReg = 0, TR::Register * raReg = 0)
: MemToMemMacroOp(rootNode, dstNode, srcNode, cg, lenNode, itersReg), _regLen(regLen), _raReg(raReg), _doneLabel(0), _opcode(opcode), _lengthMinusOne(lengthMinusOne)
Expand Down

0 comments on commit 7103275

Please sign in to comment.