Fix Boolean to integral types conversions.
Bug: 27616343
Change-Id: I050f92045bca1b8b5d6da53547cc617f17be84b1
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 1249b48..1f66db7 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -786,14 +786,21 @@
}
static bool IsTypeConversionImplicit(Primitive::Type input_type, Primitive::Type result_type) {
+ // Invariant: We should never generate a conversion to a Boolean value.
+ DCHECK_NE(Primitive::kPrimBoolean, result_type);
+
// Besides conversion to the same type, widening integral conversions are implicit,
// excluding conversions to long and the byte->char conversion where we need to
// clear the high 16 bits of the 32-bit sign-extended representation of byte.
return result_type == input_type ||
- (result_type == Primitive::kPrimInt && input_type == Primitive::kPrimByte) ||
- (result_type == Primitive::kPrimInt && input_type == Primitive::kPrimShort) ||
- (result_type == Primitive::kPrimInt && input_type == Primitive::kPrimChar) ||
- (result_type == Primitive::kPrimShort && input_type == Primitive::kPrimByte);
+ (result_type == Primitive::kPrimInt && (input_type == Primitive::kPrimBoolean ||
+ input_type == Primitive::kPrimByte ||
+ input_type == Primitive::kPrimShort ||
+ input_type == Primitive::kPrimChar)) ||
+ (result_type == Primitive::kPrimChar && input_type == Primitive::kPrimBoolean) ||
+ (result_type == Primitive::kPrimShort && (input_type == Primitive::kPrimBoolean ||
+ input_type == Primitive::kPrimByte)) ||
+ (result_type == Primitive::kPrimByte && input_type == Primitive::kPrimBoolean);
}
static bool IsTypeConversionLossless(Primitive::Type input_type, Primitive::Type result_type) {