Commit 35ecf0cd authored by Milad Fa's avatar Milad Fa Committed by Commit Bot

PPC: [wasm-simd] Saturate swizzle indices to 5 bits

`vperm` indices are taken from the five least significant bits
of the input byte. We need to make sure bigger values
are saturated to 31 to make vperm select 0 as the output.

Change-Id: I27ad77684b99f32a7fd7f690dec0b127be3ad9e7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2518343Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/master@{#70957}
parent e1fd3f69
......@@ -1804,6 +1804,11 @@ void Assembler::stxvd(const Simd128Register rt, const MemOperand& dst) {
SX);
}
void Assembler::xxspltib(const Simd128Register rt, const Operand& imm) {
int TX = 1;
emit(XXSPLTIB | rt.code() * B21 | imm.immediate() * B11 | TX);
}
// Pseudo instructions.
void Assembler::nop(int type) {
Register reg = r0;
......
......@@ -1022,6 +1022,7 @@ class Assembler : public AssemblerBase {
void mtvsrdd(const Simd128Register rt, const Register ra, const Register rb);
void lxvd(const Simd128Register rt, const MemOperand& src);
void stxvd(const Simd128Register rt, const MemOperand& src);
void xxspltib(const Simd128Register rt, const Operand& imm);
// Pseudo instructions
......
......@@ -2000,7 +2000,9 @@ using Instr = uint32_t;
/* Store VSR Vector Doubleword*2 Indexed */ \
V(stxvd, STXVD, 0x7C000798) \
/* Store VSR Vector Word*4 Indexed */ \
V(stxvw, STXVW, 0x7C000718)
V(stxvw, STXVW, 0x7C000718) \
/* Vector Splat Immediate Byte */ \
V(xxspltib, XXSPLTIB, 0xF00002D1)
#define PPC_B_OPCODE_LIST(V) \
/* Branch Conditional */ \
......
......@@ -3288,10 +3288,17 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
}
case kPPC_I8x16Swizzle: {
// Reverse the input to match IBM lane numbering.
Simd128Register tempFPReg1 = i.ToSimd128Register(instr->TempAt(0));
Simd128Register dst = i.OutputSimd128Register(),
src0 = i.InputSimd128Register(0),
src1 = i.InputSimd128Register(1),
tempFPReg1 = i.ToSimd128Register(instr->TempAt(0)),
tempFPReg2 = i.ToSimd128Register(instr->TempAt(1));
// Saturate the indices to 5 bits. Input indices more than 31 should
// return 0.
__ xxspltib(tempFPReg2, Operand(31));
__ vminub(tempFPReg2, src1, tempFPReg2);
__ addi(sp, sp, Operand(-16));
__ stxvd(i.InputSimd128Register(0), MemOperand(r0, sp));
__ stxvd(src0, MemOperand(r0, sp));
__ ldbrx(r0, MemOperand(r0, sp));
__ li(ip, Operand(8));
__ ldbrx(ip, MemOperand(ip, sp));
......@@ -3301,8 +3308,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ lxvd(kScratchDoubleReg, MemOperand(r0, sp));
__ addi(sp, sp, Operand(16));
__ vxor(tempFPReg1, tempFPReg1, tempFPReg1);
__ vperm(i.OutputSimd128Register(), kScratchDoubleReg, tempFPReg1,
i.InputSimd128Register(1));
__ vperm(dst, kScratchDoubleReg, tempFPReg1, tempFPReg2);
break;
}
case kPPC_F64x2Qfma: {
......
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