public:
HChange(HValue* value,
Representation from,
- Representation to)
+ Representation to,
+ bool is_truncating)
: HUnaryOperation(value), from_(from), to_(to) {
ASSERT(!from.IsNone() && !to.IsNone());
ASSERT(!from.Equals(to));
set_representation(to);
SetFlag(kUseGVN);
-
+ if (is_truncating) SetFlag(kTruncatingToInt32);
if (from.IsInteger32() && to.IsTagged() && value->range() != NULL &&
value->range()->IsInSmiRange()) {
set_type(HType::Smi());
return from_;
}
- bool CanTruncateToInt32() const {
- for (int i = 0; i < uses()->length(); ++i) {
- if (!uses()->at(i)->CheckFlag(HValue::kTruncatingToInt32)) return false;
- }
- return true;
- }
+ bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); }
virtual void PrintDataTo(StringStream* stream);
if (!other->IsChange()) return false;
HChange* change = HChange::cast(other);
return value() == change->value()
- && to().Equals(change->to())
- && CanTruncateToInt32() == change->CanTruncateToInt32();
+ && to().Equals(change->to());
}
private:
void HGraph::InsertRepresentationChangeForUse(HValue* value,
HValue* use,
- Representation to,
- bool is_truncating) {
+ Representation to) {
// Insert the representation change right before its use. For phi-uses we
// insert at the end of the corresponding predecessor.
HInstruction* next = NULL;
// information we treat constants like normal instructions and insert the
// change instructions for them.
HInstruction* new_value = NULL;
+ bool is_truncating = use->CheckFlag(HValue::kTruncatingToInt32);
if (value->IsConstant()) {
HConstant* constant = HConstant::cast(value);
// Try to create a new copy of the constant with the new representation.
}
if (new_value == NULL) {
- new_value = new HChange(value, value->representation(), to);
+ new_value = new HChange(value, value->representation(), to, is_truncating);
}
new_value->InsertBefore(next);
for (int i = 0; i < to_convert.length(); ++i) {
HValue* use = to_convert[i];
Representation r_to = to_convert_reps[i];
- bool is_truncating = use->CheckFlag(HValue::kTruncatingToInt32);
- InsertRepresentationChangeForUse(current, use, r_to, is_truncating);
+ InsertRepresentationChangeForUse(current, use, r_to);
}
if (current->uses()->is_empty()) {
void PropagateMinusZeroChecks(HValue* value, BitVector* visited);
void InsertRepresentationChangeForUse(HValue* value,
HValue* use,
- Representation to,
- bool truncating);
+ Representation to);
void InsertRepresentationChanges(HValue* current);
void InferTypes(ZoneList<HValue*>* worklist);
void InitializeInferredTypes(int from_inclusive, int to_inclusive);