[vm/compiler] Make BinaryIntegerOpInstr::InferRange().

Instead of putting the same InferRange() in BinaryInt32Op,
BinaryInt64Op, and (currently missing) BinaryUint32Op, just add a base
version in BinaryIntegerOp that's overridden by the caching versions in
BinarySmiOp and ShiftIntegerOp.

Change-Id: I38e4b4869c08101b97201159eee0de972bfc0cbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156681
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
This commit is contained in:
Tess Strickland
2020-07-31 15:06:15 +00:00
committed by commit-bot@chromium.org
parent 12be370067
commit d7feab5aaa
3 changed files with 16 additions and 20 deletions
+9 -8
View File
@@ -3170,18 +3170,19 @@ Definition* IntConverterInstr::Canonicalize(FlowGraph* flow_graph) {
return this;
}
#if defined(TARGET_ARCH_IS_32_BIT)
// Do not erase extending conversions from 32-bit untagged to 64-bit values
// because untagged does not specify whether it is signed or not.
if ((box_defn->from() == kUntagged) && to() == kUnboxedInt64) {
return this;
}
#endif
// It's safe to discard any other conversions from and then back to the same
// integer type.
if (box_defn->from() == to()) {
return box_defn->value()->definition();
}
// Do not merge conversions where the first starts from Untagged or the
// second ends at Untagged, since we expect to see either UnboxedIntPtr
// or UnboxedFfiIntPtr as the other type in an Untagged conversion.
if ((box_defn->from() == kUntagged) || (to() == kUntagged)) {
return this;
}
IntConverterInstr* converter = new IntConverterInstr(
box_defn->from(), representation(), box_defn->value()->CopyWithType(),
(to() == kUnboxedInt32) ? GetDeoptId() : DeoptId::kNone);
+2 -2
View File
@@ -7568,6 +7568,8 @@ class BinaryIntegerOpInstr : public TemplateDefinition<2, NoThrow, Pure> {
virtual intptr_t DeoptimizationTarget() const { return GetDeoptId(); }
virtual void InferRange(RangeAnalysis* analysis, Range* range);
PRINT_OPERANDS_TO_SUPPORT
ADD_OPERANDS_TO_S_EXPRESSION_SUPPORT
@@ -7660,7 +7662,6 @@ class BinaryInt32OpInstr : public BinaryIntegerOpInstr {
return kUnboxedInt32;
}
virtual void InferRange(RangeAnalysis* analysis, Range* range);
virtual CompileType ComputeType() const;
DECLARE_INSTRUCTION(BinaryInt32Op)
@@ -7748,7 +7749,6 @@ class BinaryInt64OpInstr : public BinaryIntegerOpInstr {
(speculative_mode_ == other->AsBinaryInt64Op()->speculative_mode_);
}
virtual void InferRange(RangeAnalysis* analysis, Range* range);
virtual CompileType ComputeType() const;
DECLARE_INSTRUCTION(BinaryInt64Op)
+5 -10
View File
@@ -2858,6 +2858,11 @@ static void CacheRange(Range** slot,
}
}
void BinaryIntegerOpInstr::InferRange(RangeAnalysis* analysis, Range* range) {
InferRangeHelper(analysis->GetSmiRange(left()),
analysis->GetSmiRange(right()), range);
}
void BinarySmiOpInstr::InferRange(RangeAnalysis* analysis, Range* range) {
const Range* right_smi_range = analysis->GetSmiRange(right());
// TODO(vegorov) completely remove this once GetSmiRange is eliminated.
@@ -2869,16 +2874,6 @@ void BinarySmiOpInstr::InferRange(RangeAnalysis* analysis, Range* range) {
InferRangeHelper(analysis->GetSmiRange(left()), right_smi_range, range);
}
void BinaryInt32OpInstr::InferRange(RangeAnalysis* analysis, Range* range) {
InferRangeHelper(analysis->GetSmiRange(left()),
analysis->GetSmiRange(right()), range);
}
void BinaryInt64OpInstr::InferRange(RangeAnalysis* analysis, Range* range) {
InferRangeHelper(left()->definition()->range(),
right()->definition()->range(), range);
}
void ShiftIntegerOpInstr::InferRange(RangeAnalysis* analysis, Range* range) {
const Range* right_range = RequiredInputRepresentation(1) == kTagged
? analysis->GetSmiRange(right())