summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_simplifier.cc
diff options
context:
space:
mode:
author Roland Levillain <rpl@google.com> 2016-03-31 10:39:52 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-03-31 10:39:53 +0000
commitb0170f0457f60b81dd232bb3fa505b22f10f324c (patch)
treeb7297d1969458814ae5184cc62dc0a8eac437929 /compiler/optimizing/instruction_simplifier.cc
parent6656f30115c4a6a52ca01f46ca84df125179466a (diff)
parentf355c3ff08710ac2eba3aac2aacc5e65caa06b4c (diff)
Merge "Fix Boolean to integral types conversions."
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r--compiler/optimizing/instruction_simplifier.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 1249b48e1e..1f66db7909 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -786,14 +786,21 @@ void InstructionSimplifierVisitor::VisitArraySet(HArraySet* instruction) {
}
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) {