Various fixes related to integer negate operations.
- Emit an RSB instruction for HNeg nodes in the ARM code
generator instead of RSBS, as we do not need to update the
condition code flags in this case.
- Simply punt when trying to statically evaluate a long
unary operation, instead of aborting.
- Move a test case to the right place.
Change-Id: I35eb8dea58ed35258d4d8df77181159c3ab07b6f
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc
index 24b7c2d..f07cb30 100644
--- a/compiler/optimizing/code_generator_arm.cc
+++ b/compiler/optimizing/code_generator_arm.cc
@@ -1065,7 +1065,7 @@
switch (neg->GetResultType()) {
case Primitive::kPrimInt:
DCHECK(in.IsRegister());
- __ rsbs(out.As<Register>(), in.As<Register>(), ShifterOperand(0));
+ __ rsb(out.As<Register>(), in.As<Register>(), ShifterOperand(0));
break;
case Primitive::kPrimLong:
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index 0505510..d624ad5 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -602,7 +602,11 @@
int32_t value = Evaluate(GetInput()->AsIntConstant()->GetValue());
return new(GetBlock()->GetGraph()->GetArena()) HIntConstant(value);
} else if (GetInput()->IsLongConstant()) {
- LOG(FATAL) << "Static evaluation of long unary operations is not yet implemented.";
+ // TODO: Implement static evaluation of long unary operations.
+ //
+ // Do not exit with a fatal condition here. Instead, simply
+ // return `nullptr' to notify the caller that this instruction
+ // cannot (yet) be statically evaluated.
return nullptr;
}
return nullptr;
diff --git a/test/411-optimizing-arith/src/Main.java b/test/411-optimizing-arith/src/Main.java
index 2b3ba33..ab8a83f 100644
--- a/test/411-optimizing-arith/src/Main.java
+++ b/test/411-optimizing-arith/src/Main.java
@@ -52,8 +52,6 @@
expectEquals(36L, $opt$Mul(-12L, -3L));
expectEquals(33L, $opt$Mul(1L, 3L) * 11);
expectEquals(240518168583L, $opt$Mul(34359738369L, 7L)); // (2^35 + 1) * 7
-
- $opt$InplaceNegOne(1);
}
public static void neg() {
@@ -75,6 +73,8 @@
// Overflow occurs in this case, but no exception is thrown.
// For all integer values x, -x equals (~x)+1.''
expectEquals(-2147483648, $opt$Neg(-2147483648)); // -(2^31)
+
+ $opt$InplaceNegOne(1);
}
public static void $opt$InplaceNegOne(int a) {