Index: src/compiler/typed-optimization.cc |
diff --git a/src/compiler/typed-optimization.cc b/src/compiler/typed-optimization.cc |
index 42d5232d589555d27c57ba7969db95dc8e57f5d2..5ebc390c8bc6a1d5f2c7bc3807211ebb88dba30c 100644 |
--- a/src/compiler/typed-optimization.cc |
+++ b/src/compiler/typed-optimization.cc |
@@ -87,6 +87,8 @@ Reduction TypedOptimization::Reduce(Node* node) { |
case IrOpcode::kNumberRound: |
case IrOpcode::kNumberTrunc: |
return ReduceNumberRoundop(node); |
+ case IrOpcode::kNumberToUint8Clamped: |
+ return ReduceNumberToUint8Clamped(node); |
case IrOpcode::kPhi: |
return ReducePhi(node); |
case IrOpcode::kSelect: |
@@ -192,6 +194,15 @@ Reduction TypedOptimization::ReduceNumberRoundop(Node* node) { |
return NoChange(); |
} |
+Reduction TypedOptimization::ReduceNumberToUint8Clamped(Node* node) { |
+ Node* const input = NodeProperties::GetValueInput(node, 0); |
+ Type* const input_type = NodeProperties::GetType(input); |
+ if (input_type->Is(type_cache_.kUint8)) { |
+ return Replace(input); |
+ } |
+ return NoChange(); |
+} |
+ |
Reduction TypedOptimization::ReducePhi(Node* node) { |
// Try to narrow the type of the Phi {node}, which might be more precise now |
// after lowering based on types, i.e. a SpeculativeNumberAdd has a more |