PPC [simd]: Implement vector population count

Change-Id: I88af87b611415753d1063d0b203f3c846fdecd57
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2778082
Reviewed-by: Junliang Yan <junyan@redhat.com>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/master@{#73579}
This commit is contained in:
Milad Fa 2021-03-22 12:47:31 -04:00 committed by Commit Bot
parent a33c82553d
commit 690636c041
6 changed files with 21 additions and 4 deletions

View File

@ -2424,7 +2424,9 @@ using Instr = uint32_t;
/* Vector Unpack Low Signed Byte */ \
V(vupklsb, VUPKLSB, 0x1000028E) \
/* Vector Unpack High Signed Byte */ \
V(vupkhsb, VUPKHSB, 0x1000020E)
V(vupkhsb, VUPKHSB, 0x1000020E) \
/* Vector Population Count Byte */ \
V(vpopcntb, VPOPCNTB, 0x10000703)
#define PPC_VX_OPCODE_UNUSED_LIST(V) \
/* Decimal Add Modulo */ \
@ -2503,8 +2505,6 @@ using Instr = uint32_t;
V(vpmsumh, VPMSUMH, 0x10000448) \
/* Vector Polynomial Multiply-Sum Word */ \
V(vpmsumw, VPMSUMW, 0x10000488) \
/* Vector Population Count Byte */ \
V(vpopcntb, VPOPCNTB, 0x10000703) \
/* Vector Population Count Doubleword */ \
V(vpopcntd, VPOPCNTD, 0x100007C3) \
/* Vector Population Count Halfword */ \

View File

@ -3823,6 +3823,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vinsertd(dst, kScratchSimd128Reg, Operand(lane_number));
break;
}
case kPPC_I8x16Popcnt: {
__ vpopcntb(i.OutputSimd128Register(), i.InputSimd128Register(0));
break;
}
case kPPC_StoreCompressTagged: {
ASSEMBLE_STORE_INTEGER(StoreTaggedField, StoreTaggedFieldX);
break;

View File

@ -386,6 +386,7 @@ namespace compiler {
V(PPC_I8x16Shuffle) \
V(PPC_I8x16Swizzle) \
V(PPC_I8x16BitMask) \
V(PPC_I8x16Popcnt) \
V(PPC_I64x2AllTrue) \
V(PPC_I32x4AllTrue) \
V(PPC_I16x8AllTrue) \

View File

@ -309,6 +309,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kPPC_I8x16Shuffle:
case kPPC_I8x16Swizzle:
case kPPC_I8x16BitMask:
case kPPC_I8x16Popcnt:
case kPPC_I64x2AllTrue:
case kPPC_I32x4AllTrue:
case kPPC_I16x8AllTrue:

View File

@ -2293,6 +2293,7 @@ void InstructionSelector::VisitInt64AbsWithOverflow(Node* node) {
V(I16x8Abs) \
V(I8x16Neg) \
V(I8x16Abs) \
V(I8x16Popcnt) \
V(I16x8SConvertI8x16Low) \
V(I16x8SConvertI8x16High) \
V(I16x8UConvertI8x16Low) \
@ -2489,7 +2490,6 @@ void InstructionSelector::VisitS128Const(Node* node) {
}
}
void InstructionSelector::VisitI8x16Popcnt(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI64x2GtS(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI64x2GeS(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI64x2Abs(Node* node) { UNIMPLEMENTED(); }

View File

@ -4842,6 +4842,17 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
break;
}
#undef VECTOR_ROUNDING_AVERAGE
case VPOPCNTB: {
int t = instr->RTValue();
int b = instr->RBValue();
FOR_EACH_LANE(i, uint8_t) {
set_simd_register_by_lane<uint8_t>(
t, i,
base::bits::CountPopulation(
get_simd_register_by_lane<uint8_t>(b, i)));
}
break;
}
#undef FOR_EACH_LANE
#undef DECODE_VX_INSTRUCTION
#undef GET_ADDRESS