chromium/v8/test/unittests/compiler/machine-operator-reducer-unittest.cc

// Copyright 2014 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/compiler/machine-operator-reducer.h"

#include <cstdint>
#include <limits>

#include "src/base/bits.h"
#include "src/base/division-by-constant.h"
#include "src/base/ieee754.h"
#include "src/base/overflowing-math.h"
#include "src/builtins/builtins.h"
#include "src/common/globals.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/machine-operator.h"
#include "src/numbers/conversions-inl.h"
#include "test/unittests/compiler/graph-unittest.h"
#include "test/unittests/compiler/node-test-utils.h"
#include "testing/gmock-support.h"

AllOf;
BitEq;
Capture;
CaptureEq;
NanSensitiveDoubleEq;

namespace v8 {
namespace internal {
namespace compiler {

class MachineOperatorReducerTest : public GraphTest {};


template <typename T>
class MachineOperatorReducerTestWithParam
    : public MachineOperatorReducerTest,
      public ::testing::WithParamInterface<T> {};


namespace {

const float kFloat32Values[] = {
    -std::numeric_limits<float>::infinity(), -2.70497e+38f, -1.4698e+37f,
    -1.22813e+35f,                           -1.20555e+35f, -1.34584e+34f,
    -1.0079e+32f,                            -6.49364e+26f, -3.06077e+25f,
    -1.46821e+25f,                           -1.17658e+23f, -1.9617e+22f,
    -2.7357e+20f,                            -1.48708e+13f, -1.89633e+12f,
    -4.66622e+11f,                           -2.22581e+11f, -1.45381e+10f,
    -1.3956e+09f,                            -1.32951e+09f, -1.30721e+09f,
    -1.19756e+09f,                           -9.26822e+08f, -6.35647e+08f,
    -4.00037e+08f,                           -1.81227e+08f, -5.09256e+07f,
    -964300.0f,                              -192446.0f,    -28455.0f,
    -27194.0f,                               -26401.0f,     -20575.0f,
    -17069.0f,                               -9167.0f,      -960.178f,
    -113.0f,                                 -62.0f,        -15.0f,
    -7.0f,                                   -0.0256635f,   -4.60374e-07f,
    -3.63759e-10f,                           -4.30175e-14f, -5.27385e-15f,
    -1.48084e-15f,                           -1.05755e-19f, -3.2995e-21f,
    -1.67354e-23f,                           -1.11885e-23f, -1.78506e-30f,
    -5.07594e-31f,                           -3.65799e-31f, -1.43718e-34f,
    -1.27126e-38f,                           -0.0f,         0.0f,
    1.17549e-38f,                            1.56657e-37f,  4.08512e-29f,
    3.31357e-28f,                            6.25073e-22f,  4.1723e-13f,
    1.44343e-09f,                            5.27004e-08f,  9.48298e-08f,
    5.57888e-07f,                            4.89988e-05f,  0.244326f,
    12.4895f,                                19.0f,         47.0f,
    106.0f,                                  538.324f,      564.536f,
    819.124f,                                7048.0f,       12611.0f,
    19878.0f,                                20309.0f,      797056.0f,
    1.77219e+09f,                            1.51116e+11f,  4.18193e+13f,
    3.59167e+16f,                            3.38211e+19f,  2.67488e+20f,
    1.78831e+21f,                            9.20914e+21f,  8.35654e+23f,
    1.4495e+24f,                             5.94015e+25f,  4.43608e+30f,
    2.44502e+33f,                            2.61152e+33f,  1.38178e+37f,
    1.71306e+37f,                            3.31899e+38f,  3.40282e+38f,
    std::numeric_limits<float>::infinity()};


const double kFloat64Values[] =;


const int32_t kInt32Values[] =;

const int64_t kInt64Values[] =;

const uint32_t kUint32Values[] =;

const uint64_t kUint64Values[] =;

struct ComparisonBinaryOperator {};


std::ostream& operator<<(std::ostream& os,
                         ComparisonBinaryOperator const& cbop) {}


const ComparisonBinaryOperator kComparisonBinaryOperators[] =;

// Avoid undefined behavior on signed integer overflow.
int32_t Shl(int32_t x, int32_t y) {}
int64_t Shl(int64_t x, int64_t y) {}

}  // namespace


// -----------------------------------------------------------------------------
// ChangeFloat64ToFloat32


TEST_F(MachineOperatorReducerTest, ChangeFloat64ToFloat32WithConstant) {}


// -----------------------------------------------------------------------------
// ChangeFloat64ToInt32


TEST_F(MachineOperatorReducerTest,
       ChangeFloat64ToInt32WithChangeInt32ToFloat64) {}

TEST_F(MachineOperatorReducerTest, ChangeFloat64ToInt32WithConstant) {}

// -----------------------------------------------------------------------------
// ChangeFloat64ToInt64

TEST_F(MachineOperatorReducerTest,
       ChangeFloat64ToInt64WithChangeInt64ToFloat64) {}

TEST_F(MachineOperatorReducerTest, ChangeFloat64ToInt64WithConstant) {}

// -----------------------------------------------------------------------------
// ChangeFloat64ToUint32


TEST_F(MachineOperatorReducerTest,
       ChangeFloat64ToUint32WithChangeUint32ToFloat64) {}


TEST_F(MachineOperatorReducerTest, ChangeFloat64ToUint32WithConstant) {}


// -----------------------------------------------------------------------------
// ChangeInt32ToFloat64


TEST_F(MachineOperatorReducerTest, ChangeInt32ToFloat64WithConstant) {}


// -----------------------------------------------------------------------------
// ChangeInt32ToInt64


TEST_F(MachineOperatorReducerTest, ChangeInt32ToInt64WithConstant) {}

// -----------------------------------------------------------------------------
// ChangeInt64ToFloat64

TEST_F(MachineOperatorReducerTest,
       ChangeInt64ToFloat64WithChangeFloat64ToInt64) {}

TEST_F(MachineOperatorReducerTest, ChangeInt64ToFloat64WithConstant) {}

// -----------------------------------------------------------------------------
// ChangeUint32ToFloat64


TEST_F(MachineOperatorReducerTest, ChangeUint32ToFloat64WithConstant) {}


// -----------------------------------------------------------------------------
// ChangeUint32ToUint64


TEST_F(MachineOperatorReducerTest, ChangeUint32ToUint64WithConstant) {}


// -----------------------------------------------------------------------------
// TruncateFloat64ToFloat32


TEST_F(MachineOperatorReducerTest,
       TruncateFloat64ToFloat32WithChangeFloat32ToFloat64) {}


TEST_F(MachineOperatorReducerTest, TruncateFloat64ToFloat32WithConstant) {}


// -----------------------------------------------------------------------------
// TruncateFloat64ToWord32

TEST_F(MachineOperatorReducerTest,
       TruncateFloat64ToWord32WithChangeInt32ToFloat64) {}

TEST_F(MachineOperatorReducerTest, TruncateFloat64ToWord32WithConstant) {}


// -----------------------------------------------------------------------------
// TruncateInt64ToInt32


TEST_F(MachineOperatorReducerTest, TruncateInt64ToInt32WithChangeInt32ToInt64) {}


TEST_F(MachineOperatorReducerTest, TruncateInt64ToInt32WithConstant) {}

TEST_F(MachineOperatorReducerTest, TruncateInt64ToInt32AfterLoadAndBitcast) {}

// -----------------------------------------------------------------------------
// RoundFloat64ToInt32

TEST_F(MachineOperatorReducerTest,
       RoundFloat64ToInt32WithChangeInt32ToFloat64) {}

TEST_F(MachineOperatorReducerTest, RoundFloat64ToInt32WithConstant) {}

// -----------------------------------------------------------------------------
// Word32And

TEST_F(MachineOperatorReducerTest, Word32AndWithWord32ShlWithConstant) {}


TEST_F(MachineOperatorReducerTest, Word32AndWithWord32AndWithConstant) {}


TEST_F(MachineOperatorReducerTest, Word32AndWithInt32AddAndConstant) {}


TEST_F(MachineOperatorReducerTest, Word32AndWithInt32MulAndConstant) {}


TEST_F(MachineOperatorReducerTest,
       Word32AndWithInt32AddAndInt32MulAndConstant) {}


TEST_F(MachineOperatorReducerTest, Word32AndWithComparisonAndConstantOne) {}

TEST_F(MachineOperatorReducerTest, Word32AndWithBitFields) {}

TEST_F(MachineOperatorReducerTest, Word32AndWithIncorrectBitField) {}

// -----------------------------------------------------------------------------
// Word32Or

TEST_F(MachineOperatorReducerTest, Word32OrWithWord32And) {}

// -----------------------------------------------------------------------------
// Word32Xor


TEST_F(MachineOperatorReducerTest, Word32XorWithWord32XorAndMinusOne) {}


// -----------------------------------------------------------------------------
// Word32Ror


TEST_F(MachineOperatorReducerTest, ReduceToWord32RorWithParameters) {}

TEST_F(MachineOperatorReducerTest, ReduceToWord32RorWithConstant) {}


TEST_F(MachineOperatorReducerTest, Word32RorWithZeroShift) {}


TEST_F(MachineOperatorReducerTest, Word32RorWithConstants) {}


// -----------------------------------------------------------------------------
// Word32Sar


TEST_F(MachineOperatorReducerTest, Word32SarWithWord32ShlAndComparison) {}


TEST_F(MachineOperatorReducerTest, Word32SarWithWord32ShlAndLoad) {}


// -----------------------------------------------------------------------------
// Word32Shr

TEST_F(MachineOperatorReducerTest, Word32ShrWithWord32And) {}

// -----------------------------------------------------------------------------
// Word32Shl

TEST_F(MachineOperatorReducerTest, Word32ShlWithZeroShift) {}


TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Sar) {}


TEST_F(MachineOperatorReducerTest,
       Word32ShlWithWord32SarAndInt32AddAndConstant) {}


TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Shr) {}

TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32SarShiftOutZeros) {}

// -----------------------------------------------------------------------------
// Word64Shl

TEST_F(MachineOperatorReducerTest, Word64ShlWithZeroShift) {}

TEST_F(MachineOperatorReducerTest, Word64ShlWithWord64Sar) {}

TEST_F(MachineOperatorReducerTest,
       Word64ShlWithWord64SarAndInt64AddAndConstant) {}

TEST_F(MachineOperatorReducerTest, Word64ShlWithWord64Shr) {}

TEST_F(MachineOperatorReducerTest, Word64ShlWithWord64SarShiftOutZeros) {}

// -----------------------------------------------------------------------------
// Word32Equal

TEST_F(MachineOperatorReducerTest,
       Word32EqualWithShiftedMaskedValueAndConstant) {}

TEST_F(MachineOperatorReducerTest, Word32EqualWithAddAndConstant) {}

// -----------------------------------------------------------------------------
// Word64Equal

TEST_F(MachineOperatorReducerTest,
       Word64EqualWithShiftedMaskedValueAndConstant) {}

TEST_F(MachineOperatorReducerTest, Word64EqualWithAddAndConstant) {}

// -----------------------------------------------------------------------------
// Branch

TEST_F(MachineOperatorReducerTest, BranchWithShiftedMaskedValue) {}

// -----------------------------------------------------------------------------
// Int32Sub


TEST_F(MachineOperatorReducerTest, Int32SubWithConstant) {}

// -----------------------------------------------------------------------------
// Int32Div, Int64Div

TEST_F(MachineOperatorReducerTest, Int32DivWithConstant) {}

TEST_F(MachineOperatorReducerTest, Int64DivWithConstant) {}

TEST_F(MachineOperatorReducerTest, Int32DivWithParameters) {}

// -----------------------------------------------------------------------------
// Uint32Div, Uint64Div

TEST_F(MachineOperatorReducerTest, Uint32DivWithConstant) {}

TEST_F(MachineOperatorReducerTest, Uint64DivWithConstant) {}

TEST_F(MachineOperatorReducerTest, Uint32DivWithParameters) {}

// -----------------------------------------------------------------------------
// Int32Mod, Uint64Mod

TEST_F(MachineOperatorReducerTest, Int32ModWithConstant) {}

TEST_F(MachineOperatorReducerTest, Int64ModWithConstant) {}

TEST_F(MachineOperatorReducerTest, Int32ModWithParameters) {}

// -----------------------------------------------------------------------------
// Uint32Mod, Uint64Mod

TEST_F(MachineOperatorReducerTest, Uint32ModWithConstant) {}

TEST_F(MachineOperatorReducerTest, Uint64ModWithConstant) {}

TEST_F(MachineOperatorReducerTest, Uint32ModWithParameters) {}

// -----------------------------------------------------------------------------
// Int32Add, Int64Add

TEST_F(MachineOperatorReducerTest, Int32AddWithInt32SubWithConstantZero) {}

TEST_F(MachineOperatorReducerTest, Int32AddMergeConstants) {}

TEST_F(MachineOperatorReducerTest, Int64AddMergeConstants) {}

// -----------------------------------------------------------------------------
// Int32Mul, Int64Mul

TEST_F(MachineOperatorReducerTest, Int32MulMergeConstants) {}

TEST_F(MachineOperatorReducerTest, Int64MulMergeConstants) {}

// -----------------------------------------------------------------------------
// Int32AddWithOverflow


TEST_F(MachineOperatorReducerTest, Int32AddWithOverflowWithZero) {}


TEST_F(MachineOperatorReducerTest, Int32AddWithOverflowWithConstant) {}


// -----------------------------------------------------------------------------
// Int32SubWithOverflow


TEST_F(MachineOperatorReducerTest, Int32SubWithOverflowWithZero) {}


TEST_F(MachineOperatorReducerTest, Int32SubWithOverflowWithConstant) {}


// -----------------------------------------------------------------------------
// Int32MulWithOverflow

TEST_F(MachineOperatorReducerTest, Int32MulWithOverflowWithZero) {}

TEST_F(MachineOperatorReducerTest, Int32MulWithOverflowWithOne) {}

TEST_F(MachineOperatorReducerTest, Int32MulWithOverflowWithMinusOne) {}

TEST_F(MachineOperatorReducerTest, Int32MulWithOverflowWithTwo) {}

TEST_F(MachineOperatorReducerTest, Int32MulWithOverflowWithConstant) {}

// -----------------------------------------------------------------------------
// Int64Mul

TEST_F(MachineOperatorReducerTest, Int64MulWithZero) {}

TEST_F(MachineOperatorReducerTest, Int64MulWithOne) {}

TEST_F(MachineOperatorReducerTest, Int64MulWithMinusOne) {}

TEST_F(MachineOperatorReducerTest, Int64MulWithPowerOfTwo) {}

TEST_F(MachineOperatorReducerTest, Int64MulWithConstant) {}

// -----------------------------------------------------------------------------
// Int32LessThan

TEST_F(MachineOperatorReducerTest, Int32LessThanWithWord32Or) {}

TEST_F(MachineOperatorReducerTest, Int32LessThanWithWord32SarShiftOutZeros) {}

// -----------------------------------------------------------------------------
// Uint32LessThan

TEST_F(MachineOperatorReducerTest, Uint32LessThanWithWord32Sar) {}

TEST_F(MachineOperatorReducerTest, Uint32LessThanWithWord32SarShiftOutZeros) {}

// -----------------------------------------------------------------------------
// Uint64LessThan

TEST_F(MachineOperatorReducerTest, Uint64LessThanWithWord64SarShiftOutZeros) {}

TEST_F(MachineOperatorReducerTest, Uint64LessThanWithUint32Reduction) {}

TEST_F(MachineOperatorReducerTest, Uint64LessThanWithInt64AddDontReduce) {}

TEST_F(MachineOperatorReducerTest,
       Uint64LessThanOrEqualWithInt64AddDontReduce) {}

// -----------------------------------------------------------------------------
// Int64LessThan

TEST_F(MachineOperatorReducerTest, Int64LessThanWithWord64SarShiftOutZeros) {}

TEST_F(MachineOperatorReducerTest, Int64LessThanWithInt32Reduction) {}

// -----------------------------------------------------------------------------
// Float64Mul


TEST_F(MachineOperatorReducerTest, Float64MulWithMinusOne) {}

TEST_F(MachineOperatorReducerTest, Float64SubMinusZeroMinusX) {}

TEST_F(MachineOperatorReducerTest, Float32SubMinusZeroMinusX) {}

TEST_F(MachineOperatorReducerTest, Float64MulWithTwo) {}

// -----------------------------------------------------------------------------
// Float64Div

TEST_F(MachineOperatorReducerTest, Float64DivWithMinusOne) {}

TEST_F(MachineOperatorReducerTest, Float64DivWithPowerOfTwo) {}

// -----------------------------------------------------------------------------
// Float64Acos

TEST_F(MachineOperatorReducerTest, Float64AcosWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Acosh

TEST_F(MachineOperatorReducerTest, Float64AcoshWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Asin

TEST_F(MachineOperatorReducerTest, Float64AsinWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Asinh

TEST_F(MachineOperatorReducerTest, Float64AsinhWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Atan

TEST_F(MachineOperatorReducerTest, Float64AtanWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Atanh

TEST_F(MachineOperatorReducerTest, Float64AtanhWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Atan2

TEST_F(MachineOperatorReducerTest, Float64Atan2WithConstant) {}

TEST_F(MachineOperatorReducerTest, Float64Atan2WithNaN) {}

// -----------------------------------------------------------------------------
// Float64Cos

TEST_F(MachineOperatorReducerTest, Float64CosWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Cosh

TEST_F(MachineOperatorReducerTest, Float64CoshWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Exp

TEST_F(MachineOperatorReducerTest, Float64ExpWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Log

TEST_F(MachineOperatorReducerTest, Float64LogWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Log1p

TEST_F(MachineOperatorReducerTest, Float64Log1pWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Pow

TEST_F(MachineOperatorReducerTest, Float64PowWithConstant) {}

TEST_F(MachineOperatorReducerTest, Float64PowWithZeroExponent) {}

// -----------------------------------------------------------------------------
// Float64Sin

TEST_F(MachineOperatorReducerTest, Float64SinWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Sinh

TEST_F(MachineOperatorReducerTest, Float64SinhWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Tan

TEST_F(MachineOperatorReducerTest, Float64TanWithConstant) {}

// -----------------------------------------------------------------------------
// Float64Tanh

TEST_F(MachineOperatorReducerTest, Float64TanhWithConstant) {}

// -----------------------------------------------------------------------------
// Float64InsertLowWord32

TEST_F(MachineOperatorReducerTest, Float64InsertLowWord32WithConstant) {}


// -----------------------------------------------------------------------------
// Float64InsertHighWord32


TEST_F(MachineOperatorReducerTest, Float64InsertHighWord32WithConstant) {}


// -----------------------------------------------------------------------------
// Float64Equal

TEST_F(MachineOperatorReducerTest, Float64EqualWithConstant) {}

TEST_F(MachineOperatorReducerTest, Float64EqualWithFloat32Conversions) {}


TEST_F(MachineOperatorReducerTest, Float64EqualWithFloat32Constant) {}


// -----------------------------------------------------------------------------
// Float64LessThan

TEST_F(MachineOperatorReducerTest, Float64LessThanWithConstant) {}

TEST_F(MachineOperatorReducerTest, Float64LessThanWithFloat32Conversions) {}


TEST_F(MachineOperatorReducerTest, Float64LessThanWithFloat32Constant) {}


// -----------------------------------------------------------------------------
// Float64LessThanOrEqual

TEST_F(MachineOperatorReducerTest, Float64LessThanOrEqualWithConstant) {}

TEST_F(MachineOperatorReducerTest,
       Float64LessThanOrEqualWithFloat32Conversions) {}


TEST_F(MachineOperatorReducerTest, Float64LessThanOrEqualWithFloat32Constant) {}


// -----------------------------------------------------------------------------
// Float64RoundDown

TEST_F(MachineOperatorReducerTest, Float64RoundDownWithConstant) {}

// -----------------------------------------------------------------------------
// Store

TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32And) {}


TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32SarAndWord32Shl) {}


TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32And) {}


TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32SarAndWord32Shl) {}

TEST_F(MachineOperatorReducerTest, Select) {}

}  // namespace compiler
}  // namespace internal
}  // namespace v8