Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: src/crankshaft/s390/lithium-codegen-s390.cc

Issue 2639853002: PPC/s390: Check for overflow when SubI IntMin (Closed)
Patch Set: addressed comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/crankshaft/ppc/lithium-codegen-ppc.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « src/crankshaft/ppc/lithium-codegen-ppc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698