Revert "[turbofan] Simplifying (x+k1)==k2 into x==(k2-k1)"
This reverts commit e9333ebd3c
.
Reason for revert:
https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Linux64%20UBSan/24520/overview
Original change's description:
> [turbofan] Simplifying (x+k1)==k2 into x==(k2-k1)
>
>
> Change-Id: I234da79e1f53fa0fc15494fe6d31742d4e6eea97
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4055393
> Commit-Queue: Jianxiao Lu <jianxiao.lu@intel.com>
> Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#84947}
Change-Id: I9e86f6f9653efff0fd0da439e270df5c7da29b20
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4111953
Auto-Submit: Michael Achenbach <machenbach@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84948}
This commit is contained in:
parent
e9333ebd3c
commit
3d46a713bb
@ -2551,19 +2551,6 @@ Reduction MachineOperatorReducer::ReduceWord32Equal(Node* node) {
|
||||
node->ReplaceInput(1, Uint32Constant(replacements->second));
|
||||
return Changed(node);
|
||||
}
|
||||
|
||||
// Simplifying (x+k1)==k2 into x==k2-k1.
|
||||
if (m.left().IsInt32Add() && m.right().IsInt32Constant()) {
|
||||
Int32AddMatcher m_add(m.left().node());
|
||||
if (m_add.right().IsInt32Constant()) {
|
||||
int32_t lte_right = m.right().ResolvedValue();
|
||||
int32_t add_right = m_add.right().ResolvedValue();
|
||||
// No need to consider overflow in this condition (==).
|
||||
node->ReplaceInput(0, m_add.left().node());
|
||||
node->ReplaceInput(1, Int32Constant(lte_right - add_right));
|
||||
return Changed(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NoChange();
|
||||
@ -2592,19 +2579,6 @@ Reduction MachineOperatorReducer::ReduceWord64Equal(Node* node) {
|
||||
return Changed(node);
|
||||
}
|
||||
|
||||
// Simplifying (x+k1)==k2 into x==k2-k1.
|
||||
if (m.left().IsInt64Add() && m.right().IsInt64Constant()) {
|
||||
Int64AddMatcher m_add(m.left().node());
|
||||
if (m_add.right().IsInt64Constant()) {
|
||||
int64_t lte_right = m.right().ResolvedValue();
|
||||
int64_t add_right = m_add.right().ResolvedValue();
|
||||
// No need to consider overflow in this condition (==).
|
||||
node->ReplaceInput(0, m_add.left().node());
|
||||
node->ReplaceInput(1, Int64Constant(lte_right - add_right));
|
||||
return Changed(node);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
If Int64Constant(c) can be casted from an Int32Constant:
|
||||
-------------------------------------------------
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include "src/compiler/machine-operator-reducer.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
#include "src/base/bits.h"
|
||||
@ -12,7 +11,6 @@
|
||||
#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"
|
||||
@ -1400,21 +1398,6 @@ TEST_F(MachineOperatorReducerTest,
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MachineOperatorReducerTest, Word32EqualWithAddAndConstant) {
|
||||
// (x+k1)==k2 => x==(k2-k1)
|
||||
Node* const p0 = Parameter(0);
|
||||
TRACED_FOREACH(int32_t, k1, kInt32Values) {
|
||||
TRACED_FOREACH(int32_t, k2, kInt32Values) {
|
||||
Node* node = graph()->NewNode(
|
||||
machine()->Word32Equal(),
|
||||
graph()->NewNode(machine()->Int32Add(), p0, Int32Constant(k1)),
|
||||
Int32Constant(k2));
|
||||
Reduction r = Reduce(node);
|
||||
ASSERT_TRUE(r.Changed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Word64Equal
|
||||
|
||||
@ -1453,21 +1436,6 @@ TEST_F(MachineOperatorReducerTest,
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MachineOperatorReducerTest, Word64EqualWithAddAndConstant) {
|
||||
// (x+k1)==k2 => x==(k2-k1)
|
||||
Node* const p0 = Parameter(0);
|
||||
TRACED_FOREACH(int64_t, k1, kInt64Values) {
|
||||
TRACED_FOREACH(int64_t, k2, kInt64Values) {
|
||||
Node* node = graph()->NewNode(
|
||||
machine()->Word64Equal(),
|
||||
graph()->NewNode(machine()->Int64Add(), p0, Int64Constant(k1)),
|
||||
Int64Constant(k2));
|
||||
Reduction r = Reduce(node);
|
||||
ASSERT_TRUE(r.Changed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Branch
|
||||
|
||||
@ -2616,49 +2584,6 @@ TEST_F(MachineOperatorReducerTest, Uint64LessThanWithUint32Reduction) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MachineOperatorReducerTest, Uint64LessThanWithInt64AddDontReduce) {
|
||||
Node* const p0 = Parameter(0);
|
||||
|
||||
TRACED_FOREACH(uint64_t, k1, kUint64Values) {
|
||||
TRACED_FOREACH(uint64_t, k2, kUint64Values) {
|
||||
Node* node = graph()->NewNode(
|
||||
machine()->Uint64LessThan(),
|
||||
graph()->NewNode(machine()->Int64Add(), p0, Int64Constant(k1)),
|
||||
Int64Constant(k2));
|
||||
Reduction r = Reduce(node);
|
||||
// Don't reduce because of potential overflow
|
||||
ASSERT_FALSE(r.Changed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MachineOperatorReducerTest,
|
||||
Uint64LessThanOrEqualWithInt64AddDontReduce) {
|
||||
Node* const p0 = Parameter(0);
|
||||
|
||||
TRACED_FOREACH(uint64_t, k1, kUint64Values) {
|
||||
TRACED_FOREACH(uint64_t, k2, kUint64Values) {
|
||||
uint64_t k1 = 0;
|
||||
uint64_t k2 = 18446744073709551615u;
|
||||
Node* node = graph()->NewNode(
|
||||
machine()->Uint64LessThanOrEqual(),
|
||||
graph()->NewNode(machine()->Int64Add(), p0, Int64Constant(k1)),
|
||||
Int64Constant(k2));
|
||||
Reduction r = Reduce(node);
|
||||
if (k2 == 0) {
|
||||
// x <= 0 => x == 0
|
||||
ASSERT_TRUE(r.Changed());
|
||||
} else if (k2 == std::numeric_limits<uint64_t>::max()) {
|
||||
// x <= Max => true
|
||||
ASSERT_TRUE(r.Changed());
|
||||
} else {
|
||||
// Don't reduce because of potential overflow
|
||||
ASSERT_FALSE(r.Changed());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Int64LessThan
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user