Commit 231cdee8 authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC [simd]: Optimize vector 64x2 and 32x4 negation

vnegw and vnegd are also added to the opcode list as well
as the disassembler and the simulator.

Change-Id: I852fbe4469b2dd3c3872aa846a0b680e35e1dba6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2892630Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/master@{#74556}
parent 265e076e
...@@ -500,6 +500,9 @@ class Assembler : public AssemblerBase { ...@@ -500,6 +500,9 @@ class Assembler : public AssemblerBase {
PPC_VX_OPCODE_A_FORM_LIST(DECLARE_PPC_VX_INSTRUCTIONS_A_FORM) PPC_VX_OPCODE_A_FORM_LIST(DECLARE_PPC_VX_INSTRUCTIONS_A_FORM)
PPC_VX_OPCODE_B_FORM_LIST(DECLARE_PPC_VX_INSTRUCTIONS_B_FORM) PPC_VX_OPCODE_B_FORM_LIST(DECLARE_PPC_VX_INSTRUCTIONS_B_FORM)
PPC_VX_OPCODE_C_FORM_LIST(DECLARE_PPC_VX_INSTRUCTIONS_C_FORM) PPC_VX_OPCODE_C_FORM_LIST(DECLARE_PPC_VX_INSTRUCTIONS_C_FORM)
PPC_VX_OPCODE_D_FORM_LIST(
DECLARE_PPC_VX_INSTRUCTIONS_C_FORM) /* OPCODE_D_FORM can use
INSTRUCTIONS_C_FORM */
#undef DECLARE_PPC_VX_INSTRUCTIONS_A_FORM #undef DECLARE_PPC_VX_INSTRUCTIONS_A_FORM
#undef DECLARE_PPC_VX_INSTRUCTIONS_B_FORM #undef DECLARE_PPC_VX_INSTRUCTIONS_B_FORM
#undef DECLARE_PPC_VX_INSTRUCTIONS_C_FORM #undef DECLARE_PPC_VX_INSTRUCTIONS_C_FORM
......
...@@ -2434,6 +2434,12 @@ using Instr = uint32_t; ...@@ -2434,6 +2434,12 @@ using Instr = uint32_t;
/* Vector Population Count Byte */ \ /* Vector Population Count Byte */ \
V(vpopcntb, VPOPCNTB, 0x10000703) V(vpopcntb, VPOPCNTB, 0x10000703)
#define PPC_VX_OPCODE_D_FORM_LIST(V) \
/* Vector Negate Word */ \
V(vnegw, VNEGW, 0x10060602) \
/* Vector Negate Doubleword */ \
V(vnegd, VNEGD, 0x10070602)
#define PPC_VX_OPCODE_UNUSED_LIST(V) \ #define PPC_VX_OPCODE_UNUSED_LIST(V) \
/* Decimal Add Modulo */ \ /* Decimal Add Modulo */ \
V(bcdadd, BCDADD, 0xF0000400) \ V(bcdadd, BCDADD, 0xF0000400) \
...@@ -2590,6 +2596,7 @@ using Instr = uint32_t; ...@@ -2590,6 +2596,7 @@ using Instr = uint32_t;
PPC_VX_OPCODE_A_FORM_LIST(V) \ PPC_VX_OPCODE_A_FORM_LIST(V) \
PPC_VX_OPCODE_B_FORM_LIST(V) \ PPC_VX_OPCODE_B_FORM_LIST(V) \
PPC_VX_OPCODE_C_FORM_LIST(V) \ PPC_VX_OPCODE_C_FORM_LIST(V) \
PPC_VX_OPCODE_D_FORM_LIST(V) \
PPC_VX_OPCODE_UNUSED_LIST(V) PPC_VX_OPCODE_UNUSED_LIST(V)
#define PPC_XS_OPCODE_LIST(V) \ #define PPC_XS_OPCODE_LIST(V) \
...@@ -2923,9 +2930,19 @@ class Instruction { ...@@ -2923,9 +2930,19 @@ class Instruction {
PPC_VA_OPCODE_LIST(OPCODE_CASES) PPC_VA_OPCODE_LIST(OPCODE_CASES)
return static_cast<Opcode>(opcode); return static_cast<Opcode>(opcode);
} }
// Some VX opcodes have integers hard coded in the middle, handle those
// first.
opcode = extcode | BitField(20, 16) | BitField(10, 0);
switch (opcode) {
PPC_VX_OPCODE_D_FORM_LIST(OPCODE_CASES)
return static_cast<Opcode>(opcode);
}
opcode = extcode | BitField(10, 0); opcode = extcode | BitField(10, 0);
switch (opcode) { switch (opcode) {
PPC_VX_OPCODE_LIST(OPCODE_CASES) PPC_VX_OPCODE_A_FORM_LIST(OPCODE_CASES)
PPC_VX_OPCODE_B_FORM_LIST(OPCODE_CASES)
PPC_VX_OPCODE_C_FORM_LIST(OPCODE_CASES)
PPC_VX_OPCODE_UNUSED_LIST(OPCODE_CASES)
PPC_X_OPCODE_EH_S_FORM_LIST(OPCODE_CASES) PPC_X_OPCODE_EH_S_FORM_LIST(OPCODE_CASES)
return static_cast<Opcode>(opcode); return static_cast<Opcode>(opcode);
} }
......
...@@ -2859,24 +2859,11 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2859,24 +2859,11 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break; break;
} }
case kPPC_I64x2Neg: { case kPPC_I64x2Neg: {
constexpr int lane_width_in_bytes = 8; __ vnegd(i.OutputSimd128Register(), i.InputSimd128Register(0));
Simd128Register tempFPReg1 = i.ToSimd128Register(instr->TempAt(0));
__ li(kScratchReg, Operand(1));
__ mtvsrd(kScratchSimd128Reg, kScratchReg);
__ vinsertd(kScratchSimd128Reg, kScratchSimd128Reg,
Operand(1 * lane_width_in_bytes));
// Perform negation.
__ vnor(tempFPReg1, i.InputSimd128Register(0), i.InputSimd128Register(0));
__ vaddudm(i.OutputSimd128Register(), tempFPReg1, kScratchSimd128Reg);
break; break;
} }
case kPPC_I32x4Neg: { case kPPC_I32x4Neg: {
Simd128Register tempFPReg1 = i.ToSimd128Register(instr->TempAt(0)); __ vnegw(i.OutputSimd128Register(), i.InputSimd128Register(0));
__ li(ip, Operand(1));
__ mtvsrd(kScratchSimd128Reg, ip);
__ vspltw(kScratchSimd128Reg, kScratchSimd128Reg, Operand(1));
__ vnor(tempFPReg1, i.InputSimd128Register(0), i.InputSimd128Register(0));
__ vadduwm(i.OutputSimd128Register(), kScratchSimd128Reg, tempFPReg1);
break; break;
} }
case kPPC_I64x2Abs: { case kPPC_I64x2Abs: {
......
...@@ -408,6 +408,16 @@ void Decoder::UnknownFormat(Instruction* instr, const char* name) { ...@@ -408,6 +408,16 @@ void Decoder::UnknownFormat(Instruction* instr, const char* name) {
} }
void Decoder::DecodeExt0(Instruction* instr) { void Decoder::DecodeExt0(Instruction* instr) {
// Some encodings have integers hard coded in the middle, handle those first.
switch (EXT0 | (instr->BitField(20, 16)) | (instr->BitField(10, 0))) {
#define DECODE_VX_D_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \
case opcode_name: { \
Format(instr, #name " 'Vt, 'Vb"); \
return; \
}
PPC_VX_OPCODE_D_FORM_LIST(DECODE_VX_D_FORM__INSTRUCTIONS)
#undef DECODE_VX_D_FORM__INSTRUCTIONS
}
// Some encodings are 5-0 bits, handle those first // Some encodings are 5-0 bits, handle those first
switch (EXT0 | (instr->BitField(5, 0))) { switch (EXT0 | (instr->BitField(5, 0))) {
#define DECODE_VA_A_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \ #define DECODE_VA_A_FORM__INSTRUCTIONS(name, opcode_name, opcode_value) \
......
...@@ -4895,6 +4895,14 @@ void Simulator::ExecuteGeneric(Instruction* instr) { ...@@ -4895,6 +4895,14 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
VECTOR_UNARY_OP(float, base::RecipSqrt) VECTOR_UNARY_OP(float, base::RecipSqrt)
break; break;
} }
case VNEGW: {
VECTOR_UNARY_OP(int32_t, -)
break;
}
case VNEGD: {
VECTOR_UNARY_OP(int64_t, -)
break;
}
#undef VECTOR_UNARY_OP #undef VECTOR_UNARY_OP
#define VECTOR_ROUNDING_AVERAGE(intermediate_type, result_type) \ #define VECTOR_ROUNDING_AVERAGE(intermediate_type, result_type) \
DECODE_VX_INSTRUCTION(t, a, b, T) \ DECODE_VX_INSTRUCTION(t, a, b, T) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment