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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/optimize.dart

Issue 114613003: double * int returns a double can be simplified to an int if both operands are constants. Therefore… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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 | « sdk/lib/_internal/compiler/implementation/ssa/nodes.dart ('k') | tests/language/issue15702_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/optimize.dart (revision 31217)
+++ sdk/lib/_internal/compiler/implementation/ssa/optimize.dart (working copy)
@@ -123,11 +123,19 @@
if (replacement != instruction) {
block.rewrite(instruction, replacement);
- // If we can replace [instruction] with [replacement], then
- // [replacement]'s type can be narrowed.
- TypeMask newType = replacement.instructionType.intersection(
- instruction.instructionType, compiler);
- replacement.instructionType = newType;
+ // The intersection of double and int return conflicting, and
+ // because of our number implementation for JavaScript, it
+ // might be that an operation thought to return double, can be
+ // simplified to an int. For example:
+ // `2.5 * 10`.
+ if (!(replacement.isNumberOrNull(compiler)
+ && instruction.isNumberOrNull(compiler))) {
+ // If we can replace [instruction] with [replacement], then
+ // [replacement]'s type can be narrowed.
+ TypeMask newType = replacement.instructionType.intersection(
+ instruction.instructionType, compiler);
+ replacement.instructionType = newType;
+ }
// If the replacement instruction does not know its
// source element, use the source element of the
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/nodes.dart ('k') | tests/language/issue15702_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698