Revision: 25025
Author: [email protected]
Date: Fri Oct 31 07:58:49 2014 UTC
Log: [turbofan] Lower NumberModulus to Uint32Mod if both inputs are
Unsigned32.
TEST=cctest/test-simplified-lowering
[email protected]
Review URL: https://codereview.chromium.org/685993003
https://code.google.com/p/v8/source/detail?r=25025
Modified:
/branches/bleeding_edge/src/compiler/simplified-lowering.cc
/branches/bleeding_edge/test/cctest/compiler/test-simplified-lowering.cc
=======================================
--- /branches/bleeding_edge/src/compiler/simplified-lowering.cc Fri Oct 31
06:41:07 2014 UTC
+++ /branches/bleeding_edge/src/compiler/simplified-lowering.cc Fri Oct 31
07:58:49 2014 UTC
@@ -509,6 +509,10 @@
// TODO(turbofan): technically Uint32 cannot observe minus zero either.
return (use & (kTypeUint32 | kTypeNumber | kTypeAny)) != 0;
}
+
+ bool CanObserveNaN(MachineTypeUnion use) {
+ return (use & (kTypeNumber | kTypeAny)) != 0;
+ }
bool CanObserveNonUint32(MachineTypeUnion use) {
return (use & (kTypeInt32 | kTypeNumber | kTypeAny)) != 0;
@@ -707,7 +711,7 @@
if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
break;
}
- if (CanLowerToUint32Binop(node, use)) {
+ if (BothInputsAre(node, Type::Unsigned32())
&& !CanObserveNaN(use)) {
// => unsigned Uint32Mod
VisitUint32Binop(node);
if (lower()) DeferReplacement(node, lowering->Uint32Mod(node));
=======================================
---
/branches/bleeding_edge/test/cctest/compiler/test-simplified-lowering.cc
Fri Oct 31 06:41:07 2014 UTC
+++
/branches/bleeding_edge/test/cctest/compiler/test-simplified-lowering.cc
Fri Oct 31 07:58:49 2014 UTC
@@ -1010,8 +1010,10 @@
TestingGraph t(test_types[i], test_types[i]);
t.CheckLoweringBinop(IrOpcode::kFloat64Div,
t.simplified()->NumberDivide());
- t.CheckLoweringBinop(IrOpcode::kFloat64Mod,
- t.simplified()->NumberModulus());
+ if (!test_types[i]->Is(Type::Unsigned32())) {
+ t.CheckLoweringBinop(IrOpcode::kFloat64Mod,
+ t.simplified()->NumberModulus());
+ }
}
}
@@ -1936,3 +1938,22 @@
CHECK_EQ(IrOpcode::kFloat64Mod, mod->opcode()); // Pesky -0 behavior.
}
}
+
+
+TEST(NumberModulus_Uint32) {
+ const double kConstants[] = {2, 100, 1000, 1024, 2048};
+ const MachineType kTypes[] = {kMachInt32, kMachUint32};
+
+ for (auto const type : kTypes) {
+ for (auto const c : kConstants) {
+ TestingGraph t(Type::Unsigned32());
+ Node* k = t.jsgraph.Constant(c);
+ Node* mod = t.graph()->NewNode(t.simplified()->NumberModulus(),
t.p0, k);
+ Node* use = t.Use(mod, type);
+ t.Return(use);
+ t.Lower();
+
+ CHECK_EQ(IrOpcode::kUint32Mod, use->InputAt(0)->opcode());
+ }
+ }
+}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.