summaryrefslogtreecommitdiffstats
path: root/test/422-type-conversion
diff options
context:
space:
mode:
authorRoland Levillain <rpl@google.com>2014-11-27 18:31:21 +0000
committerRoland Levillain <rpl@google.com>2014-11-27 18:36:14 +0000
commit6d0e483dd2e0b63e952de060738c10e2abd12ff7 (patch)
treeb396377926d2645f0df982f0b03c41149632a3de /test/422-type-conversion
parent7c97e855ceb9b45a1cc738fb144bd3312c4e09a8 (diff)
downloadart-6d0e483dd2e0b63e952de060738c10e2abd12ff7.tar.gz
art-6d0e483dd2e0b63e952de060738c10e2abd12ff7.tar.bz2
art-6d0e483dd2e0b63e952de060738c10e2abd12ff7.zip
Add support for long-to-float in the optimizing compiler.
- Add support for the long-to-float Dex instruction in the optimizing compiler. - Have art::x86_64::X86_64Assembler::cvtsi2ss work with 64-bit operands. - Generate x86, x86-64 and ARM (but not ARM64) code for long to float HTypeConversion nodes. - Add related tests to test/422-type-conversion. Change-Id: Ic983cbeb1ae2051add40bc519a8f00a6196166c9
Diffstat (limited to 'test/422-type-conversion')
-rw-r--r--test/422-type-conversion/src/Main.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/422-type-conversion/src/Main.java b/test/422-type-conversion/src/Main.java
index 44618631c1..c434db37c9 100644
--- a/test/422-type-conversion/src/Main.java
+++ b/test/422-type-conversion/src/Main.java
@@ -85,6 +85,9 @@ public class Main {
// Generate, compile and check long-to-int Dex instructions.
longToInt();
+ // Generate, compile and check long-to-float Dex instructions.
+ longToFloat();
+
// Generate, compile and check long-to-double Dex instructions.
longToDouble();
@@ -270,6 +273,26 @@ public class Main {
assertLongEquals(-1, $opt$IntToLong($opt$LongToInt(-4294967297L))); // -(2^32 + 1)
}
+ private static void longToFloat() {
+ assertFloatEquals(1F, $opt$LongToFloat(1L));
+ assertFloatEquals(0F, $opt$LongToFloat(0L));
+ assertFloatEquals(-1F, $opt$LongToFloat(-1L));
+ assertFloatEquals(51F, $opt$LongToFloat(51L));
+ assertFloatEquals(-51F, $opt$LongToFloat(-51L));
+ assertFloatEquals(2147483647F, $opt$LongToFloat(2147483647L)); // 2^31 - 1
+ assertFloatEquals(-2147483647F, $opt$LongToFloat(-2147483647L)); // -(2^31 - 1)
+ assertFloatEquals(-2147483648F, $opt$LongToFloat(-2147483648L)); // -(2^31)
+ assertFloatEquals(2147483648F, $opt$LongToFloat(2147483648L)); // (2^31)
+ assertFloatEquals(-2147483649F, $opt$LongToFloat(-2147483649L)); // -(2^31 + 1)
+ assertFloatEquals(4294967296F, $opt$LongToFloat(4294967296L)); // (2^32)
+ assertFloatEquals(-4294967296F, $opt$LongToFloat(-4294967296L)); // -(2^32)
+ assertFloatEquals(140739635871745F, $opt$LongToFloat(140739635871745L)); // 1 + 2^15 + 2^31 + 2^47
+ assertFloatEquals(-140739635871745F, $opt$LongToFloat(-140739635871745L)); // -(1 + 2^15 + 2^31 + 2^47)
+ assertFloatEquals(9223372036854775807F, $opt$LongToFloat(9223372036854775807L)); // 2^63 - 1
+ assertFloatEquals(-9223372036854775807F, $opt$LongToFloat(-9223372036854775807L)); // -(2^63 - 1)
+ assertFloatEquals(-9223372036854775808F, $opt$LongToFloat(-9223372036854775808L)); // -(2^63)
+ }
+
private static void longToDouble() {
assertDoubleEquals(1D, $opt$LongToDouble(1L));
assertDoubleEquals(0D, $opt$LongToDouble(0L));
@@ -439,6 +462,9 @@ public class Main {
static int $opt$LongToInt(long a){ return (int)a; }
static int $opt$LongLiteralToInt(){ return (int)42L; }
+ // This method produces a long-to-float Dex instruction.
+ static float $opt$LongToFloat(long a){ return (float)a; }
+
// This method produces a long-to-double Dex instruction.
static double $opt$LongToDouble(long a){ return (double)a; }