summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMark Mendell <mark.p.mendell@intel.com>2015-05-05 21:34:03 -0400
committerMark Mendell <mark.p.mendell@intel.com>2015-05-11 08:44:54 -0400
commitba56d060116d6e145be348fa575314654c6b0572 (patch)
tree4ef90809f6628435a60320b8fa0fd939849e2d29 /test
parent6727a48193db2a0cf01af971cccffe1a6518c247 (diff)
downloadart-ba56d060116d6e145be348fa575314654c6b0572.tar.gz
art-ba56d060116d6e145be348fa575314654c6b0572.tar.bz2
art-ba56d060116d6e145be348fa575314654c6b0572.zip
[optimizing] Improve 32 bit long shift by 1.
Also change FOO << 1 to FOO+FOO in the instruction simplifier. This is an architecture independent simplification, which helps 'long << 1' for 32 bit architectures. Generate an add/adc for long << 1 in x86, in case something is generated after the simplifier. Add test cases for the simplification. Change-Id: I0d512331ef13cc4ccf10c80f11c370a10ed02294 Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
Diffstat (limited to 'test')
-rw-r--r--test/431-optimizing-arith-shifts/src/Main.java31
-rw-r--r--test/458-checker-instruction-simplification/src/Main.java19
2 files changed, 48 insertions, 2 deletions
diff --git a/test/431-optimizing-arith-shifts/src/Main.java b/test/431-optimizing-arith-shifts/src/Main.java
index d8667c63c5..86422bd8e7 100644
--- a/test/431-optimizing-arith-shifts/src/Main.java
+++ b/test/431-optimizing-arith-shifts/src/Main.java
@@ -52,7 +52,7 @@ public class Main {
expectEquals(Integer.MIN_VALUE, $opt$Shl(1073741824, 1)); // overflow
expectEquals(1073741824, $opt$Shl(268435456, 2));
- // othe nly 5 lower bits should be used for shifting (& 0x1f).
+ // Only the 5 lower bits should be used for shifting (& 0x1f).
expectEquals(7, $opt$Shl(7, 32)); // 32 & 0x1f = 0
expectEquals(14, $opt$Shl(7, 33)); // 33 & 0x1f = 1
expectEquals(32, $opt$Shl(1, 101)); // 101 & 0x1f = 5
@@ -97,6 +97,13 @@ public class Main {
expectEquals(Long.MIN_VALUE, $opt$Shl(7L, Long.MAX_VALUE));
expectEquals(7L, $opt$Shl(7L, Long.MIN_VALUE));
+
+ // Exercise some special cases handled by backends/simplifier.
+ expectEquals(24L, $opt$ShlConst1(12L));
+ expectEquals(0x2345678900000000L, $opt$ShlConst32(0x123456789L));
+ expectEquals(0x2490249000000000L, $opt$ShlConst33(0x12481248L));
+ expectEquals(0x4920492000000000L, $opt$ShlConst34(0x12481248L));
+ expectEquals(0x9240924000000000L, $opt$ShlConst35(0x12481248L));
}
private static void shrInt() {
@@ -277,7 +284,7 @@ public class Main {
return a >>> 2L;
}
- static int $opt$ShlConst0(int a) {
+ static int $opt$ShlConst0(int a) {
return a << 0;
}
@@ -301,5 +308,25 @@ public class Main {
return a >>> 0L;
}
+ static long $opt$ShlConst1(long a) {
+ return a << 1L;
+ }
+
+ static long $opt$ShlConst32(long a) {
+ return a << 32L;
+ }
+
+ static long $opt$ShlConst33(long a) {
+ return a << 33L;
+ }
+
+ static long $opt$ShlConst34(long a) {
+ return a << 34L;
+ }
+
+ static long $opt$ShlConst35(long a) {
+ return a << 35L;
+ }
+
}
diff --git a/test/458-checker-instruction-simplification/src/Main.java b/test/458-checker-instruction-simplification/src/Main.java
index 5d5a6b3627..efb7b83e33 100644
--- a/test/458-checker-instruction-simplification/src/Main.java
+++ b/test/458-checker-instruction-simplification/src/Main.java
@@ -223,6 +223,24 @@ public class Main {
return arg << 0;
}
+ // CHECK-START: int Main.Shl1(int) instruction_simplifier (before)
+ // CHECK-DAG: [[Arg:i\d+]] ParameterValue
+ // CHECK-DAG: [[Const1:i\d+]] IntConstant 1
+ // CHECK-DAG: [[Shl:i\d+]] Shl [ [[Arg]] [[Const1]] ]
+ // CHECK-DAG: Return [ [[Shl]] ]
+
+ // CHECK-START: int Main.Shl1(int) instruction_simplifier (after)
+ // CHECK-DAG: [[Arg:i\d+]] ParameterValue
+ // CHECK-DAG: [[Add:i\d+]] Add [ [[Arg]] [[Arg]] ]
+ // CHECK-DAG: Return [ [[Add]] ]
+
+ // CHECK-START: int Main.Shl1(int) instruction_simplifier (after)
+ // CHECK-NOT: Shl
+
+ public static int Shl1(int arg) {
+ return arg << 1;
+ }
+
// CHECK-START: long Main.Shr0(long) instruction_simplifier (before)
// CHECK-DAG: [[Arg:j\d+]] ParameterValue
// CHECK-DAG: [[Const0:i\d+]] IntConstant 0
@@ -1060,5 +1078,6 @@ public class Main {
assertDoubleEquals(Div2(150.0), 75.0);
assertFloatEquals(DivMP25(100.0f), -400.0f);
assertDoubleEquals(DivMP25(150.0), -600.0);
+ assertLongEquals(Shl1(100), 200);
}
}