From 073acffc8db8ccfd9c3fc515f12cf3db4e1a300c Mon Sep 17 00:00:00 2001 From: Daryl Maier Date: Fri, 14 Jun 2019 15:17:20 -0400 Subject: [PATCH 1/2] Remove inlineNDmemcpyWithPad and fold code assuming false This function always returns a constant false in OMR. It is not used in any known downstream projects. Remove and fold surrounding code assuming it returns false. Signed-off-by: Daryl Maier --- compiler/z/codegen/OMRCodeGenerator.cpp | 13 ++----------- compiler/z/codegen/OMRCodeGenerator.hpp | 1 - compiler/z/codegen/OpMemToMem.cpp | 11 +---------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/compiler/z/codegen/OMRCodeGenerator.cpp b/compiler/z/codegen/OMRCodeGenerator.cpp index 901dc31ed1..3aa027b09d 100644 --- a/compiler/z/codegen/OMRCodeGenerator.cpp +++ b/compiler/z/codegen/OMRCodeGenerator.cpp @@ -2258,7 +2258,7 @@ OMR::Z::CodeGenerator::doBinaryEncoding() // overload of the constructor which can accept a NULL preceding instruction. If cursor is NULL the generated // label instruction will be prepended to the start of the instruction stream. _methodBegin = new (self()->trHeapMemory()) TR::S390LabelInstruction(TR::InstOpCode::LABEL, self()->comp()->getStartTree()->getNode(), generateLabelSymbol(self()), static_cast(NULL), self()); - + _methodEnd = generateS390LabelInstruction(self(), TR::InstOpCode::LABEL, self()->comp()->findLastTree()->getNode(), generateLabelSymbol(self())); TR_S390BinaryEncodingData data; @@ -2272,7 +2272,7 @@ OMR::Z::CodeGenerator::doBinaryEncoding() if (self()->comp()->getJittedMethodSymbol()->isJNI() && !self()->comp()->getOption(TR_FullSpeedDebug)) { data.preProcInstruction = TR::Compiler->target.is64Bit() ? - data.cursorInstruction->getNext()->getNext()->getNext() : + data.cursorInstruction->getNext()->getNext()->getNext() : data.cursorInstruction->getNext()->getNext(); } else @@ -5281,15 +5281,6 @@ bool OMR::Z::CodeGenerator::IsInMemoryType(TR::DataType type) #endif } -/** - * Determine if the Left-to-right copy semantics is allowed on NDmemcpyWithPad - * Communicates with the evaluator to do MVC semantics under certain condition no matter how the overlap is - */ -bool OMR::Z::CodeGenerator::inlineNDmemcpyWithPad(TR::Node * node, int64_t * maxLengthPtr) - { - return false; - } - uint32_t getRegMaskFromRange(TR::Instruction * inst); diff --git a/compiler/z/codegen/OMRCodeGenerator.hpp b/compiler/z/codegen/OMRCodeGenerator.hpp index 0c435c66c7..6d0a947bd6 100644 --- a/compiler/z/codegen/OMRCodeGenerator.hpp +++ b/compiler/z/codegen/OMRCodeGenerator.hpp @@ -299,7 +299,6 @@ class OMR_EXTENSIBLE CodeGenerator : public OMR::CodeGenerator bool supportsLengthMinusOneForMemoryOpts() {return true;} - bool inlineNDmemcpyWithPad(TR::Node * node, int64_t * maxLengthPtr = NULL); bool codegenSupportsLoadlessBNDCheck() {return TR::Compiler->target.cpu.getSupportsArch(TR::CPU::zEC12);} TR::Register *evaluateLengthMinusOneForMemoryOps(TR::Node *, bool , bool &lenMinusOne); diff --git a/compiler/z/codegen/OpMemToMem.cpp b/compiler/z/codegen/OpMemToMem.cpp index 4880082dc5..5a649be95f 100644 --- a/compiler/z/codegen/OpMemToMem.cpp +++ b/compiler/z/codegen/OpMemToMem.cpp @@ -198,15 +198,6 @@ MemToMemVarLenMacroOp::generateLoop() bool MemToMemVarLenMacroOp::needsLoop() { - int64_t maxLength = 0; - if (_cg->inlineNDmemcpyWithPad(_rootNode, &maxLength)) - { - if (maxLength == 0 || maxLength > 256) - return true; - else - return false; - } - return true; } @@ -357,7 +348,7 @@ MemToMemConstLenMacroOp::generateLoop() uint64_t dstOffset = 0; - if (inRange && (aliasingPattern || !_cg->storageMayOverlap(_srcNode, len, _dstNode, len)) && !_cg->inlineNDmemcpyWithPad(_rootNode)) + if (inRange && (aliasingPattern || !_cg->storageMayOverlap(_srcNode, len, _dstNode, len))) { TR::InstOpCode::Mnemonic opCode = TR::InstOpCode::MVCL; From 7103275941b892496b32c536d4810866b9dbe897 Mon Sep 17 00:00:00 2001 From: Daryl Maier Date: Fri, 14 Jun 2019 16:11:37 -0400 Subject: [PATCH 2/2] Fold code assuming MemToMemVarLenMacroOp::needsLoop is always true * Remove the function MemToMemVarLenMacroOp::needsLoop() * Fold code that references it assuming it is always true Signed-off-by: Daryl Maier --- compiler/z/codegen/OMRTreeEvaluator.cpp | 13 ++++++++++--- compiler/z/codegen/OpMemToMem.cpp | 14 ++------------ compiler/z/codegen/OpMemToMem.hpp | 2 -- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/compiler/z/codegen/OMRTreeEvaluator.cpp b/compiler/z/codegen/OMRTreeEvaluator.cpp index bbb0d469b0..7375230e00 100644 --- a/compiler/z/codegen/OMRTreeEvaluator.cpp +++ b/compiler/z/codegen/OMRTreeEvaluator.cpp @@ -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 * @@ -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); } @@ -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); } diff --git a/compiler/z/codegen/OpMemToMem.cpp b/compiler/z/codegen/OpMemToMem.cpp index 5a649be95f..34c4690a8f 100644 --- a/compiler/z/codegen/OpMemToMem.cpp +++ b/compiler/z/codegen/OpMemToMem.cpp @@ -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); @@ -195,11 +193,6 @@ MemToMemVarLenMacroOp::generateLoop() return cursor; } -bool -MemToMemVarLenMacroOp::needsLoop() - { - return true; - } TR::Instruction * MemToMemMacroOp::genSrcLoadAddress(int32_t offset, TR::Instruction *cursor) @@ -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); } @@ -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"); @@ -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; } diff --git a/compiler/z/codegen/OpMemToMem.hpp b/compiler/z/codegen/OpMemToMem.hpp index f40f255c82..07c47795ca 100644 --- a/compiler/z/codegen/OpMemToMem.hpp +++ b/compiler/z/codegen/OpMemToMem.hpp @@ -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)