changeset 16934:fc33fd65fbe5

[SPARC] new Unittests for IntegerBits, Switch (with byte, short, char values) and high float register pressure, sign extending short from heap
author Stefan Anzinger <stefan.anzinger@gmail.com>
date Mon, 25 Aug 2014 10:24:08 -0700
parents f011bf910f34
children c40b258d83ab
files graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/IntegerBits.java graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigMixedParams04.java graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/SignExtendShort.java graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Switch02.java
diffstat 4 files changed, 636 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/IntegerBits.java	Mon Aug 25 10:21:37 2014 -0700
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/IntegerBits.java	Mon Aug 25 10:24:08 2014 -0700
@@ -103,4 +103,60 @@
     public void run10() {
         runTest("test4", 0xffffffff);
     }
+
+    @Test
+    public void run11() {
+        runTest("test2", 0xFFFFFFFF);
+    }
+
+    @Test
+    public void run12() {
+        runTest("test2", 0x7FFFFFFF);
+    }
+
+    @Test
+    public void run17() {
+        runTest("test2", 0x80000000);
+    }
+
+    @Test
+    public void run18() {
+        runTest("test2", 0x40000000);
+    }
+
+    @Test
+    public void run13() {
+        runTest("test3", 0x7FFFFFFF);
+    }
+
+    @Test
+    public void run14() {
+        runTest("test3", 0xFFFFFFFF);
+    }
+
+    @Test
+    public void run15() {
+        runTest("test3", 0x80000000);
+    }
+
+    @Test
+    public void run16() {
+        runTest("test3", 0x40000000);
+    }
+
+    @Test
+    public void run19() {
+        runTest("test4", 0x80000000);
+    }
+
+    @Test
+    public void run20() {
+        runTest("test4", 0x40000000);
+    }
+
+    @Test
+    public void run21() {
+        runTest("test4", 0x00000001);
+    }
+
 }
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigMixedParams04.java	Mon Aug 25 10:21:37 2014 -0700
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigMixedParams04.java	Mon Aug 25 10:24:08 2014 -0700
@@ -27,6 +27,7 @@
 
 import org.junit.*;
 
+import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.jtt.*;
 
 /**
@@ -53,6 +54,212 @@
         return 42;
     }
 
+    /**
+     * Test SPARC mixed params with double/single float register overlapping
+     *
+     * @param f1
+     * @param d2
+     * @param f3
+     * @return Must always return the argument d2
+     */
+    @SuppressWarnings("all")
+    public static double test2(int i1, float f1, double d2, float f3,
+    // @formatter:off
+                    double ad1 ,
+                    double ad2 ,
+                    double ad3 ,
+                    double ad4 ,
+                    double ad5 ,
+                    double ad6 ,
+                    double ad7 ,
+                    double ad8 ,
+                    double ad9 ,
+                    double ad10,
+                    double ad11,
+                    double ad12,
+                    double ad13,
+                    double ad14,
+                    double ad15,
+                    double ad16,
+                    float  af1 ,
+                    float  af2 ,
+                    float  af3 ,
+                    float  af4 ,
+                    float  af5 ,
+                    float  af6 ,
+                    float  af7 ,
+                    float  af8 ,
+                    float  af9 ,
+                    float  af10,
+                    float  af11,
+                    float  af12,
+                    float  af13,
+                    float  af14,
+                    float  af15,
+                    float  af16
+    // @formatter:on
+    ) {
+
+        // now do something with the locals to make sure the locals don't get optimized away.
+        for (int i = 0; i < i1; i++) {
+            af1 += f1;
+            af2 += f1;
+            af3 += f1;
+            af4 += f1;
+            af5 += f1;
+            af6 += f1;
+            af7 += f1;
+            af8 += f1;
+            af9 += f1;
+            af10 += f1;
+            af11 += f1;
+            af12 += f1;
+            af13 += f1;
+            af14 += f1;
+            af15 += f1;
+            af16 += f1;
+            ad1 += f1;
+            ad2 += f1;
+            ad3 += f1;
+            ad4 += f1;
+            ad5 += f1;
+            ad6 += f1;
+            ad7 += f1;
+            ad8 += f1;
+            ad9 += f1;
+            ad10 += f1;
+            ad11 += f1;
+            ad12 += f1;
+            ad13 += f1;
+            ad14 += f1;
+            ad15 += f1;
+            ad16 += f1;
+        }
+        // @formatter:off
+        boolean orderFloat =
+                        af1  < af2  &&
+                        af2  < af3  &&
+                        af3  < af4  &&
+                        af4  < af5  &&
+                        af5  < af6  &&
+                        af6  < af7  &&
+                        af7  < af8  &&
+                        af8  < af9  &&
+                        af9  < af10 &&
+                        af10 < af11 &&
+                        af11 < af12 &&
+                        af12 < af13 &&
+                        af13 < af14 &&
+                        af14 < af15 &&
+                        af15 < af16;
+        boolean orderDouble =
+                        ad1  < ad2  &&
+                        ad2  < ad3  &&
+                        ad3  < ad4  &&
+                        ad4  < ad5  &&
+                        ad5  < ad6  &&
+                        ad6  < ad7  &&
+                        ad7  < ad8  &&
+                        ad8  < ad9  &&
+                        ad9  < ad10 &&
+                        ad10 < ad11 &&
+                        ad11 < ad12 &&
+                        ad12 < ad13 &&
+                        ad13 < ad14 &&
+                        ad14 < ad15 &&
+                        ad15 < ad16;
+        // @formatter:on
+        if (orderDouble && orderFloat) {
+            return f1 + d2 + f3; // this should not be destroyed
+        }
+        Assert.fail();
+        return 0.0;
+    }
+
+    /**
+     * Test SPARC mixed params with double/single float register overlapping
+     *
+     * @param f1
+     * @param d2
+     * @param f3
+     * @return Must always return the argument d2
+     */
+    @SuppressWarnings("all")
+    public static double test3(boolean f, int idx,
+    // @formatter:off
+                    double ad1 ,
+                    double ad2 ,
+                    double ad3 ,
+                    double ad4 ,
+                    double ad5 ,
+                    double ad6 ,
+                    double ad7 ,
+                    double ad8 ,
+                    double ad9 ,
+                    double ad10,
+                    double ad11,
+                    double ad12,
+                    double ad13,
+                    double ad14,
+                    double ad15,
+                    double ad16,
+                    float  af1 ,
+                    float  af2 ,
+                    float  af3 ,
+                    float  af4 ,
+                    float  af5 ,
+                    float  af6 ,
+                    float  af7 ,
+                    float  af8 ,
+                    float  af9 ,
+                    float  af10,
+                    float  af11,
+                    float  af12,
+                    float  af13,
+                    float  af14,
+                    float  af15,
+                    float  af16
+    ) {
+        switch(f ? idx + 16 : idx) {
+            case 1 : return ad1 ;
+            case 2 : return ad2 ;
+            case 3 : return ad3 ;
+            case 4 : return ad4 ;
+            case 5 : return ad5 ;
+            case 6 : return ad6 ;
+            case 7 : return ad7 ;
+            case 8 : return ad8 ;
+            case 9 : return ad9 ;
+            case 10: return ad10;
+            case 11: return ad11;
+            case 12: return ad12;
+            case 13: return ad13;
+            case 14: return ad14;
+            case 15: return ad15;
+            case 16: return ad16;
+            case 1  + 16: return af1 ;
+            case 2  + 16: return af2 ;
+            case 3  + 16: return af3 ;
+            case 4  + 16: return af4 ;
+            case 5  + 16: return af5 ;
+            case 6  + 16: return af6 ;
+            case 7  + 16: return af7 ;
+            case 8  + 16: return af8 ;
+            case 9  + 16: return af9 ;
+            case 10 + 16: return af10;
+            case 11 + 16: return af11;
+            case 12 + 16: return af12;
+            case 13 + 16: return af13;
+            case 14 + 16: return af14;
+            case 15 + 16: return af15;
+            case 16 + 16: return af16;
+        }
+        Assert.fail(); // should not reach here
+        return 0;
+
+    }
+    // @formatter:on
+
     @Test
     public void run0() throws Throwable {
         runTest("test", 0, -1, -1, -1, -1, 1d, 2d, true, false, (byte) -128, (short) -0x7FFF, (char) 0xFFFF, -0x7FFFFFF);
@@ -82,4 +289,86 @@
     public void run5() throws Throwable {
         runTest("test", 5, -1, -1, -1, -1, 1d, 2d, true, false, (byte) -128, (short) -0x7FFF, (char) 0xFFFF, -0x7FFFFFF);
     }
+
+    @Test
+    public void run6() throws Throwable {
+        // @formatter:off
+        runTest("test2", 20, 1.0f, -3.2912948246387967943231233d, 3.0f,
+                        1d,
+                        2d,
+                        3d,
+                        4d,
+                        5d,
+                        6d,
+                        7d,
+                        8d,
+                        9d,
+                        10d,
+                        11d,
+                        12d,
+                        13d,
+                        14d,
+                        15d,
+                        16d,
+                        1f,
+                        2f,
+                        3f,
+                        4f,
+                        5f,
+                        6f,
+                        7f,
+                        8f,
+                        9f,
+                        10f,
+                        11f,
+                        12f,
+                        13f,
+                        14f,
+                        15f,
+                        16f
+                        );
+        // @formatter:on
+    }
+
+    @Test
+    public void run7() throws Throwable {
+        // @formatter:off
+        for(int i =0; i<32*2; i++)
+        runTest("test3", i%2==0, i/2,
+                        1d,
+                        2d,
+                        3d,
+                        4d,
+                        5d,
+                        6d,
+                        7d,
+                        8d,
+                        9d,
+                        10d,
+                        11d,
+                        12d,
+                        13d,
+                        14d,
+                        15d,
+                        16d,
+                        1f,
+                        2f,
+                        3f,
+                        4f,
+                        5f,
+                        6f,
+                        7f,
+                        8f,
+                        9f,
+                        10f,
+                        11f,
+                        12f,
+                        13f,
+                        14f,
+                        15f,
+                        16f
+                        );
+        // @formatter:on
+    }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/SignExtendShort.java	Mon Aug 25 10:24:08 2014 -0700
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.jtt.optimize;
+
+import org.junit.*;
+
+import com.oracle.graal.jtt.*;
+
+/*
+ */
+public class SignExtendShort extends JTTTest {
+
+    public static int val;
+
+    public static boolean test(short[] b) {
+        val = b[2];
+        int x = 0;
+        return val >= x;
+    }
+
+    @Test
+    public void run0() throws Throwable {
+        runTest("test", new short[]{0, 0, 0});
+    }
+
+    @Test
+    public void run1() throws Throwable {
+        runTest("test", new short[]{0, 0, 1});
+    }
+
+    @Test
+    public void run2() throws Throwable {
+        runTest("test", new short[]{0, 0, -1});
+    }
+
+    @Test
+    public void run3() throws Throwable {
+        runTest("test", new short[]{0, 0, Short.MAX_VALUE});
+    }
+
+    @Test
+    public void run4() throws Throwable {
+        runTest("test", new short[]{0, 0, Short.MIN_VALUE});
+    }
+}
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Switch02.java	Mon Aug 25 10:21:37 2014 -0700
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Switch02.java	Mon Aug 25 10:24:08 2014 -0700
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import java.util.*;
+
 import org.junit.*;
 
 import com.oracle.graal.jtt.*;
@@ -30,6 +32,9 @@
  * Tests optimization of switches.
  */
 public class Switch02 extends JTTTest {
+    private static char staticCharVal = 0;
+    private static short staticShortVal = 0;
+    private static byte staticByteVal = 0;
 
     public static int test(int arg) {
         switch (arg) {
@@ -40,6 +45,168 @@
         }
     }
 
+    public static int test2char(char arg) {
+        int result = 392123;
+        Object x = null;
+        char val = staticCharVal != 0 ? staticCharVal : arg;
+        switch (val) {
+            case (char) 0xFFFF:
+                result = 23212 / val;
+                break;
+            case (char) 0xFFFF - 3:
+                result = 932991439 / val;
+                break;
+            case (char) 0xFFFF - 6:
+                result = 47329561 / val;
+                break;
+            case (char) 0xFFFF - 9:
+                result = 1950976984 / val;
+                break;
+            case (char) 0xFFFF - 10:
+                result = 97105581 / val;
+                switch (result) {
+                    case 1:
+                        result = 321;
+                        break;
+                    default:
+                        result = 2391;
+                        break;
+                }
+                break;
+            case (char) 0xFFFF - 12:
+                result = 99757362 / val;
+                break;
+            case (char) 0xFFFF - 15:
+                result = 912573 / val;
+                x = new LinkedList<>();
+                break;
+            case (char) 0xFFFF - 18:
+                x = new HashSet<>();
+                result = 876765 / val;
+                break;
+            case (char) 0xFFFF - 19:
+                result = 75442917 / val;
+                break;
+            case (char) 0xFFFF - 21:
+                result = 858112498 / val;
+                x = new Hashtable<>();
+                break;
+            default:
+                result = 34324341 / val;
+        }
+        result = result + (x == null ? 0 : x.hashCode());
+        return result;
+    }
+
+    public static int test2short(short arg) {
+        int result = 392123;
+        Object x = null;
+        short val = staticShortVal != 0 ? staticShortVal : arg;
+        switch (val) {
+            case (short) -0x7FFF:
+                result = 23212 / val;
+                break;
+            case (short) -0x7FFF + 3:
+                result = 932991439 / val;
+                break;
+            case (short) -0x7FFF + 6:
+                result = 47329561 / val;
+                break;
+            case (short) -0x7FFF + 9:
+                result = 1950976984 / val;
+                break;
+            case (short) -0x7FFF + 10:
+                result = 97105581 / val;
+                switch (result) {
+                    case 1:
+                        result = 321;
+                        break;
+                    default:
+                        result = 2391;
+                        break;
+                }
+                break;
+            case (short) -0x7FFF + 12:
+                result = 99757362 / val;
+                break;
+            case (short) -0x7FFF + 15:
+                result = 912573 / val;
+                x = new LinkedList<>();
+                break;
+            case (short) -0x7FFF + 18:
+                x = new HashSet<>();
+                result = 876765 / val;
+                break;
+            case (short) -0x7FFF + 19:
+                result = 75442917 / val;
+                break;
+            case (short) -0x7FFF + 21:
+                result = 858112498 / val;
+                x = new Hashtable<>();
+                break;
+            default:
+                result = 34324341 / val;
+        }
+        result = result + (x == null ? 0 : x.hashCode());
+        return result;
+    }
+
+    public static int test2byte(byte arg) {
+        int result = 392123;
+        Object x = null;
+        byte val = staticByteVal != 0 ? staticByteVal : arg;
+        switch (val) {
+            case (byte) -0x7F:
+                result = 23212 / val;
+                break;
+            case (byte) -0x7F + 3:
+                result = 932991439 / val;
+                break;
+            case (byte) -0x7F + 6:
+                result = 47329561 / val;
+                break;
+            case (byte) -0x7F + 9:
+                result = 1950976984 / val;
+                break;
+            case (byte) -0x7F + 10:
+                result = 97105581 / val;
+                switch (result) {
+                    case 1:
+                        result = 321;
+                        break;
+                    default:
+                        result = 2391;
+                        break;
+                }
+                break;
+            case (byte) -0x7F + 12:
+                result = 99757362 / val;
+                break;
+            case (byte) -0x7F + 15:
+                result = 912573 / val;
+                x = new LinkedList<>();
+                break;
+            case (byte) -0x7F + 18:
+                x = new HashSet<>();
+                result = 876765 / val;
+                break;
+            case (byte) -0x7F + 19:
+                result = 75442917 / val;
+                break;
+            case (byte) -0x7F + 20:
+                result = 856261268 / val;
+                break;
+            case (byte) -0x7F + 21:
+                result = 858112498 / val;
+                x = new Hashtable<>();
+                break;
+            default:
+                result = 34324341 / val;
+        }
+        result = result + (x == null ? 0 : x.hashCode());
+        return result;
+    }
+
     @Test
     public void run0() throws Throwable {
         runTest("test", 0);
@@ -50,4 +217,63 @@
         runTest("test", 1);
     }
 
+    @Test
+    public void run2() throws Throwable {
+        runTest("test2char", (char) (0x0));
+        runTest("test2char", (char) (0xFFFF));
+        runTest("test2char", (char) (0xFFFF - 21)); // miss
+        runTest("test2char", (char) (0xFFFF - 22)); // hit
+        runTest("test2char", (char) (0xFFFF - 23)); // miss (out of bound)
+
+        staticCharVal = (char) 0xFFFF;
+        runTest("test2char", (char) 0);
+        staticCharVal = (char) (0xFFFF - 21);
+        runTest("test2char", (char) 0xFFFF);
+        staticCharVal = (char) (0xFFFF - 22);
+        runTest("test2char", (char) 0xFFFF);
+        staticCharVal = (char) (0xFFFF - 23);
+        runTest("test2char", (char) 0xFFFF);
+    }
+
+    @Test
+    public void run3() throws Throwable {
+        runTest("test2short", (short) 0x0);
+        runTest("test2short", (short) -0x7FFF);
+        runTest("test2short", (short) (-0x7FFF + 21)); // Miss
+        runTest("test2short", (short) (-0x7FFF + 22)); // hit
+        runTest("test2short", (short) (-0x7FFF + 23)); // miss (out of bound)
+        runTest("test2short", (short) 0x7FFF);         // miss (out of bound)
+
+        staticShortVal = (short) -0x7FFF;
+        runTest("test2short", (short) 0);
+        staticShortVal = (short) (-0x7FFF + 21);
+        runTest("test2short", (short) 0);
+        staticShortVal = (short) (-0x7FFF + 22);
+        runTest("test2short", (short) 0);
+        staticShortVal = (short) (-0x7FFF + 23);
+        runTest("test2short", (short) 0);
+        staticShortVal = (short) 0x7FFF;
+        runTest("test2short", (short) 0);
+    }
+
+    @Test
+    public void run4() throws Throwable {
+        runTest("test2byte", (byte) 0);
+        runTest("test2byte", (byte) -0x7F);
+        runTest("test2byte", (byte) (-0x7F + 21)); // Miss
+        runTest("test2byte", (byte) (-0x7F + 22)); // hit
+        runTest("test2byte", (byte) (-0x7F + 23)); // miss (out of bound)
+        runTest("test2byte", (byte) 0x7F);         // miss (out of bound)
+
+        staticByteVal = (byte) -0x7F;
+        runTest("test2short", (short) 0);
+        staticByteVal = (byte) (-0x7F + 21);
+        runTest("test2short", (short) 0);
+        staticByteVal = (byte) (-0x7F + 22);
+        runTest("test2short", (short) 0);
+        staticByteVal = (byte) (-0x7F + 23);
+        runTest("test2short", (short) 0);
+        staticByteVal = (byte) 0x7F;
+        runTest("test2short", (short) 0);
+    }
 }