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

Unified Diff: src/hydrogen-instructions.cc

Issue 68493005: Constant-folding through HForceRepresentation fix. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review notes fixed. Created 7 years, 1 month 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/hydrogen-instructions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index c47351d1aafa3c4a7856a40dbfeda4cb1e3a9f32..84949c09aa1df1b3038f20d6ab2a8c6a45e267ae 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -521,19 +521,12 @@ bool HValue::CanReplaceWithDummyUses() {
bool HValue::IsInteger32Constant() {
- HValue* value_to_check = IsForceRepresentation()
- ? HForceRepresentation::cast(this)->value()
- : this;
- return value_to_check->IsConstant() &&
- HConstant::cast(value_to_check)->HasInteger32Value();
+ return IsConstant() && HConstant::cast(this)->HasInteger32Value();
}
int32_t HValue::GetInteger32Constant() {
- HValue* constant_value = IsForceRepresentation()
- ? HForceRepresentation::cast(this)->value()
- : this;
- return HConstant::cast(constant_value)->Integer32Value();
+ return HConstant::cast(this)->Integer32Value();
}
@@ -1342,6 +1335,23 @@ void HTypeof::PrintDataTo(StringStream* stream) {
}
+HInstruction* HForceRepresentation::New(Zone* zone, HValue* context,
+ HValue* value, Representation required_representation) {
+ if (FLAG_fold_constants && value->IsConstant()) {
+ HConstant* c = HConstant::cast(value);
+ if (c->HasNumberValue()) {
+ double double_res = c->DoubleValue();
+ if (TypeInfo::IsInt32Double(double_res)) {
+ return HConstant::New(zone, context,
+ static_cast<int32_t>(double_res),
+ required_representation);
+ }
+ }
+ }
+ return new(zone) HForceRepresentation(value, required_representation);
+}
+
+
void HForceRepresentation::PrintDataTo(StringStream* stream) {
stream->Add("%s ", representation().Mnemonic());
value()->PrintNameTo(stream);
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698