Skip to content

Commit bd44f1f

Browse files
alexmarkovCommit Queue
authored andcommitted
[vm/compiler] Simplify range analysis by removing range sizes
Concept of range sizes is artificial and sometimes over-approximated as it doesn't match representations used in IL instructions. It is replaced by "full range" derived from representation. Also, this change removes a bit of Smi-specific logic which cannot be extended for arbitrary integers. TEST=ci Change-Id: Ifc3092b13e4655cd5790d39d3fb88bd9b40ba484 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396481 Reviewed-by: Slava Egorov <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent f601692 commit bd44f1f

File tree

5 files changed

+298
-445
lines changed

5 files changed

+298
-445
lines changed

runtime/vm/compiler/backend/flow_graph.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,10 +2177,9 @@ class PhiUnboxingHeuristic : public ValueObject {
21772177
// If all the inputs are unboxed integers but with different
21782178
// representations, then pick a representation based on the range
21792179
// of values that flow into the phi node.
2180-
new_representation =
2181-
RangeUtils::Fits(phi->range(), RangeBoundary::kRangeBoundaryInt32)
2182-
? kUnboxedInt32
2183-
: kUnboxedInt64;
2180+
new_representation = Range::Fits(phi->range(), kUnboxedInt32)
2181+
? kUnboxedInt32
2182+
: kUnboxedInt64;
21842183
}
21852184

21862185
// Decide if it is worth to unbox an boxed integer phi.
@@ -2202,10 +2201,9 @@ class PhiUnboxingHeuristic : public ValueObject {
22022201
const bool flows_into_unboxed_use = FlowsIntoUnboxedUse(phi);
22032202

22042203
if (has_unboxed_incoming_value && flows_into_unboxed_use) {
2205-
new_representation =
2206-
RangeUtils::Fits(phi->range(), RangeBoundary::kRangeBoundaryInt32)
2207-
? kUnboxedInt32
2208-
: kUnboxedInt64;
2204+
new_representation = Range::Fits(phi->range(), kUnboxedInt32)
2205+
? kUnboxedInt32
2206+
: kUnboxedInt64;
22092207
}
22102208
#endif
22112209
}

runtime/vm/compiler/backend/il.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3182,7 +3182,8 @@ Definition* UnboxLaneInstr::Canonicalize(FlowGraph* flow_graph) {
31823182

31833183
bool BoxIntegerInstr::ValueFitsSmi() const {
31843184
Range* range = value()->definition()->range();
3185-
return RangeUtils::Fits(range, RangeBoundary::kRangeBoundarySmi);
3185+
return RangeUtils::IsWithin(range, compiler::target::kSmiMin,
3186+
compiler::target::kSmiMax);
31863187
}
31873188

31883189
Definition* BoxIntegerInstr::Canonicalize(FlowGraph* flow_graph) {

0 commit comments

Comments
 (0)