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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 14617014: Fixed constant folding in HMod. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Fixed unit test. Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/constant-folding-2.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after
3334 3334
3335 3335
3336 HInstruction* HMod::New( 3336 HInstruction* HMod::New(
3337 Zone* zone, HValue* context, HValue* left, HValue* right) { 3337 Zone* zone, HValue* context, HValue* left, HValue* right) {
3338 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { 3338 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
3339 HConstant* c_left = HConstant::cast(left); 3339 HConstant* c_left = HConstant::cast(left);
3340 HConstant* c_right = HConstant::cast(right); 3340 HConstant* c_right = HConstant::cast(right);
3341 if (c_left->HasInteger32Value() && c_right->HasInteger32Value()) { 3341 if (c_left->HasInteger32Value() && c_right->HasInteger32Value()) {
3342 int32_t dividend = c_left->Integer32Value(); 3342 int32_t dividend = c_left->Integer32Value();
3343 int32_t divisor = c_right->Integer32Value(); 3343 int32_t divisor = c_right->Integer32Value();
3344 if (dividend == kMinInt && divisor == -1) {
3345 return H_CONSTANT_DOUBLE(-0.0);
3346 }
3344 if (divisor != 0) { 3347 if (divisor != 0) {
3345 int32_t res = dividend % divisor; 3348 int32_t res = dividend % divisor;
3346 if ((res == 0) && (dividend < 0)) { 3349 if ((res == 0) && (dividend < 0)) {
3347 return H_CONSTANT_DOUBLE(-0.0); 3350 return H_CONSTANT_DOUBLE(-0.0);
3348 } 3351 }
3349 return H_CONSTANT_INT32(res); 3352 return H_CONSTANT_INT32(res);
3350 } 3353 }
3351 } 3354 }
3352 } 3355 }
3353 return new(zone) HMod(context, left, right); 3356 return new(zone) HMod(context, left, right);
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
3621 3624
3622 3625
3623 void HCheckFunction::Verify() { 3626 void HCheckFunction::Verify() {
3624 HInstruction::Verify(); 3627 HInstruction::Verify();
3625 ASSERT(HasNoUses()); 3628 ASSERT(HasNoUses());
3626 } 3629 }
3627 3630
3628 #endif 3631 #endif
3629 3632
3630 } } // namespace v8::internal 3633 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/constant-folding-2.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698