// Copyright 2023 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/codegen-tester.h" #include "test/common/value-helper.h" namespace v8::internal::compiler { // 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[] = …; // 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 IrOpcode::Value int32_cmp_opcodes[] = …; constexpr IrOpcode::Value int32_bin_opcodes[] = …; TEST(Word32SelectCombineInt32CompareZero) { … } TEST(Word64SelectCombineInt32CompareZero) { … } TEST(Float32SelectCombineInt32CompareZero) { … } TEST(Float64SelectCombineInt32CompareZero) { … } constexpr IrOpcode::Value int64_bin_opcodes[] = …; constexpr IrOpcode::Value int64_cmp_opcodes[] = …; TEST(Word32SelectCombineInt64CompareZero) { … } TEST(Word64SelectCombineInt64CompareZero) { … } TEST(Float32SelectCombineInt64CompareZero) { … } TEST(Float64SelectCombineInt64CompareZero) { … } } // end namespace } // namespace v8::internal::compiler