OLD | NEW |
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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 } | 1248 } |
1249 | 1249 |
1250 | 1250 |
1251 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { | 1251 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { |
1252 return arg1->representation().IsSpecialization() && | 1252 return arg1->representation().IsSpecialization() && |
1253 arg2->EqualsInteger32Constant(identity); | 1253 arg2->EqualsInteger32Constant(identity); |
1254 } | 1254 } |
1255 | 1255 |
1256 | 1256 |
1257 HValue* HAdd::Canonicalize() { | 1257 HValue* HAdd::Canonicalize() { |
1258 if (IsIdentityOperation(left(), right(), 0)) return left(); | 1258 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0 |
1259 if (IsIdentityOperation(right(), left(), 0)) return right(); | 1259 if (IsIdentityOperation(left(), right(), 0) && |
| 1260 !left()->representation().IsDouble()) { // Left could be -0. |
| 1261 return left(); |
| 1262 } |
| 1263 if (IsIdentityOperation(right(), left(), 0) && |
| 1264 !left()->representation().IsDouble()) { // Right could be -0. |
| 1265 return right(); |
| 1266 } |
1260 return this; | 1267 return this; |
1261 } | 1268 } |
1262 | 1269 |
1263 | 1270 |
1264 HValue* HSub::Canonicalize() { | 1271 HValue* HSub::Canonicalize() { |
1265 if (IsIdentityOperation(left(), right(), 0)) return left(); | 1272 if (IsIdentityOperation(left(), right(), 0)) return left(); |
1266 return this; | 1273 return this; |
1267 } | 1274 } |
1268 | 1275 |
1269 | 1276 |
(...skipping 3021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4291 break; | 4298 break; |
4292 case kExternalMemory: | 4299 case kExternalMemory: |
4293 stream->Add("[external-memory]"); | 4300 stream->Add("[external-memory]"); |
4294 break; | 4301 break; |
4295 } | 4302 } |
4296 | 4303 |
4297 stream->Add("@%d", offset()); | 4304 stream->Add("@%d", offset()); |
4298 } | 4305 } |
4299 | 4306 |
4300 } } // namespace v8::internal | 4307 } } // namespace v8::internal |
OLD | NEW |