Skip to content

Commit

Permalink
Implement byte mask load
Browse files Browse the repository at this point in the history
- when a byte mask is loaded from a byte array the true value is represented as 1.
- expand the least significant bit so that instructions like xxsel work correctly.
  • Loading branch information
gita-omr committed Dec 9, 2024
1 parent 96d6a1d commit c013994
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions compiler/p/codegen/OMRTreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3064,6 +3064,9 @@ TR::Register *OMR::Power::TreeEvaluator::vloadEvaluator(TR::Node *node, TR::Code
TR_ASSERT_FATAL_WITH_NODE(node, node->getDataType().getVectorLength() == TR::VectorLength128,
"Only 128-bit vectors are supported %s", node->getDataType().toString());

TR_ASSERT_FATAL(!node->getDataType().isMask() || node->getDataType().getVectorElementType() == TR::Int8,
"Only load of Byte masks is currently supported"); // TODO: support other mask types

TR::InstOpCode::Mnemonic opcode;
TR_RegisterKinds kind;

Expand Down Expand Up @@ -3098,6 +3101,19 @@ TR::Register *OMR::Power::TreeEvaluator::vloadEvaluator(TR::Node *node, TR::Code

TR::LoadStoreHandler::generateLoadNodeSequence(cg, dstReg, node, opcode, 16, true);

if (node->getDataType().isMask() &&
node->getDataType().getVectorElementType() == TR::Int8)
{
// Lowest mask bit needs to be expanded to the whole mask element
TR::Register *tmpReg = cg->allocateRegister(TR_VRF);
generateTrg1ImmInstruction(cg, TR::InstOpCode::vspltisb, node, tmpReg, 15);
// move lowest bit to the sign position
generateTrg1Src2Instruction(cg, TR::InstOpCode::vslb, node, dstReg, dstReg, tmpReg);
// extend sign bit to the right
generateTrg1Src2Instruction(cg, TR::InstOpCode::vsrab, node, dstReg, dstReg, tmpReg);
cg->stopUsingRegister(tmpReg);
}

node->setRegister(dstReg);
return dstReg;
}
Expand Down

0 comments on commit c013994

Please sign in to comment.