Commit a8b5e235 authored by jarin's avatar jarin Committed by Commit bot

[turbofan] Allow truncating minus zero in add, sub, mul if we have word32 truncation.

Review-Url: https://codereview.chromium.org/2080093002
Cr-Commit-Position: refs/heads/master@{#37080}
parent 2e495010
......@@ -1056,7 +1056,7 @@ class RepresentationSelector {
}
// Use truncation if available.
if (BothInputsAre(node, type_cache_.kAdditiveSafeInteger) &&
if (BothInputsAre(node, type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
truncation.TruncatesToWord32()) {
// safe-int + safe-int = x (truncated to int32)
// => signed Int32Add/Sub (truncated)
......@@ -1282,7 +1282,8 @@ class RepresentationSelector {
// => signed Int32Add/Sub
VisitInt32Binop(node);
if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
} else if (BothInputsAre(node, type_cache_.kAdditiveSafeInteger) &&
} else if (BothInputsAre(node,
type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
truncation.TruncatesToWord32()) {
// safe-int + safe-int = x (truncated to int32)
// => signed Int32Add/Sub (truncated)
......@@ -1305,7 +1306,8 @@ class RepresentationSelector {
return;
}
if (truncation.TruncatesToWord32() &&
NodeProperties::GetType(node)->Is(type_cache_.kSafeInteger)) {
NodeProperties::GetType(node)->Is(
type_cache_.kSafeIntegerOrMinusZero)) {
// Multiply reduces to Int32Mul if the inputs are integers,
// the uses are truncating and the result is in the safe
// integer range.
......
......@@ -57,6 +57,10 @@ class TypeCache final {
Type* const kAdditiveSafeInteger =
CreateRange(-4503599627370496.0, 4503599627370496.0);
Type* const kSafeInteger = CreateRange(-kMaxSafeInteger, kMaxSafeInteger);
Type* const kAdditiveSafeIntegerOrMinusZero =
Type::Union(kAdditiveSafeInteger, Type::MinusZero(), zone());
Type* const kSafeIntegerOrMinusZero =
Type::Union(kSafeInteger, Type::MinusZero(), zone());
Type* const kPositiveSafeInteger = CreateRange(0.0, kMaxSafeInteger);
Type* const kUntaggedUndefined =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment