diff options
author | Mark Mendell <mark.p.mendell@intel.com> | 2015-05-05 21:34:03 -0400 |
---|---|---|
committer | Mark Mendell <mark.p.mendell@intel.com> | 2015-05-11 08:44:54 -0400 |
commit | ba56d060116d6e145be348fa575314654c6b0572 (patch) | |
tree | 4ef90809f6628435a60320b8fa0fd939849e2d29 /test/431-optimizing-arith-shifts | |
parent | 6727a48193db2a0cf01af971cccffe1a6518c247 (diff) | |
download | art-ba56d060116d6e145be348fa575314654c6b0572.zip art-ba56d060116d6e145be348fa575314654c6b0572.tar.gz art-ba56d060116d6e145be348fa575314654c6b0572.tar.bz2 |
[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/431-optimizing-arith-shifts')
-rw-r--r-- | test/431-optimizing-arith-shifts/src/Main.java | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/test/431-optimizing-arith-shifts/src/Main.java b/test/431-optimizing-arith-shifts/src/Main.java index d8667c6..86422bd 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; + } + } |