Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 8d73c1e51976f7cd4b2e849e1faf5f9c8930f94c..e980ecc5a9116fa1f05fd1447e773e162c6d1ed6 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -8717,9 +8717,24 @@ HValue* HGraphBuilder::BuildBinaryOperation( |
case Token::MUL: |
instr = AddUncasted<HMul>(left, right); |
break; |
- case Token::MOD: |
- instr = AddUncasted<HMod>(left, right, fixed_right_arg); |
+ case Token::MOD: { |
+ if (fixed_right_arg.has_value) { |
+ if (right->IsConstant()) { |
+ ASSERT_EQ(fixed_right_arg.value, |
+ HConstant::cast(right)->Integer32Value()); |
+ } else { |
+ HConstant* fixed_right = Add<HConstant>( |
+ static_cast<int>(fixed_right_arg.value)); |
+ IfBuilder if_same(this); |
+ if_same.If<HCompareNumericAndBranch>(right, fixed_right, Token::EQ); |
+ if_same.Then(); |
+ if_same.ElseDeopt("Unexpected RHS of binary operation"); |
+ right = fixed_right; |
+ } |
+ } |
+ instr = AddUncasted<HMod>(left, right); |
break; |
+ } |
case Token::DIV: |
instr = AddUncasted<HDiv>(left, right); |
break; |