Index: src/hydrogen-uint32-analysis.cc |
diff --git a/src/hydrogen-uint32-analysis.cc b/src/hydrogen-uint32-analysis.cc |
index 21fbec9f3363bc4de1e7b0bee10cf6210811bfd7..24c256b503a6b8af464700e4a6fa23a4912a94ea 100644 |
--- a/src/hydrogen-uint32-analysis.cc |
+++ b/src/hydrogen-uint32-analysis.cc |
@@ -8,6 +8,30 @@ namespace v8 { |
namespace internal { |
+static bool IsUnsignedLoad(HLoadKeyed* instr) { |
+ switch (instr->elements_kind()) { |
+ case EXTERNAL_UINT8_ELEMENTS: |
+ case EXTERNAL_UINT16_ELEMENTS: |
+ case EXTERNAL_UINT32_ELEMENTS: |
+ case EXTERNAL_UINT8_CLAMPED_ELEMENTS: |
+ case UINT8_ELEMENTS: |
+ case UINT16_ELEMENTS: |
+ case UINT32_ELEMENTS: |
+ case UINT8_CLAMPED_ELEMENTS: |
+ return true; |
+ default: |
+ return false; |
+ } |
+} |
+ |
+ |
+static bool IsUint32Operation(HValue* instr) { |
+ return instr->IsShr() || |
+ (instr->IsLoadKeyed() && IsUnsignedLoad(HLoadKeyed::cast(instr))) || |
+ (instr->IsInteger32Constant() && instr->GetInteger32Constant() >= 0); |
+} |
+ |
+ |
bool HUint32AnalysisPhase::IsSafeUint32Use(HValue* val, HValue* use) { |
// Operations that operate on bits are safe. |
if (use->IsBitwise() || use->IsShl() || use->IsSar() || use->IsShr()) { |
@@ -37,6 +61,9 @@ bool HUint32AnalysisPhase::IsSafeUint32Use(HValue* val, HValue* use) { |
return true; |
} |
} |
+ } else if (use->IsCompareNumericAndBranch()) { |
+ HCompareNumericAndBranch* c = HCompareNumericAndBranch::cast(use); |
+ return IsUint32Operation(c->left()) && IsUint32Operation(c->right()); |
} |
return false; |