Mercurial > hg > truffle
changeset 13793:e99fccb03926
Fix incorrect code generation for conditional branch instructions. Reenable ControlPTXTest.
author | S.Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com> |
---|---|
date | Tue, 28 Jan 2014 21:37:29 -0500 |
parents | 9e7acc9cad8e |
children | 2eb56f87b01e |
files | graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java |
diffstat | 3 files changed, 21 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java Tue Jan 28 23:38:22 2014 +0100 +++ b/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java Tue Jan 28 21:37:29 2014 -0500 @@ -397,13 +397,17 @@ } // Checkstyle: stop method name check - public final void bra(String tgt, int pred) { + /* + * Emit conditional branch to target 'tgt' guarded by predicate register 'pred' whose state is + * tested to be 'predCheck'. + */ + public final void bra(String tgt, int pred, boolean predCheck) { assert pred >= 0; if (tgt.equals("?")) { Thread.dumpStack(); } - emitString("@%p" + pred + " " + "bra" + " " + tgt + ";"); + emitString("@" + (predCheck ? "%p" : "!%p") + pred + " " + "bra" + " " + tgt + ";"); } public final void bra(String src) {
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java Tue Jan 28 23:38:22 2014 +0100 +++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java Tue Jan 28 21:37:29 2014 -0500 @@ -26,18 +26,26 @@ public class ControlPTXTest extends PTXTest { - @Ignore("[CUDA] *** Error (status=702): Synchronize kernel") @Test - public void testControl() { + public void testControl1() { test("testLoop", 42); test("testSwitchDefault1I", 3); test("testSwitch1I", 2); test("testIfElse1I", 222); test("testIfElse2I", 19, 64); + } - test("testIntegerTestBranch2I", 0xff00, 0x00ff); + @Test + public void testControl2() { compileKernel("testStatic"); compileKernel("testCall"); + } + + @Ignore("[CUDA] Check for malformed PTX kernel or incorrect PTX compilation options") + @Test + public void testControl3() { + // test("testIntegerTestBranch2I", 0xff00, 0x00ff); + compileKernel("testIntegerTestBranch2I"); compileKernel("testLookupSwitch1I"); }
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Tue Jan 28 23:38:22 2014 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Tue Jan 28 21:37:29 2014 -0500 @@ -86,9 +86,9 @@ @Override public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { if (crb.isSuccessorEdge(trueDestination)) { - masm.bra(masm.nameOf(falseDestination.label()), predRegNum); + masm.bra(masm.nameOf(falseDestination.label()), predRegNum, false); } else { - masm.bra(masm.nameOf(trueDestination.label())); + masm.bra(masm.nameOf(trueDestination.label()), predRegNum, true); if (!crb.isSuccessorEdge(falseDestination)) { masm.jmp(falseDestination.label()); } @@ -238,7 +238,7 @@ default: throw new GraalInternalError("switch only supported for int, long and object"); } - masm.bra(masm.nameOf(target), predRegNum); + masm.bra(masm.nameOf(target), predRegNum, true); } }; strategy.run(closure); @@ -281,7 +281,7 @@ // Jump to default target if index is not within the jump table if (defaultTarget != null) { - masm.bra(masm.nameOf(defaultTarget.label()), predRegNum); + masm.bra(masm.nameOf(defaultTarget.label()), predRegNum, true); } // address of jump table