Replace MathFloor/Round by HChange if the input representation does not match the...
authorverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 9 Aug 2013 12:03:40 +0000 (12:03 +0000)
committerverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 9 Aug 2013 12:03:40 +0000 (12:03 +0000)
R=svenpanne@chromium.org

Review URL: https://chromiumcodereview.appspot.com/22398009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16129 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/hydrogen-instructions.cc

index 5fc65ce..05e9196 100644 (file)
@@ -1291,7 +1291,15 @@ HValue* HUnaryMathOperation::Canonicalize() {
 
     // If the input is integer32 then we replace the round instruction
     // with its input.
-    if (val->representation().IsSmiOrInteger32()) return val;
+    if (val->representation().IsSmiOrInteger32()) {
+      if (!val->representation().Equals(representation())) {
+        HChange* result = new(block()->zone()) HChange(
+            val, representation(), false, false, false);
+        result->InsertBefore(this);
+        return result;
+      }
+      return val;
+    }
   }
 
   if (op() == kMathFloor) {
@@ -1300,7 +1308,15 @@ HValue* HUnaryMathOperation::Canonicalize() {
 
     // If the input is integer32 then we replace the floor instruction
     // with its input.
-    if (val->representation().IsSmiOrInteger32()) return val;
+    if (val->representation().IsSmiOrInteger32()) {
+      if (!val->representation().Equals(representation())) {
+        HChange* result = new(block()->zone()) HChange(
+            val, representation(), false, false, false);
+        result->InsertBefore(this);
+        return result;
+      }
+      return val;
+    }
 
     if (val->IsDiv() && (val->UseCount() == 1)) {
       HDiv* hdiv = HDiv::cast(val);