Index: test/cctest/compiler/test-branch-combine.cc |
diff --git a/test/cctest/compiler/test-branch-combine.cc b/test/cctest/compiler/test-branch-combine.cc |
index c3b4308a93ed275c54630428687f1acc5386e4f3..11395dbe51b710e454ea3a247a9de159477c39d6 100644 |
--- a/test/cctest/compiler/test-branch-combine.cc |
+++ b/test/cctest/compiler/test-branch-combine.cc |
@@ -457,6 +457,41 @@ TEST(BranchCombineFloat64Compares) { |
} |
} |
+#if V8_TARGET_ARCH_64_BIT |
+TEST(BranchCombineWord64EqualZeroPhi) { |
+ // Test combining a branch with a Word64Equal between a phi node and 0. |
+ RawMachineAssemblerTester<int32_t> m(MachineType::AnyTagged()); |
+ uintptr_t something = 0x100000000; |
+ uintptr_t null = 0; |
+ |
+ Node* p0 = m.Parameter(0); |
+ |
+ RawMachineLabel is_null, is_not_null, merge; |
+ m.Branch(m.IntPtrEqual(p0, m.IntPtrConstant(0)), &is_null, &is_not_null); |
+ m.Bind(&is_not_null); |
+ Node* val = m.Load(MachineType::AnyTagged(), p0); |
+ m.Goto(&merge); |
+ m.Bind(&is_null); |
+ Node* fail_val = m.IntPtrConstant(0); |
+ m.Goto(&merge); |
+ |
+ m.Bind(&merge); |
+ Node* phi = m.Phi(MachineRepresentation::kTagged, val, fail_val); |
+ |
+ RawMachineLabel pass, fail; |
+ m.Branch(m.IntPtrEqual(phi, m.IntPtrConstant(0)), &pass, &fail); |
+ m.Bind(&pass); |
+ m.Return(m.Int32Constant(0)); |
+ m.Bind(&fail); |
+ m.Return(m.Int32Constant(1)); |
+ |
+ CHECK_EQ(1, m.Call(reinterpret_cast<v8::internal::Object*>(&something))); |
+ CHECK_EQ(0, m.Call(reinterpret_cast<v8::internal::Object*>(&null))); |
+ CHECK_EQ(0, m.Call(static_cast<v8::internal::Object*>(nullptr))); |
+} |
+ |
+#endif |
+ |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |