Index: src/types.cc |
diff --git a/src/types.cc b/src/types.cc |
index 37386cd82f6012e1ccf05caabb6e19fcd4b6664c..f1cf6204a2beacae34bdebf190c01bd7ca41264c 100644 |
--- a/src/types.cc |
+++ b/src/types.cc |
@@ -777,7 +777,7 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Intersect( |
bits &= ~number_bits; |
result->Set(0, BitsetType::New(bits, region)); |
} |
- return NormalizeUnion(result, size); |
+ return NormalizeUnion(result, size, region); |
} |
@@ -992,7 +992,7 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Union( |
size = AddToUnion(type1, result, size, region); |
size = AddToUnion(type2, result, size, region); |
- return NormalizeUnion(result, size); |
+ return NormalizeUnion(result, size, region); |
} |
@@ -1016,9 +1016,9 @@ int TypeImpl<Config>::AddToUnion( |
} |
-template<class Config> |
+template <class Config> |
typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeUnion( |
- UnionHandle unioned, int size) { |
+ UnionHandle unioned, int size, Region* region) { |
DCHECK(size >= 1); |
DCHECK(unioned->Get(0)->IsBitset()); |
// If the union has just one element, return it. |
@@ -1032,8 +1032,11 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NormalizeUnion( |
if (representation == unioned->Get(1)->Representation()) { |
return unioned->Get(1); |
} |
- // TODO(jarin) If the element at 1 is range of constant, slap |
- // the representation on it and return that. |
+ if (unioned->Get(1)->IsRange()) { |
+ return RangeType::New(unioned->Get(1)->AsRange()->Min(), |
+ unioned->Get(1)->AsRange()->Max(), unioned->Get(0), |
+ region); |
+ } |
} |
unioned->Shrink(size); |
SLOW_DCHECK(unioned->Wellformed()); |