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

Side by Side Diff: src/hydrogen-representation-changes.cc

Issue 22600005: Eliminate intentional conversion from Smi to Int32 in HMul (Closed) Base URL: https://github.com/v8/v8.git@master
Patch Set: Fixed navier stokes benchmark fails Created 7 years, 4 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
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/runtime.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 value->DeleteAndReplaceWith(HForceRepresentation::cast(value)->value()); 96 value->DeleteAndReplaceWith(HForceRepresentation::cast(value)->value());
97 } 97 }
98 } 98 }
99 99
100 100
101 void HRepresentationChangesPhase::Run() { 101 void HRepresentationChangesPhase::Run() {
102 // Compute truncation flag for phis: Initially assume that all 102 // Compute truncation flag for phis: Initially assume that all
103 // int32-phis allow truncation and iteratively remove the ones that 103 // int32-phis allow truncation and iteratively remove the ones that
104 // are used in an operation that does not allow a truncating 104 // are used in an operation that does not allow a truncating
105 // conversion. 105 // conversion.
106 ZoneList<HPhi*> worklist(8, zone()); 106 ZoneList<HPhi*> int_worklist(8, zone());
107 ZoneList<HPhi*> smi_worklist(8, zone());
107 108
108 const ZoneList<HPhi*>* phi_list(graph()->phi_list()); 109 const ZoneList<HPhi*>* phi_list(graph()->phi_list());
109 for (int i = 0; i < phi_list->length(); i++) { 110 for (int i = 0; i < phi_list->length(); i++) {
110 HPhi* phi = phi_list->at(i); 111 HPhi* phi = phi_list->at(i);
111 if (phi->representation().IsInteger32()) { 112 if (phi->representation().IsInteger32()) {
112 phi->SetFlag(HValue::kTruncatingToInt32); 113 phi->SetFlag(HValue::kTruncatingToInt32);
113 } else if (phi->representation().IsSmi()) { 114 } else if (phi->representation().IsSmi()) {
114 phi->SetFlag(HValue::kTruncatingToSmi); 115 phi->SetFlag(HValue::kTruncatingToSmi);
116 phi->SetFlag(HValue::kTruncatingToInt32);
115 } 117 }
116 } 118 }
117 119
118 for (int i = 0; i < phi_list->length(); i++) { 120 for (int i = 0; i < phi_list->length(); i++) {
119 HPhi* phi = phi_list->at(i); 121 HPhi* phi = phi_list->at(i);
120 for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) { 122 HValue* value = NULL;
121 // If a Phi is used as a non-truncating int32 or as a double, 123 if (phi->representation().IsSmiOrInteger32() &&
122 // clear its "truncating" flag. 124 !phi->CheckUsesForFlag(HValue::kTruncatingToInt32, &value)) {
123 HValue* use = it.value(); 125 int_worklist.Add(phi, zone());
124 Representation input_representation = 126 phi->ClearFlag(HValue::kTruncatingToInt32);
125 use->RequiredInputRepresentation(it.index()); 127 if (FLAG_trace_representation) {
126 if ((phi->representation().IsInteger32() && 128 PrintF("#%d Phi is not truncating Int32 because of #%d %s\n",
127 !(input_representation.IsInteger32() && 129 phi->id(), value->id(), value->Mnemonic());
128 use->CheckFlag(HValue::kTruncatingToInt32))) || 130 }
129 (phi->representation().IsSmi() && 131 }
130 !(input_representation.IsSmi() || 132
131 use->CheckFlag(HValue::kTruncatingToSmi)))) { 133 if (phi->representation().IsSmi() &&
132 if (FLAG_trace_representation) { 134 !phi->CheckUsesForFlag(HValue::kTruncatingToSmi, &value)) {
133 PrintF("#%d Phi is not truncating because of #%d %s\n", 135 smi_worklist.Add(phi, zone());
134 phi->id(), it.value()->id(), it.value()->Mnemonic()); 136 phi->ClearFlag(HValue::kTruncatingToSmi);
135 } 137 if (FLAG_trace_representation) {
136 phi->ClearFlag(HValue::kTruncatingToInt32); 138 PrintF("#%d Phi is not truncating Smi because of #%d %s\n",
137 phi->ClearFlag(HValue::kTruncatingToSmi); 139 phi->id(), value->id(), value->Mnemonic());
138 worklist.Add(phi, zone());
139 break;
140 } 140 }
141 } 141 }
142 } 142 }
143 143
144 while (!worklist.is_empty()) { 144 while (!int_worklist.is_empty()) {
145 HPhi* current = worklist.RemoveLast(); 145 HPhi* current = int_worklist.RemoveLast();
146 for (int i = 0; i < current->OperandCount(); ++i) { 146 for (int i = 0; i < current->OperandCount(); ++i) {
147 HValue* input = current->OperandAt(i); 147 HValue* input = current->OperandAt(i);
148 if (input->IsPhi() && 148 if (input->IsPhi() &&
149 ((input->representation().IsInteger32() && 149 input->representation().IsSmiOrInteger32() &&
150 input->CheckFlag(HValue::kTruncatingToInt32)) || 150 input->CheckFlag(HValue::kTruncatingToInt32)) {
151 (input->representation().IsSmi() &&
152 input->CheckFlag(HValue::kTruncatingToSmi)))) {
153 if (FLAG_trace_representation) { 151 if (FLAG_trace_representation) {
154 PrintF("#%d Phi is not truncating because of #%d %s\n", 152 PrintF("#%d Phi is not truncating Int32 because of #%d %s\n",
155 input->id(), current->id(), current->Mnemonic()); 153 input->id(), current->id(), current->Mnemonic());
156 } 154 }
157 input->ClearFlag(HValue::kTruncatingToInt32); 155 input->ClearFlag(HValue::kTruncatingToInt32);
158 input->ClearFlag(HValue::kTruncatingToSmi); 156 int_worklist.Add(HPhi::cast(input), zone());
159 worklist.Add(HPhi::cast(input), zone());
160 } 157 }
161 } 158 }
162 } 159 }
160
161 while (!smi_worklist.is_empty()) {
162 HPhi* current = smi_worklist.RemoveLast();
163 for (int i = 0; i < current->OperandCount(); ++i) {
164 HValue* input = current->OperandAt(i);
165 if (input->IsPhi() &&
166 input->representation().IsSmi() &&
167 input->CheckFlag(HValue::kTruncatingToSmi)) {
168 if (FLAG_trace_representation) {
169 PrintF("#%d Phi is not truncating Smi because of #%d %s\n",
170 input->id(), current->id(), current->Mnemonic());
171 }
172 input->ClearFlag(HValue::kTruncatingToSmi);
173 smi_worklist.Add(HPhi::cast(input), zone());
174 }
175 }
176 }
163 177
164 const ZoneList<HBasicBlock*>* blocks(graph()->blocks()); 178 const ZoneList<HBasicBlock*>* blocks(graph()->blocks());
165 for (int i = 0; i < blocks->length(); ++i) { 179 for (int i = 0; i < blocks->length(); ++i) {
166 // Process phi instructions first. 180 // Process phi instructions first.
167 const HBasicBlock* block(blocks->at(i)); 181 const HBasicBlock* block(blocks->at(i));
168 const ZoneList<HPhi*>* phis = block->phis(); 182 const ZoneList<HPhi*>* phis = block->phis();
169 for (int j = 0; j < phis->length(); j++) { 183 for (int j = 0; j < phis->length(); j++) {
170 InsertRepresentationChangesForValue(phis->at(j)); 184 InsertRepresentationChangesForValue(phis->at(j));
171 } 185 }
172 186
173 // Process normal instructions. 187 // Process normal instructions.
174 for (HInstruction* current = block->first(); current != NULL; ) { 188 for (HInstruction* current = block->first(); current != NULL; ) {
175 HInstruction* next = current->next(); 189 HInstruction* next = current->next();
176 InsertRepresentationChangesForValue(current); 190 InsertRepresentationChangesForValue(current);
177 current = next; 191 current = next;
178 } 192 }
179 } 193 }
180 } 194 }
181 195
182 } } // namespace v8::internal 196 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698