Commit d794ef7d authored by bjaideep's avatar bjaideep Committed by Commit bot

PPC/s390: Check for overflow when SubI IntMin

R=joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Review-Url: https://codereview.chromium.org/2639853002
Cr-Commit-Position: refs/heads/master@{#42468}
parent dd789d87
......@@ -1707,12 +1707,15 @@ void LCodeGen::DoSubI(LSubI* instr) {
} else {
__ sub(result, left, EmitLoadRegister(right, ip));
}
#if V8_TARGET_ARCH_PPC64
if (can_overflow) {
#if V8_TARGET_ARCH_PPC64
__ TestIfInt32(result, r0);
#else
__ TestIfInt32(scratch0(), result, r0);
#endif
DeoptimizeIf(ne, instr, DeoptimizeReason::kOverflow);
}
#endif
} else {
if (right->IsConstantOperand()) {
__ AddAndCheckForOverflow(result, left, -(ToOperand(right).immediate()),
......
......@@ -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
} 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));
......
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