Commit 215ba999 authored by Joey Gouly's avatar Joey Gouly Committed by Commit Bot

[wasm][arm64] Fix AllTrue / AnyTrue for arm/arm64

These instructions should return 0 or 1, previously it would return the
min/max of the elements.

Change-Id: I81913c07f11e4a98ce3b9f5d79b5d975e5bf953f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1681130Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Martyn Capewell <martyn.capewell@arm.com>
Cr-Commit-Position: refs/heads/master@{#62498}
parent 1c93aa58
...@@ -2589,6 +2589,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2589,6 +2589,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vpmax(NeonU32, scratch, src.low(), src.high()); __ vpmax(NeonU32, scratch, src.low(), src.high());
__ vpmax(NeonU32, scratch, scratch, scratch); __ vpmax(NeonU32, scratch, scratch, scratch);
__ ExtractLane(i.OutputRegister(), scratch, NeonS32, 0); __ ExtractLane(i.OutputRegister(), scratch, NeonS32, 0);
__ cmp(i.OutputRegister(), Operand(0));
__ mov(i.OutputRegister(), Operand(1), LeaveCC, ne);
break; break;
} }
case kArmS1x4AllTrue: { case kArmS1x4AllTrue: {
...@@ -2598,6 +2600,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2598,6 +2600,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vpmin(NeonU32, scratch, src.low(), src.high()); __ vpmin(NeonU32, scratch, src.low(), src.high());
__ vpmin(NeonU32, scratch, scratch, scratch); __ vpmin(NeonU32, scratch, scratch, scratch);
__ ExtractLane(i.OutputRegister(), scratch, NeonS32, 0); __ ExtractLane(i.OutputRegister(), scratch, NeonS32, 0);
__ cmp(i.OutputRegister(), Operand(0));
__ mov(i.OutputRegister(), Operand(1), LeaveCC, ne);
break; break;
} }
case kArmS1x8AnyTrue: { case kArmS1x8AnyTrue: {
...@@ -2608,6 +2612,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2608,6 +2612,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vpmax(NeonU16, scratch, scratch, scratch); __ vpmax(NeonU16, scratch, scratch, scratch);
__ vpmax(NeonU16, scratch, scratch, scratch); __ vpmax(NeonU16, scratch, scratch, scratch);
__ ExtractLane(i.OutputRegister(), scratch, NeonS16, 0); __ ExtractLane(i.OutputRegister(), scratch, NeonS16, 0);
__ cmp(i.OutputRegister(), Operand(0));
__ mov(i.OutputRegister(), Operand(1), LeaveCC, ne);
break; break;
} }
case kArmS1x8AllTrue: { case kArmS1x8AllTrue: {
...@@ -2618,6 +2624,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2618,6 +2624,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vpmin(NeonU16, scratch, scratch, scratch); __ vpmin(NeonU16, scratch, scratch, scratch);
__ vpmin(NeonU16, scratch, scratch, scratch); __ vpmin(NeonU16, scratch, scratch, scratch);
__ ExtractLane(i.OutputRegister(), scratch, NeonS16, 0); __ ExtractLane(i.OutputRegister(), scratch, NeonS16, 0);
__ cmp(i.OutputRegister(), Operand(0));
__ mov(i.OutputRegister(), Operand(1), LeaveCC, ne);
break; break;
} }
case kArmS1x16AnyTrue: { case kArmS1x16AnyTrue: {
...@@ -2632,6 +2640,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2632,6 +2640,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
// kDoubleRegZero is not changed, since it is 0. // kDoubleRegZero is not changed, since it is 0.
__ vtst(Neon32, q_scratch, q_scratch, q_scratch); __ vtst(Neon32, q_scratch, q_scratch, q_scratch);
__ ExtractLane(i.OutputRegister(), d_scratch, NeonS32, 0); __ ExtractLane(i.OutputRegister(), d_scratch, NeonS32, 0);
__ cmp(i.OutputRegister(), Operand(0));
__ mov(i.OutputRegister(), Operand(1), LeaveCC, ne);
break; break;
} }
case kArmS1x16AllTrue: { case kArmS1x16AllTrue: {
...@@ -2643,6 +2653,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2643,6 +2653,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vpmin(NeonU8, scratch, scratch, scratch); __ vpmin(NeonU8, scratch, scratch, scratch);
__ vpmin(NeonU8, scratch, scratch, scratch); __ vpmin(NeonU8, scratch, scratch, scratch);
__ ExtractLane(i.OutputRegister(), scratch, NeonS8, 0); __ ExtractLane(i.OutputRegister(), scratch, NeonS8, 0);
__ cmp(i.OutputRegister(), Operand(0));
__ mov(i.OutputRegister(), Operand(1), LeaveCC, ne);
break; break;
} }
case kWord32AtomicLoadInt8: case kWord32AtomicLoadInt8:
......
...@@ -2201,6 +2201,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2201,6 +2201,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
VRegister temp = scope.AcquireV(format); \ VRegister temp = scope.AcquireV(format); \
__ Instr(temp, i.InputSimd128Register(0).V##FORMAT()); \ __ Instr(temp, i.InputSimd128Register(0).V##FORMAT()); \
__ Umov(i.OutputRegister32(), temp, 0); \ __ Umov(i.OutputRegister32(), temp, 0); \
__ Cmp(i.OutputRegister32(), 0); \
__ Cset(i.OutputRegister32(), ne); \
break; \ break; \
} }
SIMD_REDUCE_OP_CASE(kArm64S1x4AnyTrue, Umaxv, kFormatS, 4S); SIMD_REDUCE_OP_CASE(kArm64S1x4AnyTrue, Umaxv, kFormatS, 4S);
......
...@@ -2417,10 +2417,10 @@ WASM_SIMD_COMPILED_TEST(SimdLoadStoreLoad) { ...@@ -2417,10 +2417,10 @@ WASM_SIMD_COMPILED_TEST(SimdLoadStoreLoad) {
} }
} }
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM64 || \
V8_TARGET_ARCH_ARM
// V8:8665 - Tracking bug to enable reduction tests in the interpreter, // V8:8665 - Tracking bug to enable reduction tests in the interpreter,
// and for SIMD lowering. // and for SIMD lowering.
// TODO(gdeepti): Enable these tests for ARM/ARM64
#define WASM_SIMD_ANYTRUE_TEST(format, lanes, max) \ #define WASM_SIMD_ANYTRUE_TEST(format, lanes, max) \
WASM_SIMD_TEST_NO_LOWERING(S##format##AnyTrue) { \ WASM_SIMD_TEST_NO_LOWERING(S##format##AnyTrue) { \
WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); \ WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); \
...@@ -2451,7 +2451,8 @@ WASM_SIMD_ANYTRUE_TEST(8x16, 16, 0xff) ...@@ -2451,7 +2451,8 @@ WASM_SIMD_ANYTRUE_TEST(8x16, 16, 0xff)
WASM_SIMD_ALLTRUE_TEST(32x4, 4, 0xffffffff) WASM_SIMD_ALLTRUE_TEST(32x4, 4, 0xffffffff)
WASM_SIMD_ALLTRUE_TEST(16x8, 8, 0xffff) WASM_SIMD_ALLTRUE_TEST(16x8, 8, 0xffff)
WASM_SIMD_ALLTRUE_TEST(8x16, 16, 0xff) WASM_SIMD_ALLTRUE_TEST(8x16, 16, 0xff)
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 #endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM64 ||
// V8_TARGET_ARCH_ARM
WASM_SIMD_TEST(BitSelect) { WASM_SIMD_TEST(BitSelect) {
WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd);
......
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