[turbofan] Fix bogus covering of Word64Equal w/ zero.
Review URL: https://codereview.chromium.org/960783002 Cr-Commit-Position: refs/heads/master@{#26870}
This commit is contained in:
parent
75a2440982
commit
0f783c676b
@ -1250,25 +1250,12 @@ void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
|
||||
FlagsContinuation cont(kNotEqual, tbranch, fbranch);
|
||||
|
||||
// Try to combine with comparisons against 0 by simply inverting the branch.
|
||||
while (CanCover(user, value)) {
|
||||
if (value->opcode() == IrOpcode::kWord32Equal) {
|
||||
Int32BinopMatcher m(value);
|
||||
if (m.right().Is(0)) {
|
||||
user = value;
|
||||
value = m.left().node();
|
||||
cont.Negate();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (value->opcode() == IrOpcode::kWord64Equal) {
|
||||
Int64BinopMatcher m(value);
|
||||
if (m.right().Is(0)) {
|
||||
user = value;
|
||||
value = m.left().node();
|
||||
cont.Negate();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
while (CanCover(user, value) && value->opcode() == IrOpcode::kWord32Equal) {
|
||||
Int32BinopMatcher m(value);
|
||||
if (m.right().Is(0)) {
|
||||
user = value;
|
||||
value = m.left().node();
|
||||
cont.Negate();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -1068,25 +1068,12 @@ void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
|
||||
FlagsContinuation cont(kNotEqual, tbranch, fbranch);
|
||||
|
||||
// Try to combine with comparisons against 0 by simply inverting the branch.
|
||||
while (CanCover(user, value)) {
|
||||
if (value->opcode() == IrOpcode::kWord32Equal) {
|
||||
Int32BinopMatcher m(value);
|
||||
if (m.right().Is(0)) {
|
||||
user = value;
|
||||
value = m.left().node();
|
||||
cont.Negate();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (value->opcode() == IrOpcode::kWord64Equal) {
|
||||
Int64BinopMatcher m(value);
|
||||
if (m.right().Is(0)) {
|
||||
user = value;
|
||||
value = m.left().node();
|
||||
cont.Negate();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
while (CanCover(user, value) && value->opcode() == IrOpcode::kWord32Equal) {
|
||||
Int32BinopMatcher m(value);
|
||||
if (m.right().Is(0)) {
|
||||
user = value;
|
||||
value = m.left().node();
|
||||
cont.Negate();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -4436,6 +4436,26 @@ TEST(RunInt32SubWithOverflowInBranchP) {
|
||||
}
|
||||
|
||||
|
||||
TEST(RunWord64EqualInBranchP) {
|
||||
int64_t input;
|
||||
MLabel blocka, blockb;
|
||||
RawMachineAssemblerTester<int64_t> m;
|
||||
if (!m.machine()->Is64()) return;
|
||||
Node* value = m.LoadFromPointer(&input, kMachInt64);
|
||||
m.Branch(m.Word64Equal(value, m.Int64Constant(0)), &blocka, &blockb);
|
||||
m.Bind(&blocka);
|
||||
m.Return(m.Int32Constant(1));
|
||||
m.Bind(&blockb);
|
||||
m.Return(m.Int32Constant(2));
|
||||
input = V8_INT64_C(0);
|
||||
CHECK_EQ(1, m.Call());
|
||||
input = V8_INT64_C(1);
|
||||
CHECK_EQ(2, m.Call());
|
||||
input = V8_INT64_C(0x100000000);
|
||||
CHECK_EQ(2, m.Call());
|
||||
}
|
||||
|
||||
|
||||
TEST(RunChangeInt32ToInt64P) {
|
||||
if (kPointerSize < 8) return;
|
||||
int64_t actual = -1;
|
||||
@ -4793,4 +4813,5 @@ TEST(RunFloat64RoundTiesAway) {
|
||||
CHECK_EQ(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // V8_TURBOFAN_TARGET
|
||||
|
@ -896,26 +896,6 @@ TEST_F(InstructionSelectorTest, Word64AndBranchWithOneBitMaskOnRight) {
|
||||
EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
|
||||
EXPECT_EQ(bit, s.ToInt64(s[0]->InputAt(1)));
|
||||
}
|
||||
|
||||
TRACED_FORRANGE(int, bit, 0, 63) {
|
||||
uint64_t mask = 1L << bit;
|
||||
StreamBuilder m(this, kMachInt64, kMachInt64);
|
||||
MLabel a, b;
|
||||
m.Branch(
|
||||
m.Word64BinaryNot(m.Word64And(m.Parameter(0), m.Int64Constant(mask))),
|
||||
&a, &b);
|
||||
m.Bind(&a);
|
||||
m.Return(m.Int32Constant(1));
|
||||
m.Bind(&b);
|
||||
m.Return(m.Int32Constant(0));
|
||||
Stream s = m.Build();
|
||||
ASSERT_EQ(1U, s.size());
|
||||
EXPECT_EQ(kArm64TestAndBranch, s[0]->arch_opcode());
|
||||
EXPECT_EQ(kEqual, s[0]->flags_condition());
|
||||
EXPECT_EQ(4U, s[0]->InputCount());
|
||||
EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
|
||||
EXPECT_EQ(bit, s.ToInt64(s[0]->InputAt(1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -937,26 +917,6 @@ TEST_F(InstructionSelectorTest, Word64AndBranchWithOneBitMaskOnLeft) {
|
||||
EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
|
||||
EXPECT_EQ(bit, s.ToInt64(s[0]->InputAt(1)));
|
||||
}
|
||||
|
||||
TRACED_FORRANGE(int, bit, 0, 63) {
|
||||
uint64_t mask = 1L << bit;
|
||||
StreamBuilder m(this, kMachInt64, kMachInt64);
|
||||
MLabel a, b;
|
||||
m.Branch(
|
||||
m.Word64BinaryNot(m.Word64And(m.Int64Constant(mask), m.Parameter(0))),
|
||||
&a, &b);
|
||||
m.Bind(&a);
|
||||
m.Return(m.Int32Constant(1));
|
||||
m.Bind(&b);
|
||||
m.Return(m.Int32Constant(0));
|
||||
Stream s = m.Build();
|
||||
ASSERT_EQ(1U, s.size());
|
||||
EXPECT_EQ(kArm64TestAndBranch, s[0]->arch_opcode());
|
||||
EXPECT_EQ(kEqual, s[0]->flags_condition());
|
||||
EXPECT_EQ(4U, s[0]->InputCount());
|
||||
EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
|
||||
EXPECT_EQ(bit, s.ToInt64(s[0]->InputAt(1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user