Revert "Ensure consistent IR graph has only precise types."
This reverts commit e2e7e110f4c6fc086ad1b653ba42aefa844ceff4.
Reason: Causes failure for regression test: 37726195
Type constraint resolution needs to merge types between aput/aget
arrays and value/dest, which is not possible with the current ValueType.
Change-Id: I074e3ab75b096b1a085ad7ddf178d8947250f916
diff --git a/src/main/java/com/android/tools/r8/ir/code/IRCode.java b/src/main/java/com/android/tools/r8/ir/code/IRCode.java
index 4529112..a5d3e4a 100644
--- a/src/main/java/com/android/tools/r8/ir/code/IRCode.java
+++ b/src/main/java/com/android/tools/r8/ir/code/IRCode.java
@@ -376,7 +376,7 @@
for (Phi phi : block.getPhis()) {
assert !phi.isTrivialPhi();
assert phi.getOperands().size() == predecessorCount;
- assert phi.outType().isPreciseType();
+ assert phi.outType() != ValueType.INT_OR_FLOAT_OR_NULL;
values.add(phi);
for (Value value : phi.getOperands()) {
values.add(value);
@@ -393,7 +393,7 @@
if (outValue != null) {
values.add(outValue);
assert outValue.definition == instruction;
- assert outValue.outType().isPreciseType();
+ assert outValue.outType() != ValueType.INT_OR_FLOAT_OR_NULL;
}
for (Value value : instruction.inValues()) {
values.add(value);
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java b/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java
index 3b2be1f..4c6d9c1 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java
@@ -60,6 +60,9 @@
merge(ifInstruction.inValues().get(0), ifInstruction.inValues().get(1));
}
}
+
+ // TODO(zerny): Once we have detailed value types we must join the array element-type with
+ // the value/dest for array-put/get instructions.
}
}
for (Value value : impreciseValues) {
@@ -73,15 +76,7 @@
private ValueType getPreciseType(Value value) {
ValueType type = canonical(value).outType();
- if (type.isPreciseType()) {
- return type;
- }
- // If the type is still imprecise, then there are no constraints forcing its type and we
- // arbitrarily choose long for wide values and int for single values.
- if (type.isWide()) {
- return ValueType.LONG;
- }
- return ValueType.INT;
+ return type != ValueType.INT_OR_FLOAT_OR_NULL ? type : ValueType.INT_OR_FLOAT;
}
private void link(Value canonical1, Value canonical2) {
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java b/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java
index 9cff141..3ea434a 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java
@@ -1034,7 +1034,7 @@
if (argumentIndex != -1 && checkArgumentType(invoke, target.method,
argumentIndex)) {
Value argument = invoke.arguments().get(argumentIndex);
- assert invoke.outType() == argument.outType();
+ assert invoke.outType().verifyCompatible(argument.outType());
invoke.outValue().replaceUsers(argument);
invoke.setOutValue(null);
}