Do not use HNot for creating !bool.
HNot folds to ~, not !.
Change-Id: I681f968449a2ade7110b2f316146ad16ba5da74c
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc
index 07c84bc..32ec535 100644
--- a/compiler/optimizing/code_generator_arm.cc
+++ b/compiler/optimizing/code_generator_arm.cc
@@ -2437,10 +2437,6 @@
Location out = locations->Out();
Location in = locations->InAt(0);
switch (not_->InputAt(0)->GetType()) {
- case Primitive::kPrimBoolean:
- __ eor(out.AsRegister<Register>(), in.AsRegister<Register>(), ShifterOperand(1));
- break;
-
case Primitive::kPrimInt:
__ mvn(out.AsRegister<Register>(), ShifterOperand(in.AsRegister<Register>()));
break;
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc
index 306845b..5bbcd55 100644
--- a/compiler/optimizing/code_generator_arm64.cc
+++ b/compiler/optimizing/code_generator_arm64.cc
@@ -2269,10 +2269,6 @@
void InstructionCodeGeneratorARM64::VisitNot(HNot* instruction) {
switch (instruction->InputAt(0)->GetType()) {
- case Primitive::kPrimBoolean:
- __ Eor(OutputRegister(instruction), InputRegisterAt(instruction, 0), Operand(1));
- break;
-
case Primitive::kPrimInt:
case Primitive::kPrimLong:
__ Mvn(OutputRegister(instruction), InputOperandAt(instruction, 0));
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc
index 57f01e8..25a6e84 100644
--- a/compiler/optimizing/code_generator_x86.cc
+++ b/compiler/optimizing/code_generator_x86.cc
@@ -2608,10 +2608,6 @@
Location out = locations->Out();
DCHECK(in.Equals(out));
switch (not_->InputAt(0)->GetType()) {
- case Primitive::kPrimBoolean:
- __ xorl(out.AsRegister<Register>(), Immediate(1));
- break;
-
case Primitive::kPrimInt:
__ notl(out.AsRegister<Register>());
break;
diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc
index dd6861f..619ac09 100644
--- a/compiler/optimizing/code_generator_x86_64.cc
+++ b/compiler/optimizing/code_generator_x86_64.cc
@@ -2469,10 +2469,6 @@
locations->Out().AsRegister<CpuRegister>().AsRegister());
Location out = locations->Out();
switch (not_->InputAt(0)->GetType()) {
- case Primitive::kPrimBoolean:
- __ xorq(out.AsRegister<CpuRegister>(), Immediate(1));
- break;
-
case Primitive::kPrimInt:
__ notl(out.AsRegister<CpuRegister>());
break;
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 49ca443..63bc4ae 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -59,10 +59,9 @@
equal->ReplaceWith(equal->InputAt(0));
equal->GetBlock()->RemoveInstruction(equal);
} else {
- // Replace (bool_value == 0) with !bool_value
+ // We should replace (bool_value == 0) with !bool_value, but we unfortunately
+ // do not have such instruction.
DCHECK_EQ(input2->AsIntConstant()->GetValue(), 0);
- equal->GetBlock()->ReplaceAndRemoveInstructionWith(
- equal, new (GetGraph()->GetArena()) HNot(Primitive::kPrimBoolean, input1));
}
}
}
diff --git a/test/443-not-bool-inline/expected.txt b/test/443-not-bool-inline/expected.txt
new file mode 100644
index 0000000..3ee3849
--- /dev/null
+++ b/test/443-not-bool-inline/expected.txt
@@ -0,0 +1 @@
+Hello World 2
diff --git a/test/443-not-bool-inline/info.txt b/test/443-not-bool-inline/info.txt
new file mode 100644
index 0000000..31f2321
--- /dev/null
+++ b/test/443-not-bool-inline/info.txt
@@ -0,0 +1,2 @@
+Regression test for optimizing, who used a wrong instruction
+for simplifying Equals(foo, false);
diff --git a/test/443-not-bool-inline/src/Main.java b/test/443-not-bool-inline/src/Main.java
new file mode 100644
index 0000000..3a6f3be
--- /dev/null
+++ b/test/443-not-bool-inline/src/Main.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Main {
+ public static void main(String[] args) {
+ // For some reason, dx wants != for generating if-eq.
+ if (falseField != false) {
+ System.out.println("Hello World 1");
+ }
+
+ if (trueField != false) {
+ System.out.println("Hello World 2");
+ }
+ }
+
+ static boolean falseField = false;
+ static boolean trueField = true;
+}