LCOV - code coverage report
Current view: top level - test/unittests/compiler - int64-lowering-unittest.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 298 334 89.2 %
Date: 2019-04-17 Functions: 101 148 68.2 %

          Line data    Source code
       1             : // Copyright 2016 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/compiler/int64-lowering.h"
       6             : #include "src/compiler/common-operator.h"
       7             : #include "src/compiler/linkage.h"
       8             : #include "src/compiler/machine-operator.h"
       9             : #include "src/compiler/node-properties.h"
      10             : #include "src/compiler/node.h"
      11             : #include "src/compiler/wasm-compiler.h"
      12             : #include "src/objects-inl.h"
      13             : #include "src/signature.h"
      14             : #include "src/wasm/value-type.h"
      15             : #include "src/wasm/wasm-module.h"
      16             : #include "test/unittests/compiler/graph-unittest.h"
      17             : #include "test/unittests/compiler/node-test-utils.h"
      18             : #include "testing/gmock-support.h"
      19             : 
      20             : using testing::AllOf;
      21             : using testing::Capture;
      22             : using testing::CaptureEq;
      23             : 
      24             : namespace v8 {
      25             : namespace internal {
      26             : namespace compiler {
      27             : 
      28          47 : class Int64LoweringTest : public GraphTest {
      29             :  public:
      30          47 :   Int64LoweringTest()
      31             :       : GraphTest(),
      32             :         machine_(zone(), MachineRepresentation::kWord32,
      33          94 :                  MachineOperatorBuilder::Flag::kAllOptionalOps) {
      34          47 :     value_[0] = 0x1234567890ABCDEF;
      35          47 :     value_[1] = 0x1EDCBA098765432F;
      36          47 :     value_[2] = 0x1133557799886644;
      37          47 :   }
      38             : 
      39          82 :   MachineOperatorBuilder* machine() { return &machine_; }
      40             : 
      41          44 :   void LowerGraph(Node* node, Signature<MachineRepresentation>* signature) {
      42          44 :     Node* zero = graph()->NewNode(common()->Int32Constant(0));
      43          44 :     Node* ret = graph()->NewNode(common()->Return(), zero, node,
      44             :                                  graph()->start(), graph()->start());
      45          44 :     NodeProperties::MergeControlToEnd(graph(), common(), ret);
      46             : 
      47          44 :     Int64Lowering lowering(graph(), machine(), common(), zone(), signature);
      48          44 :     lowering.LowerGraph();
      49          44 :   }
      50             : 
      51          41 :   void LowerGraph(Node* node, MachineRepresentation return_type,
      52             :                   MachineRepresentation rep = MachineRepresentation::kWord32,
      53             :                   int num_params = 0) {
      54             :     Signature<MachineRepresentation>::Builder sig_builder(zone(), 1,
      55          41 :                                                           num_params);
      56             :     sig_builder.AddReturn(return_type);
      57          45 :     for (int i = 0; i < num_params; i++) {
      58             :       sig_builder.AddParam(rep);
      59             :     }
      60          41 :     LowerGraph(node, sig_builder.Build());
      61          41 :   }
      62             : 
      63             :   void CompareCallDescriptors(const CallDescriptor* lhs,
      64             :                               const CallDescriptor* rhs) {
      65             :     EXPECT_THAT(lhs->CalleeSavedFPRegisters(), rhs->CalleeSavedFPRegisters());
      66             :     EXPECT_THAT(lhs->CalleeSavedRegisters(), rhs->CalleeSavedRegisters());
      67             :     EXPECT_THAT(lhs->FrameStateCount(), rhs->FrameStateCount());
      68             :     EXPECT_THAT(lhs->InputCount(), rhs->InputCount());
      69             :     for (size_t i = 0; i < lhs->InputCount(); i++) {
      70             :       EXPECT_THAT(lhs->GetInputLocation(i), rhs->GetInputLocation(i));
      71             :       EXPECT_THAT(lhs->GetInputType(i), rhs->GetInputType(i));
      72             :     }
      73             :     EXPECT_THAT(lhs->ReturnCount(), rhs->ReturnCount());
      74             :     for (size_t i = 0; i < lhs->ReturnCount(); i++) {
      75             :       EXPECT_THAT(lhs->GetReturnLocation(i), rhs->GetReturnLocation(i));
      76             :       EXPECT_THAT(lhs->GetReturnType(i), rhs->GetReturnType(i));
      77             :     }
      78             :     EXPECT_THAT(lhs->flags(), rhs->flags());
      79             :     EXPECT_THAT(lhs->kind(), rhs->kind());
      80             :   }
      81             : 
      82          57 :   int64_t value(int i) { return value_[i]; }
      83             : 
      84             :   int32_t low_word_value(int i) {
      85          59 :     return static_cast<int32_t>(value_[i] & 0xFFFFFFFF);
      86             :   }
      87             : 
      88             :   int32_t high_word_value(int i) {
      89          53 :     return static_cast<int32_t>(value_[i] >> 32);
      90             :   }
      91             : 
      92           4 :   void TestComparison(
      93             :       const Operator* op,
      94             :       Matcher<Node*> (*high_word_matcher)(const Matcher<Node*>& lhs_matcher,
      95             :                                           const Matcher<Node*>& rhs_matcher),
      96             :       Matcher<Node*> (*low_word_matcher)(const Matcher<Node*>& lhs_matcher,
      97             :                                          const Matcher<Node*>& rhs_matcher)) {
      98           8 :     LowerGraph(
      99             :         graph()->NewNode(op, Int64Constant(value(0)), Int64Constant(value(1))),
     100           4 :         MachineRepresentation::kWord32);
     101         116 :     EXPECT_THAT(
     102             :         graph()->end()->InputAt(1),
     103             :         IsReturn(IsWord32Or(
     104             :                      high_word_matcher(IsInt32Constant(high_word_value(0)),
     105             :                                        IsInt32Constant(high_word_value(1))),
     106             :                      IsWord32And(
     107             :                          IsWord32Equal(IsInt32Constant(high_word_value(0)),
     108             :                                        IsInt32Constant(high_word_value(1))),
     109             :                          low_word_matcher(IsInt32Constant(low_word_value(0)),
     110             :                                           IsInt32Constant(low_word_value(1))))),
     111           0 :                  start(), start()));
     112           4 :   }
     113             : 
     114             :  private:
     115             :   MachineOperatorBuilder machine_;
     116             :   int64_t value_[3];
     117             : };
     118             : 
     119       15444 : TEST_F(Int64LoweringTest, Int64Constant) {
     120           1 :   LowerGraph(Int64Constant(value(0)), MachineRepresentation::kWord64);
     121          12 :   EXPECT_THAT(graph()->end()->InputAt(1),
     122             :               IsReturn2(IsInt32Constant(low_word_value(0)),
     123           0 :                         IsInt32Constant(high_word_value(0)), start(), start()));
     124           1 : }
     125             : 
     126             : #if defined(V8_TARGET_LITTLE_ENDIAN)
     127             : #define LOAD_VERIFY(kLoad)                                                     \
     128             :   Matcher<Node*> high_word_load_matcher =                                      \
     129             :       Is##kLoad(MachineType::Int32(), IsInt32Constant(base),                   \
     130             :                 IsInt32Add(IsInt32Constant(index), IsInt32Constant(0x4)),      \
     131             :                 start(), start());                                             \
     132             :                                                                                \
     133             :   EXPECT_THAT(                                                                 \
     134             :       graph()->end()->InputAt(1),                                              \
     135             :       IsReturn2(                                                               \
     136             :           Is##kLoad(MachineType::Int32(), IsInt32Constant(base),               \
     137             :                     IsInt32Constant(index),                                    \
     138             :                     AllOf(CaptureEq(&high_word_load), high_word_load_matcher), \
     139             :                     start()),                                                  \
     140             :           AllOf(CaptureEq(&high_word_load), high_word_load_matcher), start(),  \
     141             :           start()));
     142             : #elif defined(V8_TARGET_BIG_ENDIAN)
     143             : #define LOAD_VERIFY(kLoad)                                                     \
     144             :   Matcher<Node*> high_word_load_matcher =                                      \
     145             :       Is##kLoad(MachineType::Int32(), IsInt32Constant(base),                   \
     146             :                 IsInt32Constant(index), start(), start());                     \
     147             :                                                                                \
     148             :   EXPECT_THAT(                                                                 \
     149             :       graph()->end()->InputAt(1),                                              \
     150             :       IsReturn2(                                                               \
     151             :           Is##kLoad(MachineType::Int32(), IsInt32Constant(base),               \
     152             :                     IsInt32Add(IsInt32Constant(index), IsInt32Constant(0x4)),  \
     153             :                     AllOf(CaptureEq(&high_word_load), high_word_load_matcher), \
     154             :                     start()),                                                  \
     155             :           AllOf(CaptureEq(&high_word_load), high_word_load_matcher), start(),  \
     156             :           start()));
     157             : #endif
     158             : 
     159             : #define INT64_LOAD_LOWERING(kLoad)                                       \
     160             :   int32_t base = 0x1234;                                                 \
     161             :   int32_t index = 0x5678;                                                \
     162             :                                                                          \
     163             :   LowerGraph(graph()->NewNode(machine()->kLoad(MachineType::Int64()),    \
     164             :                               Int32Constant(base), Int32Constant(index), \
     165             :                               start(), start()),                         \
     166             :              MachineRepresentation::kWord64);                            \
     167             :                                                                          \
     168             :   Capture<Node*> high_word_load;                                         \
     169             :   LOAD_VERIFY(kLoad)
     170             : 
     171       15479 : TEST_F(Int64LoweringTest, Int64Load) { INT64_LOAD_LOWERING(Load); }
     172             : 
     173       15444 : TEST_F(Int64LoweringTest, UnalignedInt64Load) {
     174          35 :   INT64_LOAD_LOWERING(UnalignedLoad);
     175           1 : }
     176             : 
     177             : #if defined(V8_TARGET_LITTLE_ENDIAN)
     178             : #define STORE_VERIFY(kStore, kRep)                                             \
     179             :   EXPECT_THAT(                                                                 \
     180             :       graph()->end()->InputAt(1),                                              \
     181             :       IsReturn(IsInt32Constant(return_value),                                  \
     182             :                Is##kStore(                                                     \
     183             :                    kRep, IsInt32Constant(base), IsInt32Constant(index),        \
     184             :                    IsInt32Constant(low_word_value(0)),                         \
     185             :                    Is##kStore(                                                 \
     186             :                        kRep, IsInt32Constant(base),                            \
     187             :                        IsInt32Add(IsInt32Constant(index), IsInt32Constant(4)), \
     188             :                        IsInt32Constant(high_word_value(0)), start(), start()), \
     189             :                    start()),                                                   \
     190             :                start()));
     191             : #elif defined(V8_TARGET_BIG_ENDIAN)
     192             : #define STORE_VERIFY(kStore, kRep)                                             \
     193             :   EXPECT_THAT(                                                                 \
     194             :       graph()->end()->InputAt(1),                                              \
     195             :       IsReturn(IsInt32Constant(return_value),                                  \
     196             :                Is##kStore(                                                     \
     197             :                    kRep, IsInt32Constant(base),                                \
     198             :                    IsInt32Add(IsInt32Constant(index), IsInt32Constant(4)),     \
     199             :                    IsInt32Constant(low_word_value(0)),                         \
     200             :                    Is##kStore(                                                 \
     201             :                        kRep, IsInt32Constant(base), IsInt32Constant(index),    \
     202             :                        IsInt32Constant(high_word_value(0)), start(), start()), \
     203             :                    start()),                                                   \
     204             :                start()));
     205             : #endif
     206             : 
     207             : #define INT64_STORE_LOWERING(kStore, kRep32, kRep64)                         \
     208             :   int32_t base = 1111;                                                       \
     209             :   int32_t index = 2222;                                                      \
     210             :   int32_t return_value = 0x5555;                                             \
     211             :                                                                              \
     212             :   Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 0);       \
     213             :   sig_builder.AddReturn(MachineRepresentation::kWord32);                     \
     214             :                                                                              \
     215             :   Node* store = graph()->NewNode(machine()->kStore(kRep64),                  \
     216             :                                  Int32Constant(base), Int32Constant(index),  \
     217             :                                  Int64Constant(value(0)), start(), start()); \
     218             :                                                                              \
     219             :   Node* zero = graph()->NewNode(common()->Int32Constant(0));                 \
     220             :   Node* ret = graph()->NewNode(common()->Return(), zero,                     \
     221             :                                Int32Constant(return_value), store, start()); \
     222             :                                                                              \
     223             :   NodeProperties::MergeControlToEnd(graph(), common(), ret);                 \
     224             :                                                                              \
     225             :   Int64Lowering lowering(graph(), machine(), common(), zone(),               \
     226             :                          sig_builder.Build());                               \
     227             :   lowering.LowerGraph();                                                     \
     228             :                                                                              \
     229             :   STORE_VERIFY(kStore, kRep32)
     230             : 
     231       15444 : TEST_F(Int64LoweringTest, Int64Store) {
     232             :   const StoreRepresentation rep64(MachineRepresentation::kWord64,
     233             :                                   WriteBarrierKind::kNoWriteBarrier);
     234             :   const StoreRepresentation rep32(MachineRepresentation::kWord32,
     235             :                                   WriteBarrierKind::kNoWriteBarrier);
     236          37 :   INT64_STORE_LOWERING(Store, rep32, rep64);
     237           1 : }
     238             : 
     239       15444 : TEST_F(Int64LoweringTest, Int32Store) {
     240             :   const StoreRepresentation rep32(MachineRepresentation::kWord32,
     241             :                                   WriteBarrierKind::kNoWriteBarrier);
     242             :   int32_t base = 1111;
     243             :   int32_t index = 2222;
     244             :   int32_t return_value = 0x5555;
     245             : 
     246             :   Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 0);
     247             :   sig_builder.AddReturn(MachineRepresentation::kWord32);
     248             : 
     249           2 :   Node* store = graph()->NewNode(machine()->Store(rep32), Int32Constant(base),
     250             :                                  Int32Constant(index), Int64Constant(value(0)),
     251             :                                  start(), start());
     252             : 
     253           1 :   Node* zero = graph()->NewNode(common()->Int32Constant(0));
     254           1 :   Node* ret = graph()->NewNode(common()->Return(), zero,
     255             :                                Int32Constant(return_value), store, start());
     256             : 
     257           1 :   NodeProperties::MergeControlToEnd(graph(), common(), ret);
     258             : 
     259             :   Int64Lowering lowering(graph(), machine(), common(), zone(),
     260           1 :                          sig_builder.Build());
     261           1 :   lowering.LowerGraph();
     262             : 
     263          18 :   EXPECT_THAT(
     264             :       graph()->end()->InputAt(1),
     265             :       IsReturn(IsInt32Constant(return_value),
     266             :                IsStore(rep32, IsInt32Constant(base), IsInt32Constant(index),
     267             :                        IsInt32Constant(low_word_value(0)), start(), start()),
     268           0 :                start()));
     269           1 : }
     270             : 
     271       15444 : TEST_F(Int64LoweringTest, Int64UnalignedStore) {
     272             :   const UnalignedStoreRepresentation rep64(MachineRepresentation::kWord64);
     273             :   const UnalignedStoreRepresentation rep32(MachineRepresentation::kWord32);
     274          37 :   INT64_STORE_LOWERING(UnalignedStore, rep32, rep64);
     275           1 : }
     276             : 
     277       15444 : TEST_F(Int64LoweringTest, Int64And) {
     278           4 :   LowerGraph(graph()->NewNode(machine()->Word64And(), Int64Constant(value(0)),
     279             :                               Int64Constant(value(1))),
     280           1 :              MachineRepresentation::kWord64);
     281          20 :   EXPECT_THAT(graph()->end()->InputAt(1),
     282             :               IsReturn2(IsWord32And(IsInt32Constant(low_word_value(0)),
     283             :                                     IsInt32Constant(low_word_value(1))),
     284             :                         IsWord32And(IsInt32Constant(high_word_value(0)),
     285             :                                     IsInt32Constant(high_word_value(1))),
     286           0 :                         start(), start()));
     287           1 : }
     288             : 
     289       15444 : TEST_F(Int64LoweringTest, TruncateInt64ToInt32) {
     290           3 :   LowerGraph(graph()->NewNode(machine()->TruncateInt64ToInt32(),
     291             :                               Int64Constant(value(0))),
     292           1 :              MachineRepresentation::kWord32);
     293           9 :   EXPECT_THAT(graph()->end()->InputAt(1),
     294           0 :               IsReturn(IsInt32Constant(low_word_value(0)), start(), start()));
     295           1 : }
     296             : 
     297       15444 : TEST_F(Int64LoweringTest, Parameter) {
     298           1 :   LowerGraph(Parameter(1), MachineRepresentation::kWord64,
     299           1 :              MachineRepresentation::kWord64, 1);
     300             : 
     301          10 :   EXPECT_THAT(graph()->end()->InputAt(1),
     302           0 :               IsReturn2(IsParameter(1), IsParameter(2), start(), start()));
     303           1 : }
     304             : 
     305       15444 : TEST_F(Int64LoweringTest, Parameter2) {
     306             :   Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 5);
     307             :   sig_builder.AddReturn(MachineRepresentation::kWord32);
     308             : 
     309             :   sig_builder.AddParam(MachineRepresentation::kWord32);
     310             :   sig_builder.AddParam(MachineRepresentation::kWord64);
     311             :   sig_builder.AddParam(MachineRepresentation::kFloat64);
     312             :   sig_builder.AddParam(MachineRepresentation::kWord64);
     313             :   sig_builder.AddParam(MachineRepresentation::kWord32);
     314             : 
     315             :   int start_parameter = start()->op()->ValueOutputCount();
     316           1 :   LowerGraph(Parameter(5), sig_builder.Build());
     317             : 
     318           8 :   EXPECT_THAT(graph()->end()->InputAt(1),
     319           0 :               IsReturn(IsParameter(7), start(), start()));
     320             :   // The parameter of the start node should increase by 2, because we lowered
     321             :   // two parameter nodes.
     322           1 :   EXPECT_THAT(start()->op()->ValueOutputCount(), start_parameter + 2);
     323           1 : }
     324             : 
     325       15444 : TEST_F(Int64LoweringTest, ParameterWithJSContextParam) {
     326             :   Signature<MachineRepresentation>::Builder sig_builder(zone(), 0, 2);
     327             :   sig_builder.AddParam(MachineRepresentation::kWord64);
     328             :   sig_builder.AddParam(MachineRepresentation::kWord64);
     329             : 
     330             :   auto sig = sig_builder.Build();
     331             : 
     332           1 :   Node* js_context = graph()->NewNode(
     333             :       common()->Parameter(Linkage::GetJSCallContextParamIndex(
     334             :                               static_cast<int>(sig->parameter_count()) + 1),
     335             :                           "%context"),
     336             :       start());
     337           1 :   LowerGraph(js_context, sig);
     338             : 
     339           7 :   EXPECT_THAT(graph()->end()->InputAt(1),
     340           0 :               IsReturn(js_context, start(), start()));
     341           1 : }
     342             : 
     343       15444 : TEST_F(Int64LoweringTest, ParameterWithJSClosureParam) {
     344             :   Signature<MachineRepresentation>::Builder sig_builder(zone(), 0, 2);
     345             :   sig_builder.AddParam(MachineRepresentation::kWord64);
     346             :   sig_builder.AddParam(MachineRepresentation::kWord64);
     347             : 
     348             :   auto sig = sig_builder.Build();
     349             : 
     350           1 :   Node* js_closure = graph()->NewNode(
     351             :       common()->Parameter(Linkage::kJSCallClosureParamIndex, "%closure"),
     352             :       start());
     353           1 :   LowerGraph(js_closure, sig);
     354             : 
     355           7 :   EXPECT_THAT(graph()->end()->InputAt(1),
     356           0 :               IsReturn(js_closure, start(), start()));
     357           1 : }
     358             : 
     359             : // The following tests assume that pointers are 32 bit and therefore pointers do
     360             : // not get lowered. This assumption does not hold on 64 bit platforms, which
     361             : // invalidates these tests.
     362             : // TODO(wasm): We can find an alternative to re-activate these tests.
     363             : #if V8_TARGET_ARCH_32_BIT
     364             : TEST_F(Int64LoweringTest, CallI64Return) {
     365             :   int32_t function = 0x9999;
     366             :   Node* context_address = Int32Constant(0);
     367             : 
     368             :   wasm::FunctionSig::Builder sig_builder(zone(), 1, 0);
     369             :   sig_builder.AddReturn(wasm::kWasmI64);
     370             : 
     371             :   auto call_descriptor =
     372             :       compiler::GetWasmCallDescriptor(zone(), sig_builder.Build());
     373             : 
     374             :   LowerGraph(
     375             :       graph()->NewNode(common()->Call(call_descriptor), Int32Constant(function),
     376             :                        context_address, start(), start()),
     377             :       MachineRepresentation::kWord64);
     378             : 
     379             :   Capture<Node*> call;
     380             :   Matcher<Node*> call_matcher =
     381             :       IsCall(testing::_, IsInt32Constant(function), start(), start());
     382             : 
     383             :   EXPECT_THAT(graph()->end()->InputAt(1),
     384             :               IsReturn2(IsProjection(0, AllOf(CaptureEq(&call), call_matcher)),
     385             :                         IsProjection(1, AllOf(CaptureEq(&call), call_matcher)),
     386             :                         start(), start()));
     387             : 
     388             :   CompareCallDescriptors(
     389             :       CallDescriptorOf(
     390             :           graph()->end()->InputAt(1)->InputAt(1)->InputAt(0)->op()),
     391             :       compiler::GetI32WasmCallDescriptor(zone(), call_descriptor));
     392             : }
     393             : 
     394             : TEST_F(Int64LoweringTest, CallI64Parameter) {
     395             :   int32_t function = 0x9999;
     396             :   Node* context_address = Int32Constant(0);
     397             : 
     398             :   wasm::FunctionSig::Builder sig_builder(zone(), 1, 3);
     399             :   sig_builder.AddReturn(wasm::kWasmI32);
     400             :   sig_builder.AddParam(wasm::kWasmI64);
     401             :   sig_builder.AddParam(wasm::kWasmI32);
     402             :   sig_builder.AddParam(wasm::kWasmI64);
     403             : 
     404             :   auto call_descriptor =
     405             :       compiler::GetWasmCallDescriptor(zone(), sig_builder.Build());
     406             : 
     407             :   LowerGraph(
     408             :       graph()->NewNode(common()->Call(call_descriptor), Int32Constant(function),
     409             :                        context_address, Int64Constant(value(0)),
     410             :                        Int32Constant(low_word_value(1)),
     411             :                        Int64Constant(value(2)), start(), start()),
     412             :       MachineRepresentation::kWord32);
     413             : 
     414             :   EXPECT_THAT(
     415             :       graph()->end()->InputAt(1),
     416             :       IsReturn(IsCall(testing::_, IsInt32Constant(function), context_address,
     417             :                       IsInt32Constant(low_word_value(0)),
     418             :                       IsInt32Constant(high_word_value(0)),
     419             :                       IsInt32Constant(low_word_value(1)),
     420             :                       IsInt32Constant(low_word_value(2)),
     421             :                       IsInt32Constant(high_word_value(2)), start(), start()),
     422             :                start(), start()));
     423             : 
     424             :   CompareCallDescriptors(
     425             :       CallDescriptorOf(graph()->end()->InputAt(1)->InputAt(1)->op()),
     426             :       compiler::GetI32WasmCallDescriptor(zone(), call_descriptor));
     427             : }
     428             : 
     429             : TEST_F(Int64LoweringTest, Int64Add) {
     430             :   LowerGraph(graph()->NewNode(machine()->Int64Add(), Int64Constant(value(0)),
     431             :                               Int64Constant(value(1))),
     432             :              MachineRepresentation::kWord64);
     433             : 
     434             :   Capture<Node*> add;
     435             :   Matcher<Node*> add_matcher = IsInt32PairAdd(
     436             :       IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)),
     437             :       IsInt32Constant(low_word_value(1)), IsInt32Constant(high_word_value(1)));
     438             : 
     439             :   EXPECT_THAT(graph()->end()->InputAt(1),
     440             :               IsReturn2(IsProjection(0, AllOf(CaptureEq(&add), add_matcher)),
     441             :                         IsProjection(1, AllOf(CaptureEq(&add), add_matcher)),
     442             :                         start(), start()));
     443             : }
     444             : #endif
     445             : 
     446       15444 : TEST_F(Int64LoweringTest, Int64Sub) {
     447           4 :   LowerGraph(graph()->NewNode(machine()->Int64Sub(), Int64Constant(value(0)),
     448             :                               Int64Constant(value(1))),
     449           1 :              MachineRepresentation::kWord64);
     450             : 
     451             :   Capture<Node*> sub;
     452             :   Matcher<Node*> sub_matcher = IsInt32PairSub(
     453           6 :       IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)),
     454           7 :       IsInt32Constant(low_word_value(1)), IsInt32Constant(high_word_value(1)));
     455             : 
     456          18 :   EXPECT_THAT(graph()->end()->InputAt(1),
     457             :               IsReturn2(IsProjection(0, AllOf(CaptureEq(&sub), sub_matcher)),
     458             :                         IsProjection(1, AllOf(CaptureEq(&sub), sub_matcher)),
     459           0 :                         start(), start()));
     460           1 : }
     461             : 
     462       15444 : TEST_F(Int64LoweringTest, Int64Mul) {
     463           4 :   LowerGraph(graph()->NewNode(machine()->Int64Mul(), Int64Constant(value(0)),
     464             :                               Int64Constant(value(1))),
     465           1 :              MachineRepresentation::kWord64);
     466             : 
     467             :   Capture<Node*> mul_capture;
     468             :   Matcher<Node*> mul_matcher = IsInt32PairMul(
     469           6 :       IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)),
     470           7 :       IsInt32Constant(low_word_value(1)), IsInt32Constant(high_word_value(1)));
     471             : 
     472          18 :   EXPECT_THAT(
     473             :       graph()->end()->InputAt(1),
     474             :       IsReturn2(IsProjection(0, AllOf(CaptureEq(&mul_capture), mul_matcher)),
     475             :                 IsProjection(1, AllOf(CaptureEq(&mul_capture), mul_matcher)),
     476           0 :                 start(), start()));
     477           1 : }
     478             : 
     479       15444 : TEST_F(Int64LoweringTest, Int64Ior) {
     480           4 :   LowerGraph(graph()->NewNode(machine()->Word64Or(), Int64Constant(value(0)),
     481             :                               Int64Constant(value(1))),
     482           1 :              MachineRepresentation::kWord64);
     483          20 :   EXPECT_THAT(graph()->end()->InputAt(1),
     484             :               IsReturn2(IsWord32Or(IsInt32Constant(low_word_value(0)),
     485             :                                    IsInt32Constant(low_word_value(1))),
     486             :                         IsWord32Or(IsInt32Constant(high_word_value(0)),
     487             :                                    IsInt32Constant(high_word_value(1))),
     488           0 :                         start(), start()));
     489           1 : }
     490             : 
     491       15444 : TEST_F(Int64LoweringTest, Int64Xor) {
     492           4 :   LowerGraph(graph()->NewNode(machine()->Word64Xor(), Int64Constant(value(0)),
     493             :                               Int64Constant(value(1))),
     494           1 :              MachineRepresentation::kWord64);
     495          20 :   EXPECT_THAT(graph()->end()->InputAt(1),
     496             :               IsReturn2(IsWord32Xor(IsInt32Constant(low_word_value(0)),
     497             :                                     IsInt32Constant(low_word_value(1))),
     498             :                         IsWord32Xor(IsInt32Constant(high_word_value(0)),
     499             :                                     IsInt32Constant(high_word_value(1))),
     500           0 :                         start(), start()));
     501           1 : }
     502             : 
     503       15444 : TEST_F(Int64LoweringTest, Int64Shl) {
     504           4 :   LowerGraph(graph()->NewNode(machine()->Word64Shl(), Int64Constant(value(0)),
     505             :                               Int64Constant(value(1))),
     506           1 :              MachineRepresentation::kWord64);
     507             : 
     508             :   Capture<Node*> shl;
     509             :   Matcher<Node*> shl_matcher = IsWord32PairShl(
     510           6 :       IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)),
     511           4 :       IsInt32Constant(low_word_value(1)));
     512             : 
     513          18 :   EXPECT_THAT(graph()->end()->InputAt(1),
     514             :               IsReturn2(IsProjection(0, AllOf(CaptureEq(&shl), shl_matcher)),
     515             :                         IsProjection(1, AllOf(CaptureEq(&shl), shl_matcher)),
     516           0 :                         start(), start()));
     517           1 : }
     518             : 
     519       15444 : TEST_F(Int64LoweringTest, Int64ShrU) {
     520           4 :   LowerGraph(graph()->NewNode(machine()->Word64Shr(), Int64Constant(value(0)),
     521             :                               Int64Constant(value(1))),
     522           1 :              MachineRepresentation::kWord64);
     523             : 
     524             :   Capture<Node*> shr;
     525             :   Matcher<Node*> shr_matcher = IsWord32PairShr(
     526           6 :       IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)),
     527           4 :       IsInt32Constant(low_word_value(1)));
     528             : 
     529          18 :   EXPECT_THAT(graph()->end()->InputAt(1),
     530             :               IsReturn2(IsProjection(0, AllOf(CaptureEq(&shr), shr_matcher)),
     531             :                         IsProjection(1, AllOf(CaptureEq(&shr), shr_matcher)),
     532           0 :                         start(), start()));
     533           1 : }
     534             : 
     535       15444 : TEST_F(Int64LoweringTest, Int64ShrS) {
     536           4 :   LowerGraph(graph()->NewNode(machine()->Word64Sar(), Int64Constant(value(0)),
     537             :                               Int64Constant(value(1))),
     538           1 :              MachineRepresentation::kWord64);
     539             : 
     540             :   Capture<Node*> sar;
     541             :   Matcher<Node*> sar_matcher = IsWord32PairSar(
     542           6 :       IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)),
     543           4 :       IsInt32Constant(low_word_value(1)));
     544             : 
     545          18 :   EXPECT_THAT(graph()->end()->InputAt(1),
     546             :               IsReturn2(IsProjection(0, AllOf(CaptureEq(&sar), sar_matcher)),
     547             :                         IsProjection(1, AllOf(CaptureEq(&sar), sar_matcher)),
     548           0 :                         start(), start()));
     549           1 : }
     550             : 
     551       15444 : TEST_F(Int64LoweringTest, Int64Eq) {
     552           4 :   LowerGraph(graph()->NewNode(machine()->Word64Equal(), Int64Constant(value(0)),
     553             :                               Int64Constant(value(1))),
     554           1 :              MachineRepresentation::kWord32);
     555          24 :   EXPECT_THAT(
     556             :       graph()->end()->InputAt(1),
     557             :       IsReturn(IsWord32Equal(
     558             :                    IsWord32Or(IsWord32Xor(IsInt32Constant(low_word_value(0)),
     559             :                                           IsInt32Constant(low_word_value(1))),
     560             :                               IsWord32Xor(IsInt32Constant(high_word_value(0)),
     561             :                                           IsInt32Constant(high_word_value(1)))),
     562             :                    IsInt32Constant(0)),
     563           0 :                start(), start()));
     564           1 : }
     565             : 
     566       15444 : TEST_F(Int64LoweringTest, Int64LtS) {
     567           1 :   TestComparison(machine()->Int64LessThan(), IsInt32LessThan, IsUint32LessThan);
     568           1 : }
     569             : 
     570       15444 : TEST_F(Int64LoweringTest, Int64LeS) {
     571           1 :   TestComparison(machine()->Int64LessThanOrEqual(), IsInt32LessThan,
     572           1 :                  IsUint32LessThanOrEqual);
     573           1 : }
     574             : 
     575       15444 : TEST_F(Int64LoweringTest, Int64LtU) {
     576           1 :   TestComparison(machine()->Uint64LessThan(), IsUint32LessThan,
     577           1 :                  IsUint32LessThan);
     578           1 : }
     579             : 
     580       15444 : TEST_F(Int64LoweringTest, Int64LeU) {
     581           1 :   TestComparison(machine()->Uint64LessThanOrEqual(), IsUint32LessThan,
     582           1 :                  IsUint32LessThanOrEqual);
     583           1 : }
     584             : 
     585       15444 : TEST_F(Int64LoweringTest, I32ConvertI64) {
     586           3 :   LowerGraph(graph()->NewNode(machine()->TruncateInt64ToInt32(),
     587             :                               Int64Constant(value(0))),
     588           1 :              MachineRepresentation::kWord32);
     589           9 :   EXPECT_THAT(graph()->end()->InputAt(1),
     590           0 :               IsReturn(IsInt32Constant(low_word_value(0)), start(), start()));
     591           1 : }
     592             : 
     593       15444 : TEST_F(Int64LoweringTest, I64SConvertI32) {
     594           3 :   LowerGraph(graph()->NewNode(machine()->ChangeInt32ToInt64(),
     595             :                               Int32Constant(low_word_value(0))),
     596           1 :              MachineRepresentation::kWord64);
     597             : 
     598          15 :   EXPECT_THAT(graph()->end()->InputAt(1),
     599             :               IsReturn2(IsInt32Constant(low_word_value(0)),
     600             :                         IsWord32Sar(IsInt32Constant(low_word_value(0)),
     601             :                                     IsInt32Constant(31)),
     602           0 :                         start(), start()));
     603           1 : }
     604             : 
     605       15444 : TEST_F(Int64LoweringTest, I64SConvertI32_2) {
     606           4 :   LowerGraph(
     607             :       graph()->NewNode(machine()->ChangeInt32ToInt64(),
     608             :                        graph()->NewNode(machine()->TruncateInt64ToInt32(),
     609             :                                         Int64Constant(value(0)))),
     610           1 :       MachineRepresentation::kWord64);
     611             : 
     612          15 :   EXPECT_THAT(graph()->end()->InputAt(1),
     613             :               IsReturn2(IsInt32Constant(low_word_value(0)),
     614             :                         IsWord32Sar(IsInt32Constant(low_word_value(0)),
     615             :                                     IsInt32Constant(31)),
     616           0 :                         start(), start()));
     617           1 : }
     618             : 
     619       15444 : TEST_F(Int64LoweringTest, I64UConvertI32) {
     620           3 :   LowerGraph(graph()->NewNode(machine()->ChangeUint32ToUint64(),
     621             :                               Int32Constant(low_word_value(0))),
     622           1 :              MachineRepresentation::kWord64);
     623             : 
     624          11 :   EXPECT_THAT(graph()->end()->InputAt(1),
     625             :               IsReturn2(IsInt32Constant(low_word_value(0)), IsInt32Constant(0),
     626           0 :                         start(), start()));
     627           1 : }
     628             : 
     629       15444 : TEST_F(Int64LoweringTest, I64UConvertI32_2) {
     630           4 :   LowerGraph(
     631             :       graph()->NewNode(machine()->ChangeUint32ToUint64(),
     632             :                        graph()->NewNode(machine()->TruncateInt64ToInt32(),
     633             :                                         Int64Constant(value(0)))),
     634           1 :       MachineRepresentation::kWord64);
     635             : 
     636          11 :   EXPECT_THAT(graph()->end()->InputAt(1),
     637             :               IsReturn2(IsInt32Constant(low_word_value(0)), IsInt32Constant(0),
     638           0 :                         start(), start()));
     639           1 : }
     640             : 
     641       15444 : TEST_F(Int64LoweringTest, F64ReinterpretI64) {
     642           3 :   LowerGraph(graph()->NewNode(machine()->BitcastInt64ToFloat64(),
     643             :                               Int64Constant(value(0))),
     644           1 :              MachineRepresentation::kFloat64);
     645             : 
     646             :   Capture<Node*> stack_slot_capture;
     647             :   Matcher<Node*> stack_slot_matcher =
     648           2 :       IsStackSlot(StackSlotRepresentation(sizeof(int64_t), 0));
     649             : 
     650             :   Capture<Node*> store_capture;
     651             :   Matcher<Node*> store_matcher =
     652             :       IsStore(StoreRepresentation(MachineRepresentation::kWord32,
     653             :                                   WriteBarrierKind::kNoWriteBarrier),
     654           3 :               AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher),
     655           3 :               IsInt32Constant(kInt64LowerHalfMemoryOffset),
     656           3 :               IsInt32Constant(low_word_value(0)),
     657           8 :               IsStore(StoreRepresentation(MachineRepresentation::kWord32,
     658             :                                           WriteBarrierKind::kNoWriteBarrier),
     659           3 :                       AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher),
     660           3 :                       IsInt32Constant(kInt64UpperHalfMemoryOffset),
     661           3 :                       IsInt32Constant(high_word_value(0)), start(), start()),
     662           6 :               start());
     663             : 
     664          19 :   EXPECT_THAT(
     665             :       graph()->end()->InputAt(1),
     666             :       IsReturn(IsLoad(MachineType::Float64(),
     667             :                       AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher),
     668             :                       IsInt32Constant(0),
     669             :                       AllOf(CaptureEq(&store_capture), store_matcher), start()),
     670           0 :                start(), start()));
     671           1 : }
     672             : 
     673       15444 : TEST_F(Int64LoweringTest, I64ReinterpretF64) {
     674           3 :   LowerGraph(graph()->NewNode(machine()->BitcastFloat64ToInt64(),
     675             :                               Float64Constant(bit_cast<double>(value(0)))),
     676           1 :              MachineRepresentation::kWord64);
     677             : 
     678             :   Capture<Node*> stack_slot;
     679             :   Matcher<Node*> stack_slot_matcher =
     680           2 :       IsStackSlot(StackSlotRepresentation(sizeof(int64_t), 0));
     681             : 
     682             :   Capture<Node*> store;
     683             :   Matcher<Node*> store_matcher = IsStore(
     684             :       StoreRepresentation(MachineRepresentation::kFloat64,
     685             :                           WriteBarrierKind::kNoWriteBarrier),
     686           5 :       AllOf(CaptureEq(&stack_slot), stack_slot_matcher), IsInt32Constant(0),
     687          10 :       IsFloat64Constant(bit_cast<double>(value(0))), start(), start());
     688             : 
     689          32 :   EXPECT_THAT(
     690             :       graph()->end()->InputAt(1),
     691             :       IsReturn2(IsLoad(MachineType::Int32(),
     692             :                        AllOf(CaptureEq(&stack_slot), stack_slot_matcher),
     693             :                        IsInt32Constant(kInt64LowerHalfMemoryOffset),
     694             :                        AllOf(CaptureEq(&store), store_matcher), start()),
     695             :                 IsLoad(MachineType::Int32(),
     696             :                        AllOf(CaptureEq(&stack_slot), stack_slot_matcher),
     697             :                        IsInt32Constant(kInt64UpperHalfMemoryOffset),
     698             :                        AllOf(CaptureEq(&store), store_matcher), start()),
     699           0 :                 start(), start()));
     700           1 : }
     701             : 
     702       15444 : TEST_F(Int64LoweringTest, I64Clz) {
     703           3 :   LowerGraph(graph()->NewNode(machine()->Word64Clz(), Int64Constant(value(0))),
     704           1 :              MachineRepresentation::kWord64);
     705             : 
     706             :   Capture<Node*> branch_capture;
     707             :   Matcher<Node*> branch_matcher = IsBranch(
     708           7 :       IsWord32Equal(IsInt32Constant(high_word_value(0)), IsInt32Constant(0)),
     709           3 :       start());
     710             : 
     711          32 :   EXPECT_THAT(
     712             :       graph()->end()->InputAt(1),
     713             :       IsReturn2(
     714             :           IsPhi(MachineRepresentation::kWord32,
     715             :                 IsInt32Add(IsWord32Clz(IsInt32Constant(low_word_value(0))),
     716             :                            IsInt32Constant(32)),
     717             :                 IsWord32Clz(IsInt32Constant(high_word_value(0))),
     718             :                 IsMerge(
     719             :                     IsIfTrue(AllOf(CaptureEq(&branch_capture), branch_matcher)),
     720             :                     IsIfFalse(
     721             :                         AllOf(CaptureEq(&branch_capture), branch_matcher)))),
     722           0 :           IsInt32Constant(0), start(), start()));
     723           1 : }
     724             : 
     725       15444 : TEST_F(Int64LoweringTest, I64Ctz) {
     726           4 :   LowerGraph(graph()->NewNode(machine()->Word64Ctz().placeholder(),
     727             :                               Int64Constant(value(0))),
     728           1 :              MachineRepresentation::kWord64);
     729             :   Capture<Node*> branch_capture;
     730             :   Matcher<Node*> branch_matcher = IsBranch(
     731           7 :       IsWord32Equal(IsInt32Constant(low_word_value(0)), IsInt32Constant(0)),
     732           3 :       start());
     733          32 :   EXPECT_THAT(
     734             :       graph()->end()->InputAt(1),
     735             :       IsReturn2(
     736             :           IsPhi(MachineRepresentation::kWord32,
     737             :                 IsInt32Add(IsWord32Ctz(IsInt32Constant(high_word_value(0))),
     738             :                            IsInt32Constant(32)),
     739             :                 IsWord32Ctz(IsInt32Constant(low_word_value(0))),
     740             :                 IsMerge(
     741             :                     IsIfTrue(AllOf(CaptureEq(&branch_capture), branch_matcher)),
     742             :                     IsIfFalse(
     743             :                         AllOf(CaptureEq(&branch_capture), branch_matcher)))),
     744           0 :           IsInt32Constant(0), start(), start()));
     745           1 : }
     746             : 
     747       15444 : TEST_F(Int64LoweringTest, Dfs) {
     748           1 :   Node* common = Int64Constant(value(0));
     749           4 :   LowerGraph(graph()->NewNode(machine()->Word64And(), common,
     750             :                               graph()->NewNode(machine()->Word64And(), common,
     751             :                                                Int64Constant(value(1)))),
     752           1 :              MachineRepresentation::kWord64);
     753             : 
     754          28 :   EXPECT_THAT(
     755             :       graph()->end()->InputAt(1),
     756             :       IsReturn2(IsWord32And(IsInt32Constant(low_word_value(0)),
     757             :                             IsWord32And(IsInt32Constant(low_word_value(0)),
     758             :                                         IsInt32Constant(low_word_value(1)))),
     759             :                 IsWord32And(IsInt32Constant(high_word_value(0)),
     760             :                             IsWord32And(IsInt32Constant(high_word_value(0)),
     761             :                                         IsInt32Constant(high_word_value(1)))),
     762           0 :                 start(), start()));
     763           1 : }
     764             : 
     765       15444 : TEST_F(Int64LoweringTest, I64Popcnt) {
     766           4 :   LowerGraph(graph()->NewNode(machine()->Word64Popcnt().placeholder(),
     767             :                               Int64Constant(value(0))),
     768           1 :              MachineRepresentation::kWord64);
     769             : 
     770          17 :   EXPECT_THAT(
     771             :       graph()->end()->InputAt(1),
     772             :       IsReturn2(IsInt32Add(IsWord32Popcnt(IsInt32Constant(low_word_value(0))),
     773             :                            IsWord32Popcnt(IsInt32Constant(high_word_value(0)))),
     774           0 :                 IsInt32Constant(0), start(), start()));
     775           1 : }
     776             : 
     777       15444 : TEST_F(Int64LoweringTest, I64Ror) {
     778           4 :   LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)),
     779             :                               Parameter(0)),
     780           1 :              MachineRepresentation::kWord64, MachineRepresentation::kWord64, 1);
     781             : 
     782             :   Matcher<Node*> branch_lt32_matcher =
     783           7 :       IsBranch(IsInt32LessThan(IsParameter(0), IsInt32Constant(32)), start());
     784             : 
     785             :   Matcher<Node*> low_input_matcher = IsPhi(
     786           3 :       MachineRepresentation::kWord32, IsInt32Constant(low_word_value(0)),
     787           3 :       IsInt32Constant(high_word_value(0)),
     788           6 :       IsMerge(IsIfTrue(branch_lt32_matcher), IsIfFalse(branch_lt32_matcher)));
     789             : 
     790             :   Matcher<Node*> high_input_matcher = IsPhi(
     791           3 :       MachineRepresentation::kWord32, IsInt32Constant(high_word_value(0)),
     792           3 :       IsInt32Constant(low_word_value(0)),
     793           6 :       IsMerge(IsIfTrue(branch_lt32_matcher), IsIfFalse(branch_lt32_matcher)));
     794             : 
     795             :   Matcher<Node*> shift_matcher =
     796           5 :       IsWord32And(IsParameter(0), IsInt32Constant(0x1F));
     797             : 
     798             :   Matcher<Node*> bit_mask_matcher = IsWord32Shl(
     799           4 :       IsWord32Sar(IsInt32Constant(std::numeric_limits<int32_t>::min()),
     800             :                   shift_matcher),
     801           4 :       IsInt32Constant(1));
     802             : 
     803             :   Matcher<Node*> inv_mask_matcher =
     804           3 :       IsWord32Xor(bit_mask_matcher, IsInt32Constant(-1));
     805             : 
     806          16 :   EXPECT_THAT(
     807             :       graph()->end()->InputAt(1),
     808             :       IsReturn2(
     809             :           IsWord32Or(IsWord32And(IsWord32Ror(low_input_matcher, shift_matcher),
     810             :                                  inv_mask_matcher),
     811             :                      IsWord32And(IsWord32Ror(high_input_matcher, shift_matcher),
     812             :                                  bit_mask_matcher)),
     813             :           IsWord32Or(IsWord32And(IsWord32Ror(high_input_matcher, shift_matcher),
     814             :                                  inv_mask_matcher),
     815             :                      IsWord32And(IsWord32Ror(low_input_matcher, shift_matcher),
     816             :                                  bit_mask_matcher)),
     817           0 :           start(), start()));
     818           1 : }
     819             : 
     820       15444 : TEST_F(Int64LoweringTest, I64Ror_0) {
     821           4 :   LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)),
     822             :                               Int32Constant(0)),
     823           1 :              MachineRepresentation::kWord64);
     824             : 
     825          12 :   EXPECT_THAT(graph()->end()->InputAt(1),
     826             :               IsReturn2(IsInt32Constant(low_word_value(0)),
     827           0 :                         IsInt32Constant(high_word_value(0)), start(), start()));
     828           1 : }
     829             : 
     830       15444 : TEST_F(Int64LoweringTest, I64Ror_32) {
     831           4 :   LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)),
     832             :                               Int32Constant(32)),
     833           1 :              MachineRepresentation::kWord64);
     834             : 
     835          12 :   EXPECT_THAT(graph()->end()->InputAt(1),
     836             :               IsReturn2(IsInt32Constant(high_word_value(0)),
     837           0 :                         IsInt32Constant(low_word_value(0)), start(), start()));
     838           1 : }
     839             : 
     840       15444 : TEST_F(Int64LoweringTest, I64Ror_11) {
     841           4 :   LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)),
     842             :                               Int32Constant(11)),
     843           1 :              MachineRepresentation::kWord64);
     844             : 
     845          32 :   EXPECT_THAT(
     846             :       graph()->end()->InputAt(1),
     847             :       IsReturn2(IsWord32Or(IsWord32Shr(IsInt32Constant(low_word_value(0)),
     848             :                                        IsInt32Constant(11)),
     849             :                            IsWord32Shl(IsInt32Constant(high_word_value(0)),
     850             :                                        IsInt32Constant(21))),
     851             :                 IsWord32Or(IsWord32Shr(IsInt32Constant(high_word_value(0)),
     852             :                                        IsInt32Constant(11)),
     853             :                            IsWord32Shl(IsInt32Constant(low_word_value(0)),
     854             :                                        IsInt32Constant(21))),
     855           0 :                 start(), start()));
     856           1 : }
     857             : 
     858       15444 : TEST_F(Int64LoweringTest, I64Ror_43) {
     859           4 :   LowerGraph(graph()->NewNode(machine()->Word64Ror(), Int64Constant(value(0)),
     860             :                               Int32Constant(43)),
     861           1 :              MachineRepresentation::kWord64);
     862             : 
     863          32 :   EXPECT_THAT(
     864             :       graph()->end()->InputAt(1),
     865             :       IsReturn2(IsWord32Or(IsWord32Shr(IsInt32Constant(high_word_value(0)),
     866             :                                        IsInt32Constant(11)),
     867             :                            IsWord32Shl(IsInt32Constant(low_word_value(0)),
     868             :                                        IsInt32Constant(21))),
     869             :                 IsWord32Or(IsWord32Shr(IsInt32Constant(low_word_value(0)),
     870             :                                        IsInt32Constant(11)),
     871             :                            IsWord32Shl(IsInt32Constant(high_word_value(0)),
     872             :                                        IsInt32Constant(21))),
     873           0 :                 start(), start()));
     874           1 : }
     875             : 
     876       15444 : TEST_F(Int64LoweringTest, I64PhiWord64) {
     877           4 :   LowerGraph(graph()->NewNode(common()->Phi(MachineRepresentation::kWord64, 2),
     878             :                               Int64Constant(value(0)), Int64Constant(value(1)),
     879             :                               start()),
     880           1 :              MachineRepresentation::kWord64);
     881             : 
     882          24 :   EXPECT_THAT(graph()->end()->InputAt(1),
     883             :               IsReturn2(IsPhi(MachineRepresentation::kWord32,
     884             :                               IsInt32Constant(low_word_value(0)),
     885             :                               IsInt32Constant(low_word_value(1)), start()),
     886             :                         IsPhi(MachineRepresentation::kWord32,
     887             :                               IsInt32Constant(high_word_value(0)),
     888             :                               IsInt32Constant(high_word_value(1)), start()),
     889           0 :                         start(), start()));
     890           1 : }
     891             : 
     892           3 : void TestPhi(Int64LoweringTest* test, MachineRepresentation rep, Node* v1,
     893             :              Node* v2) {
     894           3 :   test->LowerGraph(test->graph()->NewNode(test->common()->Phi(rep, 2), v1, v2,
     895             :                                           test->start()),
     896           3 :                    rep);
     897             : 
     898          33 :   EXPECT_THAT(test->graph()->end()->InputAt(1),
     899             :               IsReturn(IsPhi(rep, v1, v2, test->start()), test->start(),
     900           0 :                        test->start()));
     901           3 : }
     902             : 
     903       15444 : TEST_F(Int64LoweringTest, I64PhiFloat32) {
     904           1 :   TestPhi(this, MachineRepresentation::kFloat32, Float32Constant(1.5),
     905           1 :           Float32Constant(2.5));
     906           1 : }
     907             : 
     908       15444 : TEST_F(Int64LoweringTest, I64PhiFloat64) {
     909           1 :   TestPhi(this, MachineRepresentation::kFloat64, Float32Constant(1.5),
     910           1 :           Float32Constant(2.5));
     911           1 : }
     912             : 
     913       15444 : TEST_F(Int64LoweringTest, I64PhiWord32) {
     914           1 :   TestPhi(this, MachineRepresentation::kWord32, Float32Constant(1),
     915           1 :           Float32Constant(2));
     916           1 : }
     917             : 
     918       15444 : TEST_F(Int64LoweringTest, I64ReverseBytes) {
     919           3 :   LowerGraph(graph()->NewNode(machine()->Word64ReverseBytes(),
     920             :                               Int64Constant(value(0))),
     921           1 :              MachineRepresentation::kWord64);
     922          14 :   EXPECT_THAT(
     923             :       graph()->end()->InputAt(1),
     924             :       IsReturn2(IsWord32ReverseBytes(IsInt32Constant(high_word_value(0))),
     925             :                 IsWord32ReverseBytes(IsInt32Constant(low_word_value(0))),
     926           0 :                 start(), start()));
     927           1 : }
     928             : 
     929       15444 : TEST_F(Int64LoweringTest, EffectPhiLoop) {
     930             :   // Construct a cycle consisting of an EffectPhi, a Store, and a Load.
     931           1 :   Node* eff_phi = graph()->NewNode(common()->EffectPhi(1), graph()->start(),
     932             :                                    graph()->start());
     933             : 
     934             :   StoreRepresentation store_rep(MachineRepresentation::kWord64,
     935             :                                 WriteBarrierKind::kNoWriteBarrier);
     936           1 :   LoadRepresentation load_rep(MachineType::Int64());
     937             : 
     938             :   Node* load =
     939           3 :       graph()->NewNode(machine()->Load(load_rep), Int64Constant(value(0)),
     940             :                        Int64Constant(value(1)), eff_phi, graph()->start());
     941             : 
     942             :   Node* store =
     943           2 :       graph()->NewNode(machine()->Store(store_rep), Int64Constant(value(0)),
     944             :                        Int64Constant(value(1)), load, load, graph()->start());
     945             : 
     946           1 :   eff_phi->InsertInput(zone(), 1, store);
     947           1 :   NodeProperties::ChangeOp(eff_phi,
     948           1 :                            common()->ResizeMergeOrPhi(eff_phi->op(), 2));
     949             : 
     950           1 :   LowerGraph(load, MachineRepresentation::kWord64);
     951           1 : }
     952             : 
     953       15444 : TEST_F(Int64LoweringTest, LoopCycle) {
     954             :   // New node with two placeholders.
     955           2 :   Node* compare = graph()->NewNode(machine()->Word64Equal(), Int64Constant(0),
     956             :                                    Int64Constant(value(0)));
     957             : 
     958           5 :   Node* load = graph()->NewNode(
     959             :       machine()->Load(MachineType::Int64()), Int64Constant(value(1)),
     960             :       Int64Constant(value(2)), graph()->start(),
     961             :       graph()->NewNode(
     962             :           common()->Loop(2), graph()->start(),
     963             :           graph()->NewNode(common()->IfFalse(),
     964             :                            graph()->NewNode(common()->Branch(), compare,
     965             :                                             graph()->start()))));
     966             : 
     967           1 :   NodeProperties::ReplaceValueInput(compare, load, 0);
     968             : 
     969           1 :   LowerGraph(load, MachineRepresentation::kWord64);
     970           1 : }
     971             : }  // namespace compiler
     972             : }  // namespace internal
     973        9264 : }  // namespace v8

Generated by: LCOV version 1.10