Revision: 21818
Author: [email protected]
Date: Thu Jun 12 16:47:51 2014 UTC
Log: Remove forced type changes when they can't deopt
Hydrogen attempts to force representation changes on certain operations in
order
to deoptimise on the change rather than the operation. However, these forced
changes are often unnecessary on 64-bit platforms, and cause poor code
generation, so this patch makes some of them conditional on whether it's
possible for deoptimisation to occur in the change.
On ARM64, this prevents sequences like:
;;; <@46,#89> smi-tag
0x7ff282c7f050 144 lsl x4, x4, #32
;;; <@48,#90> smi-untag
0x7ff282c7f054 148 asr x5, x4, #32
;;; <@50,#31> mul-const-i-s
0x7ff282c7f058 152 lsl w6, w5, #3
BUG=
[email protected]
Review URL: https://codereview.chromium.org/303263010
http://code.google.com/p/v8/source/detail?r=21818
Modified:
/branches/bleeding_edge/src/hydrogen-representation-changes.cc
=======================================
--- /branches/bleeding_edge/src/hydrogen-representation-changes.cc Tue Jun
3 08:12:43 2014 UTC
+++ /branches/bleeding_edge/src/hydrogen-representation-changes.cc Thu Jun
12 16:47:51 2014 UTC
@@ -49,6 +49,15 @@
new_value->InsertBefore(next);
use_value->SetOperandAt(use_index, new_value);
}
+
+
+static bool IsNonDeoptingIntToSmiChange(HChange* change) {
+ Representation from_rep = change->from();
+ Representation to_rep = change->to();
+ // Flags indicating Uint32 operations are set in a later Hydrogen phase.
+ ASSERT(!change->CheckFlag(HValue::kUint32));
+ return from_rep.IsInteger32() && to_rep.IsSmi() && SmiValuesAre32Bits();
+}
void HRepresentationChangesPhase::InsertRepresentationChangesForValue(
@@ -65,17 +74,33 @@
int use_index = it.index();
Representation req = use_value->RequiredInputRepresentation(use_index);
if (req.IsNone() || req.Equals(r)) continue;
+
+ // If this is an HForceRepresentation instruction, and an HChange has
been
+ // inserted above it, examine the input representation of the HChange.
If
+ // that's int32, and this HForceRepresentation use is int32, and int32
to
+ // smi changes can't cause deoptimisation, set the input of the use to
the
+ // input of the HChange.
+ if (value->IsForceRepresentation()) {
+ HValue* input = HForceRepresentation::cast(value)->value();
+ if (input->IsChange()) {
+ HChange* change = HChange::cast(input);
+ if (change->from().Equals(req) &&
IsNonDeoptingIntToSmiChange(change)) {
+ use_value->SetOperandAt(use_index, change->value());
+ continue;
+ }
+ }
+ }
InsertRepresentationChangeForUse(value, use_value, use_index, req);
}
if (value->HasNoUses()) {
- ASSERT(value->IsConstant());
+ ASSERT(value->IsConstant() || value->IsForceRepresentation());
value->DeleteAndReplaceWith(NULL);
- }
-
- // The only purpose of a HForceRepresentation is to represent the value
- // after the (possible) HChange instruction. We make it disappear.
- if (value->IsForceRepresentation()) {
-
value->DeleteAndReplaceWith(HForceRepresentation::cast(value)->value());
+ } else {
+ // The only purpose of a HForceRepresentation is to represent the value
+ // after the (possible) HChange instruction. We make it disappear.
+ if (value->IsForceRepresentation()) {
+
value->DeleteAndReplaceWith(HForceRepresentation::cast(value)->value());
+ }
}
}
--
--
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/d/optout.