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

Unified Diff: test/cctest/compiler/test-representation-change.cc

Issue 840953003: [turbofan] Correctify representation changes to bit. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: std::isnan Created 5 years, 11 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/verifier.cc ('k') | test/mjsunit/compiler/regress-bit-number-constant.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-representation-change.cc
diff --git a/test/cctest/compiler/test-representation-change.cc b/test/cctest/compiler/test-representation-change.cc
index 2dc30294a29cd6223cde2de2894f174c16d9667b..0496ad8e41989857cbc5f28431b001cbd7a3f782 100644
--- a/test/cctest/compiler/test-representation-change.cc
+++ b/test/cctest/compiler/test-representation-change.cc
@@ -79,10 +79,14 @@ class RepresentationChangerTester : public HandleAndZoneScope,
CHECK_EQ(expected, m.Value());
}
- Node* Parameter(int index = 0) {
- return graph()->NewNode(common()->Parameter(index), graph()->start());
+ Node* Parameter(Type* type, int index = 0) {
+ Node* node = graph()->NewNode(common()->Parameter(index), graph()->start());
+ NodeProperties::SetBounds(node, Bounds(type));
+ return node;
}
+ Node* Parameter(int index = 0) { return Parameter(Type::Any(), index); }
+
void CheckTypeError(MachineTypeUnion from, MachineTypeUnion to) {
changer()->testing_type_errors_ = true;
changer()->type_error_ = false;
@@ -98,16 +102,17 @@ class RepresentationChangerTester : public HandleAndZoneScope,
CHECK_EQ(n, c);
}
};
-}
-}
-} // namespace v8::internal::compiler
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
static const MachineType all_reps[] = {kRepBit, kRepWord32, kRepWord64,
kRepFloat32, kRepFloat64, kRepTagged};
-TEST(BoolToBit_constant) {
+TEST(ToBit_constant) {
RepresentationChangerTester r;
Node* true_node = r.jsgraph()->TrueConstant();
@@ -119,6 +124,22 @@ TEST(BoolToBit_constant) {
Node* false_bit =
r.changer()->GetRepresentationFor(false_node, kRepTagged, kRepBit);
r.CheckInt32Constant(false_bit, 0);
+
+ {
+ FOR_FLOAT64_INPUTS(i) {
+ Node* node = r.jsgraph()->Constant(*i);
+ Node* bit = r.changer()->GetRepresentationFor(node, kRepTagged, kRepBit);
+ r.CheckInt32Constant(bit, DoubleToBoolean(*i) ? 1 : 0);
+ }
+ }
+
+ {
+ FOR_INT32_INPUTS(i) {
+ Node* node = r.jsgraph()->Int32Constant(*i);
+ Node* bit = r.changer()->GetRepresentationFor(node, kRepWord32, kRepBit);
+ r.CheckInt32Constant(bit, *i == 0 ? 0 : 1);
+ }
+ }
}
@@ -370,10 +391,10 @@ TEST(ToUint32_constant) {
static void CheckChange(IrOpcode::Value expected, MachineTypeUnion from,
- MachineTypeUnion to) {
+ MachineTypeUnion to, Type* from_type = Type::Any()) {
RepresentationChangerTester r;
- Node* n = r.Parameter();
+ Node* n = r.Parameter(from_type);
Node* c = r.changer()->GetRepresentationFor(n, from, to);
CHECK_NE(c, n);
@@ -384,10 +405,11 @@ static void CheckChange(IrOpcode::Value expected, MachineTypeUnion from,
static void CheckTwoChanges(IrOpcode::Value expected2,
IrOpcode::Value expected1, MachineTypeUnion from,
- MachineTypeUnion to) {
+ MachineTypeUnion to,
+ Type* from_type = Type::Any()) {
RepresentationChangerTester r;
- Node* n = r.Parameter();
+ Node* n = r.Parameter(from_type);
Node* c1 = r.changer()->GetRepresentationFor(n, from, to);
CHECK_NE(c1, n);
@@ -400,7 +422,15 @@ static void CheckTwoChanges(IrOpcode::Value expected2,
TEST(SingleChanges) {
- CheckChange(IrOpcode::kChangeBoolToBit, kRepTagged, kRepBit);
+ CheckChange(IrOpcode::kChangeBoolToBit, kRepTagged, kRepBit, Type::Boolean());
+ CheckTwoChanges(IrOpcode::kChangeTaggedToInt32, IrOpcode::kChangeWord32ToBit,
+ kRepTagged, kRepBit, Type::Signed32());
+ CheckTwoChanges(IrOpcode::kChangeTaggedToUint32, IrOpcode::kChangeWord32ToBit,
+ kRepTagged, kRepBit, Type::Unsigned32());
+ CheckChange(IrOpcode::kChangeWord32ToBit, kRepWord8, kRepBit);
+ CheckChange(IrOpcode::kChangeWord32ToBit, kRepWord16, kRepBit);
+ CheckChange(IrOpcode::kChangeWord32ToBit, kRepWord32, kRepBit);
+ CheckChange(IrOpcode::kChangeWord64ToBit, kRepWord64, kRepBit);
CheckChange(IrOpcode::kChangeBitToBool, kRepBit, kRepTagged);
CheckChange(IrOpcode::kChangeInt32ToTagged, kRepWord32 | kTypeInt32,
@@ -480,12 +510,6 @@ TEST(Nops) {
r.CheckNop(kRepFloat32 | kTypeNumber, kRepFloat32);
r.CheckNop(kRepFloat32, kRepFloat32 | kTypeNumber);
- // 32-bit or 64-bit words can be used as branch conditions (kRepBit).
- r.CheckNop(kRepWord32, kRepBit);
- r.CheckNop(kRepWord32, kRepBit | kTypeBool);
- r.CheckNop(kRepWord64, kRepBit);
- r.CheckNop(kRepWord64, kRepBit | kTypeBool);
-
// 32-bit words can be used as smaller word sizes and vice versa, because
// loads from memory implicitly sign or zero extend the value to the
// full machine word size, and stores implicitly truncate.
« no previous file with comments | « src/compiler/verifier.cc ('k') | test/mjsunit/compiler/regress-bit-number-constant.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698