AMDGPU/R600: Fix ALU clause markers use detection
authorJan Vesely <jan.vesely@rutgers.edu>
Mon, 6 Mar 2017 20:10:05 +0000 (20:10 +0000)
committerJan Vesely <jan.vesely@rutgers.edu>
Mon, 6 Mar 2017 20:10:05 +0000 (20:10 +0000)
also exit early on kill instead of redefinition.

Differential Revision: https://reviews.llvm.org/D30230

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297060 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/R600EmitClauseMarkers.cpp
test/CodeGen/AMDGPU/r600.alu-limits.ll

index 81c2152cb89ef7cd3872c7ab4c26aa7455a60faa..03fc1aff5ec1596a70de05b413da71939b3f0672 100644 (file)
@@ -196,6 +196,7 @@ private:
                         MachineBasicBlock::iterator Def,
                         MachineBasicBlock::iterator BBEnd) {
     const R600RegisterInfo &TRI = TII->getRegisterInfo();
+    //TODO: change this to defs?
     for (MachineInstr::const_mop_iterator
            MOI = Def->operands_begin(),
            MOE = Def->operands_end(); MOI != MOE; ++MOI) {
@@ -218,15 +219,17 @@ private:
         if (AluInstCount >= TII->getMaxAlusPerClause())
           return false;
 
+        // TODO: Is this true? kill flag appears to work OK below
         // Register kill flags have been cleared by the time we get to this
         // pass, but it is safe to assume that all uses of this register
         // occur in the same basic block as its definition, because
         // it is illegal for the scheduler to schedule them in
         // different blocks.
-        if (UseI->findRegisterUseOperandIdx(MOI->getReg()))
+        if (UseI->readsRegister(MOI->getReg()))
           LastUseCount = AluInstCount;
 
-        if (UseI != Def && UseI->findRegisterDefOperandIdx(MOI->getReg()) != -1)
+        // Exit early if the current use kills the register
+        if (UseI != Def && UseI->killsRegister(MOI->getReg()))
           break;
       }
       if (LastUseCount)
index 1f8a0e6588f3fca95e06d70b481f0036165f7204..c5b89343616fc98a596ae0f3c6a004bc48ebc461 100644 (file)
@@ -1,8 +1,8 @@
 ; RUN: opt -loop-unroll -unroll-threshold=2000 -S < %s | llc -march=r600 -mcpu=cypress | FileCheck %s
-; XFAIL: *
 ; REQUIRES: asserts
 
-; CHECK: {{^}}@alu_limits:
+; CHECK: {{^}}alu_limits:
+; CHECK: CF_END
 
 %struct.foo = type {i32, i32, i32}