Skip to content

Commit

Permalink
Move assignments outside of if clause
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Hall <[email protected]>
  • Loading branch information
matthewhall2 committed Sep 19, 2024
1 parent c26e008 commit f72d540
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
6 changes: 4 additions & 2 deletions compiler/ras/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5084,7 +5084,8 @@ void TR_Debug::setupDebugger(void *startaddr, void *endaddr, bool before)
Argv[0] = "/tr/zos-tools/bin/dbxattach";
// for break_before, although command file is always the same,
// we generate it dynamically for consistency with other platforms
if (cf = fopen(cfname, "wb+"))
cf = fopen(cfname, "wb+");
if (NULL != cf)
{
fprintf(cf, "set $unsafebps\n");
fprintf(cf, "set $unsafegoto\n");
Expand Down Expand Up @@ -5115,7 +5116,8 @@ void TR_Debug::setupDebugger(void *startaddr, void *endaddr, bool before)
fclose(cf);
}
// check for dbx that cfname file could be read (dbx does not do this check)
if (cf = fopen(cfname, "r"))
cf = fopen(cfname, "r");
if (NULL != cf)
{
struct inheritance inh = { 0 }; /* use all the default inheritance stuff */
int fdCount = 0; /* inherit all file descriptors from parent */
Expand Down
15 changes: 10 additions & 5 deletions compiler/z/codegen/BinaryEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,8 @@ genericLongShiftSingle(TR::Node * node, TR::CodeGenerator * cg, TR::InstOpCode::
}
else if (firstChild->getOpCodeValue() == TR::land && firstChild->getReferenceCount() == 1)
{
if (trgReg = TR::TreeEvaluator::tryToReplaceShiftLandWithRotateInstruction(firstChild, cg, value, node->getOpCodeValue() == TR::lshl))
trgReg = TR::TreeEvaluator::tryToReplaceShiftLandWithRotateInstruction(firstChild, cg, value, node->getOpCodeValue() == TR::lshl);
if (NULL != trgReg)
{
node->setRegister(trgReg);
cg->decReferenceCount(firstChild);
Expand All @@ -1240,7 +1241,8 @@ genericLongShiftSingle(TR::Node * node, TR::CodeGenerator * cg, TR::InstOpCode::
// Generate RISBGN for (lshr + land) and (lushr + land) sequences
if (firstChild->getOpCodeValue() == TR::land && firstChild->getReferenceCount() == 1)
{
if (trgReg = TR::TreeEvaluator::tryToReplaceShiftLandWithRotateInstruction(firstChild, cg, -value, node->getOpCodeValue() == TR::lshr))
trgReg = TR::TreeEvaluator::tryToReplaceShiftLandWithRotateInstruction(firstChild, cg, -value, node->getOpCodeValue() == TR::lshr);
if (NULL != trgReg)
{
node->setRegister(trgReg);
cg->decReferenceCount(firstChild);
Expand Down Expand Up @@ -3350,7 +3352,8 @@ OMR::Z::TreeEvaluator::iandEvaluator(TR::Node * node, TR::CodeGenerator * cg)
TR::Node * firstChild = node->getFirstChild();
TR::Node * secondChild = node->getSecondChild();

if (targetRegister = genericRotateAndInsertHelper(node, cg))
targetRegister = genericRotateAndInsertHelper(node, cg);
if (NULL != targetRegister)
{
node->setRegister(targetRegister);

Expand Down Expand Up @@ -3501,7 +3504,8 @@ OMR::Z::TreeEvaluator::lorEvaluator(TR::Node * node, TR::CodeGenerator * cg)

// See if rotate-left can be used
//
if (targetRegister = genericRotateLeft(node, cg))
targetRegister = genericRotateLeft(node, cg);
if (NULL != targetRegister)
{
node->setRegister(targetRegister);

Expand Down Expand Up @@ -3604,7 +3608,8 @@ OMR::Z::TreeEvaluator::lxorEvaluator(TR::Node * node, TR::CodeGenerator * cg)

// See if rotate-left can be used
//
if (targetRegister = genericRotateLeft(node, cg))
targetRegister = genericRotateLeft(node, cg);
if (NULL != targetRegister)
{
node->setRegister(targetRegister);

Expand Down
15 changes: 10 additions & 5 deletions compiler/z/codegen/OMRMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,8 @@ OMR::Z::Machine::findBestFreeRegister(TR::Instruction *currentInstruction,
}
else
{
if (bestRegister = self()->findBestLegalEvenRegister(availRegMask))
bestRegister = self()->findBestLegalEvenRegister(availRegMask);
if (NULL != bestRegister)
// Set the pair's sibling to a high weight so that assignment to this real reg is unlikely
{
_registerFile[toRealRegister(bestRegister)->getRegisterNumber() + 1]->setWeight(S390_REGISTER_PAIR_SIBLING);
Expand Down Expand Up @@ -2161,7 +2162,8 @@ OMR::Z::Machine::findBestFreeRegister(TR::Instruction *currentInstruction,
}
else
{
if (bestRegister = self()->findBestLegalOddRegister(availRegMask))
bestRegister = self()->findBestLegalOddRegister(availRegMask);
if (NULL != bestRegister)
// Set the pair's sibling to a high weight so that assignment to this real reg is unlikely
{
_registerFile[toRealRegister(bestRegister)->getRegisterNumber() - 1]->setWeight(S390_REGISTER_PAIR_SIBLING);
Expand Down Expand Up @@ -2200,7 +2202,8 @@ OMR::Z::Machine::findBestFreeRegister(TR::Instruction *currentInstruction,
}
else
{
if (bestRegister = self()->findBestLegalSiblingFPRegister(true,availRegMask))
bestRegister = self()->findBestLegalSiblingFPRegister(true,availRegMask);
if (NULL != bestRegister)
// Set the pair's sibling to a high weight so that assignment to this real reg is unlikely
{
_registerFile[toRealRegister(bestRegister)->getRegisterNumber() + 2]->setWeight(S390_REGISTER_PAIR_SIBLING);
Expand Down Expand Up @@ -2239,7 +2242,8 @@ OMR::Z::Machine::findBestFreeRegister(TR::Instruction *currentInstruction,
}
else
{
if (bestRegister = self()->findBestLegalSiblingFPRegister(false,availRegMask))
bestRegister = self()->findBestLegalSiblingFPRegister(false,availRegMask);
if (NULL != bestRegister)
// Set the pair's sibling to a high weight so that assignment to this real reg is unlikely
{
_registerFile[toRealRegister(bestRegister)->getRegisterNumber() - 2]->setWeight(S390_REGISTER_PAIR_SIBLING);
Expand Down Expand Up @@ -3219,7 +3223,8 @@ OMR::Z::Machine::coerceRegisterAssignment(TR::Instruction
// to prevent exception in findBestSwapRegister
currentTargetVirtual->setAssignedRegister(targetRegister);

if (reg = self()->findBestSwapRegister(virtualRegister, currentTargetVirtual))
reg = self()->findBestSwapRegister(virtualRegister, currentTargetVirtual);
if (NULL != reg)
{
spareReg = reg;
}
Expand Down

0 comments on commit f72d540

Please sign in to comment.