Commit 1f3c8dc7 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Properly handle bit->tagged representation changes.

Look at the output type instead of the output representation,
when converting to tagged representation.

R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2159373004
Cr-Commit-Position: refs/heads/master@{#37891}
parent 1906e88d
......@@ -184,7 +184,7 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
} else if (output_type->Is(Type::Unsigned32())) {
uint32_t value = static_cast<uint32_t>(OpParameter<int32_t>(node));
return jsgraph()->Constant(static_cast<double>(value));
} else if (output_rep == MachineRepresentation::kBit) {
} else if (output_type->Is(Type::Boolean())) {
return OpParameter<int32_t>(node) == 0 ? jsgraph()->FalseConstant()
: jsgraph()->TrueConstant();
} else {
......@@ -201,7 +201,12 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
// Select the correct X -> Tagged operator.
const Operator* op;
if (output_rep == MachineRepresentation::kBit) {
op = simplified()->ChangeBitToTagged();
if (output_type->Is(Type::Boolean())) {
op = simplified()->ChangeBitToTagged();
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTagged);
}
} else if (IsWord(output_rep)) {
if (output_type->Is(Type::Signed31())) {
op = simplified()->ChangeInt31ToTaggedSigned();
......
......@@ -1136,8 +1136,7 @@ TEST(InsertBasicChanges) {
static void CheckChangesAroundBinop(TestingGraph* t, const Operator* op,
IrOpcode::Value input_change,
IrOpcode::Value output_change,
Type* type = Type::Any()) {
IrOpcode::Value output_change, Type* type) {
Node* binop =
op->ControlInputCount() == 0
? t->graph()->NewNode(op, t->p0, t->p1)
......@@ -1180,7 +1179,7 @@ TEST(InsertChangesAroundInt32Cmp) {
for (size_t i = 0; i < arraysize(ops); i++) {
CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
IrOpcode::kChangeBitToTagged);
IrOpcode::kChangeBitToTagged, Type::Boolean());
}
}
......@@ -1193,7 +1192,7 @@ TEST(InsertChangesAroundUint32Cmp) {
for (size_t i = 0; i < arraysize(ops); i++) {
CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32,
IrOpcode::kChangeBitToTagged);
IrOpcode::kChangeBitToTagged, Type::Boolean());
}
}
......@@ -1223,7 +1222,7 @@ TEST(InsertChangesAroundFloat64Cmp) {
for (size_t i = 0; i < arraysize(ops); i++) {
CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64,
IrOpcode::kChangeBitToTagged);
IrOpcode::kChangeBitToTagged, Type::Boolean());
}
}
......
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