changeset 12600:80bbaf87fc89

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 25 Oct 2013 11:42:44 +0200
parents faded4a83d63 (current diff) a5a4a0bcd863 (diff)
children 48bc171026d1
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java
diffstat 68 files changed, 3335 insertions(+), 205 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java	Fri Oct 25 11:42:44 2013 +0200
@@ -223,12 +223,46 @@
         }
     }
 
+    public static final String getArgTypeBitwiseLogical(Value src) {
+        String length = getArgType(src);
+        String prefix = "b" + (length.endsWith("64") ? "64" : "32");
+        return prefix;
+    }
+
     public void emitCompare(Value src0, Value src1, String condition, boolean unordered, boolean isUnsignedCompare) {
         String prefix = "cmp_" + condition + (unordered ? "u" : "") + "_b1_" + (isUnsignedCompare ? getArgTypeForceUnsigned(src1) : getArgType(src1));
         String comment = (isConstant(src1) && (src1.getKind() == Kind.Object) && (asConstant(src1).asObject() == null) ? " // null test " : "");
         emitString(prefix + " $c0, " + mapRegOrConstToString(src0) + ", " + mapRegOrConstToString(src1) + ";" + comment);
     }
 
+    /**
+     * I2S requires special handling because Graal passes an int for the destination operand instead
+     * of a short.
+     */
+    public void emitConvertIntToShort(Value dest, Value src) {
+        emitString("cvt_s16_s32 " + HSAIL.mapRegister(dest) + ", " + HSAIL.mapRegister(src) + ";");
+    }
+
+    /**
+     * I2C requires special handling because Graal passes an int for the destination operand instead
+     * of a char.
+     */
+    public void emitConvertIntToChar(Value dest, Value src) {
+        emitString("cvt_u16_s32 " + HSAIL.mapRegister(dest) + ", " + HSAIL.mapRegister(src) + ";");
+    }
+
+    /**
+     * I2B requires special handling because Graal passes an int for the destination operand instead
+     * of a byte.
+     */
+    public void emitConvertIntToByte(Value dest, Value src) {
+        emitString("cvt_s8_s32 " + HSAIL.mapRegister(dest) + ", " + HSAIL.mapRegister(src) + ";");
+    }
+
+    /**
+     * Generic handler for all other conversions.
+     * 
+     */
     public void emitConvert(Value dest, Value src) {
         String prefix = (getArgType(dest).equals("f32") && getArgType(src).equals("f64")) ? "cvt_near_" : "cvt_";
         emitString(prefix + getArgType(dest) + "_" + getArgType(src) + " " + HSAIL.mapRegister(dest) + ", " + HSAIL.mapRegister(src) + ";");
@@ -296,6 +330,17 @@
     }
 
     /**
+     * 
+     * Emit code to generate a 32-bit or 64-bit bitwise logical operation. Used to generate bitwise
+     * AND, OR and XOR.
+     */
+    public final void emitBitwiseLogical(String mnemonic, Value dest, Value src0, Value src1) {
+        // Bitwise ops don't use a control register so the fourth arg is empty.
+        String prefix = getArgTypeBitwiseLogical(dest);
+        emit(mnemonic + "_" + prefix, dest, "", src0, src1);
+    }
+
+    /**
      * Emit code to build a 64-bit pointer from a compressed-oop and the associated base and shift.
      * We only emit this if base and shift are not both zero.
      */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFF.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two boolean values which are both false.
+ */
+public class BooleanBitwiseAndTestFF extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = false;
+            in2[i] = false;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFT.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two booleans. First input is false and second input is true.
+ */
+public class BooleanBitwiseAndTestFT extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = false;
+            in2[i] = true;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTF.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two booleans. First input is true and second is false.
+ */
+public class BooleanBitwiseAndTestTF extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = true;
+            in2[i] = false;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTT.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two booleans. Both inputs are true.
+ */
+public class BooleanBitwiseAndTestTT extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = true;
+            in2[i] = true;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFF.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two booleans. Both inputs are false.
+ */
+public class BooleanBitwiseOrTestFF extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] | inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = false;
+            in2[i] = false;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFT.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two booleans. First input is false. Second input is true.
+ */
+public class BooleanBitwiseOrTestFT extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] | inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = false;
+            in2[i] = true;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTF.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two booleans. First input is true. Second input is false.
+ */
+public class BooleanBitwiseOrTestTF extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] | inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = true;
+            in2[i] = false;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTT.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two booleans. Both inputs are true.
+ */
+public class BooleanBitwiseOrTestTT extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] | inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = true;
+            in2[i] = true;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFF.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two booleans. Both inputs are false.
+ */
+public class BooleanBitwiseXorTestFF extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = false;
+            in2[i] = false;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFT.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two booleans. First input is false. Second input is true.
+ */
+public class BooleanBitwiseXorTestFT extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = false;
+            in2[i] = true;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTF.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two booelans. First input is true. Second input is false.
+ */
+public class BooleanBitwiseXorTestTF extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = true;
+            in2[i] = false;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTT.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two booleans. Both inputs are true.
+ */
+public class BooleanBitwiseXorTestTT extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected boolean[] outArray = new boolean[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
+        out[gid] = (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(boolean[] in, boolean[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = true;
+            in2[i] = true;
+            outArray[i] = false;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        boolean[] inArray = new boolean[num];
+        boolean[] inArray2 = new boolean[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndCastTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two bytes and casts the result to a byte.
+ */
+public class ByteBitwiseAndCastTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected byte[] outArray1 = new byte[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(byte[] out1, byte[] ina, byte[] inb, int gid) {
+        out1[gid] = (byte) (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(byte[] in, byte[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (byte) (i + i);
+            in2[i] = (byte) (i * i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        byte[] inArray = new byte[num];
+        byte[] inArray2 = new byte[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two bytes.
+ */
+public class ByteBitwiseAndTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray1 = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out1, byte[] ina, byte[] inb, int gid) {
+        out1[gid] = (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(byte[] in, byte[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (byte) (i + i);
+            in2[i] = (byte) (i * i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        byte[] inArray = new byte[num];
+        byte[] inArray2 = new byte[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrCastTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two bytes and casts the result to a byte.
+ */
+public class ByteBitwiseOrCastTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected byte[] outArray1 = new byte[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(byte[] out1, byte[] ina, byte[] inb, int gid) {
+        out1[gid] = (byte) (ina[gid] | inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(byte[] in, byte[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (byte) (i * 2);
+            in2[i] = (byte) (i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        byte[] inArray = new byte[num];
+        byte[] inArray2 = new byte[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two bytes.
+ */
+public class ByteBitwiseOrTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray1 = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out1, byte[] ina, byte[] inb, int gid) {
+        out1[gid] = (ina[gid] | inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(byte[] in, byte[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (byte) (i * 2);
+            in2[i] = (byte) (i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        byte[] inArray = new byte[num];
+        byte[] inArray2 = new byte[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorCastTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two bytes and casts the result to a byte.
+ */
+public class ByteBitwiseXorCastTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected byte[] outArray1 = new byte[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(byte[] out1, byte[] ina, byte[] inb, int gid) {
+        out1[gid] = (byte) (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(byte[] in, byte[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (byte) (i);
+            in2[i] = (byte) (i * i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        byte[] inArray = new byte[num];
+        byte[] inArray2 = new byte[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two bytes.
+ */
+public class ByteBitwiseXorTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray1 = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out1, byte[] ina, byte[] inb, int gid) {
+        out1[gid] = (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(byte[] in, byte[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (byte) (i);
+            in2[i] = (byte) (i * i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        byte[] inArray = new byte[num];
+        byte[] inArray2 = new byte[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndCastTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two chars and casts result to a char.
+ */
+public class CharBitwiseAndCastTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected char[] outArray1 = new char[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(char[] out1, char[] ina, char[] inb, int gid) {
+        out1[gid] = (char) (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(char[] in, char[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (char) (i + 65);
+            in2[i] = (char) (i + 97);
+            outArray1[i] = (char) 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        char[] inArray = new char[num];
+        char[] inArray2 = new char[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two chars.
+ */
+public class CharBitwiseAndTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray1 = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out1, char[] ina, char[] inb, int gid) {
+        out1[gid] = (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(char[] in, char[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (char) (i + 65);
+            in2[i] = (char) (i + 97);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        char[] inArray = new char[num];
+        char[] inArray2 = new char[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrCastTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two chars and casts the result to a char.
+ */
+public class CharBitwiseOrCastTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected char[] outArray1 = new char[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(char[] out1, char[] ina, char[] inb, int gid) {
+        out1[gid] = (char) (ina[gid] | inb[gid]);
+
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(char[] in, char[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (char) (i + 65);
+            in2[i] = (char) (i + 97);
+            outArray1[i] = (char) 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        char[] inArray = new char[num];
+        char[] inArray2 = new char[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two chars.
+ */
+public class CharBitwiseOrTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray1 = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out1, char[] ina, char[] inb, int gid) {
+        out1[gid] = (ina[gid] | inb[gid]);
+
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(char[] in, char[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (char) (i + 65);
+            in2[i] = (char) (i + 97);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        char[] inArray = new char[num];
+        char[] inArray2 = new char[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorCastTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two chars and casts the result to a char.
+ */
+public class CharBitwiseXorCastTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected char[] outArray1 = new char[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(char[] out1, char[] ina, char[] inb, int gid) {
+        out1[gid] = (char) (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(char[] in, char[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (char) (i + 65);
+            in2[i] = (char) (i + 97);
+            outArray1[i] = (char) 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        char[] inArray = new char[num];
+        char[] inArray2 = new char[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two chars.
+ */
+public class CharBitwiseXorTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray1 = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out1, char[] ina, char[] inb, int gid) {
+        out1[gid] = (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(char[] in, char[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (char) (i + 65);
+            in2[i] = (char) (i + 97);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        char[] inArray = new char[num];
+        char[] inArray2 = new char[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleLongConvertTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import java.util.*;
+import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Tests double to long conversion.
+ */
+public class DoubleLongConvertTest extends GraalKernelTester {
+
+    static final int size = 128;
+    static final double[] inputDouble = new double[size];
+    static final long[] inputLong = new long[size];
+    @Result static final double[] outputDouble = new double[size];
+    @Result static final long[] outputLong = new long[size];
+    static double[] seedDouble = new double[size];
+    {
+        for (int i = 0; i < seedDouble.length; i++) {
+            seedDouble[i] = (int) Math.random();
+        }
+    }
+    static long[] seedLong = new long[size];
+    {
+        for (int i = 0; i < seedLong.length; i++) {
+            seedLong[i] = (long) Math.random();
+        }
+    }
+
+    public static void run(double[] inDouble, long[] inLong, double[] outDouble, long[] outLong, int gid) {
+        outDouble[gid] = inLong[gid];
+        outLong[gid] = (long) inDouble[gid];
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seedLong, 0, inputLong, 0, seedLong.length);
+        Arrays.fill(outputLong, 0);
+        System.arraycopy(seedDouble, 0, inputDouble, 0, seedDouble.length);
+        Arrays.fill(outputDouble, 0);
+        dispatchMethodKernel(64, inputDouble, inputLong, outputDouble, outputLong);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatConvertTest.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatConvertTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatDoubleConvertTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import java.util.*;
+import com.oracle.graal.compiler.hsail.test.infra.*;
+
+/**
+ * Tests float to double conversion.
+ */
+public class FloatDoubleConvertTest extends GraalKernelTester {
+
+    static final int size = 128;
+    static final float[] inputFloat = new float[size];
+    static final double[] inputDouble = new double[size];
+    @Result static final float[] outputFloat = new float[size];
+    @Result static final double[] outputDouble = new double[size];
+    static float[] seedFloat = new float[size];
+    {
+        for (int i = 0; i < seedFloat.length; i++) {
+            seedFloat[i] = (float) Math.random();
+        }
+    }
+    static double[] seedDouble = new double[size];
+    {
+        for (int i = 0; i < seedDouble.length; i++) {
+            seedDouble[i] = Math.random();
+        }
+    }
+
+    public static void run(float[] inFloat, double[] inDouble, float[] outFloat, double[] outDouble, int gid) {
+        outFloat[gid] = (float) inDouble[gid];
+        outDouble[gid] = inFloat[gid];
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seedDouble, 0, inputDouble, 0, seedDouble.length);
+        Arrays.fill(outputDouble, 0);
+        System.arraycopy(seedFloat, 0, inputFloat, 0, seedFloat.length);
+        Arrays.fill(outputFloat, 0);
+        dispatchMethodKernel(64, inputFloat, inputDouble, outputFloat, outputDouble);
+    }
+
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatLongConvertTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import java.util.*;
+import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Tests float to long conversion.
+ */
+public class FloatLongConvertTest extends GraalKernelTester {
+
+    static final int size = 128;
+    static final float[] inputFloat = new float[size];
+    static final long[] inputLong = new long[size];
+    @Result static final float[] outputFloat = new float[size];
+    @Result static final long[] outputLong = new long[size];
+    static float[] seedFloat = new float[size];
+    {
+        for (int i = 0; i < seedFloat.length; i++) {
+            seedFloat[i] = (float) Math.random();
+        }
+    }
+    static long[] seedLong = new long[size];
+    {
+        for (int i = 0; i < seedLong.length; i++) {
+            seedLong[i] = (long) Math.random();
+        }
+    }
+
+    public static void run(float[] inFloat, long[] inLong, float[] outFloat, long[] outLong, int gid) {
+        outFloat[gid] = inLong[gid];
+        outLong[gid] = (long) inFloat[gid];
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seedLong, 0, inputLong, 0, seedLong.length);
+        Arrays.fill(outputLong, 0);
+        System.arraycopy(seedFloat, 0, inputFloat, 0, seedFloat.length);
+        Arrays.fill(outputFloat, 0);
+        dispatchMethodKernel(64, inputFloat, inputLong, outputFloat, outputLong);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseAndTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two ints.
+ */
+public class IntBitwiseAndTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out, int[] ina, int[] inb, int gid) {
+        out[gid] = (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(int[] in, int[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = i + i;
+            in2[i] = i * i;
+            outArray[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        int[] inArray = new int[num];
+        int[] inArray2 = new int[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseOrTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two ints.
+ */
+public class IntBitwiseOrTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out, int[] ina, int[] inb, int gid) {
+        out[gid] = (ina[gid] | inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(int[] in, int[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = i + 1;
+            in2[i] = i * i;
+            outArray[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        int[] inArray = new int[num];
+        int[] inArray2 = new int[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseXorTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two ints.
+ */
+public class IntBitwiseXorTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out, int[] ina, int[] inb, int gid) {
+        out[gid] = (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(int[] in, int[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = i;
+            in2[i] = i * i;
+            outArray[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        int[] inArray = new int[num];
+        int[] inArray2 = new int[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntByteConvertTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import java.util.*;
+import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Tests integer to byte conversion.
+ */
+public class IntByteConvertTest extends GraalKernelTester {
+
+    static final int size = 128;
+    static final int[] inputInt = new int[size];
+    static final byte[] inputByte = new byte[size];
+    @Result static final int[] outputInt = new int[size];
+    @Result static final byte[] outputByte = new byte[size];
+    static int[] seedInt = new int[size];
+    {
+        for (int i = 0; i < seedInt.length; i++) {
+            seedInt[i] = (int) Math.random();
+        }
+    }
+    static byte[] seedByte = new byte[size];
+    {
+        for (int i = 0; i < seedByte.length; i++) {
+            seedByte[i] = (byte) Math.random();
+        }
+    }
+
+    public static void run(int[] inInt, byte[] inByte, int[] outInt, byte[] outByte, int gid) {
+        outInt[gid] = inByte[gid];
+        outByte[gid] = (byte) inInt[gid];
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seedByte, 0, inputByte, 0, seedByte.length);
+        Arrays.fill(outputByte, (byte) 0);
+        System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
+        Arrays.fill(outputInt, 0);
+        dispatchMethodKernel(64, inputInt, inputByte, outputInt, outputByte);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntCharConvertTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import java.util.*;
+import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Tests integer to char conversion.
+ */
+public class IntCharConvertTest extends GraalKernelTester {
+
+    static final int size = 128;
+    static final int[] inputInt = new int[size];
+    static final char[] inputChar = new char[size];
+    @Result static final int[] outputInt = new int[size];
+    @Result static final char[] outputChar = new char[size];
+    static int[] seedInt = new int[size];
+    {
+        for (int i = 0; i < seedInt.length; i++) {
+            seedInt[i] = (int) Math.random();
+        }
+    }
+    static char[] seedChar = new char[size];
+    {
+        for (int i = 0; i < seedChar.length; i++) {
+            seedChar[i] = (char) Math.random();
+        }
+    }
+
+    public static void run(int[] inInt, char[] inChar, int[] outInt, char[] outChar, int gid) {
+        outInt[gid] = inChar[gid];
+        outChar[gid] = (char) inInt[gid];
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seedChar, 0, inputChar, 0, seedChar.length);
+        Arrays.fill(outputChar, (char) 0);
+        System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
+        Arrays.fill(outputInt, 0);
+        dispatchMethodKernel(64, inputInt, inputChar, outputInt, outputChar);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDoubleConvertTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import java.util.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
+
+/**
+ * Tests integer to double conversion.
+ */
+public class IntDoubleConvertTest extends GraalKernelTester {
+
+    static final int size = 128;
+    static final int[] inputInt = new int[size];
+    static final double[] inputDouble = new double[size];
+    @Result static final int[] outputInt = new int[size];
+    @Result static final double[] outputDouble = new double[size];
+    static int[] seedInt = new int[size];
+    {
+        for (int i = 0; i < seedInt.length; i++) {
+            seedInt[i] = (int) Math.random();
+        }
+    }
+    static double[] seedDouble = new double[size];
+    {
+        for (int i = 0; i < seedDouble.length; i++) {
+            seedDouble[i] = Math.random();
+        }
+    }
+
+    public static void run(int[] inInt, double[] inDouble, int[] outInt, double[] outDouble, int gid) {
+        outInt[gid] = (int) inDouble[gid];
+        outDouble[gid] = inInt[gid];
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seedDouble, 0, inputDouble, 0, seedDouble.length);
+        Arrays.fill(outputDouble, 0);
+        System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
+        Arrays.fill(outputInt, 0);
+        dispatchMethodKernel(64, inputInt, inputDouble, outputInt, outputDouble);
+    }
+
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntFloatConvertTest.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntFloatConvertTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, 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
@@ -34,34 +34,34 @@
 
     static final int size = 128;
     static final int[] inputInt = new int[size];
-    static final double[] inputDouble = new double[size];
+    static final float[] inputFloat = new float[size];
     @Result static final int[] outputInt = new int[size];
-    @Result static final double[] outputDouble = new double[size];
+    @Result static final float[] outputFloat = new float[size];
     static int[] seedInt = new int[size];
     {
         for (int i = 0; i < seedInt.length; i++) {
             seedInt[i] = (int) Math.random();
         }
     }
-    static double[] seedDouble = new double[size];
+    static float[] seedFloat = new float[size];
     {
-        for (int i = 0; i < seedDouble.length; i++) {
-            seedDouble[i] = Math.random();
+        for (int i = 0; i < seedFloat.length; i++) {
+            seedFloat[i] = (float) Math.random();
         }
     }
 
-    public static void run(int[] inInt, double[] inDouble, int[] outInt, double[] outDouble, int gid) {
-        outInt[gid] = (int) inDouble[gid];
-        outDouble[gid] = inInt[gid];
+    public static void run(int[] inInt, float[] inFloat, int[] outInt, float[] outFloat, int gid) {
+        outInt[gid] = (int) inFloat[gid];
+        outFloat[gid] = inInt[gid];
     }
 
     @Override
     public void runTest() {
-        System.arraycopy(seedDouble, 0, inputDouble, 0, seedDouble.length);
-        Arrays.fill(outputDouble, 0);
+        System.arraycopy(seedFloat, 0, inputFloat, 0, seedFloat.length);
+        Arrays.fill(outputFloat, 0);
         System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
         Arrays.fill(outputInt, 0);
-        dispatchMethodKernel(64, inputInt, inputDouble, outputInt, outputDouble);
+        dispatchMethodKernel(64, inputInt, inputFloat, outputInt, outputFloat);
     }
 
     public void test() {
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLongConvertTest.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLongConvertTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2013, 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntShortConvertTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import java.util.*;
+import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Tests integer to short conversion.
+ */
+public class IntShortConvertTest extends GraalKernelTester {
+
+    static final int size = 128;
+    static final int[] inputInt = new int[size];
+    static final short[] inputShort = new short[size];
+    @Result static final int[] outputInt = new int[size];
+    @Result static final short[] outputShort = new short[size];
+    static int[] seedInt = new int[size];
+    {
+        for (int i = 0; i < seedInt.length; i++) {
+            seedInt[i] = (int) Math.random();
+        }
+    }
+    static short[] seedShort = new short[size];
+    {
+        for (int i = 0; i < seedShort.length; i++) {
+            seedShort[i] = (short) Math.random();
+        }
+    }
+
+    public static void run(int[] inInt, short[] inShort, int[] outInt, short[] outShort, int gid) {
+        outInt[gid] = inShort[gid];
+        outShort[gid] = (short) inInt[gid];
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seedShort, 0, inputShort, 0, seedShort.length);
+        Arrays.fill(outputShort, (short) 0);
+        System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
+        Arrays.fill(outputInt, 0);
+        dispatchMethodKernel(64, inputInt, inputShort, outputInt, outputShort);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseAndTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two longs.
+ */
+public class LongBitwiseAndTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected long[] outArray = new long[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(long[] out, long[] ina, long[] inb, int gid) {
+        out[gid] = (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(long[] in, long[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = i + i;
+            in2[i] = i * i;
+            outArray[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        long[] inArray = new long[num];
+        long[] inArray2 = new long[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseOrTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two longs.
+ */
+public class LongBitwiseOrTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected long[] outArray = new long[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(long[] out, long[] ina, long[] inb, int gid) {
+        out[gid] = (ina[gid] | inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(long[] in, long[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = i + 1;
+            in2[i] = i * i;
+            outArray[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        long[] inArray = new long[num];
+        long[] inArray2 = new long[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseXorTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two longs.
+ */
+public class LongBitwiseXorTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected long[] outArray = new long[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(long[] out, long[] ina, long[] inb, int gid) {
+        out[gid] = (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(long[] in, long[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = i;
+            in2[i] = i * i;
+            outArray[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        long[] inArray = new long[num];
+        long[] inArray2 = new long[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndCastTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two shorts and casts the result to a short.
+ */
+public class ShortBitwiseAndCastTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected short[] outArray1 = new short[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(short[] out1, short[] ina, short[] inb, int gid) {
+        out1[gid] = (short) (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(short[] in, short[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (short) (i + i);
+            in2[i] = (short) (i * i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        short[] inArray = new short[num];
+        short[] inArray2 = new short[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise AND of two shorts.
+ */
+public class ShortBitwiseAndTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray1 = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out1, short[] ina, short[] inb, int gid) {
+        out1[gid] = (ina[gid] & inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(short[] in, short[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (short) (i + i);
+            in2[i] = (short) (i * i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        short[] inArray = new short[num];
+        short[] inArray2 = new short[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrCastTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two shorts and casts the result to a short.
+ */
+public class ShortBitwiseOrCastTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected short[] outArray1 = new short[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(short[] out1, short[] ina, short[] inb, int gid) {
+        out1[gid] = (short) (ina[gid] | inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(short[] in, short[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (short) (i + 1);
+            in2[i] = (short) (i * i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        short[] inArray = new short[num];
+        short[] inArray2 = new short[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise OR of two shorts.
+ */
+public class ShortBitwiseOrTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray1 = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out1, short[] ina, short[] inb, int gid) {
+        out1[gid] = (ina[gid] | inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(short[] in, short[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (short) (i + 1);
+            in2[i] = (short) (i * i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        short[] inArray = new short[num];
+        short[] inArray2 = new short[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorCastTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two shorts and casts the result to a short.
+ */
+public class ShortBitwiseXorCastTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected short[] outArray1 = new short[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(short[] out1, short[] ina, short[] inb, int gid) {
+        out1[gid] = (short) (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(short[] in, short[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (short) (i);
+            in2[i] = (short) (i * i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        short[] inArray = new short[num];
+        short[] inArray2 = new short[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorTest.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2009, 2013, 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.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+/**
+ * 
+ * Tests bitwise XOR of two shorts.
+ */
+public class ShortBitwiseXorTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray1 = new int[num];
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public static void run(int[] out1, short[] ina, short[] inb, int gid) {
+        out1[gid] = (ina[gid] ^ inb[gid]);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(short[] in, short[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = (short) (i);
+            in2[i] = (short) (i * i);
+            outArray1[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        short[] inArray = new short[num];
+        short[] inArray2 = new short[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray1, inArray, inArray2);
+    }
+
+}
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java	Fri Oct 25 11:42:44 2013 +0200
@@ -461,12 +461,34 @@
 
     @Override
     public Variable emitOr(Value a, Value b) {
-        throw GraalInternalError.unimplemented();
+        Variable result = newVariable(a.getKind());
+        switch (a.getKind()) {
+            case Int:
+                append(new Op2Stack(IOR, result, a, loadNonConst(b)));
+                break;
+            case Long:
+                append(new Op2Stack(LOR, result, a, loadNonConst(b)));
+                break;
+            default:
+                throw GraalInternalError.shouldNotReachHere();
+        }
+        return result;
     }
 
     @Override
     public Variable emitXor(Value a, Value b) {
-        throw GraalInternalError.unimplemented();
+        Variable result = newVariable(a.getKind());
+        switch (a.getKind()) {
+            case Int:
+                append(new Op2Stack(IXOR, result, a, loadNonConst(b)));
+                break;
+            case Long:
+                append(new Op2Stack(LXOR, result, a, loadNonConst(b)));
+                break;
+            default:
+                throw GraalInternalError.shouldNotReachHere();
+        }
+        return result;
     }
 
     @Override
@@ -517,21 +539,43 @@
             case I2L:
                 append(new Op1Stack(I2L, result, input));
                 break;
+            case I2S:
+                append(new Op1Stack(I2S, result, input));
+                break;
+            case I2C:
+                append(new Op1Stack(I2C, result, input));
+                break;
+            case I2B:
+                append(new Op1Stack(I2B, result, input));
+                break;
             case I2D:
                 append(new Op1Stack(I2D, result, input));
                 break;
             case D2I:
                 append(new Op1Stack(D2I, result, input));
                 break;
+            case D2F:
+                append(new Op1Stack(D2F, result, input));
+                break;
+            case D2L:
+                append(new Op1Stack(D2L, result, input));
+                break;
             case L2I:
                 append(new Op1Stack(L2I, result, input));
                 break;
+            case L2F:
+                append(new Op1Stack(L2F, result, input));
+                break;
+            case L2D:
+                append(new Op1Stack(L2D, result, input));
+                break;
             case F2D:
                 append(new Op1Stack(F2D, result, input));
                 break;
-            case D2F:
-                append(new Op1Stack(D2F, result, input));
+            case F2L:
+                append(new Op1Stack(F2L, result, input));
                 break;
+
             default:
                 throw GraalInternalError.shouldNotReachHere();
         }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Fri Oct 25 11:42:44 2013 +0200
@@ -55,7 +55,7 @@
 /**
  * HotSpot AMD64 specific backend.
  */
-public class AMD64HotSpotBackend extends HotSpotBackend {
+public class AMD64HotSpotBackend extends HotSpotHostBackend {
 
     private static final Unsafe unsafe = Unsafe.getUnsafe();
 
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java	Fri Oct 25 11:42:44 2013 +0200
@@ -56,8 +56,8 @@
         HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target);
         HotSpotConstantReflectionProvider constantReflection = createConstantReflection(runtime);
         Value[] nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(runtime.getConfig(), codeCache.getRegisterConfig());
-        HotSpotForeignCallsProvider foreignCalls = createForeignCalls(runtime, metaAccess, codeCache, nativeABICallerSaveRegisters);
-        HotSpotLoweringProvider lowerer = createLowerer(runtime, metaAccess, foreignCalls);
+        HotSpotHostForeignCallsProvider foreignCalls = createForeignCalls(runtime, metaAccess, codeCache, nativeABICallerSaveRegisters);
+        HotSpotHostLoweringProvider lowerer = createLowerer(runtime, metaAccess, foreignCalls);
         // Replacements cannot have speculative optimizations since they have
         // to be valid for the entire run of the VM.
         Assumptions assumptions = new Assumptions(false);
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILCompilationResult.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILCompilationResult.java	Fri Oct 25 11:42:44 2013 +0200
@@ -85,6 +85,7 @@
         if (b == null) {
             // Fall back to a new instance
             b = new HSAILHotSpotBackendFactory().createBackend(runtime(), runtime().getHostBackend());
+            b.completeInitialization();
         }
         backend = b;
     }
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotForeignCallsProvider.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotForeignCallsProvider.java	Fri Oct 25 11:42:44 2013 +0200
@@ -25,7 +25,6 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
 
 public class HSAILHotSpotForeignCallsProvider implements HotSpotForeignCallsProvider {
@@ -55,7 +54,4 @@
     public Value[] getNativeABICallerSaveRegisters() {
         throw GraalInternalError.unimplemented();
     }
-
-    public void initialize(HotSpotProviders providers, HotSpotVMConfig config) {
-    }
 }
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLoweringProvider.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLoweringProvider.java	Fri Oct 25 11:42:44 2013 +0200
@@ -22,16 +22,13 @@
  */
 package com.oracle.graal.hotspot.hsail;
 
-import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
 
-public class HSAILHotSpotLoweringProvider implements HotSpotLoweringProvider {
+public class HSAILHotSpotLoweringProvider implements LoweringProvider {
 
     private LoweringProvider host;
 
@@ -51,11 +48,4 @@
     public ValueNode reconstructArrayIndex(LocationNode location) {
         throw GraalInternalError.unimplemented();
     }
-
-    public void initialize(HotSpotProviders providers, HotSpotVMConfig config) {
-    }
-
-    public int getScalingFactor(Kind elementKind) {
-        throw GraalInternalError.unimplemented();
-    }
 }
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java	Fri Oct 25 11:42:44 2013 +0200
@@ -40,7 +40,7 @@
         PTXHotSpotCodeCacheProvider codeCache = new PTXHotSpotCodeCacheProvider(runtime, createTarget());
         ConstantReflectionProvider constantReflection = host.getConstantReflection();
         HotSpotForeignCallsProvider foreignCalls = new PTXHotSpotForeignCallsProvider();
-        HotSpotLoweringProvider lowerer = new PTXHotSpotLoweringProvider(host.getLowerer());
+        LoweringProvider lowerer = new PTXHotSpotLoweringProvider(host.getLowerer());
         Replacements replacements = host.getReplacements();
         HotSpotDisassemblerProvider disassembler = host.getDisassembler();
         HotSpotSuitesProvider suites = host.getSuites();
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotForeignCallsProvider.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotForeignCallsProvider.java	Fri Oct 25 11:42:44 2013 +0200
@@ -25,7 +25,6 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
 
 public class PTXHotSpotForeignCallsProvider implements HotSpotForeignCallsProvider {
@@ -49,7 +48,4 @@
     public Value[] getNativeABICallerSaveRegisters() {
         throw GraalInternalError.unimplemented();
     }
-
-    public void initialize(HotSpotProviders providers, HotSpotVMConfig config) {
-    }
 }
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotLoweringProvider.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotLoweringProvider.java	Fri Oct 25 11:42:44 2013 +0200
@@ -22,16 +22,13 @@
  */
 package com.oracle.graal.hotspot.ptx;
 
-import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
 
-public class PTXHotSpotLoweringProvider implements HotSpotLoweringProvider {
+public class PTXHotSpotLoweringProvider implements LoweringProvider {
 
     private final LoweringProvider host;
 
@@ -56,11 +53,4 @@
     public ValueNode reconstructArrayIndex(LocationNode location) {
         throw GraalInternalError.unimplemented();
     }
-
-    public void initialize(HotSpotProviders providers, HotSpotVMConfig config) {
-    }
-
-    public int getScalingFactor(Kind elementKind) {
-        throw GraalInternalError.unimplemented();
-    }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Fri Oct 25 11:42:44 2013 +0200
@@ -51,7 +51,7 @@
 /**
  * HotSpot SPARC specific backend.
  */
-public class SPARCHotSpotBackend extends HotSpotBackend {
+public class SPARCHotSpotBackend extends HotSpotHostBackend {
 
     private static final Unsafe unsafe = Unsafe.getUnsafe();
 
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java	Fri Oct 25 11:42:44 2013 +0200
@@ -28,6 +28,7 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.sparc.*;
 
@@ -54,7 +55,7 @@
         HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime);
         Value[] nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(runtime.getConfig(), codeCache.getRegisterConfig());
         HotSpotForeignCallsProvider foreignCalls = new SPARCHotSpotForeignCallsProvider(runtime, metaAccess, codeCache, nativeABICallerSaveRegisters);
-        HotSpotLoweringProvider lowerer = new SPARCHotSpotLoweringProvider(runtime, metaAccess, foreignCalls);
+        LoweringProvider lowerer = new SPARCHotSpotLoweringProvider(runtime, metaAccess, foreignCalls);
         // Replacements cannot have speculative optimizations since they have
         // to be valid for the entire run of the VM.
         Assumptions assumptions = new Assumptions(false);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java	Fri Oct 25 11:42:44 2013 +0200
@@ -80,6 +80,13 @@
         return runtime;
     }
 
+    /**
+     * Performs any remaining initialization that was deferred until the {@linkplain #getRuntime()
+     * runtime} object was initialized and this backend was registered with it.
+     */
+    public void completeInitialization() {
+    }
+
     @Override
     public HotSpotProviders getProviders() {
         return (HotSpotProviders) super.getProviders();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java	Fri Oct 25 11:42:44 2013 +0200
@@ -139,17 +139,17 @@
         Class<?>[] argumentTypes = descriptor.getArgumentTypes();
         JavaType[] parameterTypes = new JavaType[argumentTypes.length];
         for (int i = 0; i < parameterTypes.length; ++i) {
-            parameterTypes[i] = asJavaType(argumentTypes[i], metaAccess);
+            parameterTypes[i] = asJavaType(argumentTypes[i], metaAccess, codeCache);
         }
         TargetDescription target = codeCache.getTarget();
-        JavaType returnType = asJavaType(descriptor.getResultType(), metaAccess);
+        JavaType returnType = asJavaType(descriptor.getResultType(), metaAccess, codeCache);
         RegisterConfig regConfig = codeCache.getRegisterConfig();
         return regConfig.getCallingConvention(ccType, returnType, parameterTypes, target, false);
     }
 
-    private static JavaType asJavaType(Class type, MetaAccessProvider metaAccess) {
+    private static JavaType asJavaType(Class type, MetaAccessProvider metaAccess, CodeCacheProvider codeCache) {
         if (WordBase.class.isAssignableFrom(type)) {
-            return metaAccess.lookupJavaType(getHostWordKind().toJavaClass());
+            return metaAccess.lookupJavaType(codeCache.getTarget().wordKind.toJavaClass());
         } else {
             return metaAccess.lookupJavaType(type);
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013, 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.hotspot;
+
+import static com.oracle.graal.phases.GraalOptions.*;
+
+import java.util.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.nodes.spi.*;
+
+/**
+ * Common functionality of HotSpot host backends.
+ */
+public abstract class HotSpotHostBackend extends HotSpotBackend {
+
+    public HotSpotHostBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) {
+        super(runtime, providers);
+    }
+
+    @Override
+    public void completeInitialization() {
+        final HotSpotProviders providers = getProviders();
+        HotSpotVMConfig config = getRuntime().getConfig();
+        HotSpotHostForeignCallsProvider foreignCalls = (HotSpotHostForeignCallsProvider) providers.getForeignCalls();
+        final HotSpotHostLoweringProvider lowerer = (HotSpotHostLoweringProvider) providers.getLowerer();
+        foreignCalls.initialize(providers, config);
+        lowerer.initialize(providers, config);
+
+        // Install intrinsics.
+        if (Intrinsify.getValue()) {
+            Debug.scope("RegisterReplacements", new Object[]{new DebugDumpScope("RegisterReplacements")}, new Runnable() {
+
+                @Override
+                public void run() {
+
+                    Replacements replacements = providers.getReplacements();
+                    ServiceLoader<ReplacementsProvider> sl = ServiceLoader.loadInstalled(ReplacementsProvider.class);
+                    for (ReplacementsProvider replacementsProvider : sl) {
+                        replacementsProvider.registerReplacements(providers.getMetaAccess(), lowerer, replacements, providers.getCodeCache().getTarget());
+                    }
+                    if (BootstrapReplacements.getValue()) {
+                        for (ResolvedJavaMethod method : replacements.getAllReplacements()) {
+                            replacements.getMacroSubstitution(method);
+                            replacements.getMethodSubstitution(method);
+                        }
+                    }
+                }
+            });
+        }
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Fri Oct 25 11:42:44 2013 +0200
@@ -48,7 +48,6 @@
 import com.oracle.graal.hotspot.phases.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.options.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.PhasePlan.PhasePosition;
@@ -180,54 +179,16 @@
             }
         }
 
-        final HotSpotProviders hostProviders = runtime.getHostProviders();
+        HotSpotBackend hostBackend = runtime.getHostBackend();
+        final HotSpotProviders hostProviders = hostBackend.getProviders();
         assert VerifyOptionsPhase.checkOptions(hostProviders.getMetaAccess(), hostProviders.getForeignCalls());
 
-        // Install intrinsics.
-        if (Intrinsify.getValue()) {
-            Debug.scope("RegisterReplacements", new Object[]{new DebugDumpScope("RegisterReplacements")}, new Runnable() {
-
-                @Override
-                public void run() {
-
-                    List<LoweringProvider> initializedLowerers = new ArrayList<>();
-                    List<ForeignCallsProvider> initializedForeignCalls = new ArrayList<>();
-
-                    for (Map.Entry<?, HotSpotBackend> e : runtime.getBackends().entrySet()) {
-                        HotSpotBackend backend = e.getValue();
-                        HotSpotProviders providers = backend.getProviders();
-
-                        HotSpotForeignCallsProvider foreignCalls = providers.getForeignCalls();
-                        if (!initializedForeignCalls.contains(foreignCalls)) {
-                            initializedForeignCalls.add(foreignCalls);
-                            foreignCalls.initialize(providers, config);
-                        }
-                        HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
-                        if (!initializedLowerers.contains(lowerer)) {
-                            initializedLowerers.add(lowerer);
-                            initializeLowerer(providers, lowerer);
-                        }
-                    }
-                }
-
-                private void initializeLowerer(HotSpotProviders providers, HotSpotLoweringProvider lowerer) {
-                    final Replacements replacements = providers.getReplacements();
-                    ServiceLoader<ReplacementsProvider> sl = ServiceLoader.loadInstalled(ReplacementsProvider.class);
-                    TargetDescription target = providers.getCodeCache().getTarget();
-                    for (ReplacementsProvider replacementsProvider : sl) {
-                        replacementsProvider.registerReplacements(providers.getMetaAccess(), lowerer, replacements, target);
-                    }
-                    lowerer.initialize(providers, config);
-                    if (BootstrapReplacements.getValue()) {
-                        for (ResolvedJavaMethod method : replacements.getAllReplacements()) {
-                            replacements.getMacroSubstitution(method);
-                            replacements.getMethodSubstitution(method);
-                            replacements.getSnippet(method);
-                        }
-                    }
-                }
-            });
-
+        // Complete initialization of backends
+        hostBackend.completeInitialization();
+        for (HotSpotBackend backend : runtime.getBackends().values()) {
+            if (backend != hostBackend) {
+                backend.completeInitialization();
+            }
         }
 
         // Create compilation queue.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotForeignCallsProvider.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotForeignCallsProvider.java	Fri Oct 25 11:42:44 2013 +0200
@@ -24,15 +24,12 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.hotspot.*;
 
 /**
  * HotSpot extension of {@link ForeignCallsProvider}.
  */
 public interface HotSpotForeignCallsProvider extends ForeignCallsProvider {
 
-    void initialize(HotSpotProviders providers, HotSpotVMConfig config);
-
     /**
      * Gets the registers that must be saved across a foreign call into the runtime.
      */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostLoweringProvider.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostLoweringProvider.java	Fri Oct 25 11:42:44 2013 +0200
@@ -57,7 +57,7 @@
 /**
  * HotSpot implementation of {@link LoweringProvider}.
  */
-public class HotSpotHostLoweringProvider implements HotSpotLoweringProvider {
+public class HotSpotHostLoweringProvider implements LoweringProvider {
 
     protected final HotSpotGraalRuntime runtime;
     protected final MetaAccessProvider metaAccess;
@@ -79,18 +79,6 @@
     }
 
     public void initialize(HotSpotProviders providers, HotSpotVMConfig config) {
-        Replacements r = providers.getReplacements();
-
-        r.registerSubstitutions(ObjectSubstitutions.class);
-        r.registerSubstitutions(SystemSubstitutions.class);
-        r.registerSubstitutions(ThreadSubstitutions.class);
-        r.registerSubstitutions(UnsafeSubstitutions.class);
-        r.registerSubstitutions(ClassSubstitutions.class);
-        r.registerSubstitutions(AESCryptSubstitutions.class);
-        r.registerSubstitutions(CipherBlockChainingSubstitutions.class);
-        r.registerSubstitutions(CRC32Substitutions.class);
-        r.registerSubstitutions(ReflectionSubstitutions.class);
-
         TargetDescription target = providers.getCodeCache().getTarget();
         checkcastDynamicSnippets = new CheckCastDynamicSnippets.Templates(providers, target);
         instanceofSnippets = new InstanceOfSnippets.Templates(providers, target);
@@ -100,8 +88,7 @@
         boxingSnippets = new BoxingSnippets.Templates(providers, target);
         exceptionObjectSnippets = new LoadExceptionObjectSnippets.Templates(providers, target);
         unsafeLoadSnippets = new UnsafeLoadSnippets.Templates(providers, target);
-
-        r.registerSnippetTemplateCache(new UnsafeArrayCopySnippets.Templates(providers, target));
+        providers.getReplacements().registerSnippetTemplateCache(new UnsafeArrayCopySnippets.Templates(providers, target));
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java	Fri Oct 25 01:39:54 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2011, 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.hotspot.meta;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.nodes.spi.*;
-
-/**
- * HotSpot extension of {@link LoweringProvider}.
- */
-public interface HotSpotLoweringProvider extends LoweringProvider {
-
-    void initialize(HotSpotProviders providers, HotSpotVMConfig config);
-
-    int getScalingFactor(Kind elementKind);
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSubstitutions.java	Fri Oct 25 11:42:44 2013 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013, 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.hotspot.replacements;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.runtime.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.replacements.*;
+
+@ServiceProvider(ReplacementsProvider.class)
+public class HotSpotSubstitutions implements ReplacementsProvider {
+
+    @Override
+    public void registerReplacements(MetaAccessProvider metaAccess, LoweringProvider loweringProvider, Replacements replacements, TargetDescription target) {
+        replacements.registerSubstitutions(ObjectSubstitutions.class);
+        replacements.registerSubstitutions(SystemSubstitutions.class);
+        replacements.registerSubstitutions(ThreadSubstitutions.class);
+        replacements.registerSubstitutions(UnsafeSubstitutions.class);
+        replacements.registerSubstitutions(ClassSubstitutions.class);
+        replacements.registerSubstitutions(AESCryptSubstitutions.class);
+        replacements.registerSubstitutions(CipherBlockChainingSubstitutions.class);
+        replacements.registerSubstitutions(CRC32Substitutions.class);
+        replacements.registerSubstitutions(ReflectionSubstitutions.class);
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Fri Oct 25 11:42:44 2013 +0200
@@ -332,7 +332,7 @@
             Kind elementKind = elementType.getKind();
             ConstantNode hub = ConstantNode.forConstant(arrayType.klass(), providers.getMetaAccess(), graph);
             final int headerSize = HotSpotGraalRuntime.getArrayBaseOffset(elementKind);
-            HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
+            HotSpotHostLoweringProvider lowerer = (HotSpotHostLoweringProvider) providers.getLowerer();
             int log2ElementSize = CodeUtil.log2(lowerer.getScalingFactor(elementKind));
 
             Arguments args = new Arguments(allocateArray, graph.getGuardsStage());
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java	Fri Oct 25 01:39:54 2013 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java	Fri Oct 25 11:42:44 2013 +0200
@@ -31,24 +31,89 @@
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 
-// @formatter:off
 /**
  * Defines arithmetic instruction nodes.
  */
 public enum HSAILArithmetic {
-    IADD, OADD, ISUB, FSUB, DSUB, IMUL, FMUL,
-    DMUL, IDIV, FDIV, DDIV, IUADD, IUSUB,
-    IUMUL, IUDIV, LADD, DADD, FADD, LSUB,
-    LMUL, LDIV, LUADD, LUSUB, LUMUL,
-    LUDIV, IMAX, LMAX, IUMAX, LUMAX,
-    IMIN, LMIN, IUMIN, LUMIN, IREM,
-    LREM, FREM, DREM, IUREM, LUREM,
-    ICARRY, LCARRY, IUCARRY, LUCARRY,
-    IAND, LAND, INEG, INOT, I2B, I2S, I2L,
-    F2D, F2I, F2L, D2F, I2F, I2D, D2I,
-    L2F, D2L, MOV_F2I, MOV_D2L, L2D, MOV_I2F,
-    MOV_L2D, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR,
-    SQRT, UNDEF, CALL, L2I;
+    IADD,
+    OADD,
+    ISUB,
+    FSUB,
+    DSUB,
+    IMUL,
+    FMUL,
+    DMUL,
+    IDIV,
+    FDIV,
+    DDIV,
+    IUADD,
+    IUSUB,
+    IUMUL,
+    IUDIV,
+    LADD,
+    DADD,
+    FADD,
+    LSUB,
+    LMUL,
+    LDIV,
+    LUADD,
+    LUSUB,
+    LUMUL,
+    LUDIV,
+    IMAX,
+    LMAX,
+    IUMAX,
+    LUMAX,
+    IMIN,
+    LMIN,
+    IUMIN,
+    LUMIN,
+    IREM,
+    LREM,
+    FREM,
+    DREM,
+    IUREM,
+    LUREM,
+    ICARRY,
+    LCARRY,
+    IUCARRY,
+    LUCARRY,
+    IAND,
+    LAND,
+    INEG,
+    INOT,
+    I2B,
+    I2S,
+    I2L,
+    I2C,
+    F2D,
+    F2I,
+    F2L,
+    D2F,
+    I2F,
+    I2D,
+    D2I,
+    L2F,
+    D2L,
+    MOV_F2I,
+    MOV_D2L,
+    L2D,
+    MOV_I2F,
+    MOV_L2D,
+    ISHL,
+    LSHL,
+    ISHR,
+    LSHR,
+    IUSHR,
+    LUSHR,
+    SQRT,
+    UNDEF,
+    CALL,
+    L2I,
+    IXOR,
+    LXOR,
+    IOR,
+    LOR;
 
     public static class Op1Stack extends HSAILLIRInstruction {
         @Opcode private final HSAILArithmetic opcode;
@@ -215,7 +280,8 @@
     @SuppressWarnings("unused")
     protected static void emit(TargetMethodAssembler tasm, HSAILAssembler masm, HSAILArithmetic opcode, Value result) {
         switch (opcode) {
-            default:   throw GraalInternalError.shouldNotReachHere();
+            default:
+                throw GraalInternalError.shouldNotReachHere();
         }
     }
 
@@ -225,19 +291,43 @@
             switch (opcode) {
                 case I2F:
                 case I2D:
-                case D2I:
                 case I2L:
-                case L2I:
+                case F2I:
                 case F2D:
-                case D2F: masm.emitConvert(dst, src); break;
-                case SQRT: masm.emitArg1("sqrt", dst, src); break;
-                case UNDEF: masm.undefined("undefined node"); break;
-                case CALL: masm.undefined("undefined node CALL"); break;
-                case INOT: masm.emitArg1("not", dst, src); break;
+                case F2L:
+                case D2I:
+                case D2L:
+                case D2F:
+                case L2I:
+                case L2F:
+                case L2D:
+                    masm.emitConvert(dst, src);
+                    break;
+                case I2S:
+                    masm.emitConvertIntToShort(dst, src);
+                    break;
+                case I2C:
+                    masm.emitConvertIntToChar(dst, src);
+                    break;
+                case I2B:
+                    masm.emitConvertIntToByte(dst, src);
+                    break;
+                case SQRT:
+                    masm.emitArg1("sqrt", dst, src);
+                    break;
+                case UNDEF:
+                    masm.undefined("undefined node");
+                    break;
+                case CALL:
+                    masm.undefined("undefined node CALL");
+                    break;
+                case INOT:
+                    masm.emitArg1("not", dst, src);
+                    break;
                 default:
                     throw GraalInternalError.shouldNotReachHere();
             }
-        }  else {
+        } else {
             throw GraalInternalError.shouldNotReachHere();
         }
         if (info != null) {
@@ -248,9 +338,8 @@
 
     public static void emit(TargetMethodAssembler tasm, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) {
         /**
-         * First check if one of src1 or src2 is an AddressValue.  If it is,
-         * convert the address to a register using an lda instruction.  We can
-         * just reuse the eventual dst register for this.
+         * First check if one of src1 or src2 is an AddressValue. If it is, convert the address to a
+         * register using an lda instruction. We can just reuse the eventual dst register for this.
          */
         if (src1 instanceof HSAILAddressValue) {
             assert (!(src2 instanceof HSAILAddressValue));
@@ -270,41 +359,64 @@
             case DADD:
             case FADD:
             case OADD:
-                masm.emit("add", dst, src1, src2); break;
+                masm.emit("add", dst, src1, src2);
+                break;
             case ISUB:
             case LSUB:
             case DSUB:
             case FSUB:
-                masm.emit("sub", dst, src1, src2); break;
+                masm.emit("sub", dst, src1, src2);
+                break;
             case IMUL:
             case LMUL:
             case FMUL:
             case DMUL:
             case LUMUL:
-                masm.emit("mul", dst, src1, src2); break;
+                masm.emit("mul", dst, src1, src2);
+                break;
             case IDIV:
             case LDIV:
             case FDIV:
             case DDIV:
-                masm.emit("div", dst, src1, src2); break;
+                masm.emit("div", dst, src1, src2);
+                break;
             case IMAX:
             case LMAX:
-                masm.emit("max", dst, src1, src2); break;
+                masm.emit("max", dst, src1, src2);
+                break;
             case IMIN:
             case LMIN:
-                masm.emit("min", dst, src1, src2); break;
+                masm.emit("min", dst, src1, src2);
+                break;
             case ISHL:
             case LSHL:
-                masm.emit("shl", dst, src1, src2); break;
+                masm.emit("shl", dst, src1, src2);
+                break;
             case ISHR:
             case LSHR:
-                masm.emit("shr", dst, src1, src2); break;
+                masm.emit("shr", dst, src1, src2);
+                break;
             case IUSHR:
             case LUSHR:
-                masm.emitForceUnsigned("shr", dst, src1, src2); break;
+                masm.emitForceUnsigned("shr", dst, src1, src2);
+                break;
+            case IAND:
+            case LAND:
+                masm.emitBitwiseLogical("and", dst, src1, src2);
+                break;
+            case IXOR:
+            case LXOR:
+                masm.emitBitwiseLogical("xor", dst, src1, src2);
+                break;
+            case IOR:
+            case LOR:
+                masm.emitBitwiseLogical("or", dst, src1, src2);
+                break;
             case IREM:
-                masm.emit("rem", dst, src1, src2); break;
-            default:    throw GraalInternalError.shouldNotReachHere();
+                masm.emit("rem", dst, src1, src2);
+                break;
+            default:
+                throw GraalInternalError.shouldNotReachHere();
         }
         if (info != null) {
             assert exceptionOffset != -1;
@@ -313,12 +425,11 @@
     }
 
     private static void verifyKind(HSAILArithmetic opcode, Value result, Value x, Value y) {
-        assert (opcode.name().startsWith("I") && result.getKind() == Kind.Int && x.getKind().getStackKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int)
-        || (opcode.name().startsWith("L") && result.getKind() == Kind.Long && x.getKind() == Kind.Long && y.getKind() == Kind.Long)
-        || (opcode.name().startsWith("LU") && result.getKind() == Kind.Long && x.getKind() == Kind.Long && y.getKind() == Kind.Int)
-        || (opcode.name().startsWith("F") && result.getKind() == Kind.Float && x.getKind() == Kind.Float && y.getKind() == Kind.Float)
-        || (opcode.name().startsWith("D") && result.getKind() == Kind.Double && x.getKind() == Kind.Double && y.getKind() == Kind.Double)
-        || (opcode.name().startsWith("O") && result.getKind() == Kind.Object && x.getKind() == Kind.Object && (y.getKind() == Kind.Int || y.getKind() == Kind.Long)
-                        );
+        assert (opcode.name().startsWith("I") && result.getKind() == Kind.Int && x.getKind().getStackKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) ||
+                        (opcode.name().startsWith("L") && result.getKind() == Kind.Long && x.getKind() == Kind.Long && y.getKind() == Kind.Long) ||
+                        (opcode.name().startsWith("LU") && result.getKind() == Kind.Long && x.getKind() == Kind.Long && y.getKind() == Kind.Int) ||
+                        (opcode.name().startsWith("F") && result.getKind() == Kind.Float && x.getKind() == Kind.Float && y.getKind() == Kind.Float) ||
+                        (opcode.name().startsWith("D") && result.getKind() == Kind.Double && x.getKind() == Kind.Double && y.getKind() == Kind.Double) ||
+                        (opcode.name().startsWith("O") && result.getKind() == Kind.Object && x.getKind() == Kind.Object && (y.getKind() == Kind.Int || y.getKind() == Kind.Long));
     }
 }