summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-07-12 04:26:03 -0700
committerAndreas Gampe <agampe@google.com>2014-07-12 04:26:03 -0700
commit39c8a99a3fdd9876980502ab12ed74a27e6be369 (patch)
tree7fabbfc0cc74b734452a7153d2a95ed09576a63e
parent7aab98798ad676d7ede05b25bcff946a6550868c (diff)
downloadart-39c8a99a3fdd9876980502ab12ed74a27e6be369.tar.gz
art-39c8a99a3fdd9876980502ab12ed74a27e6be369.tar.bz2
art-39c8a99a3fdd9876980502ab12ed74a27e6be369.zip
ART: Add another special case to GenSelect for ARM64
This adds a special case for a select of two constants that have a difference of exactly one. Change-Id: I6e8bea791cb25af1b855d62e2333fd7fe6ac4e3a
-rw-r--r--compiler/dex/quick/arm64/int_arm64.cc13
-rw-r--r--test/083-compiler-regressions/src/Main.java3
2 files changed, 16 insertions, 0 deletions
diff --git a/compiler/dex/quick/arm64/int_arm64.cc b/compiler/dex/quick/arm64/int_arm64.cc
index f7aa39f4c2..abc239fede 100644
--- a/compiler/dex/quick/arm64/int_arm64.cc
+++ b/compiler/dex/quick/arm64/int_arm64.cc
@@ -168,6 +168,19 @@ void Arm64Mir2Lir::GenSelect(BasicBlock* bb, MIR* mir) {
left_op = rl_result.reg.GetReg();
right_op = zero_reg;
opcode = is_wide ? WIDE(kA64Csinv4rrrc) : kA64Csinv4rrrc;
+ } else if ((true_val + 1 == false_val) || (false_val + 1 == true_val)) {
+ // Load a constant and use CSinc. Use rl_result.
+ if (false_val + 1 == true_val) {
+ // Negate.
+ code = ArmConditionEncoding(NegateComparison(mir->meta.ccode));
+ true_val = false_val;
+ }
+
+ rl_result = EvalLoc(rl_dest, result_reg_class, true);
+ rl_result_evaled = true;
+ LoadConstantNoClobber(rl_result.reg, true_val);
+ left_op = right_op = rl_result.reg.GetReg();
+ opcode = is_wide ? WIDE(kA64Csinc4rrrc) : kA64Csinc4rrrc;
} else {
// Csel. The rest. Use rl_result and a temp.
// TODO: To minimize the constants being loaded, check whether one can be inexpensively
diff --git a/test/083-compiler-regressions/src/Main.java b/test/083-compiler-regressions/src/Main.java
index 0f7527cd45..18bc674b0a 100644
--- a/test/083-compiler-regressions/src/Main.java
+++ b/test/083-compiler-regressions/src/Main.java
@@ -9638,6 +9638,7 @@ class MirOpSelectTests {
private static int ifGezThen7Else4(int i) { return (i >= 0) ? 7 : 4; }
private static int ifGtzThen2Else9(int i) { return (i > 0) ? 2 : 9; }
private static int ifLezThen8Else0(int i) { return (i <= 0) ? 8 : 0; }
+ private static int ifGtzThen8Else9(int i) { return (i > 0) ? 8 : 9; }
private static int ifEqz(int src, int thn, int els) { return (src == 0) ? thn : els; }
private static int ifNez(int src, int thn, int els) { return (src != 0) ? thn : els; }
@@ -9714,6 +9715,8 @@ class MirOpSelectTests {
ifLez(-1, 116, 216), 116,
ifLez(0, 117, 217), 117,
ifLez(1, 118, 218), 218,
+ ifGtzThen8Else9(0), 9,
+ ifGtzThen8Else9(1), 8
};
boolean success = true;