Skip to content

Commit

Permalink
Revert "[arm64][turbofan] Word[32|64]Select support"
Browse files Browse the repository at this point in the history
This reverts commit 1f26e44.

Reason for revert: https://crbug.com/1453645#c12

Original change's description:
> [arm64][turbofan] Word[32|64]Select support
>
> Enable the use of csel.
>
> Change-Id: I6c2d3cc835149ce4beeb7334985ad2c11300d2c8
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4374179
> Reviewed-by: Thibaud Michaud <thibaudm@chromium.org>
> Commit-Queue: Martyn Capewell <martyn.capewell@arm.com>
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#87165}

(cherry picked from commit 51311a8)

Bug: chromium:1451929, chromium:1453645
Change-Id: I9b8a9c04b796a8459d3614eb5979e0ed99340ac8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4607616
Commit-Queue: Adam Klein <adamk@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/11.5@{v8#14}
Cr-Branched-From: 0c4044b-refs/heads/11.5.150@{#1}
Cr-Branched-From: b71d303-refs/heads/main@{#87781}
  • Loading branch information
ajklein authored and V8 LUCI CQ committed Jun 12, 2023
1 parent ab37fbc commit c32ef33
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 63 deletions.
10 changes: 2 additions & 8 deletions src/compiler/backend/arm64/code-generator-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3166,17 +3166,11 @@ void CodeGenerator::AssembleArchSelect(Instruction* instr,
__ Fcsel(i.OutputFloat32Register(),
i.InputFloat32Register(true_value_index),
i.InputFloat32Register(false_value_index), cc);
} else if (rep == MachineRepresentation::kFloat64) {
} else {
DCHECK_EQ(rep, MachineRepresentation::kFloat64);
__ Fcsel(i.OutputFloat64Register(),
i.InputFloat64Register(true_value_index),
i.InputFloat64Register(false_value_index), cc);
} else if (rep == MachineRepresentation::kWord32) {
__ Csel(i.OutputRegister32(), i.InputRegister32(true_value_index),
i.InputRegister32(false_value_index), cc);
} else {
DCHECK_EQ(rep, MachineRepresentation::kWord64);
__ Csel(i.OutputRegister64(), i.InputRegister64(true_value_index),
i.InputRegister64(false_value_index), cc);
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/compiler/backend/arm64/instruction-selector-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4785,8 +4785,6 @@ InstructionSelector::SupportedMachineOperatorFlags() {
MachineOperatorBuilder::kSatConversionIsSafe |
MachineOperatorBuilder::kFloat32Select |
MachineOperatorBuilder::kFloat64Select |
MachineOperatorBuilder::kWord32Select |
MachineOperatorBuilder::kWord64Select |
MachineOperatorBuilder::kLoadStorePairs;
}

Expand Down
60 changes: 33 additions & 27 deletions test/cctest/compiler/test-run-machops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -472,22 +472,6 @@ TEST(RunSelectUnorderedNotEqual) {
CHECK_EQ(input1, m.Call(input1, input2, std::nanf("")));
}

namespace {
template <typename T>
ExternalReference ExternalRefFromFunc(RawMachineAssemblerTester<T>* m,
Address func_address) {
ExternalReference::Type func_type = ExternalReference::FAST_C_CALL;
ApiFunction func(func_address);
ExternalReference ref = ExternalReference::Create(&func, func_type);
#ifdef V8_USE_SIMULATOR_WITH_GENERIC_C_CALLS
EncodedCSignature sig = m->call_descriptor()->ToEncodedCSignature();
m->main_isolate()->simulator_data()->AddSignatureForTargetForTesting(
func_address, sig);
#endif
return ref;
}
} // namespace

namespace {
void FooForSelect() {}
} // namespace
Expand All @@ -500,13 +484,14 @@ TEST(RunWord32SelectWithMemoryInput) {
}

// Test that the generated code also works with values spilled on the stack.
ExternalReference ref = ExternalRefFromFunc(&m, FUNCTION_ADDR(FooForSelect));

auto* foo_ptr = &FooForSelect;
constexpr int input1 = 16;
int input2 = 3443;
// Load {value2} before the function call so that it gets spilled.
Node* value2 = m.LoadFromPointer(&input2, MachineType::Int32());
Node* function = m.LoadFromPointer(&foo_ptr, MachineType::Pointer());
// Call a function so that {value2} gets spilled on the stack.
Node* function = m.ExternalConstant(ref);
m.CallCFunction(function, MachineType::Int32());
Node* cmp = m.Word32Equal(m.Parameter(1), m.Int32Constant(0));
m.Return(m.Word32Select(cmp, m.Parameter(0), value2));
Expand All @@ -526,13 +511,13 @@ TEST(RunWord64SelectWithMemoryInput) {

// Test that the generated code also works with values spilled on the stack.

ExternalReference ref = ExternalRefFromFunc(&m, FUNCTION_ADDR(FooForSelect));
auto* foo_ptr = &FooForSelect;
constexpr int64_t input1 = 16;
int64_t input2 = 0x12345678ABCD;
// Load {value2} before the function call so that it gets spilled.
Node* value2 = m.LoadFromPointer(&input2, MachineType::Int64());
Node* function = m.LoadFromPointer(&foo_ptr, MachineType::Pointer());
// Call a function so that {value2} gets spilled on the stack.
Node* function = m.ExternalConstant(ref);
m.CallCFunction(function, MachineType::Int32());
Node* cmp = m.Word32Equal(m.Parameter(1), m.Int32Constant(0));
m.Return(m.Word64Select(cmp, m.Parameter(0), value2));
Expand Down Expand Up @@ -6793,6 +6778,20 @@ TEST(RunCallCFunction9) {
#endif // !USE_SIMULATOR

#ifdef V8_ENABLE_FP_PARAMS_IN_C_LINKAGE
#ifdef V8_USE_SIMULATOR_WITH_GENERIC_C_CALLS
#define IF_SIMULATOR_ADD_SIGNATURE \
EncodedCSignature sig = m.call_descriptor()->ToEncodedCSignature(); \
m.main_isolate()->simulator_data()->AddSignatureForTargetForTesting( \
func_address, sig);
#else
#define IF_SIMULATOR_ADD_SIGNATURE
#endif // V8_USE_SIMULATOR_WITH_GENERIC_C_CALLS

#define EXTERNAL_REF_FROM_FUNC(FUNC) \
Address func_address = FUNCTION_ADDR(&FUNC); \
ExternalReference::Type func_type = ExternalReference::FAST_C_CALL; \
ApiFunction func(func_address); \
ExternalReference ref = ExternalReference::Create(&func, func_type);

namespace {

Expand Down Expand Up @@ -6920,7 +6919,8 @@ double int_foo10(int64_t a, int64_t b, int64_t c, int64_t d, int64_t e,

TEST(RunCallDoubleCFunction0) {
RawMachineAssemblerTester<double> m;
ExternalReference ref = ExternalRefFromFunc(&m, FUNCTION_ADDR(double_foo0));
EXTERNAL_REF_FROM_FUNC(double_foo0)
IF_SIMULATOR_ADD_SIGNATURE

Node* function = m.ExternalConstant(ref);
m.Return(m.CallCFunction(function, MachineType::Float64()));
Expand All @@ -6929,7 +6929,8 @@ TEST(RunCallDoubleCFunction0) {

TEST(RunCallDoubleCFunction1) {
RawMachineAssemblerTester<double> m(MachineType::Float64());
ExternalReference ref = ExternalRefFromFunc(&m, FUNCTION_ADDR(double_foo1));
EXTERNAL_REF_FROM_FUNC(double_foo1)
IF_SIMULATOR_ADD_SIGNATURE

Node* function = m.ExternalConstant(ref);
m.Return(
Expand All @@ -6941,7 +6942,8 @@ TEST(RunCallDoubleCFunction1) {
TEST(RunCallDoubleCFunction2) {
RawMachineAssemblerTester<double> m(MachineType::Float64(),
MachineType::Float64());
ExternalReference ref = ExternalRefFromFunc(&m, FUNCTION_ADDR(double_foo2));
EXTERNAL_REF_FROM_FUNC(double_foo2)
IF_SIMULATOR_ADD_SIGNATURE

Node* function = m.ExternalConstant(ref);
m.Return(
Expand All @@ -6959,7 +6961,8 @@ TEST(RunCallDoubleCFunction8) {
MachineType::Float64(), MachineType::Float64(), MachineType::Float64(),
MachineType::Float64(), MachineType::Float64(), MachineType::Float64(),
MachineType::Float64(), MachineType::Float64());
ExternalReference ref = ExternalRefFromFunc(&m, FUNCTION_ADDR(double_foo8));
EXTERNAL_REF_FROM_FUNC(double_foo8)
IF_SIMULATOR_ADD_SIGNATURE

Node* function = m.ExternalConstant(ref);
Node* param = m.Parameter(0);
Expand All @@ -6983,7 +6986,8 @@ TEST(RunCallDoubleCFunction9) {
MachineType::Float64(), MachineType::Float64(), MachineType::Float64(),
MachineType::Float64(), MachineType::Float64(), MachineType::Float64(),
MachineType::Float64(), MachineType::Float64(), MachineType::Float64());
ExternalReference ref = ExternalRefFromFunc(&m, FUNCTION_ADDR(double_foo9));
EXTERNAL_REF_FROM_FUNC(double_foo9)
IF_SIMULATOR_ADD_SIGNATURE

Node* function = m.ExternalConstant(ref);
Node* param = m.Parameter(0);
Expand Down Expand Up @@ -7018,7 +7022,8 @@ TEST(RunCallDoubleCFunction10) {
MachineType::Float64(), MachineType::Float64(), MachineType::Float64(),
MachineType::Float64(), MachineType::Float64(), MachineType::Float64(),
MachineType::Int64());
ExternalReference ref = ExternalRefFromFunc(&m, FUNCTION_ADDR(double_foo10));
EXTERNAL_REF_FROM_FUNC(double_foo10)
IF_SIMULATOR_ADD_SIGNATURE

Node* function = m.ExternalConstant(ref);
m.Return(
Expand Down Expand Up @@ -7046,7 +7051,8 @@ TEST(RunCallIntCFunction10) {
MachineType::Int64(), MachineType::Int64(), MachineType::Int64(),
MachineType::Int64(), MachineType::Int64(), MachineType::Int64(),
MachineType::Float64());
ExternalReference ref = ExternalRefFromFunc(&m, FUNCTION_ADDR(int_foo10));
EXTERNAL_REF_FROM_FUNC(int_foo10)
IF_SIMULATOR_ADD_SIGNATURE

Node* function = m.ExternalConstant(ref);
m.Return(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2993,32 +2993,6 @@ TEST_F(InstructionSelectorTest, Float64SelectWithRegisters) {
EXPECT_EQ(kNotEqual, s[0]->flags_condition());
}

TEST_F(InstructionSelectorTest, Word32SelectWithRegisters) {
StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(),
MachineType::Int32());
Node* cond = m.Int32Constant(1);
m.Return(m.Word32Select(cond, m.Parameter(0), m.Parameter(1)));
Stream s = m.Build();
EXPECT_EQ(kArm64Tst32, s[0]->arch_opcode());
EXPECT_EQ(4U, s[0]->InputCount());
EXPECT_EQ(1U, s[0]->OutputCount());
EXPECT_EQ(kFlags_select, s[0]->flags_mode());
EXPECT_EQ(kNotEqual, s[0]->flags_condition());
}

TEST_F(InstructionSelectorTest, Word64SelectWithRegisters) {
StreamBuilder m(this, MachineType::Int32(), MachineType::Int64(),
MachineType::Int64());
Node* cond = m.Int32Constant(1);
m.Return(m.Word64Select(cond, m.Parameter(0), m.Parameter(1)));
Stream s = m.Build();
EXPECT_EQ(kArm64Tst32, s[0]->arch_opcode());
EXPECT_EQ(4U, s[0]->InputCount());
EXPECT_EQ(1U, s[0]->OutputCount());
EXPECT_EQ(kFlags_select, s[0]->flags_mode());
EXPECT_EQ(kNotEqual, s[0]->flags_condition());
}

// -----------------------------------------------------------------------------
// Conversions.

Expand Down

0 comments on commit c32ef33

Please sign in to comment.