Commit 34c5458c authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[turbofan] Teach LoopVariableOptimizer about Number operations.

The LoopVariableOptimizer didn't understand NumberAdd, NumberSubtract
and friends, and so Phis in Loops that are generated in the call
reducer (like for Array.prototype.shift) got bad types, leading to
unnecessary double computations.

Bug: v8:8015
Change-Id: I9686f86682c106ef84f2760fed9948ce54d7cd9a
Reviewed-on: https://chromium-review.googlesource.com/1224371Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55859}
parent 18380a3c
......@@ -158,6 +158,7 @@ void LoopVariableOptimizer::VisitIf(Node* node, bool polarity) {
// Normalize to less than comparison.
switch (cond->opcode()) {
case IrOpcode::kJSLessThan:
case IrOpcode::kNumberLessThan:
case IrOpcode::kSpeculativeNumberLessThan:
AddCmpToLimits(&limits, cond, InductionVariable::kStrict, polarity);
break;
......@@ -165,6 +166,7 @@ void LoopVariableOptimizer::VisitIf(Node* node, bool polarity) {
AddCmpToLimits(&limits, cond, InductionVariable::kNonStrict, !polarity);
break;
case IrOpcode::kJSLessThanOrEqual:
case IrOpcode::kNumberLessThanOrEqual:
case IrOpcode::kSpeculativeNumberLessThanOrEqual:
AddCmpToLimits(&limits, cond, InductionVariable::kNonStrict, polarity);
break;
......@@ -226,10 +228,12 @@ InductionVariable* LoopVariableOptimizer::TryGetInductionVariable(Node* phi) {
Node* arith = phi->InputAt(1);
InductionVariable::ArithmeticType arithmeticType;
if (arith->opcode() == IrOpcode::kJSAdd ||
arith->opcode() == IrOpcode::kNumberAdd ||
arith->opcode() == IrOpcode::kSpeculativeNumberAdd ||
arith->opcode() == IrOpcode::kSpeculativeSafeIntegerAdd) {
arithmeticType = InductionVariable::ArithmeticType::kAddition;
} else if (arith->opcode() == IrOpcode::kJSSubtract ||
arith->opcode() == IrOpcode::kNumberSubtract ||
arith->opcode() == IrOpcode::kSpeculativeNumberSubtract ||
arith->opcode() == IrOpcode::kSpeculativeSafeIntegerSubtract) {
arithmeticType = InductionVariable::ArithmeticType::kSubtraction;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment