Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 795833006: Revert of [turbofan] Improve typed lowering of JSBitwiseAnd. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | test/unittests/compiler/js-typed-lowering-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index e2f3044409cb57b73da7cab0a0f049349074f516..761837576b3b40401063da876012e38ecf5eb18c 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -33,11 +33,10 @@
: jsgraph_(jsgraph), simplified_(graph()->zone()), conversions_(zone) {
Handle<Object> zero = factory()->NewNumber(0.0);
Handle<Object> one = factory()->NewNumber(1.0);
- zero_range_ = Type::Range(zero, zero, zone);
- one_range_ = Type::Range(one, one, zone);
- zero_one_range_ = Type::Range(zero, one, zone);
+ zero_range_ = Type::Range(zero, zero, graph()->zone());
+ one_range_ = Type::Range(one, one, graph()->zone());
Handle<Object> thirtyone = factory()->NewNumber(31.0);
- zero_thirtyone_range_ = Type::Range(zero, thirtyone, zone);
+ zero_thirtyone_range_ = Type::Range(zero, thirtyone, graph()->zone());
// TODO(jarin): Can we have a correctification of the stupid type system?
// These stupid work-arounds are just stupid!
shifted_int32_ranges_[0] = Type::Signed32();
@@ -46,13 +45,13 @@
for (size_t k = 2; k < arraysize(shifted_int32_ranges_); ++k) {
Handle<Object> min = factory()->NewNumber(kMinInt / (1 << k));
Handle<Object> max = factory()->NewNumber(kMaxInt / (1 << k));
- shifted_int32_ranges_[k] = Type::Range(min, max, zone);
+ shifted_int32_ranges_[k] = Type::Range(min, max, graph()->zone());
}
} else {
for (size_t k = 1; k < arraysize(shifted_int32_ranges_); ++k) {
Handle<Object> min = factory()->NewNumber(kMinInt / (1 << k));
Handle<Object> max = factory()->NewNumber(kMaxInt / (1 << k));
- shifted_int32_ranges_[k] = Type::Range(min, max, zone);
+ shifted_int32_ranges_[k] = Type::Range(min, max, graph()->zone());
}
}
}
@@ -112,11 +111,6 @@
std::swap(left_type_, right_type_);
}
- void ReplaceLeftInput(Node* l) {
- node_->ReplaceInput(0, l);
- left_type_ = NodeProperties::GetBounds(l).upper;
- }
-
// Remove all effect and control inputs and outputs to this node and change
// to the pure operator {op}, possibly inserting a boolean inversion.
Reduction ChangeToPureOperator(const Operator* op, bool invert = false,
@@ -124,17 +118,16 @@
DCHECK_EQ(0, op->EffectInputCount());
DCHECK_EQ(false, OperatorProperties::HasContextInput(op));
DCHECK_EQ(0, op->ControlInputCount());
- DCHECK_LE(1, op->ValueInputCount());
- DCHECK_GE(2, op->ValueInputCount());
+ DCHECK_EQ(2, op->ValueInputCount());
// Remove the effects from the node, if any, and update its effect usages.
if (node_->op()->EffectInputCount() > 0) {
RelaxEffects(node_);
}
+ // Remove the inputs corresponding to context, effect, and control.
+ NodeProperties::RemoveNonValueInputs(node_);
// Finally, update the operator to the new one.
node_->set_op(op);
- // Remove the inputs corresponding to context, effect, and control.
- NodeProperties::RemoveNonValueInputs(node_);
// TODO(jarin): Replace the explicit typing hack with a call to some method
// that encapsulates changing the operator and re-typing.
@@ -156,18 +149,11 @@
return ChangeToPureOperator(op, false, type);
}
- Reduction ReplaceWithLeftInput() {
- // Remove the effects from the node, if any, and update its effect usages.
- if (node_->op()->EffectInputCount() > 0) {
- RelaxEffects(node_);
- }
- return lowering_->Replace(left());
- }
-
- bool LeftInputIs(Type* t) { return left_type_->Is(t); }
- bool RightInputIs(Type* t) { return right_type_->Is(t); }
- bool OneInputIs(Type* t) { return LeftInputIs(t) || RightInputIs(t); }
- bool BothInputsAre(Type* t) { return LeftInputIs(t) && RightInputIs(t); }
+ bool OneInputIs(Type* t) { return left_type_->Is(t) || right_type_->Is(t); }
+
+ bool BothInputsAre(Type* t) {
+ return left_type_->Is(t) && right_type_->Is(t);
+ }
bool OneInputCannotBe(Type* t) {
return !left_type_->Maybe(t) || !right_type_->Maybe(t);
@@ -275,41 +261,6 @@
return r.ChangeToPureOperator(simplified()->StringAdd());
}
#endif
- return NoChange();
-}
-
-
-Reduction JSTypedLowering::ReduceJSBitwiseAnd(Node* node) {
- JSBinopReduction r(this, node);
- if (r.LeftInputIs(one_range_)) {
- if (r.RightInputIs(zero_one_range_)) {
- // JSBitwiseAnd(1, x:[0,1]) => x
- r.SwapInputs();
- return r.ReplaceWithLeftInput();
- } else if (r.RightInputIs(Type::Boolean())) {
- // JSBitwiseAnd(1, x:boolean) => BooleanToNumber(x)
- r.SwapInputs();
- return r.ChangeToPureOperator(simplified()->BooleanToNumber());
- }
- }
- if (r.RightInputIs(one_range_)) {
- if (r.LeftInputIs(zero_one_range_)) {
- // JSBitwiseAnd(x:[0,1], 1) => x
- return r.ReplaceWithLeftInput();
- } else if (r.LeftInputIs(Type::Boolean())) {
- // JSBitwiseAnd(x:boolean, 1) => BooleanToNumber(x)
- return r.ChangeToPureOperator(simplified()->BooleanToNumber());
- }
- }
- if (r.BothInputsAre(Type::Primitive())) {
- // TODO(titzer): some Smi bitwise operations don't really require going
- // all the way to int32, which can save tagging/untagging for some
- // operations
- // on some platforms.
- // TODO(turbofan): make this heuristic configurable for code size.
- r.ConvertInputsToUI32(kSigned, kSigned);
- return r.ChangeToPureOperator(machine()->Word32And(), Type::Integral32());
- }
return NoChange();
}
@@ -936,7 +887,7 @@
case IrOpcode::kJSBitwiseXor:
return ReduceInt32Binop(node, machine()->Word32Xor());
case IrOpcode::kJSBitwiseAnd:
- return ReduceJSBitwiseAnd(node);
+ return ReduceInt32Binop(node, machine()->Word32And());
case IrOpcode::kJSShiftLeft:
return ReduceUI32Shift(node, kSigned, machine()->Word32Shl());
case IrOpcode::kJSShiftRight:
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | test/unittests/compiler/js-typed-lowering-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698