Index: lib/Target/AMDGPU/R600EmitClauseMarkers.cpp =================================================================== --- lib/Target/AMDGPU/R600EmitClauseMarkers.cpp +++ lib/Target/AMDGPU/R600EmitClauseMarkers.cpp @@ -196,6 +196,7 @@ 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,18 @@ 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->findRegisterUseOperandIdx(MOI->getReg()) != -1) { LastUseCount = AluInstCount; + } - if (UseI != Def && UseI->findRegisterDefOperandIdx(MOI->getReg()) != -1) + // Exit early if the current use kills the register + if (UseI != Def && UseI->findRegisterUseOperandIdx(MOI->getReg(), true) != -1) break; } if (LastUseCount) Index: test/CodeGen/AMDGPU/r600.alu-limits.ll =================================================================== --- test/CodeGen/AMDGPU/r600.alu-limits.ll +++ test/CodeGen/AMDGPU/r600.alu-limits.ll @@ -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}