[llvm] r199917 - R600: Correctly handle vertex fetch clauses the precede ENDIFs

Tom Stellard thomas.stellard at amd.com
Thu Jan 23 10:49:31 PST 2014


Author: tstellar
Date: Thu Jan 23 12:49:31 2014
New Revision: 199917

URL: http://llvm.org/viewvc/llvm-project?rev=199917&view=rev
Log:
R600: Correctly handle vertex fetch clauses the precede ENDIFs

The control flow finalizer would sometimes use an ALU_POP_AFTER
instruction before the vetex fetch clause instead of using a POP
instruction after it.

Added:
    llvm/trunk/test/CodeGen/R600/vtx-fetch-branch.ll
Modified:
    llvm/trunk/lib/Target/R600/R600ControlFlowFinalizer.cpp

Modified: llvm/trunk/lib/Target/R600/R600ControlFlowFinalizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/R600ControlFlowFinalizer.cpp?rev=199917&r1=199916&r2=199917&view=diff
==============================================================================
--- llvm/trunk/lib/Target/R600/R600ControlFlowFinalizer.cpp (original)
+++ llvm/trunk/lib/Target/R600/R600ControlFlowFinalizer.cpp Thu Jan 23 12:49:31 2014
@@ -501,6 +501,7 @@ public:
           DEBUG(dbgs() << CfCount << ":"; I->dump(););
           FetchClauses.push_back(MakeFetchClause(MBB, I));
           CfCount++;
+          LastAlu.back() = 0;
           continue;
         }
 

Added: llvm/trunk/test/CodeGen/R600/vtx-fetch-branch.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/R600/vtx-fetch-branch.ll?rev=199917&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/R600/vtx-fetch-branch.ll (added)
+++ llvm/trunk/test/CodeGen/R600/vtx-fetch-branch.ll Thu Jan 23 12:49:31 2014
@@ -0,0 +1,29 @@
+; RUN: llc -march=r600 -mcpu=redwood %s -o - | FileCheck %s
+
+; This tests for a bug where vertex fetch clauses right before an ENDIF
+; instruction where being emitted after the ENDIF.  We were using ALU_POP_AFTER
+; for the ALU clause before the vetex fetch instead of emitting a POP instruction
+; after the fetch clause.
+
+
+; CHECK-LABEL: @test
+; CHECK-NOT: ALU_POP_AFTER
+; CHECK: TEX
+; CHECK-NEXT: POP
+define void @test(i32 addrspace(1)* %out, i32 addrspace(1)* %in, i32 %cond) {
+entry:
+  %0 = icmp eq i32 %cond, 0
+  br i1 %0, label %endif, label %if
+
+if:
+  %1 = load i32 addrspace(1)* %in
+  br label %endif
+
+endif:
+  %x = phi i32 [ %1, %if], [ 0, %entry]
+  store i32 %x, i32 addrspace(1)* %out
+  br label %done
+
+done:
+  ret void
+}





More information about the llvm-commits mailing list