Skip to content

Commit

Permalink
Implement vmul for type ShortVector of size 128
Browse files Browse the repository at this point in the history
Signed-off-by: midronij <jackie.midroni@ibm.com>
  • Loading branch information
midronij committed Nov 26, 2021
1 parent 08ac8e9 commit 5f7c29a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 14 deletions.
2 changes: 2 additions & 0 deletions compiler/p/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,8 @@ bool OMR::Power::CodeGenerator::getSupportsOpCodeForAutoSIMD(TR::ILOpCode opcode
else
return false;
case TR::vmul:
if (dt == TR::Int16)
return true;
case TR::vdiv:
case TR::vneg:
if (dt == TR::Int32 || dt == TR::Float || dt == TR::Double)
Expand Down
4 changes: 2 additions & 2 deletions compiler/p/codegen/OMRInstOpCode.enum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2020 IBM Corp. and others
* Copyright (c) 2019, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -711,7 +711,7 @@
vsubuws, // vector subtract unsigned word saturate
// vmhaddshs, // Vector Multiply-High-Add Signed Hword Saturate
// vmhraddshs, // Vector Multiply-High-Round-Add Signed Hword Saturate
// vmladduhm, // Vector Multiply-Low-Add Unsigned Hword Modulo
vmladduhm, // Vector Multiply-Low-Add Unsigned Hword Modulo
// vmsummbm, // Vector Multiply-Sum Mixed Byte Modulo
// vmsumshm, // Vector Multiply-Sum Signed Hword Modulo
// vmsumshs, // Vector Multiply-Sum Signed Hword Saturate
Expand Down
24 changes: 12 additions & 12 deletions compiler/p/codegen/OMRInstOpCodeProperties.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2020 IBM Corp. and others
* Copyright (c) 2019, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -8353,17 +8353,17 @@
/* PPCOpProp_SyncSideEffectFree, */
/* }, */

/* { */
/* .mnemonic = OMR::InstOpCode::vmladduhm, */
/* .name = "vmladduhm", */
/* .description = "Vector Multiply-Low-Add Unsigned Hword Modulo", */
/* .prefix = 0x00000000, */
/* .opcode = 0x10000022, */
/* .format = FORMAT_UNKNOWN, */
/* .minimumALS = OMR_PROCESSOR_PPC_P6, */
/* .properties = PPCOpProp_IsVMX | */
/* PPCOpProp_SyncSideEffectFree, */
/* }, */
{
/* .mnemonic = */ OMR::InstOpCode::vmladduhm,
/* .name = */ "vmladduhm",
/* .description = "Vector Multiply-Low-Add Unsigned Hword Modulo", */
/* .prefix = */ 0x00000000,
/* .opcode = */ 0x10000022,
/* .format = */ FORMAT_VRT_VRA_VRB_VRC,
/* .minimumALS = */ OMR_PROCESSOR_PPC_P6,
/* .properties = */ PPCOpProp_IsVMX |
PPCOpProp_SyncSideEffectFree,
},

/* { */
/* .mnemonic = OMR::InstOpCode::vmsummbm, */
Expand Down
33 changes: 33 additions & 0 deletions compiler/p/codegen/OMRTreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3466,11 +3466,44 @@ TR::Register *OMR::Power::TreeEvaluator::vmulEvaluator(TR::Node *node, TR::CodeG
return TR::TreeEvaluator::vmulFloatHelper(node,cg);
case TR::VectorDouble:
return TR::TreeEvaluator::vmulDoubleHelper(node,cg);
case TR::VectorInt16:
return TR::TreeEvaluator::vmulInt16Helper(node,cg);
default:
TR_ASSERT(false, "unrecognized vector type %s\n", node->getDataType().toString()); return NULL;
}
}

TR::Register *OMR::Power::TreeEvaluator::vmulInt16Helper(TR::Node *node, TR::CodeGenerator *cg)
{
TR::Node *firstChild;
TR::Node *secondChild;
TR::Register *lhsReg, *rhsReg;
TR::Register *productReg;
TR::Register *temp;

firstChild = node->getFirstChild();
secondChild = node->getSecondChild();
lhsReg = NULL;
rhsReg = NULL;

lhsReg = cg->evaluate(firstChild);
rhsReg = cg->evaluate(secondChild);

productReg = cg->allocateRegister(TR_VRF);
temp = cg->allocateRegister(TR_VRF);

node->setRegister(productReg);

generateTrg1ImmInstruction(cg, TR::InstOpCode::vspltish, node, temp, 0);
generateTrg1Src3Instruction(cg, TR::InstOpCode::vmladduhm, node, productReg, lhsReg, rhsReg, temp);

cg->stopUsingRegister(temp);
cg->decReferenceCount(firstChild);
cg->decReferenceCount(secondChild);

return productReg;
}

TR::Register *OMR::Power::TreeEvaluator::vmulInt32Helper(TR::Node *node, TR::CodeGenerator *cg)
{
return TR::TreeEvaluator::inlineVectorBinaryOp(node, cg, TR::InstOpCode::vmuluwm);
Expand Down
1 change: 1 addition & 0 deletions compiler/p/codegen/OMRTreeEvaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ class OMR_EXTENSIBLE TreeEvaluator: public OMR::TreeEvaluator
static TR::Register *vaddEvaluator(TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *vsubEvaluator(TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *vmulEvaluator(TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *vmulInt16Helper(TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *vmulInt32Helper(TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *vmulFloatHelper(TR::Node *node, TR::CodeGenerator *cg);
static TR::Register *vmulDoubleHelper(TR::Node *node, TR::CodeGenerator *cg);
Expand Down

0 comments on commit 5f7c29a

Please sign in to comment.