Detect truncating Phi uses of Phis with constant inputs

Review URL: https://codereview.chromium.org/14260013

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14525 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 84fd96e4
...@@ -1958,6 +1958,10 @@ void HPhi::DeleteFromGraph() { ...@@ -1958,6 +1958,10 @@ void HPhi::DeleteFromGraph() {
void HPhi::InitRealUses(int phi_id) { void HPhi::InitRealUses(int phi_id) {
// Initialize real uses. // Initialize real uses.
phi_id_ = phi_id; phi_id_ = phi_id;
// Compute a conservative approximation of truncating uses before inferring
// representations. The proper, exact computation will be done later, when
// inserting representation changes.
SetFlag(kTruncatingToInt32);
for (HUseIterator it(uses()); !it.Done(); it.Advance()) { for (HUseIterator it(uses()); !it.Done(); it.Advance()) {
HValue* value = it.value(); HValue* value = it.value();
if (!value->IsPhi()) { if (!value->IsPhi()) {
...@@ -1967,6 +1971,9 @@ void HPhi::InitRealUses(int phi_id) { ...@@ -1967,6 +1971,9 @@ void HPhi::InitRealUses(int phi_id) {
PrintF("#%d Phi is used by real #%d %s as %s\n", PrintF("#%d Phi is used by real #%d %s as %s\n",
id(), value->id(), value->Mnemonic(), rep.Mnemonic()); id(), value->id(), value->Mnemonic(), rep.Mnemonic());
} }
if (!value->IsSimulate() && !value->CheckFlag(kTruncatingToInt32)) {
ClearFlag(kTruncatingToInt32);
}
} }
} }
} }
......
...@@ -3763,7 +3763,39 @@ void HInferRepresentation::Analyze() { ...@@ -3763,7 +3763,39 @@ void HInferRepresentation::Analyze() {
} }
} }
// Set truncation flags for groups of connected phis. This is a conservative
// approximation; the flag will be properly re-computed after representations
// have been determined.
if (phi_count > 0) {
BitVector* done = new(zone()) BitVector(phi_count, graph_->zone());
for (int i = 0; i < phi_count; ++i) {
if (done->Contains(i)) continue;
// Check if all uses of all connected phis in this group are truncating.
bool all_uses_everywhere_truncating = true;
for (BitVector::Iterator it(connected_phis.at(i));
!it.Done();
it.Advance()) {
int index = it.Current();
all_uses_everywhere_truncating &=
phi_list->at(index)->CheckFlag(HInstruction::kTruncatingToInt32);
done->Add(index);
}
if (all_uses_everywhere_truncating) {
continue; // Great, nothing to do.
}
// Clear truncation flag of this group of connected phis.
for (BitVector::Iterator it(connected_phis.at(i));
!it.Done();
it.Advance()) {
int index = it.Current();
phi_list->at(index)->ClearFlag(HInstruction::kTruncatingToInt32);
}
}
}
// Simplify constant phi inputs where possible. // Simplify constant phi inputs where possible.
// This step uses kTruncatingToInt32 flags of phis.
for (int i = 0; i < phi_count; ++i) { for (int i = 0; i < phi_count; ++i) {
phi_list->at(i)->SimplifyConstantInputs(); phi_list->at(i)->SimplifyConstantInputs();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment