[turbofan] Don't lower to NumberModulus unless the inputs are numbers.
The IC for modulus is usually way faster than converting the inputs to numbers and doing a Float64Mod on them. R=jarin@chromium.org Review URL: https://codereview.chromium.org/1170433002 Cr-Commit-Position: refs/heads/master@{#28787}
This commit is contained in:
parent
a961d6c014
commit
daba339a84
@ -388,10 +388,21 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
|
||||
}
|
||||
|
||||
|
||||
Reduction JSTypedLowering::ReduceJSModulus(Node* node) {
|
||||
JSBinopReduction r(this, node);
|
||||
if (r.BothInputsAre(Type::Number())) {
|
||||
// JSModulus(x:number, x:number) => NumberModulus(x, y)
|
||||
return r.ChangeToPureOperator(simplified()->NumberModulus(),
|
||||
Type::Number());
|
||||
}
|
||||
return NoChange();
|
||||
}
|
||||
|
||||
|
||||
Reduction JSTypedLowering::ReduceNumberBinop(Node* node,
|
||||
const Operator* numberOp) {
|
||||
JSBinopReduction r(this, node);
|
||||
if (r.IsStrong()) {
|
||||
if (r.IsStrong() || numberOp == simplified()->NumberModulus()) {
|
||||
if (r.BothInputsAre(Type::Number())) {
|
||||
return r.ChangeToPureOperator(numberOp, Type::Number());
|
||||
}
|
||||
@ -1469,7 +1480,7 @@ Reduction JSTypedLowering::Reduce(Node* node) {
|
||||
case IrOpcode::kJSDivide:
|
||||
return ReduceNumberBinop(node, simplified()->NumberDivide());
|
||||
case IrOpcode::kJSModulus:
|
||||
return ReduceNumberBinop(node, simplified()->NumberModulus());
|
||||
return ReduceJSModulus(node);
|
||||
case IrOpcode::kJSUnaryNot:
|
||||
return ReduceJSUnaryNot(node);
|
||||
case IrOpcode::kJSToBoolean:
|
||||
|
@ -37,6 +37,7 @@ class JSTypedLowering final : public AdvancedReducer {
|
||||
friend class JSBinopReduction;
|
||||
|
||||
Reduction ReduceJSAdd(Node* node);
|
||||
Reduction ReduceJSModulus(Node* node);
|
||||
Reduction ReduceJSBitwiseOr(Node* node);
|
||||
Reduction ReduceJSMultiply(Node* node);
|
||||
Reduction ReduceJSComparison(Node* node);
|
||||
|
@ -942,8 +942,6 @@ TEST(OrderNumberBinopEffects1) {
|
||||
R.simplified.NumberMultiply(),
|
||||
R.javascript.Divide(LanguageMode::SLOPPY),
|
||||
R.simplified.NumberDivide(),
|
||||
R.javascript.Modulus(LanguageMode::SLOPPY),
|
||||
R.simplified.NumberModulus(),
|
||||
};
|
||||
|
||||
for (size_t j = 0; j < arraysize(ops); j += 2) {
|
||||
@ -974,8 +972,6 @@ TEST(OrderNumberBinopEffects2) {
|
||||
R.simplified.NumberMultiply(),
|
||||
R.javascript.Divide(LanguageMode::SLOPPY),
|
||||
R.simplified.NumberDivide(),
|
||||
R.javascript.Modulus(LanguageMode::SLOPPY),
|
||||
R.simplified.NumberModulus(),
|
||||
};
|
||||
|
||||
for (size_t j = 0; j < arraysize(ops); j += 2) {
|
||||
|
Loading…
Reference in New Issue
Block a user