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

Unified Diff: src/compiler/simplified-lowering.cc

Issue 2096403002: [turbofan] Introduce simplified operator NumberAbs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: This time fix the compile error for realz Created 4 years, 6 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/simplified-lowering.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc
index 66792f162e969067eed9e63f8e146703fd0bc103..c56494ce32ae5bd3070af96becf046c3014093c4 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -1487,6 +1487,27 @@ class RepresentationSelector {
}
return;
}
+ case IrOpcode::kNumberAbs: {
+ if (InputIs(node, Type::Unsigned32())) {
+ VisitUnop(node, UseInfo::TruncatingWord32(),
+ MachineRepresentation::kWord32);
+ if (lower()) DeferReplacement(node, node->InputAt(0));
+ } else if (InputIs(node, type_cache_.kSafeSigned32)) {
+ VisitUnop(node, UseInfo::TruncatingWord32(),
+ MachineRepresentation::kWord32);
+ if (lower()) DeferReplacement(node, lowering->Int32Abs(node));
+ } else if (InputIs(node,
+ type_cache_.kPositiveIntegerOrMinusZeroOrNaN)) {
+ VisitUnop(node, UseInfo::TruncatingFloat64(),
+ MachineRepresentation::kFloat64);
+ if (lower()) DeferReplacement(node, node->InputAt(0));
+ } else {
+ VisitUnop(node, UseInfo::TruncatingFloat64(),
+ MachineRepresentation::kFloat64);
+ if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
+ }
+ return;
+ }
case IrOpcode::kNumberClz32: {
VisitUnop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32);
@@ -2782,6 +2803,17 @@ Node* SimplifiedLowering::Float64Trunc(Node* const node) {
vtrue0, vfalse0, merge0);
}
+Node* SimplifiedLowering::Int32Abs(Node* const node) {
+ Node* const zero = jsgraph()->Int32Constant(0);
+ Node* const input = node->InputAt(0);
+
+ // if 0 < input then input else 0 - input
+ return graph()->NewNode(
+ common()->Select(MachineRepresentation::kWord32, BranchHint::kTrue),
+ graph()->NewNode(machine()->Int32LessThan(), zero, input), input,
+ graph()->NewNode(machine()->Int32Sub(), zero, input));
+}
+
Node* SimplifiedLowering::Int32Div(Node* const node) {
Int32BinopMatcher m(node);
Node* const zero = jsgraph()->Int32Constant(0);
« no previous file with comments | « src/compiler/simplified-lowering.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698