Commit 75a61325 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[turbofan] Simplified LowerCheckedInt(32|64)ToTaggedSigned

Merge duplicate LowerCheckedInt32ToTaggedSigned code.

Skip ChangeInt32ToInt64:
* In 32 bit archs, ChangeInt32ToInt64 is a no-op.
* In 64 bit archs with 31 bit smis and smi corrupting enabled,
ChangeInt32ToIntPtr can be skipped. This is because it would only
change the upper bits, and those upper bits are not significant
since we are smi-corrupting.

Change-Id: Ia217773fc7fccdd6227f66fbd600326ebbe9b86d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1893193
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64906}
parent a42a0b72
......@@ -2265,13 +2265,13 @@ Node* EffectControlLinearizer::LowerCheckedInt32ToTaggedSigned(
Node* value = node->InputAt(0);
const CheckParameters& params = CheckParametersOf(node->op());
// Check for the lost precision at the same time that we are smi tagging.
Node* add = __ Int32AddWithOverflow(value, value);
Node* check = __ Projection(1, add);
__ DeoptimizeIf(DeoptimizeReason::kLostPrecision, params.feedback(), check,
frame_state);
Node* result = __ Projection(0, add);
result = ChangeInt32ToIntPtr(result);
return result;
// Since smi tagging shifts left by one, it's the same as adding value twice.
return __ Projection(0, add);
}
Node* EffectControlLinearizer::LowerCheckedInt64ToInt32(Node* node,
......@@ -2299,13 +2299,7 @@ Node* EffectControlLinearizer::LowerCheckedInt64ToTaggedSigned(
if (SmiValuesAre32Bits()) {
return ChangeInt64ToSmi(value);
} else {
Node* add = __ Int32AddWithOverflow(value32, value32);
Node* check = __ Projection(1, add);
__ DeoptimizeIf(DeoptimizeReason::kLostPrecision, params.feedback(), check,
frame_state);
Node* result = __ Projection(0, add);
result = ChangeInt32ToIntPtr(result);
return result;
return LowerCheckedInt32ToTaggedSigned(value32, frame_state);
}
}
......
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