Revision: 10870
Author: [email protected]
Date: Wed Feb 29 05:41:18 2012
Log: Eliminate overflow check after integer add and sub operation if
result is truncated to int32.
Review URL: https://chromiumcodereview.appspot.com/9286002
http://code.google.com/p/v8/source/detail?r=10870
Modified:
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/hydrogen.cc
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Tue Feb 28
07:32:58 2012
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Wed Feb 29
05:41:18 2012
@@ -283,6 +283,14 @@
}
return tail_;
}
+
+
+bool HValue::CheckUsesForFlag(Flag f) {
+ for (HUseIterator it(uses()); !it.Done(); it.Advance()) {
+ if (!it.value()->CheckFlag(f)) return false;
+ }
+ return true;
+}
HUseIterator::HUseIterator(HUseListNode* head) : next_(head) {
@@ -831,12 +839,12 @@
HValue* HConstant::Canonicalize() {
- return HasNoUses() && !IsBlockEntry() ? NULL : this;
+ return HasNoUses() ? NULL : this;
}
HValue* HTypeof::Canonicalize() {
- return HasNoUses() && !IsBlockEntry() ? NULL : this;
+ return HasNoUses() ? NULL : this;
}
@@ -856,6 +864,20 @@
}
return this;
}
+
+
+HValue* HAdd::Canonicalize() {
+ if (!representation().IsInteger32()) return this;
+ if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow);
+ return this;
+}
+
+
+HValue* HSub::Canonicalize() {
+ if (!representation().IsInteger32()) return this;
+ if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow);
+ return this;
+}
HValue* HChange::Canonicalize() {
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Tue Feb 28 07:32:58
2012
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Wed Feb 29 05:41:18
2012
@@ -644,6 +644,9 @@
void SetFlag(Flag f) { flags_ |= (1 << f); }
void ClearFlag(Flag f) { flags_ &= ~(1 << f); }
bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; }
+
+ // Returns true if the flag specified is set for all uses, false
otherwise.
+ bool CheckUsesForFlag(Flag f);
GVNFlagSet gvn_flags() const { return gvn_flags_; }
void SetGVNFlag(GVNFlag f) { gvn_flags_.Add(f); }
@@ -823,6 +826,8 @@
int position() const { return position_; }
bool has_position() const { return position_ != RelocInfo::kNoPosition; }
void set_position(int position) { position_ = position; }
+
+ bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); }
virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0;
@@ -1120,10 +1125,6 @@
static HUnaryOperation* cast(HValue* value) {
return reinterpret_cast<HUnaryOperation*>(value);
}
-
- virtual bool CanTruncateToInt32() const {
- return CheckFlag(kTruncatingToInt32);
- }
HValue* value() { return OperandAt(0); }
virtual void PrintDataTo(StringStream* stream);
@@ -1248,15 +1249,12 @@
: HUnaryOperation(value) {
set_representation(Representation::Integer32());
SetFlag(kUseGVN);
+ SetFlag(kTruncatingToInt32);
}
virtual Representation RequiredInputRepresentation(int index) {
return Representation::None();
}
-
- virtual bool CanTruncateToInt32() const {
- return true;
- }
virtual HValue* Canonicalize() {
if (value()->representation().IsInteger32()) {
@@ -3154,6 +3152,8 @@
virtual HType CalculateInferredType();
+ virtual HValue* Canonicalize();
+
DECLARE_CONCRETE_INSTRUCTION(Add)
protected:
@@ -3172,6 +3172,8 @@
virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
+ virtual HValue* Canonicalize();
+
static HInstruction* NewHSub(Zone* zone,
HValue* context,
HValue* left,
@@ -3257,7 +3259,6 @@
virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
-
static HInstruction* NewHDiv(Zone* zone,
HValue* context,
HValue* left,
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Wed Feb 29 04:12:52 2012
+++ /branches/bleeding_edge/src/hydrogen.cc Wed Feb 29 05:41:18 2012
@@ -2067,13 +2067,9 @@
for (int i = 0; i < phi_list()->length(); i++) {
HPhi* phi = phi_list()->at(i);
if (!phi->CheckFlag(HValue::kTruncatingToInt32)) continue;
- for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) {
- HValue* use = it.value();
- if (!use->CheckFlag(HValue::kTruncatingToInt32)) {
- phi->ClearFlag(HValue::kTruncatingToInt32);
- change = true;
- break;
- }
+ if (!phi->CheckUsesForFlag(HValue::kTruncatingToInt32)) {
+ phi->ClearFlag(HValue::kTruncatingToInt32);
+ change = true;
}
}
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev