changeset 12582:a5a4a0bcd863

Adds support to the HSAIL backend for three of the bitwise logical operators, bitwise AND, bitwise OR and bitwise XOR. Contributed-by: Vasanth Venkatachalam <Vasanth.Venkatachalam@amd.com>
author twisti
date Thu, 24 Oct 2013 19:21:43 -0700
parents 8fde330c11cd
children 110c3faa57e9 80bbaf87fc89
files graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleLongConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatDoubleConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatLongConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseAndTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseOrTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseXorTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntByteConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntCharConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDoubleConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntFloatConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLongConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntShortConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseAndTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseOrTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseXorTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorTest.java graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java
diffstat 49 files changed, 3183 insertions(+), 62 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:26:27 2013 +0200
+++ b/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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:26:27 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatConvertTest.java	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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:26:27 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntFloatConvertTest.java	Thu Oct 24 19:21:43 2013 -0700
@@ -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:26:27 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLongConvertTest.java	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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	Thu Oct 24 19:21:43 2013 -0700
@@ -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:26:27 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java	Thu Oct 24 19:21:43 2013 -0700
@@ -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.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java	Fri Oct 25 01:26:27 2013 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java	Thu Oct 24 19:21:43 2013 -0700
@@ -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));
     }
 }