Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: src/compiler/effect-control-linearizer.cc

Issue 2149493002: [turbofan] Introduce CheckedUint32Div and CheckUint32Mod operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comment Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/effect-control-linearizer.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/effect-control-linearizer.cc
diff --git a/src/compiler/effect-control-linearizer.cc b/src/compiler/effect-control-linearizer.cc
index aeb5926759fc7a45a1703965a5643ba215e66c79..65a8a6527e32ea75b2be2978de84c5ed7a52e3f5 100644
--- a/src/compiler/effect-control-linearizer.cc
+++ b/src/compiler/effect-control-linearizer.cc
@@ -642,6 +642,12 @@ bool EffectControlLinearizer::TryWireInStateEffect(Node* node,
case IrOpcode::kCheckedInt32Mod:
state = LowerCheckedInt32Mod(node, frame_state, *effect, *control);
break;
+ case IrOpcode::kCheckedUint32Div:
+ state = LowerCheckedUint32Div(node, frame_state, *effect, *control);
+ break;
+ case IrOpcode::kCheckedUint32Mod:
+ state = LowerCheckedUint32Mod(node, frame_state, *effect, *control);
+ break;
case IrOpcode::kCheckedUint32ToInt32:
state = LowerCheckedUint32ToInt32(node, frame_state, *effect, *control);
break;
@@ -1249,6 +1255,50 @@ EffectControlLinearizer::LowerCheckedInt32Mod(Node* node, Node* frame_state,
}
EffectControlLinearizer::ValueEffectControl
+EffectControlLinearizer::LowerCheckedUint32Div(Node* node, Node* frame_state,
+ Node* effect, Node* control) {
+ Node* zero = jsgraph()->Int32Constant(0);
+
+ Node* lhs = node->InputAt(0);
+ Node* rhs = node->InputAt(1);
+
+ // Ensure that {rhs} is not zero, otherwise we'd have to return NaN.
+ Node* check = graph()->NewNode(machine()->Word32Equal(), rhs, zero);
+ control = effect = graph()->NewNode(common()->DeoptimizeIf(), check,
+ frame_state, effect, control);
+
+ // Perform the actual unsigned integer division.
+ Node* value = graph()->NewNode(machine()->Uint32Div(), lhs, rhs, control);
+
+ // Check if the remainder is non-zero.
+ check = graph()->NewNode(machine()->Word32Equal(), lhs,
+ graph()->NewNode(machine()->Int32Mul(), rhs, value));
+ control = effect = graph()->NewNode(common()->DeoptimizeUnless(), check,
+ frame_state, effect, control);
+
+ return ValueEffectControl(value, effect, control);
+}
+
+EffectControlLinearizer::ValueEffectControl
+EffectControlLinearizer::LowerCheckedUint32Mod(Node* node, Node* frame_state,
+ Node* effect, Node* control) {
+ Node* zero = jsgraph()->Int32Constant(0);
+
+ Node* lhs = node->InputAt(0);
+ Node* rhs = node->InputAt(1);
+
+ // Ensure that {rhs} is not zero, otherwise we'd have to return NaN.
+ Node* check = graph()->NewNode(machine()->Word32Equal(), rhs, zero);
+ control = effect = graph()->NewNode(common()->DeoptimizeIf(), check,
+ frame_state, effect, control);
+
+ // Perform the actual unsigned integer modulus.
+ Node* value = graph()->NewNode(machine()->Uint32Mod(), lhs, rhs, control);
+
+ return ValueEffectControl(value, effect, control);
+}
+
+EffectControlLinearizer::ValueEffectControl
EffectControlLinearizer::LowerCheckedUint32ToInt32(Node* node,
Node* frame_state,
Node* effect,
« no previous file with comments | « src/compiler/effect-control-linearizer.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698