diff options
author | Nicolai Haehnle <nhaehnle@gmail.com> | 2016-03-16 20:14:33 +0000 |
---|---|---|
committer | Nicolai Haehnle <nhaehnle@gmail.com> | 2016-03-16 20:14:33 +0000 |
commit | ef160de3e5af3c8e51928fbe7b096af3d9471880 (patch) | |
tree | 26cc4963b1ef36a06537fd3413d7da3c2e844297 /llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp | |
parent | bb0cdfb9f7b79f13ce340d7571bd36b02a829792 (diff) | |
download | bcm5719-llvm-ef160de3e5af3c8e51928fbe7b096af3d9471880.tar.gz bcm5719-llvm-ef160de3e5af3c8e51928fbe7b096af3d9471880.zip |
AMDGPU: Prevent uniform loops from becoming infinite
Summary:
Uniform loops where the branch leaving the loop is predicated on VCCNZ
must be skipped if EXEC = 0, otherwise they will be infinite.
Reviewers: tstellarAMD, arsenm
Subscribers: arsenm, llvm-commits
Differential Revision: http://reviews.llvm.org/D18137
llvm-svn: 263658
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp index 7dd0d7bc8f7..2a645d15ca2 100644 --- a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp +++ b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp @@ -137,6 +137,12 @@ bool SILowerControlFlow::shouldSkip(MachineBasicBlock *From, NumInstr < SkipThreshold && I != E; ++I) { if (I->isBundle() || !I->isBundled()) + // When a uniform loop is inside non-uniform control flow, the branch + // leaving the loop might be an S_CBRANCH_VCCNZ, which is never taken + // when EXEC = 0. We should skip the loop lest it becomes infinite. + if (I->getOpcode() == AMDGPU::S_CBRANCH_VCCNZ) + return true; + if (++NumInstr >= SkipThreshold) return true; } |