Skip to content

Commit

Permalink
Reland "[wasm-simd][liftoff][ia32][x64] Implement bitmask"
Browse files Browse the repository at this point in the history
This relands commit d04b5e4.

The fix here is in the assembler for pmovmskb, emit_optional_rex_32 should be
called after emitting the prefix byte.

Original change's description:
> [wasm-simd][liftoff][ia32][x64] Implement bitmask
>
> Implements i8x16 i16x8 i32x4 bitmask.
>
> This was merged into the proposal in
> WebAssembly/simd#201.
>
> Bug: v8:9909,v8:10308
> Change-Id: I882f0c2697213cdf593e745112e0897cee252009
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2222607
> Commit-Queue: Zhi An Ng <[email protected]>
> Reviewed-by: Clemens Backes <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#68090}

Bug: v8:9909, v8:10308
Change-Id: I4897585c86b87f72dc8f142b275171276d135a24
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2225090
Reviewed-by: Clemens Backes <[email protected]>
Commit-Queue: Zhi An Ng <[email protected]>
Cr-Commit-Position: refs/heads/master@{#68106}
  • Loading branch information
ngzhian authored and Commit Bot committed Jun 2, 2020
1 parent a16ad72 commit aa5bcc0
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/codegen/x64/assembler-x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3450,8 +3450,8 @@ void Assembler::movmskps(Register dst, XMMRegister src) {

void Assembler::pmovmskb(Register dst, XMMRegister src) {
EnsureSpace ensure_space(this);
emit_optional_rex_32(dst, src);
emit(0x66);
emit_optional_rex_32(dst, src);
emit(0x0F);
emit(0xD7);
emit_sse_operand(dst, src);
Expand Down
15 changes: 15 additions & 0 deletions src/wasm/baseline/arm/liftoff-assembler-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2573,6 +2573,11 @@ void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst,
mov(dst.gp(), Operand(1), LeaveCC, ne);
}

void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i32x4_bitmask");
}

void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::kLeft, NeonS32, Neon32>(this, dst, lhs, rhs);
Expand Down Expand Up @@ -2682,6 +2687,11 @@ void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst,
mov(dst.gp(), Operand(1), LeaveCC, ne);
}

void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i16x8_bitmask");
}

void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::kLeft, NeonS16, Neon16>(this, dst, lhs, rhs);
Expand Down Expand Up @@ -2864,6 +2874,11 @@ void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst,
mov(dst.gp(), Operand(1), LeaveCC, ne);
}

void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i8x16_bitmask");
}

void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::kLeft, NeonS8, Neon8>(this, dst, lhs, rhs);
Expand Down
15 changes: 15 additions & 0 deletions src/wasm/baseline/arm64/liftoff-assembler-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,11 @@ void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue(this, dst, src, kFormat4S);
}

void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i32x4_bitmask");
}

void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::ShiftDirection::kLeft>(
Expand Down Expand Up @@ -1634,6 +1639,11 @@ void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue(this, dst, src, kFormat8H);
}

void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i16x8_bitmask");
}

void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::ShiftDirection::kLeft>(
Expand Down Expand Up @@ -1779,6 +1789,11 @@ void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue(this, dst, src, kFormat16B);
}

void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
bailout(kSimd, "i8x16_bitmask");
}

void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShift<liftoff::ShiftDirection::kLeft>(
Expand Down
18 changes: 18 additions & 0 deletions src/wasm/baseline/ia32/liftoff-assembler-ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -2552,6 +2552,11 @@ void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqb>(this, dst, src);
}

void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
Pmovmskb(dst.gp(), src.fp());
}

void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
static constexpr RegClass tmp_rc = reg_class_for(ValueType::kI32);
Expand Down Expand Up @@ -2790,6 +2795,14 @@ void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqw>(this, dst, src);
}

void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
XMMRegister tmp = liftoff::kScratchDoubleReg;
Packsswb(tmp, src.fp());
Pmovmskb(dst.gp(), tmp);
shr(dst.gp(), 8);
}

void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShiftOp<&Assembler::vpsllw, &Assembler::psllw, 4>(this, dst,
Expand Down Expand Up @@ -2924,6 +2937,11 @@ void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqd>(this, dst, src);
}

void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
Movmskps(dst.gp(), src.fp());
}

void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShiftOp<&Assembler::vpslld, &Assembler::pslld, 5>(this, dst,
Expand Down
3 changes: 3 additions & 0 deletions src/wasm/baseline/liftoff-assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ class LiftoffAssembler : public TurboAssembler {
inline void emit_i8x16_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v8x16_anytrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v8x16_alltrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i8x16_bitmask(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs);
inline void emit_i8x16_shli(LiftoffRegister dst, LiftoffRegister lhs,
Expand Down Expand Up @@ -859,6 +860,7 @@ class LiftoffAssembler : public TurboAssembler {
inline void emit_i16x8_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v16x8_anytrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v16x8_alltrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i16x8_bitmask(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs);
inline void emit_i16x8_shli(LiftoffRegister dst, LiftoffRegister lhs,
Expand Down Expand Up @@ -900,6 +902,7 @@ class LiftoffAssembler : public TurboAssembler {
inline void emit_i32x4_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v32x4_anytrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v32x4_alltrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i32x4_bitmask(LiftoffRegister dst, LiftoffRegister src);
inline void emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs);
inline void emit_i32x4_shli(LiftoffRegister dst, LiftoffRegister lhs,
Expand Down
6 changes: 6 additions & 0 deletions src/wasm/baseline/liftoff-compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2585,6 +2585,8 @@ class LiftoffCompiler {
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v8x16_anytrue);
case wasm::kExprV8x16AllTrue:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v8x16_alltrue);
case wasm::kExprI8x16BitMask:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_i8x16_bitmask);
case wasm::kExprI8x16Shl:
return EmitSimdShiftOp(&LiftoffAssembler::emit_i8x16_shl,
&LiftoffAssembler::emit_i8x16_shli);
Expand Down Expand Up @@ -2626,6 +2628,8 @@ class LiftoffCompiler {
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v16x8_anytrue);
case wasm::kExprV16x8AllTrue:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v16x8_alltrue);
case wasm::kExprI16x8BitMask:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_i16x8_bitmask);
case wasm::kExprI16x8Shl:
return EmitSimdShiftOp(&LiftoffAssembler::emit_i16x8_shl,
&LiftoffAssembler::emit_i16x8_shli);
Expand Down Expand Up @@ -2667,6 +2671,8 @@ class LiftoffCompiler {
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v32x4_anytrue);
case wasm::kExprV32x4AllTrue:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_v32x4_alltrue);
case wasm::kExprI32x4BitMask:
return EmitUnOp<kS128, kI32>(&LiftoffAssembler::emit_i32x4_bitmask);
case wasm::kExprI32x4Shl:
return EmitSimdShiftOp(&LiftoffAssembler::emit_i32x4_shl,
&LiftoffAssembler::emit_i32x4_shli);
Expand Down
18 changes: 18 additions & 0 deletions src/wasm/baseline/x64/liftoff-assembler-x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -2591,6 +2591,11 @@ void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqb>(this, dst, src);
}

void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
Pmovmskb(dst.gp(), src.fp());
}

void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
static constexpr RegClass tmp_simd_rc = reg_class_for(ValueType::kS128);
Expand Down Expand Up @@ -2830,6 +2835,14 @@ void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqw>(this, dst, src);
}

void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
XMMRegister tmp = kScratchDoubleReg;
Packsswb(tmp, src.fp());
Pmovmskb(dst.gp(), tmp);
shrq(dst.gp(), Immediate(8));
}

void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShiftOp<&Assembler::vpsllw, &Assembler::psllw, 4>(this, dst,
Expand Down Expand Up @@ -2964,6 +2977,11 @@ void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst,
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqd>(this, dst, src);
}

void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst,
LiftoffRegister src) {
Movmskps(dst.gp(), src.fp());
}

void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
liftoff::EmitSimdShiftOp<&Assembler::vpslld, &Assembler::pslld, 5>(this, dst,
Expand Down

0 comments on commit aa5bcc0

Please sign in to comment.