chromium/v8/test/cctest/compiler/turboshaft-test-select-combine.cc

// Copyright 2024 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/objects/objects-inl.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/turboshaft-codegen-tester.h"
#include "test/common/value-helper.h"

namespace v8::internal::compiler::turboshaft {

// Generates a binop arithmetic instruction, followed by an integer compare zero
// and select. This is to test a possible merge of the arithmetic op and the
// compare for use by the select. We test a matrix of configurations:
// - floating-point and integer select.
// - add, sub, mul, and, or and xor.
// - int32, uint32t, int64_t, uint64_t, float and double.
// - one or multiple users of the binary operation.
// - two different graph layouts (single block vs three blocks).

namespace {

enum GraphConfig {};
constexpr GraphConfig graph_configs[] =;

#define SELECT_OP_LIST(V)

enum class SelectOperator {};

bool SelectIsSupported(SelectOperator op) {}

// kOneUse:
// (bin_res = binop lhs, rhs)
// (return (select (compare bin_res, zero, cond), tval, fval))
//
// kTwoUsesOneBlock:
// (bin_res = binop lhs, rhs)
// (return (add (select (compare bin_res, zero, cond), tval, fval), bin_res))
//
// kTwoUsesTwoBlocks:
// Same as above, but the final addition is conditionally executed in a
// different block.
// (bin_res = binop lhs, rhs)
// (select_res = (select (compare bin_res, zero, cond), tval, fval))
// (select_res >= tval)
//   ? (return select_res)
//   : (return (add select_res, bin_res))

template <typename CondType, typename ResultType>
class ConditionalSelectGen {};

template <typename ResultType>
class UInt32ConditionalSelectGen
    : public ConditionalSelectGen<uint32_t, ResultType> {};

template <typename ResultType>
class UInt64ConditionalSelectGen
    : public ConditionalSelectGen<uint64_t, ResultType> {};

constexpr TurboshaftComparison int32_cmp_opcodes[] =;
constexpr TurboshaftBinop int32_bin_opcodes[] =;

TEST(Word32SelectCombineInt32CompareZero) {}

TEST(Word64SelectCombineInt32CompareZero) {}

TEST(Float32SelectCombineInt32CompareZero) {}

TEST(Float64SelectCombineInt32CompareZero) {}

constexpr TurboshaftBinop int64_bin_opcodes[] =;
constexpr TurboshaftComparison int64_cmp_opcodes[] =;

TEST(Word32SelectCombineInt64CompareZero) {}

TEST(Word64SelectCombineInt64CompareZero) {}

TEST(Float32SelectCombineInt64CompareZero) {}

TEST(Float64SelectCombineInt64CompareZero) {}

}  // end namespace

}  // namespace v8::internal::compiler::turboshaft