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

Unified Diff: src/compiler/representation-change.cc

Issue 2167593002: [turbofan] Introduce TruncateTaggedToBit operator for ToBoolean truncation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix remaining bugs. Created 4 years, 3 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/representation-change.h ('k') | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/representation-change.cc
diff --git a/src/compiler/representation-change.cc b/src/compiler/representation-change.cc
index e4a2f42b6cdc1596ca3012406daa822a2ba37de2..c9e995ec505d567407d1ddaa66e85c6dc49a1dec 100644
--- a/src/compiler/representation-change.cc
+++ b/src/compiler/representation-change.cc
@@ -650,10 +650,7 @@ Node* RepresentationChanger::GetBitRepresentationFor(
switch (node->opcode()) {
case IrOpcode::kHeapConstant: {
Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(node);
- DCHECK(value.is_identical_to(factory()->true_value()) ||
- value.is_identical_to(factory()->false_value()));
- return jsgraph()->Int32Constant(
- value.is_identical_to(factory()->true_value()) ? 1 : 0);
+ return jsgraph()->Int32Constant(value->BooleanValue() ? 1 : 0);
}
default:
break;
@@ -665,9 +662,31 @@ Node* RepresentationChanger::GetBitRepresentationFor(
// We just provide a dummy value here.
return jsgraph()->Int32Constant(0);
} else if (output_rep == MachineRepresentation::kTagged ||
- output_rep == MachineRepresentation::kTaggedSigned ||
output_rep == MachineRepresentation::kTaggedPointer) {
- op = simplified()->ChangeTaggedToBit();
+ if (output_type->Is(Type::BooleanOrNullOrUndefined())) {
+ // true is the only trueish Oddball.
+ op = simplified()->ChangeTaggedToBit();
+ } else {
+ op = simplified()->TruncateTaggedToBit();
+ }
+ } else if (output_rep == MachineRepresentation::kTaggedSigned) {
+ node = jsgraph()->graph()->NewNode(machine()->WordEqual(), node,
+ jsgraph()->ZeroConstant());
+ return jsgraph()->graph()->NewNode(machine()->Word32Equal(), node,
+ jsgraph()->Int32Constant(0));
+ } else if (IsWord(output_rep)) {
+ node = jsgraph()->graph()->NewNode(machine()->Word32Equal(), node,
+ jsgraph()->Int32Constant(0));
+ return jsgraph()->graph()->NewNode(machine()->Word32Equal(), node,
+ jsgraph()->Int32Constant(0));
+ } else if (output_rep == MachineRepresentation::kFloat32) {
+ node = jsgraph()->graph()->NewNode(machine()->Float32Abs(), node);
+ return jsgraph()->graph()->NewNode(machine()->Float32LessThan(),
+ jsgraph()->Float32Constant(0.0), node);
+ } else if (output_rep == MachineRepresentation::kFloat64) {
+ node = jsgraph()->graph()->NewNode(machine()->Float64Abs(), node);
+ return jsgraph()->graph()->NewNode(machine()->Float64LessThan(),
+ jsgraph()->Float64Constant(0.0), node);
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kBit);
« no previous file with comments | « src/compiler/representation-change.h ('k') | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698