Revision: 13703
Author: [email protected]
Date: Thu Feb 21 02:22:31 2013
Log: Fixed numeric relations on HPhi instances.
Review URL: https://codereview.chromium.org/12301027
http://code.google.com/p/v8/source/detail?r=13703
Modified:
/branches/bleeding_edge/src/arm/lithium-arm.cc
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/ia32/lithium-ia32.cc
/branches/bleeding_edge/src/mips/lithium-mips.cc
/branches/bleeding_edge/src/x64/lithium-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc Wed Feb 13 06:16:15 2013
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Thu Feb 21 02:22:31 2013
@@ -1688,6 +1688,12 @@
LInstruction* LChunkBuilder::DoNumericConstraint(HNumericConstraint*
instr) {
return NULL;
}
+
+
+LInstruction* LChunkBuilder::DoInductionVariableAnnotation(
+ HInductionVariableAnnotation* instr) {
+ return NULL;
+}
LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Wed Feb 13
06:16:15 2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Thu Feb 21
02:22:31 2013
@@ -841,6 +841,27 @@
related_value()->PrintNameTo(stream);
stream->Add(")");
}
+
+
+HInductionVariableAnnotation* HInductionVariableAnnotation::AddToGraph(
+ HPhi* phi,
+ NumericRelation relation,
+ int operand_index) {
+ HInductionVariableAnnotation* result =
+ new(phi->block()->zone()) HInductionVariableAnnotation(phi, relation,
+
operand_index);
+ result->InsertAfter(phi->block()->first());
+ return result;
+}
+
+
+void HInductionVariableAnnotation::PrintDataTo(StringStream* stream) {
+ stream->Add("(");
+ RedefinedOperand()->PrintNameTo(stream);
+ stream->Add(" %s ", relation().Mnemonic());
+ induction_base()->PrintNameTo(stream);
+ stream->Add(")");
+}
void HDummyUse::PrintDataTo(StringStream* stream) {
@@ -1554,14 +1575,13 @@
void HPhi::AddInformativeDefinitions() {
if (OperandCount() == 2) {
+ // If one of the operands is an OSR block give up (this cannot be an
+ // induction variable).
+ if (OperandAt(0)->block()->is_osr_entry() ||
+ OperandAt(1)->block()->is_osr_entry()) return;
+
for (int operand_index = 0; operand_index < 2; operand_index++) {
int other_operand_index = (operand_index + 1) % 2;
-
- // Add an idef that "discards" the OSR entry block branch.
- if (OperandAt(operand_index)->block()->is_osr_entry()) {
- HNumericConstraint::AddToGraph(
- this, NumericRelation::Eq(), OperandAt(other_operand_index));
- }
static NumericRelation relations[] = {
NumericRelation::Ge(),
@@ -1574,14 +1594,34 @@
for (int relation_index = 0; relation_index < 2; relation_index++) {
if
(OperandAt(operand_index)->IsRelationTrue(relations[relation_index],
this)) {
- HNumericConstraint::AddToGraph(this,
- relations[relation_index],
- OperandAt(other_operand_index));
+ HInductionVariableAnnotation::AddToGraph(this,
+
relations[relation_index],
+ other_operand_index);
}
}
}
}
}
+
+
+bool HPhi::IsRelationTrueInternal(NumericRelation relation, HValue* other)
{
+ if (CheckFlag(kNumericConstraintEvaluationInProgress)) return false;
+
+ SetFlag(kNumericConstraintEvaluationInProgress);
+ bool result = true;
+ for (int i = 0; i < OperandCount(); i++) {
+ // Skip OSR entry blocks
+ if (OperandAt(i)->block()->is_osr_entry()) continue;
+
+ if (!OperandAt(i)->IsRelationTrue(relation, other)) {
+ result = false;
+ break;
+ }
+ }
+ ClearFlag(kNumericConstraintEvaluationInProgress);
+
+ return result;
+}
Range* HMathMinMax::InferRange(Zone* zone) {
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Wed Feb 20 03:49:54
2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Thu Feb 21 02:22:31
2013
@@ -119,6 +119,7 @@
V(Goto) \
V(HasCachedArrayIndexAndBranch) \
V(HasInstanceTypeAndBranch) \
+ V(InductionVariableAnnotation) \
V(In) \
V(InstanceOf) \
V(InstanceOfKnownGlobal) \
@@ -704,6 +705,9 @@
// HGraph::ComputeSafeUint32Operations is responsible for setting this
// flag.
kUint32,
+ // If a phi is involved in the evaluation of a numeric constraint the
+ // recursion can cause an endless cycle: we use this flag to exit the
loop.
+ kNumericConstraintEvaluationInProgress,
// This flag is set to true after the SetupInformativeDefinitions()
pass
// has processed this instruction.
kIDefsProcessingDone,
@@ -2954,6 +2958,8 @@
virtual void InternalSetOperandAt(int index, HValue* value) {
inputs_[index] = value;
}
+
+ virtual bool IsRelationTrueInternal(NumericRelation relation, HValue*
other);
private:
ZoneList<HValue*> inputs_;
@@ -2967,6 +2973,52 @@
};
+class HInductionVariableAnnotation : public HUnaryOperation {
+ public:
+ static HInductionVariableAnnotation* AddToGraph(HPhi* phi,
+ NumericRelation relation,
+ int operand_index);
+
+ NumericRelation relation() { return relation_; }
+ HValue* induction_base() { return phi_->OperandAt(operand_index_); }
+
+ virtual int RedefinedOperandIndex() { return 0; }
+ virtual bool IsPurelyInformativeDefinition() { return true; }
+ virtual Representation RequiredInputRepresentation(int index) {
+ return representation();
+ }
+
+ virtual void PrintDataTo(StringStream* stream);
+
+ virtual bool IsRelationTrueInternal(NumericRelation other_relation,
+ HValue* other_related_value) {
+ if (induction_base() == other_related_value) {
+ return relation().Implies(other_relation);
+ } else {
+ return false;
+ }
+ }
+
+ DECLARE_CONCRETE_INSTRUCTION(InductionVariableAnnotation)
+
+ private:
+ HInductionVariableAnnotation(HPhi* phi,
+ NumericRelation relation,
+ int operand_index)
+ : HUnaryOperation(phi),
+ phi_(phi), relation_(relation), operand_index_(operand_index) {
+ set_representation(phi->representation());
+ }
+
+ // We need to store the phi both here and in the instruction operand
because
+ // the operand can change if a new idef of the phi is added between the
phi
+ // and this instruction (inserting an idef updates every use).
+ HPhi* phi_;
+ NumericRelation relation_;
+ int operand_index_;
+};
+
+
class HArgumentsObject: public HTemplateInstruction<0> {
public:
HArgumentsObject() {
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Wed Feb 13 06:16:15
2013
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Thu Feb 21 02:22:31
2013
@@ -1715,6 +1715,12 @@
LInstruction* LChunkBuilder::DoNumericConstraint(HNumericConstraint*
instr) {
return NULL;
}
+
+
+LInstruction* LChunkBuilder::DoInductionVariableAnnotation(
+ HInductionVariableAnnotation* instr) {
+ return NULL;
+}
LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.cc Wed Feb 13 06:35:05
2013
+++ /branches/bleeding_edge/src/mips/lithium-mips.cc Thu Feb 21 02:22:31
2013
@@ -1593,6 +1593,12 @@
LInstruction* LChunkBuilder::DoNumericConstraint(HNumericConstraint*
instr) {
return NULL;
}
+
+
+LInstruction* LChunkBuilder::DoInductionVariableAnnotation(
+ HInductionVariableAnnotation* instr) {
+ return NULL;
+}
LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Wed Feb 13 06:16:15 2013
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Thu Feb 21 02:22:31 2013
@@ -1639,6 +1639,12 @@
LInstruction* LChunkBuilder::DoNumericConstraint(HNumericConstraint*
instr) {
return NULL;
}
+
+
+LInstruction* LChunkBuilder::DoInductionVariableAnnotation(
+ HInductionVariableAnnotation* instr) {
+ return NULL;
+}
LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.