Index: src/crankshaft/s390/lithium-codegen-s390.cc |
diff --git a/src/crankshaft/s390/lithium-codegen-s390.cc b/src/crankshaft/s390/lithium-codegen-s390.cc |
index bbc8f839451389c73bc629f623f4447938815768..0cdcc34f31f31a268075580fa3fdc1375281768c 100644 |
--- a/src/crankshaft/s390/lithium-codegen-s390.cc |
+++ b/src/crankshaft/s390/lithium-codegen-s390.cc |
@@ -1682,10 +1682,17 @@ void LCodeGen::DoSubI(LSubI* instr) { |
#endif |
if (right->IsConstantOperand()) { |
- if (!isInteger || !checkOverflow) |
+ if (!isInteger || !checkOverflow) { |
__ SubP(ToRegister(result), ToRegister(left), ToOperand(right)); |
- else |
- __ Sub32(ToRegister(result), ToRegister(left), ToOperand(right)); |
+ } else { |
+ // -(MinInt) will overflow |
+ if (ToInteger32(LConstantOperand::cast(right)) == kMinInt) { |
+ __ Load(scratch0(), ToOperand(right)); |
+ __ Sub32(ToRegister(result), ToRegister(left), scratch0()); |
+ } else { |
+ __ Sub32(ToRegister(result), ToRegister(left), ToOperand(right)); |
+ } |
+ } |
} else if (right->IsRegister()) { |
if (!isInteger) |
__ SubP(ToRegister(result), ToRegister(left), ToRegister(right)); |